function su(n) {
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
}
/**
 * @license
 * Copyright 2010-2023 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
const _a = "163", en = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }, fi = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, Hh = 0, Fs = 1, Vh = 2, cu = 1, Gh = 2, _n = 3, Hn = 0, wt = 1, bn = 2, En = 0, Ni = 1, Bs = 2, ks = 3, zs = 4, Wh = 5, ii = 100, jh = 101, Xh = 102, $h = 103, qh = 104, Yh = 200, Kh = 201, Zh = 202, Jh = 203, Io = 204, No = 205, Qh = 206, ef = 207, tf = 208, nf = 209, rf = 210, af = 211, of = 212, sf = 213, cf = 214, lf = 0, uf = 1, hf = 2, aa = 3, ff = 4, df = 5, pf = 6, mf = 7, os = 0, gf = 1, vf = 2, kn = 0, _f = 1, yf = 2, xf = 3, bf = 4, Mf = 5, Sf = 6, Ef = 7, lu = 300, Bi = 301, ki = 302, Uo = 303, Fo = 304, ya = 306, Bo = 1e3, ai = 1001, ko = 1002, Ht = 1003, wf = 1004, Tr = 1005, Yt = 1006, Ua = 1007, oi = 1008, zn = 1009, Tf = 1010, Af = 1011, uu = 1012, hu = 1013, zi = 1014, Bn = 1015, pr = 1016, fu = 1017, du = 1018, br = 1020, Cf = 35902, Rf = 1021, Pf = 1022, rn = 1023, Lf = 1024, Df = 1025, Ui = 1026, mr = 1027, Of = 1028, pu = 1029, If = 1030, mu = 1031, gu = 1033, Fa = 33776, Ba = 33777, ka = 33778, za = 33779, Hs = 35840, Vs = 35841, Gs = 35842, Ws = 35843, vu = 36196, js = 37492, Xs = 37496, $s = 37808, qs = 37809, Ys = 37810, Ks = 37811, Zs = 37812, Js = 37813, Qs = 37814, ec = 37815, tc = 37816, nc = 37817, ic = 37818, rc = 37819, ac = 37820, oc = 37821, Ha = 36492, sc = 36494, cc = 36495, Nf = 36283, lc = 36284, uc = 36285, hc = 36286, Uf = 3200, Ff = 3201, _u = 0, Bf = 1, Fn = "", $t = "srgb", Gn = "srgb-linear", ss = "display-p3", xa = "display-p3-linear", oa = "linear", Qe = "srgb", sa = "rec709", ca = "p3", di = 7680, fc = 519, kf = 512, zf = 513, Hf = 514, yu = 515, Vf = 516, Gf = 517, Wf = 518, jf = 519, dc = 35044, pc = "300 es", Mn = 2e3, la = 2001;
class Qt {
  addEventListener(e, t) {
    this._listeners === void 0 && (this._listeners = {});
    const i = this._listeners;
    i[e] === void 0 && (i[e] = []), i[e].indexOf(t) === -1 && i[e].push(t);
  }
  hasEventListener(e, t) {
    if (this._listeners === void 0)
      return !1;
    const i = this._listeners;
    return i[e] !== void 0 && i[e].indexOf(t) !== -1;
  }
  removeEventListener(e, t) {
    if (this._listeners === void 0)
      return;
    const r = this._listeners[e];
    if (r !== void 0) {
      const a = r.indexOf(t);
      a !== -1 && r.splice(a, 1);
    }
  }
  dispatchEvent(e) {
    if (this._listeners === void 0)
      return;
    const i = this._listeners[e.type];
    if (i !== void 0) {
      e.target = this;
      const r = i.slice(0);
      for (let a = 0, o = r.length; a < o; a++)
        r[a].call(this, e);
      e.target = null;
    }
  }
}
const yt = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
let mc = 1234567;
const ur = Math.PI / 180, gr = 180 / Math.PI;
function Gi() {
  const n = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, i = Math.random() * 4294967295 | 0;
  return (yt[n & 255] + yt[n >> 8 & 255] + yt[n >> 16 & 255] + yt[n >> 24 & 255] + "-" + yt[e & 255] + yt[e >> 8 & 255] + "-" + yt[e >> 16 & 15 | 64] + yt[e >> 24 & 255] + "-" + yt[t & 63 | 128] + yt[t >> 8 & 255] + "-" + yt[t >> 16 & 255] + yt[t >> 24 & 255] + yt[i & 255] + yt[i >> 8 & 255] + yt[i >> 16 & 255] + yt[i >> 24 & 255]).toLowerCase();
}
function mt(n, e, t) {
  return Math.max(e, Math.min(t, n));
}
function cs(n, e) {
  return (n % e + e) % e;
}
function Xf(n, e, t, i, r) {
  return i + (n - e) * (r - i) / (t - e);
}
function $f(n, e, t) {
  return n !== e ? (t - n) / (e - n) : 0;
}
function hr(n, e, t) {
  return (1 - t) * n + t * e;
}
function qf(n, e, t, i) {
  return hr(n, e, 1 - Math.exp(-t * i));
}
function Yf(n, e = 1) {
  return e - Math.abs(cs(n, e * 2) - e);
}
function Kf(n, e, t) {
  return n <= e ? 0 : n >= t ? 1 : (n = (n - e) / (t - e), n * n * (3 - 2 * n));
}
function Zf(n, e, t) {
  return n <= e ? 0 : n >= t ? 1 : (n = (n - e) / (t - e), n * n * n * (n * (n * 6 - 15) + 10));
}
function Jf(n, e) {
  return n + Math.floor(Math.random() * (e - n + 1));
}
function Qf(n, e) {
  return n + Math.random() * (e - n);
}
function ed(n) {
  return n * (0.5 - Math.random());
}
function td(n) {
  n !== void 0 && (mc = n);
  let e = mc += 1831565813;
  return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
}
function nd(n) {
  return n * ur;
}
function id(n) {
  return n * gr;
}
function rd(n) {
  return (n & n - 1) === 0 && n !== 0;
}
function ad(n) {
  return Math.pow(2, Math.ceil(Math.log(n) / Math.LN2));
}
function od(n) {
  return Math.pow(2, Math.floor(Math.log(n) / Math.LN2));
}
function sd(n, e, t, i, r) {
  const a = Math.cos, o = Math.sin, s = a(t / 2), c = o(t / 2), l = a((e + i) / 2), u = o((e + i) / 2), h = a((e - i) / 2), d = o((e - i) / 2), p = a((i - e) / 2), g = o((i - e) / 2);
  switch (r) {
    case "XYX":
      n.set(s * u, c * h, c * d, s * l);
      break;
    case "YZY":
      n.set(c * d, s * u, c * h, s * l);
      break;
    case "ZXZ":
      n.set(c * h, c * d, s * u, s * l);
      break;
    case "XZX":
      n.set(s * u, c * g, c * p, s * l);
      break;
    case "YXY":
      n.set(c * p, s * u, c * g, s * l);
      break;
    case "ZYZ":
      n.set(c * g, c * p, s * u, s * l);
      break;
    default:
      console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + r);
  }
}
function Li(n, e) {
  switch (e.constructor) {
    case Float32Array:
      return n;
    case Uint32Array:
      return n / 4294967295;
    case Uint16Array:
      return n / 65535;
    case Uint8Array:
      return n / 255;
    case Int32Array:
      return Math.max(n / 2147483647, -1);
    case Int16Array:
      return Math.max(n / 32767, -1);
    case Int8Array:
      return Math.max(n / 127, -1);
    default:
      throw new Error("Invalid component type.");
  }
}
function Mt(n, e) {
  switch (e.constructor) {
    case Float32Array:
      return n;
    case Uint32Array:
      return Math.round(n * 4294967295);
    case Uint16Array:
      return Math.round(n * 65535);
    case Uint8Array:
      return Math.round(n * 255);
    case Int32Array:
      return Math.round(n * 2147483647);
    case Int16Array:
      return Math.round(n * 32767);
    case Int8Array:
      return Math.round(n * 127);
    default:
      throw new Error("Invalid component type.");
  }
}
const zo = {
  DEG2RAD: ur,
  RAD2DEG: gr,
  generateUUID: Gi,
  clamp: mt,
  euclideanModulo: cs,
  mapLinear: Xf,
  inverseLerp: $f,
  lerp: hr,
  damp: qf,
  pingpong: Yf,
  smoothstep: Kf,
  smootherstep: Zf,
  randInt: Jf,
  randFloat: Qf,
  randFloatSpread: ed,
  seededRandom: td,
  degToRad: nd,
  radToDeg: id,
  isPowerOfTwo: rd,
  ceilPowerOfTwo: ad,
  floorPowerOfTwo: od,
  setQuaternionFromProperEuler: sd,
  normalize: Mt,
  denormalize: Li
};
class le {
  constructor(e = 0, t = 0) {
    le.prototype.isVector2 = !0, this.x = e, this.y = t;
  }
  get width() {
    return this.x;
  }
  set width(e) {
    this.x = e;
  }
  get height() {
    return this.y;
  }
  set height(e) {
    this.y = e;
  }
  set(e, t) {
    return this.x = e, this.y = t, this;
  }
  setScalar(e) {
    return this.x = e, this.y = e, this;
  }
  setX(e) {
    return this.x = e, this;
  }
  setY(e) {
    return this.y = e, this;
  }
  setComponent(e, t) {
    switch (e) {
      case 0:
        this.x = t;
        break;
      case 1:
        this.y = t;
        break;
      default:
        throw new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this;
  }
  divide(e) {
    return this.x /= e.x, this.y /= e.y, this;
  }
  divideScalar(e) {
    return this.multiplyScalar(1 / e);
  }
  applyMatrix3(e) {
    const t = this.x, i = this.y, r = e.elements;
    return this.x = r[0] * t + r[3] * i + r[6], this.y = r[1] * t + r[4] * i + r[7], this;
  }
  min(e) {
    return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this;
  }
  max(e) {
    return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this;
  }
  clamp(e, t) {
    return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this;
  }
  clampLength(e, t) {
    const i = this.length();
    return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this;
  }
  dot(e) {
    return this.x * e.x + this.y * e.y;
  }
  cross(e) {
    return this.x * e.y - this.y * e.x;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  angle() {
    return Math.atan2(-this.y, -this.x) + Math.PI;
  }
  angleTo(e) {
    const t = Math.sqrt(this.lengthSq() * e.lengthSq());
    if (t === 0)
      return Math.PI / 2;
    const i = this.dot(e) / t;
    return Math.acos(mt(i, -1, 1));
  }
  distanceTo(e) {
    return Math.sqrt(this.distanceToSquared(e));
  }
  distanceToSquared(e) {
    const t = this.x - e.x, i = this.y - e.y;
    return t * t + i * i;
  }
  manhattanDistanceTo(e) {
    return Math.abs(this.x - e.x) + Math.abs(this.y - e.y);
  }
  setLength(e) {
    return this.normalize().multiplyScalar(e);
  }
  lerp(e, t) {
    return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this;
  }
  lerpVectors(e, t, i) {
    return this.x = e.x + (t.x - e.x) * i, this.y = e.y + (t.y - e.y) * i, this;
  }
  equals(e) {
    return e.x === this.x && e.y === this.y;
  }
  fromArray(e, t = 0) {
    return this.x = e[t], this.y = e[t + 1], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.x, e[t + 1] = this.y, e;
  }
  fromBufferAttribute(e, t) {
    return this.x = e.getX(t), this.y = e.getY(t), this;
  }
  rotateAround(e, t) {
    const i = Math.cos(t), r = Math.sin(t), a = this.x - e.x, o = this.y - e.y;
    return this.x = a * i - o * r + e.x, this.y = a * r + o * i + e.y, this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y;
  }
}
class Fe {
  constructor(e, t, i, r, a, o, s, c, l) {
    Fe.prototype.isMatrix3 = !0, this.elements = [
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ], e !== void 0 && this.set(e, t, i, r, a, o, s, c, l);
  }
  set(e, t, i, r, a, o, s, c, l) {
    const u = this.elements;
    return u[0] = e, u[1] = r, u[2] = s, u[3] = t, u[4] = a, u[5] = c, u[6] = i, u[7] = o, u[8] = l, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ), this;
  }
  copy(e) {
    const t = this.elements, i = e.elements;
    return t[0] = i[0], t[1] = i[1], t[2] = i[2], t[3] = i[3], t[4] = i[4], t[5] = i[5], t[6] = i[6], t[7] = i[7], t[8] = i[8], this;
  }
  extractBasis(e, t, i) {
    return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), i.setFromMatrix3Column(this, 2), this;
  }
  setFromMatrix4(e) {
    const t = e.elements;
    return this.set(
      t[0],
      t[4],
      t[8],
      t[1],
      t[5],
      t[9],
      t[2],
      t[6],
      t[10]
    ), this;
  }
  multiply(e) {
    return this.multiplyMatrices(this, e);
  }
  premultiply(e) {
    return this.multiplyMatrices(e, this);
  }
  multiplyMatrices(e, t) {
    const i = e.elements, r = t.elements, a = this.elements, o = i[0], s = i[3], c = i[6], l = i[1], u = i[4], h = i[7], d = i[2], p = i[5], g = i[8], v = r[0], m = r[3], f = r[6], M = r[1], _ = r[4], x = r[7], T = r[2], E = r[5], A = r[8];
    return a[0] = o * v + s * M + c * T, a[3] = o * m + s * _ + c * E, a[6] = o * f + s * x + c * A, a[1] = l * v + u * M + h * T, a[4] = l * m + u * _ + h * E, a[7] = l * f + u * x + h * A, a[2] = d * v + p * M + g * T, a[5] = d * m + p * _ + g * E, a[8] = d * f + p * x + g * A, this;
  }
  multiplyScalar(e) {
    const t = this.elements;
    return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, this;
  }
  determinant() {
    const e = this.elements, t = e[0], i = e[1], r = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8];
    return t * o * u - t * s * l - i * a * u + i * s * c + r * a * l - r * o * c;
  }
  invert() {
    const e = this.elements, t = e[0], i = e[1], r = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8], h = u * o - s * l, d = s * c - u * a, p = l * a - o * c, g = t * h + i * d + r * p;
    if (g === 0)
      return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
    const v = 1 / g;
    return e[0] = h * v, e[1] = (r * l - u * i) * v, e[2] = (s * i - r * o) * v, e[3] = d * v, e[4] = (u * t - r * c) * v, e[5] = (r * a - s * t) * v, e[6] = p * v, e[7] = (i * c - l * t) * v, e[8] = (o * t - i * a) * v, this;
  }
  transpose() {
    let e;
    const t = this.elements;
    return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this;
  }
  getNormalMatrix(e) {
    return this.setFromMatrix4(e).invert().transpose();
  }
  transposeIntoArray(e) {
    const t = this.elements;
    return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this;
  }
  setUvTransform(e, t, i, r, a, o, s) {
    const c = Math.cos(a), l = Math.sin(a);
    return this.set(
      i * c,
      i * l,
      -i * (c * o + l * s) + o + e,
      -r * l,
      r * c,
      -r * (-l * o + c * s) + s + t,
      0,
      0,
      1
    ), this;
  }
  //
  scale(e, t) {
    return this.premultiply(Va.makeScale(e, t)), this;
  }
  rotate(e) {
    return this.premultiply(Va.makeRotation(-e)), this;
  }
  translate(e, t) {
    return this.premultiply(Va.makeTranslation(e, t)), this;
  }
  // for 2D Transforms
  makeTranslation(e, t) {
    return e.isVector2 ? this.set(
      1,
      0,
      e.x,
      0,
      1,
      e.y,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      e,
      0,
      1,
      t,
      0,
      0,
      1
    ), this;
  }
  makeRotation(e) {
    const t = Math.cos(e), i = Math.sin(e);
    return this.set(
      t,
      -i,
      0,
      i,
      t,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(e, t) {
    return this.set(
      e,
      0,
      0,
      0,
      t,
      0,
      0,
      0,
      1
    ), this;
  }
  //
  equals(e) {
    const t = this.elements, i = e.elements;
    for (let r = 0; r < 9; r++)
      if (t[r] !== i[r])
        return !1;
    return !0;
  }
  fromArray(e, t = 0) {
    for (let i = 0; i < 9; i++)
      this.elements[i] = e[i + t];
    return this;
  }
  toArray(e = [], t = 0) {
    const i = this.elements;
    return e[t] = i[0], e[t + 1] = i[1], e[t + 2] = i[2], e[t + 3] = i[3], e[t + 4] = i[4], e[t + 5] = i[5], e[t + 6] = i[6], e[t + 7] = i[7], e[t + 8] = i[8], e;
  }
  clone() {
    return new this.constructor().fromArray(this.elements);
  }
}
const Va = /* @__PURE__ */ new Fe();
function xu(n) {
  for (let e = n.length - 1; e >= 0; --e)
    if (n[e] >= 65535)
      return !0;
  return !1;
}
function vr(n) {
  return document.createElementNS("http://www.w3.org/1999/xhtml", n);
}
function cd() {
  const n = vr("canvas");
  return n.style.display = "block", n;
}
const gc = {};
function ld(n) {
  n in gc || (gc[n] = !0, console.warn(n));
}
const vc = /* @__PURE__ */ new Fe().set(
  0.8224621,
  0.177538,
  0,
  0.0331941,
  0.9668058,
  0,
  0.0170827,
  0.0723974,
  0.9105199
), _c = /* @__PURE__ */ new Fe().set(
  1.2249401,
  -0.2249404,
  0,
  -0.0420569,
  1.0420571,
  0,
  -0.0196376,
  -0.0786361,
  1.0982735
), Ar = {
  [Gn]: {
    transfer: oa,
    primaries: sa,
    toReference: (n) => n,
    fromReference: (n) => n
  },
  [$t]: {
    transfer: Qe,
    primaries: sa,
    toReference: (n) => n.convertSRGBToLinear(),
    fromReference: (n) => n.convertLinearToSRGB()
  },
  [xa]: {
    transfer: oa,
    primaries: ca,
    toReference: (n) => n.applyMatrix3(_c),
    fromReference: (n) => n.applyMatrix3(vc)
  },
  [ss]: {
    transfer: Qe,
    primaries: ca,
    toReference: (n) => n.convertSRGBToLinear().applyMatrix3(_c),
    fromReference: (n) => n.applyMatrix3(vc).convertLinearToSRGB()
  }
}, ud = /* @__PURE__ */ new Set([Gn, xa]), Ke = {
  enabled: !0,
  _workingColorSpace: Gn,
  get workingColorSpace() {
    return this._workingColorSpace;
  },
  set workingColorSpace(n) {
    if (!ud.has(n))
      throw new Error(`Unsupported working color space, "${n}".`);
    this._workingColorSpace = n;
  },
  convert: function(n, e, t) {
    if (this.enabled === !1 || e === t || !e || !t)
      return n;
    const i = Ar[e].toReference, r = Ar[t].fromReference;
    return r(i(n));
  },
  fromWorkingColorSpace: function(n, e) {
    return this.convert(n, this._workingColorSpace, e);
  },
  toWorkingColorSpace: function(n, e) {
    return this.convert(n, e, this._workingColorSpace);
  },
  getPrimaries: function(n) {
    return Ar[n].primaries;
  },
  getTransfer: function(n) {
    return n === Fn ? oa : Ar[n].transfer;
  }
};
function Fi(n) {
  return n < 0.04045 ? n * 0.0773993808 : Math.pow(n * 0.9478672986 + 0.0521327014, 2.4);
}
function Ga(n) {
  return n < 31308e-7 ? n * 12.92 : 1.055 * Math.pow(n, 0.41666) - 0.055;
}
let pi;
class hd {
  static getDataURL(e) {
    if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u")
      return e.src;
    let t;
    if (e instanceof HTMLCanvasElement)
      t = e;
    else {
      pi === void 0 && (pi = vr("canvas")), pi.width = e.width, pi.height = e.height;
      const i = pi.getContext("2d");
      e instanceof ImageData ? i.putImageData(e, 0, 0) : i.drawImage(e, 0, 0, e.width, e.height), t = pi;
    }
    return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", 0.6)) : t.toDataURL("image/png");
  }
  static sRGBToLinear(e) {
    if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) {
      const t = vr("canvas");
      t.width = e.width, t.height = e.height;
      const i = t.getContext("2d");
      i.drawImage(e, 0, 0, e.width, e.height);
      const r = i.getImageData(0, 0, e.width, e.height), a = r.data;
      for (let o = 0; o < a.length; o++)
        a[o] = Fi(a[o] / 255) * 255;
      return i.putImageData(r, 0, 0), t;
    } else if (e.data) {
      const t = e.data.slice(0);
      for (let i = 0; i < t.length; i++)
        t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[i] = Math.floor(Fi(t[i] / 255) * 255) : t[i] = Fi(t[i]);
      return {
        data: t,
        width: e.width,
        height: e.height
      };
    } else
      return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e;
  }
}
let fd = 0;
class bu {
  constructor(e = null) {
    this.isSource = !0, Object.defineProperty(this, "id", { value: fd++ }), this.uuid = Gi(), this.data = e, this.dataReady = !0, this.version = 0;
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    if (!t && e.images[this.uuid] !== void 0)
      return e.images[this.uuid];
    const i = {
      uuid: this.uuid,
      url: ""
    }, r = this.data;
    if (r !== null) {
      let a;
      if (Array.isArray(r)) {
        a = [];
        for (let o = 0, s = r.length; o < s; o++)
          r[o].isDataTexture ? a.push(Wa(r[o].image)) : a.push(Wa(r[o]));
      } else
        a = Wa(r);
      i.url = a;
    }
    return t || (e.images[this.uuid] = i), i;
  }
}
function Wa(n) {
  return typeof HTMLImageElement < "u" && n instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && n instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && n instanceof ImageBitmap ? hd.getDataURL(n) : n.data ? {
    data: Array.from(n.data),
    width: n.width,
    height: n.height,
    type: n.data.constructor.name
  } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
}
let dd = 0;
class Tt extends Qt {
  constructor(e = Tt.DEFAULT_IMAGE, t = Tt.DEFAULT_MAPPING, i = ai, r = ai, a = Yt, o = oi, s = rn, c = zn, l = Tt.DEFAULT_ANISOTROPY, u = Fn) {
    super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: dd++ }), this.uuid = Gi(), this.name = "", this.source = new bu(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = i, this.wrapT = r, this.magFilter = a, this.minFilter = o, this.anisotropy = l, this.format = s, this.internalFormat = null, this.type = c, this.offset = new le(0, 0), this.repeat = new le(1, 1), this.center = new le(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new Fe(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = u, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0;
  }
  get image() {
    return this.source.data;
  }
  set image(e = null) {
    this.source.data = e;
  }
  updateMatrix() {
    this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.name = e.name, this.source = e.source, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.channel = e.channel, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.colorSpace = e.colorSpace, this.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this;
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    if (!t && e.textures[this.uuid] !== void 0)
      return e.textures[this.uuid];
    const i = {
      metadata: {
        version: 4.6,
        type: "Texture",
        generator: "Texture.toJSON"
      },
      uuid: this.uuid,
      name: this.name,
      image: this.source.toJSON(e).uuid,
      mapping: this.mapping,
      channel: this.channel,
      repeat: [this.repeat.x, this.repeat.y],
      offset: [this.offset.x, this.offset.y],
      center: [this.center.x, this.center.y],
      rotation: this.rotation,
      wrap: [this.wrapS, this.wrapT],
      format: this.format,
      internalFormat: this.internalFormat,
      type: this.type,
      colorSpace: this.colorSpace,
      minFilter: this.minFilter,
      magFilter: this.magFilter,
      anisotropy: this.anisotropy,
      flipY: this.flipY,
      generateMipmaps: this.generateMipmaps,
      premultiplyAlpha: this.premultiplyAlpha,
      unpackAlignment: this.unpackAlignment
    };
    return Object.keys(this.userData).length > 0 && (i.userData = this.userData), t || (e.textures[this.uuid] = i), i;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  transformUv(e) {
    if (this.mapping !== lu)
      return e;
    if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)
      switch (this.wrapS) {
        case Bo:
          e.x = e.x - Math.floor(e.x);
          break;
        case ai:
          e.x = e.x < 0 ? 0 : 1;
          break;
        case ko:
          Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x);
          break;
      }
    if (e.y < 0 || e.y > 1)
      switch (this.wrapT) {
        case Bo:
          e.y = e.y - Math.floor(e.y);
          break;
        case ai:
          e.y = e.y < 0 ? 0 : 1;
          break;
        case ko:
          Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y);
          break;
      }
    return this.flipY && (e.y = 1 - e.y), e;
  }
  set needsUpdate(e) {
    e === !0 && (this.version++, this.source.needsUpdate = !0);
  }
  set needsPMREMUpdate(e) {
    e === !0 && this.pmremVersion++;
  }
}
Tt.DEFAULT_IMAGE = null;
Tt.DEFAULT_MAPPING = lu;
Tt.DEFAULT_ANISOTROPY = 1;
class gt {
  constructor(e = 0, t = 0, i = 0, r = 1) {
    gt.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = i, this.w = r;
  }
  get width() {
    return this.z;
  }
  set width(e) {
    this.z = e;
  }
  get height() {
    return this.w;
  }
  set height(e) {
    this.w = e;
  }
  set(e, t, i, r) {
    return this.x = e, this.y = t, this.z = i, this.w = r, this;
  }
  setScalar(e) {
    return this.x = e, this.y = e, this.z = e, this.w = e, this;
  }
  setX(e) {
    return this.x = e, this;
  }
  setY(e) {
    return this.y = e, this;
  }
  setZ(e) {
    return this.z = e, this;
  }
  setW(e) {
    return this.w = e, this;
  }
  setComponent(e, t) {
    switch (e) {
      case 0:
        this.x = t;
        break;
      case 1:
        this.y = t;
        break;
      case 2:
        this.z = t;
        break;
      case 3:
        this.w = t;
        break;
      default:
        throw new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      case 3:
        return this.w;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z, this.w);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this.z += e, this.w += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this;
  }
  applyMatrix4(e) {
    const t = this.x, i = this.y, r = this.z, a = this.w, o = e.elements;
    return this.x = o[0] * t + o[4] * i + o[8] * r + o[12] * a, this.y = o[1] * t + o[5] * i + o[9] * r + o[13] * a, this.z = o[2] * t + o[6] * i + o[10] * r + o[14] * a, this.w = o[3] * t + o[7] * i + o[11] * r + o[15] * a, this;
  }
  divideScalar(e) {
    return this.multiplyScalar(1 / e);
  }
  setAxisAngleFromQuaternion(e) {
    this.w = 2 * Math.acos(e.w);
    const t = Math.sqrt(1 - e.w * e.w);
    return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this;
  }
  setAxisAngleFromRotationMatrix(e) {
    let t, i, r, a;
    const c = e.elements, l = c[0], u = c[4], h = c[8], d = c[1], p = c[5], g = c[9], v = c[2], m = c[6], f = c[10];
    if (Math.abs(u - d) < 0.01 && Math.abs(h - v) < 0.01 && Math.abs(g - m) < 0.01) {
      if (Math.abs(u + d) < 0.1 && Math.abs(h + v) < 0.1 && Math.abs(g + m) < 0.1 && Math.abs(l + p + f - 3) < 0.1)
        return this.set(1, 0, 0, 0), this;
      t = Math.PI;
      const _ = (l + 1) / 2, x = (p + 1) / 2, T = (f + 1) / 2, E = (u + d) / 4, A = (h + v) / 4, R = (g + m) / 4;
      return _ > x && _ > T ? _ < 0.01 ? (i = 0, r = 0.707106781, a = 0.707106781) : (i = Math.sqrt(_), r = E / i, a = A / i) : x > T ? x < 0.01 ? (i = 0.707106781, r = 0, a = 0.707106781) : (r = Math.sqrt(x), i = E / r, a = R / r) : T < 0.01 ? (i = 0.707106781, r = 0.707106781, a = 0) : (a = Math.sqrt(T), i = A / a, r = R / a), this.set(i, r, a, t), this;
    }
    let M = Math.sqrt((m - g) * (m - g) + (h - v) * (h - v) + (d - u) * (d - u));
    return Math.abs(M) < 1e-3 && (M = 1), this.x = (m - g) / M, this.y = (h - v) / M, this.z = (d - u) / M, this.w = Math.acos((l + p + f - 1) / 2), this;
  }
  min(e) {
    return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), this;
  }
  max(e) {
    return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.w), this;
  }
  clamp(e, t) {
    return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this;
  }
  clampLength(e, t) {
    const i = this.length();
    return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this.w = Math.floor(this.w), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this.w = Math.ceil(this.w), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this.w = Math.round(this.w), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this.w = Math.trunc(this.w), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this;
  }
  dot(e) {
    return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  setLength(e) {
    return this.normalize().multiplyScalar(e);
  }
  lerp(e, t) {
    return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this;
  }
  lerpVectors(e, t, i) {
    return this.x = e.x + (t.x - e.x) * i, this.y = e.y + (t.y - e.y) * i, this.z = e.z + (t.z - e.z) * i, this.w = e.w + (t.w - e.w) * i, this;
  }
  equals(e) {
    return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w;
  }
  fromArray(e, t = 0) {
    return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e;
  }
  fromBufferAttribute(e, t) {
    return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z, yield this.w;
  }
}
class pd extends Qt {
  constructor(e = 1, t = 1, i = {}) {
    super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = 1, this.scissor = new gt(0, 0, e, t), this.scissorTest = !1, this.viewport = new gt(0, 0, e, t);
    const r = { width: e, height: t, depth: 1 };
    i = Object.assign({
      generateMipmaps: !1,
      internalFormat: null,
      minFilter: Yt,
      depthBuffer: !0,
      stencilBuffer: !1,
      depthTexture: null,
      samples: 0,
      count: 1
    }, i);
    const a = new Tt(r, i.mapping, i.wrapS, i.wrapT, i.magFilter, i.minFilter, i.format, i.type, i.anisotropy, i.colorSpace);
    a.flipY = !1, a.generateMipmaps = i.generateMipmaps, a.internalFormat = i.internalFormat, this.textures = [];
    const o = i.count;
    for (let s = 0; s < o; s++)
      this.textures[s] = a.clone(), this.textures[s].isRenderTargetTexture = !0;
    this.depthBuffer = i.depthBuffer, this.stencilBuffer = i.stencilBuffer, this.depthTexture = i.depthTexture, this.samples = i.samples;
  }
  get texture() {
    return this.textures[0];
  }
  set texture(e) {
    this.textures[0] = e;
  }
  setSize(e, t, i = 1) {
    if (this.width !== e || this.height !== t || this.depth !== i) {
      this.width = e, this.height = t, this.depth = i;
      for (let r = 0, a = this.textures.length; r < a; r++)
        this.textures[r].image.width = e, this.textures[r].image.height = t, this.textures[r].image.depth = i;
      this.dispose();
    }
    this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    this.width = e.width, this.height = e.height, this.depth = e.depth, this.scissor.copy(e.scissor), this.scissorTest = e.scissorTest, this.viewport.copy(e.viewport), this.textures.length = 0;
    for (let i = 0, r = e.textures.length; i < r; i++)
      this.textures[i] = e.textures[i].clone(), this.textures[i].isRenderTargetTexture = !0;
    const t = Object.assign({}, e.texture.image);
    return this.texture.source = new bu(t), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
class Vn extends pd {
  constructor(e = 1, t = 1, i = {}) {
    super(e, t, i), this.isWebGLRenderTarget = !0;
  }
}
class Mu extends Tt {
  constructor(e = null, t = 1, i = 1, r = 1) {
    super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: i, depth: r }, this.magFilter = Ht, this.minFilter = Ht, this.wrapR = ai, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class md extends Tt {
  constructor(e = null, t = 1, i = 1, r = 1) {
    super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: i, depth: r }, this.magFilter = Ht, this.minFilter = Ht, this.wrapR = ai, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class Jt {
  constructor(e = 0, t = 0, i = 0, r = 1) {
    this.isQuaternion = !0, this._x = e, this._y = t, this._z = i, this._w = r;
  }
  static slerpFlat(e, t, i, r, a, o, s) {
    let c = i[r + 0], l = i[r + 1], u = i[r + 2], h = i[r + 3];
    const d = a[o + 0], p = a[o + 1], g = a[o + 2], v = a[o + 3];
    if (s === 0) {
      e[t + 0] = c, e[t + 1] = l, e[t + 2] = u, e[t + 3] = h;
      return;
    }
    if (s === 1) {
      e[t + 0] = d, e[t + 1] = p, e[t + 2] = g, e[t + 3] = v;
      return;
    }
    if (h !== v || c !== d || l !== p || u !== g) {
      let m = 1 - s;
      const f = c * d + l * p + u * g + h * v, M = f >= 0 ? 1 : -1, _ = 1 - f * f;
      if (_ > Number.EPSILON) {
        const T = Math.sqrt(_), E = Math.atan2(T, f * M);
        m = Math.sin(m * E) / T, s = Math.sin(s * E) / T;
      }
      const x = s * M;
      if (c = c * m + d * x, l = l * m + p * x, u = u * m + g * x, h = h * m + v * x, m === 1 - s) {
        const T = 1 / Math.sqrt(c * c + l * l + u * u + h * h);
        c *= T, l *= T, u *= T, h *= T;
      }
    }
    e[t] = c, e[t + 1] = l, e[t + 2] = u, e[t + 3] = h;
  }
  static multiplyQuaternionsFlat(e, t, i, r, a, o) {
    const s = i[r], c = i[r + 1], l = i[r + 2], u = i[r + 3], h = a[o], d = a[o + 1], p = a[o + 2], g = a[o + 3];
    return e[t] = s * g + u * h + c * p - l * d, e[t + 1] = c * g + u * d + l * h - s * p, e[t + 2] = l * g + u * p + s * d - c * h, e[t + 3] = u * g - s * h - c * d - l * p, e;
  }
  get x() {
    return this._x;
  }
  set x(e) {
    this._x = e, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(e) {
    this._y = e, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(e) {
    this._z = e, this._onChangeCallback();
  }
  get w() {
    return this._w;
  }
  set w(e) {
    this._w = e, this._onChangeCallback();
  }
  set(e, t, i, r) {
    return this._x = e, this._y = t, this._z = i, this._w = r, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._w);
  }
  copy(e) {
    return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this;
  }
  setFromEuler(e, t = !0) {
    const i = e._x, r = e._y, a = e._z, o = e._order, s = Math.cos, c = Math.sin, l = s(i / 2), u = s(r / 2), h = s(a / 2), d = c(i / 2), p = c(r / 2), g = c(a / 2);
    switch (o) {
      case "XYZ":
        this._x = d * u * h + l * p * g, this._y = l * p * h - d * u * g, this._z = l * u * g + d * p * h, this._w = l * u * h - d * p * g;
        break;
      case "YXZ":
        this._x = d * u * h + l * p * g, this._y = l * p * h - d * u * g, this._z = l * u * g - d * p * h, this._w = l * u * h + d * p * g;
        break;
      case "ZXY":
        this._x = d * u * h - l * p * g, this._y = l * p * h + d * u * g, this._z = l * u * g + d * p * h, this._w = l * u * h - d * p * g;
        break;
      case "ZYX":
        this._x = d * u * h - l * p * g, this._y = l * p * h + d * u * g, this._z = l * u * g - d * p * h, this._w = l * u * h + d * p * g;
        break;
      case "YZX":
        this._x = d * u * h + l * p * g, this._y = l * p * h + d * u * g, this._z = l * u * g - d * p * h, this._w = l * u * h - d * p * g;
        break;
      case "XZY":
        this._x = d * u * h - l * p * g, this._y = l * p * h - d * u * g, this._z = l * u * g + d * p * h, this._w = l * u * h + d * p * g;
        break;
      default:
        console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + o);
    }
    return t === !0 && this._onChangeCallback(), this;
  }
  setFromAxisAngle(e, t) {
    const i = t / 2, r = Math.sin(i);
    return this._x = e.x * r, this._y = e.y * r, this._z = e.z * r, this._w = Math.cos(i), this._onChangeCallback(), this;
  }
  setFromRotationMatrix(e) {
    const t = e.elements, i = t[0], r = t[4], a = t[8], o = t[1], s = t[5], c = t[9], l = t[2], u = t[6], h = t[10], d = i + s + h;
    if (d > 0) {
      const p = 0.5 / Math.sqrt(d + 1);
      this._w = 0.25 / p, this._x = (u - c) * p, this._y = (a - l) * p, this._z = (o - r) * p;
    } else if (i > s && i > h) {
      const p = 2 * Math.sqrt(1 + i - s - h);
      this._w = (u - c) / p, this._x = 0.25 * p, this._y = (r + o) / p, this._z = (a + l) / p;
    } else if (s > h) {
      const p = 2 * Math.sqrt(1 + s - i - h);
      this._w = (a - l) / p, this._x = (r + o) / p, this._y = 0.25 * p, this._z = (c + u) / p;
    } else {
      const p = 2 * Math.sqrt(1 + h - i - s);
      this._w = (o - r) / p, this._x = (a + l) / p, this._y = (c + u) / p, this._z = 0.25 * p;
    }
    return this._onChangeCallback(), this;
  }
  setFromUnitVectors(e, t) {
    let i = e.dot(t) + 1;
    return i < Number.EPSILON ? (i = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = i) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = i)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = i), this.normalize();
  }
  angleTo(e) {
    return 2 * Math.acos(Math.abs(mt(this.dot(e), -1, 1)));
  }
  rotateTowards(e, t) {
    const i = this.angleTo(e);
    if (i === 0)
      return this;
    const r = Math.min(1, t / i);
    return this.slerp(e, r), this;
  }
  identity() {
    return this.set(0, 0, 0, 1);
  }
  invert() {
    return this.conjugate();
  }
  conjugate() {
    return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
  }
  dot(e) {
    return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;
  }
  lengthSq() {
    return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
  }
  length() {
    return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
  }
  normalize() {
    let e = this.length();
    return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this;
  }
  multiply(e) {
    return this.multiplyQuaternions(this, e);
  }
  premultiply(e) {
    return this.multiplyQuaternions(e, this);
  }
  multiplyQuaternions(e, t) {
    const i = e._x, r = e._y, a = e._z, o = e._w, s = t._x, c = t._y, l = t._z, u = t._w;
    return this._x = i * u + o * s + r * l - a * c, this._y = r * u + o * c + a * s - i * l, this._z = a * u + o * l + i * c - r * s, this._w = o * u - i * s - r * c - a * l, this._onChangeCallback(), this;
  }
  slerp(e, t) {
    if (t === 0)
      return this;
    if (t === 1)
      return this.copy(e);
    const i = this._x, r = this._y, a = this._z, o = this._w;
    let s = o * e._w + i * e._x + r * e._y + a * e._z;
    if (s < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, s = -s) : this.copy(e), s >= 1)
      return this._w = o, this._x = i, this._y = r, this._z = a, this;
    const c = 1 - s * s;
    if (c <= Number.EPSILON) {
      const p = 1 - t;
      return this._w = p * o + t * this._w, this._x = p * i + t * this._x, this._y = p * r + t * this._y, this._z = p * a + t * this._z, this.normalize(), this;
    }
    const l = Math.sqrt(c), u = Math.atan2(l, s), h = Math.sin((1 - t) * u) / l, d = Math.sin(t * u) / l;
    return this._w = o * h + this._w * d, this._x = i * h + this._x * d, this._y = r * h + this._y * d, this._z = a * h + this._z * d, this._onChangeCallback(), this;
  }
  slerpQuaternions(e, t, i) {
    return this.copy(e).slerp(t, i);
  }
  random() {
    const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), i = Math.random(), r = Math.sqrt(1 - i), a = Math.sqrt(i);
    return this.set(
      r * Math.sin(e),
      r * Math.cos(e),
      a * Math.sin(t),
      a * Math.cos(t)
    );
  }
  equals(e) {
    return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;
  }
  fromArray(e, t = 0) {
    return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e;
  }
  fromBufferAttribute(e, t) {
    return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this._onChangeCallback(), this;
  }
  toJSON() {
    return this.toArray();
  }
  _onChange(e) {
    return this._onChangeCallback = e, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._w;
  }
}
class O {
  constructor(e = 0, t = 0, i = 0) {
    O.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = i;
  }
  set(e, t, i) {
    return i === void 0 && (i = this.z), this.x = e, this.y = t, this.z = i, this;
  }
  setScalar(e) {
    return this.x = e, this.y = e, this.z = e, this;
  }
  setX(e) {
    return this.x = e, this;
  }
  setY(e) {
    return this.y = e, this;
  }
  setZ(e) {
    return this.z = e, this;
  }
  setComponent(e, t) {
    switch (e) {
      case 0:
        this.x = t;
        break;
      case 1:
        this.y = t;
        break;
      case 2:
        this.z = t;
        break;
      default:
        throw new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this.z = e.z, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this.z += e.z, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this.z += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this.z -= e.z, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this.z -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this.z *= e.z, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this.z *= e, this;
  }
  multiplyVectors(e, t) {
    return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this;
  }
  applyEuler(e) {
    return this.applyQuaternion(yc.setFromEuler(e));
  }
  applyAxisAngle(e, t) {
    return this.applyQuaternion(yc.setFromAxisAngle(e, t));
  }
  applyMatrix3(e) {
    const t = this.x, i = this.y, r = this.z, a = e.elements;
    return this.x = a[0] * t + a[3] * i + a[6] * r, this.y = a[1] * t + a[4] * i + a[7] * r, this.z = a[2] * t + a[5] * i + a[8] * r, this;
  }
  applyNormalMatrix(e) {
    return this.applyMatrix3(e).normalize();
  }
  applyMatrix4(e) {
    const t = this.x, i = this.y, r = this.z, a = e.elements, o = 1 / (a[3] * t + a[7] * i + a[11] * r + a[15]);
    return this.x = (a[0] * t + a[4] * i + a[8] * r + a[12]) * o, this.y = (a[1] * t + a[5] * i + a[9] * r + a[13]) * o, this.z = (a[2] * t + a[6] * i + a[10] * r + a[14]) * o, this;
  }
  applyQuaternion(e) {
    const t = this.x, i = this.y, r = this.z, a = e.x, o = e.y, s = e.z, c = e.w, l = 2 * (o * r - s * i), u = 2 * (s * t - a * r), h = 2 * (a * i - o * t);
    return this.x = t + c * l + o * h - s * u, this.y = i + c * u + s * l - a * h, this.z = r + c * h + a * u - o * l, this;
  }
  project(e) {
    return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);
  }
  unproject(e) {
    return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);
  }
  transformDirection(e) {
    const t = this.x, i = this.y, r = this.z, a = e.elements;
    return this.x = a[0] * t + a[4] * i + a[8] * r, this.y = a[1] * t + a[5] * i + a[9] * r, this.z = a[2] * t + a[6] * i + a[10] * r, this.normalize();
  }
  divide(e) {
    return this.x /= e.x, this.y /= e.y, this.z /= e.z, this;
  }
  divideScalar(e) {
    return this.multiplyScalar(1 / e);
  }
  min(e) {
    return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this;
  }
  max(e) {
    return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this;
  }
  clamp(e, t) {
    return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this;
  }
  clampLength(e, t) {
    const i = this.length();
    return this.divideScalar(i || 1).multiplyScalar(Math.max(e, Math.min(t, i)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
  }
  dot(e) {
    return this.x * e.x + this.y * e.y + this.z * e.z;
  }
  // TODO lengthSquared?
  lengthSq() {
    return this.x * this.x + this.y * this.y + this.z * this.z;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  setLength(e) {
    return this.normalize().multiplyScalar(e);
  }
  lerp(e, t) {
    return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this;
  }
  lerpVectors(e, t, i) {
    return this.x = e.x + (t.x - e.x) * i, this.y = e.y + (t.y - e.y) * i, this.z = e.z + (t.z - e.z) * i, this;
  }
  cross(e) {
    return this.crossVectors(this, e);
  }
  crossVectors(e, t) {
    const i = e.x, r = e.y, a = e.z, o = t.x, s = t.y, c = t.z;
    return this.x = r * c - a * s, this.y = a * o - i * c, this.z = i * s - r * o, this;
  }
  projectOnVector(e) {
    const t = e.lengthSq();
    if (t === 0)
      return this.set(0, 0, 0);
    const i = e.dot(this) / t;
    return this.copy(e).multiplyScalar(i);
  }
  projectOnPlane(e) {
    return ja.copy(this).projectOnVector(e), this.sub(ja);
  }
  reflect(e) {
    return this.sub(ja.copy(e).multiplyScalar(2 * this.dot(e)));
  }
  angleTo(e) {
    const t = Math.sqrt(this.lengthSq() * e.lengthSq());
    if (t === 0)
      return Math.PI / 2;
    const i = this.dot(e) / t;
    return Math.acos(mt(i, -1, 1));
  }
  distanceTo(e) {
    return Math.sqrt(this.distanceToSquared(e));
  }
  distanceToSquared(e) {
    const t = this.x - e.x, i = this.y - e.y, r = this.z - e.z;
    return t * t + i * i + r * r;
  }
  manhattanDistanceTo(e) {
    return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z);
  }
  setFromSpherical(e) {
    return this.setFromSphericalCoords(e.radius, e.phi, e.theta);
  }
  setFromSphericalCoords(e, t, i) {
    const r = Math.sin(t) * e;
    return this.x = r * Math.sin(i), this.y = Math.cos(t) * e, this.z = r * Math.cos(i), this;
  }
  setFromCylindrical(e) {
    return this.setFromCylindricalCoords(e.radius, e.theta, e.y);
  }
  setFromCylindricalCoords(e, t, i) {
    return this.x = e * Math.sin(t), this.y = i, this.z = e * Math.cos(t), this;
  }
  setFromMatrixPosition(e) {
    const t = e.elements;
    return this.x = t[12], this.y = t[13], this.z = t[14], this;
  }
  setFromMatrixScale(e) {
    const t = this.setFromMatrixColumn(e, 0).length(), i = this.setFromMatrixColumn(e, 1).length(), r = this.setFromMatrixColumn(e, 2).length();
    return this.x = t, this.y = i, this.z = r, this;
  }
  setFromMatrixColumn(e, t) {
    return this.fromArray(e.elements, t * 4);
  }
  setFromMatrix3Column(e, t) {
    return this.fromArray(e.elements, t * 3);
  }
  setFromEuler(e) {
    return this.x = e._x, this.y = e._y, this.z = e._z, this;
  }
  setFromColor(e) {
    return this.x = e.r, this.y = e.g, this.z = e.b, this;
  }
  equals(e) {
    return e.x === this.x && e.y === this.y && e.z === this.z;
  }
  fromArray(e, t = 0) {
    return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e;
  }
  fromBufferAttribute(e, t) {
    return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
  }
  randomDirection() {
    const e = Math.random() * Math.PI * 2, t = Math.random() * 2 - 1, i = Math.sqrt(1 - t * t);
    return this.x = i * Math.cos(e), this.y = t, this.z = i * Math.sin(e), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z;
  }
}
const ja = /* @__PURE__ */ new O(), yc = /* @__PURE__ */ new Jt();
class ui {
  constructor(e = new O(1 / 0, 1 / 0, 1 / 0), t = new O(-1 / 0, -1 / 0, -1 / 0)) {
    this.isBox3 = !0, this.min = e, this.max = t;
  }
  set(e, t) {
    return this.min.copy(e), this.max.copy(t), this;
  }
  setFromArray(e) {
    this.makeEmpty();
    for (let t = 0, i = e.length; t < i; t += 3)
      this.expandByPoint(Gt.fromArray(e, t));
    return this;
  }
  setFromBufferAttribute(e) {
    this.makeEmpty();
    for (let t = 0, i = e.count; t < i; t++)
      this.expandByPoint(Gt.fromBufferAttribute(e, t));
    return this;
  }
  setFromPoints(e) {
    this.makeEmpty();
    for (let t = 0, i = e.length; t < i; t++)
      this.expandByPoint(e[t]);
    return this;
  }
  setFromCenterAndSize(e, t) {
    const i = Gt.copy(t).multiplyScalar(0.5);
    return this.min.copy(e).sub(i), this.max.copy(e).add(i), this;
  }
  setFromObject(e, t = !1) {
    return this.makeEmpty(), this.expandByObject(e, t);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.min.copy(e.min), this.max.copy(e.max), this;
  }
  makeEmpty() {
    return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this;
  }
  isEmpty() {
    return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
  }
  getCenter(e) {
    return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5);
  }
  getSize(e) {
    return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min);
  }
  expandByPoint(e) {
    return this.min.min(e), this.max.max(e), this;
  }
  expandByVector(e) {
    return this.min.sub(e), this.max.add(e), this;
  }
  expandByScalar(e) {
    return this.min.addScalar(-e), this.max.addScalar(e), this;
  }
  expandByObject(e, t = !1) {
    e.updateWorldMatrix(!1, !1);
    const i = e.geometry;
    if (i !== void 0) {
      const a = i.getAttribute("position");
      if (t === !0 && a !== void 0 && e.isInstancedMesh !== !0)
        for (let o = 0, s = a.count; o < s; o++)
          e.isMesh === !0 ? e.getVertexPosition(o, Gt) : Gt.fromBufferAttribute(a, o), Gt.applyMatrix4(e.matrixWorld), this.expandByPoint(Gt);
      else
        e.boundingBox !== void 0 ? (e.boundingBox === null && e.computeBoundingBox(), Cr.copy(e.boundingBox)) : (i.boundingBox === null && i.computeBoundingBox(), Cr.copy(i.boundingBox)), Cr.applyMatrix4(e.matrixWorld), this.union(Cr);
    }
    const r = e.children;
    for (let a = 0, o = r.length; a < o; a++)
      this.expandByObject(r[a], t);
    return this;
  }
  containsPoint(e) {
    return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y || e.z < this.min.z || e.z > this.max.z);
  }
  containsBox(e) {
    return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z;
  }
  getParameter(e, t) {
    return t.set(
      (e.x - this.min.x) / (this.max.x - this.min.x),
      (e.y - this.min.y) / (this.max.y - this.min.y),
      (e.z - this.min.z) / (this.max.z - this.min.z)
    );
  }
  intersectsBox(e) {
    return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y || e.max.z < this.min.z || e.min.z > this.max.z);
  }
  intersectsSphere(e) {
    return this.clampPoint(e.center, Gt), Gt.distanceToSquared(e.center) <= e.radius * e.radius;
  }
  intersectsPlane(e) {
    let t, i;
    return e.normal.x > 0 ? (t = e.normal.x * this.min.x, i = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, i = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, i += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, i += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, i += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, i += e.normal.z * this.min.z), t <= -e.constant && i >= -e.constant;
  }
  intersectsTriangle(e) {
    if (this.isEmpty())
      return !1;
    this.getCenter(Yi), Rr.subVectors(this.max, Yi), mi.subVectors(e.a, Yi), gi.subVectors(e.b, Yi), vi.subVectors(e.c, Yi), Rn.subVectors(gi, mi), Pn.subVectors(vi, gi), Yn.subVectors(mi, vi);
    let t = [
      0,
      -Rn.z,
      Rn.y,
      0,
      -Pn.z,
      Pn.y,
      0,
      -Yn.z,
      Yn.y,
      Rn.z,
      0,
      -Rn.x,
      Pn.z,
      0,
      -Pn.x,
      Yn.z,
      0,
      -Yn.x,
      -Rn.y,
      Rn.x,
      0,
      -Pn.y,
      Pn.x,
      0,
      -Yn.y,
      Yn.x,
      0
    ];
    return !Xa(t, mi, gi, vi, Rr) || (t = [1, 0, 0, 0, 1, 0, 0, 0, 1], !Xa(t, mi, gi, vi, Rr)) ? !1 : (Pr.crossVectors(Rn, Pn), t = [Pr.x, Pr.y, Pr.z], Xa(t, mi, gi, vi, Rr));
  }
  clampPoint(e, t) {
    return t.copy(e).clamp(this.min, this.max);
  }
  distanceToPoint(e) {
    return this.clampPoint(e, Gt).distanceTo(e);
  }
  getBoundingSphere(e) {
    return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(Gt).length() * 0.5), e;
  }
  intersect(e) {
    return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this;
  }
  union(e) {
    return this.min.min(e.min), this.max.max(e.max), this;
  }
  applyMatrix4(e) {
    return this.isEmpty() ? this : (un[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), un[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), un[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), un[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), un[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), un[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), un[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), un[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(un), this);
  }
  translate(e) {
    return this.min.add(e), this.max.add(e), this;
  }
  equals(e) {
    return e.min.equals(this.min) && e.max.equals(this.max);
  }
}
const un = [
  /* @__PURE__ */ new O(),
  /* @__PURE__ */ new O(),
  /* @__PURE__ */ new O(),
  /* @__PURE__ */ new O(),
  /* @__PURE__ */ new O(),
  /* @__PURE__ */ new O(),
  /* @__PURE__ */ new O(),
  /* @__PURE__ */ new O()
], Gt = /* @__PURE__ */ new O(), Cr = /* @__PURE__ */ new ui(), mi = /* @__PURE__ */ new O(), gi = /* @__PURE__ */ new O(), vi = /* @__PURE__ */ new O(), Rn = /* @__PURE__ */ new O(), Pn = /* @__PURE__ */ new O(), Yn = /* @__PURE__ */ new O(), Yi = /* @__PURE__ */ new O(), Rr = /* @__PURE__ */ new O(), Pr = /* @__PURE__ */ new O(), Kn = /* @__PURE__ */ new O();
function Xa(n, e, t, i, r) {
  for (let a = 0, o = n.length - 3; a <= o; a += 3) {
    Kn.fromArray(n, a);
    const s = r.x * Math.abs(Kn.x) + r.y * Math.abs(Kn.y) + r.z * Math.abs(Kn.z), c = e.dot(Kn), l = t.dot(Kn), u = i.dot(Kn);
    if (Math.max(-Math.max(c, l, u), Math.min(c, l, u)) > s)
      return !1;
  }
  return !0;
}
const gd = /* @__PURE__ */ new ui(), Ki = /* @__PURE__ */ new O(), $a = /* @__PURE__ */ new O();
class ba {
  constructor(e = new O(), t = -1) {
    this.isSphere = !0, this.center = e, this.radius = t;
  }
  set(e, t) {
    return this.center.copy(e), this.radius = t, this;
  }
  setFromPoints(e, t) {
    const i = this.center;
    t !== void 0 ? i.copy(t) : gd.setFromPoints(e).getCenter(i);
    let r = 0;
    for (let a = 0, o = e.length; a < o; a++)
      r = Math.max(r, i.distanceToSquared(e[a]));
    return this.radius = Math.sqrt(r), this;
  }
  copy(e) {
    return this.center.copy(e.center), this.radius = e.radius, this;
  }
  isEmpty() {
    return this.radius < 0;
  }
  makeEmpty() {
    return this.center.set(0, 0, 0), this.radius = -1, this;
  }
  containsPoint(e) {
    return e.distanceToSquared(this.center) <= this.radius * this.radius;
  }
  distanceToPoint(e) {
    return e.distanceTo(this.center) - this.radius;
  }
  intersectsSphere(e) {
    const t = this.radius + e.radius;
    return e.center.distanceToSquared(this.center) <= t * t;
  }
  intersectsBox(e) {
    return e.intersectsSphere(this);
  }
  intersectsPlane(e) {
    return Math.abs(e.distanceToPoint(this.center)) <= this.radius;
  }
  clampPoint(e, t) {
    const i = this.center.distanceToSquared(e);
    return t.copy(e), i > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t;
  }
  getBoundingBox(e) {
    return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e);
  }
  applyMatrix4(e) {
    return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this;
  }
  translate(e) {
    return this.center.add(e), this;
  }
  expandByPoint(e) {
    if (this.isEmpty())
      return this.center.copy(e), this.radius = 0, this;
    Ki.subVectors(e, this.center);
    const t = Ki.lengthSq();
    if (t > this.radius * this.radius) {
      const i = Math.sqrt(t), r = (i - this.radius) * 0.5;
      this.center.addScaledVector(Ki, r / i), this.radius += r;
    }
    return this;
  }
  union(e) {
    return e.isEmpty() ? this : this.isEmpty() ? (this.copy(e), this) : (this.center.equals(e.center) === !0 ? this.radius = Math.max(this.radius, e.radius) : ($a.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(Ki.copy(e.center).add($a)), this.expandByPoint(Ki.copy(e.center).sub($a))), this);
  }
  equals(e) {
    return e.center.equals(this.center) && e.radius === this.radius;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const hn = /* @__PURE__ */ new O(), qa = /* @__PURE__ */ new O(), Lr = /* @__PURE__ */ new O(), Ln = /* @__PURE__ */ new O(), Ya = /* @__PURE__ */ new O(), Dr = /* @__PURE__ */ new O(), Ka = /* @__PURE__ */ new O();
class Ma {
  constructor(e = new O(), t = new O(0, 0, -1)) {
    this.origin = e, this.direction = t;
  }
  set(e, t) {
    return this.origin.copy(e), this.direction.copy(t), this;
  }
  copy(e) {
    return this.origin.copy(e.origin), this.direction.copy(e.direction), this;
  }
  at(e, t) {
    return t.copy(this.origin).addScaledVector(this.direction, e);
  }
  lookAt(e) {
    return this.direction.copy(e).sub(this.origin).normalize(), this;
  }
  recast(e) {
    return this.origin.copy(this.at(e, hn)), this;
  }
  closestPointToPoint(e, t) {
    t.subVectors(e, this.origin);
    const i = t.dot(this.direction);
    return i < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, i);
  }
  distanceToPoint(e) {
    return Math.sqrt(this.distanceSqToPoint(e));
  }
  distanceSqToPoint(e) {
    const t = hn.subVectors(e, this.origin).dot(this.direction);
    return t < 0 ? this.origin.distanceToSquared(e) : (hn.copy(this.origin).addScaledVector(this.direction, t), hn.distanceToSquared(e));
  }
  distanceSqToSegment(e, t, i, r) {
    qa.copy(e).add(t).multiplyScalar(0.5), Lr.copy(t).sub(e).normalize(), Ln.copy(this.origin).sub(qa);
    const a = e.distanceTo(t) * 0.5, o = -this.direction.dot(Lr), s = Ln.dot(this.direction), c = -Ln.dot(Lr), l = Ln.lengthSq(), u = Math.abs(1 - o * o);
    let h, d, p, g;
    if (u > 0)
      if (h = o * c - s, d = o * s - c, g = a * u, h >= 0)
        if (d >= -g)
          if (d <= g) {
            const v = 1 / u;
            h *= v, d *= v, p = h * (h + o * d + 2 * s) + d * (o * h + d + 2 * c) + l;
          } else
            d = a, h = Math.max(0, -(o * d + s)), p = -h * h + d * (d + 2 * c) + l;
        else
          d = -a, h = Math.max(0, -(o * d + s)), p = -h * h + d * (d + 2 * c) + l;
      else
        d <= -g ? (h = Math.max(0, -(-o * a + s)), d = h > 0 ? -a : Math.min(Math.max(-a, -c), a), p = -h * h + d * (d + 2 * c) + l) : d <= g ? (h = 0, d = Math.min(Math.max(-a, -c), a), p = d * (d + 2 * c) + l) : (h = Math.max(0, -(o * a + s)), d = h > 0 ? a : Math.min(Math.max(-a, -c), a), p = -h * h + d * (d + 2 * c) + l);
    else
      d = o > 0 ? -a : a, h = Math.max(0, -(o * d + s)), p = -h * h + d * (d + 2 * c) + l;
    return i && i.copy(this.origin).addScaledVector(this.direction, h), r && r.copy(qa).addScaledVector(Lr, d), p;
  }
  intersectSphere(e, t) {
    hn.subVectors(e.center, this.origin);
    const i = hn.dot(this.direction), r = hn.dot(hn) - i * i, a = e.radius * e.radius;
    if (r > a)
      return null;
    const o = Math.sqrt(a - r), s = i - o, c = i + o;
    return c < 0 ? null : s < 0 ? this.at(c, t) : this.at(s, t);
  }
  intersectsSphere(e) {
    return this.distanceSqToPoint(e.center) <= e.radius * e.radius;
  }
  distanceToPlane(e) {
    const t = e.normal.dot(this.direction);
    if (t === 0)
      return e.distanceToPoint(this.origin) === 0 ? 0 : null;
    const i = -(this.origin.dot(e.normal) + e.constant) / t;
    return i >= 0 ? i : null;
  }
  intersectPlane(e, t) {
    const i = this.distanceToPlane(e);
    return i === null ? null : this.at(i, t);
  }
  intersectsPlane(e) {
    const t = e.distanceToPoint(this.origin);
    return t === 0 || e.normal.dot(this.direction) * t < 0;
  }
  intersectBox(e, t) {
    let i, r, a, o, s, c;
    const l = 1 / this.direction.x, u = 1 / this.direction.y, h = 1 / this.direction.z, d = this.origin;
    return l >= 0 ? (i = (e.min.x - d.x) * l, r = (e.max.x - d.x) * l) : (i = (e.max.x - d.x) * l, r = (e.min.x - d.x) * l), u >= 0 ? (a = (e.min.y - d.y) * u, o = (e.max.y - d.y) * u) : (a = (e.max.y - d.y) * u, o = (e.min.y - d.y) * u), i > o || a > r || ((a > i || isNaN(i)) && (i = a), (o < r || isNaN(r)) && (r = o), h >= 0 ? (s = (e.min.z - d.z) * h, c = (e.max.z - d.z) * h) : (s = (e.max.z - d.z) * h, c = (e.min.z - d.z) * h), i > c || s > r) || ((s > i || i !== i) && (i = s), (c < r || r !== r) && (r = c), r < 0) ? null : this.at(i >= 0 ? i : r, t);
  }
  intersectsBox(e) {
    return this.intersectBox(e, hn) !== null;
  }
  intersectTriangle(e, t, i, r, a) {
    Ya.subVectors(t, e), Dr.subVectors(i, e), Ka.crossVectors(Ya, Dr);
    let o = this.direction.dot(Ka), s;
    if (o > 0) {
      if (r)
        return null;
      s = 1;
    } else if (o < 0)
      s = -1, o = -o;
    else
      return null;
    Ln.subVectors(this.origin, e);
    const c = s * this.direction.dot(Dr.crossVectors(Ln, Dr));
    if (c < 0)
      return null;
    const l = s * this.direction.dot(Ya.cross(Ln));
    if (l < 0 || c + l > o)
      return null;
    const u = -s * Ln.dot(Ka);
    return u < 0 ? null : this.at(u / o, a);
  }
  applyMatrix4(e) {
    return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this;
  }
  equals(e) {
    return e.origin.equals(this.origin) && e.direction.equals(this.direction);
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Je {
  constructor(e, t, i, r, a, o, s, c, l, u, h, d, p, g, v, m) {
    Je.prototype.isMatrix4 = !0, this.elements = [
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ], e !== void 0 && this.set(e, t, i, r, a, o, s, c, l, u, h, d, p, g, v, m);
  }
  set(e, t, i, r, a, o, s, c, l, u, h, d, p, g, v, m) {
    const f = this.elements;
    return f[0] = e, f[4] = t, f[8] = i, f[12] = r, f[1] = a, f[5] = o, f[9] = s, f[13] = c, f[2] = l, f[6] = u, f[10] = h, f[14] = d, f[3] = p, f[7] = g, f[11] = v, f[15] = m, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  clone() {
    return new Je().fromArray(this.elements);
  }
  copy(e) {
    const t = this.elements, i = e.elements;
    return t[0] = i[0], t[1] = i[1], t[2] = i[2], t[3] = i[3], t[4] = i[4], t[5] = i[5], t[6] = i[6], t[7] = i[7], t[8] = i[8], t[9] = i[9], t[10] = i[10], t[11] = i[11], t[12] = i[12], t[13] = i[13], t[14] = i[14], t[15] = i[15], this;
  }
  copyPosition(e) {
    const t = this.elements, i = e.elements;
    return t[12] = i[12], t[13] = i[13], t[14] = i[14], this;
  }
  setFromMatrix3(e) {
    const t = e.elements;
    return this.set(
      t[0],
      t[3],
      t[6],
      0,
      t[1],
      t[4],
      t[7],
      0,
      t[2],
      t[5],
      t[8],
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractBasis(e, t, i) {
    return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), i.setFromMatrixColumn(this, 2), this;
  }
  makeBasis(e, t, i) {
    return this.set(
      e.x,
      t.x,
      i.x,
      0,
      e.y,
      t.y,
      i.y,
      0,
      e.z,
      t.z,
      i.z,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractRotation(e) {
    const t = this.elements, i = e.elements, r = 1 / _i.setFromMatrixColumn(e, 0).length(), a = 1 / _i.setFromMatrixColumn(e, 1).length(), o = 1 / _i.setFromMatrixColumn(e, 2).length();
    return t[0] = i[0] * r, t[1] = i[1] * r, t[2] = i[2] * r, t[3] = 0, t[4] = i[4] * a, t[5] = i[5] * a, t[6] = i[6] * a, t[7] = 0, t[8] = i[8] * o, t[9] = i[9] * o, t[10] = i[10] * o, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
  }
  makeRotationFromEuler(e) {
    const t = this.elements, i = e.x, r = e.y, a = e.z, o = Math.cos(i), s = Math.sin(i), c = Math.cos(r), l = Math.sin(r), u = Math.cos(a), h = Math.sin(a);
    if (e.order === "XYZ") {
      const d = o * u, p = o * h, g = s * u, v = s * h;
      t[0] = c * u, t[4] = -c * h, t[8] = l, t[1] = p + g * l, t[5] = d - v * l, t[9] = -s * c, t[2] = v - d * l, t[6] = g + p * l, t[10] = o * c;
    } else if (e.order === "YXZ") {
      const d = c * u, p = c * h, g = l * u, v = l * h;
      t[0] = d + v * s, t[4] = g * s - p, t[8] = o * l, t[1] = o * h, t[5] = o * u, t[9] = -s, t[2] = p * s - g, t[6] = v + d * s, t[10] = o * c;
    } else if (e.order === "ZXY") {
      const d = c * u, p = c * h, g = l * u, v = l * h;
      t[0] = d - v * s, t[4] = -o * h, t[8] = g + p * s, t[1] = p + g * s, t[5] = o * u, t[9] = v - d * s, t[2] = -o * l, t[6] = s, t[10] = o * c;
    } else if (e.order === "ZYX") {
      const d = o * u, p = o * h, g = s * u, v = s * h;
      t[0] = c * u, t[4] = g * l - p, t[8] = d * l + v, t[1] = c * h, t[5] = v * l + d, t[9] = p * l - g, t[2] = -l, t[6] = s * c, t[10] = o * c;
    } else if (e.order === "YZX") {
      const d = o * c, p = o * l, g = s * c, v = s * l;
      t[0] = c * u, t[4] = v - d * h, t[8] = g * h + p, t[1] = h, t[5] = o * u, t[9] = -s * u, t[2] = -l * u, t[6] = p * h + g, t[10] = d - v * h;
    } else if (e.order === "XZY") {
      const d = o * c, p = o * l, g = s * c, v = s * l;
      t[0] = c * u, t[4] = -h, t[8] = l * u, t[1] = d * h + v, t[5] = o * u, t[9] = p * h - g, t[2] = g * h - p, t[6] = s * u, t[10] = v * h + d;
    }
    return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
  }
  makeRotationFromQuaternion(e) {
    return this.compose(vd, e, _d);
  }
  lookAt(e, t, i) {
    const r = this.elements;
    return Dt.subVectors(e, t), Dt.lengthSq() === 0 && (Dt.z = 1), Dt.normalize(), Dn.crossVectors(i, Dt), Dn.lengthSq() === 0 && (Math.abs(i.z) === 1 ? Dt.x += 1e-4 : Dt.z += 1e-4, Dt.normalize(), Dn.crossVectors(i, Dt)), Dn.normalize(), Or.crossVectors(Dt, Dn), r[0] = Dn.x, r[4] = Or.x, r[8] = Dt.x, r[1] = Dn.y, r[5] = Or.y, r[9] = Dt.y, r[2] = Dn.z, r[6] = Or.z, r[10] = Dt.z, this;
  }
  multiply(e) {
    return this.multiplyMatrices(this, e);
  }
  premultiply(e) {
    return this.multiplyMatrices(e, this);
  }
  multiplyMatrices(e, t) {
    const i = e.elements, r = t.elements, a = this.elements, o = i[0], s = i[4], c = i[8], l = i[12], u = i[1], h = i[5], d = i[9], p = i[13], g = i[2], v = i[6], m = i[10], f = i[14], M = i[3], _ = i[7], x = i[11], T = i[15], E = r[0], A = r[4], R = r[8], w = r[12], b = r[1], U = r[5], z = r[9], I = r[13], L = r[2], D = r[6], B = r[10], te = r[14], W = r[3], ie = r[7], G = r[11], Q = r[15];
    return a[0] = o * E + s * b + c * L + l * W, a[4] = o * A + s * U + c * D + l * ie, a[8] = o * R + s * z + c * B + l * G, a[12] = o * w + s * I + c * te + l * Q, a[1] = u * E + h * b + d * L + p * W, a[5] = u * A + h * U + d * D + p * ie, a[9] = u * R + h * z + d * B + p * G, a[13] = u * w + h * I + d * te + p * Q, a[2] = g * E + v * b + m * L + f * W, a[6] = g * A + v * U + m * D + f * ie, a[10] = g * R + v * z + m * B + f * G, a[14] = g * w + v * I + m * te + f * Q, a[3] = M * E + _ * b + x * L + T * W, a[7] = M * A + _ * U + x * D + T * ie, a[11] = M * R + _ * z + x * B + T * G, a[15] = M * w + _ * I + x * te + T * Q, this;
  }
  multiplyScalar(e) {
    const t = this.elements;
    return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this;
  }
  determinant() {
    const e = this.elements, t = e[0], i = e[4], r = e[8], a = e[12], o = e[1], s = e[5], c = e[9], l = e[13], u = e[2], h = e[6], d = e[10], p = e[14], g = e[3], v = e[7], m = e[11], f = e[15];
    return g * (+a * c * h - r * l * h - a * s * d + i * l * d + r * s * p - i * c * p) + v * (+t * c * p - t * l * d + a * o * d - r * o * p + r * l * u - a * c * u) + m * (+t * l * h - t * s * p - a * o * h + i * o * p + a * s * u - i * l * u) + f * (-r * s * u - t * c * h + t * s * d + r * o * h - i * o * d + i * c * u);
  }
  transpose() {
    const e = this.elements;
    let t;
    return t = e[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this;
  }
  setPosition(e, t, i) {
    const r = this.elements;
    return e.isVector3 ? (r[12] = e.x, r[13] = e.y, r[14] = e.z) : (r[12] = e, r[13] = t, r[14] = i), this;
  }
  invert() {
    const e = this.elements, t = e[0], i = e[1], r = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8], h = e[9], d = e[10], p = e[11], g = e[12], v = e[13], m = e[14], f = e[15], M = h * m * l - v * d * l + v * c * p - s * m * p - h * c * f + s * d * f, _ = g * d * l - u * m * l - g * c * p + o * m * p + u * c * f - o * d * f, x = u * v * l - g * h * l + g * s * p - o * v * p - u * s * f + o * h * f, T = g * h * c - u * v * c - g * s * d + o * v * d + u * s * m - o * h * m, E = t * M + i * _ + r * x + a * T;
    if (E === 0)
      return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    const A = 1 / E;
    return e[0] = M * A, e[1] = (v * d * a - h * m * a - v * r * p + i * m * p + h * r * f - i * d * f) * A, e[2] = (s * m * a - v * c * a + v * r * l - i * m * l - s * r * f + i * c * f) * A, e[3] = (h * c * a - s * d * a - h * r * l + i * d * l + s * r * p - i * c * p) * A, e[4] = _ * A, e[5] = (u * m * a - g * d * a + g * r * p - t * m * p - u * r * f + t * d * f) * A, e[6] = (g * c * a - o * m * a - g * r * l + t * m * l + o * r * f - t * c * f) * A, e[7] = (o * d * a - u * c * a + u * r * l - t * d * l - o * r * p + t * c * p) * A, e[8] = x * A, e[9] = (g * h * a - u * v * a - g * i * p + t * v * p + u * i * f - t * h * f) * A, e[10] = (o * v * a - g * s * a + g * i * l - t * v * l - o * i * f + t * s * f) * A, e[11] = (u * s * a - o * h * a - u * i * l + t * h * l + o * i * p - t * s * p) * A, e[12] = T * A, e[13] = (u * v * r - g * h * r + g * i * d - t * v * d - u * i * m + t * h * m) * A, e[14] = (g * s * r - o * v * r - g * i * c + t * v * c + o * i * m - t * s * m) * A, e[15] = (o * h * r - u * s * r + u * i * c - t * h * c - o * i * d + t * s * d) * A, this;
  }
  scale(e) {
    const t = this.elements, i = e.x, r = e.y, a = e.z;
    return t[0] *= i, t[4] *= r, t[8] *= a, t[1] *= i, t[5] *= r, t[9] *= a, t[2] *= i, t[6] *= r, t[10] *= a, t[3] *= i, t[7] *= r, t[11] *= a, this;
  }
  getMaxScaleOnAxis() {
    const e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], i = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], r = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];
    return Math.sqrt(Math.max(t, i, r));
  }
  makeTranslation(e, t, i) {
    return e.isVector3 ? this.set(
      1,
      0,
      0,
      e.x,
      0,
      1,
      0,
      e.y,
      0,
      0,
      1,
      e.z,
      0,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      0,
      e,
      0,
      1,
      0,
      t,
      0,
      0,
      1,
      i,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationX(e) {
    const t = Math.cos(e), i = Math.sin(e);
    return this.set(
      1,
      0,
      0,
      0,
      0,
      t,
      -i,
      0,
      0,
      i,
      t,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationY(e) {
    const t = Math.cos(e), i = Math.sin(e);
    return this.set(
      t,
      0,
      i,
      0,
      0,
      1,
      0,
      0,
      -i,
      0,
      t,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationZ(e) {
    const t = Math.cos(e), i = Math.sin(e);
    return this.set(
      t,
      -i,
      0,
      0,
      i,
      t,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeRotationAxis(e, t) {
    const i = Math.cos(t), r = Math.sin(t), a = 1 - i, o = e.x, s = e.y, c = e.z, l = a * o, u = a * s;
    return this.set(
      l * o + i,
      l * s - r * c,
      l * c + r * s,
      0,
      l * s + r * c,
      u * s + i,
      u * c - r * o,
      0,
      l * c - r * s,
      u * c + r * o,
      a * c * c + i,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(e, t, i) {
    return this.set(
      e,
      0,
      0,
      0,
      0,
      t,
      0,
      0,
      0,
      0,
      i,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  makeShear(e, t, i, r, a, o) {
    return this.set(
      1,
      i,
      a,
      0,
      e,
      1,
      o,
      0,
      t,
      r,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  compose(e, t, i) {
    const r = this.elements, a = t._x, o = t._y, s = t._z, c = t._w, l = a + a, u = o + o, h = s + s, d = a * l, p = a * u, g = a * h, v = o * u, m = o * h, f = s * h, M = c * l, _ = c * u, x = c * h, T = i.x, E = i.y, A = i.z;
    return r[0] = (1 - (v + f)) * T, r[1] = (p + x) * T, r[2] = (g - _) * T, r[3] = 0, r[4] = (p - x) * E, r[5] = (1 - (d + f)) * E, r[6] = (m + M) * E, r[7] = 0, r[8] = (g + _) * A, r[9] = (m - M) * A, r[10] = (1 - (d + v)) * A, r[11] = 0, r[12] = e.x, r[13] = e.y, r[14] = e.z, r[15] = 1, this;
  }
  decompose(e, t, i) {
    const r = this.elements;
    let a = _i.set(r[0], r[1], r[2]).length();
    const o = _i.set(r[4], r[5], r[6]).length(), s = _i.set(r[8], r[9], r[10]).length();
    this.determinant() < 0 && (a = -a), e.x = r[12], e.y = r[13], e.z = r[14], Wt.copy(this);
    const l = 1 / a, u = 1 / o, h = 1 / s;
    return Wt.elements[0] *= l, Wt.elements[1] *= l, Wt.elements[2] *= l, Wt.elements[4] *= u, Wt.elements[5] *= u, Wt.elements[6] *= u, Wt.elements[8] *= h, Wt.elements[9] *= h, Wt.elements[10] *= h, t.setFromRotationMatrix(Wt), i.x = a, i.y = o, i.z = s, this;
  }
  makePerspective(e, t, i, r, a, o, s = Mn) {
    const c = this.elements, l = 2 * a / (t - e), u = 2 * a / (i - r), h = (t + e) / (t - e), d = (i + r) / (i - r);
    let p, g;
    if (s === Mn)
      p = -(o + a) / (o - a), g = -2 * o * a / (o - a);
    else if (s === la)
      p = -o / (o - a), g = -o * a / (o - a);
    else
      throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + s);
    return c[0] = l, c[4] = 0, c[8] = h, c[12] = 0, c[1] = 0, c[5] = u, c[9] = d, c[13] = 0, c[2] = 0, c[6] = 0, c[10] = p, c[14] = g, c[3] = 0, c[7] = 0, c[11] = -1, c[15] = 0, this;
  }
  makeOrthographic(e, t, i, r, a, o, s = Mn) {
    const c = this.elements, l = 1 / (t - e), u = 1 / (i - r), h = 1 / (o - a), d = (t + e) * l, p = (i + r) * u;
    let g, v;
    if (s === Mn)
      g = (o + a) * h, v = -2 * h;
    else if (s === la)
      g = a * h, v = -1 * h;
    else
      throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + s);
    return c[0] = 2 * l, c[4] = 0, c[8] = 0, c[12] = -d, c[1] = 0, c[5] = 2 * u, c[9] = 0, c[13] = -p, c[2] = 0, c[6] = 0, c[10] = v, c[14] = -g, c[3] = 0, c[7] = 0, c[11] = 0, c[15] = 1, this;
  }
  equals(e) {
    const t = this.elements, i = e.elements;
    for (let r = 0; r < 16; r++)
      if (t[r] !== i[r])
        return !1;
    return !0;
  }
  fromArray(e, t = 0) {
    for (let i = 0; i < 16; i++)
      this.elements[i] = e[i + t];
    return this;
  }
  toArray(e = [], t = 0) {
    const i = this.elements;
    return e[t] = i[0], e[t + 1] = i[1], e[t + 2] = i[2], e[t + 3] = i[3], e[t + 4] = i[4], e[t + 5] = i[5], e[t + 6] = i[6], e[t + 7] = i[7], e[t + 8] = i[8], e[t + 9] = i[9], e[t + 10] = i[10], e[t + 11] = i[11], e[t + 12] = i[12], e[t + 13] = i[13], e[t + 14] = i[14], e[t + 15] = i[15], e;
  }
}
const _i = /* @__PURE__ */ new O(), Wt = /* @__PURE__ */ new Je(), vd = /* @__PURE__ */ new O(0, 0, 0), _d = /* @__PURE__ */ new O(1, 1, 1), Dn = /* @__PURE__ */ new O(), Or = /* @__PURE__ */ new O(), Dt = /* @__PURE__ */ new O(), xc = /* @__PURE__ */ new Je(), bc = /* @__PURE__ */ new Jt();
class on {
  constructor(e = 0, t = 0, i = 0, r = on.DEFAULT_ORDER) {
    this.isEuler = !0, this._x = e, this._y = t, this._z = i, this._order = r;
  }
  get x() {
    return this._x;
  }
  set x(e) {
    this._x = e, this._onChangeCallback();
  }
  get y() {
    return this._y;
  }
  set y(e) {
    this._y = e, this._onChangeCallback();
  }
  get z() {
    return this._z;
  }
  set z(e) {
    this._z = e, this._onChangeCallback();
  }
  get order() {
    return this._order;
  }
  set order(e) {
    this._order = e, this._onChangeCallback();
  }
  set(e, t, i, r = this._order) {
    return this._x = e, this._y = t, this._z = i, this._order = r, this._onChangeCallback(), this;
  }
  clone() {
    return new this.constructor(this._x, this._y, this._z, this._order);
  }
  copy(e) {
    return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this;
  }
  setFromRotationMatrix(e, t = this._order, i = !0) {
    const r = e.elements, a = r[0], o = r[4], s = r[8], c = r[1], l = r[5], u = r[9], h = r[2], d = r[6], p = r[10];
    switch (t) {
      case "XYZ":
        this._y = Math.asin(mt(s, -1, 1)), Math.abs(s) < 0.9999999 ? (this._x = Math.atan2(-u, p), this._z = Math.atan2(-o, a)) : (this._x = Math.atan2(d, l), this._z = 0);
        break;
      case "YXZ":
        this._x = Math.asin(-mt(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._y = Math.atan2(s, p), this._z = Math.atan2(c, l)) : (this._y = Math.atan2(-h, a), this._z = 0);
        break;
      case "ZXY":
        this._x = Math.asin(mt(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._y = Math.atan2(-h, p), this._z = Math.atan2(-o, l)) : (this._y = 0, this._z = Math.atan2(c, a));
        break;
      case "ZYX":
        this._y = Math.asin(-mt(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._x = Math.atan2(d, p), this._z = Math.atan2(c, a)) : (this._x = 0, this._z = Math.atan2(-o, l));
        break;
      case "YZX":
        this._z = Math.asin(mt(c, -1, 1)), Math.abs(c) < 0.9999999 ? (this._x = Math.atan2(-u, l), this._y = Math.atan2(-h, a)) : (this._x = 0, this._y = Math.atan2(s, p));
        break;
      case "XZY":
        this._z = Math.asin(-mt(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(d, l), this._y = Math.atan2(s, a)) : (this._x = Math.atan2(-u, p), this._y = 0);
        break;
      default:
        console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t);
    }
    return this._order = t, i === !0 && this._onChangeCallback(), this;
  }
  setFromQuaternion(e, t, i) {
    return xc.makeRotationFromQuaternion(e), this.setFromRotationMatrix(xc, t, i);
  }
  setFromVector3(e, t = this._order) {
    return this.set(e.x, e.y, e.z, t);
  }
  reorder(e) {
    return bc.setFromEuler(this), this.setFromQuaternion(bc, e);
  }
  equals(e) {
    return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order;
  }
  fromArray(e) {
    return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e;
  }
  _onChange(e) {
    return this._onChangeCallback = e, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._order;
  }
}
on.DEFAULT_ORDER = "XYZ";
class ls {
  constructor() {
    this.mask = 1;
  }
  set(e) {
    this.mask = (1 << e | 0) >>> 0;
  }
  enable(e) {
    this.mask |= 1 << e | 0;
  }
  enableAll() {
    this.mask = -1;
  }
  toggle(e) {
    this.mask ^= 1 << e | 0;
  }
  disable(e) {
    this.mask &= ~(1 << e | 0);
  }
  disableAll() {
    this.mask = 0;
  }
  test(e) {
    return (this.mask & e.mask) !== 0;
  }
  isEnabled(e) {
    return (this.mask & (1 << e | 0)) !== 0;
  }
}
let yd = 0;
const Mc = /* @__PURE__ */ new O(), yi = /* @__PURE__ */ new Jt(), fn = /* @__PURE__ */ new Je(), Ir = /* @__PURE__ */ new O(), Zi = /* @__PURE__ */ new O(), xd = /* @__PURE__ */ new O(), bd = /* @__PURE__ */ new Jt(), Sc = /* @__PURE__ */ new O(1, 0, 0), Ec = /* @__PURE__ */ new O(0, 1, 0), wc = /* @__PURE__ */ new O(0, 0, 1), Tc = { type: "added" }, Md = { type: "removed" }, xi = { type: "childadded", child: null }, Za = { type: "childremoved", child: null };
class vt extends Qt {
  constructor() {
    super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: yd++ }), this.uuid = Gi(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = vt.DEFAULT_UP.clone();
    const e = new O(), t = new on(), i = new Jt(), r = new O(1, 1, 1);
    function a() {
      i.setFromEuler(t, !1);
    }
    function o() {
      t.setFromQuaternion(i, void 0, !1);
    }
    t._onChange(a), i._onChange(o), Object.defineProperties(this, {
      position: {
        configurable: !0,
        enumerable: !0,
        value: e
      },
      rotation: {
        configurable: !0,
        enumerable: !0,
        value: t
      },
      quaternion: {
        configurable: !0,
        enumerable: !0,
        value: i
      },
      scale: {
        configurable: !0,
        enumerable: !0,
        value: r
      },
      modelViewMatrix: {
        value: new Je()
      },
      normalMatrix: {
        value: new Fe()
      }
    }), this.matrix = new Je(), this.matrixWorld = new Je(), this.matrixAutoUpdate = vt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = vt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new ls(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
  }
  onBeforeShadow() {
  }
  onAfterShadow() {
  }
  onBeforeRender() {
  }
  onAfterRender() {
  }
  applyMatrix4(e) {
    this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale);
  }
  applyQuaternion(e) {
    return this.quaternion.premultiply(e), this;
  }
  setRotationFromAxisAngle(e, t) {
    this.quaternion.setFromAxisAngle(e, t);
  }
  setRotationFromEuler(e) {
    this.quaternion.setFromEuler(e, !0);
  }
  setRotationFromMatrix(e) {
    this.quaternion.setFromRotationMatrix(e);
  }
  setRotationFromQuaternion(e) {
    this.quaternion.copy(e);
  }
  rotateOnAxis(e, t) {
    return yi.setFromAxisAngle(e, t), this.quaternion.multiply(yi), this;
  }
  rotateOnWorldAxis(e, t) {
    return yi.setFromAxisAngle(e, t), this.quaternion.premultiply(yi), this;
  }
  rotateX(e) {
    return this.rotateOnAxis(Sc, e);
  }
  rotateY(e) {
    return this.rotateOnAxis(Ec, e);
  }
  rotateZ(e) {
    return this.rotateOnAxis(wc, e);
  }
  translateOnAxis(e, t) {
    return Mc.copy(e).applyQuaternion(this.quaternion), this.position.add(Mc.multiplyScalar(t)), this;
  }
  translateX(e) {
    return this.translateOnAxis(Sc, e);
  }
  translateY(e) {
    return this.translateOnAxis(Ec, e);
  }
  translateZ(e) {
    return this.translateOnAxis(wc, e);
  }
  localToWorld(e) {
    return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld);
  }
  worldToLocal(e) {
    return this.updateWorldMatrix(!0, !1), e.applyMatrix4(fn.copy(this.matrixWorld).invert());
  }
  lookAt(e, t, i) {
    e.isVector3 ? Ir.copy(e) : Ir.set(e, t, i);
    const r = this.parent;
    this.updateWorldMatrix(!0, !1), Zi.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? fn.lookAt(Zi, Ir, this.up) : fn.lookAt(Ir, Zi, this.up), this.quaternion.setFromRotationMatrix(fn), r && (fn.extractRotation(r.matrixWorld), yi.setFromRotationMatrix(fn), this.quaternion.premultiply(yi.invert()));
  }
  add(e) {
    if (arguments.length > 1) {
      for (let t = 0; t < arguments.length; t++)
        this.add(arguments[t]);
      return this;
    }
    return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.removeFromParent(), e.parent = this, this.children.push(e), e.dispatchEvent(Tc), xi.child = e, this.dispatchEvent(xi), xi.child = null) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e), this);
  }
  remove(e) {
    if (arguments.length > 1) {
      for (let i = 0; i < arguments.length; i++)
        this.remove(arguments[i]);
      return this;
    }
    const t = this.children.indexOf(e);
    return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(Md), Za.child = e, this.dispatchEvent(Za), Za.child = null), this;
  }
  removeFromParent() {
    const e = this.parent;
    return e !== null && e.remove(this), this;
  }
  clear() {
    return this.remove(...this.children);
  }
  attach(e) {
    return this.updateWorldMatrix(!0, !1), fn.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), fn.multiply(e.parent.matrixWorld)), e.applyMatrix4(fn), e.removeFromParent(), e.parent = this, this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(Tc), xi.child = e, this.dispatchEvent(xi), xi.child = null, this;
  }
  getObjectById(e) {
    return this.getObjectByProperty("id", e);
  }
  getObjectByName(e) {
    return this.getObjectByProperty("name", e);
  }
  getObjectByProperty(e, t) {
    if (this[e] === t)
      return this;
    for (let i = 0, r = this.children.length; i < r; i++) {
      const o = this.children[i].getObjectByProperty(e, t);
      if (o !== void 0)
        return o;
    }
  }
  getObjectsByProperty(e, t, i = []) {
    this[e] === t && i.push(this);
    const r = this.children;
    for (let a = 0, o = r.length; a < o; a++)
      r[a].getObjectsByProperty(e, t, i);
    return i;
  }
  getWorldPosition(e) {
    return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld);
  }
  getWorldQuaternion(e) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Zi, e, xd), e;
  }
  getWorldScale(e) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Zi, bd, e), e;
  }
  getWorldDirection(e) {
    this.updateWorldMatrix(!0, !1);
    const t = this.matrixWorld.elements;
    return e.set(t[8], t[9], t[10]).normalize();
  }
  raycast() {
  }
  traverse(e) {
    e(this);
    const t = this.children;
    for (let i = 0, r = t.length; i < r; i++)
      t[i].traverse(e);
  }
  traverseVisible(e) {
    if (this.visible === !1)
      return;
    e(this);
    const t = this.children;
    for (let i = 0, r = t.length; i < r; i++)
      t[i].traverseVisible(e);
  }
  traverseAncestors(e) {
    const t = this.parent;
    t !== null && (e(t), t.traverseAncestors(e));
  }
  updateMatrix() {
    this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;
  }
  updateMatrixWorld(e) {
    this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, e = !0);
    const t = this.children;
    for (let i = 0, r = t.length; i < r; i++) {
      const a = t[i];
      (a.matrixWorldAutoUpdate === !0 || e === !0) && a.updateMatrixWorld(e);
    }
  }
  updateWorldMatrix(e, t) {
    const i = this.parent;
    if (e === !0 && i !== null && i.matrixWorldAutoUpdate === !0 && i.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), t === !0) {
      const r = this.children;
      for (let a = 0, o = r.length; a < o; a++) {
        const s = r[a];
        s.matrixWorldAutoUpdate === !0 && s.updateWorldMatrix(!1, !0);
      }
    }
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string", i = {};
    t && (e = {
      geometries: {},
      materials: {},
      textures: {},
      images: {},
      shapes: {},
      skeletons: {},
      animations: {},
      nodes: {}
    }, i.metadata = {
      version: 4.6,
      type: "Object",
      generator: "Object3D.toJSON"
    });
    const r = {};
    r.uuid = this.uuid, r.type = this.type, this.name !== "" && (r.name = this.name), this.castShadow === !0 && (r.castShadow = !0), this.receiveShadow === !0 && (r.receiveShadow = !0), this.visible === !1 && (r.visible = !1), this.frustumCulled === !1 && (r.frustumCulled = !1), this.renderOrder !== 0 && (r.renderOrder = this.renderOrder), Object.keys(this.userData).length > 0 && (r.userData = this.userData), r.layers = this.layers.mask, r.matrix = this.matrix.toArray(), r.up = this.up.toArray(), this.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1), this.isInstancedMesh && (r.type = "InstancedMesh", r.count = this.count, r.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (r.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (r.type = "BatchedMesh", r.perObjectFrustumCulled = this.perObjectFrustumCulled, r.sortObjects = this.sortObjects, r.drawRanges = this._drawRanges, r.reservedRanges = this._reservedRanges, r.visibility = this._visibility, r.active = this._active, r.bounds = this._bounds.map((s) => ({
      boxInitialized: s.boxInitialized,
      boxMin: s.box.min.toArray(),
      boxMax: s.box.max.toArray(),
      sphereInitialized: s.sphereInitialized,
      sphereRadius: s.sphere.radius,
      sphereCenter: s.sphere.center.toArray()
    })), r.maxGeometryCount = this._maxGeometryCount, r.maxVertexCount = this._maxVertexCount, r.maxIndexCount = this._maxIndexCount, r.geometryInitialized = this._geometryInitialized, r.geometryCount = this._geometryCount, r.matricesTexture = this._matricesTexture.toJSON(e), this.boundingSphere !== null && (r.boundingSphere = {
      center: r.boundingSphere.center.toArray(),
      radius: r.boundingSphere.radius
    }), this.boundingBox !== null && (r.boundingBox = {
      min: r.boundingBox.min.toArray(),
      max: r.boundingBox.max.toArray()
    }));
    function a(s, c) {
      return s[c.uuid] === void 0 && (s[c.uuid] = c.toJSON(e)), c.uuid;
    }
    if (this.isScene)
      this.background && (this.background.isColor ? r.background = this.background.toJSON() : this.background.isTexture && (r.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (r.environment = this.environment.toJSON(e).uuid);
    else if (this.isMesh || this.isLine || this.isPoints) {
      r.geometry = a(e.geometries, this.geometry);
      const s = this.geometry.parameters;
      if (s !== void 0 && s.shapes !== void 0) {
        const c = s.shapes;
        if (Array.isArray(c))
          for (let l = 0, u = c.length; l < u; l++) {
            const h = c[l];
            a(e.shapes, h);
          }
        else
          a(e.shapes, c);
      }
    }
    if (this.isSkinnedMesh && (r.bindMode = this.bindMode, r.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (a(e.skeletons, this.skeleton), r.skeleton = this.skeleton.uuid)), this.material !== void 0)
      if (Array.isArray(this.material)) {
        const s = [];
        for (let c = 0, l = this.material.length; c < l; c++)
          s.push(a(e.materials, this.material[c]));
        r.material = s;
      } else
        r.material = a(e.materials, this.material);
    if (this.children.length > 0) {
      r.children = [];
      for (let s = 0; s < this.children.length; s++)
        r.children.push(this.children[s].toJSON(e).object);
    }
    if (this.animations.length > 0) {
      r.animations = [];
      for (let s = 0; s < this.animations.length; s++) {
        const c = this.animations[s];
        r.animations.push(a(e.animations, c));
      }
    }
    if (t) {
      const s = o(e.geometries), c = o(e.materials), l = o(e.textures), u = o(e.images), h = o(e.shapes), d = o(e.skeletons), p = o(e.animations), g = o(e.nodes);
      s.length > 0 && (i.geometries = s), c.length > 0 && (i.materials = c), l.length > 0 && (i.textures = l), u.length > 0 && (i.images = u), h.length > 0 && (i.shapes = h), d.length > 0 && (i.skeletons = d), p.length > 0 && (i.animations = p), g.length > 0 && (i.nodes = g);
    }
    return i.object = r, i;
    function o(s) {
      const c = [];
      for (const l in s) {
        const u = s[l];
        delete u.metadata, c.push(u);
      }
      return c;
    }
  }
  clone(e) {
    return new this.constructor().copy(this, e);
  }
  copy(e, t = !0) {
    if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.animations = e.animations.slice(), this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0)
      for (let i = 0; i < e.children.length; i++) {
        const r = e.children[i];
        this.add(r.clone());
      }
    return this;
  }
}
vt.DEFAULT_UP = /* @__PURE__ */ new O(0, 1, 0);
vt.DEFAULT_MATRIX_AUTO_UPDATE = !0;
vt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
const jt = /* @__PURE__ */ new O(), dn = /* @__PURE__ */ new O(), Ja = /* @__PURE__ */ new O(), pn = /* @__PURE__ */ new O(), bi = /* @__PURE__ */ new O(), Mi = /* @__PURE__ */ new O(), Ac = /* @__PURE__ */ new O(), Qa = /* @__PURE__ */ new O(), eo = /* @__PURE__ */ new O(), to = /* @__PURE__ */ new O();
class nn {
  constructor(e = new O(), t = new O(), i = new O()) {
    this.a = e, this.b = t, this.c = i;
  }
  static getNormal(e, t, i, r) {
    r.subVectors(i, t), jt.subVectors(e, t), r.cross(jt);
    const a = r.lengthSq();
    return a > 0 ? r.multiplyScalar(1 / Math.sqrt(a)) : r.set(0, 0, 0);
  }
  // static/instance method to calculate barycentric coordinates
  // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
  static getBarycoord(e, t, i, r, a) {
    jt.subVectors(r, t), dn.subVectors(i, t), Ja.subVectors(e, t);
    const o = jt.dot(jt), s = jt.dot(dn), c = jt.dot(Ja), l = dn.dot(dn), u = dn.dot(Ja), h = o * l - s * s;
    if (h === 0)
      return a.set(0, 0, 0), null;
    const d = 1 / h, p = (l * c - s * u) * d, g = (o * u - s * c) * d;
    return a.set(1 - p - g, g, p);
  }
  static containsPoint(e, t, i, r) {
    return this.getBarycoord(e, t, i, r, pn) === null ? !1 : pn.x >= 0 && pn.y >= 0 && pn.x + pn.y <= 1;
  }
  static getInterpolation(e, t, i, r, a, o, s, c) {
    return this.getBarycoord(e, t, i, r, pn) === null ? (c.x = 0, c.y = 0, "z" in c && (c.z = 0), "w" in c && (c.w = 0), null) : (c.setScalar(0), c.addScaledVector(a, pn.x), c.addScaledVector(o, pn.y), c.addScaledVector(s, pn.z), c);
  }
  static isFrontFacing(e, t, i, r) {
    return jt.subVectors(i, t), dn.subVectors(e, t), jt.cross(dn).dot(r) < 0;
  }
  set(e, t, i) {
    return this.a.copy(e), this.b.copy(t), this.c.copy(i), this;
  }
  setFromPointsAndIndices(e, t, i, r) {
    return this.a.copy(e[t]), this.b.copy(e[i]), this.c.copy(e[r]), this;
  }
  setFromAttributeAndIndices(e, t, i, r) {
    return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, i), this.c.fromBufferAttribute(e, r), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this;
  }
  getArea() {
    return jt.subVectors(this.c, this.b), dn.subVectors(this.a, this.b), jt.cross(dn).length() * 0.5;
  }
  getMidpoint(e) {
    return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
  }
  getNormal(e) {
    return nn.getNormal(this.a, this.b, this.c, e);
  }
  getPlane(e) {
    return e.setFromCoplanarPoints(this.a, this.b, this.c);
  }
  getBarycoord(e, t) {
    return nn.getBarycoord(e, this.a, this.b, this.c, t);
  }
  getInterpolation(e, t, i, r, a) {
    return nn.getInterpolation(e, this.a, this.b, this.c, t, i, r, a);
  }
  containsPoint(e) {
    return nn.containsPoint(e, this.a, this.b, this.c);
  }
  isFrontFacing(e) {
    return nn.isFrontFacing(this.a, this.b, this.c, e);
  }
  intersectsBox(e) {
    return e.intersectsTriangle(this);
  }
  closestPointToPoint(e, t) {
    const i = this.a, r = this.b, a = this.c;
    let o, s;
    bi.subVectors(r, i), Mi.subVectors(a, i), Qa.subVectors(e, i);
    const c = bi.dot(Qa), l = Mi.dot(Qa);
    if (c <= 0 && l <= 0)
      return t.copy(i);
    eo.subVectors(e, r);
    const u = bi.dot(eo), h = Mi.dot(eo);
    if (u >= 0 && h <= u)
      return t.copy(r);
    const d = c * h - u * l;
    if (d <= 0 && c >= 0 && u <= 0)
      return o = c / (c - u), t.copy(i).addScaledVector(bi, o);
    to.subVectors(e, a);
    const p = bi.dot(to), g = Mi.dot(to);
    if (g >= 0 && p <= g)
      return t.copy(a);
    const v = p * l - c * g;
    if (v <= 0 && l >= 0 && g <= 0)
      return s = l / (l - g), t.copy(i).addScaledVector(Mi, s);
    const m = u * g - p * h;
    if (m <= 0 && h - u >= 0 && p - g >= 0)
      return Ac.subVectors(a, r), s = (h - u) / (h - u + (p - g)), t.copy(r).addScaledVector(Ac, s);
    const f = 1 / (m + v + d);
    return o = v * f, s = d * f, t.copy(i).addScaledVector(bi, o).addScaledVector(Mi, s);
  }
  equals(e) {
    return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c);
  }
}
const Su = {
  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,
  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,
  lavender: 15132410,
  lavenderblush: 16773365,
  lawngreen: 8190976,
  lemonchiffon: 16775885,
  lightblue: 11393254,
  lightcoral: 15761536,
  lightcyan: 14745599,
  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,
  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,
  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
}, On = { h: 0, s: 0, l: 0 }, Nr = { h: 0, s: 0, l: 0 };
function no(n, e, t) {
  return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? n + (e - n) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? n + (e - n) * 6 * (2 / 3 - t) : n;
}
class We {
  constructor(e, t, i) {
    return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(e, t, i);
  }
  set(e, t, i) {
    if (t === void 0 && i === void 0) {
      const r = e;
      r && r.isColor ? this.copy(r) : typeof r == "number" ? this.setHex(r) : typeof r == "string" && this.setStyle(r);
    } else
      this.setRGB(e, t, i);
    return this;
  }
  setScalar(e) {
    return this.r = e, this.g = e, this.b = e, this;
  }
  setHex(e, t = $t) {
    return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, Ke.toWorkingColorSpace(this, t), this;
  }
  setRGB(e, t, i, r = Ke.workingColorSpace) {
    return this.r = e, this.g = t, this.b = i, Ke.toWorkingColorSpace(this, r), this;
  }
  setHSL(e, t, i, r = Ke.workingColorSpace) {
    if (e = cs(e, 1), t = mt(t, 0, 1), i = mt(i, 0, 1), t === 0)
      this.r = this.g = this.b = i;
    else {
      const a = i <= 0.5 ? i * (1 + t) : i + t - i * t, o = 2 * i - a;
      this.r = no(o, a, e + 1 / 3), this.g = no(o, a, e), this.b = no(o, a, e - 1 / 3);
    }
    return Ke.toWorkingColorSpace(this, r), this;
  }
  setStyle(e, t = $t) {
    function i(a) {
      a !== void 0 && parseFloat(a) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored.");
    }
    let r;
    if (r = /^(\w+)\(([^\)]*)\)/.exec(e)) {
      let a;
      const o = r[1], s = r[2];
      switch (o) {
        case "rgb":
        case "rgba":
          if (a = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))
            return i(a[4]), this.setRGB(
              Math.min(255, parseInt(a[1], 10)) / 255,
              Math.min(255, parseInt(a[2], 10)) / 255,
              Math.min(255, parseInt(a[3], 10)) / 255,
              t
            );
          if (a = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))
            return i(a[4]), this.setRGB(
              Math.min(100, parseInt(a[1], 10)) / 100,
              Math.min(100, parseInt(a[2], 10)) / 100,
              Math.min(100, parseInt(a[3], 10)) / 100,
              t
            );
          break;
        case "hsl":
        case "hsla":
          if (a = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))
            return i(a[4]), this.setHSL(
              parseFloat(a[1]) / 360,
              parseFloat(a[2]) / 100,
              parseFloat(a[3]) / 100,
              t
            );
          break;
        default:
          console.warn("THREE.Color: Unknown color model " + e);
      }
    } else if (r = /^\#([A-Fa-f\d]+)$/.exec(e)) {
      const a = r[1], o = a.length;
      if (o === 3)
        return this.setRGB(
          parseInt(a.charAt(0), 16) / 15,
          parseInt(a.charAt(1), 16) / 15,
          parseInt(a.charAt(2), 16) / 15,
          t
        );
      if (o === 6)
        return this.setHex(parseInt(a, 16), t);
      console.warn("THREE.Color: Invalid hex color " + e);
    } else if (e && e.length > 0)
      return this.setColorName(e, t);
    return this;
  }
  setColorName(e, t = $t) {
    const i = Su[e.toLowerCase()];
    return i !== void 0 ? this.setHex(i, t) : console.warn("THREE.Color: Unknown color " + e), this;
  }
  clone() {
    return new this.constructor(this.r, this.g, this.b);
  }
  copy(e) {
    return this.r = e.r, this.g = e.g, this.b = e.b, this;
  }
  copySRGBToLinear(e) {
    return this.r = Fi(e.r), this.g = Fi(e.g), this.b = Fi(e.b), this;
  }
  copyLinearToSRGB(e) {
    return this.r = Ga(e.r), this.g = Ga(e.g), this.b = Ga(e.b), this;
  }
  convertSRGBToLinear() {
    return this.copySRGBToLinear(this), this;
  }
  convertLinearToSRGB() {
    return this.copyLinearToSRGB(this), this;
  }
  getHex(e = $t) {
    return Ke.fromWorkingColorSpace(xt.copy(this), e), Math.round(mt(xt.r * 255, 0, 255)) * 65536 + Math.round(mt(xt.g * 255, 0, 255)) * 256 + Math.round(mt(xt.b * 255, 0, 255));
  }
  getHexString(e = $t) {
    return ("000000" + this.getHex(e).toString(16)).slice(-6);
  }
  getHSL(e, t = Ke.workingColorSpace) {
    Ke.fromWorkingColorSpace(xt.copy(this), t);
    const i = xt.r, r = xt.g, a = xt.b, o = Math.max(i, r, a), s = Math.min(i, r, a);
    let c, l;
    const u = (s + o) / 2;
    if (s === o)
      c = 0, l = 0;
    else {
      const h = o - s;
      switch (l = u <= 0.5 ? h / (o + s) : h / (2 - o - s), o) {
        case i:
          c = (r - a) / h + (r < a ? 6 : 0);
          break;
        case r:
          c = (a - i) / h + 2;
          break;
        case a:
          c = (i - r) / h + 4;
          break;
      }
      c /= 6;
    }
    return e.h = c, e.s = l, e.l = u, e;
  }
  getRGB(e, t = Ke.workingColorSpace) {
    return Ke.fromWorkingColorSpace(xt.copy(this), t), e.r = xt.r, e.g = xt.g, e.b = xt.b, e;
  }
  getStyle(e = $t) {
    Ke.fromWorkingColorSpace(xt.copy(this), e);
    const t = xt.r, i = xt.g, r = xt.b;
    return e !== $t ? `color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})` : `rgb(${Math.round(t * 255)},${Math.round(i * 255)},${Math.round(r * 255)})`;
  }
  offsetHSL(e, t, i) {
    return this.getHSL(On), this.setHSL(On.h + e, On.s + t, On.l + i);
  }
  add(e) {
    return this.r += e.r, this.g += e.g, this.b += e.b, this;
  }
  addColors(e, t) {
    return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this;
  }
  addScalar(e) {
    return this.r += e, this.g += e, this.b += e, this;
  }
  sub(e) {
    return this.r = Math.max(0, this.r - e.r), this.g = Math.max(0, this.g - e.g), this.b = Math.max(0, this.b - e.b), this;
  }
  multiply(e) {
    return this.r *= e.r, this.g *= e.g, this.b *= e.b, this;
  }
  multiplyScalar(e) {
    return this.r *= e, this.g *= e, this.b *= e, this;
  }
  lerp(e, t) {
    return this.r += (e.r - this.r) * t, this.g += (e.g - this.g) * t, this.b += (e.b - this.b) * t, this;
  }
  lerpColors(e, t, i) {
    return this.r = e.r + (t.r - e.r) * i, this.g = e.g + (t.g - e.g) * i, this.b = e.b + (t.b - e.b) * i, this;
  }
  lerpHSL(e, t) {
    this.getHSL(On), e.getHSL(Nr);
    const i = hr(On.h, Nr.h, t), r = hr(On.s, Nr.s, t), a = hr(On.l, Nr.l, t);
    return this.setHSL(i, r, a), this;
  }
  setFromVector3(e) {
    return this.r = e.x, this.g = e.y, this.b = e.z, this;
  }
  applyMatrix3(e) {
    const t = this.r, i = this.g, r = this.b, a = e.elements;
    return this.r = a[0] * t + a[3] * i + a[6] * r, this.g = a[1] * t + a[4] * i + a[7] * r, this.b = a[2] * t + a[5] * i + a[8] * r, this;
  }
  equals(e) {
    return e.r === this.r && e.g === this.g && e.b === this.b;
  }
  fromArray(e, t = 0) {
    return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e;
  }
  fromBufferAttribute(e, t) {
    return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), this;
  }
  toJSON() {
    return this.getHex();
  }
  *[Symbol.iterator]() {
    yield this.r, yield this.g, yield this.b;
  }
}
const xt = /* @__PURE__ */ new We();
We.NAMES = Su;
let Sd = 0;
class Wi extends Qt {
  constructor() {
    super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: Sd++ }), this.uuid = Gi(), this.name = "", this.type = "Material", this.blending = Ni, this.side = Hn, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = Io, this.blendDst = No, this.blendEquation = ii, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new We(0, 0, 0), this.blendAlpha = 0, this.depthFunc = aa, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = fc, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = di, this.stencilZFail = di, this.stencilZPass = di, this.stencilWrite = !1, this.clippingPlanes = null, this.clipIntersection = !1, this.clipShadows = !1, this.shadowSide = null, this.colorWrite = !0, this.precision = null, this.polygonOffset = !1, this.polygonOffsetFactor = 0, this.polygonOffsetUnits = 0, this.dithering = !1, this.alphaToCoverage = !1, this.premultipliedAlpha = !1, this.forceSinglePass = !1, this.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0;
  }
  get alphaTest() {
    return this._alphaTest;
  }
  set alphaTest(e) {
    this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e;
  }
  onBuild() {
  }
  onBeforeRender() {
  }
  onBeforeCompile() {
  }
  customProgramCacheKey() {
    return this.onBeforeCompile.toString();
  }
  setValues(e) {
    if (e !== void 0)
      for (const t in e) {
        const i = e[t];
        if (i === void 0) {
          console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);
          continue;
        }
        const r = this[t];
        if (r === void 0) {
          console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);
          continue;
        }
        r && r.isColor ? r.set(i) : r && r.isVector3 && i && i.isVector3 ? r.copy(i) : this[t] = i;
      }
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    t && (e = {
      textures: {},
      images: {}
    });
    const i = {
      metadata: {
        version: 4.6,
        type: "Material",
        generator: "Material.toJSON"
      }
    };
    i.uuid = this.uuid, i.type = this.type, this.name !== "" && (i.name = this.name), this.color && this.color.isColor && (i.color = this.color.getHex()), this.roughness !== void 0 && (i.roughness = this.roughness), this.metalness !== void 0 && (i.metalness = this.metalness), this.sheen !== void 0 && (i.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (i.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (i.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (i.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (i.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (i.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (i.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (i.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (i.shininess = this.shininess), this.clearcoat !== void 0 && (i.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (i.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (i.clearcoatMap = this.clearcoatMap.toJSON(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (i.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (i.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, i.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.iridescence !== void 0 && (i.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (i.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (i.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (i.iridescenceMap = this.iridescenceMap.toJSON(e).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (i.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid), this.anisotropy !== void 0 && (i.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (i.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (i.anisotropyMap = this.anisotropyMap.toJSON(e).uuid), this.map && this.map.isTexture && (i.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (i.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (i.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (i.lightMap = this.lightMap.toJSON(e).uuid, i.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (i.aoMap = this.aoMap.toJSON(e).uuid, i.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (i.bumpMap = this.bumpMap.toJSON(e).uuid, i.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (i.normalMap = this.normalMap.toJSON(e).uuid, i.normalMapType = this.normalMapType, i.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (i.displacementMap = this.displacementMap.toJSON(e).uuid, i.displacementScale = this.displacementScale, i.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (i.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (i.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (i.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (i.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (i.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (i.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (i.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (i.combine = this.combine)), this.envMapRotation !== void 0 && (i.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (i.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (i.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (i.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (i.gradientMap = this.gradientMap.toJSON(e).uuid), this.transmission !== void 0 && (i.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (i.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (i.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (i.thicknessMap = this.thicknessMap.toJSON(e).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== 1 / 0 && (i.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (i.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (i.size = this.size), this.shadowSide !== null && (i.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (i.sizeAttenuation = this.sizeAttenuation), this.blending !== Ni && (i.blending = this.blending), this.side !== Hn && (i.side = this.side), this.vertexColors === !0 && (i.vertexColors = !0), this.opacity < 1 && (i.opacity = this.opacity), this.transparent === !0 && (i.transparent = !0), this.blendSrc !== Io && (i.blendSrc = this.blendSrc), this.blendDst !== No && (i.blendDst = this.blendDst), this.blendEquation !== ii && (i.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (i.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (i.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (i.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (i.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (i.blendAlpha = this.blendAlpha), this.depthFunc !== aa && (i.depthFunc = this.depthFunc), this.depthTest === !1 && (i.depthTest = this.depthTest), this.depthWrite === !1 && (i.depthWrite = this.depthWrite), this.colorWrite === !1 && (i.colorWrite = this.colorWrite), this.stencilWriteMask !== 255 && (i.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== fc && (i.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (i.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (i.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== di && (i.stencilFail = this.stencilFail), this.stencilZFail !== di && (i.stencilZFail = this.stencilZFail), this.stencilZPass !== di && (i.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (i.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (i.rotation = this.rotation), this.polygonOffset === !0 && (i.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (i.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (i.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (i.linewidth = this.linewidth), this.dashSize !== void 0 && (i.dashSize = this.dashSize), this.gapSize !== void 0 && (i.gapSize = this.gapSize), this.scale !== void 0 && (i.scale = this.scale), this.dithering === !0 && (i.dithering = !0), this.alphaTest > 0 && (i.alphaTest = this.alphaTest), this.alphaHash === !0 && (i.alphaHash = !0), this.alphaToCoverage === !0 && (i.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (i.premultipliedAlpha = !0), this.forceSinglePass === !0 && (i.forceSinglePass = !0), this.wireframe === !0 && (i.wireframe = !0), this.wireframeLinewidth > 1 && (i.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (i.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (i.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (i.flatShading = !0), this.visible === !1 && (i.visible = !1), this.toneMapped === !1 && (i.toneMapped = !1), this.fog === !1 && (i.fog = !1), Object.keys(this.userData).length > 0 && (i.userData = this.userData);
    function r(a) {
      const o = [];
      for (const s in a) {
        const c = a[s];
        delete c.metadata, o.push(c);
      }
      return o;
    }
    if (t) {
      const a = r(e.textures), o = r(e.images);
      a.length > 0 && (i.textures = a), o.length > 0 && (i.images = o);
    }
    return i;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    this.name = e.name, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.blendColor.copy(e.blendColor), this.blendAlpha = e.blendAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite;
    const t = e.clippingPlanes;
    let i = null;
    if (t !== null) {
      const r = t.length;
      i = new Array(r);
      for (let a = 0; a !== r; ++a)
        i[a] = t[a].clone();
    }
    return this.clippingPlanes = i, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaHash = e.alphaHash, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.forceSinglePass = e.forceSinglePass, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
}
class us extends Wi {
  constructor(e) {
    super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new We(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new on(), this.combine = os, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.fog = e.fog, this;
  }
}
const ct = /* @__PURE__ */ new O(), Ur = /* @__PURE__ */ new le();
class Zt {
  constructor(e, t, i = !1) {
    if (Array.isArray(e))
      throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
    this.isBufferAttribute = !0, this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = i, this.usage = dc, this._updateRange = { offset: 0, count: -1 }, this.updateRanges = [], this.gpuType = Bn, this.version = 0;
  }
  onUploadCallback() {
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
  get updateRange() {
    return ld("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."), this._updateRange;
  }
  setUsage(e) {
    return this.usage = e, this;
  }
  addUpdateRange(e, t) {
    this.updateRanges.push({ start: e, count: t });
  }
  clearUpdateRanges() {
    this.updateRanges.length = 0;
  }
  copy(e) {
    return this.name = e.name, this.array = new e.array.constructor(e.array), this.itemSize = e.itemSize, this.count = e.count, this.normalized = e.normalized, this.usage = e.usage, this.gpuType = e.gpuType, this;
  }
  copyAt(e, t, i) {
    e *= this.itemSize, i *= t.itemSize;
    for (let r = 0, a = this.itemSize; r < a; r++)
      this.array[e + r] = t.array[i + r];
    return this;
  }
  copyArray(e) {
    return this.array.set(e), this;
  }
  applyMatrix3(e) {
    if (this.itemSize === 2)
      for (let t = 0, i = this.count; t < i; t++)
        Ur.fromBufferAttribute(this, t), Ur.applyMatrix3(e), this.setXY(t, Ur.x, Ur.y);
    else if (this.itemSize === 3)
      for (let t = 0, i = this.count; t < i; t++)
        ct.fromBufferAttribute(this, t), ct.applyMatrix3(e), this.setXYZ(t, ct.x, ct.y, ct.z);
    return this;
  }
  applyMatrix4(e) {
    for (let t = 0, i = this.count; t < i; t++)
      ct.fromBufferAttribute(this, t), ct.applyMatrix4(e), this.setXYZ(t, ct.x, ct.y, ct.z);
    return this;
  }
  applyNormalMatrix(e) {
    for (let t = 0, i = this.count; t < i; t++)
      ct.fromBufferAttribute(this, t), ct.applyNormalMatrix(e), this.setXYZ(t, ct.x, ct.y, ct.z);
    return this;
  }
  transformDirection(e) {
    for (let t = 0, i = this.count; t < i; t++)
      ct.fromBufferAttribute(this, t), ct.transformDirection(e), this.setXYZ(t, ct.x, ct.y, ct.z);
    return this;
  }
  set(e, t = 0) {
    return this.array.set(e, t), this;
  }
  getComponent(e, t) {
    let i = this.array[e * this.itemSize + t];
    return this.normalized && (i = Li(i, this.array)), i;
  }
  setComponent(e, t, i) {
    return this.normalized && (i = Mt(i, this.array)), this.array[e * this.itemSize + t] = i, this;
  }
  getX(e) {
    let t = this.array[e * this.itemSize];
    return this.normalized && (t = Li(t, this.array)), t;
  }
  setX(e, t) {
    return this.normalized && (t = Mt(t, this.array)), this.array[e * this.itemSize] = t, this;
  }
  getY(e) {
    let t = this.array[e * this.itemSize + 1];
    return this.normalized && (t = Li(t, this.array)), t;
  }
  setY(e, t) {
    return this.normalized && (t = Mt(t, this.array)), this.array[e * this.itemSize + 1] = t, this;
  }
  getZ(e) {
    let t = this.array[e * this.itemSize + 2];
    return this.normalized && (t = Li(t, this.array)), t;
  }
  setZ(e, t) {
    return this.normalized && (t = Mt(t, this.array)), this.array[e * this.itemSize + 2] = t, this;
  }
  getW(e) {
    let t = this.array[e * this.itemSize + 3];
    return this.normalized && (t = Li(t, this.array)), t;
  }
  setW(e, t) {
    return this.normalized && (t = Mt(t, this.array)), this.array[e * this.itemSize + 3] = t, this;
  }
  setXY(e, t, i) {
    return e *= this.itemSize, this.normalized && (t = Mt(t, this.array), i = Mt(i, this.array)), this.array[e + 0] = t, this.array[e + 1] = i, this;
  }
  setXYZ(e, t, i, r) {
    return e *= this.itemSize, this.normalized && (t = Mt(t, this.array), i = Mt(i, this.array), r = Mt(r, this.array)), this.array[e + 0] = t, this.array[e + 1] = i, this.array[e + 2] = r, this;
  }
  setXYZW(e, t, i, r, a) {
    return e *= this.itemSize, this.normalized && (t = Mt(t, this.array), i = Mt(i, this.array), r = Mt(r, this.array), a = Mt(a, this.array)), this.array[e + 0] = t, this.array[e + 1] = i, this.array[e + 2] = r, this.array[e + 3] = a, this;
  }
  onUpload(e) {
    return this.onUploadCallback = e, this;
  }
  clone() {
    return new this.constructor(this.array, this.itemSize).copy(this);
  }
  toJSON() {
    const e = {
      itemSize: this.itemSize,
      type: this.array.constructor.name,
      array: Array.from(this.array),
      normalized: this.normalized
    };
    return this.name !== "" && (e.name = this.name), this.usage !== dc && (e.usage = this.usage), e;
  }
}
class Eu extends Zt {
  constructor(e, t, i) {
    super(new Uint16Array(e), t, i);
  }
}
class wu extends Zt {
  constructor(e, t, i) {
    super(new Uint32Array(e), t, i);
  }
}
class lt extends Zt {
  constructor(e, t, i) {
    super(new Float32Array(e), t, i);
  }
}
let Ed = 0;
const kt = /* @__PURE__ */ new Je(), io = /* @__PURE__ */ new vt(), Si = /* @__PURE__ */ new O(), Ot = /* @__PURE__ */ new ui(), Ji = /* @__PURE__ */ new ui(), pt = /* @__PURE__ */ new O();
class Nt extends Qt {
  constructor() {
    super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: Ed++ }), this.uuid = Gi(), this.name = "", this.type = "BufferGeometry", this.index = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { start: 0, count: 1 / 0 }, this.userData = {};
  }
  getIndex() {
    return this.index;
  }
  setIndex(e) {
    return Array.isArray(e) ? this.index = new (xu(e) ? wu : Eu)(e, 1) : this.index = e, this;
  }
  getAttribute(e) {
    return this.attributes[e];
  }
  setAttribute(e, t) {
    return this.attributes[e] = t, this;
  }
  deleteAttribute(e) {
    return delete this.attributes[e], this;
  }
  hasAttribute(e) {
    return this.attributes[e] !== void 0;
  }
  addGroup(e, t, i = 0) {
    this.groups.push({
      start: e,
      count: t,
      materialIndex: i
    });
  }
  clearGroups() {
    this.groups = [];
  }
  setDrawRange(e, t) {
    this.drawRange.start = e, this.drawRange.count = t;
  }
  applyMatrix4(e) {
    const t = this.attributes.position;
    t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0);
    const i = this.attributes.normal;
    if (i !== void 0) {
      const a = new Fe().getNormalMatrix(e);
      i.applyNormalMatrix(a), i.needsUpdate = !0;
    }
    const r = this.attributes.tangent;
    return r !== void 0 && (r.transformDirection(e), r.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;
  }
  applyQuaternion(e) {
    return kt.makeRotationFromQuaternion(e), this.applyMatrix4(kt), this;
  }
  rotateX(e) {
    return kt.makeRotationX(e), this.applyMatrix4(kt), this;
  }
  rotateY(e) {
    return kt.makeRotationY(e), this.applyMatrix4(kt), this;
  }
  rotateZ(e) {
    return kt.makeRotationZ(e), this.applyMatrix4(kt), this;
  }
  translate(e, t, i) {
    return kt.makeTranslation(e, t, i), this.applyMatrix4(kt), this;
  }
  scale(e, t, i) {
    return kt.makeScale(e, t, i), this.applyMatrix4(kt), this;
  }
  lookAt(e) {
    return io.lookAt(e), io.updateMatrix(), this.applyMatrix4(io.matrix), this;
  }
  center() {
    return this.computeBoundingBox(), this.boundingBox.getCenter(Si).negate(), this.translate(Si.x, Si.y, Si.z), this;
  }
  setFromPoints(e) {
    const t = [];
    for (let i = 0, r = e.length; i < r; i++) {
      const a = e[i];
      t.push(a.x, a.y, a.z || 0);
    }
    return this.setAttribute("position", new lt(t, 3)), this;
  }
  computeBoundingBox() {
    this.boundingBox === null && (this.boundingBox = new ui());
    const e = this.attributes.position, t = this.morphAttributes.position;
    if (e && e.isGLBufferAttribute) {
      console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set(
        new O(-1 / 0, -1 / 0, -1 / 0),
        new O(1 / 0, 1 / 0, 1 / 0)
      );
      return;
    }
    if (e !== void 0) {
      if (this.boundingBox.setFromBufferAttribute(e), t)
        for (let i = 0, r = t.length; i < r; i++) {
          const a = t[i];
          Ot.setFromBufferAttribute(a), this.morphTargetsRelative ? (pt.addVectors(this.boundingBox.min, Ot.min), this.boundingBox.expandByPoint(pt), pt.addVectors(this.boundingBox.max, Ot.max), this.boundingBox.expandByPoint(pt)) : (this.boundingBox.expandByPoint(Ot.min), this.boundingBox.expandByPoint(Ot.max));
        }
    } else
      this.boundingBox.makeEmpty();
    (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);
  }
  computeBoundingSphere() {
    this.boundingSphere === null && (this.boundingSphere = new ba());
    const e = this.attributes.position, t = this.morphAttributes.position;
    if (e && e.isGLBufferAttribute) {
      console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new O(), 1 / 0);
      return;
    }
    if (e) {
      const i = this.boundingSphere.center;
      if (Ot.setFromBufferAttribute(e), t)
        for (let a = 0, o = t.length; a < o; a++) {
          const s = t[a];
          Ji.setFromBufferAttribute(s), this.morphTargetsRelative ? (pt.addVectors(Ot.min, Ji.min), Ot.expandByPoint(pt), pt.addVectors(Ot.max, Ji.max), Ot.expandByPoint(pt)) : (Ot.expandByPoint(Ji.min), Ot.expandByPoint(Ji.max));
        }
      Ot.getCenter(i);
      let r = 0;
      for (let a = 0, o = e.count; a < o; a++)
        pt.fromBufferAttribute(e, a), r = Math.max(r, i.distanceToSquared(pt));
      if (t)
        for (let a = 0, o = t.length; a < o; a++) {
          const s = t[a], c = this.morphTargetsRelative;
          for (let l = 0, u = s.count; l < u; l++)
            pt.fromBufferAttribute(s, l), c && (Si.fromBufferAttribute(e, l), pt.add(Si)), r = Math.max(r, i.distanceToSquared(pt));
        }
      this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
    }
  }
  computeTangents() {
    const e = this.index, t = this.attributes;
    if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) {
      console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");
      return;
    }
    const i = t.position, r = t.normal, a = t.uv;
    this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new Zt(new Float32Array(4 * i.count), 4));
    const o = this.getAttribute("tangent"), s = [], c = [];
    for (let R = 0; R < i.count; R++)
      s[R] = new O(), c[R] = new O();
    const l = new O(), u = new O(), h = new O(), d = new le(), p = new le(), g = new le(), v = new O(), m = new O();
    function f(R, w, b) {
      l.fromBufferAttribute(i, R), u.fromBufferAttribute(i, w), h.fromBufferAttribute(i, b), d.fromBufferAttribute(a, R), p.fromBufferAttribute(a, w), g.fromBufferAttribute(a, b), u.sub(l), h.sub(l), p.sub(d), g.sub(d);
      const U = 1 / (p.x * g.y - g.x * p.y);
      isFinite(U) && (v.copy(u).multiplyScalar(g.y).addScaledVector(h, -p.y).multiplyScalar(U), m.copy(h).multiplyScalar(p.x).addScaledVector(u, -g.x).multiplyScalar(U), s[R].add(v), s[w].add(v), s[b].add(v), c[R].add(m), c[w].add(m), c[b].add(m));
    }
    let M = this.groups;
    M.length === 0 && (M = [{
      start: 0,
      count: e.count
    }]);
    for (let R = 0, w = M.length; R < w; ++R) {
      const b = M[R], U = b.start, z = b.count;
      for (let I = U, L = U + z; I < L; I += 3)
        f(
          e.getX(I + 0),
          e.getX(I + 1),
          e.getX(I + 2)
        );
    }
    const _ = new O(), x = new O(), T = new O(), E = new O();
    function A(R) {
      T.fromBufferAttribute(r, R), E.copy(T);
      const w = s[R];
      _.copy(w), _.sub(T.multiplyScalar(T.dot(w))).normalize(), x.crossVectors(E, w);
      const U = x.dot(c[R]) < 0 ? -1 : 1;
      o.setXYZW(R, _.x, _.y, _.z, U);
    }
    for (let R = 0, w = M.length; R < w; ++R) {
      const b = M[R], U = b.start, z = b.count;
      for (let I = U, L = U + z; I < L; I += 3)
        A(e.getX(I + 0)), A(e.getX(I + 1)), A(e.getX(I + 2));
    }
  }
  computeVertexNormals() {
    const e = this.index, t = this.getAttribute("position");
    if (t !== void 0) {
      let i = this.getAttribute("normal");
      if (i === void 0)
        i = new Zt(new Float32Array(t.count * 3), 3), this.setAttribute("normal", i);
      else
        for (let d = 0, p = i.count; d < p; d++)
          i.setXYZ(d, 0, 0, 0);
      const r = new O(), a = new O(), o = new O(), s = new O(), c = new O(), l = new O(), u = new O(), h = new O();
      if (e)
        for (let d = 0, p = e.count; d < p; d += 3) {
          const g = e.getX(d + 0), v = e.getX(d + 1), m = e.getX(d + 2);
          r.fromBufferAttribute(t, g), a.fromBufferAttribute(t, v), o.fromBufferAttribute(t, m), u.subVectors(o, a), h.subVectors(r, a), u.cross(h), s.fromBufferAttribute(i, g), c.fromBufferAttribute(i, v), l.fromBufferAttribute(i, m), s.add(u), c.add(u), l.add(u), i.setXYZ(g, s.x, s.y, s.z), i.setXYZ(v, c.x, c.y, c.z), i.setXYZ(m, l.x, l.y, l.z);
        }
      else
        for (let d = 0, p = t.count; d < p; d += 3)
          r.fromBufferAttribute(t, d + 0), a.fromBufferAttribute(t, d + 1), o.fromBufferAttribute(t, d + 2), u.subVectors(o, a), h.subVectors(r, a), u.cross(h), i.setXYZ(d + 0, u.x, u.y, u.z), i.setXYZ(d + 1, u.x, u.y, u.z), i.setXYZ(d + 2, u.x, u.y, u.z);
      this.normalizeNormals(), i.needsUpdate = !0;
    }
  }
  normalizeNormals() {
    const e = this.attributes.normal;
    for (let t = 0, i = e.count; t < i; t++)
      pt.fromBufferAttribute(e, t), pt.normalize(), e.setXYZ(t, pt.x, pt.y, pt.z);
  }
  toNonIndexed() {
    function e(s, c) {
      const l = s.array, u = s.itemSize, h = s.normalized, d = new l.constructor(c.length * u);
      let p = 0, g = 0;
      for (let v = 0, m = c.length; v < m; v++) {
        s.isInterleavedBufferAttribute ? p = c[v] * s.data.stride + s.offset : p = c[v] * u;
        for (let f = 0; f < u; f++)
          d[g++] = l[p++];
      }
      return new Zt(d, u, h);
    }
    if (this.index === null)
      return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;
    const t = new Nt(), i = this.index.array, r = this.attributes;
    for (const s in r) {
      const c = r[s], l = e(c, i);
      t.setAttribute(s, l);
    }
    const a = this.morphAttributes;
    for (const s in a) {
      const c = [], l = a[s];
      for (let u = 0, h = l.length; u < h; u++) {
        const d = l[u], p = e(d, i);
        c.push(p);
      }
      t.morphAttributes[s] = c;
    }
    t.morphTargetsRelative = this.morphTargetsRelative;
    const o = this.groups;
    for (let s = 0, c = o.length; s < c; s++) {
      const l = o[s];
      t.addGroup(l.start, l.count, l.materialIndex);
    }
    return t;
  }
  toJSON() {
    const e = {
      metadata: {
        version: 4.6,
        type: "BufferGeometry",
        generator: "BufferGeometry.toJSON"
      }
    };
    if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) {
      const c = this.parameters;
      for (const l in c)
        c[l] !== void 0 && (e[l] = c[l]);
      return e;
    }
    e.data = { attributes: {} };
    const t = this.index;
    t !== null && (e.data.index = {
      type: t.array.constructor.name,
      array: Array.prototype.slice.call(t.array)
    });
    const i = this.attributes;
    for (const c in i) {
      const l = i[c];
      e.data.attributes[c] = l.toJSON(e.data);
    }
    const r = {};
    let a = !1;
    for (const c in this.morphAttributes) {
      const l = this.morphAttributes[c], u = [];
      for (let h = 0, d = l.length; h < d; h++) {
        const p = l[h];
        u.push(p.toJSON(e.data));
      }
      u.length > 0 && (r[c] = u, a = !0);
    }
    a && (e.data.morphAttributes = r, e.data.morphTargetsRelative = this.morphTargetsRelative);
    const o = this.groups;
    o.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(o)));
    const s = this.boundingSphere;
    return s !== null && (e.data.boundingSphere = {
      center: s.center.toArray(),
      radius: s.radius
    }), e;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null;
    const t = {};
    this.name = e.name;
    const i = e.index;
    i !== null && this.setIndex(i.clone(t));
    const r = e.attributes;
    for (const l in r) {
      const u = r[l];
      this.setAttribute(l, u.clone(t));
    }
    const a = e.morphAttributes;
    for (const l in a) {
      const u = [], h = a[l];
      for (let d = 0, p = h.length; d < p; d++)
        u.push(h[d].clone(t));
      this.morphAttributes[l] = u;
    }
    this.morphTargetsRelative = e.morphTargetsRelative;
    const o = e.groups;
    for (let l = 0, u = o.length; l < u; l++) {
      const h = o[l];
      this.addGroup(h.start, h.count, h.materialIndex);
    }
    const s = e.boundingBox;
    s !== null && (this.boundingBox = s.clone());
    const c = e.boundingSphere;
    return c !== null && (this.boundingSphere = c.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
const Cc = /* @__PURE__ */ new Je(), Zn = /* @__PURE__ */ new Ma(), Fr = /* @__PURE__ */ new ba(), Rc = /* @__PURE__ */ new O(), Ei = /* @__PURE__ */ new O(), wi = /* @__PURE__ */ new O(), Ti = /* @__PURE__ */ new O(), ro = /* @__PURE__ */ new O(), Br = /* @__PURE__ */ new O(), kr = /* @__PURE__ */ new le(), zr = /* @__PURE__ */ new le(), Hr = /* @__PURE__ */ new le(), Pc = /* @__PURE__ */ new O(), Lc = /* @__PURE__ */ new O(), Dc = /* @__PURE__ */ new O(), Vr = /* @__PURE__ */ new O(), Gr = /* @__PURE__ */ new O();
class Vt extends vt {
  constructor(e = new Nt(), t = new us()) {
    super(), this.isMesh = !0, this.type = "Mesh", this.geometry = e, this.material = t, this.updateMorphTargets();
  }
  copy(e, t) {
    return super.copy(e, t), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;
  }
  updateMorphTargets() {
    const t = this.geometry.morphAttributes, i = Object.keys(t);
    if (i.length > 0) {
      const r = t[i[0]];
      if (r !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let a = 0, o = r.length; a < o; a++) {
          const s = r[a].name || String(a);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[s] = a;
        }
      }
    }
  }
  getVertexPosition(e, t) {
    const i = this.geometry, r = i.attributes.position, a = i.morphAttributes.position, o = i.morphTargetsRelative;
    t.fromBufferAttribute(r, e);
    const s = this.morphTargetInfluences;
    if (a && s) {
      Br.set(0, 0, 0);
      for (let c = 0, l = a.length; c < l; c++) {
        const u = s[c], h = a[c];
        u !== 0 && (ro.fromBufferAttribute(h, e), o ? Br.addScaledVector(ro, u) : Br.addScaledVector(ro.sub(t), u));
      }
      t.add(Br);
    }
    return t;
  }
  raycast(e, t) {
    const i = this.geometry, r = this.material, a = this.matrixWorld;
    r !== void 0 && (i.boundingSphere === null && i.computeBoundingSphere(), Fr.copy(i.boundingSphere), Fr.applyMatrix4(a), Zn.copy(e.ray).recast(e.near), !(Fr.containsPoint(Zn.origin) === !1 && (Zn.intersectSphere(Fr, Rc) === null || Zn.origin.distanceToSquared(Rc) > (e.far - e.near) ** 2)) && (Cc.copy(a).invert(), Zn.copy(e.ray).applyMatrix4(Cc), !(i.boundingBox !== null && Zn.intersectsBox(i.boundingBox) === !1) && this._computeIntersections(e, t, Zn)));
  }
  _computeIntersections(e, t, i) {
    let r;
    const a = this.geometry, o = this.material, s = a.index, c = a.attributes.position, l = a.attributes.uv, u = a.attributes.uv1, h = a.attributes.normal, d = a.groups, p = a.drawRange;
    if (s !== null)
      if (Array.isArray(o))
        for (let g = 0, v = d.length; g < v; g++) {
          const m = d[g], f = o[m.materialIndex], M = Math.max(m.start, p.start), _ = Math.min(s.count, Math.min(m.start + m.count, p.start + p.count));
          for (let x = M, T = _; x < T; x += 3) {
            const E = s.getX(x), A = s.getX(x + 1), R = s.getX(x + 2);
            r = Wr(this, f, e, i, l, u, h, E, A, R), r && (r.faceIndex = Math.floor(x / 3), r.face.materialIndex = m.materialIndex, t.push(r));
          }
        }
      else {
        const g = Math.max(0, p.start), v = Math.min(s.count, p.start + p.count);
        for (let m = g, f = v; m < f; m += 3) {
          const M = s.getX(m), _ = s.getX(m + 1), x = s.getX(m + 2);
          r = Wr(this, o, e, i, l, u, h, M, _, x), r && (r.faceIndex = Math.floor(m / 3), t.push(r));
        }
      }
    else if (c !== void 0)
      if (Array.isArray(o))
        for (let g = 0, v = d.length; g < v; g++) {
          const m = d[g], f = o[m.materialIndex], M = Math.max(m.start, p.start), _ = Math.min(c.count, Math.min(m.start + m.count, p.start + p.count));
          for (let x = M, T = _; x < T; x += 3) {
            const E = x, A = x + 1, R = x + 2;
            r = Wr(this, f, e, i, l, u, h, E, A, R), r && (r.faceIndex = Math.floor(x / 3), r.face.materialIndex = m.materialIndex, t.push(r));
          }
        }
      else {
        const g = Math.max(0, p.start), v = Math.min(c.count, p.start + p.count);
        for (let m = g, f = v; m < f; m += 3) {
          const M = m, _ = m + 1, x = m + 2;
          r = Wr(this, o, e, i, l, u, h, M, _, x), r && (r.faceIndex = Math.floor(m / 3), t.push(r));
        }
      }
  }
}
function wd(n, e, t, i, r, a, o, s) {
  let c;
  if (e.side === wt ? c = i.intersectTriangle(o, a, r, !0, s) : c = i.intersectTriangle(r, a, o, e.side === Hn, s), c === null)
    return null;
  Gr.copy(s), Gr.applyMatrix4(n.matrixWorld);
  const l = t.ray.origin.distanceTo(Gr);
  return l < t.near || l > t.far ? null : {
    distance: l,
    point: Gr.clone(),
    object: n
  };
}
function Wr(n, e, t, i, r, a, o, s, c, l) {
  n.getVertexPosition(s, Ei), n.getVertexPosition(c, wi), n.getVertexPosition(l, Ti);
  const u = wd(n, e, t, i, Ei, wi, Ti, Vr);
  if (u) {
    r && (kr.fromBufferAttribute(r, s), zr.fromBufferAttribute(r, c), Hr.fromBufferAttribute(r, l), u.uv = nn.getInterpolation(Vr, Ei, wi, Ti, kr, zr, Hr, new le())), a && (kr.fromBufferAttribute(a, s), zr.fromBufferAttribute(a, c), Hr.fromBufferAttribute(a, l), u.uv1 = nn.getInterpolation(Vr, Ei, wi, Ti, kr, zr, Hr, new le())), o && (Pc.fromBufferAttribute(o, s), Lc.fromBufferAttribute(o, c), Dc.fromBufferAttribute(o, l), u.normal = nn.getInterpolation(Vr, Ei, wi, Ti, Pc, Lc, Dc, new O()), u.normal.dot(i.direction) > 0 && u.normal.multiplyScalar(-1));
    const h = {
      a: s,
      b: c,
      c: l,
      normal: new O(),
      materialIndex: 0
    };
    nn.getNormal(Ei, wi, Ti, h.normal), u.face = h;
  }
  return u;
}
class Mr extends Nt {
  constructor(e = 1, t = 1, i = 1, r = 1, a = 1, o = 1) {
    super(), this.type = "BoxGeometry", this.parameters = {
      width: e,
      height: t,
      depth: i,
      widthSegments: r,
      heightSegments: a,
      depthSegments: o
    };
    const s = this;
    r = Math.floor(r), a = Math.floor(a), o = Math.floor(o);
    const c = [], l = [], u = [], h = [];
    let d = 0, p = 0;
    g("z", "y", "x", -1, -1, i, t, e, o, a, 0), g("z", "y", "x", 1, -1, i, t, -e, o, a, 1), g("x", "z", "y", 1, 1, e, i, t, r, o, 2), g("x", "z", "y", 1, -1, e, i, -t, r, o, 3), g("x", "y", "z", 1, -1, e, t, i, r, a, 4), g("x", "y", "z", -1, -1, e, t, -i, r, a, 5), this.setIndex(c), this.setAttribute("position", new lt(l, 3)), this.setAttribute("normal", new lt(u, 3)), this.setAttribute("uv", new lt(h, 2));
    function g(v, m, f, M, _, x, T, E, A, R, w) {
      const b = x / A, U = T / R, z = x / 2, I = T / 2, L = E / 2, D = A + 1, B = R + 1;
      let te = 0, W = 0;
      const ie = new O();
      for (let G = 0; G < B; G++) {
        const Q = G * U - I;
        for (let se = 0; se < D; se++) {
          const xe = se * b - z;
          ie[v] = xe * M, ie[m] = Q * _, ie[f] = L, l.push(ie.x, ie.y, ie.z), ie[v] = 0, ie[m] = 0, ie[f] = E > 0 ? 1 : -1, u.push(ie.x, ie.y, ie.z), h.push(se / A), h.push(1 - G / R), te += 1;
        }
      }
      for (let G = 0; G < R; G++)
        for (let Q = 0; Q < A; Q++) {
          const se = d + Q + D * G, xe = d + Q + D * (G + 1), k = d + (Q + 1) + D * (G + 1), H = d + (Q + 1) + D * G;
          c.push(se, xe, H), c.push(xe, k, H), W += 6;
        }
      s.addGroup(p, W, w), p += W, d += te;
    }
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new Mr(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments);
  }
}
function Hi(n) {
  const e = {};
  for (const t in n) {
    e[t] = {};
    for (const i in n[t]) {
      const r = n[t][i];
      r && (r.isColor || r.isMatrix3 || r.isMatrix4 || r.isVector2 || r.isVector3 || r.isVector4 || r.isTexture || r.isQuaternion) ? r.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), e[t][i] = null) : e[t][i] = r.clone() : Array.isArray(r) ? e[t][i] = r.slice() : e[t][i] = r;
    }
  }
  return e;
}
function St(n) {
  const e = {};
  for (let t = 0; t < n.length; t++) {
    const i = Hi(n[t]);
    for (const r in i)
      e[r] = i[r];
  }
  return e;
}
function Td(n) {
  const e = [];
  for (let t = 0; t < n.length; t++)
    e.push(n[t].clone());
  return e;
}
function Tu(n) {
  const e = n.getRenderTarget();
  return e === null ? n.outputColorSpace : e.isXRRenderTarget === !0 ? e.texture.colorSpace : Ke.workingColorSpace;
}
const Au = { clone: Hi, merge: St };
var Ad = `void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`, Cd = `void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;
class sn extends Wi {
  constructor(e) {
    super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = Ad, this.fragmentShader = Cd, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.forceSinglePass = !0, this.extensions = {
      clipCullDistance: !1,
      // set to use vertex shader clipping
      multiDraw: !1
      // set to use vertex shader multi_draw / enable gl_DrawID
    }, this.defaultAttributeValues = {
      color: [1, 1, 1],
      uv: [0, 0],
      uv1: [0, 0]
    }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, e !== void 0 && this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.fragmentShader = e.fragmentShader, this.vertexShader = e.vertexShader, this.uniforms = Hi(e.uniforms), this.uniformsGroups = Td(e.uniformsGroups), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.fog = e.fog, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    t.glslVersion = this.glslVersion, t.uniforms = {};
    for (const r in this.uniforms) {
      const o = this.uniforms[r].value;
      o && o.isTexture ? t.uniforms[r] = {
        type: "t",
        value: o.toJSON(e).uuid
      } : o && o.isColor ? t.uniforms[r] = {
        type: "c",
        value: o.getHex()
      } : o && o.isVector2 ? t.uniforms[r] = {
        type: "v2",
        value: o.toArray()
      } : o && o.isVector3 ? t.uniforms[r] = {
        type: "v3",
        value: o.toArray()
      } : o && o.isVector4 ? t.uniforms[r] = {
        type: "v4",
        value: o.toArray()
      } : o && o.isMatrix3 ? t.uniforms[r] = {
        type: "m3",
        value: o.toArray()
      } : o && o.isMatrix4 ? t.uniforms[r] = {
        type: "m4",
        value: o.toArray()
      } : t.uniforms[r] = {
        value: o
      };
    }
    Object.keys(this.defines).length > 0 && (t.defines = this.defines), t.vertexShader = this.vertexShader, t.fragmentShader = this.fragmentShader, t.lights = this.lights, t.clipping = this.clipping;
    const i = {};
    for (const r in this.extensions)
      this.extensions[r] === !0 && (i[r] = !0);
    return Object.keys(i).length > 0 && (t.extensions = i), t;
  }
}
class Cu extends vt {
  constructor() {
    super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new Je(), this.projectionMatrix = new Je(), this.projectionMatrixInverse = new Je(), this.coordinateSystem = Mn;
  }
  copy(e, t) {
    return super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this.coordinateSystem = e.coordinateSystem, this;
  }
  getWorldDirection(e) {
    return super.getWorldDirection(e).negate();
  }
  updateMatrixWorld(e) {
    super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  updateWorldMatrix(e, t) {
    super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const In = /* @__PURE__ */ new O(), Oc = /* @__PURE__ */ new le(), Ic = /* @__PURE__ */ new le();
class zt extends Cu {
  constructor(e = 50, t = 1, i = 0.1, r = 2e3) {
    super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = i, this.far = r, this.focus = 10, this.aspect = t, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix();
  }
  copy(e, t) {
    return super.copy(e, t), this.fov = e.fov, this.zoom = e.zoom, this.near = e.near, this.far = e.far, this.focus = e.focus, this.aspect = e.aspect, this.view = e.view === null ? null : Object.assign({}, e.view), this.filmGauge = e.filmGauge, this.filmOffset = e.filmOffset, this;
  }
  /**
   * Sets the FOV by focal length in respect to the current .filmGauge.
   *
   * The default film gauge is 35, so that the focal length can be specified for
   * a 35mm (full frame) camera.
   *
   * Values for focal length and film gauge must have the same unit.
   */
  setFocalLength(e) {
    const t = 0.5 * this.getFilmHeight() / e;
    this.fov = gr * 2 * Math.atan(t), this.updateProjectionMatrix();
  }
  /**
   * Calculates the focal length from the current .fov and .filmGauge.
   */
  getFocalLength() {
    const e = Math.tan(ur * 0.5 * this.fov);
    return 0.5 * this.getFilmHeight() / e;
  }
  getEffectiveFOV() {
    return gr * 2 * Math.atan(
      Math.tan(ur * 0.5 * this.fov) / this.zoom
    );
  }
  getFilmWidth() {
    return this.filmGauge * Math.min(this.aspect, 1);
  }
  getFilmHeight() {
    return this.filmGauge / Math.max(this.aspect, 1);
  }
  /**
   * Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction.
   * Sets minTarget and maxTarget to the coordinates of the lower-left and upper-right corners of the view rectangle.
   */
  getViewBounds(e, t, i) {
    In.set(-1, -1, 0.5).applyMatrix4(this.projectionMatrixInverse), t.set(In.x, In.y).multiplyScalar(-e / In.z), In.set(1, 1, 0.5).applyMatrix4(this.projectionMatrixInverse), i.set(In.x, In.y).multiplyScalar(-e / In.z);
  }
  /**
   * Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction.
   * Copies the result into the target Vector2, where x is width and y is height.
   */
  getViewSize(e, t) {
    return this.getViewBounds(e, Oc, Ic), t.subVectors(Ic, Oc);
  }
  /**
   * Sets an offset in a larger frustum. This is useful for multi-window or
   * multi-monitor/multi-machine setups.
   *
   * For example, if you have 3x2 monitors and each monitor is 1920x1080 and
   * the monitors are in grid like this
   *
   *   +---+---+---+
   *   | A | B | C |
   *   +---+---+---+
   *   | D | E | F |
   *   +---+---+---+
   *
   * then for each monitor you would call it like this
   *
   *   const w = 1920;
   *   const h = 1080;
   *   const fullWidth = w * 3;
   *   const fullHeight = h * 2;
   *
   *   --A--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
   *   --B--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
   *   --C--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
   *   --D--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
   *   --E--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
   *   --F--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
   *
   *   Note there is no reason monitors have to be the same size or in a grid.
   */
  setViewOffset(e, t, i, r, a, o) {
    this.aspect = e / t, this.view === null && (this.view = {
      enabled: !0,
      fullWidth: 1,
      fullHeight: 1,
      offsetX: 0,
      offsetY: 0,
      width: 1,
      height: 1
    }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = i, this.view.offsetY = r, this.view.width = a, this.view.height = o, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const e = this.near;
    let t = e * Math.tan(ur * 0.5 * this.fov) / this.zoom, i = 2 * t, r = this.aspect * i, a = -0.5 * r;
    const o = this.view;
    if (this.view !== null && this.view.enabled) {
      const c = o.fullWidth, l = o.fullHeight;
      a += o.offsetX * r / c, t -= o.offsetY * i / l, r *= o.width / c, i *= o.height / l;
    }
    const s = this.filmOffset;
    s !== 0 && (a += e * s / this.getFilmWidth()), this.projectionMatrix.makePerspective(a, a + r, t, t - i, e, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return t.object.fov = this.fov, t.object.zoom = this.zoom, t.object.near = this.near, t.object.far = this.far, t.object.focus = this.focus, t.object.aspect = this.aspect, this.view !== null && (t.object.view = Object.assign({}, this.view)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t;
  }
}
const Ai = -90, Ci = 1;
class Rd extends vt {
  constructor(e, t, i) {
    super(), this.type = "CubeCamera", this.renderTarget = i, this.coordinateSystem = null, this.activeMipmapLevel = 0;
    const r = new zt(Ai, Ci, e, t);
    r.layers = this.layers, this.add(r);
    const a = new zt(Ai, Ci, e, t);
    a.layers = this.layers, this.add(a);
    const o = new zt(Ai, Ci, e, t);
    o.layers = this.layers, this.add(o);
    const s = new zt(Ai, Ci, e, t);
    s.layers = this.layers, this.add(s);
    const c = new zt(Ai, Ci, e, t);
    c.layers = this.layers, this.add(c);
    const l = new zt(Ai, Ci, e, t);
    l.layers = this.layers, this.add(l);
  }
  updateCoordinateSystem() {
    const e = this.coordinateSystem, t = this.children.concat(), [i, r, a, o, s, c] = t;
    for (const l of t)
      this.remove(l);
    if (e === Mn)
      i.up.set(0, 1, 0), i.lookAt(1, 0, 0), r.up.set(0, 1, 0), r.lookAt(-1, 0, 0), a.up.set(0, 0, -1), a.lookAt(0, 1, 0), o.up.set(0, 0, 1), o.lookAt(0, -1, 0), s.up.set(0, 1, 0), s.lookAt(0, 0, 1), c.up.set(0, 1, 0), c.lookAt(0, 0, -1);
    else if (e === la)
      i.up.set(0, -1, 0), i.lookAt(-1, 0, 0), r.up.set(0, -1, 0), r.lookAt(1, 0, 0), a.up.set(0, 0, 1), a.lookAt(0, 1, 0), o.up.set(0, 0, -1), o.lookAt(0, -1, 0), s.up.set(0, -1, 0), s.lookAt(0, 0, 1), c.up.set(0, -1, 0), c.lookAt(0, 0, -1);
    else
      throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e);
    for (const l of t)
      this.add(l), l.updateMatrixWorld();
  }
  update(e, t) {
    this.parent === null && this.updateMatrixWorld();
    const { renderTarget: i, activeMipmapLevel: r } = this;
    this.coordinateSystem !== e.coordinateSystem && (this.coordinateSystem = e.coordinateSystem, this.updateCoordinateSystem());
    const [a, o, s, c, l, u] = this.children, h = e.getRenderTarget(), d = e.getActiveCubeFace(), p = e.getActiveMipmapLevel(), g = e.xr.enabled;
    e.xr.enabled = !1;
    const v = i.texture.generateMipmaps;
    i.texture.generateMipmaps = !1, e.setRenderTarget(i, 0, r), e.render(t, a), e.setRenderTarget(i, 1, r), e.render(t, o), e.setRenderTarget(i, 2, r), e.render(t, s), e.setRenderTarget(i, 3, r), e.render(t, c), e.setRenderTarget(i, 4, r), e.render(t, l), i.texture.generateMipmaps = v, e.setRenderTarget(i, 5, r), e.render(t, u), e.setRenderTarget(h, d, p), e.xr.enabled = g, i.texture.needsPMREMUpdate = !0;
  }
}
class Ru extends Tt {
  constructor(e, t, i, r, a, o, s, c, l, u) {
    e = e !== void 0 ? e : [], t = t !== void 0 ? t : Bi, super(e, t, i, r, a, o, s, c, l, u), this.isCubeTexture = !0, this.flipY = !1;
  }
  get images() {
    return this.image;
  }
  set images(e) {
    this.image = e;
  }
}
class Pd extends Vn {
  constructor(e = 1, t = {}) {
    super(e, e, t), this.isWebGLCubeRenderTarget = !0;
    const i = { width: e, height: e, depth: 1 }, r = [i, i, i, i, i, i];
    this.texture = new Ru(r, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1, this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : Yt;
  }
  fromEquirectangularTexture(e, t) {
    this.texture.type = t.type, this.texture.colorSpace = t.colorSpace, this.texture.generateMipmaps = t.generateMipmaps, this.texture.minFilter = t.minFilter, this.texture.magFilter = t.magFilter;
    const i = {
      uniforms: {
        tEquirect: { value: null }
      },
      vertexShader: (
        /* glsl */
        `

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`
      ),
      fragmentShader: (
        /* glsl */
        `

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`
      )
    }, r = new Mr(5, 5, 5), a = new sn({
      name: "CubemapFromEquirect",
      uniforms: Hi(i.uniforms),
      vertexShader: i.vertexShader,
      fragmentShader: i.fragmentShader,
      side: wt,
      blending: En
    });
    a.uniforms.tEquirect.value = t;
    const o = new Vt(r, a), s = t.minFilter;
    return t.minFilter === oi && (t.minFilter = Yt), new Rd(1, 10, this).update(e, o), t.minFilter = s, o.geometry.dispose(), o.material.dispose(), this;
  }
  clear(e, t, i, r) {
    const a = e.getRenderTarget();
    for (let o = 0; o < 6; o++)
      e.setRenderTarget(this, o), e.clear(t, i, r);
    e.setRenderTarget(a);
  }
}
const ao = /* @__PURE__ */ new O(), Ld = /* @__PURE__ */ new O(), Dd = /* @__PURE__ */ new Fe();
class yn {
  constructor(e = new O(1, 0, 0), t = 0) {
    this.isPlane = !0, this.normal = e, this.constant = t;
  }
  set(e, t) {
    return this.normal.copy(e), this.constant = t, this;
  }
  setComponents(e, t, i, r) {
    return this.normal.set(e, t, i), this.constant = r, this;
  }
  setFromNormalAndCoplanarPoint(e, t) {
    return this.normal.copy(e), this.constant = -t.dot(this.normal), this;
  }
  setFromCoplanarPoints(e, t, i) {
    const r = ao.subVectors(i, t).cross(Ld.subVectors(e, t)).normalize();
    return this.setFromNormalAndCoplanarPoint(r, e), this;
  }
  copy(e) {
    return this.normal.copy(e.normal), this.constant = e.constant, this;
  }
  normalize() {
    const e = 1 / this.normal.length();
    return this.normal.multiplyScalar(e), this.constant *= e, this;
  }
  negate() {
    return this.constant *= -1, this.normal.negate(), this;
  }
  distanceToPoint(e) {
    return this.normal.dot(e) + this.constant;
  }
  distanceToSphere(e) {
    return this.distanceToPoint(e.center) - e.radius;
  }
  projectPoint(e, t) {
    return t.copy(e).addScaledVector(this.normal, -this.distanceToPoint(e));
  }
  intersectLine(e, t) {
    const i = e.delta(ao), r = this.normal.dot(i);
    if (r === 0)
      return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null;
    const a = -(e.start.dot(this.normal) + this.constant) / r;
    return a < 0 || a > 1 ? null : t.copy(e.start).addScaledVector(i, a);
  }
  intersectsLine(e) {
    const t = this.distanceToPoint(e.start), i = this.distanceToPoint(e.end);
    return t < 0 && i > 0 || i < 0 && t > 0;
  }
  intersectsBox(e) {
    return e.intersectsPlane(this);
  }
  intersectsSphere(e) {
    return e.intersectsPlane(this);
  }
  coplanarPoint(e) {
    return e.copy(this.normal).multiplyScalar(-this.constant);
  }
  applyMatrix4(e, t) {
    const i = t || Dd.getNormalMatrix(e), r = this.coplanarPoint(ao).applyMatrix4(e), a = this.normal.applyMatrix3(i).normalize();
    return this.constant = -r.dot(a), this;
  }
  translate(e) {
    return this.constant -= e.dot(this.normal), this;
  }
  equals(e) {
    return e.normal.equals(this.normal) && e.constant === this.constant;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const Jn = /* @__PURE__ */ new ba(), jr = /* @__PURE__ */ new O();
class hs {
  constructor(e = new yn(), t = new yn(), i = new yn(), r = new yn(), a = new yn(), o = new yn()) {
    this.planes = [e, t, i, r, a, o];
  }
  set(e, t, i, r, a, o) {
    const s = this.planes;
    return s[0].copy(e), s[1].copy(t), s[2].copy(i), s[3].copy(r), s[4].copy(a), s[5].copy(o), this;
  }
  copy(e) {
    const t = this.planes;
    for (let i = 0; i < 6; i++)
      t[i].copy(e.planes[i]);
    return this;
  }
  setFromProjectionMatrix(e, t = Mn) {
    const i = this.planes, r = e.elements, a = r[0], o = r[1], s = r[2], c = r[3], l = r[4], u = r[5], h = r[6], d = r[7], p = r[8], g = r[9], v = r[10], m = r[11], f = r[12], M = r[13], _ = r[14], x = r[15];
    if (i[0].setComponents(c - a, d - l, m - p, x - f).normalize(), i[1].setComponents(c + a, d + l, m + p, x + f).normalize(), i[2].setComponents(c + o, d + u, m + g, x + M).normalize(), i[3].setComponents(c - o, d - u, m - g, x - M).normalize(), i[4].setComponents(c - s, d - h, m - v, x - _).normalize(), t === Mn)
      i[5].setComponents(c + s, d + h, m + v, x + _).normalize();
    else if (t === la)
      i[5].setComponents(s, h, v, _).normalize();
    else
      throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t);
    return this;
  }
  intersectsObject(e) {
    if (e.boundingSphere !== void 0)
      e.boundingSphere === null && e.computeBoundingSphere(), Jn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);
    else {
      const t = e.geometry;
      t.boundingSphere === null && t.computeBoundingSphere(), Jn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld);
    }
    return this.intersectsSphere(Jn);
  }
  intersectsSprite(e) {
    return Jn.center.set(0, 0, 0), Jn.radius = 0.7071067811865476, Jn.applyMatrix4(e.matrixWorld), this.intersectsSphere(Jn);
  }
  intersectsSphere(e) {
    const t = this.planes, i = e.center, r = -e.radius;
    for (let a = 0; a < 6; a++)
      if (t[a].distanceToPoint(i) < r)
        return !1;
    return !0;
  }
  intersectsBox(e) {
    const t = this.planes;
    for (let i = 0; i < 6; i++) {
      const r = t[i];
      if (jr.x = r.normal.x > 0 ? e.max.x : e.min.x, jr.y = r.normal.y > 0 ? e.max.y : e.min.y, jr.z = r.normal.z > 0 ? e.max.z : e.min.z, r.distanceToPoint(jr) < 0)
        return !1;
    }
    return !0;
  }
  containsPoint(e) {
    const t = this.planes;
    for (let i = 0; i < 6; i++)
      if (t[i].distanceToPoint(e) < 0)
        return !1;
    return !0;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
function Pu() {
  let n = null, e = !1, t = null, i = null;
  function r(a, o) {
    t(a, o), i = n.requestAnimationFrame(r);
  }
  return {
    start: function() {
      e !== !0 && t !== null && (i = n.requestAnimationFrame(r), e = !0);
    },
    stop: function() {
      n.cancelAnimationFrame(i), e = !1;
    },
    setAnimationLoop: function(a) {
      t = a;
    },
    setContext: function(a) {
      n = a;
    }
  };
}
function Od(n) {
  const e = /* @__PURE__ */ new WeakMap();
  function t(s, c) {
    const l = s.array, u = s.usage, h = l.byteLength, d = n.createBuffer();
    n.bindBuffer(c, d), n.bufferData(c, l, u), s.onUploadCallback();
    let p;
    if (l instanceof Float32Array)
      p = n.FLOAT;
    else if (l instanceof Uint16Array)
      s.isFloat16BufferAttribute ? p = n.HALF_FLOAT : p = n.UNSIGNED_SHORT;
    else if (l instanceof Int16Array)
      p = n.SHORT;
    else if (l instanceof Uint32Array)
      p = n.UNSIGNED_INT;
    else if (l instanceof Int32Array)
      p = n.INT;
    else if (l instanceof Int8Array)
      p = n.BYTE;
    else if (l instanceof Uint8Array)
      p = n.UNSIGNED_BYTE;
    else if (l instanceof Uint8ClampedArray)
      p = n.UNSIGNED_BYTE;
    else
      throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + l);
    return {
      buffer: d,
      type: p,
      bytesPerElement: l.BYTES_PER_ELEMENT,
      version: s.version,
      size: h
    };
  }
  function i(s, c, l) {
    const u = c.array, h = c._updateRange, d = c.updateRanges;
    if (n.bindBuffer(l, s), h.count === -1 && d.length === 0 && n.bufferSubData(l, 0, u), d.length !== 0) {
      for (let p = 0, g = d.length; p < g; p++) {
        const v = d[p];
        n.bufferSubData(
          l,
          v.start * u.BYTES_PER_ELEMENT,
          u,
          v.start,
          v.count
        );
      }
      c.clearUpdateRanges();
    }
    h.count !== -1 && (n.bufferSubData(
      l,
      h.offset * u.BYTES_PER_ELEMENT,
      u,
      h.offset,
      h.count
    ), h.count = -1), c.onUploadCallback();
  }
  function r(s) {
    return s.isInterleavedBufferAttribute && (s = s.data), e.get(s);
  }
  function a(s) {
    s.isInterleavedBufferAttribute && (s = s.data);
    const c = e.get(s);
    c && (n.deleteBuffer(c.buffer), e.delete(s));
  }
  function o(s, c) {
    if (s.isGLBufferAttribute) {
      const u = e.get(s);
      (!u || u.version < s.version) && e.set(s, {
        buffer: s.buffer,
        type: s.type,
        bytesPerElement: s.elementSize,
        version: s.version
      });
      return;
    }
    s.isInterleavedBufferAttribute && (s = s.data);
    const l = e.get(s);
    if (l === void 0)
      e.set(s, t(s, c));
    else if (l.version < s.version) {
      if (l.size !== s.array.byteLength)
        throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");
      i(l.buffer, s, c), l.version = s.version;
    }
  }
  return {
    get: r,
    remove: a,
    update: o
  };
}
class Sa extends Nt {
  constructor(e = 1, t = 1, i = 1, r = 1) {
    super(), this.type = "PlaneGeometry", this.parameters = {
      width: e,
      height: t,
      widthSegments: i,
      heightSegments: r
    };
    const a = e / 2, o = t / 2, s = Math.floor(i), c = Math.floor(r), l = s + 1, u = c + 1, h = e / s, d = t / c, p = [], g = [], v = [], m = [];
    for (let f = 0; f < u; f++) {
      const M = f * d - o;
      for (let _ = 0; _ < l; _++) {
        const x = _ * h - a;
        g.push(x, -M, 0), v.push(0, 0, 1), m.push(_ / s), m.push(1 - f / c);
      }
    }
    for (let f = 0; f < c; f++)
      for (let M = 0; M < s; M++) {
        const _ = M + l * f, x = M + l * (f + 1), T = M + 1 + l * (f + 1), E = M + 1 + l * f;
        p.push(_, x, E), p.push(x, T, E);
      }
    this.setIndex(p), this.setAttribute("position", new lt(g, 3)), this.setAttribute("normal", new lt(v, 3)), this.setAttribute("uv", new lt(m, 2));
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new Sa(e.width, e.height, e.widthSegments, e.heightSegments);
  }
}
var Id = `#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`, Nd = `#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`, Ud = `#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`, Fd = `#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, Bd = `#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`, kd = `#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`, zd = `#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`, Hd = `#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`, Vd = `#ifdef USE_BATCHING
	attribute float batchId;
	uniform highp sampler2D batchingTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`, Gd = `#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( batchId );
#endif`, Wd = `vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`, jd = `vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`, Xd = `float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`, $d = `#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`, qd = `#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`, Yd = `#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`, Kd = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`, Zd = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`, Jd = `#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`, Qd = `#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`, ep = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`, tp = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	varying vec3 vColor;
#endif`, np = `#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif`, ip = `#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
float luminance( const in vec3 rgb ) {
	const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
	return dot( weights, rgb );
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
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 ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`, rp = `#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`, ap = `vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`, op = `#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`, sp = `#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`, cp = `#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`, lp = `#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`, up = "gl_FragColor = linearToOutputTexel( gl_FragColor );", hp = `
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
	vec3( 0.8224621, 0.177538, 0.0 ),
	vec3( 0.0331941, 0.9668058, 0.0 ),
	vec3( 0.0170827, 0.0723974, 0.9105199 )
);
const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
	vec3( 1.2249401, - 0.2249404, 0.0 ),
	vec3( - 0.0420569, 1.0420571, 0.0 ),
	vec3( - 0.0196376, - 0.0786361, 1.0982735 )
);
vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
	return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
}
vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
	return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
}
vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}
vec4 LinearToLinear( in vec4 value ) {
	return value;
}
vec4 LinearTosRGB( in vec4 value ) {
	return sRGBTransferOETF( value );
}`, fp = `#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`, dp = `#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`, pp = `#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`, mp = `#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`, gp = `#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`, vp = `#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`, _p = `#ifdef USE_FOG
	varying float vFogDepth;
#endif`, yp = `#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`, xp = `#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`, bp = `#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`, Mp = `#ifdef USE_LIGHTMAP
	vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
	vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
	reflectedLight.indirectDiffuse += lightMapIrradiance;
#endif`, Sp = `#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`, Ep = `LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`, wp = `varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`, Tp = `uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	#if defined ( LEGACY_LIGHTS )
		if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
			return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
		}
		return 1.0;
	#else
		float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
		if ( cutoffDistance > 0.0 ) {
			distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
		}
		return distanceFalloff;
	#endif
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`, Ap = `#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`, Cp = `ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`, Rp = `varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`, Pp = `BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`, Lp = `varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`, Dp = `PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`, Op = `struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
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 );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( 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 );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( 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 );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
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;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
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 ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, 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 vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`, Ip = `
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`, Np = `#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`, Up = `#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`, Fp = `#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`, Bp = `#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, kp = `#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, zp = `#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`, Hp = `#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
	
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`, Vp = `#ifdef USE_MAP
	uniform sampler2D map;
#endif`, Gp = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`, Wp = `#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, jp = `float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`, Xp = `#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`, $p = `#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[MORPHTARGETS_COUNT];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`, qp = `#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`, Yp = `#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	#ifdef MORPHTARGETS_TEXTURE
		for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
			if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
		}
	#else
		objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
		objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
		objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
		objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
	#endif
#endif`, Kp = `#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
	#endif
	#ifdef MORPHTARGETS_TEXTURE
		#ifndef USE_INSTANCING_MORPH
			uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
		#endif
		uniform sampler2DArray morphTargetsTexture;
		uniform ivec2 morphTargetsTextureSize;
		vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
			int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
			int y = texelIndex / morphTargetsTextureSize.x;
			int x = texelIndex - y * morphTargetsTextureSize.x;
			ivec3 morphUV = ivec3( x, y, morphTargetIndex );
			return texelFetch( morphTargetsTexture, morphUV, 0 );
		}
	#else
		#ifndef USE_MORPHNORMALS
			uniform float morphTargetInfluences[ 8 ];
		#else
			uniform float morphTargetInfluences[ 4 ];
		#endif
	#endif
#endif`, Zp = `#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	#ifdef MORPHTARGETS_TEXTURE
		for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
			if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
		}
	#else
		transformed += morphTarget0 * morphTargetInfluences[ 0 ];
		transformed += morphTarget1 * morphTargetInfluences[ 1 ];
		transformed += morphTarget2 * morphTargetInfluences[ 2 ];
		transformed += morphTarget3 * morphTargetInfluences[ 3 ];
		#ifndef USE_MORPHNORMALS
			transformed += morphTarget4 * morphTargetInfluences[ 4 ];
			transformed += morphTarget5 * morphTargetInfluences[ 5 ];
			transformed += morphTarget6 * morphTargetInfluences[ 6 ];
			transformed += morphTarget7 * morphTargetInfluences[ 7 ];
		#endif
	#endif
#endif`, Jp = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`, Qp = `#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`, em = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, tm = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, nm = `#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`, im = `#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`, rm = `#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`, am = `#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`, om = `#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`, sm = `#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`, cm = `#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, lm = `vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
const float ShiftRight8 = 1. / 256.;
vec4 packDepthToRGBA( const in float v ) {
	vec4 r = vec4( fract( v * PackFactors ), v );
	r.yzw -= r.xyz * ShiftRight8;	return r * PackUpscale;
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors );
}
vec2 packDepthToRG( in highp float v ) {
	return packDepthToRGBA( v ).yx;
}
float unpackRGToDepth( const in highp vec2 v ) {
	return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
}
vec4 pack2HalfToRGBA( vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`, um = `#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`, hm = `vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`, fm = `#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`, dm = `#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`, pm = `float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`, mm = `#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`, gm = `#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return shadow;
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return shadow;
	}
#endif`, vm = `#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`, _m = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`, ym = `float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`, xm = `#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`, bm = `#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`, Mm = `#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`, Sm = `#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`, Em = `float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`, wm = `#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`, Tm = `#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`, Am = `#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 OptimizedCineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	float startCompression = 0.8 - 0.04;
	float desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min(color.r, min(color.g, color.b));
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max(color.r, max(color.g, color.b));
	if (peak < startCompression) return color;
	float d = 1. - startCompression;
	float newPeak = 1. - d * d / (peak + d - startCompression);
	color *= newPeak / peak;
	float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
	return mix(color, newPeak * vec3(1, 1, 1), g);
}
vec3 CustomToneMapping( vec3 color ) { return color; }`, Cm = `#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`, Rm = `#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
		vec3 refractedRayExit = position + transmissionRay;
		vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
		vec2 refractionCoords = ndcPos.xy / ndcPos.w;
		refractionCoords += 1.0;
		refractionCoords /= 2.0;
		vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
		vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`, Pm = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`, Lm = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`, Dm = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`, Om = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`;
const Im = `varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`, Nm = `uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, Um = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, Fm = `#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, Bm = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, km = `uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, zm = `#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`, Hm = `#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#endif
}`, Vm = `#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`, Gm = `#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`, Wm = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`, jm = `uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, Xm = `uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`, $m = `uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`, qm = `#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`, Ym = `uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, Km = `#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, Zm = `#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, Jm = `#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`, Qm = `#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, eg = `#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`, tg = `#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`, ng = `#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, ig = `#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, rg = `#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`, ag = `#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, og = `#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, sg = `#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, cg = `uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`, lg = `uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`, ug = `#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, hg = `uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`, fg = `uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
	vec2 scale;
	scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
	scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`, dg = `uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`, Ue = {
  alphahash_fragment: Id,
  alphahash_pars_fragment: Nd,
  alphamap_fragment: Ud,
  alphamap_pars_fragment: Fd,
  alphatest_fragment: Bd,
  alphatest_pars_fragment: kd,
  aomap_fragment: zd,
  aomap_pars_fragment: Hd,
  batching_pars_vertex: Vd,
  batching_vertex: Gd,
  begin_vertex: Wd,
  beginnormal_vertex: jd,
  bsdfs: Xd,
  iridescence_fragment: $d,
  bumpmap_pars_fragment: qd,
  clipping_planes_fragment: Yd,
  clipping_planes_pars_fragment: Kd,
  clipping_planes_pars_vertex: Zd,
  clipping_planes_vertex: Jd,
  color_fragment: Qd,
  color_pars_fragment: ep,
  color_pars_vertex: tp,
  color_vertex: np,
  common: ip,
  cube_uv_reflection_fragment: rp,
  defaultnormal_vertex: ap,
  displacementmap_pars_vertex: op,
  displacementmap_vertex: sp,
  emissivemap_fragment: cp,
  emissivemap_pars_fragment: lp,
  colorspace_fragment: up,
  colorspace_pars_fragment: hp,
  envmap_fragment: fp,
  envmap_common_pars_fragment: dp,
  envmap_pars_fragment: pp,
  envmap_pars_vertex: mp,
  envmap_physical_pars_fragment: Ap,
  envmap_vertex: gp,
  fog_vertex: vp,
  fog_pars_vertex: _p,
  fog_fragment: yp,
  fog_pars_fragment: xp,
  gradientmap_pars_fragment: bp,
  lightmap_fragment: Mp,
  lightmap_pars_fragment: Sp,
  lights_lambert_fragment: Ep,
  lights_lambert_pars_fragment: wp,
  lights_pars_begin: Tp,
  lights_toon_fragment: Cp,
  lights_toon_pars_fragment: Rp,
  lights_phong_fragment: Pp,
  lights_phong_pars_fragment: Lp,
  lights_physical_fragment: Dp,
  lights_physical_pars_fragment: Op,
  lights_fragment_begin: Ip,
  lights_fragment_maps: Np,
  lights_fragment_end: Up,
  logdepthbuf_fragment: Fp,
  logdepthbuf_pars_fragment: Bp,
  logdepthbuf_pars_vertex: kp,
  logdepthbuf_vertex: zp,
  map_fragment: Hp,
  map_pars_fragment: Vp,
  map_particle_fragment: Gp,
  map_particle_pars_fragment: Wp,
  metalnessmap_fragment: jp,
  metalnessmap_pars_fragment: Xp,
  morphinstance_vertex: $p,
  morphcolor_vertex: qp,
  morphnormal_vertex: Yp,
  morphtarget_pars_vertex: Kp,
  morphtarget_vertex: Zp,
  normal_fragment_begin: Jp,
  normal_fragment_maps: Qp,
  normal_pars_fragment: em,
  normal_pars_vertex: tm,
  normal_vertex: nm,
  normalmap_pars_fragment: im,
  clearcoat_normal_fragment_begin: rm,
  clearcoat_normal_fragment_maps: am,
  clearcoat_pars_fragment: om,
  iridescence_pars_fragment: sm,
  opaque_fragment: cm,
  packing: lm,
  premultiplied_alpha_fragment: um,
  project_vertex: hm,
  dithering_fragment: fm,
  dithering_pars_fragment: dm,
  roughnessmap_fragment: pm,
  roughnessmap_pars_fragment: mm,
  shadowmap_pars_fragment: gm,
  shadowmap_pars_vertex: vm,
  shadowmap_vertex: _m,
  shadowmask_pars_fragment: ym,
  skinbase_vertex: xm,
  skinning_pars_vertex: bm,
  skinning_vertex: Mm,
  skinnormal_vertex: Sm,
  specularmap_fragment: Em,
  specularmap_pars_fragment: wm,
  tonemapping_fragment: Tm,
  tonemapping_pars_fragment: Am,
  transmission_fragment: Cm,
  transmission_pars_fragment: Rm,
  uv_pars_fragment: Pm,
  uv_pars_vertex: Lm,
  uv_vertex: Dm,
  worldpos_vertex: Om,
  background_vert: Im,
  background_frag: Nm,
  backgroundCube_vert: Um,
  backgroundCube_frag: Fm,
  cube_vert: Bm,
  cube_frag: km,
  depth_vert: zm,
  depth_frag: Hm,
  distanceRGBA_vert: Vm,
  distanceRGBA_frag: Gm,
  equirect_vert: Wm,
  equirect_frag: jm,
  linedashed_vert: Xm,
  linedashed_frag: $m,
  meshbasic_vert: qm,
  meshbasic_frag: Ym,
  meshlambert_vert: Km,
  meshlambert_frag: Zm,
  meshmatcap_vert: Jm,
  meshmatcap_frag: Qm,
  meshnormal_vert: eg,
  meshnormal_frag: tg,
  meshphong_vert: ng,
  meshphong_frag: ig,
  meshphysical_vert: rg,
  meshphysical_frag: ag,
  meshtoon_vert: og,
  meshtoon_frag: sg,
  points_vert: cg,
  points_frag: lg,
  shadow_vert: ug,
  shadow_frag: hg,
  sprite_vert: fg,
  sprite_frag: dg
}, he = {
  common: {
    diffuse: { value: /* @__PURE__ */ new We(16777215) },
    opacity: { value: 1 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new Fe() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new Fe() },
    alphaTest: { value: 0 }
  },
  specularmap: {
    specularMap: { value: null },
    specularMapTransform: { value: /* @__PURE__ */ new Fe() }
  },
  envmap: {
    envMap: { value: null },
    envMapRotation: { value: /* @__PURE__ */ new Fe() },
    flipEnvMap: { value: -1 },
    reflectivity: { value: 1 },
    // basic, lambert, phong
    ior: { value: 1.5 },
    // physical
    refractionRatio: { value: 0.98 }
    // basic, lambert, phong
  },
  aomap: {
    aoMap: { value: null },
    aoMapIntensity: { value: 1 },
    aoMapTransform: { value: /* @__PURE__ */ new Fe() }
  },
  lightmap: {
    lightMap: { value: null },
    lightMapIntensity: { value: 1 },
    lightMapTransform: { value: /* @__PURE__ */ new Fe() }
  },
  bumpmap: {
    bumpMap: { value: null },
    bumpMapTransform: { value: /* @__PURE__ */ new Fe() },
    bumpScale: { value: 1 }
  },
  normalmap: {
    normalMap: { value: null },
    normalMapTransform: { value: /* @__PURE__ */ new Fe() },
    normalScale: { value: /* @__PURE__ */ new le(1, 1) }
  },
  displacementmap: {
    displacementMap: { value: null },
    displacementMapTransform: { value: /* @__PURE__ */ new Fe() },
    displacementScale: { value: 1 },
    displacementBias: { value: 0 }
  },
  emissivemap: {
    emissiveMap: { value: null },
    emissiveMapTransform: { value: /* @__PURE__ */ new Fe() }
  },
  metalnessmap: {
    metalnessMap: { value: null },
    metalnessMapTransform: { value: /* @__PURE__ */ new Fe() }
  },
  roughnessmap: {
    roughnessMap: { value: null },
    roughnessMapTransform: { value: /* @__PURE__ */ new Fe() }
  },
  gradientmap: {
    gradientMap: { value: null }
  },
  fog: {
    fogDensity: { value: 25e-5 },
    fogNear: { value: 1 },
    fogFar: { value: 2e3 },
    fogColor: { value: /* @__PURE__ */ new We(16777215) }
  },
  lights: {
    ambientLightColor: { value: [] },
    lightProbe: { value: [] },
    directionalLights: { value: [], properties: {
      direction: {},
      color: {}
    } },
    directionalLightShadows: { value: [], properties: {
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {}
    } },
    directionalShadowMap: { value: [] },
    directionalShadowMatrix: { value: [] },
    spotLights: { value: [], properties: {
      color: {},
      position: {},
      direction: {},
      distance: {},
      coneCos: {},
      penumbraCos: {},
      decay: {}
    } },
    spotLightShadows: { value: [], properties: {
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {}
    } },
    spotLightMap: { value: [] },
    spotShadowMap: { value: [] },
    spotLightMatrix: { value: [] },
    pointLights: { value: [], properties: {
      color: {},
      position: {},
      decay: {},
      distance: {}
    } },
    pointLightShadows: { value: [], properties: {
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {},
      shadowCameraNear: {},
      shadowCameraFar: {}
    } },
    pointShadowMap: { value: [] },
    pointShadowMatrix: { value: [] },
    hemisphereLights: { value: [], properties: {
      direction: {},
      skyColor: {},
      groundColor: {}
    } },
    // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
    rectAreaLights: { value: [], properties: {
      color: {},
      position: {},
      width: {},
      height: {}
    } },
    ltc_1: { value: null },
    ltc_2: { value: null }
  },
  points: {
    diffuse: { value: /* @__PURE__ */ new We(16777215) },
    opacity: { value: 1 },
    size: { value: 1 },
    scale: { value: 1 },
    map: { value: null },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new Fe() },
    alphaTest: { value: 0 },
    uvTransform: { value: /* @__PURE__ */ new Fe() }
  },
  sprite: {
    diffuse: { value: /* @__PURE__ */ new We(16777215) },
    opacity: { value: 1 },
    center: { value: /* @__PURE__ */ new le(0.5, 0.5) },
    rotation: { value: 0 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new Fe() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new Fe() },
    alphaTest: { value: 0 }
  }
}, tn = {
  basic: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.specularmap,
      he.envmap,
      he.aomap,
      he.lightmap,
      he.fog
    ]),
    vertexShader: Ue.meshbasic_vert,
    fragmentShader: Ue.meshbasic_frag
  },
  lambert: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.specularmap,
      he.envmap,
      he.aomap,
      he.lightmap,
      he.emissivemap,
      he.bumpmap,
      he.normalmap,
      he.displacementmap,
      he.fog,
      he.lights,
      {
        emissive: { value: /* @__PURE__ */ new We(0) }
      }
    ]),
    vertexShader: Ue.meshlambert_vert,
    fragmentShader: Ue.meshlambert_frag
  },
  phong: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.specularmap,
      he.envmap,
      he.aomap,
      he.lightmap,
      he.emissivemap,
      he.bumpmap,
      he.normalmap,
      he.displacementmap,
      he.fog,
      he.lights,
      {
        emissive: { value: /* @__PURE__ */ new We(0) },
        specular: { value: /* @__PURE__ */ new We(1118481) },
        shininess: { value: 30 }
      }
    ]),
    vertexShader: Ue.meshphong_vert,
    fragmentShader: Ue.meshphong_frag
  },
  standard: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.envmap,
      he.aomap,
      he.lightmap,
      he.emissivemap,
      he.bumpmap,
      he.normalmap,
      he.displacementmap,
      he.roughnessmap,
      he.metalnessmap,
      he.fog,
      he.lights,
      {
        emissive: { value: /* @__PURE__ */ new We(0) },
        roughness: { value: 1 },
        metalness: { value: 0 },
        envMapIntensity: { value: 1 }
      }
    ]),
    vertexShader: Ue.meshphysical_vert,
    fragmentShader: Ue.meshphysical_frag
  },
  toon: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.aomap,
      he.lightmap,
      he.emissivemap,
      he.bumpmap,
      he.normalmap,
      he.displacementmap,
      he.gradientmap,
      he.fog,
      he.lights,
      {
        emissive: { value: /* @__PURE__ */ new We(0) }
      }
    ]),
    vertexShader: Ue.meshtoon_vert,
    fragmentShader: Ue.meshtoon_frag
  },
  matcap: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.bumpmap,
      he.normalmap,
      he.displacementmap,
      he.fog,
      {
        matcap: { value: null }
      }
    ]),
    vertexShader: Ue.meshmatcap_vert,
    fragmentShader: Ue.meshmatcap_frag
  },
  points: {
    uniforms: /* @__PURE__ */ St([
      he.points,
      he.fog
    ]),
    vertexShader: Ue.points_vert,
    fragmentShader: Ue.points_frag
  },
  dashed: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.fog,
      {
        scale: { value: 1 },
        dashSize: { value: 1 },
        totalSize: { value: 2 }
      }
    ]),
    vertexShader: Ue.linedashed_vert,
    fragmentShader: Ue.linedashed_frag
  },
  depth: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.displacementmap
    ]),
    vertexShader: Ue.depth_vert,
    fragmentShader: Ue.depth_frag
  },
  normal: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.bumpmap,
      he.normalmap,
      he.displacementmap,
      {
        opacity: { value: 1 }
      }
    ]),
    vertexShader: Ue.meshnormal_vert,
    fragmentShader: Ue.meshnormal_frag
  },
  sprite: {
    uniforms: /* @__PURE__ */ St([
      he.sprite,
      he.fog
    ]),
    vertexShader: Ue.sprite_vert,
    fragmentShader: Ue.sprite_frag
  },
  background: {
    uniforms: {
      uvTransform: { value: /* @__PURE__ */ new Fe() },
      t2D: { value: null },
      backgroundIntensity: { value: 1 }
    },
    vertexShader: Ue.background_vert,
    fragmentShader: Ue.background_frag
  },
  backgroundCube: {
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 },
      backgroundBlurriness: { value: 0 },
      backgroundIntensity: { value: 1 },
      backgroundRotation: { value: /* @__PURE__ */ new Fe() }
    },
    vertexShader: Ue.backgroundCube_vert,
    fragmentShader: Ue.backgroundCube_frag
  },
  cube: {
    uniforms: {
      tCube: { value: null },
      tFlip: { value: -1 },
      opacity: { value: 1 }
    },
    vertexShader: Ue.cube_vert,
    fragmentShader: Ue.cube_frag
  },
  equirect: {
    uniforms: {
      tEquirect: { value: null }
    },
    vertexShader: Ue.equirect_vert,
    fragmentShader: Ue.equirect_frag
  },
  distanceRGBA: {
    uniforms: /* @__PURE__ */ St([
      he.common,
      he.displacementmap,
      {
        referencePosition: { value: /* @__PURE__ */ new O() },
        nearDistance: { value: 1 },
        farDistance: { value: 1e3 }
      }
    ]),
    vertexShader: Ue.distanceRGBA_vert,
    fragmentShader: Ue.distanceRGBA_frag
  },
  shadow: {
    uniforms: /* @__PURE__ */ St([
      he.lights,
      he.fog,
      {
        color: { value: /* @__PURE__ */ new We(0) },
        opacity: { value: 1 }
      }
    ]),
    vertexShader: Ue.shadow_vert,
    fragmentShader: Ue.shadow_frag
  }
};
tn.physical = {
  uniforms: /* @__PURE__ */ St([
    tn.standard.uniforms,
    {
      clearcoat: { value: 0 },
      clearcoatMap: { value: null },
      clearcoatMapTransform: { value: /* @__PURE__ */ new Fe() },
      clearcoatNormalMap: { value: null },
      clearcoatNormalMapTransform: { value: /* @__PURE__ */ new Fe() },
      clearcoatNormalScale: { value: /* @__PURE__ */ new le(1, 1) },
      clearcoatRoughness: { value: 0 },
      clearcoatRoughnessMap: { value: null },
      clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new Fe() },
      iridescence: { value: 0 },
      iridescenceMap: { value: null },
      iridescenceMapTransform: { value: /* @__PURE__ */ new Fe() },
      iridescenceIOR: { value: 1.3 },
      iridescenceThicknessMinimum: { value: 100 },
      iridescenceThicknessMaximum: { value: 400 },
      iridescenceThicknessMap: { value: null },
      iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new Fe() },
      sheen: { value: 0 },
      sheenColor: { value: /* @__PURE__ */ new We(0) },
      sheenColorMap: { value: null },
      sheenColorMapTransform: { value: /* @__PURE__ */ new Fe() },
      sheenRoughness: { value: 1 },
      sheenRoughnessMap: { value: null },
      sheenRoughnessMapTransform: { value: /* @__PURE__ */ new Fe() },
      transmission: { value: 0 },
      transmissionMap: { value: null },
      transmissionMapTransform: { value: /* @__PURE__ */ new Fe() },
      transmissionSamplerSize: { value: /* @__PURE__ */ new le() },
      transmissionSamplerMap: { value: null },
      thickness: { value: 0 },
      thicknessMap: { value: null },
      thicknessMapTransform: { value: /* @__PURE__ */ new Fe() },
      attenuationDistance: { value: 0 },
      attenuationColor: { value: /* @__PURE__ */ new We(0) },
      specularColor: { value: /* @__PURE__ */ new We(1, 1, 1) },
      specularColorMap: { value: null },
      specularColorMapTransform: { value: /* @__PURE__ */ new Fe() },
      specularIntensity: { value: 1 },
      specularIntensityMap: { value: null },
      specularIntensityMapTransform: { value: /* @__PURE__ */ new Fe() },
      anisotropyVector: { value: /* @__PURE__ */ new le() },
      anisotropyMap: { value: null },
      anisotropyMapTransform: { value: /* @__PURE__ */ new Fe() }
    }
  ]),
  vertexShader: Ue.meshphysical_vert,
  fragmentShader: Ue.meshphysical_frag
};
const Xr = { r: 0, b: 0, g: 0 }, Qn = /* @__PURE__ */ new on(), pg = /* @__PURE__ */ new Je();
function mg(n, e, t, i, r, a, o) {
  const s = new We(0);
  let c = a === !0 ? 0 : 1, l, u, h = null, d = 0, p = null;
  function g(m, f) {
    let M = !1, _ = f.isScene === !0 ? f.background : null;
    _ && _.isTexture && (_ = (f.backgroundBlurriness > 0 ? t : e).get(_)), _ === null ? v(s, c) : _ && _.isColor && (v(_, 1), M = !0);
    const x = n.xr.getEnvironmentBlendMode();
    x === "additive" ? i.buffers.color.setClear(0, 0, 0, 1, o) : x === "alpha-blend" && i.buffers.color.setClear(0, 0, 0, 0, o), (n.autoClear || M) && n.clear(n.autoClearColor, n.autoClearDepth, n.autoClearStencil), _ && (_.isCubeTexture || _.mapping === ya) ? (u === void 0 && (u = new Vt(
      new Mr(1, 1, 1),
      new sn({
        name: "BackgroundCubeMaterial",
        uniforms: Hi(tn.backgroundCube.uniforms),
        vertexShader: tn.backgroundCube.vertexShader,
        fragmentShader: tn.backgroundCube.fragmentShader,
        side: wt,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), u.geometry.deleteAttribute("normal"), u.geometry.deleteAttribute("uv"), u.onBeforeRender = function(T, E, A) {
      this.matrixWorld.copyPosition(A.matrixWorld);
    }, Object.defineProperty(u.material, "envMap", {
      get: function() {
        return this.uniforms.envMap.value;
      }
    }), r.update(u)), Qn.copy(f.backgroundRotation), Qn.x *= -1, Qn.y *= -1, Qn.z *= -1, _.isCubeTexture && _.isRenderTargetTexture === !1 && (Qn.y *= -1, Qn.z *= -1), u.material.uniforms.envMap.value = _, u.material.uniforms.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, u.material.uniforms.backgroundBlurriness.value = f.backgroundBlurriness, u.material.uniforms.backgroundIntensity.value = f.backgroundIntensity, u.material.uniforms.backgroundRotation.value.setFromMatrix4(pg.makeRotationFromEuler(Qn)), u.material.toneMapped = Ke.getTransfer(_.colorSpace) !== Qe, (h !== _ || d !== _.version || p !== n.toneMapping) && (u.material.needsUpdate = !0, h = _, d = _.version, p = n.toneMapping), u.layers.enableAll(), m.unshift(u, u.geometry, u.material, 0, 0, null)) : _ && _.isTexture && (l === void 0 && (l = new Vt(
      new Sa(2, 2),
      new sn({
        name: "BackgroundMaterial",
        uniforms: Hi(tn.background.uniforms),
        vertexShader: tn.background.vertexShader,
        fragmentShader: tn.background.fragmentShader,
        side: Hn,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), l.geometry.deleteAttribute("normal"), Object.defineProperty(l.material, "map", {
      get: function() {
        return this.uniforms.t2D.value;
      }
    }), r.update(l)), l.material.uniforms.t2D.value = _, l.material.uniforms.backgroundIntensity.value = f.backgroundIntensity, l.material.toneMapped = Ke.getTransfer(_.colorSpace) !== Qe, _.matrixAutoUpdate === !0 && _.updateMatrix(), l.material.uniforms.uvTransform.value.copy(_.matrix), (h !== _ || d !== _.version || p !== n.toneMapping) && (l.material.needsUpdate = !0, h = _, d = _.version, p = n.toneMapping), l.layers.enableAll(), m.unshift(l, l.geometry, l.material, 0, 0, null));
  }
  function v(m, f) {
    m.getRGB(Xr, Tu(n)), i.buffers.color.setClear(Xr.r, Xr.g, Xr.b, f, o);
  }
  return {
    getClearColor: function() {
      return s;
    },
    setClearColor: function(m, f = 1) {
      s.set(m), c = f, v(s, c);
    },
    getClearAlpha: function() {
      return c;
    },
    setClearAlpha: function(m) {
      c = m, v(s, c);
    },
    render: g
  };
}
function gg(n, e) {
  const t = n.getParameter(n.MAX_VERTEX_ATTRIBS), i = {}, r = d(null);
  let a = r, o = !1;
  function s(b, U, z, I, L) {
    let D = !1;
    const B = h(I, z, U);
    a !== B && (a = B, l(a.object)), D = p(b, I, z, L), D && g(b, I, z, L), L !== null && e.update(L, n.ELEMENT_ARRAY_BUFFER), (D || o) && (o = !1, x(b, U, z, I), L !== null && n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, e.get(L).buffer));
  }
  function c() {
    return n.createVertexArray();
  }
  function l(b) {
    return n.bindVertexArray(b);
  }
  function u(b) {
    return n.deleteVertexArray(b);
  }
  function h(b, U, z) {
    const I = z.wireframe === !0;
    let L = i[b.id];
    L === void 0 && (L = {}, i[b.id] = L);
    let D = L[U.id];
    D === void 0 && (D = {}, L[U.id] = D);
    let B = D[I];
    return B === void 0 && (B = d(c()), D[I] = B), B;
  }
  function d(b) {
    const U = [], z = [], I = [];
    for (let L = 0; L < t; L++)
      U[L] = 0, z[L] = 0, I[L] = 0;
    return {
      // for backward compatibility on non-VAO support browser
      geometry: null,
      program: null,
      wireframe: !1,
      newAttributes: U,
      enabledAttributes: z,
      attributeDivisors: I,
      object: b,
      attributes: {},
      index: null
    };
  }
  function p(b, U, z, I) {
    const L = a.attributes, D = U.attributes;
    let B = 0;
    const te = z.getAttributes();
    for (const W in te)
      if (te[W].location >= 0) {
        const G = L[W];
        let Q = D[W];
        if (Q === void 0 && (W === "instanceMatrix" && b.instanceMatrix && (Q = b.instanceMatrix), W === "instanceColor" && b.instanceColor && (Q = b.instanceColor)), G === void 0 || G.attribute !== Q || Q && G.data !== Q.data)
          return !0;
        B++;
      }
    return a.attributesNum !== B || a.index !== I;
  }
  function g(b, U, z, I) {
    const L = {}, D = U.attributes;
    let B = 0;
    const te = z.getAttributes();
    for (const W in te)
      if (te[W].location >= 0) {
        let G = D[W];
        G === void 0 && (W === "instanceMatrix" && b.instanceMatrix && (G = b.instanceMatrix), W === "instanceColor" && b.instanceColor && (G = b.instanceColor));
        const Q = {};
        Q.attribute = G, G && G.data && (Q.data = G.data), L[W] = Q, B++;
      }
    a.attributes = L, a.attributesNum = B, a.index = I;
  }
  function v() {
    const b = a.newAttributes;
    for (let U = 0, z = b.length; U < z; U++)
      b[U] = 0;
  }
  function m(b) {
    f(b, 0);
  }
  function f(b, U) {
    const z = a.newAttributes, I = a.enabledAttributes, L = a.attributeDivisors;
    z[b] = 1, I[b] === 0 && (n.enableVertexAttribArray(b), I[b] = 1), L[b] !== U && (n.vertexAttribDivisor(b, U), L[b] = U);
  }
  function M() {
    const b = a.newAttributes, U = a.enabledAttributes;
    for (let z = 0, I = U.length; z < I; z++)
      U[z] !== b[z] && (n.disableVertexAttribArray(z), U[z] = 0);
  }
  function _(b, U, z, I, L, D, B) {
    B === !0 ? n.vertexAttribIPointer(b, U, z, L, D) : n.vertexAttribPointer(b, U, z, I, L, D);
  }
  function x(b, U, z, I) {
    v();
    const L = I.attributes, D = z.getAttributes(), B = U.defaultAttributeValues;
    for (const te in D) {
      const W = D[te];
      if (W.location >= 0) {
        let ie = L[te];
        if (ie === void 0 && (te === "instanceMatrix" && b.instanceMatrix && (ie = b.instanceMatrix), te === "instanceColor" && b.instanceColor && (ie = b.instanceColor)), ie !== void 0) {
          const G = ie.normalized, Q = ie.itemSize, se = e.get(ie);
          if (se === void 0)
            continue;
          const xe = se.buffer, k = se.type, H = se.bytesPerElement, Z = k === n.INT || k === n.UNSIGNED_INT || ie.gpuType === hu;
          if (ie.isInterleavedBufferAttribute) {
            const N = ie.data, K = N.stride, oe = ie.offset;
            if (N.isInstancedInterleavedBuffer) {
              for (let fe = 0; fe < W.locationSize; fe++)
                f(W.location + fe, N.meshPerAttribute);
              b.isInstancedMesh !== !0 && I._maxInstanceCount === void 0 && (I._maxInstanceCount = N.meshPerAttribute * N.count);
            } else
              for (let fe = 0; fe < W.locationSize; fe++)
                m(W.location + fe);
            n.bindBuffer(n.ARRAY_BUFFER, xe);
            for (let fe = 0; fe < W.locationSize; fe++)
              _(
                W.location + fe,
                Q / W.locationSize,
                k,
                G,
                K * H,
                (oe + Q / W.locationSize * fe) * H,
                Z
              );
          } else {
            if (ie.isInstancedBufferAttribute) {
              for (let N = 0; N < W.locationSize; N++)
                f(W.location + N, ie.meshPerAttribute);
              b.isInstancedMesh !== !0 && I._maxInstanceCount === void 0 && (I._maxInstanceCount = ie.meshPerAttribute * ie.count);
            } else
              for (let N = 0; N < W.locationSize; N++)
                m(W.location + N);
            n.bindBuffer(n.ARRAY_BUFFER, xe);
            for (let N = 0; N < W.locationSize; N++)
              _(
                W.location + N,
                Q / W.locationSize,
                k,
                G,
                Q * H,
                Q / W.locationSize * N * H,
                Z
              );
          }
        } else if (B !== void 0) {
          const G = B[te];
          if (G !== void 0)
            switch (G.length) {
              case 2:
                n.vertexAttrib2fv(W.location, G);
                break;
              case 3:
                n.vertexAttrib3fv(W.location, G);
                break;
              case 4:
                n.vertexAttrib4fv(W.location, G);
                break;
              default:
                n.vertexAttrib1fv(W.location, G);
            }
        }
      }
    }
    M();
  }
  function T() {
    R();
    for (const b in i) {
      const U = i[b];
      for (const z in U) {
        const I = U[z];
        for (const L in I)
          u(I[L].object), delete I[L];
        delete U[z];
      }
      delete i[b];
    }
  }
  function E(b) {
    if (i[b.id] === void 0)
      return;
    const U = i[b.id];
    for (const z in U) {
      const I = U[z];
      for (const L in I)
        u(I[L].object), delete I[L];
      delete U[z];
    }
    delete i[b.id];
  }
  function A(b) {
    for (const U in i) {
      const z = i[U];
      if (z[b.id] === void 0)
        continue;
      const I = z[b.id];
      for (const L in I)
        u(I[L].object), delete I[L];
      delete z[b.id];
    }
  }
  function R() {
    w(), o = !0, a !== r && (a = r, l(a.object));
  }
  function w() {
    r.geometry = null, r.program = null, r.wireframe = !1;
  }
  return {
    setup: s,
    reset: R,
    resetDefaultState: w,
    dispose: T,
    releaseStatesOfGeometry: E,
    releaseStatesOfProgram: A,
    initAttributes: v,
    enableAttribute: m,
    disableUnusedAttributes: M
  };
}
function vg(n, e, t) {
  let i;
  function r(c) {
    i = c;
  }
  function a(c, l) {
    n.drawArrays(i, c, l), t.update(l, i, 1);
  }
  function o(c, l, u) {
    u !== 0 && (n.drawArraysInstanced(i, c, l, u), t.update(l, i, u));
  }
  function s(c, l, u) {
    if (u === 0)
      return;
    const h = e.get("WEBGL_multi_draw");
    if (h === null)
      for (let d = 0; d < u; d++)
        this.render(c[d], l[d]);
    else {
      h.multiDrawArraysWEBGL(i, c, 0, l, 0, u);
      let d = 0;
      for (let p = 0; p < u; p++)
        d += l[p];
      t.update(d, i, 1);
    }
  }
  this.setMode = r, this.render = a, this.renderInstances = o, this.renderMultiDraw = s;
}
function _g(n, e, t) {
  let i;
  function r() {
    if (i !== void 0)
      return i;
    if (e.has("EXT_texture_filter_anisotropic") === !0) {
      const _ = e.get("EXT_texture_filter_anisotropic");
      i = n.getParameter(_.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
    } else
      i = 0;
    return i;
  }
  function a(_) {
    if (_ === "highp") {
      if (n.getShaderPrecisionFormat(n.VERTEX_SHADER, n.HIGH_FLOAT).precision > 0 && n.getShaderPrecisionFormat(n.FRAGMENT_SHADER, n.HIGH_FLOAT).precision > 0)
        return "highp";
      _ = "mediump";
    }
    return _ === "mediump" && n.getShaderPrecisionFormat(n.VERTEX_SHADER, n.MEDIUM_FLOAT).precision > 0 && n.getShaderPrecisionFormat(n.FRAGMENT_SHADER, n.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp";
  }
  let o = t.precision !== void 0 ? t.precision : "highp";
  const s = a(o);
  s !== o && (console.warn("THREE.WebGLRenderer:", o, "not supported, using", s, "instead."), o = s);
  const c = t.logarithmicDepthBuffer === !0, l = n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS), u = n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS), h = n.getParameter(n.MAX_TEXTURE_SIZE), d = n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE), p = n.getParameter(n.MAX_VERTEX_ATTRIBS), g = n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS), v = n.getParameter(n.MAX_VARYING_VECTORS), m = n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS), f = u > 0, M = n.getParameter(n.MAX_SAMPLES);
  return {
    isWebGL2: !0,
    // keeping this for backwards compatibility
    getMaxAnisotropy: r,
    getMaxPrecision: a,
    precision: o,
    logarithmicDepthBuffer: c,
    maxTextures: l,
    maxVertexTextures: u,
    maxTextureSize: h,
    maxCubemapSize: d,
    maxAttributes: p,
    maxVertexUniforms: g,
    maxVaryings: v,
    maxFragmentUniforms: m,
    vertexTextures: f,
    maxSamples: M
  };
}
function yg(n) {
  const e = this;
  let t = null, i = 0, r = !1, a = !1;
  const o = new yn(), s = new Fe(), c = { value: null, needsUpdate: !1 };
  this.uniform = c, this.numPlanes = 0, this.numIntersection = 0, this.init = function(h, d) {
    const p = h.length !== 0 || d || // enable state of previous frame - the clipping code has to
    // run another frame in order to reset the state:
    i !== 0 || r;
    return r = d, i = h.length, p;
  }, this.beginShadows = function() {
    a = !0, u(null);
  }, this.endShadows = function() {
    a = !1;
  }, this.setGlobalState = function(h, d) {
    t = u(h, d, 0);
  }, this.setState = function(h, d, p) {
    const g = h.clippingPlanes, v = h.clipIntersection, m = h.clipShadows, f = n.get(h);
    if (!r || g === null || g.length === 0 || a && !m)
      a ? u(null) : l();
    else {
      const M = a ? 0 : i, _ = M * 4;
      let x = f.clippingState || null;
      c.value = x, x = u(g, d, _, p);
      for (let T = 0; T !== _; ++T)
        x[T] = t[T];
      f.clippingState = x, this.numIntersection = v ? this.numPlanes : 0, this.numPlanes += M;
    }
  };
  function l() {
    c.value !== t && (c.value = t, c.needsUpdate = i > 0), e.numPlanes = i, e.numIntersection = 0;
  }
  function u(h, d, p, g) {
    const v = h !== null ? h.length : 0;
    let m = null;
    if (v !== 0) {
      if (m = c.value, g !== !0 || m === null) {
        const f = p + v * 4, M = d.matrixWorldInverse;
        s.getNormalMatrix(M), (m === null || m.length < f) && (m = new Float32Array(f));
        for (let _ = 0, x = p; _ !== v; ++_, x += 4)
          o.copy(h[_]).applyMatrix4(M, s), o.normal.toArray(m, x), m[x + 3] = o.constant;
      }
      c.value = m, c.needsUpdate = !0;
    }
    return e.numPlanes = v, e.numIntersection = 0, m;
  }
}
function xg(n) {
  let e = /* @__PURE__ */ new WeakMap();
  function t(o, s) {
    return s === Uo ? o.mapping = Bi : s === Fo && (o.mapping = ki), o;
  }
  function i(o) {
    if (o && o.isTexture) {
      const s = o.mapping;
      if (s === Uo || s === Fo)
        if (e.has(o)) {
          const c = e.get(o).texture;
          return t(c, o.mapping);
        } else {
          const c = o.image;
          if (c && c.height > 0) {
            const l = new Pd(c.height);
            return l.fromEquirectangularTexture(n, o), e.set(o, l), o.addEventListener("dispose", r), t(l.texture, o.mapping);
          } else
            return null;
        }
    }
    return o;
  }
  function r(o) {
    const s = o.target;
    s.removeEventListener("dispose", r);
    const c = e.get(s);
    c !== void 0 && (e.delete(s), c.dispose());
  }
  function a() {
    e = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: i,
    dispose: a
  };
}
class fs extends Cu {
  constructor(e = -1, t = 1, i = 1, r = -1, a = 0.1, o = 2e3) {
    super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = i, this.bottom = r, this.near = a, this.far = o, this.updateProjectionMatrix();
  }
  copy(e, t) {
    return super.copy(e, t), this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.near = e.near, this.far = e.far, this.zoom = e.zoom, this.view = e.view === null ? null : Object.assign({}, e.view), this;
  }
  setViewOffset(e, t, i, r, a, o) {
    this.view === null && (this.view = {
      enabled: !0,
      fullWidth: 1,
      fullHeight: 1,
      offsetX: 0,
      offsetY: 0,
      width: 1,
      height: 1
    }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = i, this.view.offsetY = r, this.view.width = a, this.view.height = o, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), i = (this.right + this.left) / 2, r = (this.top + this.bottom) / 2;
    let a = i - e, o = i + e, s = r + t, c = r - t;
    if (this.view !== null && this.view.enabled) {
      const l = (this.right - this.left) / this.view.fullWidth / this.zoom, u = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
      a += l * this.view.offsetX, o = a + l * this.view.width, s -= u * this.view.offsetY, c = s - u * this.view.height;
    }
    this.projectionMatrix.makeOrthographic(a, o, s, c, this.near, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return t.object.zoom = this.zoom, t.object.left = this.left, t.object.right = this.right, t.object.top = this.top, t.object.bottom = this.bottom, t.object.near = this.near, t.object.far = this.far, this.view !== null && (t.object.view = Object.assign({}, this.view)), t;
  }
}
const Di = 4, Nc = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], ri = 20, oo = /* @__PURE__ */ new fs(), Uc = /* @__PURE__ */ new We();
let so = null, co = 0, lo = 0, uo = !1;
const ti = (1 + Math.sqrt(5)) / 2, Ri = 1 / ti, Fc = [
  /* @__PURE__ */ new O(1, 1, 1),
  /* @__PURE__ */ new O(-1, 1, 1),
  /* @__PURE__ */ new O(1, 1, -1),
  /* @__PURE__ */ new O(-1, 1, -1),
  /* @__PURE__ */ new O(0, ti, Ri),
  /* @__PURE__ */ new O(0, ti, -Ri),
  /* @__PURE__ */ new O(Ri, 0, ti),
  /* @__PURE__ */ new O(-Ri, 0, ti),
  /* @__PURE__ */ new O(ti, Ri, 0),
  /* @__PURE__ */ new O(-ti, Ri, 0)
];
class Bc {
  constructor(e) {
    this._renderer = e, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._lodPlanes = [], this._sizeLods = [], this._sigmas = [], this._blurMaterial = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._compileMaterial(this._blurMaterial);
  }
  /**
   * Generates a PMREM from a supplied Scene, which can be faster than using an
   * image if networking bandwidth is low. Optional sigma specifies a blur radius
   * in radians to be applied to the scene before PMREM generation. Optional near
   * and far planes ensure the scene is rendered in its entirety (the cubeCamera
   * is placed at the origin).
   */
  fromScene(e, t = 0, i = 0.1, r = 100) {
    so = this._renderer.getRenderTarget(), co = this._renderer.getActiveCubeFace(), lo = this._renderer.getActiveMipmapLevel(), uo = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(256);
    const a = this._allocateTargets();
    return a.depthBuffer = !0, this._sceneToCubeUV(e, i, r, a), t > 0 && this._blur(a, 0, 0, t), this._applyPMREM(a), this._cleanup(a), a;
  }
  /**
   * Generates a PMREM from an equirectangular texture, which can be either LDR
   * or HDR. The ideal input image size is 1k (1024 x 512),
   * as this matches best with the 256 x 256 cubemap output.
   * The smallest supported equirectangular image size is 64 x 32.
   */
  fromEquirectangular(e, t = null) {
    return this._fromTexture(e, t);
  }
  /**
   * Generates a PMREM from an cubemap texture, which can be either LDR
   * or HDR. The ideal input cube size is 256 x 256,
   * as this matches best with the 256 x 256 cubemap output.
   * The smallest supported cube size is 16 x 16.
   */
  fromCubemap(e, t = null) {
    return this._fromTexture(e, t);
  }
  /**
   * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
   * your texture's network fetch for increased concurrency.
   */
  compileCubemapShader() {
    this._cubemapMaterial === null && (this._cubemapMaterial = Hc(), this._compileMaterial(this._cubemapMaterial));
  }
  /**
   * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
   * your texture's network fetch for increased concurrency.
   */
  compileEquirectangularShader() {
    this._equirectMaterial === null && (this._equirectMaterial = zc(), this._compileMaterial(this._equirectMaterial));
  }
  /**
   * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,
   * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on
   * one of them will cause any others to also become unusable.
   */
  dispose() {
    this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose();
  }
  // private interface
  _setSize(e) {
    this._lodMax = Math.floor(Math.log2(e)), this._cubeSize = Math.pow(2, this._lodMax);
  }
  _dispose() {
    this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose();
    for (let e = 0; e < this._lodPlanes.length; e++)
      this._lodPlanes[e].dispose();
  }
  _cleanup(e) {
    this._renderer.setRenderTarget(so, co, lo), this._renderer.xr.enabled = uo, e.scissorTest = !1, $r(e, 0, 0, e.width, e.height);
  }
  _fromTexture(e, t) {
    e.mapping === Bi || e.mapping === ki ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), so = this._renderer.getRenderTarget(), co = this._renderer.getActiveCubeFace(), lo = this._renderer.getActiveMipmapLevel(), uo = this._renderer.xr.enabled, this._renderer.xr.enabled = !1;
    const i = t || this._allocateTargets();
    return this._textureToCubeUV(e, i), this._applyPMREM(i), this._cleanup(i), i;
  }
  _allocateTargets() {
    const e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, i = {
      magFilter: Yt,
      minFilter: Yt,
      generateMipmaps: !1,
      type: pr,
      format: rn,
      colorSpace: Gn,
      depthBuffer: !1
    }, r = kc(e, t, i);
    if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) {
      this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = kc(e, t, i);
      const { _lodMax: a } = this;
      ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = bg(a)), this._blurMaterial = Mg(a, e, t);
    }
    return r;
  }
  _compileMaterial(e) {
    const t = new Vt(this._lodPlanes[0], e);
    this._renderer.compile(t, oo);
  }
  _sceneToCubeUV(e, t, i, r) {
    const s = new zt(90, 1, t, i), c = [1, -1, 1, 1, 1, 1], l = [1, 1, 1, -1, -1, -1], u = this._renderer, h = u.autoClear, d = u.toneMapping;
    u.getClearColor(Uc), u.toneMapping = kn, u.autoClear = !1;
    const p = new us({
      name: "PMREM.Background",
      side: wt,
      depthWrite: !1,
      depthTest: !1
    }), g = new Vt(new Mr(), p);
    let v = !1;
    const m = e.background;
    m ? m.isColor && (p.color.copy(m), e.background = null, v = !0) : (p.color.copy(Uc), v = !0);
    for (let f = 0; f < 6; f++) {
      const M = f % 3;
      M === 0 ? (s.up.set(0, c[f], 0), s.lookAt(l[f], 0, 0)) : M === 1 ? (s.up.set(0, 0, c[f]), s.lookAt(0, l[f], 0)) : (s.up.set(0, c[f], 0), s.lookAt(0, 0, l[f]));
      const _ = this._cubeSize;
      $r(r, M * _, f > 2 ? _ : 0, _, _), u.setRenderTarget(r), v && u.render(g, s), u.render(e, s);
    }
    g.geometry.dispose(), g.material.dispose(), u.toneMapping = d, u.autoClear = h, e.background = m;
  }
  _textureToCubeUV(e, t) {
    const i = this._renderer, r = e.mapping === Bi || e.mapping === ki;
    r ? (this._cubemapMaterial === null && (this._cubemapMaterial = Hc()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = zc());
    const a = r ? this._cubemapMaterial : this._equirectMaterial, o = new Vt(this._lodPlanes[0], a), s = a.uniforms;
    s.envMap.value = e;
    const c = this._cubeSize;
    $r(t, 0, 0, 3 * c, 2 * c), i.setRenderTarget(t), i.render(o, oo);
  }
  _applyPMREM(e) {
    const t = this._renderer, i = t.autoClear;
    t.autoClear = !1;
    for (let r = 1; r < this._lodPlanes.length; r++) {
      const a = Math.sqrt(this._sigmas[r] * this._sigmas[r] - this._sigmas[r - 1] * this._sigmas[r - 1]), o = Fc[(r - 1) % Fc.length];
      this._blur(e, r - 1, r, a, o);
    }
    t.autoClear = i;
  }
  /**
   * This is a two-pass Gaussian blur for a cubemap. Normally this is done
   * vertically and horizontally, but this breaks down on a cube. Here we apply
   * the blur latitudinally (around the poles), and then longitudinally (towards
   * the poles) to approximate the orthogonally-separable blur. It is least
   * accurate at the poles, but still does a decent job.
   */
  _blur(e, t, i, r, a) {
    const o = this._pingPongRenderTarget;
    this._halfBlur(
      e,
      o,
      t,
      i,
      r,
      "latitudinal",
      a
    ), this._halfBlur(
      o,
      e,
      i,
      i,
      r,
      "longitudinal",
      a
    );
  }
  _halfBlur(e, t, i, r, a, o, s) {
    const c = this._renderer, l = this._blurMaterial;
    o !== "latitudinal" && o !== "longitudinal" && console.error(
      "blur direction must be either latitudinal or longitudinal!"
    );
    const u = 3, h = new Vt(this._lodPlanes[r], l), d = l.uniforms, p = this._sizeLods[i] - 1, g = isFinite(a) ? Math.PI / (2 * p) : 2 * Math.PI / (2 * ri - 1), v = a / g, m = isFinite(a) ? 1 + Math.floor(u * v) : ri;
    m > ri && console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ri}`);
    const f = [];
    let M = 0;
    for (let A = 0; A < ri; ++A) {
      const R = A / v, w = Math.exp(-R * R / 2);
      f.push(w), A === 0 ? M += w : A < m && (M += 2 * w);
    }
    for (let A = 0; A < f.length; A++)
      f[A] = f[A] / M;
    d.envMap.value = e.texture, d.samples.value = m, d.weights.value = f, d.latitudinal.value = o === "latitudinal", s && (d.poleAxis.value = s);
    const { _lodMax: _ } = this;
    d.dTheta.value = g, d.mipInt.value = _ - i;
    const x = this._sizeLods[r], T = 3 * x * (r > _ - Di ? r - _ + Di : 0), E = 4 * (this._cubeSize - x);
    $r(t, T, E, 3 * x, 2 * x), c.setRenderTarget(t), c.render(h, oo);
  }
}
function bg(n) {
  const e = [], t = [], i = [];
  let r = n;
  const a = n - Di + 1 + Nc.length;
  for (let o = 0; o < a; o++) {
    const s = Math.pow(2, r);
    t.push(s);
    let c = 1 / s;
    o > n - Di ? c = Nc[o - n + Di - 1] : o === 0 && (c = 0), i.push(c);
    const l = 1 / (s - 2), u = -l, h = 1 + l, d = [u, u, h, u, h, h, u, u, h, h, u, h], p = 6, g = 6, v = 3, m = 2, f = 1, M = new Float32Array(v * g * p), _ = new Float32Array(m * g * p), x = new Float32Array(f * g * p);
    for (let E = 0; E < p; E++) {
      const A = E % 3 * 2 / 3 - 1, R = E > 2 ? 0 : -1, w = [
        A,
        R,
        0,
        A + 2 / 3,
        R,
        0,
        A + 2 / 3,
        R + 1,
        0,
        A,
        R,
        0,
        A + 2 / 3,
        R + 1,
        0,
        A,
        R + 1,
        0
      ];
      M.set(w, v * g * E), _.set(d, m * g * E);
      const b = [E, E, E, E, E, E];
      x.set(b, f * g * E);
    }
    const T = new Nt();
    T.setAttribute("position", new Zt(M, v)), T.setAttribute("uv", new Zt(_, m)), T.setAttribute("faceIndex", new Zt(x, f)), e.push(T), r > Di && r--;
  }
  return { lodPlanes: e, sizeLods: t, sigmas: i };
}
function kc(n, e, t) {
  const i = new Vn(n, e, t);
  return i.texture.mapping = ya, i.texture.name = "PMREM.cubeUv", i.scissorTest = !0, i;
}
function $r(n, e, t, i, r) {
  n.viewport.set(e, t, i, r), n.scissor.set(e, t, i, r);
}
function Mg(n, e, t) {
  const i = new Float32Array(ri), r = new O(0, 1, 0);
  return new sn({
    name: "SphericalGaussianBlur",
    defines: {
      n: ri,
      CUBEUV_TEXEL_WIDTH: 1 / e,
      CUBEUV_TEXEL_HEIGHT: 1 / t,
      CUBEUV_MAX_MIP: `${n}.0`
    },
    uniforms: {
      envMap: { value: null },
      samples: { value: 1 },
      weights: { value: i },
      latitudinal: { value: !1 },
      dTheta: { value: 0 },
      mipInt: { value: 0 },
      poleAxis: { value: r }
    },
    vertexShader: ds(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`
    ),
    blending: En,
    depthTest: !1,
    depthWrite: !1
  });
}
function zc() {
  return new sn({
    name: "EquirectangularToCubeUV",
    uniforms: {
      envMap: { value: null }
    },
    vertexShader: ds(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`
    ),
    blending: En,
    depthTest: !1,
    depthWrite: !1
  });
}
function Hc() {
  return new sn({
    name: "CubemapToCubeUV",
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 }
    },
    vertexShader: ds(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`
    ),
    blending: En,
    depthTest: !1,
    depthWrite: !1
  });
}
function ds() {
  return (
    /* glsl */
    `

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`
  );
}
function Sg(n) {
  let e = /* @__PURE__ */ new WeakMap(), t = null;
  function i(s) {
    if (s && s.isTexture) {
      const c = s.mapping, l = c === Uo || c === Fo, u = c === Bi || c === ki;
      if (l || u) {
        let h = e.get(s);
        const d = h !== void 0 ? h.texture.pmremVersion : 0;
        if (s.isRenderTargetTexture && s.pmremVersion !== d)
          return t === null && (t = new Bc(n)), h = l ? t.fromEquirectangular(s, h) : t.fromCubemap(s, h), h.texture.pmremVersion = s.pmremVersion, e.set(s, h), h.texture;
        if (h !== void 0)
          return h.texture;
        {
          const p = s.image;
          return l && p && p.height > 0 || u && p && r(p) ? (t === null && (t = new Bc(n)), h = l ? t.fromEquirectangular(s) : t.fromCubemap(s), h.texture.pmremVersion = s.pmremVersion, e.set(s, h), s.addEventListener("dispose", a), h.texture) : null;
        }
      }
    }
    return s;
  }
  function r(s) {
    let c = 0;
    const l = 6;
    for (let u = 0; u < l; u++)
      s[u] !== void 0 && c++;
    return c === l;
  }
  function a(s) {
    const c = s.target;
    c.removeEventListener("dispose", a);
    const l = e.get(c);
    l !== void 0 && (e.delete(c), l.dispose());
  }
  function o() {
    e = /* @__PURE__ */ new WeakMap(), t !== null && (t.dispose(), t = null);
  }
  return {
    get: i,
    dispose: o
  };
}
function Eg(n) {
  const e = {};
  function t(i) {
    if (e[i] !== void 0)
      return e[i];
    let r;
    switch (i) {
      case "WEBGL_depth_texture":
        r = n.getExtension("WEBGL_depth_texture") || n.getExtension("MOZ_WEBGL_depth_texture") || n.getExtension("WEBKIT_WEBGL_depth_texture");
        break;
      case "EXT_texture_filter_anisotropic":
        r = n.getExtension("EXT_texture_filter_anisotropic") || n.getExtension("MOZ_EXT_texture_filter_anisotropic") || n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
        break;
      case "WEBGL_compressed_texture_s3tc":
        r = n.getExtension("WEBGL_compressed_texture_s3tc") || n.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
        break;
      case "WEBGL_compressed_texture_pvrtc":
        r = n.getExtension("WEBGL_compressed_texture_pvrtc") || n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
        break;
      default:
        r = n.getExtension(i);
    }
    return e[i] = r, r;
  }
  return {
    has: function(i) {
      return t(i) !== null;
    },
    init: function() {
      t("EXT_color_buffer_float"), t("WEBGL_clip_cull_distance"), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture"), t("WEBGL_render_shared_exponent");
    },
    get: function(i) {
      const r = t(i);
      return r === null && console.warn("THREE.WebGLRenderer: " + i + " extension not supported."), r;
    }
  };
}
function wg(n, e, t, i) {
  const r = {}, a = /* @__PURE__ */ new WeakMap();
  function o(h) {
    const d = h.target;
    d.index !== null && e.remove(d.index);
    for (const g in d.attributes)
      e.remove(d.attributes[g]);
    for (const g in d.morphAttributes) {
      const v = d.morphAttributes[g];
      for (let m = 0, f = v.length; m < f; m++)
        e.remove(v[m]);
    }
    d.removeEventListener("dispose", o), delete r[d.id];
    const p = a.get(d);
    p && (e.remove(p), a.delete(d)), i.releaseStatesOfGeometry(d), d.isInstancedBufferGeometry === !0 && delete d._maxInstanceCount, t.memory.geometries--;
  }
  function s(h, d) {
    return r[d.id] === !0 || (d.addEventListener("dispose", o), r[d.id] = !0, t.memory.geometries++), d;
  }
  function c(h) {
    const d = h.attributes;
    for (const g in d)
      e.update(d[g], n.ARRAY_BUFFER);
    const p = h.morphAttributes;
    for (const g in p) {
      const v = p[g];
      for (let m = 0, f = v.length; m < f; m++)
        e.update(v[m], n.ARRAY_BUFFER);
    }
  }
  function l(h) {
    const d = [], p = h.index, g = h.attributes.position;
    let v = 0;
    if (p !== null) {
      const M = p.array;
      v = p.version;
      for (let _ = 0, x = M.length; _ < x; _ += 3) {
        const T = M[_ + 0], E = M[_ + 1], A = M[_ + 2];
        d.push(T, E, E, A, A, T);
      }
    } else if (g !== void 0) {
      const M = g.array;
      v = g.version;
      for (let _ = 0, x = M.length / 3 - 1; _ < x; _ += 3) {
        const T = _ + 0, E = _ + 1, A = _ + 2;
        d.push(T, E, E, A, A, T);
      }
    } else
      return;
    const m = new (xu(d) ? wu : Eu)(d, 1);
    m.version = v;
    const f = a.get(h);
    f && e.remove(f), a.set(h, m);
  }
  function u(h) {
    const d = a.get(h);
    if (d) {
      const p = h.index;
      p !== null && d.version < p.version && l(h);
    } else
      l(h);
    return a.get(h);
  }
  return {
    get: s,
    update: c,
    getWireframeAttribute: u
  };
}
function Tg(n, e, t) {
  let i;
  function r(h) {
    i = h;
  }
  let a, o;
  function s(h) {
    a = h.type, o = h.bytesPerElement;
  }
  function c(h, d) {
    n.drawElements(i, d, a, h * o), t.update(d, i, 1);
  }
  function l(h, d, p) {
    p !== 0 && (n.drawElementsInstanced(i, d, a, h * o, p), t.update(d, i, p));
  }
  function u(h, d, p) {
    if (p === 0)
      return;
    const g = e.get("WEBGL_multi_draw");
    if (g === null)
      for (let v = 0; v < p; v++)
        this.render(h[v] / o, d[v]);
    else {
      g.multiDrawElementsWEBGL(i, d, 0, a, h, 0, p);
      let v = 0;
      for (let m = 0; m < p; m++)
        v += d[m];
      t.update(v, i, 1);
    }
  }
  this.setMode = r, this.setIndex = s, this.render = c, this.renderInstances = l, this.renderMultiDraw = u;
}
function Ag(n) {
  const e = {
    geometries: 0,
    textures: 0
  }, t = {
    frame: 0,
    calls: 0,
    triangles: 0,
    points: 0,
    lines: 0
  };
  function i(a, o, s) {
    switch (t.calls++, o) {
      case n.TRIANGLES:
        t.triangles += s * (a / 3);
        break;
      case n.LINES:
        t.lines += s * (a / 2);
        break;
      case n.LINE_STRIP:
        t.lines += s * (a - 1);
        break;
      case n.LINE_LOOP:
        t.lines += s * a;
        break;
      case n.POINTS:
        t.points += s * a;
        break;
      default:
        console.error("THREE.WebGLInfo: Unknown draw mode:", o);
        break;
    }
  }
  function r() {
    t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0;
  }
  return {
    memory: e,
    render: t,
    programs: null,
    autoReset: !0,
    reset: r,
    update: i
  };
}
function Cg(n, e, t) {
  const i = /* @__PURE__ */ new WeakMap(), r = new gt();
  function a(o, s, c) {
    const l = o.morphTargetInfluences, u = s.morphAttributes.position || s.morphAttributes.normal || s.morphAttributes.color, h = u !== void 0 ? u.length : 0;
    let d = i.get(s);
    if (d === void 0 || d.count !== h) {
      let w = function() {
        A.dispose(), i.delete(s), s.removeEventListener("dispose", w);
      };
      d !== void 0 && d.texture.dispose();
      const p = s.morphAttributes.position !== void 0, g = s.morphAttributes.normal !== void 0, v = s.morphAttributes.color !== void 0, m = s.morphAttributes.position || [], f = s.morphAttributes.normal || [], M = s.morphAttributes.color || [];
      let _ = 0;
      p === !0 && (_ = 1), g === !0 && (_ = 2), v === !0 && (_ = 3);
      let x = s.attributes.position.count * _, T = 1;
      x > e.maxTextureSize && (T = Math.ceil(x / e.maxTextureSize), x = e.maxTextureSize);
      const E = new Float32Array(x * T * 4 * h), A = new Mu(E, x, T, h);
      A.type = Bn, A.needsUpdate = !0;
      const R = _ * 4;
      for (let b = 0; b < h; b++) {
        const U = m[b], z = f[b], I = M[b], L = x * T * 4 * b;
        for (let D = 0; D < U.count; D++) {
          const B = D * R;
          p === !0 && (r.fromBufferAttribute(U, D), E[L + B + 0] = r.x, E[L + B + 1] = r.y, E[L + B + 2] = r.z, E[L + B + 3] = 0), g === !0 && (r.fromBufferAttribute(z, D), E[L + B + 4] = r.x, E[L + B + 5] = r.y, E[L + B + 6] = r.z, E[L + B + 7] = 0), v === !0 && (r.fromBufferAttribute(I, D), E[L + B + 8] = r.x, E[L + B + 9] = r.y, E[L + B + 10] = r.z, E[L + B + 11] = I.itemSize === 4 ? r.w : 1);
        }
      }
      d = {
        count: h,
        texture: A,
        size: new le(x, T)
      }, i.set(s, d), s.addEventListener("dispose", w);
    }
    if (o.isInstancedMesh === !0 && o.morphTexture !== null)
      c.getUniforms().setValue(n, "morphTexture", o.morphTexture, t);
    else {
      let p = 0;
      for (let v = 0; v < l.length; v++)
        p += l[v];
      const g = s.morphTargetsRelative ? 1 : 1 - p;
      c.getUniforms().setValue(n, "morphTargetBaseInfluence", g), c.getUniforms().setValue(n, "morphTargetInfluences", l);
    }
    c.getUniforms().setValue(n, "morphTargetsTexture", d.texture, t), c.getUniforms().setValue(n, "morphTargetsTextureSize", d.size);
  }
  return {
    update: a
  };
}
function Rg(n, e, t, i) {
  let r = /* @__PURE__ */ new WeakMap();
  function a(c) {
    const l = i.render.frame, u = c.geometry, h = e.get(c, u);
    if (r.get(h) !== l && (e.update(h), r.set(h, l)), c.isInstancedMesh && (c.hasEventListener("dispose", s) === !1 && c.addEventListener("dispose", s), r.get(c) !== l && (t.update(c.instanceMatrix, n.ARRAY_BUFFER), c.instanceColor !== null && t.update(c.instanceColor, n.ARRAY_BUFFER), r.set(c, l))), c.isSkinnedMesh) {
      const d = c.skeleton;
      r.get(d) !== l && (d.update(), r.set(d, l));
    }
    return h;
  }
  function o() {
    r = /* @__PURE__ */ new WeakMap();
  }
  function s(c) {
    const l = c.target;
    l.removeEventListener("dispose", s), t.remove(l.instanceMatrix), l.instanceColor !== null && t.remove(l.instanceColor);
  }
  return {
    update: a,
    dispose: o
  };
}
class Lu extends Tt {
  constructor(e, t, i, r, a, o, s, c, l, u) {
    if (u = u !== void 0 ? u : Ui, u !== Ui && u !== mr)
      throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
    i === void 0 && u === Ui && (i = zi), i === void 0 && u === mr && (i = br), super(null, r, a, o, s, c, u, i, l), this.isDepthTexture = !0, this.image = { width: e, height: t }, this.magFilter = s !== void 0 ? s : Ht, this.minFilter = c !== void 0 ? c : Ht, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
  }
  copy(e) {
    return super.copy(e), this.compareFunction = e.compareFunction, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return this.compareFunction !== null && (t.compareFunction = this.compareFunction), t;
  }
}
const Du = /* @__PURE__ */ new Tt(), Ou = /* @__PURE__ */ new Lu(1, 1);
Ou.compareFunction = yu;
const Iu = /* @__PURE__ */ new Mu(), Nu = /* @__PURE__ */ new md(), Uu = /* @__PURE__ */ new Ru(), Vc = [], Gc = [], Wc = new Float32Array(16), jc = new Float32Array(9), Xc = new Float32Array(4);
function ji(n, e, t) {
  const i = n[0];
  if (i <= 0 || i > 0)
    return n;
  const r = e * t;
  let a = Vc[r];
  if (a === void 0 && (a = new Float32Array(r), Vc[r] = a), e !== 0) {
    i.toArray(a, 0);
    for (let o = 1, s = 0; o !== e; ++o)
      s += t, n[o].toArray(a, s);
  }
  return a;
}
function ut(n, e) {
  if (n.length !== e.length)
    return !1;
  for (let t = 0, i = n.length; t < i; t++)
    if (n[t] !== e[t])
      return !1;
  return !0;
}
function ht(n, e) {
  for (let t = 0, i = e.length; t < i; t++)
    n[t] = e[t];
}
function Ea(n, e) {
  let t = Gc[e];
  t === void 0 && (t = new Int32Array(e), Gc[e] = t);
  for (let i = 0; i !== e; ++i)
    t[i] = n.allocateTextureUnit();
  return t;
}
function Pg(n, e) {
  const t = this.cache;
  t[0] !== e && (n.uniform1f(this.addr, e), t[0] = e);
}
function Lg(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (n.uniform2f(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (ut(t, e))
      return;
    n.uniform2fv(this.addr, e), ht(t, e);
  }
}
function Dg(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (n.uniform3f(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else if (e.r !== void 0)
    (t[0] !== e.r || t[1] !== e.g || t[2] !== e.b) && (n.uniform3f(this.addr, e.r, e.g, e.b), t[0] = e.r, t[1] = e.g, t[2] = e.b);
  else {
    if (ut(t, e))
      return;
    n.uniform3fv(this.addr, e), ht(t, e);
  }
}
function Og(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (n.uniform4f(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (ut(t, e))
      return;
    n.uniform4fv(this.addr, e), ht(t, e);
  }
}
function Ig(n, e) {
  const t = this.cache, i = e.elements;
  if (i === void 0) {
    if (ut(t, e))
      return;
    n.uniformMatrix2fv(this.addr, !1, e), ht(t, e);
  } else {
    if (ut(t, i))
      return;
    Xc.set(i), n.uniformMatrix2fv(this.addr, !1, Xc), ht(t, i);
  }
}
function Ng(n, e) {
  const t = this.cache, i = e.elements;
  if (i === void 0) {
    if (ut(t, e))
      return;
    n.uniformMatrix3fv(this.addr, !1, e), ht(t, e);
  } else {
    if (ut(t, i))
      return;
    jc.set(i), n.uniformMatrix3fv(this.addr, !1, jc), ht(t, i);
  }
}
function Ug(n, e) {
  const t = this.cache, i = e.elements;
  if (i === void 0) {
    if (ut(t, e))
      return;
    n.uniformMatrix4fv(this.addr, !1, e), ht(t, e);
  } else {
    if (ut(t, i))
      return;
    Wc.set(i), n.uniformMatrix4fv(this.addr, !1, Wc), ht(t, i);
  }
}
function Fg(n, e) {
  const t = this.cache;
  t[0] !== e && (n.uniform1i(this.addr, e), t[0] = e);
}
function Bg(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (n.uniform2i(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (ut(t, e))
      return;
    n.uniform2iv(this.addr, e), ht(t, e);
  }
}
function kg(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (n.uniform3i(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else {
    if (ut(t, e))
      return;
    n.uniform3iv(this.addr, e), ht(t, e);
  }
}
function zg(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (n.uniform4i(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (ut(t, e))
      return;
    n.uniform4iv(this.addr, e), ht(t, e);
  }
}
function Hg(n, e) {
  const t = this.cache;
  t[0] !== e && (n.uniform1ui(this.addr, e), t[0] = e);
}
function Vg(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (n.uniform2ui(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (ut(t, e))
      return;
    n.uniform2uiv(this.addr, e), ht(t, e);
  }
}
function Gg(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (n.uniform3ui(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else {
    if (ut(t, e))
      return;
    n.uniform3uiv(this.addr, e), ht(t, e);
  }
}
function Wg(n, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (n.uniform4ui(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (ut(t, e))
      return;
    n.uniform4uiv(this.addr, e), ht(t, e);
  }
}
function jg(n, e, t) {
  const i = this.cache, r = t.allocateTextureUnit();
  i[0] !== r && (n.uniform1i(this.addr, r), i[0] = r);
  const a = this.type === n.SAMPLER_2D_SHADOW ? Ou : Du;
  t.setTexture2D(e || a, r);
}
function Xg(n, e, t) {
  const i = this.cache, r = t.allocateTextureUnit();
  i[0] !== r && (n.uniform1i(this.addr, r), i[0] = r), t.setTexture3D(e || Nu, r);
}
function $g(n, e, t) {
  const i = this.cache, r = t.allocateTextureUnit();
  i[0] !== r && (n.uniform1i(this.addr, r), i[0] = r), t.setTextureCube(e || Uu, r);
}
function qg(n, e, t) {
  const i = this.cache, r = t.allocateTextureUnit();
  i[0] !== r && (n.uniform1i(this.addr, r), i[0] = r), t.setTexture2DArray(e || Iu, r);
}
function Yg(n) {
  switch (n) {
    case 5126:
      return Pg;
    case 35664:
      return Lg;
    case 35665:
      return Dg;
    case 35666:
      return Og;
    case 35674:
      return Ig;
    case 35675:
      return Ng;
    case 35676:
      return Ug;
    case 5124:
    case 35670:
      return Fg;
    case 35667:
    case 35671:
      return Bg;
    case 35668:
    case 35672:
      return kg;
    case 35669:
    case 35673:
      return zg;
    case 5125:
      return Hg;
    case 36294:
      return Vg;
    case 36295:
      return Gg;
    case 36296:
      return Wg;
    case 35678:
    case 36198:
    case 36298:
    case 36306:
    case 35682:
      return jg;
    case 35679:
    case 36299:
    case 36307:
      return Xg;
    case 35680:
    case 36300:
    case 36308:
    case 36293:
      return $g;
    case 36289:
    case 36303:
    case 36311:
    case 36292:
      return qg;
  }
}
function Kg(n, e) {
  n.uniform1fv(this.addr, e);
}
function Zg(n, e) {
  const t = ji(e, this.size, 2);
  n.uniform2fv(this.addr, t);
}
function Jg(n, e) {
  const t = ji(e, this.size, 3);
  n.uniform3fv(this.addr, t);
}
function Qg(n, e) {
  const t = ji(e, this.size, 4);
  n.uniform4fv(this.addr, t);
}
function ev(n, e) {
  const t = ji(e, this.size, 4);
  n.uniformMatrix2fv(this.addr, !1, t);
}
function tv(n, e) {
  const t = ji(e, this.size, 9);
  n.uniformMatrix3fv(this.addr, !1, t);
}
function nv(n, e) {
  const t = ji(e, this.size, 16);
  n.uniformMatrix4fv(this.addr, !1, t);
}
function iv(n, e) {
  n.uniform1iv(this.addr, e);
}
function rv(n, e) {
  n.uniform2iv(this.addr, e);
}
function av(n, e) {
  n.uniform3iv(this.addr, e);
}
function ov(n, e) {
  n.uniform4iv(this.addr, e);
}
function sv(n, e) {
  n.uniform1uiv(this.addr, e);
}
function cv(n, e) {
  n.uniform2uiv(this.addr, e);
}
function lv(n, e) {
  n.uniform3uiv(this.addr, e);
}
function uv(n, e) {
  n.uniform4uiv(this.addr, e);
}
function hv(n, e, t) {
  const i = this.cache, r = e.length, a = Ea(t, r);
  ut(i, a) || (n.uniform1iv(this.addr, a), ht(i, a));
  for (let o = 0; o !== r; ++o)
    t.setTexture2D(e[o] || Du, a[o]);
}
function fv(n, e, t) {
  const i = this.cache, r = e.length, a = Ea(t, r);
  ut(i, a) || (n.uniform1iv(this.addr, a), ht(i, a));
  for (let o = 0; o !== r; ++o)
    t.setTexture3D(e[o] || Nu, a[o]);
}
function dv(n, e, t) {
  const i = this.cache, r = e.length, a = Ea(t, r);
  ut(i, a) || (n.uniform1iv(this.addr, a), ht(i, a));
  for (let o = 0; o !== r; ++o)
    t.setTextureCube(e[o] || Uu, a[o]);
}
function pv(n, e, t) {
  const i = this.cache, r = e.length, a = Ea(t, r);
  ut(i, a) || (n.uniform1iv(this.addr, a), ht(i, a));
  for (let o = 0; o !== r; ++o)
    t.setTexture2DArray(e[o] || Iu, a[o]);
}
function mv(n) {
  switch (n) {
    case 5126:
      return Kg;
    case 35664:
      return Zg;
    case 35665:
      return Jg;
    case 35666:
      return Qg;
    case 35674:
      return ev;
    case 35675:
      return tv;
    case 35676:
      return nv;
    case 5124:
    case 35670:
      return iv;
    case 35667:
    case 35671:
      return rv;
    case 35668:
    case 35672:
      return av;
    case 35669:
    case 35673:
      return ov;
    case 5125:
      return sv;
    case 36294:
      return cv;
    case 36295:
      return lv;
    case 36296:
      return uv;
    case 35678:
    case 36198:
    case 36298:
    case 36306:
    case 35682:
      return hv;
    case 35679:
    case 36299:
    case 36307:
      return fv;
    case 35680:
    case 36300:
    case 36308:
    case 36293:
      return dv;
    case 36289:
    case 36303:
    case 36311:
    case 36292:
      return pv;
  }
}
class gv {
  constructor(e, t, i) {
    this.id = e, this.addr = i, this.cache = [], this.type = t.type, this.setValue = Yg(t.type);
  }
}
class vv {
  constructor(e, t, i) {
    this.id = e, this.addr = i, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = mv(t.type);
  }
}
class _v {
  constructor(e) {
    this.id = e, this.seq = [], this.map = {};
  }
  setValue(e, t, i) {
    const r = this.seq;
    for (let a = 0, o = r.length; a !== o; ++a) {
      const s = r[a];
      s.setValue(e, t[s.id], i);
    }
  }
}
const ho = /(\w+)(\])?(\[|\.)?/g;
function $c(n, e) {
  n.seq.push(e), n.map[e.id] = e;
}
function yv(n, e, t) {
  const i = n.name, r = i.length;
  for (ho.lastIndex = 0; ; ) {
    const a = ho.exec(i), o = ho.lastIndex;
    let s = a[1];
    const c = a[2] === "]", l = a[3];
    if (c && (s = s | 0), l === void 0 || l === "[" && o + 2 === r) {
      $c(t, l === void 0 ? new gv(s, n, e) : new vv(s, n, e));
      break;
    } else {
      let h = t.map[s];
      h === void 0 && (h = new _v(s), $c(t, h)), t = h;
    }
  }
}
class na {
  constructor(e, t) {
    this.seq = [], this.map = {};
    const i = e.getProgramParameter(t, e.ACTIVE_UNIFORMS);
    for (let r = 0; r < i; ++r) {
      const a = e.getActiveUniform(t, r), o = e.getUniformLocation(t, a.name);
      yv(a, o, this);
    }
  }
  setValue(e, t, i, r) {
    const a = this.map[t];
    a !== void 0 && a.setValue(e, i, r);
  }
  setOptional(e, t, i) {
    const r = t[i];
    r !== void 0 && this.setValue(e, i, r);
  }
  static upload(e, t, i, r) {
    for (let a = 0, o = t.length; a !== o; ++a) {
      const s = t[a], c = i[s.id];
      c.needsUpdate !== !1 && s.setValue(e, c.value, r);
    }
  }
  static seqWithValue(e, t) {
    const i = [];
    for (let r = 0, a = e.length; r !== a; ++r) {
      const o = e[r];
      o.id in t && i.push(o);
    }
    return i;
  }
}
function qc(n, e, t) {
  const i = n.createShader(e);
  return n.shaderSource(i, t), n.compileShader(i), i;
}
const xv = 37297;
let bv = 0;
function Mv(n, e) {
  const t = n.split(`
`), i = [], r = Math.max(e - 6, 0), a = Math.min(e + 6, t.length);
  for (let o = r; o < a; o++) {
    const s = o + 1;
    i.push(`${s === e ? ">" : " "} ${s}: ${t[o]}`);
  }
  return i.join(`
`);
}
function Sv(n) {
  const e = Ke.getPrimaries(Ke.workingColorSpace), t = Ke.getPrimaries(n);
  let i;
  switch (e === t ? i = "" : e === ca && t === sa ? i = "LinearDisplayP3ToLinearSRGB" : e === sa && t === ca && (i = "LinearSRGBToLinearDisplayP3"), n) {
    case Gn:
    case xa:
      return [i, "LinearTransferOETF"];
    case $t:
    case ss:
      return [i, "sRGBTransferOETF"];
    default:
      return console.warn("THREE.WebGLProgram: Unsupported color space:", n), [i, "LinearTransferOETF"];
  }
}
function Yc(n, e, t) {
  const i = n.getShaderParameter(e, n.COMPILE_STATUS), r = n.getShaderInfoLog(e).trim();
  if (i && r === "")
    return "";
  const a = /ERROR: 0:(\d+)/.exec(r);
  if (a) {
    const o = parseInt(a[1]);
    return t.toUpperCase() + `

` + r + `

` + Mv(n.getShaderSource(e), o);
  } else
    return r;
}
function Ev(n, e) {
  const t = Sv(e);
  return `vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`;
}
function wv(n, e) {
  let t;
  switch (e) {
    case _f:
      t = "Linear";
      break;
    case yf:
      t = "Reinhard";
      break;
    case xf:
      t = "OptimizedCineon";
      break;
    case bf:
      t = "ACESFilmic";
      break;
    case Sf:
      t = "AgX";
      break;
    case Ef:
      t = "Neutral";
      break;
    case Mf:
      t = "Custom";
      break;
    default:
      console.warn("THREE.WebGLProgram: Unsupported toneMapping:", e), t = "Linear";
  }
  return "vec3 " + n + "( vec3 color ) { return " + t + "ToneMapping( color ); }";
}
function Tv(n) {
  return [
    n.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "",
    n.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""
  ].filter(ar).join(`
`);
}
function Av(n) {
  const e = [];
  for (const t in n) {
    const i = n[t];
    i !== !1 && e.push("#define " + t + " " + i);
  }
  return e.join(`
`);
}
function Cv(n, e) {
  const t = {}, i = n.getProgramParameter(e, n.ACTIVE_ATTRIBUTES);
  for (let r = 0; r < i; r++) {
    const a = n.getActiveAttrib(e, r), o = a.name;
    let s = 1;
    a.type === n.FLOAT_MAT2 && (s = 2), a.type === n.FLOAT_MAT3 && (s = 3), a.type === n.FLOAT_MAT4 && (s = 4), t[o] = {
      type: a.type,
      location: n.getAttribLocation(e, o),
      locationSize: s
    };
  }
  return t;
}
function ar(n) {
  return n !== "";
}
function Kc(n, e) {
  const t = e.numSpotLightShadows + e.numSpotLightMaps - e.numSpotLightShadowsWithMaps;
  return n.replace(/NUM_DIR_LIGHTS/g, e.numDirLights).replace(/NUM_SPOT_LIGHTS/g, e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, t).replace(/NUM_RECT_AREA_LIGHTS/g, e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, e.numPointLights).replace(/NUM_HEMI_LIGHTS/g, e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, e.numPointLightShadows);
}
function Zc(n, e) {
  return n.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection);
}
const Rv = /^[ \t]*#include +<([\w\d./]+)>/gm;
function Ho(n) {
  return n.replace(Rv, Lv);
}
const Pv = /* @__PURE__ */ new Map([
  ["encodings_fragment", "colorspace_fragment"],
  // @deprecated, r154
  ["encodings_pars_fragment", "colorspace_pars_fragment"],
  // @deprecated, r154
  ["output_fragment", "opaque_fragment"]
  // @deprecated, r154
]);
function Lv(n, e) {
  let t = Ue[e];
  if (t === void 0) {
    const i = Pv.get(e);
    if (i !== void 0)
      t = Ue[i], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', e, i);
    else
      throw new Error("Can not resolve #include <" + e + ">");
  }
  return Ho(t);
}
const Dv = /#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;
function Jc(n) {
  return n.replace(Dv, Ov);
}
function Ov(n, e, t, i) {
  let r = "";
  for (let a = parseInt(e); a < parseInt(t); a++)
    r += i.replace(/\[\s*i\s*\]/g, "[ " + a + " ]").replace(/UNROLLED_LOOP_INDEX/g, a);
  return r;
}
function Qc(n) {
  let e = `precision ${n.precision} float;
	precision ${n.precision} int;
	precision ${n.precision} sampler2D;
	precision ${n.precision} samplerCube;
	precision ${n.precision} sampler3D;
	precision ${n.precision} sampler2DArray;
	precision ${n.precision} sampler2DShadow;
	precision ${n.precision} samplerCubeShadow;
	precision ${n.precision} sampler2DArrayShadow;
	precision ${n.precision} isampler2D;
	precision ${n.precision} isampler3D;
	precision ${n.precision} isamplerCube;
	precision ${n.precision} isampler2DArray;
	precision ${n.precision} usampler2D;
	precision ${n.precision} usampler3D;
	precision ${n.precision} usamplerCube;
	precision ${n.precision} usampler2DArray;
	`;
  return n.precision === "highp" ? e += `
#define HIGH_PRECISION` : n.precision === "mediump" ? e += `
#define MEDIUM_PRECISION` : n.precision === "lowp" && (e += `
#define LOW_PRECISION`), e;
}
function Iv(n) {
  let e = "SHADOWMAP_TYPE_BASIC";
  return n.shadowMapType === cu ? e = "SHADOWMAP_TYPE_PCF" : n.shadowMapType === Gh ? e = "SHADOWMAP_TYPE_PCF_SOFT" : n.shadowMapType === _n && (e = "SHADOWMAP_TYPE_VSM"), e;
}
function Nv(n) {
  let e = "ENVMAP_TYPE_CUBE";
  if (n.envMap)
    switch (n.envMapMode) {
      case Bi:
      case ki:
        e = "ENVMAP_TYPE_CUBE";
        break;
      case ya:
        e = "ENVMAP_TYPE_CUBE_UV";
        break;
    }
  return e;
}
function Uv(n) {
  let e = "ENVMAP_MODE_REFLECTION";
  if (n.envMap)
    switch (n.envMapMode) {
      case ki:
        e = "ENVMAP_MODE_REFRACTION";
        break;
    }
  return e;
}
function Fv(n) {
  let e = "ENVMAP_BLENDING_NONE";
  if (n.envMap)
    switch (n.combine) {
      case os:
        e = "ENVMAP_BLENDING_MULTIPLY";
        break;
      case gf:
        e = "ENVMAP_BLENDING_MIX";
        break;
      case vf:
        e = "ENVMAP_BLENDING_ADD";
        break;
    }
  return e;
}
function Bv(n) {
  const e = n.envMapCubeUVHeight;
  if (e === null)
    return null;
  const t = Math.log2(e) - 2, i = 1 / e;
  return { texelWidth: 1 / (3 * Math.max(Math.pow(2, t), 7 * 16)), texelHeight: i, maxMip: t };
}
function kv(n, e, t, i) {
  const r = n.getContext(), a = t.defines;
  let o = t.vertexShader, s = t.fragmentShader;
  const c = Iv(t), l = Nv(t), u = Uv(t), h = Fv(t), d = Bv(t), p = Tv(t), g = Av(a), v = r.createProgram();
  let m, f, M = t.glslVersion ? "#version " + t.glslVersion + `
` : "";
  t.isRawShaderMaterial ? (m = [
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    g
  ].filter(ar).join(`
`), m.length > 0 && (m += `
`), f = [
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    g
  ].filter(ar).join(`
`), f.length > 0 && (f += `
`)) : (m = [
    Qc(t),
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    g,
    t.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "",
    t.batching ? "#define USE_BATCHING" : "",
    t.instancing ? "#define USE_INSTANCING" : "",
    t.instancingColor ? "#define USE_INSTANCING_COLOR" : "",
    t.instancingMorph ? "#define USE_INSTANCING_MORPH" : "",
    t.useFog && t.fog ? "#define USE_FOG" : "",
    t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "",
    t.map ? "#define USE_MAP" : "",
    t.envMap ? "#define USE_ENVMAP" : "",
    t.envMap ? "#define " + u : "",
    t.lightMap ? "#define USE_LIGHTMAP" : "",
    t.aoMap ? "#define USE_AOMAP" : "",
    t.bumpMap ? "#define USE_BUMPMAP" : "",
    t.normalMap ? "#define USE_NORMALMAP" : "",
    t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    t.displacementMap ? "#define USE_DISPLACEMENTMAP" : "",
    t.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    t.anisotropy ? "#define USE_ANISOTROPY" : "",
    t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    t.specularMap ? "#define USE_SPECULARMAP" : "",
    t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    t.metalnessMap ? "#define USE_METALNESSMAP" : "",
    t.alphaMap ? "#define USE_ALPHAMAP" : "",
    t.alphaHash ? "#define USE_ALPHAHASH" : "",
    t.transmission ? "#define USE_TRANSMISSION" : "",
    t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    t.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    //
    t.mapUv ? "#define MAP_UV " + t.mapUv : "",
    t.alphaMapUv ? "#define ALPHAMAP_UV " + t.alphaMapUv : "",
    t.lightMapUv ? "#define LIGHTMAP_UV " + t.lightMapUv : "",
    t.aoMapUv ? "#define AOMAP_UV " + t.aoMapUv : "",
    t.emissiveMapUv ? "#define EMISSIVEMAP_UV " + t.emissiveMapUv : "",
    t.bumpMapUv ? "#define BUMPMAP_UV " + t.bumpMapUv : "",
    t.normalMapUv ? "#define NORMALMAP_UV " + t.normalMapUv : "",
    t.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + t.displacementMapUv : "",
    t.metalnessMapUv ? "#define METALNESSMAP_UV " + t.metalnessMapUv : "",
    t.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + t.roughnessMapUv : "",
    t.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + t.anisotropyMapUv : "",
    t.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + t.clearcoatMapUv : "",
    t.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + t.clearcoatNormalMapUv : "",
    t.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + t.clearcoatRoughnessMapUv : "",
    t.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + t.iridescenceMapUv : "",
    t.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + t.iridescenceThicknessMapUv : "",
    t.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + t.sheenColorMapUv : "",
    t.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + t.sheenRoughnessMapUv : "",
    t.specularMapUv ? "#define SPECULARMAP_UV " + t.specularMapUv : "",
    t.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + t.specularColorMapUv : "",
    t.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + t.specularIntensityMapUv : "",
    t.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + t.transmissionMapUv : "",
    t.thicknessMapUv ? "#define THICKNESSMAP_UV " + t.thicknessMapUv : "",
    //
    t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "",
    t.vertexColors ? "#define USE_COLOR" : "",
    t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    t.vertexUv1s ? "#define USE_UV1" : "",
    t.vertexUv2s ? "#define USE_UV2" : "",
    t.vertexUv3s ? "#define USE_UV3" : "",
    t.pointsUvs ? "#define USE_POINTS_UV" : "",
    t.flatShading ? "#define FLAT_SHADED" : "",
    t.skinning ? "#define USE_SKINNING" : "",
    t.morphTargets ? "#define USE_MORPHTARGETS" : "",
    t.morphNormals && t.flatShading === !1 ? "#define USE_MORPHNORMALS" : "",
    t.morphColors ? "#define USE_MORPHCOLORS" : "",
    t.morphTargetsCount > 0 ? "#define MORPHTARGETS_TEXTURE" : "",
    t.morphTargetsCount > 0 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + t.morphTextureStride : "",
    t.morphTargetsCount > 0 ? "#define MORPHTARGETS_COUNT " + t.morphTargetsCount : "",
    t.doubleSided ? "#define DOUBLE_SIDED" : "",
    t.flipSided ? "#define FLIP_SIDED" : "",
    t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    t.shadowMapEnabled ? "#define " + c : "",
    t.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",
    t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    t.useLegacyLights ? "#define LEGACY_LIGHTS" : "",
    t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    "uniform mat4 modelMatrix;",
    "uniform mat4 modelViewMatrix;",
    "uniform mat4 projectionMatrix;",
    "uniform mat4 viewMatrix;",
    "uniform mat3 normalMatrix;",
    "uniform vec3 cameraPosition;",
    "uniform bool isOrthographic;",
    "#ifdef USE_INSTANCING",
    "	attribute mat4 instanceMatrix;",
    "#endif",
    "#ifdef USE_INSTANCING_COLOR",
    "	attribute vec3 instanceColor;",
    "#endif",
    "#ifdef USE_INSTANCING_MORPH",
    "	uniform sampler2D morphTexture;",
    "#endif",
    "attribute vec3 position;",
    "attribute vec3 normal;",
    "attribute vec2 uv;",
    "#ifdef USE_UV1",
    "	attribute vec2 uv1;",
    "#endif",
    "#ifdef USE_UV2",
    "	attribute vec2 uv2;",
    "#endif",
    "#ifdef USE_UV3",
    "	attribute vec2 uv3;",
    "#endif",
    "#ifdef USE_TANGENT",
    "	attribute vec4 tangent;",
    "#endif",
    "#if defined( USE_COLOR_ALPHA )",
    "	attribute vec4 color;",
    "#elif defined( USE_COLOR )",
    "	attribute vec3 color;",
    "#endif",
    "#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )",
    "	attribute vec3 morphTarget0;",
    "	attribute vec3 morphTarget1;",
    "	attribute vec3 morphTarget2;",
    "	attribute vec3 morphTarget3;",
    "	#ifdef USE_MORPHNORMALS",
    "		attribute vec3 morphNormal0;",
    "		attribute vec3 morphNormal1;",
    "		attribute vec3 morphNormal2;",
    "		attribute vec3 morphNormal3;",
    "	#else",
    "		attribute vec3 morphTarget4;",
    "		attribute vec3 morphTarget5;",
    "		attribute vec3 morphTarget6;",
    "		attribute vec3 morphTarget7;",
    "	#endif",
    "#endif",
    "#ifdef USE_SKINNING",
    "	attribute vec4 skinIndex;",
    "	attribute vec4 skinWeight;",
    "#endif",
    `
`
  ].filter(ar).join(`
`), f = [
    Qc(t),
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    g,
    t.useFog && t.fog ? "#define USE_FOG" : "",
    t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "",
    t.alphaToCoverage ? "#define ALPHA_TO_COVERAGE" : "",
    t.map ? "#define USE_MAP" : "",
    t.matcap ? "#define USE_MATCAP" : "",
    t.envMap ? "#define USE_ENVMAP" : "",
    t.envMap ? "#define " + l : "",
    t.envMap ? "#define " + u : "",
    t.envMap ? "#define " + h : "",
    d ? "#define CUBEUV_TEXEL_WIDTH " + d.texelWidth : "",
    d ? "#define CUBEUV_TEXEL_HEIGHT " + d.texelHeight : "",
    d ? "#define CUBEUV_MAX_MIP " + d.maxMip + ".0" : "",
    t.lightMap ? "#define USE_LIGHTMAP" : "",
    t.aoMap ? "#define USE_AOMAP" : "",
    t.bumpMap ? "#define USE_BUMPMAP" : "",
    t.normalMap ? "#define USE_NORMALMAP" : "",
    t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    t.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    t.anisotropy ? "#define USE_ANISOTROPY" : "",
    t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    t.clearcoat ? "#define USE_CLEARCOAT" : "",
    t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    t.iridescence ? "#define USE_IRIDESCENCE" : "",
    t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    t.specularMap ? "#define USE_SPECULARMAP" : "",
    t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    t.metalnessMap ? "#define USE_METALNESSMAP" : "",
    t.alphaMap ? "#define USE_ALPHAMAP" : "",
    t.alphaTest ? "#define USE_ALPHATEST" : "",
    t.alphaHash ? "#define USE_ALPHAHASH" : "",
    t.sheen ? "#define USE_SHEEN" : "",
    t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    t.transmission ? "#define USE_TRANSMISSION" : "",
    t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    t.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "",
    t.vertexColors || t.instancingColor ? "#define USE_COLOR" : "",
    t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    t.vertexUv1s ? "#define USE_UV1" : "",
    t.vertexUv2s ? "#define USE_UV2" : "",
    t.vertexUv3s ? "#define USE_UV3" : "",
    t.pointsUvs ? "#define USE_POINTS_UV" : "",
    t.gradientMap ? "#define USE_GRADIENTMAP" : "",
    t.flatShading ? "#define FLAT_SHADED" : "",
    t.doubleSided ? "#define DOUBLE_SIDED" : "",
    t.flipSided ? "#define FLIP_SIDED" : "",
    t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    t.shadowMapEnabled ? "#define " + c : "",
    t.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
    t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    t.useLegacyLights ? "#define LEGACY_LIGHTS" : "",
    t.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
    t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    "uniform mat4 viewMatrix;",
    "uniform vec3 cameraPosition;",
    "uniform bool isOrthographic;",
    t.toneMapping !== kn ? "#define TONE_MAPPING" : "",
    t.toneMapping !== kn ? Ue.tonemapping_pars_fragment : "",
    // this code is required here because it is used by the toneMapping() function defined below
    t.toneMapping !== kn ? wv("toneMapping", t.toneMapping) : "",
    t.dithering ? "#define DITHERING" : "",
    t.opaque ? "#define OPAQUE" : "",
    Ue.colorspace_pars_fragment,
    // this code is required here because it is used by the various encoding/decoding function defined below
    Ev("linearToOutputTexel", t.outputColorSpace),
    t.useDepthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "",
    `
`
  ].filter(ar).join(`
`)), o = Ho(o), o = Kc(o, t), o = Zc(o, t), s = Ho(s), s = Kc(s, t), s = Zc(s, t), o = Jc(o), s = Jc(s), t.isRawShaderMaterial !== !0 && (M = `#version 300 es
`, m = [
    p,
    "#define attribute in",
    "#define varying out",
    "#define texture2D texture"
  ].join(`
`) + `
` + m, f = [
    "#define varying in",
    t.glslVersion === pc ? "" : "layout(location = 0) out highp vec4 pc_fragColor;",
    t.glslVersion === pc ? "" : "#define gl_FragColor pc_fragColor",
    "#define gl_FragDepthEXT gl_FragDepth",
    "#define texture2D texture",
    "#define textureCube texture",
    "#define texture2DProj textureProj",
    "#define texture2DLodEXT textureLod",
    "#define texture2DProjLodEXT textureProjLod",
    "#define textureCubeLodEXT textureLod",
    "#define texture2DGradEXT textureGrad",
    "#define texture2DProjGradEXT textureProjGrad",
    "#define textureCubeGradEXT textureGrad"
  ].join(`
`) + `
` + f);
  const _ = M + m + o, x = M + f + s, T = qc(r, r.VERTEX_SHADER, _), E = qc(r, r.FRAGMENT_SHADER, x);
  r.attachShader(v, T), r.attachShader(v, E), t.index0AttributeName !== void 0 ? r.bindAttribLocation(v, 0, t.index0AttributeName) : t.morphTargets === !0 && r.bindAttribLocation(v, 0, "position"), r.linkProgram(v);
  function A(U) {
    if (n.debug.checkShaderErrors) {
      const z = r.getProgramInfoLog(v).trim(), I = r.getShaderInfoLog(T).trim(), L = r.getShaderInfoLog(E).trim();
      let D = !0, B = !0;
      if (r.getProgramParameter(v, r.LINK_STATUS) === !1)
        if (D = !1, typeof n.debug.onShaderError == "function")
          n.debug.onShaderError(r, v, T, E);
        else {
          const te = Yc(r, T, "vertex"), W = Yc(r, E, "fragment");
          console.error(
            "THREE.WebGLProgram: Shader Error " + r.getError() + " - VALIDATE_STATUS " + r.getProgramParameter(v, r.VALIDATE_STATUS) + `

Material Name: ` + U.name + `
Material Type: ` + U.type + `

Program Info Log: ` + z + `
` + te + `
` + W
          );
        }
      else
        z !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", z) : (I === "" || L === "") && (B = !1);
      B && (U.diagnostics = {
        runnable: D,
        programLog: z,
        vertexShader: {
          log: I,
          prefix: m
        },
        fragmentShader: {
          log: L,
          prefix: f
        }
      });
    }
    r.deleteShader(T), r.deleteShader(E), R = new na(r, v), w = Cv(r, v);
  }
  let R;
  this.getUniforms = function() {
    return R === void 0 && A(this), R;
  };
  let w;
  this.getAttributes = function() {
    return w === void 0 && A(this), w;
  };
  let b = t.rendererExtensionParallelShaderCompile === !1;
  return this.isReady = function() {
    return b === !1 && (b = r.getProgramParameter(v, xv)), b;
  }, this.destroy = function() {
    i.releaseStatesOfProgram(this), r.deleteProgram(v), this.program = void 0;
  }, this.type = t.shaderType, this.name = t.shaderName, this.id = bv++, this.cacheKey = e, this.usedTimes = 1, this.program = v, this.vertexShader = T, this.fragmentShader = E, this;
}
let zv = 0;
class Hv {
  constructor() {
    this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();
  }
  update(e) {
    const t = e.vertexShader, i = e.fragmentShader, r = this._getShaderStage(t), a = this._getShaderStage(i), o = this._getShaderCacheForMaterial(e);
    return o.has(r) === !1 && (o.add(r), r.usedTimes++), o.has(a) === !1 && (o.add(a), a.usedTimes++), this;
  }
  remove(e) {
    const t = this.materialCache.get(e);
    for (const i of t)
      i.usedTimes--, i.usedTimes === 0 && this.shaderCache.delete(i.code);
    return this.materialCache.delete(e), this;
  }
  getVertexShaderID(e) {
    return this._getShaderStage(e.vertexShader).id;
  }
  getFragmentShaderID(e) {
    return this._getShaderStage(e.fragmentShader).id;
  }
  dispose() {
    this.shaderCache.clear(), this.materialCache.clear();
  }
  _getShaderCacheForMaterial(e) {
    const t = this.materialCache;
    let i = t.get(e);
    return i === void 0 && (i = /* @__PURE__ */ new Set(), t.set(e, i)), i;
  }
  _getShaderStage(e) {
    const t = this.shaderCache;
    let i = t.get(e);
    return i === void 0 && (i = new Vv(e), t.set(e, i)), i;
  }
}
class Vv {
  constructor(e) {
    this.id = zv++, this.code = e, this.usedTimes = 0;
  }
}
function Gv(n, e, t, i, r, a, o) {
  const s = new ls(), c = new Hv(), l = /* @__PURE__ */ new Set(), u = [], h = r.logarithmicDepthBuffer, d = r.vertexTextures;
  let p = r.precision;
  const g = {
    MeshDepthMaterial: "depth",
    MeshDistanceMaterial: "distanceRGBA",
    MeshNormalMaterial: "normal",
    MeshBasicMaterial: "basic",
    MeshLambertMaterial: "lambert",
    MeshPhongMaterial: "phong",
    MeshToonMaterial: "toon",
    MeshStandardMaterial: "physical",
    MeshPhysicalMaterial: "physical",
    MeshMatcapMaterial: "matcap",
    LineBasicMaterial: "basic",
    LineDashedMaterial: "dashed",
    PointsMaterial: "points",
    ShadowMaterial: "shadow",
    SpriteMaterial: "sprite"
  };
  function v(w) {
    return l.add(w), w === 0 ? "uv" : `uv${w}`;
  }
  function m(w, b, U, z, I) {
    const L = z.fog, D = I.geometry, B = w.isMeshStandardMaterial ? z.environment : null, te = (w.isMeshStandardMaterial ? t : e).get(w.envMap || B), W = te && te.mapping === ya ? te.image.height : null, ie = g[w.type];
    w.precision !== null && (p = r.getMaxPrecision(w.precision), p !== w.precision && console.warn("THREE.WebGLProgram.getParameters:", w.precision, "not supported, using", p, "instead."));
    const G = D.morphAttributes.position || D.morphAttributes.normal || D.morphAttributes.color, Q = G !== void 0 ? G.length : 0;
    let se = 0;
    D.morphAttributes.position !== void 0 && (se = 1), D.morphAttributes.normal !== void 0 && (se = 2), D.morphAttributes.color !== void 0 && (se = 3);
    let xe, k, H, Z;
    if (ie) {
      const ft = tn[ie];
      xe = ft.vertexShader, k = ft.fragmentShader;
    } else
      xe = w.vertexShader, k = w.fragmentShader, c.update(w), H = c.getVertexShaderID(w), Z = c.getFragmentShaderID(w);
    const N = n.getRenderTarget(), K = I.isInstancedMesh === !0, oe = I.isBatchedMesh === !0, fe = !!w.map, F = !!w.matcap, ge = !!te, Se = !!w.aoMap, ze = !!w.lightMap, Ee = !!w.bumpMap, Be = !!w.normalMap, P = !!w.displacementMap, S = !!w.emissiveMap, Y = !!w.metalnessMap, ee = !!w.roughnessMap, ne = w.anisotropy > 0, re = w.clearcoat > 0, Te = w.iridescence > 0, ae = w.sheen > 0, we = w.transmission > 0, Ae = ne && !!w.anisotropyMap, ue = re && !!w.clearcoatMap, pe = re && !!w.clearcoatNormalMap, Pe = re && !!w.clearcoatRoughnessMap, ve = Te && !!w.iridescenceMap, _e = Te && !!w.iridescenceThicknessMap, He = ae && !!w.sheenColorMap, Ve = ae && !!w.sheenRoughnessMap, $e = !!w.specularMap, je = !!w.specularColorMap, qe = !!w.specularIntensityMap, be = we && !!w.transmissionMap, y = we && !!w.thicknessMap, j = !!w.gradientMap, J = !!w.alphaMap, ce = w.alphaTest > 0, me = !!w.alphaHash, Ge = !!w.extensions;
    let ke = kn;
    w.toneMapped && (N === null || N.isXRRenderTarget === !0) && (ke = n.toneMapping);
    const et = {
      shaderID: ie,
      shaderType: w.type,
      shaderName: w.name,
      vertexShader: xe,
      fragmentShader: k,
      defines: w.defines,
      customVertexShaderID: H,
      customFragmentShaderID: Z,
      isRawShaderMaterial: w.isRawShaderMaterial === !0,
      glslVersion: w.glslVersion,
      precision: p,
      batching: oe,
      instancing: K,
      instancingColor: K && I.instanceColor !== null,
      instancingMorph: K && I.morphTexture !== null,
      supportsVertexTextures: d,
      outputColorSpace: N === null ? n.outputColorSpace : N.isXRRenderTarget === !0 ? N.texture.colorSpace : Gn,
      alphaToCoverage: !!w.alphaToCoverage,
      map: fe,
      matcap: F,
      envMap: ge,
      envMapMode: ge && te.mapping,
      envMapCubeUVHeight: W,
      aoMap: Se,
      lightMap: ze,
      bumpMap: Ee,
      normalMap: Be,
      displacementMap: d && P,
      emissiveMap: S,
      normalMapObjectSpace: Be && w.normalMapType === Bf,
      normalMapTangentSpace: Be && w.normalMapType === _u,
      metalnessMap: Y,
      roughnessMap: ee,
      anisotropy: ne,
      anisotropyMap: Ae,
      clearcoat: re,
      clearcoatMap: ue,
      clearcoatNormalMap: pe,
      clearcoatRoughnessMap: Pe,
      iridescence: Te,
      iridescenceMap: ve,
      iridescenceThicknessMap: _e,
      sheen: ae,
      sheenColorMap: He,
      sheenRoughnessMap: Ve,
      specularMap: $e,
      specularColorMap: je,
      specularIntensityMap: qe,
      transmission: we,
      transmissionMap: be,
      thicknessMap: y,
      gradientMap: j,
      opaque: w.transparent === !1 && w.blending === Ni && w.alphaToCoverage === !1,
      alphaMap: J,
      alphaTest: ce,
      alphaHash: me,
      combine: w.combine,
      //
      mapUv: fe && v(w.map.channel),
      aoMapUv: Se && v(w.aoMap.channel),
      lightMapUv: ze && v(w.lightMap.channel),
      bumpMapUv: Ee && v(w.bumpMap.channel),
      normalMapUv: Be && v(w.normalMap.channel),
      displacementMapUv: P && v(w.displacementMap.channel),
      emissiveMapUv: S && v(w.emissiveMap.channel),
      metalnessMapUv: Y && v(w.metalnessMap.channel),
      roughnessMapUv: ee && v(w.roughnessMap.channel),
      anisotropyMapUv: Ae && v(w.anisotropyMap.channel),
      clearcoatMapUv: ue && v(w.clearcoatMap.channel),
      clearcoatNormalMapUv: pe && v(w.clearcoatNormalMap.channel),
      clearcoatRoughnessMapUv: Pe && v(w.clearcoatRoughnessMap.channel),
      iridescenceMapUv: ve && v(w.iridescenceMap.channel),
      iridescenceThicknessMapUv: _e && v(w.iridescenceThicknessMap.channel),
      sheenColorMapUv: He && v(w.sheenColorMap.channel),
      sheenRoughnessMapUv: Ve && v(w.sheenRoughnessMap.channel),
      specularMapUv: $e && v(w.specularMap.channel),
      specularColorMapUv: je && v(w.specularColorMap.channel),
      specularIntensityMapUv: qe && v(w.specularIntensityMap.channel),
      transmissionMapUv: be && v(w.transmissionMap.channel),
      thicknessMapUv: y && v(w.thicknessMap.channel),
      alphaMapUv: J && v(w.alphaMap.channel),
      //
      vertexTangents: !!D.attributes.tangent && (Be || ne),
      vertexColors: w.vertexColors,
      vertexAlphas: w.vertexColors === !0 && !!D.attributes.color && D.attributes.color.itemSize === 4,
      pointsUvs: I.isPoints === !0 && !!D.attributes.uv && (fe || J),
      fog: !!L,
      useFog: w.fog === !0,
      fogExp2: !!L && L.isFogExp2,
      flatShading: w.flatShading === !0,
      sizeAttenuation: w.sizeAttenuation === !0,
      logarithmicDepthBuffer: h,
      skinning: I.isSkinnedMesh === !0,
      morphTargets: D.morphAttributes.position !== void 0,
      morphNormals: D.morphAttributes.normal !== void 0,
      morphColors: D.morphAttributes.color !== void 0,
      morphTargetsCount: Q,
      morphTextureStride: se,
      numDirLights: b.directional.length,
      numPointLights: b.point.length,
      numSpotLights: b.spot.length,
      numSpotLightMaps: b.spotLightMap.length,
      numRectAreaLights: b.rectArea.length,
      numHemiLights: b.hemi.length,
      numDirLightShadows: b.directionalShadowMap.length,
      numPointLightShadows: b.pointShadowMap.length,
      numSpotLightShadows: b.spotShadowMap.length,
      numSpotLightShadowsWithMaps: b.numSpotLightShadowsWithMaps,
      numLightProbes: b.numLightProbes,
      numClippingPlanes: o.numPlanes,
      numClipIntersection: o.numIntersection,
      dithering: w.dithering,
      shadowMapEnabled: n.shadowMap.enabled && U.length > 0,
      shadowMapType: n.shadowMap.type,
      toneMapping: ke,
      useLegacyLights: n._useLegacyLights,
      decodeVideoTexture: fe && w.map.isVideoTexture === !0 && Ke.getTransfer(w.map.colorSpace) === Qe,
      premultipliedAlpha: w.premultipliedAlpha,
      doubleSided: w.side === bn,
      flipSided: w.side === wt,
      useDepthPacking: w.depthPacking >= 0,
      depthPacking: w.depthPacking || 0,
      index0AttributeName: w.index0AttributeName,
      extensionClipCullDistance: Ge && w.extensions.clipCullDistance === !0 && i.has("WEBGL_clip_cull_distance"),
      extensionMultiDraw: Ge && w.extensions.multiDraw === !0 && i.has("WEBGL_multi_draw"),
      rendererExtensionParallelShaderCompile: i.has("KHR_parallel_shader_compile"),
      customProgramCacheKey: w.customProgramCacheKey()
    };
    return et.vertexUv1s = l.has(1), et.vertexUv2s = l.has(2), et.vertexUv3s = l.has(3), l.clear(), et;
  }
  function f(w) {
    const b = [];
    if (w.shaderID ? b.push(w.shaderID) : (b.push(w.customVertexShaderID), b.push(w.customFragmentShaderID)), w.defines !== void 0)
      for (const U in w.defines)
        b.push(U), b.push(w.defines[U]);
    return w.isRawShaderMaterial === !1 && (M(b, w), _(b, w), b.push(n.outputColorSpace)), b.push(w.customProgramCacheKey), b.join();
  }
  function M(w, b) {
    w.push(b.precision), w.push(b.outputColorSpace), w.push(b.envMapMode), w.push(b.envMapCubeUVHeight), w.push(b.mapUv), w.push(b.alphaMapUv), w.push(b.lightMapUv), w.push(b.aoMapUv), w.push(b.bumpMapUv), w.push(b.normalMapUv), w.push(b.displacementMapUv), w.push(b.emissiveMapUv), w.push(b.metalnessMapUv), w.push(b.roughnessMapUv), w.push(b.anisotropyMapUv), w.push(b.clearcoatMapUv), w.push(b.clearcoatNormalMapUv), w.push(b.clearcoatRoughnessMapUv), w.push(b.iridescenceMapUv), w.push(b.iridescenceThicknessMapUv), w.push(b.sheenColorMapUv), w.push(b.sheenRoughnessMapUv), w.push(b.specularMapUv), w.push(b.specularColorMapUv), w.push(b.specularIntensityMapUv), w.push(b.transmissionMapUv), w.push(b.thicknessMapUv), w.push(b.combine), w.push(b.fogExp2), w.push(b.sizeAttenuation), w.push(b.morphTargetsCount), w.push(b.morphAttributeCount), w.push(b.numDirLights), w.push(b.numPointLights), w.push(b.numSpotLights), w.push(b.numSpotLightMaps), w.push(b.numHemiLights), w.push(b.numRectAreaLights), w.push(b.numDirLightShadows), w.push(b.numPointLightShadows), w.push(b.numSpotLightShadows), w.push(b.numSpotLightShadowsWithMaps), w.push(b.numLightProbes), w.push(b.shadowMapType), w.push(b.toneMapping), w.push(b.numClippingPlanes), w.push(b.numClipIntersection), w.push(b.depthPacking);
  }
  function _(w, b) {
    s.disableAll(), b.supportsVertexTextures && s.enable(0), b.instancing && s.enable(1), b.instancingColor && s.enable(2), b.instancingMorph && s.enable(3), b.matcap && s.enable(4), b.envMap && s.enable(5), b.normalMapObjectSpace && s.enable(6), b.normalMapTangentSpace && s.enable(7), b.clearcoat && s.enable(8), b.iridescence && s.enable(9), b.alphaTest && s.enable(10), b.vertexColors && s.enable(11), b.vertexAlphas && s.enable(12), b.vertexUv1s && s.enable(13), b.vertexUv2s && s.enable(14), b.vertexUv3s && s.enable(15), b.vertexTangents && s.enable(16), b.anisotropy && s.enable(17), b.alphaHash && s.enable(18), b.batching && s.enable(19), w.push(s.mask), s.disableAll(), b.fog && s.enable(0), b.useFog && s.enable(1), b.flatShading && s.enable(2), b.logarithmicDepthBuffer && s.enable(3), b.skinning && s.enable(4), b.morphTargets && s.enable(5), b.morphNormals && s.enable(6), b.morphColors && s.enable(7), b.premultipliedAlpha && s.enable(8), b.shadowMapEnabled && s.enable(9), b.useLegacyLights && s.enable(10), b.doubleSided && s.enable(11), b.flipSided && s.enable(12), b.useDepthPacking && s.enable(13), b.dithering && s.enable(14), b.transmission && s.enable(15), b.sheen && s.enable(16), b.opaque && s.enable(17), b.pointsUvs && s.enable(18), b.decodeVideoTexture && s.enable(19), b.alphaToCoverage && s.enable(20), w.push(s.mask);
  }
  function x(w) {
    const b = g[w.type];
    let U;
    if (b) {
      const z = tn[b];
      U = Au.clone(z.uniforms);
    } else
      U = w.uniforms;
    return U;
  }
  function T(w, b) {
    let U;
    for (let z = 0, I = u.length; z < I; z++) {
      const L = u[z];
      if (L.cacheKey === b) {
        U = L, ++U.usedTimes;
        break;
      }
    }
    return U === void 0 && (U = new kv(n, b, w, a), u.push(U)), U;
  }
  function E(w) {
    if (--w.usedTimes === 0) {
      const b = u.indexOf(w);
      u[b] = u[u.length - 1], u.pop(), w.destroy();
    }
  }
  function A(w) {
    c.remove(w);
  }
  function R() {
    c.dispose();
  }
  return {
    getParameters: m,
    getProgramCacheKey: f,
    getUniforms: x,
    acquireProgram: T,
    releaseProgram: E,
    releaseShaderCache: A,
    // Exposed for resource monitoring & error feedback via renderer.info:
    programs: u,
    dispose: R
  };
}
function Wv() {
  let n = /* @__PURE__ */ new WeakMap();
  function e(a) {
    let o = n.get(a);
    return o === void 0 && (o = {}, n.set(a, o)), o;
  }
  function t(a) {
    n.delete(a);
  }
  function i(a, o, s) {
    n.get(a)[o] = s;
  }
  function r() {
    n = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: e,
    remove: t,
    update: i,
    dispose: r
  };
}
function jv(n, e) {
  return n.groupOrder !== e.groupOrder ? n.groupOrder - e.groupOrder : n.renderOrder !== e.renderOrder ? n.renderOrder - e.renderOrder : n.material.id !== e.material.id ? n.material.id - e.material.id : n.z !== e.z ? n.z - e.z : n.id - e.id;
}
function el(n, e) {
  return n.groupOrder !== e.groupOrder ? n.groupOrder - e.groupOrder : n.renderOrder !== e.renderOrder ? n.renderOrder - e.renderOrder : n.z !== e.z ? e.z - n.z : n.id - e.id;
}
function tl() {
  const n = [];
  let e = 0;
  const t = [], i = [], r = [];
  function a() {
    e = 0, t.length = 0, i.length = 0, r.length = 0;
  }
  function o(h, d, p, g, v, m) {
    let f = n[e];
    return f === void 0 ? (f = {
      id: h.id,
      object: h,
      geometry: d,
      material: p,
      groupOrder: g,
      renderOrder: h.renderOrder,
      z: v,
      group: m
    }, n[e] = f) : (f.id = h.id, f.object = h, f.geometry = d, f.material = p, f.groupOrder = g, f.renderOrder = h.renderOrder, f.z = v, f.group = m), e++, f;
  }
  function s(h, d, p, g, v, m) {
    const f = o(h, d, p, g, v, m);
    p.transmission > 0 ? i.push(f) : p.transparent === !0 ? r.push(f) : t.push(f);
  }
  function c(h, d, p, g, v, m) {
    const f = o(h, d, p, g, v, m);
    p.transmission > 0 ? i.unshift(f) : p.transparent === !0 ? r.unshift(f) : t.unshift(f);
  }
  function l(h, d) {
    t.length > 1 && t.sort(h || jv), i.length > 1 && i.sort(d || el), r.length > 1 && r.sort(d || el);
  }
  function u() {
    for (let h = e, d = n.length; h < d; h++) {
      const p = n[h];
      if (p.id === null)
        break;
      p.id = null, p.object = null, p.geometry = null, p.material = null, p.group = null;
    }
  }
  return {
    opaque: t,
    transmissive: i,
    transparent: r,
    init: a,
    push: s,
    unshift: c,
    finish: u,
    sort: l
  };
}
function Xv() {
  let n = /* @__PURE__ */ new WeakMap();
  function e(i, r) {
    const a = n.get(i);
    let o;
    return a === void 0 ? (o = new tl(), n.set(i, [o])) : r >= a.length ? (o = new tl(), a.push(o)) : o = a[r], o;
  }
  function t() {
    n = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: e,
    dispose: t
  };
}
function $v() {
  const n = {};
  return {
    get: function(e) {
      if (n[e.id] !== void 0)
        return n[e.id];
      let t;
      switch (e.type) {
        case "DirectionalLight":
          t = {
            direction: new O(),
            color: new We()
          };
          break;
        case "SpotLight":
          t = {
            position: new O(),
            direction: new O(),
            color: new We(),
            distance: 0,
            coneCos: 0,
            penumbraCos: 0,
            decay: 0
          };
          break;
        case "PointLight":
          t = {
            position: new O(),
            color: new We(),
            distance: 0,
            decay: 0
          };
          break;
        case "HemisphereLight":
          t = {
            direction: new O(),
            skyColor: new We(),
            groundColor: new We()
          };
          break;
        case "RectAreaLight":
          t = {
            color: new We(),
            position: new O(),
            halfWidth: new O(),
            halfHeight: new O()
          };
          break;
      }
      return n[e.id] = t, t;
    }
  };
}
function qv() {
  const n = {};
  return {
    get: function(e) {
      if (n[e.id] !== void 0)
        return n[e.id];
      let t;
      switch (e.type) {
        case "DirectionalLight":
          t = {
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new le()
          };
          break;
        case "SpotLight":
          t = {
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new le()
          };
          break;
        case "PointLight":
          t = {
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new le(),
            shadowCameraNear: 1,
            shadowCameraFar: 1e3
          };
          break;
      }
      return n[e.id] = t, t;
    }
  };
}
let Yv = 0;
function Kv(n, e) {
  return (e.castShadow ? 2 : 0) - (n.castShadow ? 2 : 0) + (e.map ? 1 : 0) - (n.map ? 1 : 0);
}
function Zv(n) {
  const e = new $v(), t = qv(), i = {
    version: 0,
    hash: {
      directionalLength: -1,
      pointLength: -1,
      spotLength: -1,
      rectAreaLength: -1,
      hemiLength: -1,
      numDirectionalShadows: -1,
      numPointShadows: -1,
      numSpotShadows: -1,
      numSpotMaps: -1,
      numLightProbes: -1
    },
    ambient: [0, 0, 0],
    probe: [],
    directional: [],
    directionalShadow: [],
    directionalShadowMap: [],
    directionalShadowMatrix: [],
    spot: [],
    spotLightMap: [],
    spotShadow: [],
    spotShadowMap: [],
    spotLightMatrix: [],
    rectArea: [],
    rectAreaLTC1: null,
    rectAreaLTC2: null,
    point: [],
    pointShadow: [],
    pointShadowMap: [],
    pointShadowMatrix: [],
    hemi: [],
    numSpotLightShadowsWithMaps: 0,
    numLightProbes: 0
  };
  for (let l = 0; l < 9; l++)
    i.probe.push(new O());
  const r = new O(), a = new Je(), o = new Je();
  function s(l, u) {
    let h = 0, d = 0, p = 0;
    for (let U = 0; U < 9; U++)
      i.probe[U].set(0, 0, 0);
    let g = 0, v = 0, m = 0, f = 0, M = 0, _ = 0, x = 0, T = 0, E = 0, A = 0, R = 0;
    l.sort(Kv);
    const w = u === !0 ? Math.PI : 1;
    for (let U = 0, z = l.length; U < z; U++) {
      const I = l[U], L = I.color, D = I.intensity, B = I.distance, te = I.shadow && I.shadow.map ? I.shadow.map.texture : null;
      if (I.isAmbientLight)
        h += L.r * D * w, d += L.g * D * w, p += L.b * D * w;
      else if (I.isLightProbe) {
        for (let W = 0; W < 9; W++)
          i.probe[W].addScaledVector(I.sh.coefficients[W], D);
        R++;
      } else if (I.isDirectionalLight) {
        const W = e.get(I);
        if (W.color.copy(I.color).multiplyScalar(I.intensity * w), I.castShadow) {
          const ie = I.shadow, G = t.get(I);
          G.shadowBias = ie.bias, G.shadowNormalBias = ie.normalBias, G.shadowRadius = ie.radius, G.shadowMapSize = ie.mapSize, i.directionalShadow[g] = G, i.directionalShadowMap[g] = te, i.directionalShadowMatrix[g] = I.shadow.matrix, _++;
        }
        i.directional[g] = W, g++;
      } else if (I.isSpotLight) {
        const W = e.get(I);
        W.position.setFromMatrixPosition(I.matrixWorld), W.color.copy(L).multiplyScalar(D * w), W.distance = B, W.coneCos = Math.cos(I.angle), W.penumbraCos = Math.cos(I.angle * (1 - I.penumbra)), W.decay = I.decay, i.spot[m] = W;
        const ie = I.shadow;
        if (I.map && (i.spotLightMap[E] = I.map, E++, ie.updateMatrices(I), I.castShadow && A++), i.spotLightMatrix[m] = ie.matrix, I.castShadow) {
          const G = t.get(I);
          G.shadowBias = ie.bias, G.shadowNormalBias = ie.normalBias, G.shadowRadius = ie.radius, G.shadowMapSize = ie.mapSize, i.spotShadow[m] = G, i.spotShadowMap[m] = te, T++;
        }
        m++;
      } else if (I.isRectAreaLight) {
        const W = e.get(I);
        W.color.copy(L).multiplyScalar(D), W.halfWidth.set(I.width * 0.5, 0, 0), W.halfHeight.set(0, I.height * 0.5, 0), i.rectArea[f] = W, f++;
      } else if (I.isPointLight) {
        const W = e.get(I);
        if (W.color.copy(I.color).multiplyScalar(I.intensity * w), W.distance = I.distance, W.decay = I.decay, I.castShadow) {
          const ie = I.shadow, G = t.get(I);
          G.shadowBias = ie.bias, G.shadowNormalBias = ie.normalBias, G.shadowRadius = ie.radius, G.shadowMapSize = ie.mapSize, G.shadowCameraNear = ie.camera.near, G.shadowCameraFar = ie.camera.far, i.pointShadow[v] = G, i.pointShadowMap[v] = te, i.pointShadowMatrix[v] = I.shadow.matrix, x++;
        }
        i.point[v] = W, v++;
      } else if (I.isHemisphereLight) {
        const W = e.get(I);
        W.skyColor.copy(I.color).multiplyScalar(D * w), W.groundColor.copy(I.groundColor).multiplyScalar(D * w), i.hemi[M] = W, M++;
      }
    }
    f > 0 && (n.has("OES_texture_float_linear") === !0 ? (i.rectAreaLTC1 = he.LTC_FLOAT_1, i.rectAreaLTC2 = he.LTC_FLOAT_2) : (i.rectAreaLTC1 = he.LTC_HALF_1, i.rectAreaLTC2 = he.LTC_HALF_2)), i.ambient[0] = h, i.ambient[1] = d, i.ambient[2] = p;
    const b = i.hash;
    (b.directionalLength !== g || b.pointLength !== v || b.spotLength !== m || b.rectAreaLength !== f || b.hemiLength !== M || b.numDirectionalShadows !== _ || b.numPointShadows !== x || b.numSpotShadows !== T || b.numSpotMaps !== E || b.numLightProbes !== R) && (i.directional.length = g, i.spot.length = m, i.rectArea.length = f, i.point.length = v, i.hemi.length = M, i.directionalShadow.length = _, i.directionalShadowMap.length = _, i.pointShadow.length = x, i.pointShadowMap.length = x, i.spotShadow.length = T, i.spotShadowMap.length = T, i.directionalShadowMatrix.length = _, i.pointShadowMatrix.length = x, i.spotLightMatrix.length = T + E - A, i.spotLightMap.length = E, i.numSpotLightShadowsWithMaps = A, i.numLightProbes = R, b.directionalLength = g, b.pointLength = v, b.spotLength = m, b.rectAreaLength = f, b.hemiLength = M, b.numDirectionalShadows = _, b.numPointShadows = x, b.numSpotShadows = T, b.numSpotMaps = E, b.numLightProbes = R, i.version = Yv++);
  }
  function c(l, u) {
    let h = 0, d = 0, p = 0, g = 0, v = 0;
    const m = u.matrixWorldInverse;
    for (let f = 0, M = l.length; f < M; f++) {
      const _ = l[f];
      if (_.isDirectionalLight) {
        const x = i.directional[h];
        x.direction.setFromMatrixPosition(_.matrixWorld), r.setFromMatrixPosition(_.target.matrixWorld), x.direction.sub(r), x.direction.transformDirection(m), h++;
      } else if (_.isSpotLight) {
        const x = i.spot[p];
        x.position.setFromMatrixPosition(_.matrixWorld), x.position.applyMatrix4(m), x.direction.setFromMatrixPosition(_.matrixWorld), r.setFromMatrixPosition(_.target.matrixWorld), x.direction.sub(r), x.direction.transformDirection(m), p++;
      } else if (_.isRectAreaLight) {
        const x = i.rectArea[g];
        x.position.setFromMatrixPosition(_.matrixWorld), x.position.applyMatrix4(m), o.identity(), a.copy(_.matrixWorld), a.premultiply(m), o.extractRotation(a), x.halfWidth.set(_.width * 0.5, 0, 0), x.halfHeight.set(0, _.height * 0.5, 0), x.halfWidth.applyMatrix4(o), x.halfHeight.applyMatrix4(o), g++;
      } else if (_.isPointLight) {
        const x = i.point[d];
        x.position.setFromMatrixPosition(_.matrixWorld), x.position.applyMatrix4(m), d++;
      } else if (_.isHemisphereLight) {
        const x = i.hemi[v];
        x.direction.setFromMatrixPosition(_.matrixWorld), x.direction.transformDirection(m), v++;
      }
    }
  }
  return {
    setup: s,
    setupView: c,
    state: i
  };
}
function nl(n) {
  const e = new Zv(n), t = [], i = [];
  function r() {
    t.length = 0, i.length = 0;
  }
  function a(u) {
    t.push(u);
  }
  function o(u) {
    i.push(u);
  }
  function s(u) {
    e.setup(t, u);
  }
  function c(u) {
    e.setupView(t, u);
  }
  return {
    init: r,
    state: {
      lightsArray: t,
      shadowsArray: i,
      lights: e,
      transmissionRenderTarget: null
    },
    setupLights: s,
    setupLightsView: c,
    pushLight: a,
    pushShadow: o
  };
}
function Jv(n) {
  let e = /* @__PURE__ */ new WeakMap();
  function t(r, a = 0) {
    const o = e.get(r);
    let s;
    return o === void 0 ? (s = new nl(n), e.set(r, [s])) : a >= o.length ? (s = new nl(n), o.push(s)) : s = o[a], s;
  }
  function i() {
    e = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: t,
    dispose: i
  };
}
class Qv extends Wi {
  constructor(e) {
    super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = Uf, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this;
  }
}
class e_ extends Wi {
  constructor(e) {
    super(), this.isMeshDistanceMaterial = !0, this.type = "MeshDistanceMaterial", this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this;
  }
}
const t_ = `void main() {
	gl_Position = vec4( position, 1.0 );
}`, n_ = `uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;
function i_(n, e, t) {
  let i = new hs();
  const r = new le(), a = new le(), o = new gt(), s = new Qv({ depthPacking: Ff }), c = new e_(), l = {}, u = t.maxTextureSize, h = { [Hn]: wt, [wt]: Hn, [bn]: bn }, d = new sn({
    defines: {
      VSM_SAMPLES: 8
    },
    uniforms: {
      shadow_pass: { value: null },
      resolution: { value: new le() },
      radius: { value: 4 }
    },
    vertexShader: t_,
    fragmentShader: n_
  }), p = d.clone();
  p.defines.HORIZONTAL_PASS = 1;
  const g = new Nt();
  g.setAttribute(
    "position",
    new Zt(
      new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),
      3
    )
  );
  const v = new Vt(g, d), m = this;
  this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = cu;
  let f = this.type;
  this.render = function(E, A, R) {
    if (m.enabled === !1 || m.autoUpdate === !1 && m.needsUpdate === !1 || E.length === 0)
      return;
    const w = n.getRenderTarget(), b = n.getActiveCubeFace(), U = n.getActiveMipmapLevel(), z = n.state;
    z.setBlending(En), z.buffers.color.setClear(1, 1, 1, 1), z.buffers.depth.setTest(!0), z.setScissorTest(!1);
    const I = f !== _n && this.type === _n, L = f === _n && this.type !== _n;
    for (let D = 0, B = E.length; D < B; D++) {
      const te = E[D], W = te.shadow;
      if (W === void 0) {
        console.warn("THREE.WebGLShadowMap:", te, "has no shadow.");
        continue;
      }
      if (W.autoUpdate === !1 && W.needsUpdate === !1)
        continue;
      r.copy(W.mapSize);
      const ie = W.getFrameExtents();
      if (r.multiply(ie), a.copy(W.mapSize), (r.x > u || r.y > u) && (r.x > u && (a.x = Math.floor(u / ie.x), r.x = a.x * ie.x, W.mapSize.x = a.x), r.y > u && (a.y = Math.floor(u / ie.y), r.y = a.y * ie.y, W.mapSize.y = a.y)), W.map === null || I === !0 || L === !0) {
        const Q = this.type !== _n ? { minFilter: Ht, magFilter: Ht } : {};
        W.map !== null && W.map.dispose(), W.map = new Vn(r.x, r.y, Q), W.map.texture.name = te.name + ".shadowMap", W.camera.updateProjectionMatrix();
      }
      n.setRenderTarget(W.map), n.clear();
      const G = W.getViewportCount();
      for (let Q = 0; Q < G; Q++) {
        const se = W.getViewport(Q);
        o.set(
          a.x * se.x,
          a.y * se.y,
          a.x * se.z,
          a.y * se.w
        ), z.viewport(o), W.updateMatrices(te, Q), i = W.getFrustum(), x(A, R, W.camera, te, this.type);
      }
      W.isPointLightShadow !== !0 && this.type === _n && M(W, R), W.needsUpdate = !1;
    }
    f = this.type, m.needsUpdate = !1, n.setRenderTarget(w, b, U);
  };
  function M(E, A) {
    const R = e.update(v);
    d.defines.VSM_SAMPLES !== E.blurSamples && (d.defines.VSM_SAMPLES = E.blurSamples, p.defines.VSM_SAMPLES = E.blurSamples, d.needsUpdate = !0, p.needsUpdate = !0), E.mapPass === null && (E.mapPass = new Vn(r.x, r.y)), d.uniforms.shadow_pass.value = E.map.texture, d.uniforms.resolution.value = E.mapSize, d.uniforms.radius.value = E.radius, n.setRenderTarget(E.mapPass), n.clear(), n.renderBufferDirect(A, null, R, d, v, null), p.uniforms.shadow_pass.value = E.mapPass.texture, p.uniforms.resolution.value = E.mapSize, p.uniforms.radius.value = E.radius, n.setRenderTarget(E.map), n.clear(), n.renderBufferDirect(A, null, R, p, v, null);
  }
  function _(E, A, R, w) {
    let b = null;
    const U = R.isPointLight === !0 ? E.customDistanceMaterial : E.customDepthMaterial;
    if (U !== void 0)
      b = U;
    else if (b = R.isPointLight === !0 ? c : s, n.localClippingEnabled && A.clipShadows === !0 && Array.isArray(A.clippingPlanes) && A.clippingPlanes.length !== 0 || A.displacementMap && A.displacementScale !== 0 || A.alphaMap && A.alphaTest > 0 || A.map && A.alphaTest > 0) {
      const z = b.uuid, I = A.uuid;
      let L = l[z];
      L === void 0 && (L = {}, l[z] = L);
      let D = L[I];
      D === void 0 && (D = b.clone(), L[I] = D, A.addEventListener("dispose", T)), b = D;
    }
    if (b.visible = A.visible, b.wireframe = A.wireframe, w === _n ? b.side = A.shadowSide !== null ? A.shadowSide : A.side : b.side = A.shadowSide !== null ? A.shadowSide : h[A.side], b.alphaMap = A.alphaMap, b.alphaTest = A.alphaTest, b.map = A.map, b.clipShadows = A.clipShadows, b.clippingPlanes = A.clippingPlanes, b.clipIntersection = A.clipIntersection, b.displacementMap = A.displacementMap, b.displacementScale = A.displacementScale, b.displacementBias = A.displacementBias, b.wireframeLinewidth = A.wireframeLinewidth, b.linewidth = A.linewidth, R.isPointLight === !0 && b.isMeshDistanceMaterial === !0) {
      const z = n.properties.get(b);
      z.light = R;
    }
    return b;
  }
  function x(E, A, R, w, b) {
    if (E.visible === !1)
      return;
    if (E.layers.test(A.layers) && (E.isMesh || E.isLine || E.isPoints) && (E.castShadow || E.receiveShadow && b === _n) && (!E.frustumCulled || i.intersectsObject(E))) {
      E.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse, E.matrixWorld);
      const I = e.update(E), L = E.material;
      if (Array.isArray(L)) {
        const D = I.groups;
        for (let B = 0, te = D.length; B < te; B++) {
          const W = D[B], ie = L[W.materialIndex];
          if (ie && ie.visible) {
            const G = _(E, ie, w, b);
            E.onBeforeShadow(n, E, A, R, I, G, W), n.renderBufferDirect(R, null, I, G, E, W), E.onAfterShadow(n, E, A, R, I, G, W);
          }
        }
      } else if (L.visible) {
        const D = _(E, L, w, b);
        E.onBeforeShadow(n, E, A, R, I, D, null), n.renderBufferDirect(R, null, I, D, E, null), E.onAfterShadow(n, E, A, R, I, D, null);
      }
    }
    const z = E.children;
    for (let I = 0, L = z.length; I < L; I++)
      x(z[I], A, R, w, b);
  }
  function T(E) {
    E.target.removeEventListener("dispose", T);
    for (const R in l) {
      const w = l[R], b = E.target.uuid;
      b in w && (w[b].dispose(), delete w[b]);
    }
  }
}
function r_(n) {
  function e() {
    let y = !1;
    const j = new gt();
    let J = null;
    const ce = new gt(0, 0, 0, 0);
    return {
      setMask: function(me) {
        J !== me && !y && (n.colorMask(me, me, me, me), J = me);
      },
      setLocked: function(me) {
        y = me;
      },
      setClear: function(me, Ge, ke, et, ft) {
        ft === !0 && (me *= et, Ge *= et, ke *= et), j.set(me, Ge, ke, et), ce.equals(j) === !1 && (n.clearColor(me, Ge, ke, et), ce.copy(j));
      },
      reset: function() {
        y = !1, J = null, ce.set(-1, 0, 0, 0);
      }
    };
  }
  function t() {
    let y = !1, j = null, J = null, ce = null;
    return {
      setTest: function(me) {
        me ? Z(n.DEPTH_TEST) : N(n.DEPTH_TEST);
      },
      setMask: function(me) {
        j !== me && !y && (n.depthMask(me), j = me);
      },
      setFunc: function(me) {
        if (J !== me) {
          switch (me) {
            case lf:
              n.depthFunc(n.NEVER);
              break;
            case uf:
              n.depthFunc(n.ALWAYS);
              break;
            case hf:
              n.depthFunc(n.LESS);
              break;
            case aa:
              n.depthFunc(n.LEQUAL);
              break;
            case ff:
              n.depthFunc(n.EQUAL);
              break;
            case df:
              n.depthFunc(n.GEQUAL);
              break;
            case pf:
              n.depthFunc(n.GREATER);
              break;
            case mf:
              n.depthFunc(n.NOTEQUAL);
              break;
            default:
              n.depthFunc(n.LEQUAL);
          }
          J = me;
        }
      },
      setLocked: function(me) {
        y = me;
      },
      setClear: function(me) {
        ce !== me && (n.clearDepth(me), ce = me);
      },
      reset: function() {
        y = !1, j = null, J = null, ce = null;
      }
    };
  }
  function i() {
    let y = !1, j = null, J = null, ce = null, me = null, Ge = null, ke = null, et = null, ft = null;
    return {
      setTest: function(Ye) {
        y || (Ye ? Z(n.STENCIL_TEST) : N(n.STENCIL_TEST));
      },
      setMask: function(Ye) {
        j !== Ye && !y && (n.stencilMask(Ye), j = Ye);
      },
      setFunc: function(Ye, ot, st) {
        (J !== Ye || ce !== ot || me !== st) && (n.stencilFunc(Ye, ot, st), J = Ye, ce = ot, me = st);
      },
      setOp: function(Ye, ot, st) {
        (Ge !== Ye || ke !== ot || et !== st) && (n.stencilOp(Ye, ot, st), Ge = Ye, ke = ot, et = st);
      },
      setLocked: function(Ye) {
        y = Ye;
      },
      setClear: function(Ye) {
        ft !== Ye && (n.clearStencil(Ye), ft = Ye);
      },
      reset: function() {
        y = !1, j = null, J = null, ce = null, me = null, Ge = null, ke = null, et = null, ft = null;
      }
    };
  }
  const r = new e(), a = new t(), o = new i(), s = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap();
  let l = {}, u = {}, h = /* @__PURE__ */ new WeakMap(), d = [], p = null, g = !1, v = null, m = null, f = null, M = null, _ = null, x = null, T = null, E = new We(0, 0, 0), A = 0, R = !1, w = null, b = null, U = null, z = null, I = null;
  const L = n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  let D = !1, B = 0;
  const te = n.getParameter(n.VERSION);
  te.indexOf("WebGL") !== -1 ? (B = parseFloat(/^WebGL (\d)/.exec(te)[1]), D = B >= 1) : te.indexOf("OpenGL ES") !== -1 && (B = parseFloat(/^OpenGL ES (\d)/.exec(te)[1]), D = B >= 2);
  let W = null, ie = {};
  const G = n.getParameter(n.SCISSOR_BOX), Q = n.getParameter(n.VIEWPORT), se = new gt().fromArray(G), xe = new gt().fromArray(Q);
  function k(y, j, J, ce) {
    const me = new Uint8Array(4), Ge = n.createTexture();
    n.bindTexture(y, Ge), n.texParameteri(y, n.TEXTURE_MIN_FILTER, n.NEAREST), n.texParameteri(y, n.TEXTURE_MAG_FILTER, n.NEAREST);
    for (let ke = 0; ke < J; ke++)
      y === n.TEXTURE_3D || y === n.TEXTURE_2D_ARRAY ? n.texImage3D(j, 0, n.RGBA, 1, 1, ce, 0, n.RGBA, n.UNSIGNED_BYTE, me) : n.texImage2D(j + ke, 0, n.RGBA, 1, 1, 0, n.RGBA, n.UNSIGNED_BYTE, me);
    return Ge;
  }
  const H = {};
  H[n.TEXTURE_2D] = k(n.TEXTURE_2D, n.TEXTURE_2D, 1), H[n.TEXTURE_CUBE_MAP] = k(n.TEXTURE_CUBE_MAP, n.TEXTURE_CUBE_MAP_POSITIVE_X, 6), H[n.TEXTURE_2D_ARRAY] = k(n.TEXTURE_2D_ARRAY, n.TEXTURE_2D_ARRAY, 1, 1), H[n.TEXTURE_3D] = k(n.TEXTURE_3D, n.TEXTURE_3D, 1, 1), r.setClear(0, 0, 0, 1), a.setClear(1), o.setClear(0), Z(n.DEPTH_TEST), a.setFunc(aa), Ee(!1), Be(Fs), Z(n.CULL_FACE), Se(En);
  function Z(y) {
    l[y] !== !0 && (n.enable(y), l[y] = !0);
  }
  function N(y) {
    l[y] !== !1 && (n.disable(y), l[y] = !1);
  }
  function K(y, j) {
    return u[y] !== j ? (n.bindFramebuffer(y, j), u[y] = j, y === n.DRAW_FRAMEBUFFER && (u[n.FRAMEBUFFER] = j), y === n.FRAMEBUFFER && (u[n.DRAW_FRAMEBUFFER] = j), !0) : !1;
  }
  function oe(y, j) {
    let J = d, ce = !1;
    if (y) {
      J = h.get(j), J === void 0 && (J = [], h.set(j, J));
      const me = y.textures;
      if (J.length !== me.length || J[0] !== n.COLOR_ATTACHMENT0) {
        for (let Ge = 0, ke = me.length; Ge < ke; Ge++)
          J[Ge] = n.COLOR_ATTACHMENT0 + Ge;
        J.length = me.length, ce = !0;
      }
    } else
      J[0] !== n.BACK && (J[0] = n.BACK, ce = !0);
    ce && n.drawBuffers(J);
  }
  function fe(y) {
    return p !== y ? (n.useProgram(y), p = y, !0) : !1;
  }
  const F = {
    [ii]: n.FUNC_ADD,
    [jh]: n.FUNC_SUBTRACT,
    [Xh]: n.FUNC_REVERSE_SUBTRACT
  };
  F[$h] = n.MIN, F[qh] = n.MAX;
  const ge = {
    [Yh]: n.ZERO,
    [Kh]: n.ONE,
    [Zh]: n.SRC_COLOR,
    [Io]: n.SRC_ALPHA,
    [rf]: n.SRC_ALPHA_SATURATE,
    [tf]: n.DST_COLOR,
    [Qh]: n.DST_ALPHA,
    [Jh]: n.ONE_MINUS_SRC_COLOR,
    [No]: n.ONE_MINUS_SRC_ALPHA,
    [nf]: n.ONE_MINUS_DST_COLOR,
    [ef]: n.ONE_MINUS_DST_ALPHA,
    [af]: n.CONSTANT_COLOR,
    [of]: n.ONE_MINUS_CONSTANT_COLOR,
    [sf]: n.CONSTANT_ALPHA,
    [cf]: n.ONE_MINUS_CONSTANT_ALPHA
  };
  function Se(y, j, J, ce, me, Ge, ke, et, ft, Ye) {
    if (y === En) {
      g === !0 && (N(n.BLEND), g = !1);
      return;
    }
    if (g === !1 && (Z(n.BLEND), g = !0), y !== Wh) {
      if (y !== v || Ye !== R) {
        if ((m !== ii || _ !== ii) && (n.blendEquation(n.FUNC_ADD), m = ii, _ = ii), Ye)
          switch (y) {
            case Ni:
              n.blendFuncSeparate(n.ONE, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA);
              break;
            case Bs:
              n.blendFunc(n.ONE, n.ONE);
              break;
            case ks:
              n.blendFuncSeparate(n.ZERO, n.ONE_MINUS_SRC_COLOR, n.ZERO, n.ONE);
              break;
            case zs:
              n.blendFuncSeparate(n.ZERO, n.SRC_COLOR, n.ZERO, n.SRC_ALPHA);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", y);
              break;
          }
        else
          switch (y) {
            case Ni:
              n.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA);
              break;
            case Bs:
              n.blendFunc(n.SRC_ALPHA, n.ONE);
              break;
            case ks:
              n.blendFuncSeparate(n.ZERO, n.ONE_MINUS_SRC_COLOR, n.ZERO, n.ONE);
              break;
            case zs:
              n.blendFunc(n.ZERO, n.SRC_COLOR);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", y);
              break;
          }
        f = null, M = null, x = null, T = null, E.set(0, 0, 0), A = 0, v = y, R = Ye;
      }
      return;
    }
    me = me || j, Ge = Ge || J, ke = ke || ce, (j !== m || me !== _) && (n.blendEquationSeparate(F[j], F[me]), m = j, _ = me), (J !== f || ce !== M || Ge !== x || ke !== T) && (n.blendFuncSeparate(ge[J], ge[ce], ge[Ge], ge[ke]), f = J, M = ce, x = Ge, T = ke), (et.equals(E) === !1 || ft !== A) && (n.blendColor(et.r, et.g, et.b, ft), E.copy(et), A = ft), v = y, R = !1;
  }
  function ze(y, j) {
    y.side === bn ? N(n.CULL_FACE) : Z(n.CULL_FACE);
    let J = y.side === wt;
    j && (J = !J), Ee(J), y.blending === Ni && y.transparent === !1 ? Se(En) : Se(y.blending, y.blendEquation, y.blendSrc, y.blendDst, y.blendEquationAlpha, y.blendSrcAlpha, y.blendDstAlpha, y.blendColor, y.blendAlpha, y.premultipliedAlpha), a.setFunc(y.depthFunc), a.setTest(y.depthTest), a.setMask(y.depthWrite), r.setMask(y.colorWrite);
    const ce = y.stencilWrite;
    o.setTest(ce), ce && (o.setMask(y.stencilWriteMask), o.setFunc(y.stencilFunc, y.stencilRef, y.stencilFuncMask), o.setOp(y.stencilFail, y.stencilZFail, y.stencilZPass)), S(y.polygonOffset, y.polygonOffsetFactor, y.polygonOffsetUnits), y.alphaToCoverage === !0 ? Z(n.SAMPLE_ALPHA_TO_COVERAGE) : N(n.SAMPLE_ALPHA_TO_COVERAGE);
  }
  function Ee(y) {
    w !== y && (y ? n.frontFace(n.CW) : n.frontFace(n.CCW), w = y);
  }
  function Be(y) {
    y !== Hh ? (Z(n.CULL_FACE), y !== b && (y === Fs ? n.cullFace(n.BACK) : y === Vh ? n.cullFace(n.FRONT) : n.cullFace(n.FRONT_AND_BACK))) : N(n.CULL_FACE), b = y;
  }
  function P(y) {
    y !== U && (D && n.lineWidth(y), U = y);
  }
  function S(y, j, J) {
    y ? (Z(n.POLYGON_OFFSET_FILL), (z !== j || I !== J) && (n.polygonOffset(j, J), z = j, I = J)) : N(n.POLYGON_OFFSET_FILL);
  }
  function Y(y) {
    y ? Z(n.SCISSOR_TEST) : N(n.SCISSOR_TEST);
  }
  function ee(y) {
    y === void 0 && (y = n.TEXTURE0 + L - 1), W !== y && (n.activeTexture(y), W = y);
  }
  function ne(y, j, J) {
    J === void 0 && (W === null ? J = n.TEXTURE0 + L - 1 : J = W);
    let ce = ie[J];
    ce === void 0 && (ce = { type: void 0, texture: void 0 }, ie[J] = ce), (ce.type !== y || ce.texture !== j) && (W !== J && (n.activeTexture(J), W = J), n.bindTexture(y, j || H[y]), ce.type = y, ce.texture = j);
  }
  function re() {
    const y = ie[W];
    y !== void 0 && y.type !== void 0 && (n.bindTexture(y.type, null), y.type = void 0, y.texture = void 0);
  }
  function Te() {
    try {
      n.compressedTexImage2D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function ae() {
    try {
      n.compressedTexImage3D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function we() {
    try {
      n.texSubImage2D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function Ae() {
    try {
      n.texSubImage3D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function ue() {
    try {
      n.compressedTexSubImage2D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function pe() {
    try {
      n.compressedTexSubImage3D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function Pe() {
    try {
      n.texStorage2D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function ve() {
    try {
      n.texStorage3D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function _e() {
    try {
      n.texImage2D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function He() {
    try {
      n.texImage3D.apply(n, arguments);
    } catch (y) {
      console.error("THREE.WebGLState:", y);
    }
  }
  function Ve(y) {
    se.equals(y) === !1 && (n.scissor(y.x, y.y, y.z, y.w), se.copy(y));
  }
  function $e(y) {
    xe.equals(y) === !1 && (n.viewport(y.x, y.y, y.z, y.w), xe.copy(y));
  }
  function je(y, j) {
    let J = c.get(j);
    J === void 0 && (J = /* @__PURE__ */ new WeakMap(), c.set(j, J));
    let ce = J.get(y);
    ce === void 0 && (ce = n.getUniformBlockIndex(j, y.name), J.set(y, ce));
  }
  function qe(y, j) {
    const ce = c.get(j).get(y);
    s.get(j) !== ce && (n.uniformBlockBinding(j, ce, y.__bindingPointIndex), s.set(j, ce));
  }
  function be() {
    n.disable(n.BLEND), n.disable(n.CULL_FACE), n.disable(n.DEPTH_TEST), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SCISSOR_TEST), n.disable(n.STENCIL_TEST), n.disable(n.SAMPLE_ALPHA_TO_COVERAGE), n.blendEquation(n.FUNC_ADD), n.blendFunc(n.ONE, n.ZERO), n.blendFuncSeparate(n.ONE, n.ZERO, n.ONE, n.ZERO), n.blendColor(0, 0, 0, 0), n.colorMask(!0, !0, !0, !0), n.clearColor(0, 0, 0, 0), n.depthMask(!0), n.depthFunc(n.LESS), n.clearDepth(1), n.stencilMask(4294967295), n.stencilFunc(n.ALWAYS, 0, 4294967295), n.stencilOp(n.KEEP, n.KEEP, n.KEEP), n.clearStencil(0), n.cullFace(n.BACK), n.frontFace(n.CCW), n.polygonOffset(0, 0), n.activeTexture(n.TEXTURE0), n.bindFramebuffer(n.FRAMEBUFFER, null), n.bindFramebuffer(n.DRAW_FRAMEBUFFER, null), n.bindFramebuffer(n.READ_FRAMEBUFFER, null), n.useProgram(null), n.lineWidth(1), n.scissor(0, 0, n.canvas.width, n.canvas.height), n.viewport(0, 0, n.canvas.width, n.canvas.height), l = {}, W = null, ie = {}, u = {}, h = /* @__PURE__ */ new WeakMap(), d = [], p = null, g = !1, v = null, m = null, f = null, M = null, _ = null, x = null, T = null, E = new We(0, 0, 0), A = 0, R = !1, w = null, b = null, U = null, z = null, I = null, se.set(0, 0, n.canvas.width, n.canvas.height), xe.set(0, 0, n.canvas.width, n.canvas.height), r.reset(), a.reset(), o.reset();
  }
  return {
    buffers: {
      color: r,
      depth: a,
      stencil: o
    },
    enable: Z,
    disable: N,
    bindFramebuffer: K,
    drawBuffers: oe,
    useProgram: fe,
    setBlending: Se,
    setMaterial: ze,
    setFlipSided: Ee,
    setCullFace: Be,
    setLineWidth: P,
    setPolygonOffset: S,
    setScissorTest: Y,
    activeTexture: ee,
    bindTexture: ne,
    unbindTexture: re,
    compressedTexImage2D: Te,
    compressedTexImage3D: ae,
    texImage2D: _e,
    texImage3D: He,
    updateUBOMapping: je,
    uniformBlockBinding: qe,
    texStorage2D: Pe,
    texStorage3D: ve,
    texSubImage2D: we,
    texSubImage3D: Ae,
    compressedTexSubImage2D: ue,
    compressedTexSubImage3D: pe,
    scissor: Ve,
    viewport: $e,
    reset: be
  };
}
function a_(n, e, t, i, r, a, o) {
  const s = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : null, c = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), l = new le(), u = /* @__PURE__ */ new WeakMap();
  let h;
  const d = /* @__PURE__ */ new WeakMap();
  let p = !1;
  try {
    p = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
  } catch {
  }
  function g(P, S) {
    return p ? (
      // eslint-disable-next-line compat/compat
      new OffscreenCanvas(P, S)
    ) : vr("canvas");
  }
  function v(P, S, Y) {
    let ee = 1;
    const ne = Be(P);
    if ((ne.width > Y || ne.height > Y) && (ee = Y / Math.max(ne.width, ne.height)), ee < 1)
      if (typeof HTMLImageElement < "u" && P instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && P instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && P instanceof ImageBitmap || typeof VideoFrame < "u" && P instanceof VideoFrame) {
        const re = Math.floor(ee * ne.width), Te = Math.floor(ee * ne.height);
        h === void 0 && (h = g(re, Te));
        const ae = S ? g(re, Te) : h;
        return ae.width = re, ae.height = Te, ae.getContext("2d").drawImage(P, 0, 0, re, Te), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + ne.width + "x" + ne.height + ") to (" + re + "x" + Te + ")."), ae;
      } else
        return "data" in P && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + ne.width + "x" + ne.height + ")."), P;
    return P;
  }
  function m(P) {
    return P.generateMipmaps && P.minFilter !== Ht && P.minFilter !== Yt;
  }
  function f(P) {
    n.generateMipmap(P);
  }
  function M(P, S, Y, ee, ne = !1) {
    if (P !== null) {
      if (n[P] !== void 0)
        return n[P];
      console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + P + "'");
    }
    let re = S;
    if (S === n.RED && (Y === n.FLOAT && (re = n.R32F), Y === n.HALF_FLOAT && (re = n.R16F), Y === n.UNSIGNED_BYTE && (re = n.R8)), S === n.RED_INTEGER && (Y === n.UNSIGNED_BYTE && (re = n.R8UI), Y === n.UNSIGNED_SHORT && (re = n.R16UI), Y === n.UNSIGNED_INT && (re = n.R32UI), Y === n.BYTE && (re = n.R8I), Y === n.SHORT && (re = n.R16I), Y === n.INT && (re = n.R32I)), S === n.RG && (Y === n.FLOAT && (re = n.RG32F), Y === n.HALF_FLOAT && (re = n.RG16F), Y === n.UNSIGNED_BYTE && (re = n.RG8)), S === n.RG_INTEGER && (Y === n.UNSIGNED_BYTE && (re = n.RG8UI), Y === n.UNSIGNED_SHORT && (re = n.RG16UI), Y === n.UNSIGNED_INT && (re = n.RG32UI), Y === n.BYTE && (re = n.RG8I), Y === n.SHORT && (re = n.RG16I), Y === n.INT && (re = n.RG32I)), S === n.RGB && Y === n.UNSIGNED_INT_5_9_9_9_REV && (re = n.RGB9_E5), S === n.RGBA) {
      const Te = ne ? oa : Ke.getTransfer(ee);
      Y === n.FLOAT && (re = n.RGBA32F), Y === n.HALF_FLOAT && (re = n.RGBA16F), Y === n.UNSIGNED_BYTE && (re = Te === Qe ? n.SRGB8_ALPHA8 : n.RGBA8), Y === n.UNSIGNED_SHORT_4_4_4_4 && (re = n.RGBA4), Y === n.UNSIGNED_SHORT_5_5_5_1 && (re = n.RGB5_A1);
    }
    return (re === n.R16F || re === n.R32F || re === n.RG16F || re === n.RG32F || re === n.RGBA16F || re === n.RGBA32F) && e.get("EXT_color_buffer_float"), re;
  }
  function _(P, S) {
    return m(P) === !0 || P.isFramebufferTexture && P.minFilter !== Ht && P.minFilter !== Yt ? Math.log2(Math.max(S.width, S.height)) + 1 : P.mipmaps !== void 0 && P.mipmaps.length > 0 ? P.mipmaps.length : P.isCompressedTexture && Array.isArray(P.image) ? S.mipmaps.length : 1;
  }
  function x(P) {
    const S = P.target;
    S.removeEventListener("dispose", x), E(S), S.isVideoTexture && u.delete(S);
  }
  function T(P) {
    const S = P.target;
    S.removeEventListener("dispose", T), R(S);
  }
  function E(P) {
    const S = i.get(P);
    if (S.__webglInit === void 0)
      return;
    const Y = P.source, ee = d.get(Y);
    if (ee) {
      const ne = ee[S.__cacheKey];
      ne.usedTimes--, ne.usedTimes === 0 && A(P), Object.keys(ee).length === 0 && d.delete(Y);
    }
    i.remove(P);
  }
  function A(P) {
    const S = i.get(P);
    n.deleteTexture(S.__webglTexture);
    const Y = P.source, ee = d.get(Y);
    delete ee[S.__cacheKey], o.memory.textures--;
  }
  function R(P) {
    const S = i.get(P);
    if (P.depthTexture && P.depthTexture.dispose(), P.isWebGLCubeRenderTarget)
      for (let ee = 0; ee < 6; ee++) {
        if (Array.isArray(S.__webglFramebuffer[ee]))
          for (let ne = 0; ne < S.__webglFramebuffer[ee].length; ne++)
            n.deleteFramebuffer(S.__webglFramebuffer[ee][ne]);
        else
          n.deleteFramebuffer(S.__webglFramebuffer[ee]);
        S.__webglDepthbuffer && n.deleteRenderbuffer(S.__webglDepthbuffer[ee]);
      }
    else {
      if (Array.isArray(S.__webglFramebuffer))
        for (let ee = 0; ee < S.__webglFramebuffer.length; ee++)
          n.deleteFramebuffer(S.__webglFramebuffer[ee]);
      else
        n.deleteFramebuffer(S.__webglFramebuffer);
      if (S.__webglDepthbuffer && n.deleteRenderbuffer(S.__webglDepthbuffer), S.__webglMultisampledFramebuffer && n.deleteFramebuffer(S.__webglMultisampledFramebuffer), S.__webglColorRenderbuffer)
        for (let ee = 0; ee < S.__webglColorRenderbuffer.length; ee++)
          S.__webglColorRenderbuffer[ee] && n.deleteRenderbuffer(S.__webglColorRenderbuffer[ee]);
      S.__webglDepthRenderbuffer && n.deleteRenderbuffer(S.__webglDepthRenderbuffer);
    }
    const Y = P.textures;
    for (let ee = 0, ne = Y.length; ee < ne; ee++) {
      const re = i.get(Y[ee]);
      re.__webglTexture && (n.deleteTexture(re.__webglTexture), o.memory.textures--), i.remove(Y[ee]);
    }
    i.remove(P);
  }
  let w = 0;
  function b() {
    w = 0;
  }
  function U() {
    const P = w;
    return P >= r.maxTextures && console.warn("THREE.WebGLTextures: Trying to use " + P + " texture units while this GPU supports only " + r.maxTextures), w += 1, P;
  }
  function z(P) {
    const S = [];
    return S.push(P.wrapS), S.push(P.wrapT), S.push(P.wrapR || 0), S.push(P.magFilter), S.push(P.minFilter), S.push(P.anisotropy), S.push(P.internalFormat), S.push(P.format), S.push(P.type), S.push(P.generateMipmaps), S.push(P.premultiplyAlpha), S.push(P.flipY), S.push(P.unpackAlignment), S.push(P.colorSpace), S.join();
  }
  function I(P, S) {
    const Y = i.get(P);
    if (P.isVideoTexture && ze(P), P.isRenderTargetTexture === !1 && P.version > 0 && Y.__version !== P.version) {
      const ee = P.image;
      if (ee === null)
        console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");
      else if (ee.complete === !1)
        console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");
      else {
        se(Y, P, S);
        return;
      }
    }
    t.bindTexture(n.TEXTURE_2D, Y.__webglTexture, n.TEXTURE0 + S);
  }
  function L(P, S) {
    const Y = i.get(P);
    if (P.version > 0 && Y.__version !== P.version) {
      se(Y, P, S);
      return;
    }
    t.bindTexture(n.TEXTURE_2D_ARRAY, Y.__webglTexture, n.TEXTURE0 + S);
  }
  function D(P, S) {
    const Y = i.get(P);
    if (P.version > 0 && Y.__version !== P.version) {
      se(Y, P, S);
      return;
    }
    t.bindTexture(n.TEXTURE_3D, Y.__webglTexture, n.TEXTURE0 + S);
  }
  function B(P, S) {
    const Y = i.get(P);
    if (P.version > 0 && Y.__version !== P.version) {
      xe(Y, P, S);
      return;
    }
    t.bindTexture(n.TEXTURE_CUBE_MAP, Y.__webglTexture, n.TEXTURE0 + S);
  }
  const te = {
    [Bo]: n.REPEAT,
    [ai]: n.CLAMP_TO_EDGE,
    [ko]: n.MIRRORED_REPEAT
  }, W = {
    [Ht]: n.NEAREST,
    [wf]: n.NEAREST_MIPMAP_NEAREST,
    [Tr]: n.NEAREST_MIPMAP_LINEAR,
    [Yt]: n.LINEAR,
    [Ua]: n.LINEAR_MIPMAP_NEAREST,
    [oi]: n.LINEAR_MIPMAP_LINEAR
  }, ie = {
    [kf]: n.NEVER,
    [jf]: n.ALWAYS,
    [zf]: n.LESS,
    [yu]: n.LEQUAL,
    [Hf]: n.EQUAL,
    [Wf]: n.GEQUAL,
    [Vf]: n.GREATER,
    [Gf]: n.NOTEQUAL
  };
  function G(P, S) {
    if (S.type === Bn && e.has("OES_texture_float_linear") === !1 && (S.magFilter === Yt || S.magFilter === Ua || S.magFilter === Tr || S.magFilter === oi || S.minFilter === Yt || S.minFilter === Ua || S.minFilter === Tr || S.minFilter === oi) && console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), n.texParameteri(P, n.TEXTURE_WRAP_S, te[S.wrapS]), n.texParameteri(P, n.TEXTURE_WRAP_T, te[S.wrapT]), (P === n.TEXTURE_3D || P === n.TEXTURE_2D_ARRAY) && n.texParameteri(P, n.TEXTURE_WRAP_R, te[S.wrapR]), n.texParameteri(P, n.TEXTURE_MAG_FILTER, W[S.magFilter]), n.texParameteri(P, n.TEXTURE_MIN_FILTER, W[S.minFilter]), S.compareFunction && (n.texParameteri(P, n.TEXTURE_COMPARE_MODE, n.COMPARE_REF_TO_TEXTURE), n.texParameteri(P, n.TEXTURE_COMPARE_FUNC, ie[S.compareFunction])), e.has("EXT_texture_filter_anisotropic") === !0) {
      if (S.magFilter === Ht || S.minFilter !== Tr && S.minFilter !== oi || S.type === Bn && e.has("OES_texture_float_linear") === !1)
        return;
      if (S.anisotropy > 1 || i.get(S).__currentAnisotropy) {
        const Y = e.get("EXT_texture_filter_anisotropic");
        n.texParameterf(P, Y.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(S.anisotropy, r.getMaxAnisotropy())), i.get(S).__currentAnisotropy = S.anisotropy;
      }
    }
  }
  function Q(P, S) {
    let Y = !1;
    P.__webglInit === void 0 && (P.__webglInit = !0, S.addEventListener("dispose", x));
    const ee = S.source;
    let ne = d.get(ee);
    ne === void 0 && (ne = {}, d.set(ee, ne));
    const re = z(S);
    if (re !== P.__cacheKey) {
      ne[re] === void 0 && (ne[re] = {
        texture: n.createTexture(),
        usedTimes: 0
      }, o.memory.textures++, Y = !0), ne[re].usedTimes++;
      const Te = ne[P.__cacheKey];
      Te !== void 0 && (ne[P.__cacheKey].usedTimes--, Te.usedTimes === 0 && A(S)), P.__cacheKey = re, P.__webglTexture = ne[re].texture;
    }
    return Y;
  }
  function se(P, S, Y) {
    let ee = n.TEXTURE_2D;
    (S.isDataArrayTexture || S.isCompressedArrayTexture) && (ee = n.TEXTURE_2D_ARRAY), S.isData3DTexture && (ee = n.TEXTURE_3D);
    const ne = Q(P, S), re = S.source;
    t.bindTexture(ee, P.__webglTexture, n.TEXTURE0 + Y);
    const Te = i.get(re);
    if (re.version !== Te.__version || ne === !0) {
      t.activeTexture(n.TEXTURE0 + Y);
      const ae = Ke.getPrimaries(Ke.workingColorSpace), we = S.colorSpace === Fn ? null : Ke.getPrimaries(S.colorSpace), Ae = S.colorSpace === Fn || ae === we ? n.NONE : n.BROWSER_DEFAULT_WEBGL;
      n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, S.flipY), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, S.premultiplyAlpha), n.pixelStorei(n.UNPACK_ALIGNMENT, S.unpackAlignment), n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL, Ae);
      let ue = v(S.image, !1, r.maxTextureSize);
      ue = Ee(S, ue);
      const pe = a.convert(S.format, S.colorSpace), Pe = a.convert(S.type);
      let ve = M(S.internalFormat, pe, Pe, S.colorSpace, S.isVideoTexture);
      G(ee, S);
      let _e;
      const He = S.mipmaps, Ve = S.isVideoTexture !== !0 && ve !== vu, $e = Te.__version === void 0 || ne === !0, je = re.dataReady, qe = _(S, ue);
      if (S.isDepthTexture)
        ve = n.DEPTH_COMPONENT16, S.type === Bn ? ve = n.DEPTH_COMPONENT32F : S.type === zi ? ve = n.DEPTH_COMPONENT24 : S.type === br && (ve = n.DEPTH24_STENCIL8), $e && (Ve ? t.texStorage2D(n.TEXTURE_2D, 1, ve, ue.width, ue.height) : t.texImage2D(n.TEXTURE_2D, 0, ve, ue.width, ue.height, 0, pe, Pe, null));
      else if (S.isDataTexture)
        if (He.length > 0) {
          Ve && $e && t.texStorage2D(n.TEXTURE_2D, qe, ve, He[0].width, He[0].height);
          for (let be = 0, y = He.length; be < y; be++)
            _e = He[be], Ve ? je && t.texSubImage2D(n.TEXTURE_2D, be, 0, 0, _e.width, _e.height, pe, Pe, _e.data) : t.texImage2D(n.TEXTURE_2D, be, ve, _e.width, _e.height, 0, pe, Pe, _e.data);
          S.generateMipmaps = !1;
        } else
          Ve ? ($e && t.texStorage2D(n.TEXTURE_2D, qe, ve, ue.width, ue.height), je && t.texSubImage2D(n.TEXTURE_2D, 0, 0, 0, ue.width, ue.height, pe, Pe, ue.data)) : t.texImage2D(n.TEXTURE_2D, 0, ve, ue.width, ue.height, 0, pe, Pe, ue.data);
      else if (S.isCompressedTexture)
        if (S.isCompressedArrayTexture) {
          Ve && $e && t.texStorage3D(n.TEXTURE_2D_ARRAY, qe, ve, He[0].width, He[0].height, ue.depth);
          for (let be = 0, y = He.length; be < y; be++)
            _e = He[be], S.format !== rn ? pe !== null ? Ve ? je && t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY, be, 0, 0, 0, _e.width, _e.height, ue.depth, pe, _e.data, 0, 0) : t.compressedTexImage3D(n.TEXTURE_2D_ARRAY, be, ve, _e.width, _e.height, ue.depth, 0, _e.data, 0, 0) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Ve ? je && t.texSubImage3D(n.TEXTURE_2D_ARRAY, be, 0, 0, 0, _e.width, _e.height, ue.depth, pe, Pe, _e.data) : t.texImage3D(n.TEXTURE_2D_ARRAY, be, ve, _e.width, _e.height, ue.depth, 0, pe, Pe, _e.data);
        } else {
          Ve && $e && t.texStorage2D(n.TEXTURE_2D, qe, ve, He[0].width, He[0].height);
          for (let be = 0, y = He.length; be < y; be++)
            _e = He[be], S.format !== rn ? pe !== null ? Ve ? je && t.compressedTexSubImage2D(n.TEXTURE_2D, be, 0, 0, _e.width, _e.height, pe, _e.data) : t.compressedTexImage2D(n.TEXTURE_2D, be, ve, _e.width, _e.height, 0, _e.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : Ve ? je && t.texSubImage2D(n.TEXTURE_2D, be, 0, 0, _e.width, _e.height, pe, Pe, _e.data) : t.texImage2D(n.TEXTURE_2D, be, ve, _e.width, _e.height, 0, pe, Pe, _e.data);
        }
      else if (S.isDataArrayTexture)
        Ve ? ($e && t.texStorage3D(n.TEXTURE_2D_ARRAY, qe, ve, ue.width, ue.height, ue.depth), je && t.texSubImage3D(n.TEXTURE_2D_ARRAY, 0, 0, 0, 0, ue.width, ue.height, ue.depth, pe, Pe, ue.data)) : t.texImage3D(n.TEXTURE_2D_ARRAY, 0, ve, ue.width, ue.height, ue.depth, 0, pe, Pe, ue.data);
      else if (S.isData3DTexture)
        Ve ? ($e && t.texStorage3D(n.TEXTURE_3D, qe, ve, ue.width, ue.height, ue.depth), je && t.texSubImage3D(n.TEXTURE_3D, 0, 0, 0, 0, ue.width, ue.height, ue.depth, pe, Pe, ue.data)) : t.texImage3D(n.TEXTURE_3D, 0, ve, ue.width, ue.height, ue.depth, 0, pe, Pe, ue.data);
      else if (S.isFramebufferTexture) {
        if ($e)
          if (Ve)
            t.texStorage2D(n.TEXTURE_2D, qe, ve, ue.width, ue.height);
          else {
            let be = ue.width, y = ue.height;
            for (let j = 0; j < qe; j++)
              t.texImage2D(n.TEXTURE_2D, j, ve, be, y, 0, pe, Pe, null), be >>= 1, y >>= 1;
          }
      } else if (He.length > 0) {
        if (Ve && $e) {
          const be = Be(He[0]);
          t.texStorage2D(n.TEXTURE_2D, qe, ve, be.width, be.height);
        }
        for (let be = 0, y = He.length; be < y; be++)
          _e = He[be], Ve ? je && t.texSubImage2D(n.TEXTURE_2D, be, 0, 0, pe, Pe, _e) : t.texImage2D(n.TEXTURE_2D, be, ve, pe, Pe, _e);
        S.generateMipmaps = !1;
      } else if (Ve) {
        if ($e) {
          const be = Be(ue);
          t.texStorage2D(n.TEXTURE_2D, qe, ve, be.width, be.height);
        }
        je && t.texSubImage2D(n.TEXTURE_2D, 0, 0, 0, pe, Pe, ue);
      } else
        t.texImage2D(n.TEXTURE_2D, 0, ve, pe, Pe, ue);
      m(S) && f(ee), Te.__version = re.version, S.onUpdate && S.onUpdate(S);
    }
    P.__version = S.version;
  }
  function xe(P, S, Y) {
    if (S.image.length !== 6)
      return;
    const ee = Q(P, S), ne = S.source;
    t.bindTexture(n.TEXTURE_CUBE_MAP, P.__webglTexture, n.TEXTURE0 + Y);
    const re = i.get(ne);
    if (ne.version !== re.__version || ee === !0) {
      t.activeTexture(n.TEXTURE0 + Y);
      const Te = Ke.getPrimaries(Ke.workingColorSpace), ae = S.colorSpace === Fn ? null : Ke.getPrimaries(S.colorSpace), we = S.colorSpace === Fn || Te === ae ? n.NONE : n.BROWSER_DEFAULT_WEBGL;
      n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, S.flipY), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, S.premultiplyAlpha), n.pixelStorei(n.UNPACK_ALIGNMENT, S.unpackAlignment), n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL, we);
      const Ae = S.isCompressedTexture || S.image[0].isCompressedTexture, ue = S.image[0] && S.image[0].isDataTexture, pe = [];
      for (let y = 0; y < 6; y++)
        !Ae && !ue ? pe[y] = v(S.image[y], !0, r.maxCubemapSize) : pe[y] = ue ? S.image[y].image : S.image[y], pe[y] = Ee(S, pe[y]);
      const Pe = pe[0], ve = a.convert(S.format, S.colorSpace), _e = a.convert(S.type), He = M(S.internalFormat, ve, _e, S.colorSpace), Ve = S.isVideoTexture !== !0, $e = re.__version === void 0 || ee === !0, je = ne.dataReady;
      let qe = _(S, Pe);
      G(n.TEXTURE_CUBE_MAP, S);
      let be;
      if (Ae) {
        Ve && $e && t.texStorage2D(n.TEXTURE_CUBE_MAP, qe, He, Pe.width, Pe.height);
        for (let y = 0; y < 6; y++) {
          be = pe[y].mipmaps;
          for (let j = 0; j < be.length; j++) {
            const J = be[j];
            S.format !== rn ? ve !== null ? Ve ? je && t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, j, 0, 0, J.width, J.height, ve, J.data) : t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, j, He, J.width, J.height, 0, J.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : Ve ? je && t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, j, 0, 0, J.width, J.height, ve, _e, J.data) : t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, j, He, J.width, J.height, 0, ve, _e, J.data);
          }
        }
      } else {
        if (be = S.mipmaps, Ve && $e) {
          be.length > 0 && qe++;
          const y = Be(pe[0]);
          t.texStorage2D(n.TEXTURE_CUBE_MAP, qe, He, y.width, y.height);
        }
        for (let y = 0; y < 6; y++)
          if (ue) {
            Ve ? je && t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, 0, 0, 0, pe[y].width, pe[y].height, ve, _e, pe[y].data) : t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, 0, He, pe[y].width, pe[y].height, 0, ve, _e, pe[y].data);
            for (let j = 0; j < be.length; j++) {
              const ce = be[j].image[y].image;
              Ve ? je && t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, j + 1, 0, 0, ce.width, ce.height, ve, _e, ce.data) : t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, j + 1, He, ce.width, ce.height, 0, ve, _e, ce.data);
            }
          } else {
            Ve ? je && t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, 0, 0, 0, ve, _e, pe[y]) : t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, 0, He, ve, _e, pe[y]);
            for (let j = 0; j < be.length; j++) {
              const J = be[j];
              Ve ? je && t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, j + 1, 0, 0, ve, _e, J.image[y]) : t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X + y, j + 1, He, ve, _e, J.image[y]);
            }
          }
      }
      m(S) && f(n.TEXTURE_CUBE_MAP), re.__version = ne.version, S.onUpdate && S.onUpdate(S);
    }
    P.__version = S.version;
  }
  function k(P, S, Y, ee, ne, re) {
    const Te = a.convert(Y.format, Y.colorSpace), ae = a.convert(Y.type), we = M(Y.internalFormat, Te, ae, Y.colorSpace);
    if (!i.get(S).__hasExternalTextures) {
      const ue = Math.max(1, S.width >> re), pe = Math.max(1, S.height >> re);
      ne === n.TEXTURE_3D || ne === n.TEXTURE_2D_ARRAY ? t.texImage3D(ne, re, we, ue, pe, S.depth, 0, Te, ae, null) : t.texImage2D(ne, re, we, ue, pe, 0, Te, ae, null);
    }
    t.bindFramebuffer(n.FRAMEBUFFER, P), Se(S) ? s.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, ee, ne, i.get(Y).__webglTexture, 0, ge(S)) : (ne === n.TEXTURE_2D || ne >= n.TEXTURE_CUBE_MAP_POSITIVE_X && ne <= n.TEXTURE_CUBE_MAP_NEGATIVE_Z) && n.framebufferTexture2D(n.FRAMEBUFFER, ee, ne, i.get(Y).__webglTexture, re), t.bindFramebuffer(n.FRAMEBUFFER, null);
  }
  function H(P, S, Y) {
    if (n.bindRenderbuffer(n.RENDERBUFFER, P), S.depthBuffer && !S.stencilBuffer) {
      let ee = n.DEPTH_COMPONENT24;
      if (Y || Se(S)) {
        const ne = S.depthTexture;
        ne && ne.isDepthTexture && (ne.type === Bn ? ee = n.DEPTH_COMPONENT32F : ne.type === zi && (ee = n.DEPTH_COMPONENT24));
        const re = ge(S);
        Se(S) ? s.renderbufferStorageMultisampleEXT(n.RENDERBUFFER, re, ee, S.width, S.height) : n.renderbufferStorageMultisample(n.RENDERBUFFER, re, ee, S.width, S.height);
      } else
        n.renderbufferStorage(n.RENDERBUFFER, ee, S.width, S.height);
      n.framebufferRenderbuffer(n.FRAMEBUFFER, n.DEPTH_ATTACHMENT, n.RENDERBUFFER, P);
    } else if (S.depthBuffer && S.stencilBuffer) {
      const ee = ge(S);
      Y && Se(S) === !1 ? n.renderbufferStorageMultisample(n.RENDERBUFFER, ee, n.DEPTH24_STENCIL8, S.width, S.height) : Se(S) ? s.renderbufferStorageMultisampleEXT(n.RENDERBUFFER, ee, n.DEPTH24_STENCIL8, S.width, S.height) : n.renderbufferStorage(n.RENDERBUFFER, n.DEPTH_STENCIL, S.width, S.height), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.DEPTH_STENCIL_ATTACHMENT, n.RENDERBUFFER, P);
    } else {
      const ee = S.textures;
      for (let ne = 0; ne < ee.length; ne++) {
        const re = ee[ne], Te = a.convert(re.format, re.colorSpace), ae = a.convert(re.type), we = M(re.internalFormat, Te, ae, re.colorSpace), Ae = ge(S);
        Y && Se(S) === !1 ? n.renderbufferStorageMultisample(n.RENDERBUFFER, Ae, we, S.width, S.height) : Se(S) ? s.renderbufferStorageMultisampleEXT(n.RENDERBUFFER, Ae, we, S.width, S.height) : n.renderbufferStorage(n.RENDERBUFFER, we, S.width, S.height);
      }
    }
    n.bindRenderbuffer(n.RENDERBUFFER, null);
  }
  function Z(P, S) {
    if (S && S.isWebGLCubeRenderTarget)
      throw new Error("Depth Texture with cube render targets is not supported");
    if (t.bindFramebuffer(n.FRAMEBUFFER, P), !(S.depthTexture && S.depthTexture.isDepthTexture))
      throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
    (!i.get(S.depthTexture).__webglTexture || S.depthTexture.image.width !== S.width || S.depthTexture.image.height !== S.height) && (S.depthTexture.image.width = S.width, S.depthTexture.image.height = S.height, S.depthTexture.needsUpdate = !0), I(S.depthTexture, 0);
    const ee = i.get(S.depthTexture).__webglTexture, ne = ge(S);
    if (S.depthTexture.format === Ui)
      Se(S) ? s.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, n.DEPTH_ATTACHMENT, n.TEXTURE_2D, ee, 0, ne) : n.framebufferTexture2D(n.FRAMEBUFFER, n.DEPTH_ATTACHMENT, n.TEXTURE_2D, ee, 0);
    else if (S.depthTexture.format === mr)
      Se(S) ? s.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER, n.DEPTH_STENCIL_ATTACHMENT, n.TEXTURE_2D, ee, 0, ne) : n.framebufferTexture2D(n.FRAMEBUFFER, n.DEPTH_STENCIL_ATTACHMENT, n.TEXTURE_2D, ee, 0);
    else
      throw new Error("Unknown depthTexture format");
  }
  function N(P) {
    const S = i.get(P), Y = P.isWebGLCubeRenderTarget === !0;
    if (P.depthTexture && !S.__autoAllocateDepthBuffer) {
      if (Y)
        throw new Error("target.depthTexture not supported in Cube render targets");
      Z(S.__webglFramebuffer, P);
    } else if (Y) {
      S.__webglDepthbuffer = [];
      for (let ee = 0; ee < 6; ee++)
        t.bindFramebuffer(n.FRAMEBUFFER, S.__webglFramebuffer[ee]), S.__webglDepthbuffer[ee] = n.createRenderbuffer(), H(S.__webglDepthbuffer[ee], P, !1);
    } else
      t.bindFramebuffer(n.FRAMEBUFFER, S.__webglFramebuffer), S.__webglDepthbuffer = n.createRenderbuffer(), H(S.__webglDepthbuffer, P, !1);
    t.bindFramebuffer(n.FRAMEBUFFER, null);
  }
  function K(P, S, Y) {
    const ee = i.get(P);
    S !== void 0 && k(ee.__webglFramebuffer, P, P.texture, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, 0), Y !== void 0 && N(P);
  }
  function oe(P) {
    const S = P.texture, Y = i.get(P), ee = i.get(S);
    P.addEventListener("dispose", T);
    const ne = P.textures, re = P.isWebGLCubeRenderTarget === !0, Te = ne.length > 1;
    if (Te || (ee.__webglTexture === void 0 && (ee.__webglTexture = n.createTexture()), ee.__version = S.version, o.memory.textures++), re) {
      Y.__webglFramebuffer = [];
      for (let ae = 0; ae < 6; ae++)
        if (S.mipmaps && S.mipmaps.length > 0) {
          Y.__webglFramebuffer[ae] = [];
          for (let we = 0; we < S.mipmaps.length; we++)
            Y.__webglFramebuffer[ae][we] = n.createFramebuffer();
        } else
          Y.__webglFramebuffer[ae] = n.createFramebuffer();
    } else {
      if (S.mipmaps && S.mipmaps.length > 0) {
        Y.__webglFramebuffer = [];
        for (let ae = 0; ae < S.mipmaps.length; ae++)
          Y.__webglFramebuffer[ae] = n.createFramebuffer();
      } else
        Y.__webglFramebuffer = n.createFramebuffer();
      if (Te)
        for (let ae = 0, we = ne.length; ae < we; ae++) {
          const Ae = i.get(ne[ae]);
          Ae.__webglTexture === void 0 && (Ae.__webglTexture = n.createTexture(), o.memory.textures++);
        }
      if (P.samples > 0 && Se(P) === !1) {
        Y.__webglMultisampledFramebuffer = n.createFramebuffer(), Y.__webglColorRenderbuffer = [], t.bindFramebuffer(n.FRAMEBUFFER, Y.__webglMultisampledFramebuffer);
        for (let ae = 0; ae < ne.length; ae++) {
          const we = ne[ae];
          Y.__webglColorRenderbuffer[ae] = n.createRenderbuffer(), n.bindRenderbuffer(n.RENDERBUFFER, Y.__webglColorRenderbuffer[ae]);
          const Ae = a.convert(we.format, we.colorSpace), ue = a.convert(we.type), pe = M(we.internalFormat, Ae, ue, we.colorSpace, P.isXRRenderTarget === !0), Pe = ge(P);
          n.renderbufferStorageMultisample(n.RENDERBUFFER, Pe, pe, P.width, P.height), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0 + ae, n.RENDERBUFFER, Y.__webglColorRenderbuffer[ae]);
        }
        n.bindRenderbuffer(n.RENDERBUFFER, null), P.depthBuffer && (Y.__webglDepthRenderbuffer = n.createRenderbuffer(), H(Y.__webglDepthRenderbuffer, P, !0)), t.bindFramebuffer(n.FRAMEBUFFER, null);
      }
    }
    if (re) {
      t.bindTexture(n.TEXTURE_CUBE_MAP, ee.__webglTexture), G(n.TEXTURE_CUBE_MAP, S);
      for (let ae = 0; ae < 6; ae++)
        if (S.mipmaps && S.mipmaps.length > 0)
          for (let we = 0; we < S.mipmaps.length; we++)
            k(Y.__webglFramebuffer[ae][we], P, S, n.COLOR_ATTACHMENT0, n.TEXTURE_CUBE_MAP_POSITIVE_X + ae, we);
        else
          k(Y.__webglFramebuffer[ae], P, S, n.COLOR_ATTACHMENT0, n.TEXTURE_CUBE_MAP_POSITIVE_X + ae, 0);
      m(S) && f(n.TEXTURE_CUBE_MAP), t.unbindTexture();
    } else if (Te) {
      for (let ae = 0, we = ne.length; ae < we; ae++) {
        const Ae = ne[ae], ue = i.get(Ae);
        t.bindTexture(n.TEXTURE_2D, ue.__webglTexture), G(n.TEXTURE_2D, Ae), k(Y.__webglFramebuffer, P, Ae, n.COLOR_ATTACHMENT0 + ae, n.TEXTURE_2D, 0), m(Ae) && f(n.TEXTURE_2D);
      }
      t.unbindTexture();
    } else {
      let ae = n.TEXTURE_2D;
      if ((P.isWebGL3DRenderTarget || P.isWebGLArrayRenderTarget) && (ae = P.isWebGL3DRenderTarget ? n.TEXTURE_3D : n.TEXTURE_2D_ARRAY), t.bindTexture(ae, ee.__webglTexture), G(ae, S), S.mipmaps && S.mipmaps.length > 0)
        for (let we = 0; we < S.mipmaps.length; we++)
          k(Y.__webglFramebuffer[we], P, S, n.COLOR_ATTACHMENT0, ae, we);
      else
        k(Y.__webglFramebuffer, P, S, n.COLOR_ATTACHMENT0, ae, 0);
      m(S) && f(ae), t.unbindTexture();
    }
    P.depthBuffer && N(P);
  }
  function fe(P) {
    const S = P.textures;
    for (let Y = 0, ee = S.length; Y < ee; Y++) {
      const ne = S[Y];
      if (m(ne)) {
        const re = P.isWebGLCubeRenderTarget ? n.TEXTURE_CUBE_MAP : n.TEXTURE_2D, Te = i.get(ne).__webglTexture;
        t.bindTexture(re, Te), f(re), t.unbindTexture();
      }
    }
  }
  function F(P) {
    if (P.samples > 0 && Se(P) === !1) {
      const S = P.textures, Y = P.width, ee = P.height;
      let ne = n.COLOR_BUFFER_BIT;
      const re = [], Te = P.stencilBuffer ? n.DEPTH_STENCIL_ATTACHMENT : n.DEPTH_ATTACHMENT, ae = i.get(P), we = S.length > 1;
      if (we)
        for (let Ae = 0; Ae < S.length; Ae++)
          t.bindFramebuffer(n.FRAMEBUFFER, ae.__webglMultisampledFramebuffer), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Ae, n.RENDERBUFFER, null), t.bindFramebuffer(n.FRAMEBUFFER, ae.__webglFramebuffer), n.framebufferTexture2D(n.DRAW_FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Ae, n.TEXTURE_2D, null, 0);
      t.bindFramebuffer(n.READ_FRAMEBUFFER, ae.__webglMultisampledFramebuffer), t.bindFramebuffer(n.DRAW_FRAMEBUFFER, ae.__webglFramebuffer);
      for (let Ae = 0; Ae < S.length; Ae++) {
        re.push(n.COLOR_ATTACHMENT0 + Ae), P.depthBuffer && re.push(Te);
        const ue = ae.__ignoreDepthValues !== void 0 ? ae.__ignoreDepthValues : !1;
        if (ue === !1 && (P.depthBuffer && (ne |= n.DEPTH_BUFFER_BIT), P.stencilBuffer && ae.__isTransmissionRenderTarget !== !0 && (ne |= n.STENCIL_BUFFER_BIT)), we && n.framebufferRenderbuffer(n.READ_FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.RENDERBUFFER, ae.__webglColorRenderbuffer[Ae]), ue === !0 && (n.invalidateFramebuffer(n.READ_FRAMEBUFFER, [Te]), n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER, [Te])), we) {
          const pe = i.get(S[Ae]).__webglTexture;
          n.framebufferTexture2D(n.DRAW_FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, pe, 0);
        }
        n.blitFramebuffer(0, 0, Y, ee, 0, 0, Y, ee, ne, n.NEAREST), c && n.invalidateFramebuffer(n.READ_FRAMEBUFFER, re);
      }
      if (t.bindFramebuffer(n.READ_FRAMEBUFFER, null), t.bindFramebuffer(n.DRAW_FRAMEBUFFER, null), we)
        for (let Ae = 0; Ae < S.length; Ae++) {
          t.bindFramebuffer(n.FRAMEBUFFER, ae.__webglMultisampledFramebuffer), n.framebufferRenderbuffer(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Ae, n.RENDERBUFFER, ae.__webglColorRenderbuffer[Ae]);
          const ue = i.get(S[Ae]).__webglTexture;
          t.bindFramebuffer(n.FRAMEBUFFER, ae.__webglFramebuffer), n.framebufferTexture2D(n.DRAW_FRAMEBUFFER, n.COLOR_ATTACHMENT0 + Ae, n.TEXTURE_2D, ue, 0);
        }
      t.bindFramebuffer(n.DRAW_FRAMEBUFFER, ae.__webglMultisampledFramebuffer);
    }
  }
  function ge(P) {
    return Math.min(r.maxSamples, P.samples);
  }
  function Se(P) {
    const S = i.get(P);
    return P.samples > 0 && e.has("WEBGL_multisampled_render_to_texture") === !0 && S.__useRenderToTexture !== !1;
  }
  function ze(P) {
    const S = o.render.frame;
    u.get(P) !== S && (u.set(P, S), P.update());
  }
  function Ee(P, S) {
    const Y = P.colorSpace, ee = P.format, ne = P.type;
    return P.isCompressedTexture === !0 || P.isVideoTexture === !0 || Y !== Gn && Y !== Fn && (Ke.getTransfer(Y) === Qe ? (ee !== rn || ne !== zn) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", Y)), S;
  }
  function Be(P) {
    return typeof HTMLImageElement < "u" && P instanceof HTMLImageElement ? (l.width = P.naturalWidth || P.width, l.height = P.naturalHeight || P.height) : typeof VideoFrame < "u" && P instanceof VideoFrame ? (l.width = P.displayWidth, l.height = P.displayHeight) : (l.width = P.width, l.height = P.height), l;
  }
  this.allocateTextureUnit = U, this.resetTextureUnits = b, this.setTexture2D = I, this.setTexture2DArray = L, this.setTexture3D = D, this.setTextureCube = B, this.rebindTextures = K, this.setupRenderTarget = oe, this.updateRenderTargetMipmap = fe, this.updateMultisampleRenderTarget = F, this.setupDepthRenderbuffer = N, this.setupFrameBufferTexture = k, this.useMultisampledRTT = Se;
}
function o_(n, e) {
  function t(i, r = Fn) {
    let a;
    const o = Ke.getTransfer(r);
    if (i === zn)
      return n.UNSIGNED_BYTE;
    if (i === fu)
      return n.UNSIGNED_SHORT_4_4_4_4;
    if (i === du)
      return n.UNSIGNED_SHORT_5_5_5_1;
    if (i === Cf)
      return n.UNSIGNED_INT_5_9_9_9_REV;
    if (i === Tf)
      return n.BYTE;
    if (i === Af)
      return n.SHORT;
    if (i === uu)
      return n.UNSIGNED_SHORT;
    if (i === hu)
      return n.INT;
    if (i === zi)
      return n.UNSIGNED_INT;
    if (i === Bn)
      return n.FLOAT;
    if (i === pr)
      return n.HALF_FLOAT;
    if (i === Rf)
      return n.ALPHA;
    if (i === Pf)
      return n.RGB;
    if (i === rn)
      return n.RGBA;
    if (i === Lf)
      return n.LUMINANCE;
    if (i === Df)
      return n.LUMINANCE_ALPHA;
    if (i === Ui)
      return n.DEPTH_COMPONENT;
    if (i === mr)
      return n.DEPTH_STENCIL;
    if (i === Of)
      return n.RED;
    if (i === pu)
      return n.RED_INTEGER;
    if (i === If)
      return n.RG;
    if (i === mu)
      return n.RG_INTEGER;
    if (i === gu)
      return n.RGBA_INTEGER;
    if (i === Fa || i === Ba || i === ka || i === za)
      if (o === Qe)
        if (a = e.get("WEBGL_compressed_texture_s3tc_srgb"), a !== null) {
          if (i === Fa)
            return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;
          if (i === Ba)
            return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
          if (i === ka)
            return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
          if (i === za)
            return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
        } else
          return null;
      else if (a = e.get("WEBGL_compressed_texture_s3tc"), a !== null) {
        if (i === Fa)
          return a.COMPRESSED_RGB_S3TC_DXT1_EXT;
        if (i === Ba)
          return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;
        if (i === ka)
          return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;
        if (i === za)
          return a.COMPRESSED_RGBA_S3TC_DXT5_EXT;
      } else
        return null;
    if (i === Hs || i === Vs || i === Gs || i === Ws)
      if (a = e.get("WEBGL_compressed_texture_pvrtc"), a !== null) {
        if (i === Hs)
          return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
        if (i === Vs)
          return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
        if (i === Gs)
          return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
        if (i === Ws)
          return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
      } else
        return null;
    if (i === vu)
      return a = e.get("WEBGL_compressed_texture_etc1"), a !== null ? a.COMPRESSED_RGB_ETC1_WEBGL : null;
    if (i === js || i === Xs)
      if (a = e.get("WEBGL_compressed_texture_etc"), a !== null) {
        if (i === js)
          return o === Qe ? a.COMPRESSED_SRGB8_ETC2 : a.COMPRESSED_RGB8_ETC2;
        if (i === Xs)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : a.COMPRESSED_RGBA8_ETC2_EAC;
      } else
        return null;
    if (i === $s || i === qs || i === Ys || i === Ks || i === Zs || i === Js || i === Qs || i === ec || i === tc || i === nc || i === ic || i === rc || i === ac || i === oc)
      if (a = e.get("WEBGL_compressed_texture_astc"), a !== null) {
        if (i === $s)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : a.COMPRESSED_RGBA_ASTC_4x4_KHR;
        if (i === qs)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : a.COMPRESSED_RGBA_ASTC_5x4_KHR;
        if (i === Ys)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : a.COMPRESSED_RGBA_ASTC_5x5_KHR;
        if (i === Ks)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : a.COMPRESSED_RGBA_ASTC_6x5_KHR;
        if (i === Zs)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : a.COMPRESSED_RGBA_ASTC_6x6_KHR;
        if (i === Js)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : a.COMPRESSED_RGBA_ASTC_8x5_KHR;
        if (i === Qs)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : a.COMPRESSED_RGBA_ASTC_8x6_KHR;
        if (i === ec)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : a.COMPRESSED_RGBA_ASTC_8x8_KHR;
        if (i === tc)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : a.COMPRESSED_RGBA_ASTC_10x5_KHR;
        if (i === nc)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : a.COMPRESSED_RGBA_ASTC_10x6_KHR;
        if (i === ic)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : a.COMPRESSED_RGBA_ASTC_10x8_KHR;
        if (i === rc)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : a.COMPRESSED_RGBA_ASTC_10x10_KHR;
        if (i === ac)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : a.COMPRESSED_RGBA_ASTC_12x10_KHR;
        if (i === oc)
          return o === Qe ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : a.COMPRESSED_RGBA_ASTC_12x12_KHR;
      } else
        return null;
    if (i === Ha || i === sc || i === cc)
      if (a = e.get("EXT_texture_compression_bptc"), a !== null) {
        if (i === Ha)
          return o === Qe ? a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : a.COMPRESSED_RGBA_BPTC_UNORM_EXT;
        if (i === sc)
          return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
        if (i === cc)
          return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
      } else
        return null;
    if (i === Nf || i === lc || i === uc || i === hc)
      if (a = e.get("EXT_texture_compression_rgtc"), a !== null) {
        if (i === Ha)
          return a.COMPRESSED_RED_RGTC1_EXT;
        if (i === lc)
          return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;
        if (i === uc)
          return a.COMPRESSED_RED_GREEN_RGTC2_EXT;
        if (i === hc)
          return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
      } else
        return null;
    return i === br ? n.UNSIGNED_INT_24_8 : n[i] !== void 0 ? n[i] : null;
  }
  return { convert: t };
}
class s_ extends zt {
  constructor(e = []) {
    super(), this.isArrayCamera = !0, this.cameras = e;
  }
}
let Oi = class extends vt {
  constructor() {
    super(), this.isGroup = !0, this.type = "Group";
  }
};
const c_ = { type: "move" };
class fo {
  constructor() {
    this._targetRay = null, this._grip = null, this._hand = null;
  }
  getHandSpace() {
    return this._hand === null && (this._hand = new Oi(), this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand;
  }
  getTargetRaySpace() {
    return this._targetRay === null && (this._targetRay = new Oi(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new O(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new O()), this._targetRay;
  }
  getGripSpace() {
    return this._grip === null && (this._grip = new Oi(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new O(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new O()), this._grip;
  }
  dispatchEvent(e) {
    return this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), this;
  }
  connect(e) {
    if (e && e.hand) {
      const t = this._hand;
      if (t)
        for (const i of e.hand.values())
          this._getHandJoint(t, i);
    }
    return this.dispatchEvent({ type: "connected", data: e }), this;
  }
  disconnect(e) {
    return this.dispatchEvent({ type: "disconnected", data: e }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this;
  }
  update(e, t, i) {
    let r = null, a = null, o = null;
    const s = this._targetRay, c = this._grip, l = this._hand;
    if (e && t.session.visibilityState !== "visible-blurred") {
      if (l && e.hand) {
        o = !0;
        for (const v of e.hand.values()) {
          const m = t.getJointPose(v, i), f = this._getHandJoint(l, v);
          m !== null && (f.matrix.fromArray(m.transform.matrix), f.matrix.decompose(f.position, f.rotation, f.scale), f.matrixWorldNeedsUpdate = !0, f.jointRadius = m.radius), f.visible = m !== null;
        }
        const u = l.joints["index-finger-tip"], h = l.joints["thumb-tip"], d = u.position.distanceTo(h.position), p = 0.02, g = 5e-3;
        l.inputState.pinching && d > p + g ? (l.inputState.pinching = !1, this.dispatchEvent({
          type: "pinchend",
          handedness: e.handedness,
          target: this
        })) : !l.inputState.pinching && d <= p - g && (l.inputState.pinching = !0, this.dispatchEvent({
          type: "pinchstart",
          handedness: e.handedness,
          target: this
        }));
      } else
        c !== null && e.gripSpace && (a = t.getPose(e.gripSpace, i), a !== null && (c.matrix.fromArray(a.transform.matrix), c.matrix.decompose(c.position, c.rotation, c.scale), c.matrixWorldNeedsUpdate = !0, a.linearVelocity ? (c.hasLinearVelocity = !0, c.linearVelocity.copy(a.linearVelocity)) : c.hasLinearVelocity = !1, a.angularVelocity ? (c.hasAngularVelocity = !0, c.angularVelocity.copy(a.angularVelocity)) : c.hasAngularVelocity = !1));
      s !== null && (r = t.getPose(e.targetRaySpace, i), r === null && a !== null && (r = a), r !== null && (s.matrix.fromArray(r.transform.matrix), s.matrix.decompose(s.position, s.rotation, s.scale), s.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (s.hasLinearVelocity = !0, s.linearVelocity.copy(r.linearVelocity)) : s.hasLinearVelocity = !1, r.angularVelocity ? (s.hasAngularVelocity = !0, s.angularVelocity.copy(r.angularVelocity)) : s.hasAngularVelocity = !1, this.dispatchEvent(c_)));
    }
    return s !== null && (s.visible = r !== null), c !== null && (c.visible = a !== null), l !== null && (l.visible = o !== null), this;
  }
  // private method
  _getHandJoint(e, t) {
    if (e.joints[t.jointName] === void 0) {
      const i = new Oi();
      i.matrixAutoUpdate = !1, i.visible = !1, e.joints[t.jointName] = i, e.add(i);
    }
    return e.joints[t.jointName];
  }
}
const l_ = `
void main() {

	gl_Position = vec4( position, 1.0 );

}`, u_ = `
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;

void main() {

	vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );

	if ( coord.x >= 1.0 ) {

		gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;

	} else {

		gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;

	}

}`;
class h_ {
  constructor() {
    this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0;
  }
  init(e, t, i) {
    if (this.texture === null) {
      const r = new Tt(), a = e.properties.get(r);
      a.__webglTexture = t.texture, (t.depthNear != i.depthNear || t.depthFar != i.depthFar) && (this.depthNear = t.depthNear, this.depthFar = t.depthFar), this.texture = r;
    }
  }
  render(e, t) {
    if (this.texture !== null) {
      if (this.mesh === null) {
        const i = t.cameras[0].viewport, r = new sn({
          vertexShader: l_,
          fragmentShader: u_,
          uniforms: {
            depthColor: { value: this.texture },
            depthWidth: { value: i.z },
            depthHeight: { value: i.w }
          }
        });
        this.mesh = new Vt(new Sa(20, 20), r);
      }
      e.render(this.mesh, t);
    }
  }
  reset() {
    this.texture = null, this.mesh = null;
  }
}
class f_ extends Qt {
  constructor(e, t) {
    super();
    const i = this;
    let r = null, a = 1, o = null, s = "local-floor", c = 1, l = null, u = null, h = null, d = null, p = null, g = null;
    const v = new h_(), m = t.getContextAttributes();
    let f = null, M = null;
    const _ = [], x = [], T = new le();
    let E = null;
    const A = new zt();
    A.layers.enable(1), A.viewport = new gt();
    const R = new zt();
    R.layers.enable(2), R.viewport = new gt();
    const w = [A, R], b = new s_();
    b.layers.enable(1), b.layers.enable(2);
    let U = null, z = null;
    this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(k) {
      let H = _[k];
      return H === void 0 && (H = new fo(), _[k] = H), H.getTargetRaySpace();
    }, this.getControllerGrip = function(k) {
      let H = _[k];
      return H === void 0 && (H = new fo(), _[k] = H), H.getGripSpace();
    }, this.getHand = function(k) {
      let H = _[k];
      return H === void 0 && (H = new fo(), _[k] = H), H.getHandSpace();
    };
    function I(k) {
      const H = x.indexOf(k.inputSource);
      if (H === -1)
        return;
      const Z = _[H];
      Z !== void 0 && (Z.update(k.inputSource, k.frame, l || o), Z.dispatchEvent({ type: k.type, data: k.inputSource }));
    }
    function L() {
      r.removeEventListener("select", I), r.removeEventListener("selectstart", I), r.removeEventListener("selectend", I), r.removeEventListener("squeeze", I), r.removeEventListener("squeezestart", I), r.removeEventListener("squeezeend", I), r.removeEventListener("end", L), r.removeEventListener("inputsourceschange", D);
      for (let k = 0; k < _.length; k++) {
        const H = x[k];
        H !== null && (x[k] = null, _[k].disconnect(H));
      }
      U = null, z = null, v.reset(), e.setRenderTarget(f), p = null, d = null, h = null, r = null, M = null, xe.stop(), i.isPresenting = !1, e.setPixelRatio(E), e.setSize(T.width, T.height, !1), i.dispatchEvent({ type: "sessionend" });
    }
    this.setFramebufferScaleFactor = function(k) {
      a = k, i.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.");
    }, this.setReferenceSpaceType = function(k) {
      s = k, i.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.");
    }, this.getReferenceSpace = function() {
      return l || o;
    }, this.setReferenceSpace = function(k) {
      l = k;
    }, this.getBaseLayer = function() {
      return d !== null ? d : p;
    }, this.getBinding = function() {
      return h;
    }, this.getFrame = function() {
      return g;
    }, this.getSession = function() {
      return r;
    }, this.setSession = async function(k) {
      if (r = k, r !== null) {
        if (f = e.getRenderTarget(), r.addEventListener("select", I), r.addEventListener("selectstart", I), r.addEventListener("selectend", I), r.addEventListener("squeeze", I), r.addEventListener("squeezestart", I), r.addEventListener("squeezeend", I), r.addEventListener("end", L), r.addEventListener("inputsourceschange", D), m.xrCompatible !== !0 && await t.makeXRCompatible(), E = e.getPixelRatio(), e.getSize(T), r.renderState.layers === void 0) {
          const H = {
            antialias: m.antialias,
            alpha: !0,
            depth: m.depth,
            stencil: m.stencil,
            framebufferScaleFactor: a
          };
          p = new XRWebGLLayer(r, t, H), r.updateRenderState({ baseLayer: p }), e.setPixelRatio(1), e.setSize(p.framebufferWidth, p.framebufferHeight, !1), M = new Vn(
            p.framebufferWidth,
            p.framebufferHeight,
            {
              format: rn,
              type: zn,
              colorSpace: e.outputColorSpace,
              stencilBuffer: m.stencil
            }
          );
        } else {
          let H = null, Z = null, N = null;
          m.depth && (N = m.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, H = m.stencil ? mr : Ui, Z = m.stencil ? br : zi);
          const K = {
            colorFormat: t.RGBA8,
            depthFormat: N,
            scaleFactor: a
          };
          h = new XRWebGLBinding(r, t), d = h.createProjectionLayer(K), r.updateRenderState({ layers: [d] }), e.setPixelRatio(1), e.setSize(d.textureWidth, d.textureHeight, !1), M = new Vn(
            d.textureWidth,
            d.textureHeight,
            {
              format: rn,
              type: zn,
              depthTexture: new Lu(d.textureWidth, d.textureHeight, Z, void 0, void 0, void 0, void 0, void 0, void 0, H),
              stencilBuffer: m.stencil,
              colorSpace: e.outputColorSpace,
              samples: m.antialias ? 4 : 0
            }
          );
          const oe = e.properties.get(M);
          oe.__ignoreDepthValues = d.ignoreDepthValues;
        }
        M.isXRRenderTarget = !0, this.setFoveation(c), l = null, o = await r.requestReferenceSpace(s), xe.setContext(r), xe.start(), i.isPresenting = !0, i.dispatchEvent({ type: "sessionstart" });
      }
    }, this.getEnvironmentBlendMode = function() {
      if (r !== null)
        return r.environmentBlendMode;
    };
    function D(k) {
      for (let H = 0; H < k.removed.length; H++) {
        const Z = k.removed[H], N = x.indexOf(Z);
        N >= 0 && (x[N] = null, _[N].disconnect(Z));
      }
      for (let H = 0; H < k.added.length; H++) {
        const Z = k.added[H];
        let N = x.indexOf(Z);
        if (N === -1) {
          for (let oe = 0; oe < _.length; oe++)
            if (oe >= x.length) {
              x.push(Z), N = oe;
              break;
            } else if (x[oe] === null) {
              x[oe] = Z, N = oe;
              break;
            }
          if (N === -1)
            break;
        }
        const K = _[N];
        K && K.connect(Z);
      }
    }
    const B = new O(), te = new O();
    function W(k, H, Z) {
      B.setFromMatrixPosition(H.matrixWorld), te.setFromMatrixPosition(Z.matrixWorld);
      const N = B.distanceTo(te), K = H.projectionMatrix.elements, oe = Z.projectionMatrix.elements, fe = K[14] / (K[10] - 1), F = K[14] / (K[10] + 1), ge = (K[9] + 1) / K[5], Se = (K[9] - 1) / K[5], ze = (K[8] - 1) / K[0], Ee = (oe[8] + 1) / oe[0], Be = fe * ze, P = fe * Ee, S = N / (-ze + Ee), Y = S * -ze;
      H.matrixWorld.decompose(k.position, k.quaternion, k.scale), k.translateX(Y), k.translateZ(S), k.matrixWorld.compose(k.position, k.quaternion, k.scale), k.matrixWorldInverse.copy(k.matrixWorld).invert();
      const ee = fe + S, ne = F + S, re = Be - Y, Te = P + (N - Y), ae = ge * F / ne * ee, we = Se * F / ne * ee;
      k.projectionMatrix.makePerspective(re, Te, ae, we, ee, ne), k.projectionMatrixInverse.copy(k.projectionMatrix).invert();
    }
    function ie(k, H) {
      H === null ? k.matrixWorld.copy(k.matrix) : k.matrixWorld.multiplyMatrices(H.matrixWorld, k.matrix), k.matrixWorldInverse.copy(k.matrixWorld).invert();
    }
    this.updateCamera = function(k) {
      if (r === null)
        return;
      v.texture !== null && (k.near = v.depthNear, k.far = v.depthFar), b.near = R.near = A.near = k.near, b.far = R.far = A.far = k.far, (U !== b.near || z !== b.far) && (r.updateRenderState({
        depthNear: b.near,
        depthFar: b.far
      }), U = b.near, z = b.far, A.near = U, A.far = z, R.near = U, R.far = z, A.updateProjectionMatrix(), R.updateProjectionMatrix(), k.updateProjectionMatrix());
      const H = k.parent, Z = b.cameras;
      ie(b, H);
      for (let N = 0; N < Z.length; N++)
        ie(Z[N], H);
      Z.length === 2 ? W(b, A, R) : b.projectionMatrix.copy(A.projectionMatrix), G(k, b, H);
    };
    function G(k, H, Z) {
      Z === null ? k.matrix.copy(H.matrixWorld) : (k.matrix.copy(Z.matrixWorld), k.matrix.invert(), k.matrix.multiply(H.matrixWorld)), k.matrix.decompose(k.position, k.quaternion, k.scale), k.updateMatrixWorld(!0), k.projectionMatrix.copy(H.projectionMatrix), k.projectionMatrixInverse.copy(H.projectionMatrixInverse), k.isPerspectiveCamera && (k.fov = gr * 2 * Math.atan(1 / k.projectionMatrix.elements[5]), k.zoom = 1);
    }
    this.getCamera = function() {
      return b;
    }, this.getFoveation = function() {
      if (!(d === null && p === null))
        return c;
    }, this.setFoveation = function(k) {
      c = k, d !== null && (d.fixedFoveation = k), p !== null && p.fixedFoveation !== void 0 && (p.fixedFoveation = k);
    }, this.hasDepthSensing = function() {
      return v.texture !== null;
    };
    let Q = null;
    function se(k, H) {
      if (u = H.getViewerPose(l || o), g = H, u !== null) {
        const Z = u.views;
        p !== null && (e.setRenderTargetFramebuffer(M, p.framebuffer), e.setRenderTarget(M));
        let N = !1;
        Z.length !== b.cameras.length && (b.cameras.length = 0, N = !0);
        for (let oe = 0; oe < Z.length; oe++) {
          const fe = Z[oe];
          let F = null;
          if (p !== null)
            F = p.getViewport(fe);
          else {
            const Se = h.getViewSubImage(d, fe);
            F = Se.viewport, oe === 0 && (e.setRenderTargetTextures(
              M,
              Se.colorTexture,
              d.ignoreDepthValues ? void 0 : Se.depthStencilTexture
            ), e.setRenderTarget(M));
          }
          let ge = w[oe];
          ge === void 0 && (ge = new zt(), ge.layers.enable(oe), ge.viewport = new gt(), w[oe] = ge), ge.matrix.fromArray(fe.transform.matrix), ge.matrix.decompose(ge.position, ge.quaternion, ge.scale), ge.projectionMatrix.fromArray(fe.projectionMatrix), ge.projectionMatrixInverse.copy(ge.projectionMatrix).invert(), ge.viewport.set(F.x, F.y, F.width, F.height), oe === 0 && (b.matrix.copy(ge.matrix), b.matrix.decompose(b.position, b.quaternion, b.scale)), N === !0 && b.cameras.push(ge);
        }
        const K = r.enabledFeatures;
        if (K && K.includes("depth-sensing")) {
          const oe = h.getDepthInformation(Z[0]);
          oe && oe.isValid && oe.texture && v.init(e, oe, r.renderState);
        }
      }
      for (let Z = 0; Z < _.length; Z++) {
        const N = x[Z], K = _[Z];
        N !== null && K !== void 0 && K.update(N, H, l || o);
      }
      v.render(e, b), Q && Q(k, H), H.detectedPlanes && i.dispatchEvent({ type: "planesdetected", data: H }), g = null;
    }
    const xe = new Pu();
    xe.setAnimationLoop(se), this.setAnimationLoop = function(k) {
      Q = k;
    }, this.dispose = function() {
    };
  }
}
const ei = /* @__PURE__ */ new on(), d_ = /* @__PURE__ */ new Je();
function p_(n, e) {
  function t(m, f) {
    m.matrixAutoUpdate === !0 && m.updateMatrix(), f.value.copy(m.matrix);
  }
  function i(m, f) {
    f.color.getRGB(m.fogColor.value, Tu(n)), f.isFog ? (m.fogNear.value = f.near, m.fogFar.value = f.far) : f.isFogExp2 && (m.fogDensity.value = f.density);
  }
  function r(m, f, M, _, x) {
    f.isMeshBasicMaterial || f.isMeshLambertMaterial ? a(m, f) : f.isMeshToonMaterial ? (a(m, f), h(m, f)) : f.isMeshPhongMaterial ? (a(m, f), u(m, f)) : f.isMeshStandardMaterial ? (a(m, f), d(m, f), f.isMeshPhysicalMaterial && p(m, f, x)) : f.isMeshMatcapMaterial ? (a(m, f), g(m, f)) : f.isMeshDepthMaterial ? a(m, f) : f.isMeshDistanceMaterial ? (a(m, f), v(m, f)) : f.isMeshNormalMaterial ? a(m, f) : f.isLineBasicMaterial ? (o(m, f), f.isLineDashedMaterial && s(m, f)) : f.isPointsMaterial ? c(m, f, M, _) : f.isSpriteMaterial ? l(m, f) : f.isShadowMaterial ? (m.color.value.copy(f.color), m.opacity.value = f.opacity) : f.isShaderMaterial && (f.uniformsNeedUpdate = !1);
  }
  function a(m, f) {
    m.opacity.value = f.opacity, f.color && m.diffuse.value.copy(f.color), f.emissive && m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity), f.map && (m.map.value = f.map, t(f.map, m.mapTransform)), f.alphaMap && (m.alphaMap.value = f.alphaMap, t(f.alphaMap, m.alphaMapTransform)), f.bumpMap && (m.bumpMap.value = f.bumpMap, t(f.bumpMap, m.bumpMapTransform), m.bumpScale.value = f.bumpScale, f.side === wt && (m.bumpScale.value *= -1)), f.normalMap && (m.normalMap.value = f.normalMap, t(f.normalMap, m.normalMapTransform), m.normalScale.value.copy(f.normalScale), f.side === wt && m.normalScale.value.negate()), f.displacementMap && (m.displacementMap.value = f.displacementMap, t(f.displacementMap, m.displacementMapTransform), m.displacementScale.value = f.displacementScale, m.displacementBias.value = f.displacementBias), f.emissiveMap && (m.emissiveMap.value = f.emissiveMap, t(f.emissiveMap, m.emissiveMapTransform)), f.specularMap && (m.specularMap.value = f.specularMap, t(f.specularMap, m.specularMapTransform)), f.alphaTest > 0 && (m.alphaTest.value = f.alphaTest);
    const M = e.get(f), _ = M.envMap, x = M.envMapRotation;
    if (_ && (m.envMap.value = _, ei.copy(x), ei.x *= -1, ei.y *= -1, ei.z *= -1, _.isCubeTexture && _.isRenderTargetTexture === !1 && (ei.y *= -1, ei.z *= -1), m.envMapRotation.value.setFromMatrix4(d_.makeRotationFromEuler(ei)), m.flipEnvMap.value = _.isCubeTexture && _.isRenderTargetTexture === !1 ? -1 : 1, m.reflectivity.value = f.reflectivity, m.ior.value = f.ior, m.refractionRatio.value = f.refractionRatio), f.lightMap) {
      m.lightMap.value = f.lightMap;
      const T = n._useLegacyLights === !0 ? Math.PI : 1;
      m.lightMapIntensity.value = f.lightMapIntensity * T, t(f.lightMap, m.lightMapTransform);
    }
    f.aoMap && (m.aoMap.value = f.aoMap, m.aoMapIntensity.value = f.aoMapIntensity, t(f.aoMap, m.aoMapTransform));
  }
  function o(m, f) {
    m.diffuse.value.copy(f.color), m.opacity.value = f.opacity, f.map && (m.map.value = f.map, t(f.map, m.mapTransform));
  }
  function s(m, f) {
    m.dashSize.value = f.dashSize, m.totalSize.value = f.dashSize + f.gapSize, m.scale.value = f.scale;
  }
  function c(m, f, M, _) {
    m.diffuse.value.copy(f.color), m.opacity.value = f.opacity, m.size.value = f.size * M, m.scale.value = _ * 0.5, f.map && (m.map.value = f.map, t(f.map, m.uvTransform)), f.alphaMap && (m.alphaMap.value = f.alphaMap, t(f.alphaMap, m.alphaMapTransform)), f.alphaTest > 0 && (m.alphaTest.value = f.alphaTest);
  }
  function l(m, f) {
    m.diffuse.value.copy(f.color), m.opacity.value = f.opacity, m.rotation.value = f.rotation, f.map && (m.map.value = f.map, t(f.map, m.mapTransform)), f.alphaMap && (m.alphaMap.value = f.alphaMap, t(f.alphaMap, m.alphaMapTransform)), f.alphaTest > 0 && (m.alphaTest.value = f.alphaTest);
  }
  function u(m, f) {
    m.specular.value.copy(f.specular), m.shininess.value = Math.max(f.shininess, 1e-4);
  }
  function h(m, f) {
    f.gradientMap && (m.gradientMap.value = f.gradientMap);
  }
  function d(m, f) {
    m.metalness.value = f.metalness, f.metalnessMap && (m.metalnessMap.value = f.metalnessMap, t(f.metalnessMap, m.metalnessMapTransform)), m.roughness.value = f.roughness, f.roughnessMap && (m.roughnessMap.value = f.roughnessMap, t(f.roughnessMap, m.roughnessMapTransform)), f.envMap && (m.envMapIntensity.value = f.envMapIntensity);
  }
  function p(m, f, M) {
    m.ior.value = f.ior, f.sheen > 0 && (m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen), m.sheenRoughness.value = f.sheenRoughness, f.sheenColorMap && (m.sheenColorMap.value = f.sheenColorMap, t(f.sheenColorMap, m.sheenColorMapTransform)), f.sheenRoughnessMap && (m.sheenRoughnessMap.value = f.sheenRoughnessMap, t(f.sheenRoughnessMap, m.sheenRoughnessMapTransform))), f.clearcoat > 0 && (m.clearcoat.value = f.clearcoat, m.clearcoatRoughness.value = f.clearcoatRoughness, f.clearcoatMap && (m.clearcoatMap.value = f.clearcoatMap, t(f.clearcoatMap, m.clearcoatMapTransform)), f.clearcoatRoughnessMap && (m.clearcoatRoughnessMap.value = f.clearcoatRoughnessMap, t(f.clearcoatRoughnessMap, m.clearcoatRoughnessMapTransform)), f.clearcoatNormalMap && (m.clearcoatNormalMap.value = f.clearcoatNormalMap, t(f.clearcoatNormalMap, m.clearcoatNormalMapTransform), m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale), f.side === wt && m.clearcoatNormalScale.value.negate())), f.iridescence > 0 && (m.iridescence.value = f.iridescence, m.iridescenceIOR.value = f.iridescenceIOR, m.iridescenceThicknessMinimum.value = f.iridescenceThicknessRange[0], m.iridescenceThicknessMaximum.value = f.iridescenceThicknessRange[1], f.iridescenceMap && (m.iridescenceMap.value = f.iridescenceMap, t(f.iridescenceMap, m.iridescenceMapTransform)), f.iridescenceThicknessMap && (m.iridescenceThicknessMap.value = f.iridescenceThicknessMap, t(f.iridescenceThicknessMap, m.iridescenceThicknessMapTransform))), f.transmission > 0 && (m.transmission.value = f.transmission, m.transmissionSamplerMap.value = M.texture, m.transmissionSamplerSize.value.set(M.width, M.height), f.transmissionMap && (m.transmissionMap.value = f.transmissionMap, t(f.transmissionMap, m.transmissionMapTransform)), m.thickness.value = f.thickness, f.thicknessMap && (m.thicknessMap.value = f.thicknessMap, t(f.thicknessMap, m.thicknessMapTransform)), m.attenuationDistance.value = f.attenuationDistance, m.attenuationColor.value.copy(f.attenuationColor)), f.anisotropy > 0 && (m.anisotropyVector.value.set(f.anisotropy * Math.cos(f.anisotropyRotation), f.anisotropy * Math.sin(f.anisotropyRotation)), f.anisotropyMap && (m.anisotropyMap.value = f.anisotropyMap, t(f.anisotropyMap, m.anisotropyMapTransform))), m.specularIntensity.value = f.specularIntensity, m.specularColor.value.copy(f.specularColor), f.specularColorMap && (m.specularColorMap.value = f.specularColorMap, t(f.specularColorMap, m.specularColorMapTransform)), f.specularIntensityMap && (m.specularIntensityMap.value = f.specularIntensityMap, t(f.specularIntensityMap, m.specularIntensityMapTransform));
  }
  function g(m, f) {
    f.matcap && (m.matcap.value = f.matcap);
  }
  function v(m, f) {
    const M = e.get(f).light;
    m.referencePosition.value.setFromMatrixPosition(M.matrixWorld), m.nearDistance.value = M.shadow.camera.near, m.farDistance.value = M.shadow.camera.far;
  }
  return {
    refreshFogUniforms: i,
    refreshMaterialUniforms: r
  };
}
function m_(n, e, t, i) {
  let r = {}, a = {}, o = [];
  const s = n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);
  function c(M, _) {
    const x = _.program;
    i.uniformBlockBinding(M, x);
  }
  function l(M, _) {
    let x = r[M.id];
    x === void 0 && (g(M), x = u(M), r[M.id] = x, M.addEventListener("dispose", m));
    const T = _.program;
    i.updateUBOMapping(M, T);
    const E = e.render.frame;
    a[M.id] !== E && (d(M), a[M.id] = E);
  }
  function u(M) {
    const _ = h();
    M.__bindingPointIndex = _;
    const x = n.createBuffer(), T = M.__size, E = M.usage;
    return n.bindBuffer(n.UNIFORM_BUFFER, x), n.bufferData(n.UNIFORM_BUFFER, T, E), n.bindBuffer(n.UNIFORM_BUFFER, null), n.bindBufferBase(n.UNIFORM_BUFFER, _, x), x;
  }
  function h() {
    for (let M = 0; M < s; M++)
      if (o.indexOf(M) === -1)
        return o.push(M), M;
    return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0;
  }
  function d(M) {
    const _ = r[M.id], x = M.uniforms, T = M.__cache;
    n.bindBuffer(n.UNIFORM_BUFFER, _);
    for (let E = 0, A = x.length; E < A; E++) {
      const R = Array.isArray(x[E]) ? x[E] : [x[E]];
      for (let w = 0, b = R.length; w < b; w++) {
        const U = R[w];
        if (p(U, E, w, T) === !0) {
          const z = U.__offset, I = Array.isArray(U.value) ? U.value : [U.value];
          let L = 0;
          for (let D = 0; D < I.length; D++) {
            const B = I[D], te = v(B);
            typeof B == "number" || typeof B == "boolean" ? (U.__data[0] = B, n.bufferSubData(n.UNIFORM_BUFFER, z + L, U.__data)) : B.isMatrix3 ? (U.__data[0] = B.elements[0], U.__data[1] = B.elements[1], U.__data[2] = B.elements[2], U.__data[3] = 0, U.__data[4] = B.elements[3], U.__data[5] = B.elements[4], U.__data[6] = B.elements[5], U.__data[7] = 0, U.__data[8] = B.elements[6], U.__data[9] = B.elements[7], U.__data[10] = B.elements[8], U.__data[11] = 0) : (B.toArray(U.__data, L), L += te.storage / Float32Array.BYTES_PER_ELEMENT);
          }
          n.bufferSubData(n.UNIFORM_BUFFER, z, U.__data);
        }
      }
    }
    n.bindBuffer(n.UNIFORM_BUFFER, null);
  }
  function p(M, _, x, T) {
    const E = M.value, A = _ + "_" + x;
    if (T[A] === void 0)
      return typeof E == "number" || typeof E == "boolean" ? T[A] = E : T[A] = E.clone(), !0;
    {
      const R = T[A];
      if (typeof E == "number" || typeof E == "boolean") {
        if (R !== E)
          return T[A] = E, !0;
      } else if (R.equals(E) === !1)
        return R.copy(E), !0;
    }
    return !1;
  }
  function g(M) {
    const _ = M.uniforms;
    let x = 0;
    const T = 16;
    for (let A = 0, R = _.length; A < R; A++) {
      const w = Array.isArray(_[A]) ? _[A] : [_[A]];
      for (let b = 0, U = w.length; b < U; b++) {
        const z = w[b], I = Array.isArray(z.value) ? z.value : [z.value];
        for (let L = 0, D = I.length; L < D; L++) {
          const B = I[L], te = v(B), W = x % T;
          W !== 0 && T - W < te.boundary && (x += T - W), z.__data = new Float32Array(te.storage / Float32Array.BYTES_PER_ELEMENT), z.__offset = x, x += te.storage;
        }
      }
    }
    const E = x % T;
    return E > 0 && (x += T - E), M.__size = x, M.__cache = {}, this;
  }
  function v(M) {
    const _ = {
      boundary: 0,
      // bytes
      storage: 0
      // bytes
    };
    return typeof M == "number" || typeof M == "boolean" ? (_.boundary = 4, _.storage = 4) : M.isVector2 ? (_.boundary = 8, _.storage = 8) : M.isVector3 || M.isColor ? (_.boundary = 16, _.storage = 12) : M.isVector4 ? (_.boundary = 16, _.storage = 16) : M.isMatrix3 ? (_.boundary = 48, _.storage = 48) : M.isMatrix4 ? (_.boundary = 64, _.storage = 64) : M.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", M), _;
  }
  function m(M) {
    const _ = M.target;
    _.removeEventListener("dispose", m);
    const x = o.indexOf(_.__bindingPointIndex);
    o.splice(x, 1), n.deleteBuffer(r[_.id]), delete r[_.id], delete a[_.id];
  }
  function f() {
    for (const M in r)
      n.deleteBuffer(r[M]);
    o = [], r = {}, a = {};
  }
  return {
    bind: c,
    update: l,
    dispose: f
  };
}
class g_ {
  constructor(e = {}) {
    const {
      canvas: t = cd(),
      context: i = null,
      depth: r = !0,
      stencil: a = !1,
      alpha: o = !1,
      antialias: s = !1,
      premultipliedAlpha: c = !0,
      preserveDrawingBuffer: l = !1,
      powerPreference: u = "default",
      failIfMajorPerformanceCaveat: h = !1
    } = e;
    this.isWebGLRenderer = !0;
    let d;
    if (i !== null) {
      if (typeof WebGLRenderingContext < "u" && i instanceof WebGLRenderingContext)
        throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");
      d = i.getContextAttributes().alpha;
    } else
      d = o;
    const p = new Uint32Array(4), g = new Int32Array(4);
    let v = null, m = null;
    const f = [], M = [];
    this.domElement = t, this.debug = {
      /**
       * Enables error checking and reporting when shader programs are being compiled
       * @type {boolean}
       */
      checkShaderErrors: !0,
      /**
       * Callback for custom error reporting.
       * @type {?Function}
       */
      onShaderError: null
    }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this._outputColorSpace = $t, this._useLegacyLights = !1, this.toneMapping = kn, this.toneMappingExposure = 1;
    const _ = this;
    let x = !1, T = 0, E = 0, A = null, R = -1, w = null;
    const b = new gt(), U = new gt();
    let z = null;
    const I = new We(0);
    let L = 0, D = t.width, B = t.height, te = 1, W = null, ie = null;
    const G = new gt(0, 0, D, B), Q = new gt(0, 0, D, B);
    let se = !1;
    const xe = new hs();
    let k = !1, H = !1;
    const Z = new Je(), N = new le(), K = new O(), oe = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 };
    function fe() {
      return A === null ? te : 1;
    }
    let F = i;
    function ge(C, V) {
      const $ = t.getContext(C, V);
      return $ !== null ? $ : null;
    }
    try {
      const C = {
        alpha: !0,
        depth: r,
        stencil: a,
        antialias: s,
        premultipliedAlpha: c,
        preserveDrawingBuffer: l,
        powerPreference: u,
        failIfMajorPerformanceCaveat: h
      };
      if ("setAttribute" in t && t.setAttribute("data-engine", `three.js r${_a}`), t.addEventListener("webglcontextlost", j, !1), t.addEventListener("webglcontextrestored", J, !1), t.addEventListener("webglcontextcreationerror", ce, !1), F === null) {
        const V = "webgl2";
        if (F = ge(V, C), F === null)
          throw ge(V) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context.");
      }
    } catch (C) {
      throw console.error("THREE.WebGLRenderer: " + C.message), C;
    }
    let Se, ze, Ee, Be, P, S, Y, ee, ne, re, Te, ae, we, Ae, ue, pe, Pe, ve, _e, He, Ve, $e, je, qe;
    function be() {
      Se = new Eg(F), Se.init(), ze = new _g(F, Se, e), $e = new o_(F, Se), Ee = new r_(F), Be = new Ag(F), P = new Wv(), S = new a_(F, Se, Ee, P, ze, $e, Be), Y = new xg(_), ee = new Sg(_), ne = new Od(F), je = new gg(F, ne), re = new wg(F, ne, Be, je), Te = new Rg(F, re, ne, Be), _e = new Cg(F, ze, S), pe = new yg(P), ae = new Gv(_, Y, ee, Se, ze, je, pe), we = new p_(_, P), Ae = new Xv(), ue = new Jv(Se), ve = new mg(_, Y, ee, Ee, Te, d, c), Pe = new i_(_, Te, ze), qe = new m_(F, Be, ze, Ee), He = new vg(F, Se, Be), Ve = new Tg(F, Se, Be), Be.programs = ae.programs, _.capabilities = ze, _.extensions = Se, _.properties = P, _.renderLists = Ae, _.shadowMap = Pe, _.state = Ee, _.info = Be;
    }
    be();
    const y = new f_(_, F);
    this.xr = y, this.getContext = function() {
      return F;
    }, this.getContextAttributes = function() {
      return F.getContextAttributes();
    }, this.forceContextLoss = function() {
      const C = Se.get("WEBGL_lose_context");
      C && C.loseContext();
    }, this.forceContextRestore = function() {
      const C = Se.get("WEBGL_lose_context");
      C && C.restoreContext();
    }, this.getPixelRatio = function() {
      return te;
    }, this.setPixelRatio = function(C) {
      C !== void 0 && (te = C, this.setSize(D, B, !1));
    }, this.getSize = function(C) {
      return C.set(D, B);
    }, this.setSize = function(C, V, $ = !0) {
      if (y.isPresenting) {
        console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
        return;
      }
      D = C, B = V, t.width = Math.floor(C * te), t.height = Math.floor(V * te), $ === !0 && (t.style.width = C + "px", t.style.height = V + "px"), this.setViewport(0, 0, C, V);
    }, this.getDrawingBufferSize = function(C) {
      return C.set(D * te, B * te).floor();
    }, this.setDrawingBufferSize = function(C, V, $) {
      D = C, B = V, te = $, t.width = Math.floor(C * $), t.height = Math.floor(V * $), this.setViewport(0, 0, C, V);
    }, this.getCurrentViewport = function(C) {
      return C.copy(b);
    }, this.getViewport = function(C) {
      return C.copy(G);
    }, this.setViewport = function(C, V, $, q) {
      C.isVector4 ? G.set(C.x, C.y, C.z, C.w) : G.set(C, V, $, q), Ee.viewport(b.copy(G).multiplyScalar(te).round());
    }, this.getScissor = function(C) {
      return C.copy(Q);
    }, this.setScissor = function(C, V, $, q) {
      C.isVector4 ? Q.set(C.x, C.y, C.z, C.w) : Q.set(C, V, $, q), Ee.scissor(U.copy(Q).multiplyScalar(te).round());
    }, this.getScissorTest = function() {
      return se;
    }, this.setScissorTest = function(C) {
      Ee.setScissorTest(se = C);
    }, this.setOpaqueSort = function(C) {
      W = C;
    }, this.setTransparentSort = function(C) {
      ie = C;
    }, this.getClearColor = function(C) {
      return C.copy(ve.getClearColor());
    }, this.setClearColor = function() {
      ve.setClearColor.apply(ve, arguments);
    }, this.getClearAlpha = function() {
      return ve.getClearAlpha();
    }, this.setClearAlpha = function() {
      ve.setClearAlpha.apply(ve, arguments);
    }, this.clear = function(C = !0, V = !0, $ = !0) {
      let q = 0;
      if (C) {
        let X = !1;
        if (A !== null) {
          const de = A.texture.format;
          X = de === gu || de === mu || de === pu;
        }
        if (X) {
          const de = A.texture.type, Me = de === zn || de === zi || de === uu || de === br || de === fu || de === du, Re = ve.getClearColor(), Le = ve.getClearAlpha(), Oe = Re.r, De = Re.g, Ie = Re.b;
          Me ? (p[0] = Oe, p[1] = De, p[2] = Ie, p[3] = Le, F.clearBufferuiv(F.COLOR, 0, p)) : (g[0] = Oe, g[1] = De, g[2] = Ie, g[3] = Le, F.clearBufferiv(F.COLOR, 0, g));
        } else
          q |= F.COLOR_BUFFER_BIT;
      }
      V && (q |= F.DEPTH_BUFFER_BIT), $ && (q |= F.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), F.clear(q);
    }, this.clearColor = function() {
      this.clear(!0, !1, !1);
    }, this.clearDepth = function() {
      this.clear(!1, !0, !1);
    }, this.clearStencil = function() {
      this.clear(!1, !1, !0);
    }, this.dispose = function() {
      t.removeEventListener("webglcontextlost", j, !1), t.removeEventListener("webglcontextrestored", J, !1), t.removeEventListener("webglcontextcreationerror", ce, !1), Ae.dispose(), ue.dispose(), P.dispose(), Y.dispose(), ee.dispose(), Te.dispose(), je.dispose(), qe.dispose(), ae.dispose(), y.dispose(), y.removeEventListener("sessionstart", ot), y.removeEventListener("sessionend", st), Pt.stop();
    };
    function j(C) {
      C.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), x = !0;
    }
    function J() {
      console.log("THREE.WebGLRenderer: Context Restored."), x = !1;
      const C = Be.autoReset, V = Pe.enabled, $ = Pe.autoUpdate, q = Pe.needsUpdate, X = Pe.type;
      be(), Be.autoReset = C, Pe.enabled = V, Pe.autoUpdate = $, Pe.needsUpdate = q, Pe.type = X;
    }
    function ce(C) {
      console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", C.statusMessage);
    }
    function me(C) {
      const V = C.target;
      V.removeEventListener("dispose", me), Ge(V);
    }
    function Ge(C) {
      ke(C), P.remove(C);
    }
    function ke(C) {
      const V = P.get(C).programs;
      V !== void 0 && (V.forEach(function($) {
        ae.releaseProgram($);
      }), C.isShaderMaterial && ae.releaseShaderCache(C));
    }
    this.renderBufferDirect = function(C, V, $, q, X, de) {
      V === null && (V = oe);
      const Me = X.isMesh && X.matrixWorld.determinant() < 0, Re = Fh(C, V, $, q, X);
      Ee.setMaterial(q, Me);
      let Le = $.index, Oe = 1;
      if (q.wireframe === !0) {
        if (Le = re.getWireframeAttribute($), Le === void 0)
          return;
        Oe = 2;
      }
      const De = $.drawRange, Ie = $.attributes.position;
      let at = De.start * Oe, Lt = (De.start + De.count) * Oe;
      de !== null && (at = Math.max(at, de.start * Oe), Lt = Math.min(Lt, (de.start + de.count) * Oe)), Le !== null ? (at = Math.max(at, 0), Lt = Math.min(Lt, Le.count)) : Ie != null && (at = Math.max(at, 0), Lt = Math.min(Lt, Ie.count));
      const dt = Lt - at;
      if (dt < 0 || dt === 1 / 0)
        return;
      je.setup(X, q, Re, $, Le);
      let ln, rt = He;
      if (Le !== null && (ln = ne.get(Le), rt = Ve, rt.setIndex(ln)), X.isMesh)
        q.wireframe === !0 ? (Ee.setLineWidth(q.wireframeLinewidth * fe()), rt.setMode(F.LINES)) : rt.setMode(F.TRIANGLES);
      else if (X.isLine) {
        let Ne = q.linewidth;
        Ne === void 0 && (Ne = 1), Ee.setLineWidth(Ne * fe()), X.isLineSegments ? rt.setMode(F.LINES) : X.isLineLoop ? rt.setMode(F.LINE_LOOP) : rt.setMode(F.LINE_STRIP);
      } else
        X.isPoints ? rt.setMode(F.POINTS) : X.isSprite && rt.setMode(F.TRIANGLES);
      if (X.isBatchedMesh)
        rt.renderMultiDraw(X._multiDrawStarts, X._multiDrawCounts, X._multiDrawCount);
      else if (X.isInstancedMesh)
        rt.renderInstances(at, dt, X.count);
      else if ($.isInstancedBufferGeometry) {
        const Ne = $._maxInstanceCount !== void 0 ? $._maxInstanceCount : 1 / 0, Da = Math.min($.instanceCount, Ne);
        rt.renderInstances(at, dt, Da);
      } else
        rt.render(at, dt);
    };
    function et(C, V, $) {
      C.transparent === !0 && C.side === bn && C.forceSinglePass === !1 ? (C.side = wt, C.needsUpdate = !0, wr(C, V, $), C.side = Hn, C.needsUpdate = !0, wr(C, V, $), C.side = bn) : wr(C, V, $);
    }
    this.compile = function(C, V, $ = null) {
      $ === null && ($ = C), m = ue.get($), m.init(), M.push(m), $.traverseVisible(function(X) {
        X.isLight && X.layers.test(V.layers) && (m.pushLight(X), X.castShadow && m.pushShadow(X));
      }), C !== $ && C.traverseVisible(function(X) {
        X.isLight && X.layers.test(V.layers) && (m.pushLight(X), X.castShadow && m.pushShadow(X));
      }), m.setupLights(_._useLegacyLights);
      const q = /* @__PURE__ */ new Set();
      return C.traverse(function(X) {
        const de = X.material;
        if (de)
          if (Array.isArray(de))
            for (let Me = 0; Me < de.length; Me++) {
              const Re = de[Me];
              et(Re, $, X), q.add(Re);
            }
          else
            et(de, $, X), q.add(de);
      }), M.pop(), m = null, q;
    }, this.compileAsync = function(C, V, $ = null) {
      const q = this.compile(C, V, $);
      return new Promise((X) => {
        function de() {
          if (q.forEach(function(Me) {
            P.get(Me).currentProgram.isReady() && q.delete(Me);
          }), q.size === 0) {
            X(C);
            return;
          }
          setTimeout(de, 10);
        }
        Se.get("KHR_parallel_shader_compile") !== null ? de() : setTimeout(de, 10);
      });
    };
    let ft = null;
    function Ye(C) {
      ft && ft(C);
    }
    function ot() {
      Pt.stop();
    }
    function st() {
      Pt.start();
    }
    const Pt = new Pu();
    Pt.setAnimationLoop(Ye), typeof self < "u" && Pt.setContext(self), this.setAnimationLoop = function(C) {
      ft = C, y.setAnimationLoop(C), C === null ? Pt.stop() : Pt.start();
    }, y.addEventListener("sessionstart", ot), y.addEventListener("sessionend", st), this.render = function(C, V) {
      if (V !== void 0 && V.isCamera !== !0) {
        console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
        return;
      }
      if (x === !0)
        return;
      C.matrixWorldAutoUpdate === !0 && C.updateMatrixWorld(), V.parent === null && V.matrixWorldAutoUpdate === !0 && V.updateMatrixWorld(), y.enabled === !0 && y.isPresenting === !0 && (y.cameraAutoUpdate === !0 && y.updateCamera(V), V = y.getCamera()), C.isScene === !0 && C.onBeforeRender(_, C, V, A), m = ue.get(C, M.length), m.init(), M.push(m), Z.multiplyMatrices(V.projectionMatrix, V.matrixWorldInverse), xe.setFromProjectionMatrix(Z), H = this.localClippingEnabled, k = pe.init(this.clippingPlanes, H), v = Ae.get(C, f.length), v.init(), f.push(v), Ft(C, V, 0, _.sortObjects), v.finish(), _.sortObjects === !0 && v.sort(W, ie), this.info.render.frame++, k === !0 && pe.beginShadows();
      const $ = m.state.shadowsArray;
      if (Pe.render($, C, V), k === !0 && pe.endShadows(), this.info.autoReset === !0 && this.info.reset(), (y.enabled === !1 || y.isPresenting === !1 || y.hasDepthSensing() === !1) && ve.render(v, C), m.setupLights(_._useLegacyLights), V.isArrayCamera) {
        const q = V.cameras;
        for (let X = 0, de = q.length; X < de; X++) {
          const Me = q[X];
          An(v, C, Me, Me.viewport);
        }
      } else
        An(v, C, V);
      A !== null && (S.updateMultisampleRenderTarget(A), S.updateRenderTargetMipmap(A)), C.isScene === !0 && C.onAfterRender(_, C, V), je.resetDefaultState(), R = -1, w = null, M.pop(), M.length > 0 ? m = M[M.length - 1] : m = null, f.pop(), f.length > 0 ? v = f[f.length - 1] : v = null;
    };
    function Ft(C, V, $, q) {
      if (C.visible === !1)
        return;
      if (C.layers.test(V.layers)) {
        if (C.isGroup)
          $ = C.renderOrder;
        else if (C.isLOD)
          C.autoUpdate === !0 && C.update(V);
        else if (C.isLight)
          m.pushLight(C), C.castShadow && m.pushShadow(C);
        else if (C.isSprite) {
          if (!C.frustumCulled || xe.intersectsSprite(C)) {
            q && K.setFromMatrixPosition(C.matrixWorld).applyMatrix4(Z);
            const Me = Te.update(C), Re = C.material;
            Re.visible && v.push(C, Me, Re, $, K.z, null);
          }
        } else if ((C.isMesh || C.isLine || C.isPoints) && (!C.frustumCulled || xe.intersectsObject(C))) {
          const Me = Te.update(C), Re = C.material;
          if (q && (C.boundingSphere !== void 0 ? (C.boundingSphere === null && C.computeBoundingSphere(), K.copy(C.boundingSphere.center)) : (Me.boundingSphere === null && Me.computeBoundingSphere(), K.copy(Me.boundingSphere.center)), K.applyMatrix4(C.matrixWorld).applyMatrix4(Z)), Array.isArray(Re)) {
            const Le = Me.groups;
            for (let Oe = 0, De = Le.length; Oe < De; Oe++) {
              const Ie = Le[Oe], at = Re[Ie.materialIndex];
              at && at.visible && v.push(C, Me, at, $, K.z, Ie);
            }
          } else
            Re.visible && v.push(C, Me, Re, $, K.z, null);
        }
      }
      const de = C.children;
      for (let Me = 0, Re = de.length; Me < Re; Me++)
        Ft(de[Me], V, $, q);
    }
    function An(C, V, $, q) {
      const X = C.opaque, de = C.transmissive, Me = C.transparent;
      m.setupLightsView($), k === !0 && pe.setGlobalState(_.clippingPlanes, $), de.length > 0 && hi(X, de, V, $), q && Ee.viewport(b.copy(q)), X.length > 0 && $n(X, V, $), de.length > 0 && $n(de, V, $), Me.length > 0 && $n(Me, V, $), Ee.buffers.depth.setTest(!0), Ee.buffers.depth.setMask(!0), Ee.buffers.color.setMask(!0), Ee.setPolygonOffset(!1);
    }
    function hi(C, V, $, q) {
      if (($.isScene === !0 ? $.overrideMaterial : null) !== null)
        return;
      if (m.state.transmissionRenderTarget === null) {
        m.state.transmissionRenderTarget = new Vn(1, 1, {
          generateMipmaps: !0,
          type: Se.has("EXT_color_buffer_half_float") || Se.has("EXT_color_buffer_float") ? pr : zn,
          minFilter: oi,
          samples: 4,
          stencilBuffer: a
        });
        const Oe = P.get(m.state.transmissionRenderTarget);
        Oe.__isTransmissionRenderTarget = !0;
      }
      const de = m.state.transmissionRenderTarget;
      _.getDrawingBufferSize(N), de.setSize(N.x, N.y);
      const Me = _.getRenderTarget();
      _.setRenderTarget(de), _.getClearColor(I), L = _.getClearAlpha(), L < 1 && _.setClearColor(16777215, 0.5), _.clear();
      const Re = _.toneMapping;
      _.toneMapping = kn, $n(C, $, q), S.updateMultisampleRenderTarget(de), S.updateRenderTargetMipmap(de);
      let Le = !1;
      for (let Oe = 0, De = V.length; Oe < De; Oe++) {
        const Ie = V[Oe], at = Ie.object, Lt = Ie.geometry, dt = Ie.material, ln = Ie.group;
        if (dt.side === bn && at.layers.test(q.layers)) {
          const rt = dt.side;
          dt.side = wt, dt.needsUpdate = !0, Ds(at, $, q, Lt, dt, ln), dt.side = rt, dt.needsUpdate = !0, Le = !0;
        }
      }
      Le === !0 && (S.updateMultisampleRenderTarget(de), S.updateRenderTargetMipmap(de)), _.setRenderTarget(Me), _.setClearColor(I, L), _.toneMapping = Re;
    }
    function $n(C, V, $) {
      const q = V.isScene === !0 ? V.overrideMaterial : null;
      for (let X = 0, de = C.length; X < de; X++) {
        const Me = C[X], Re = Me.object, Le = Me.geometry, Oe = q === null ? Me.material : q, De = Me.group;
        Re.layers.test($.layers) && Ds(Re, V, $, Le, Oe, De);
      }
    }
    function Ds(C, V, $, q, X, de) {
      C.onBeforeRender(_, V, $, q, X, de), C.modelViewMatrix.multiplyMatrices($.matrixWorldInverse, C.matrixWorld), C.normalMatrix.getNormalMatrix(C.modelViewMatrix), X.onBeforeRender(_, V, $, q, C, de), X.transparent === !0 && X.side === bn && X.forceSinglePass === !1 ? (X.side = wt, X.needsUpdate = !0, _.renderBufferDirect($, V, q, X, C, de), X.side = Hn, X.needsUpdate = !0, _.renderBufferDirect($, V, q, X, C, de), X.side = bn) : _.renderBufferDirect($, V, q, X, C, de), C.onAfterRender(_, V, $, q, X, de);
    }
    function wr(C, V, $) {
      V.isScene !== !0 && (V = oe);
      const q = P.get(C), X = m.state.lights, de = m.state.shadowsArray, Me = X.state.version, Re = ae.getParameters(C, X.state, de, V, $), Le = ae.getProgramCacheKey(Re);
      let Oe = q.programs;
      q.environment = C.isMeshStandardMaterial ? V.environment : null, q.fog = V.fog, q.envMap = (C.isMeshStandardMaterial ? ee : Y).get(C.envMap || q.environment), q.envMapRotation = q.environment !== null && C.envMap === null ? V.environmentRotation : C.envMapRotation, Oe === void 0 && (C.addEventListener("dispose", me), Oe = /* @__PURE__ */ new Map(), q.programs = Oe);
      let De = Oe.get(Le);
      if (De !== void 0) {
        if (q.currentProgram === De && q.lightsStateVersion === Me)
          return Is(C, Re), De;
      } else
        Re.uniforms = ae.getUniforms(C), C.onBuild($, Re, _), C.onBeforeCompile(Re, _), De = ae.acquireProgram(Re, Le), Oe.set(Le, De), q.uniforms = Re.uniforms;
      const Ie = q.uniforms;
      return (!C.isShaderMaterial && !C.isRawShaderMaterial || C.clipping === !0) && (Ie.clippingPlanes = pe.uniform), Is(C, Re), q.needsLights = kh(C), q.lightsStateVersion = Me, q.needsLights && (Ie.ambientLightColor.value = X.state.ambient, Ie.lightProbe.value = X.state.probe, Ie.directionalLights.value = X.state.directional, Ie.directionalLightShadows.value = X.state.directionalShadow, Ie.spotLights.value = X.state.spot, Ie.spotLightShadows.value = X.state.spotShadow, Ie.rectAreaLights.value = X.state.rectArea, Ie.ltc_1.value = X.state.rectAreaLTC1, Ie.ltc_2.value = X.state.rectAreaLTC2, Ie.pointLights.value = X.state.point, Ie.pointLightShadows.value = X.state.pointShadow, Ie.hemisphereLights.value = X.state.hemi, Ie.directionalShadowMap.value = X.state.directionalShadowMap, Ie.directionalShadowMatrix.value = X.state.directionalShadowMatrix, Ie.spotShadowMap.value = X.state.spotShadowMap, Ie.spotLightMatrix.value = X.state.spotLightMatrix, Ie.spotLightMap.value = X.state.spotLightMap, Ie.pointShadowMap.value = X.state.pointShadowMap, Ie.pointShadowMatrix.value = X.state.pointShadowMatrix), q.currentProgram = De, q.uniformsList = null, De;
    }
    function Os(C) {
      if (C.uniformsList === null) {
        const V = C.currentProgram.getUniforms();
        C.uniformsList = na.seqWithValue(V.seq, C.uniforms);
      }
      return C.uniformsList;
    }
    function Is(C, V) {
      const $ = P.get(C);
      $.outputColorSpace = V.outputColorSpace, $.batching = V.batching, $.instancing = V.instancing, $.instancingColor = V.instancingColor, $.instancingMorph = V.instancingMorph, $.skinning = V.skinning, $.morphTargets = V.morphTargets, $.morphNormals = V.morphNormals, $.morphColors = V.morphColors, $.morphTargetsCount = V.morphTargetsCount, $.numClippingPlanes = V.numClippingPlanes, $.numIntersection = V.numClipIntersection, $.vertexAlphas = V.vertexAlphas, $.vertexTangents = V.vertexTangents, $.toneMapping = V.toneMapping;
    }
    function Fh(C, V, $, q, X) {
      V.isScene !== !0 && (V = oe), S.resetTextureUnits();
      const de = V.fog, Me = q.isMeshStandardMaterial ? V.environment : null, Re = A === null ? _.outputColorSpace : A.isXRRenderTarget === !0 ? A.texture.colorSpace : Gn, Le = (q.isMeshStandardMaterial ? ee : Y).get(q.envMap || Me), Oe = q.vertexColors === !0 && !!$.attributes.color && $.attributes.color.itemSize === 4, De = !!$.attributes.tangent && (!!q.normalMap || q.anisotropy > 0), Ie = !!$.morphAttributes.position, at = !!$.morphAttributes.normal, Lt = !!$.morphAttributes.color;
      let dt = kn;
      q.toneMapped && (A === null || A.isXRRenderTarget === !0) && (dt = _.toneMapping);
      const ln = $.morphAttributes.position || $.morphAttributes.normal || $.morphAttributes.color, rt = ln !== void 0 ? ln.length : 0, Ne = P.get(q), Da = m.state.lights;
      if (k === !0 && (H === !0 || C !== w)) {
        const Bt = C === w && q.id === R;
        pe.setState(q, C, Bt);
      }
      let tt = !1;
      q.version === Ne.__version ? (Ne.needsLights && Ne.lightsStateVersion !== Da.state.version || Ne.outputColorSpace !== Re || X.isBatchedMesh && Ne.batching === !1 || !X.isBatchedMesh && Ne.batching === !0 || X.isInstancedMesh && Ne.instancing === !1 || !X.isInstancedMesh && Ne.instancing === !0 || X.isSkinnedMesh && Ne.skinning === !1 || !X.isSkinnedMesh && Ne.skinning === !0 || X.isInstancedMesh && Ne.instancingColor === !0 && X.instanceColor === null || X.isInstancedMesh && Ne.instancingColor === !1 && X.instanceColor !== null || X.isInstancedMesh && Ne.instancingMorph === !0 && X.morphTexture === null || X.isInstancedMesh && Ne.instancingMorph === !1 && X.morphTexture !== null || Ne.envMap !== Le || q.fog === !0 && Ne.fog !== de || Ne.numClippingPlanes !== void 0 && (Ne.numClippingPlanes !== pe.numPlanes || Ne.numIntersection !== pe.numIntersection) || Ne.vertexAlphas !== Oe || Ne.vertexTangents !== De || Ne.morphTargets !== Ie || Ne.morphNormals !== at || Ne.morphColors !== Lt || Ne.toneMapping !== dt || Ne.morphTargetsCount !== rt) && (tt = !0) : (tt = !0, Ne.__version = q.version);
      let qn = Ne.currentProgram;
      tt === !0 && (qn = wr(q, V, X));
      let Ns = !1, qi = !1, Oa = !1;
      const _t = qn.getUniforms(), Cn = Ne.uniforms;
      if (Ee.useProgram(qn.program) && (Ns = !0, qi = !0, Oa = !0), q.id !== R && (R = q.id, qi = !0), Ns || w !== C) {
        _t.setValue(F, "projectionMatrix", C.projectionMatrix), _t.setValue(F, "viewMatrix", C.matrixWorldInverse);
        const Bt = _t.map.cameraPosition;
        Bt !== void 0 && Bt.setValue(F, K.setFromMatrixPosition(C.matrixWorld)), ze.logarithmicDepthBuffer && _t.setValue(
          F,
          "logDepthBufFC",
          2 / (Math.log(C.far + 1) / Math.LN2)
        ), (q.isMeshPhongMaterial || q.isMeshToonMaterial || q.isMeshLambertMaterial || q.isMeshBasicMaterial || q.isMeshStandardMaterial || q.isShaderMaterial) && _t.setValue(F, "isOrthographic", C.isOrthographicCamera === !0), w !== C && (w = C, qi = !0, Oa = !0);
      }
      if (X.isSkinnedMesh) {
        _t.setOptional(F, X, "bindMatrix"), _t.setOptional(F, X, "bindMatrixInverse");
        const Bt = X.skeleton;
        Bt && (Bt.boneTexture === null && Bt.computeBoneTexture(), _t.setValue(F, "boneTexture", Bt.boneTexture, S));
      }
      X.isBatchedMesh && (_t.setOptional(F, X, "batchingTexture"), _t.setValue(F, "batchingTexture", X._matricesTexture, S));
      const Ia = $.morphAttributes;
      if ((Ia.position !== void 0 || Ia.normal !== void 0 || Ia.color !== void 0) && _e.update(X, $, qn), (qi || Ne.receiveShadow !== X.receiveShadow) && (Ne.receiveShadow = X.receiveShadow, _t.setValue(F, "receiveShadow", X.receiveShadow)), q.isMeshGouraudMaterial && q.envMap !== null && (Cn.envMap.value = Le, Cn.flipEnvMap.value = Le.isCubeTexture && Le.isRenderTargetTexture === !1 ? -1 : 1), q.isMeshStandardMaterial && q.envMap === null && V.environment !== null && (Cn.envMapIntensity.value = V.environmentIntensity), qi && (_t.setValue(F, "toneMappingExposure", _.toneMappingExposure), Ne.needsLights && Bh(Cn, Oa), de && q.fog === !0 && we.refreshFogUniforms(Cn, de), we.refreshMaterialUniforms(Cn, q, te, B, m.state.transmissionRenderTarget), na.upload(F, Os(Ne), Cn, S)), q.isShaderMaterial && q.uniformsNeedUpdate === !0 && (na.upload(F, Os(Ne), Cn, S), q.uniformsNeedUpdate = !1), q.isSpriteMaterial && _t.setValue(F, "center", X.center), _t.setValue(F, "modelViewMatrix", X.modelViewMatrix), _t.setValue(F, "normalMatrix", X.normalMatrix), _t.setValue(F, "modelMatrix", X.matrixWorld), q.isShaderMaterial || q.isRawShaderMaterial) {
        const Bt = q.uniformsGroups;
        for (let Na = 0, zh = Bt.length; Na < zh; Na++) {
          const Us = Bt[Na];
          qe.update(Us, qn), qe.bind(Us, qn);
        }
      }
      return qn;
    }
    function Bh(C, V) {
      C.ambientLightColor.needsUpdate = V, C.lightProbe.needsUpdate = V, C.directionalLights.needsUpdate = V, C.directionalLightShadows.needsUpdate = V, C.pointLights.needsUpdate = V, C.pointLightShadows.needsUpdate = V, C.spotLights.needsUpdate = V, C.spotLightShadows.needsUpdate = V, C.rectAreaLights.needsUpdate = V, C.hemisphereLights.needsUpdate = V;
    }
    function kh(C) {
      return C.isMeshLambertMaterial || C.isMeshToonMaterial || C.isMeshPhongMaterial || C.isMeshStandardMaterial || C.isShadowMaterial || C.isShaderMaterial && C.lights === !0;
    }
    this.getActiveCubeFace = function() {
      return T;
    }, this.getActiveMipmapLevel = function() {
      return E;
    }, this.getRenderTarget = function() {
      return A;
    }, this.setRenderTargetTextures = function(C, V, $) {
      P.get(C.texture).__webglTexture = V, P.get(C.depthTexture).__webglTexture = $;
      const q = P.get(C);
      q.__hasExternalTextures = !0, q.__autoAllocateDepthBuffer = $ === void 0, q.__autoAllocateDepthBuffer || Se.has("WEBGL_multisampled_render_to_texture") === !0 && (console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"), q.__useRenderToTexture = !1);
    }, this.setRenderTargetFramebuffer = function(C, V) {
      const $ = P.get(C);
      $.__webglFramebuffer = V, $.__useDefaultFramebuffer = V === void 0;
    }, this.setRenderTarget = function(C, V = 0, $ = 0) {
      A = C, T = V, E = $;
      let q = !0, X = null, de = !1, Me = !1;
      if (C) {
        const Le = P.get(C);
        Le.__useDefaultFramebuffer !== void 0 ? (Ee.bindFramebuffer(F.FRAMEBUFFER, null), q = !1) : Le.__webglFramebuffer === void 0 ? S.setupRenderTarget(C) : Le.__hasExternalTextures && S.rebindTextures(C, P.get(C.texture).__webglTexture, P.get(C.depthTexture).__webglTexture);
        const Oe = C.texture;
        (Oe.isData3DTexture || Oe.isDataArrayTexture || Oe.isCompressedArrayTexture) && (Me = !0);
        const De = P.get(C).__webglFramebuffer;
        C.isWebGLCubeRenderTarget ? (Array.isArray(De[V]) ? X = De[V][$] : X = De[V], de = !0) : C.samples > 0 && S.useMultisampledRTT(C) === !1 ? X = P.get(C).__webglMultisampledFramebuffer : Array.isArray(De) ? X = De[$] : X = De, b.copy(C.viewport), U.copy(C.scissor), z = C.scissorTest;
      } else
        b.copy(G).multiplyScalar(te).floor(), U.copy(Q).multiplyScalar(te).floor(), z = se;
      if (Ee.bindFramebuffer(F.FRAMEBUFFER, X) && q && Ee.drawBuffers(C, X), Ee.viewport(b), Ee.scissor(U), Ee.setScissorTest(z), de) {
        const Le = P.get(C.texture);
        F.framebufferTexture2D(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0, F.TEXTURE_CUBE_MAP_POSITIVE_X + V, Le.__webglTexture, $);
      } else if (Me) {
        const Le = P.get(C.texture), Oe = V || 0;
        F.framebufferTextureLayer(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0, Le.__webglTexture, $ || 0, Oe);
      }
      R = -1;
    }, this.readRenderTargetPixels = function(C, V, $, q, X, de, Me) {
      if (!(C && C.isWebGLRenderTarget)) {
        console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
        return;
      }
      let Re = P.get(C).__webglFramebuffer;
      if (C.isWebGLCubeRenderTarget && Me !== void 0 && (Re = Re[Me]), Re) {
        Ee.bindFramebuffer(F.FRAMEBUFFER, Re);
        try {
          const Le = C.texture, Oe = Le.format, De = Le.type;
          if (Oe !== rn && $e.convert(Oe) !== F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
            return;
          }
          const Ie = De === pr && (Se.has("EXT_color_buffer_half_float") || Se.has("EXT_color_buffer_float"));
          if (De !== zn && $e.convert(De) !== F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)
          De !== Bn && !Ie) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
            return;
          }
          V >= 0 && V <= C.width - q && $ >= 0 && $ <= C.height - X && F.readPixels(V, $, q, X, $e.convert(Oe), $e.convert(De), de);
        } finally {
          const Le = A !== null ? P.get(A).__webglFramebuffer : null;
          Ee.bindFramebuffer(F.FRAMEBUFFER, Le);
        }
      }
    }, this.copyFramebufferToTexture = function(C, V, $ = 0) {
      const q = Math.pow(2, -$), X = Math.floor(V.image.width * q), de = Math.floor(V.image.height * q);
      S.setTexture2D(V, 0), F.copyTexSubImage2D(F.TEXTURE_2D, $, 0, 0, C.x, C.y, X, de), Ee.unbindTexture();
    }, this.copyTextureToTexture = function(C, V, $, q = 0) {
      const X = V.image.width, de = V.image.height, Me = $e.convert($.format), Re = $e.convert($.type);
      S.setTexture2D($, 0), F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL, $.flipY), F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL, $.premultiplyAlpha), F.pixelStorei(F.UNPACK_ALIGNMENT, $.unpackAlignment), V.isDataTexture ? F.texSubImage2D(F.TEXTURE_2D, q, C.x, C.y, X, de, Me, Re, V.image.data) : V.isCompressedTexture ? F.compressedTexSubImage2D(F.TEXTURE_2D, q, C.x, C.y, V.mipmaps[0].width, V.mipmaps[0].height, Me, V.mipmaps[0].data) : F.texSubImage2D(F.TEXTURE_2D, q, C.x, C.y, Me, Re, V.image), q === 0 && $.generateMipmaps && F.generateMipmap(F.TEXTURE_2D), Ee.unbindTexture();
    }, this.copyTextureToTexture3D = function(C, V, $, q, X = 0) {
      const de = Math.round(C.max.x - C.min.x), Me = Math.round(C.max.y - C.min.y), Re = C.max.z - C.min.z + 1, Le = $e.convert(q.format), Oe = $e.convert(q.type);
      let De;
      if (q.isData3DTexture)
        S.setTexture3D(q, 0), De = F.TEXTURE_3D;
      else if (q.isDataArrayTexture || q.isCompressedArrayTexture)
        S.setTexture2DArray(q, 0), De = F.TEXTURE_2D_ARRAY;
      else {
        console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");
        return;
      }
      F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL, q.flipY), F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL, q.premultiplyAlpha), F.pixelStorei(F.UNPACK_ALIGNMENT, q.unpackAlignment);
      const Ie = F.getParameter(F.UNPACK_ROW_LENGTH), at = F.getParameter(F.UNPACK_IMAGE_HEIGHT), Lt = F.getParameter(F.UNPACK_SKIP_PIXELS), dt = F.getParameter(F.UNPACK_SKIP_ROWS), ln = F.getParameter(F.UNPACK_SKIP_IMAGES), rt = $.isCompressedTexture ? $.mipmaps[X] : $.image;
      F.pixelStorei(F.UNPACK_ROW_LENGTH, rt.width), F.pixelStorei(F.UNPACK_IMAGE_HEIGHT, rt.height), F.pixelStorei(F.UNPACK_SKIP_PIXELS, C.min.x), F.pixelStorei(F.UNPACK_SKIP_ROWS, C.min.y), F.pixelStorei(F.UNPACK_SKIP_IMAGES, C.min.z), $.isDataTexture || $.isData3DTexture ? F.texSubImage3D(De, X, V.x, V.y, V.z, de, Me, Re, Le, Oe, rt.data) : q.isCompressedArrayTexture ? F.compressedTexSubImage3D(De, X, V.x, V.y, V.z, de, Me, Re, Le, rt.data) : F.texSubImage3D(De, X, V.x, V.y, V.z, de, Me, Re, Le, Oe, rt), F.pixelStorei(F.UNPACK_ROW_LENGTH, Ie), F.pixelStorei(F.UNPACK_IMAGE_HEIGHT, at), F.pixelStorei(F.UNPACK_SKIP_PIXELS, Lt), F.pixelStorei(F.UNPACK_SKIP_ROWS, dt), F.pixelStorei(F.UNPACK_SKIP_IMAGES, ln), X === 0 && q.generateMipmaps && F.generateMipmap(De), Ee.unbindTexture();
    }, this.initTexture = function(C) {
      C.isCubeTexture ? S.setTextureCube(C, 0) : C.isData3DTexture ? S.setTexture3D(C, 0) : C.isDataArrayTexture || C.isCompressedArrayTexture ? S.setTexture2DArray(C, 0) : S.setTexture2D(C, 0), Ee.unbindTexture();
    }, this.resetState = function() {
      T = 0, E = 0, A = null, Ee.reset(), je.reset();
    }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  get coordinateSystem() {
    return Mn;
  }
  get outputColorSpace() {
    return this._outputColorSpace;
  }
  set outputColorSpace(e) {
    this._outputColorSpace = e;
    const t = this.getContext();
    t.drawingBufferColorSpace = e === ss ? "display-p3" : "srgb", t.unpackColorSpace = Ke.workingColorSpace === xa ? "display-p3" : "srgb";
  }
  get useLegacyLights() {
    return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."), this._useLegacyLights;
  }
  set useLegacyLights(e) {
    console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."), this._useLegacyLights = e;
  }
}
class v_ extends vt {
  constructor() {
    super(), this.isScene = !0, this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.backgroundBlurriness = 0, this.backgroundIntensity = 1, this.backgroundRotation = new on(), this.environmentIntensity = 1, this.environmentRotation = new on(), this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  copy(e, t) {
    return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), this.backgroundBlurriness = e.backgroundBlurriness, this.backgroundIntensity = e.backgroundIntensity, this.backgroundRotation.copy(e.backgroundRotation), this.environmentIntensity = e.environmentIntensity, this.environmentRotation.copy(e.environmentRotation), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.matrixAutoUpdate = e.matrixAutoUpdate, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return this.fog !== null && (t.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (t.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (t.object.backgroundIntensity = this.backgroundIntensity), t.object.backgroundRotation = this.backgroundRotation.toArray(), this.environmentIntensity !== 1 && (t.object.environmentIntensity = this.environmentIntensity), t.object.environmentRotation = this.environmentRotation.toArray(), t;
  }
}
class Fu extends Wi {
  constructor(e) {
    super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new We(16777215), this.map = null, this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.fog = !0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.color.copy(e.color), this.map = e.map, this.linewidth = e.linewidth, this.linecap = e.linecap, this.linejoin = e.linejoin, this.fog = e.fog, this;
  }
}
const il = /* @__PURE__ */ new O(), rl = /* @__PURE__ */ new O(), al = /* @__PURE__ */ new Je(), po = /* @__PURE__ */ new Ma(), qr = /* @__PURE__ */ new ba();
class __ extends vt {
  constructor(e = new Nt(), t = new Fu()) {
    super(), this.isLine = !0, this.type = "Line", this.geometry = e, this.material = t, this.updateMorphTargets();
  }
  copy(e, t) {
    return super.copy(e, t), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this;
  }
  computeLineDistances() {
    const e = this.geometry;
    if (e.index === null) {
      const t = e.attributes.position, i = [0];
      for (let r = 1, a = t.count; r < a; r++)
        il.fromBufferAttribute(t, r - 1), rl.fromBufferAttribute(t, r), i[r] = i[r - 1], i[r] += il.distanceTo(rl);
      e.setAttribute("lineDistance", new lt(i, 1));
    } else
      console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");
    return this;
  }
  raycast(e, t) {
    const i = this.geometry, r = this.matrixWorld, a = e.params.Line.threshold, o = i.drawRange;
    if (i.boundingSphere === null && i.computeBoundingSphere(), qr.copy(i.boundingSphere), qr.applyMatrix4(r), qr.radius += a, e.ray.intersectsSphere(qr) === !1)
      return;
    al.copy(r).invert(), po.copy(e.ray).applyMatrix4(al);
    const s = a / ((this.scale.x + this.scale.y + this.scale.z) / 3), c = s * s, l = new O(), u = new O(), h = new O(), d = new O(), p = this.isLineSegments ? 2 : 1, g = i.index, m = i.attributes.position;
    if (g !== null) {
      const f = Math.max(0, o.start), M = Math.min(g.count, o.start + o.count);
      for (let _ = f, x = M - 1; _ < x; _ += p) {
        const T = g.getX(_), E = g.getX(_ + 1);
        if (l.fromBufferAttribute(m, T), u.fromBufferAttribute(m, E), po.distanceSqToSegment(l, u, d, h) > c)
          continue;
        d.applyMatrix4(this.matrixWorld);
        const R = e.ray.origin.distanceTo(d);
        R < e.near || R > e.far || t.push({
          distance: R,
          // What do we want? intersection point on the ray or on the segment??
          // point: raycaster.ray.at( distance ),
          point: h.clone().applyMatrix4(this.matrixWorld),
          index: _,
          face: null,
          faceIndex: null,
          object: this
        });
      }
    } else {
      const f = Math.max(0, o.start), M = Math.min(m.count, o.start + o.count);
      for (let _ = f, x = M - 1; _ < x; _ += p) {
        if (l.fromBufferAttribute(m, _), u.fromBufferAttribute(m, _ + 1), po.distanceSqToSegment(l, u, d, h) > c)
          continue;
        d.applyMatrix4(this.matrixWorld);
        const E = e.ray.origin.distanceTo(d);
        E < e.near || E > e.far || t.push({
          distance: E,
          // What do we want? intersection point on the ray or on the segment??
          // point: raycaster.ray.at( distance ),
          point: h.clone().applyMatrix4(this.matrixWorld),
          index: _,
          face: null,
          faceIndex: null,
          object: this
        });
      }
    }
  }
  updateMorphTargets() {
    const t = this.geometry.morphAttributes, i = Object.keys(t);
    if (i.length > 0) {
      const r = t[i[0]];
      if (r !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let a = 0, o = r.length; a < o; a++) {
          const s = r[a].name || String(a);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[s] = a;
        }
      }
    }
  }
}
class Tn {
  constructor() {
    this.type = "Curve", this.arcLengthDivisions = 200;
  }
  // Virtual base class method to overwrite and implement in subclasses
  //	- t [0 .. 1]
  getPoint() {
    return console.warn("THREE.Curve: .getPoint() not implemented."), null;
  }
  // Get point at relative position in curve according to arc length
  // - u [0 .. 1]
  getPointAt(e, t) {
    const i = this.getUtoTmapping(e);
    return this.getPoint(i, t);
  }
  // Get sequence of points using getPoint( t )
  getPoints(e = 5) {
    const t = [];
    for (let i = 0; i <= e; i++)
      t.push(this.getPoint(i / e));
    return t;
  }
  // Get sequence of points using getPointAt( u )
  getSpacedPoints(e = 5) {
    const t = [];
    for (let i = 0; i <= e; i++)
      t.push(this.getPointAt(i / e));
    return t;
  }
  // Get total curve arc length
  getLength() {
    const e = this.getLengths();
    return e[e.length - 1];
  }
  // Get list of cumulative segment lengths
  getLengths(e = this.arcLengthDivisions) {
    if (this.cacheArcLengths && this.cacheArcLengths.length === e + 1 && !this.needsUpdate)
      return this.cacheArcLengths;
    this.needsUpdate = !1;
    const t = [];
    let i, r = this.getPoint(0), a = 0;
    t.push(0);
    for (let o = 1; o <= e; o++)
      i = this.getPoint(o / e), a += i.distanceTo(r), t.push(a), r = i;
    return this.cacheArcLengths = t, t;
  }
  updateArcLengths() {
    this.needsUpdate = !0, this.getLengths();
  }
  // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
  getUtoTmapping(e, t) {
    const i = this.getLengths();
    let r = 0;
    const a = i.length;
    let o;
    t ? o = t : o = e * i[a - 1];
    let s = 0, c = a - 1, l;
    for (; s <= c; )
      if (r = Math.floor(s + (c - s) / 2), l = i[r] - o, l < 0)
        s = r + 1;
      else if (l > 0)
        c = r - 1;
      else {
        c = r;
        break;
      }
    if (r = c, i[r] === o)
      return r / (a - 1);
    const u = i[r], d = i[r + 1] - u, p = (o - u) / d;
    return (r + p) / (a - 1);
  }
  // Returns a unit vector tangent at t
  // In case any sub curve does not implement its tangent derivation,
  // 2 points a small delta apart will be used to find its gradient
  // which seems to give a reasonable approximation
  getTangent(e, t) {
    let r = e - 1e-4, a = e + 1e-4;
    r < 0 && (r = 0), a > 1 && (a = 1);
    const o = this.getPoint(r), s = this.getPoint(a), c = t || (o.isVector2 ? new le() : new O());
    return c.copy(s).sub(o).normalize(), c;
  }
  getTangentAt(e, t) {
    const i = this.getUtoTmapping(e);
    return this.getTangent(i, t);
  }
  computeFrenetFrames(e, t) {
    const i = new O(), r = [], a = [], o = [], s = new O(), c = new Je();
    for (let p = 0; p <= e; p++) {
      const g = p / e;
      r[p] = this.getTangentAt(g, new O());
    }
    a[0] = new O(), o[0] = new O();
    let l = Number.MAX_VALUE;
    const u = Math.abs(r[0].x), h = Math.abs(r[0].y), d = Math.abs(r[0].z);
    u <= l && (l = u, i.set(1, 0, 0)), h <= l && (l = h, i.set(0, 1, 0)), d <= l && i.set(0, 0, 1), s.crossVectors(r[0], i).normalize(), a[0].crossVectors(r[0], s), o[0].crossVectors(r[0], a[0]);
    for (let p = 1; p <= e; p++) {
      if (a[p] = a[p - 1].clone(), o[p] = o[p - 1].clone(), s.crossVectors(r[p - 1], r[p]), s.length() > Number.EPSILON) {
        s.normalize();
        const g = Math.acos(mt(r[p - 1].dot(r[p]), -1, 1));
        a[p].applyMatrix4(c.makeRotationAxis(s, g));
      }
      o[p].crossVectors(r[p], a[p]);
    }
    if (t === !0) {
      let p = Math.acos(mt(a[0].dot(a[e]), -1, 1));
      p /= e, r[0].dot(s.crossVectors(a[0], a[e])) > 0 && (p = -p);
      for (let g = 1; g <= e; g++)
        a[g].applyMatrix4(c.makeRotationAxis(r[g], p * g)), o[g].crossVectors(r[g], a[g]);
    }
    return {
      tangents: r,
      normals: a,
      binormals: o
    };
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.arcLengthDivisions = e.arcLengthDivisions, this;
  }
  toJSON() {
    const e = {
      metadata: {
        version: 4.6,
        type: "Curve",
        generator: "Curve.toJSON"
      }
    };
    return e.arcLengthDivisions = this.arcLengthDivisions, e.type = this.type, e;
  }
  fromJSON(e) {
    return this.arcLengthDivisions = e.arcLengthDivisions, this;
  }
}
class Bu extends Tn {
  constructor(e = 0, t = 0, i = 1, r = 1, a = 0, o = Math.PI * 2, s = !1, c = 0) {
    super(), this.isEllipseCurve = !0, this.type = "EllipseCurve", this.aX = e, this.aY = t, this.xRadius = i, this.yRadius = r, this.aStartAngle = a, this.aEndAngle = o, this.aClockwise = s, this.aRotation = c;
  }
  getPoint(e, t = new le()) {
    const i = t, r = Math.PI * 2;
    let a = this.aEndAngle - this.aStartAngle;
    const o = Math.abs(a) < Number.EPSILON;
    for (; a < 0; )
      a += r;
    for (; a > r; )
      a -= r;
    a < Number.EPSILON && (o ? a = 0 : a = r), this.aClockwise === !0 && !o && (a === r ? a = -r : a = a - r);
    const s = this.aStartAngle + e * a;
    let c = this.aX + this.xRadius * Math.cos(s), l = this.aY + this.yRadius * Math.sin(s);
    if (this.aRotation !== 0) {
      const u = Math.cos(this.aRotation), h = Math.sin(this.aRotation), d = c - this.aX, p = l - this.aY;
      c = d * u - p * h + this.aX, l = d * h + p * u + this.aY;
    }
    return i.set(c, l);
  }
  copy(e) {
    return super.copy(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.aX = this.aX, e.aY = this.aY, e.xRadius = this.xRadius, e.yRadius = this.yRadius, e.aStartAngle = this.aStartAngle, e.aEndAngle = this.aEndAngle, e.aClockwise = this.aClockwise, e.aRotation = this.aRotation, e;
  }
  fromJSON(e) {
    return super.fromJSON(e), this.aX = e.aX, this.aY = e.aY, this.xRadius = e.xRadius, this.yRadius = e.yRadius, this.aStartAngle = e.aStartAngle, this.aEndAngle = e.aEndAngle, this.aClockwise = e.aClockwise, this.aRotation = e.aRotation, this;
  }
}
class y_ extends Bu {
  constructor(e, t, i, r, a, o) {
    super(e, t, i, i, r, a, o), this.isArcCurve = !0, this.type = "ArcCurve";
  }
}
function ps() {
  let n = 0, e = 0, t = 0, i = 0;
  function r(a, o, s, c) {
    n = a, e = s, t = -3 * a + 3 * o - 2 * s - c, i = 2 * a - 2 * o + s + c;
  }
  return {
    initCatmullRom: function(a, o, s, c, l) {
      r(o, s, l * (s - a), l * (c - o));
    },
    initNonuniformCatmullRom: function(a, o, s, c, l, u, h) {
      let d = (o - a) / l - (s - a) / (l + u) + (s - o) / u, p = (s - o) / u - (c - o) / (u + h) + (c - s) / h;
      d *= u, p *= u, r(o, s, d, p);
    },
    calc: function(a) {
      const o = a * a, s = o * a;
      return n + e * a + t * o + i * s;
    }
  };
}
const Yr = /* @__PURE__ */ new O(), mo = /* @__PURE__ */ new ps(), go = /* @__PURE__ */ new ps(), vo = /* @__PURE__ */ new ps();
class x_ extends Tn {
  constructor(e = [], t = !1, i = "centripetal", r = 0.5) {
    super(), this.isCatmullRomCurve3 = !0, this.type = "CatmullRomCurve3", this.points = e, this.closed = t, this.curveType = i, this.tension = r;
  }
  getPoint(e, t = new O()) {
    const i = t, r = this.points, a = r.length, o = (a - (this.closed ? 0 : 1)) * e;
    let s = Math.floor(o), c = o - s;
    this.closed ? s += s > 0 ? 0 : (Math.floor(Math.abs(s) / a) + 1) * a : c === 0 && s === a - 1 && (s = a - 2, c = 1);
    let l, u;
    this.closed || s > 0 ? l = r[(s - 1) % a] : (Yr.subVectors(r[0], r[1]).add(r[0]), l = Yr);
    const h = r[s % a], d = r[(s + 1) % a];
    if (this.closed || s + 2 < a ? u = r[(s + 2) % a] : (Yr.subVectors(r[a - 1], r[a - 2]).add(r[a - 1]), u = Yr), this.curveType === "centripetal" || this.curveType === "chordal") {
      const p = this.curveType === "chordal" ? 0.5 : 0.25;
      let g = Math.pow(l.distanceToSquared(h), p), v = Math.pow(h.distanceToSquared(d), p), m = Math.pow(d.distanceToSquared(u), p);
      v < 1e-4 && (v = 1), g < 1e-4 && (g = v), m < 1e-4 && (m = v), mo.initNonuniformCatmullRom(l.x, h.x, d.x, u.x, g, v, m), go.initNonuniformCatmullRom(l.y, h.y, d.y, u.y, g, v, m), vo.initNonuniformCatmullRom(l.z, h.z, d.z, u.z, g, v, m);
    } else
      this.curveType === "catmullrom" && (mo.initCatmullRom(l.x, h.x, d.x, u.x, this.tension), go.initCatmullRom(l.y, h.y, d.y, u.y, this.tension), vo.initCatmullRom(l.z, h.z, d.z, u.z, this.tension));
    return i.set(
      mo.calc(c),
      go.calc(c),
      vo.calc(c)
    ), i;
  }
  copy(e) {
    super.copy(e), this.points = [];
    for (let t = 0, i = e.points.length; t < i; t++) {
      const r = e.points[t];
      this.points.push(r.clone());
    }
    return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this;
  }
  toJSON() {
    const e = super.toJSON();
    e.points = [];
    for (let t = 0, i = this.points.length; t < i; t++) {
      const r = this.points[t];
      e.points.push(r.toArray());
    }
    return e.closed = this.closed, e.curveType = this.curveType, e.tension = this.tension, e;
  }
  fromJSON(e) {
    super.fromJSON(e), this.points = [];
    for (let t = 0, i = e.points.length; t < i; t++) {
      const r = e.points[t];
      this.points.push(new O().fromArray(r));
    }
    return this.closed = e.closed, this.curveType = e.curveType, this.tension = e.tension, this;
  }
}
function ol(n, e, t, i, r) {
  const a = (i - e) * 0.5, o = (r - t) * 0.5, s = n * n, c = n * s;
  return (2 * t - 2 * i + a + o) * c + (-3 * t + 3 * i - 2 * a - o) * s + a * n + t;
}
function b_(n, e) {
  const t = 1 - n;
  return t * t * e;
}
function M_(n, e) {
  return 2 * (1 - n) * n * e;
}
function S_(n, e) {
  return n * n * e;
}
function fr(n, e, t, i) {
  return b_(n, e) + M_(n, t) + S_(n, i);
}
function E_(n, e) {
  const t = 1 - n;
  return t * t * t * e;
}
function w_(n, e) {
  const t = 1 - n;
  return 3 * t * t * n * e;
}
function T_(n, e) {
  return 3 * (1 - n) * n * n * e;
}
function A_(n, e) {
  return n * n * n * e;
}
function dr(n, e, t, i, r) {
  return E_(n, e) + w_(n, t) + T_(n, i) + A_(n, r);
}
class C_ extends Tn {
  constructor(e = new le(), t = new le(), i = new le(), r = new le()) {
    super(), this.isCubicBezierCurve = !0, this.type = "CubicBezierCurve", this.v0 = e, this.v1 = t, this.v2 = i, this.v3 = r;
  }
  getPoint(e, t = new le()) {
    const i = t, r = this.v0, a = this.v1, o = this.v2, s = this.v3;
    return i.set(
      dr(e, r.x, a.x, o.x, s.x),
      dr(e, r.y, a.y, o.y, s.y)
    ), i;
  }
  copy(e) {
    return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e;
  }
  fromJSON(e) {
    return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this;
  }
}
class ku extends Tn {
  constructor(e = new O(), t = new O(), i = new O(), r = new O()) {
    super(), this.isCubicBezierCurve3 = !0, this.type = "CubicBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = i, this.v3 = r;
  }
  getPoint(e, t = new O()) {
    const i = t, r = this.v0, a = this.v1, o = this.v2, s = this.v3;
    return i.set(
      dr(e, r.x, a.x, o.x, s.x),
      dr(e, r.y, a.y, o.y, s.y),
      dr(e, r.z, a.z, o.z, s.z)
    ), i;
  }
  copy(e) {
    return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this.v3.copy(e.v3), this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e.v3 = this.v3.toArray(), e;
  }
  fromJSON(e) {
    return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this.v3.fromArray(e.v3), this;
  }
}
class R_ extends Tn {
  constructor(e = new le(), t = new le()) {
    super(), this.isLineCurve = !0, this.type = "LineCurve", this.v1 = e, this.v2 = t;
  }
  getPoint(e, t = new le()) {
    const i = t;
    return e === 1 ? i.copy(this.v2) : (i.copy(this.v2).sub(this.v1), i.multiplyScalar(e).add(this.v1)), i;
  }
  // Line curve is linear, so we can overwrite default getPointAt
  getPointAt(e, t) {
    return this.getPoint(e, t);
  }
  getTangent(e, t = new le()) {
    return t.subVectors(this.v2, this.v1).normalize();
  }
  getTangentAt(e, t) {
    return this.getTangent(e, t);
  }
  copy(e) {
    return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e;
  }
  fromJSON(e) {
    return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
  }
}
class P_ extends Tn {
  constructor(e = new O(), t = new O()) {
    super(), this.isLineCurve3 = !0, this.type = "LineCurve3", this.v1 = e, this.v2 = t;
  }
  getPoint(e, t = new O()) {
    const i = t;
    return e === 1 ? i.copy(this.v2) : (i.copy(this.v2).sub(this.v1), i.multiplyScalar(e).add(this.v1)), i;
  }
  // Line curve is linear, so we can overwrite default getPointAt
  getPointAt(e, t) {
    return this.getPoint(e, t);
  }
  getTangent(e, t = new O()) {
    return t.subVectors(this.v2, this.v1).normalize();
  }
  getTangentAt(e, t) {
    return this.getTangent(e, t);
  }
  copy(e) {
    return super.copy(e), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e;
  }
  fromJSON(e) {
    return super.fromJSON(e), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
  }
}
class L_ extends Tn {
  constructor(e = new le(), t = new le(), i = new le()) {
    super(), this.isQuadraticBezierCurve = !0, this.type = "QuadraticBezierCurve", this.v0 = e, this.v1 = t, this.v2 = i;
  }
  getPoint(e, t = new le()) {
    const i = t, r = this.v0, a = this.v1, o = this.v2;
    return i.set(
      fr(e, r.x, a.x, o.x),
      fr(e, r.y, a.y, o.y)
    ), i;
  }
  copy(e) {
    return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e;
  }
  fromJSON(e) {
    return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
  }
}
class ms extends Tn {
  constructor(e = new O(), t = new O(), i = new O()) {
    super(), this.isQuadraticBezierCurve3 = !0, this.type = "QuadraticBezierCurve3", this.v0 = e, this.v1 = t, this.v2 = i;
  }
  getPoint(e, t = new O()) {
    const i = t, r = this.v0, a = this.v1, o = this.v2;
    return i.set(
      fr(e, r.x, a.x, o.x),
      fr(e, r.y, a.y, o.y),
      fr(e, r.z, a.z, o.z)
    ), i;
  }
  copy(e) {
    return super.copy(e), this.v0.copy(e.v0), this.v1.copy(e.v1), this.v2.copy(e.v2), this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.v0 = this.v0.toArray(), e.v1 = this.v1.toArray(), e.v2 = this.v2.toArray(), e;
  }
  fromJSON(e) {
    return super.fromJSON(e), this.v0.fromArray(e.v0), this.v1.fromArray(e.v1), this.v2.fromArray(e.v2), this;
  }
}
class D_ extends Tn {
  constructor(e = []) {
    super(), this.isSplineCurve = !0, this.type = "SplineCurve", this.points = e;
  }
  getPoint(e, t = new le()) {
    const i = t, r = this.points, a = (r.length - 1) * e, o = Math.floor(a), s = a - o, c = r[o === 0 ? o : o - 1], l = r[o], u = r[o > r.length - 2 ? r.length - 1 : o + 1], h = r[o > r.length - 3 ? r.length - 1 : o + 2];
    return i.set(
      ol(s, c.x, l.x, u.x, h.x),
      ol(s, c.y, l.y, u.y, h.y)
    ), i;
  }
  copy(e) {
    super.copy(e), this.points = [];
    for (let t = 0, i = e.points.length; t < i; t++) {
      const r = e.points[t];
      this.points.push(r.clone());
    }
    return this;
  }
  toJSON() {
    const e = super.toJSON();
    e.points = [];
    for (let t = 0, i = this.points.length; t < i; t++) {
      const r = this.points[t];
      e.points.push(r.toArray());
    }
    return e;
  }
  fromJSON(e) {
    super.fromJSON(e), this.points = [];
    for (let t = 0, i = e.points.length; t < i; t++) {
      const r = e.points[t];
      this.points.push(new le().fromArray(r));
    }
    return this;
  }
}
var O_ = /* @__PURE__ */ Object.freeze({
  __proto__: null,
  ArcCurve: y_,
  CatmullRomCurve3: x_,
  CubicBezierCurve: C_,
  CubicBezierCurve3: ku,
  EllipseCurve: Bu,
  LineCurve: R_,
  LineCurve3: P_,
  QuadraticBezierCurve: L_,
  QuadraticBezierCurve3: ms,
  SplineCurve: D_
});
class wa extends Nt {
  constructor(e = 1, t = 1, i = 1, r = 32, a = 1, o = !1, s = 0, c = Math.PI * 2) {
    super(), this.type = "CylinderGeometry", this.parameters = {
      radiusTop: e,
      radiusBottom: t,
      height: i,
      radialSegments: r,
      heightSegments: a,
      openEnded: o,
      thetaStart: s,
      thetaLength: c
    };
    const l = this;
    r = Math.floor(r), a = Math.floor(a);
    const u = [], h = [], d = [], p = [];
    let g = 0;
    const v = [], m = i / 2;
    let f = 0;
    M(), o === !1 && (e > 0 && _(!0), t > 0 && _(!1)), this.setIndex(u), this.setAttribute("position", new lt(h, 3)), this.setAttribute("normal", new lt(d, 3)), this.setAttribute("uv", new lt(p, 2));
    function M() {
      const x = new O(), T = new O();
      let E = 0;
      const A = (t - e) / i;
      for (let R = 0; R <= a; R++) {
        const w = [], b = R / a, U = b * (t - e) + e;
        for (let z = 0; z <= r; z++) {
          const I = z / r, L = I * c + s, D = Math.sin(L), B = Math.cos(L);
          T.x = U * D, T.y = -b * i + m, T.z = U * B, h.push(T.x, T.y, T.z), x.set(D, A, B).normalize(), d.push(x.x, x.y, x.z), p.push(I, 1 - b), w.push(g++);
        }
        v.push(w);
      }
      for (let R = 0; R < r; R++)
        for (let w = 0; w < a; w++) {
          const b = v[w][R], U = v[w + 1][R], z = v[w + 1][R + 1], I = v[w][R + 1];
          u.push(b, U, I), u.push(U, z, I), E += 6;
        }
      l.addGroup(f, E, 0), f += E;
    }
    function _(x) {
      const T = g, E = new le(), A = new O();
      let R = 0;
      const w = x === !0 ? e : t, b = x === !0 ? 1 : -1;
      for (let z = 1; z <= r; z++)
        h.push(0, m * b, 0), d.push(0, b, 0), p.push(0.5, 0.5), g++;
      const U = g;
      for (let z = 0; z <= r; z++) {
        const L = z / r * c + s, D = Math.cos(L), B = Math.sin(L);
        A.x = w * B, A.y = m * b, A.z = w * D, h.push(A.x, A.y, A.z), d.push(0, b, 0), E.x = D * 0.5 + 0.5, E.y = B * 0.5 * b + 0.5, p.push(E.x, E.y), g++;
      }
      for (let z = 0; z < r; z++) {
        const I = T + z, L = U + z;
        x === !0 ? u.push(L, L + 1, I) : u.push(L + 1, L, I), R += 3;
      }
      l.addGroup(f, R, x === !0 ? 1 : 2), f += R;
    }
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new wa(e.radiusTop, e.radiusBottom, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength);
  }
}
class gs extends wa {
  constructor(e = 1, t = 1, i = 32, r = 1, a = !1, o = 0, s = Math.PI * 2) {
    super(0, e, t, i, r, a, o, s), this.type = "ConeGeometry", this.parameters = {
      radius: e,
      height: t,
      radialSegments: i,
      heightSegments: r,
      openEnded: a,
      thetaStart: o,
      thetaLength: s
    };
  }
  static fromJSON(e) {
    return new gs(e.radius, e.height, e.radialSegments, e.heightSegments, e.openEnded, e.thetaStart, e.thetaLength);
  }
}
class Ta extends Nt {
  constructor(e = 1, t = 32, i = 16, r = 0, a = Math.PI * 2, o = 0, s = Math.PI) {
    super(), this.type = "SphereGeometry", this.parameters = {
      radius: e,
      widthSegments: t,
      heightSegments: i,
      phiStart: r,
      phiLength: a,
      thetaStart: o,
      thetaLength: s
    }, t = Math.max(3, Math.floor(t)), i = Math.max(2, Math.floor(i));
    const c = Math.min(o + s, Math.PI);
    let l = 0;
    const u = [], h = new O(), d = new O(), p = [], g = [], v = [], m = [];
    for (let f = 0; f <= i; f++) {
      const M = [], _ = f / i;
      let x = 0;
      f === 0 && o === 0 ? x = 0.5 / t : f === i && c === Math.PI && (x = -0.5 / t);
      for (let T = 0; T <= t; T++) {
        const E = T / t;
        h.x = -e * Math.cos(r + E * a) * Math.sin(o + _ * s), h.y = e * Math.cos(o + _ * s), h.z = e * Math.sin(r + E * a) * Math.sin(o + _ * s), g.push(h.x, h.y, h.z), d.copy(h).normalize(), v.push(d.x, d.y, d.z), m.push(E + x, 1 - _), M.push(l++);
      }
      u.push(M);
    }
    for (let f = 0; f < i; f++)
      for (let M = 0; M < t; M++) {
        const _ = u[f][M + 1], x = u[f][M], T = u[f + 1][M], E = u[f + 1][M + 1];
        (f !== 0 || o > 0) && p.push(_, x, E), (f !== i - 1 || c < Math.PI) && p.push(x, T, E);
      }
    this.setIndex(p), this.setAttribute("position", new lt(g, 3)), this.setAttribute("normal", new lt(v, 3)), this.setAttribute("uv", new lt(m, 2));
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new Ta(e.radius, e.widthSegments, e.heightSegments, e.phiStart, e.phiLength, e.thetaStart, e.thetaLength);
  }
}
class vs extends Nt {
  constructor(e = new ms(new O(-1, -1, 0), new O(-1, 1, 0), new O(1, 1, 0)), t = 64, i = 1, r = 8, a = !1) {
    super(), this.type = "TubeGeometry", this.parameters = {
      path: e,
      tubularSegments: t,
      radius: i,
      radialSegments: r,
      closed: a
    };
    const o = e.computeFrenetFrames(t, a);
    this.tangents = o.tangents, this.normals = o.normals, this.binormals = o.binormals;
    const s = new O(), c = new O(), l = new le();
    let u = new O();
    const h = [], d = [], p = [], g = [];
    v(), this.setIndex(g), this.setAttribute("position", new lt(h, 3)), this.setAttribute("normal", new lt(d, 3)), this.setAttribute("uv", new lt(p, 2));
    function v() {
      for (let _ = 0; _ < t; _++)
        m(_);
      m(a === !1 ? t : 0), M(), f();
    }
    function m(_) {
      u = e.getPointAt(_ / t, u);
      const x = o.normals[_], T = o.binormals[_];
      for (let E = 0; E <= r; E++) {
        const A = E / r * Math.PI * 2, R = Math.sin(A), w = -Math.cos(A);
        c.x = w * x.x + R * T.x, c.y = w * x.y + R * T.y, c.z = w * x.z + R * T.z, c.normalize(), d.push(c.x, c.y, c.z), s.x = u.x + i * c.x, s.y = u.y + i * c.y, s.z = u.z + i * c.z, h.push(s.x, s.y, s.z);
      }
    }
    function f() {
      for (let _ = 1; _ <= t; _++)
        for (let x = 1; x <= r; x++) {
          const T = (r + 1) * (_ - 1) + (x - 1), E = (r + 1) * _ + (x - 1), A = (r + 1) * _ + x, R = (r + 1) * (_ - 1) + x;
          g.push(T, E, R), g.push(E, A, R);
        }
    }
    function M() {
      for (let _ = 0; _ <= t; _++)
        for (let x = 0; x <= r; x++)
          l.x = _ / t, l.y = x / r, p.push(l.x, l.y);
    }
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  toJSON() {
    const e = super.toJSON();
    return e.path = this.parameters.path.toJSON(), e;
  }
  static fromJSON(e) {
    return new vs(
      new O_[e.path.type]().fromJSON(e.path),
      e.tubularSegments,
      e.radius,
      e.radialSegments,
      e.closed
    );
  }
}
class I_ extends Wi {
  constructor(e) {
    super(), this.isMeshLambertMaterial = !0, this.type = "MeshLambertMaterial", this.color = new We(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.emissive = new We(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = _u, this.normalScale = new le(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new on(), this.combine = os, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.flatShading = !1, this.fog = !0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.emissive.copy(e.emissive), this.emissiveMap = e.emissiveMap, this.emissiveIntensity = e.emissiveIntensity, this.bumpMap = e.bumpMap, this.bumpScale = e.bumpScale, this.normalMap = e.normalMap, this.normalMapType = e.normalMapType, this.normalScale.copy(e.normalScale), this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this.fog = e.fog, this;
  }
}
const sl = {
  enabled: !1,
  files: {},
  add: function(n, e) {
    this.enabled !== !1 && (this.files[n] = e);
  },
  get: function(n) {
    if (this.enabled !== !1)
      return this.files[n];
  },
  remove: function(n) {
    delete this.files[n];
  },
  clear: function() {
    this.files = {};
  }
};
class N_ {
  constructor(e, t, i) {
    const r = this;
    let a = !1, o = 0, s = 0, c;
    const l = [];
    this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = i, this.itemStart = function(u) {
      s++, a === !1 && r.onStart !== void 0 && r.onStart(u, o, s), a = !0;
    }, this.itemEnd = function(u) {
      o++, r.onProgress !== void 0 && r.onProgress(u, o, s), o === s && (a = !1, r.onLoad !== void 0 && r.onLoad());
    }, this.itemError = function(u) {
      r.onError !== void 0 && r.onError(u);
    }, this.resolveURL = function(u) {
      return c ? c(u) : u;
    }, this.setURLModifier = function(u) {
      return c = u, this;
    }, this.addHandler = function(u, h) {
      return l.push(u, h), this;
    }, this.removeHandler = function(u) {
      const h = l.indexOf(u);
      return h !== -1 && l.splice(h, 2), this;
    }, this.getHandler = function(u) {
      for (let h = 0, d = l.length; h < d; h += 2) {
        const p = l[h], g = l[h + 1];
        if (p.global && (p.lastIndex = 0), p.test(u))
          return g;
      }
      return null;
    };
  }
}
const U_ = /* @__PURE__ */ new N_();
class _s {
  constructor(e) {
    this.manager = e !== void 0 ? e : U_, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {};
  }
  load() {
  }
  loadAsync(e, t) {
    const i = this;
    return new Promise(function(r, a) {
      i.load(e, r, t, a);
    });
  }
  parse() {
  }
  setCrossOrigin(e) {
    return this.crossOrigin = e, this;
  }
  setWithCredentials(e) {
    return this.withCredentials = e, this;
  }
  setPath(e) {
    return this.path = e, this;
  }
  setResourcePath(e) {
    return this.resourcePath = e, this;
  }
  setRequestHeader(e) {
    return this.requestHeader = e, this;
  }
}
_s.DEFAULT_MATERIAL_NAME = "__DEFAULT";
class F_ extends _s {
  constructor(e) {
    super(e);
  }
  load(e, t, i, r) {
    this.path !== void 0 && (e = this.path + e), e = this.manager.resolveURL(e);
    const a = this, o = sl.get(e);
    if (o !== void 0)
      return a.manager.itemStart(e), setTimeout(function() {
        t && t(o), a.manager.itemEnd(e);
      }, 0), o;
    const s = vr("img");
    function c() {
      u(), sl.add(e, this), t && t(this), a.manager.itemEnd(e);
    }
    function l(h) {
      u(), r && r(h), a.manager.itemError(e), a.manager.itemEnd(e);
    }
    function u() {
      s.removeEventListener("load", c, !1), s.removeEventListener("error", l, !1);
    }
    return s.addEventListener("load", c, !1), s.addEventListener("error", l, !1), e.slice(0, 5) !== "data:" && this.crossOrigin !== void 0 && (s.crossOrigin = this.crossOrigin), a.manager.itemStart(e), s.src = e, s;
  }
}
class B_ extends _s {
  constructor(e) {
    super(e);
  }
  load(e, t, i, r) {
    const a = new Tt(), o = new F_(this.manager);
    return o.setCrossOrigin(this.crossOrigin), o.setPath(this.path), o.load(e, function(s) {
      a.image = s, a.needsUpdate = !0, t !== void 0 && t(a);
    }, i, r), a;
  }
}
class zu extends vt {
  constructor(e, t = 1) {
    super(), this.isLight = !0, this.type = "Light", this.color = new We(e), this.intensity = t;
  }
  dispose() {
  }
  copy(e, t) {
    return super.copy(e, t), this.color.copy(e.color), this.intensity = e.intensity, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return t.object.color = this.color.getHex(), t.object.intensity = this.intensity, this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (t.object.distance = this.distance), this.angle !== void 0 && (t.object.angle = this.angle), this.decay !== void 0 && (t.object.decay = this.decay), this.penumbra !== void 0 && (t.object.penumbra = this.penumbra), this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()), t;
  }
}
const _o = /* @__PURE__ */ new Je(), cl = /* @__PURE__ */ new O(), ll = /* @__PURE__ */ new O();
class k_ {
  constructor(e) {
    this.camera = e, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new le(512, 512), this.map = null, this.mapPass = null, this.matrix = new Je(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new hs(), this._frameExtents = new le(1, 1), this._viewportCount = 1, this._viewports = [
      new gt(0, 0, 1, 1)
    ];
  }
  getViewportCount() {
    return this._viewportCount;
  }
  getFrustum() {
    return this._frustum;
  }
  updateMatrices(e) {
    const t = this.camera, i = this.matrix;
    cl.setFromMatrixPosition(e.matrixWorld), t.position.copy(cl), ll.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(ll), t.updateMatrixWorld(), _o.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(_o), i.set(
      0.5,
      0,
      0,
      0.5,
      0,
      0.5,
      0,
      0.5,
      0,
      0,
      0.5,
      0.5,
      0,
      0,
      0,
      1
    ), i.multiply(_o);
  }
  getViewport(e) {
    return this._viewports[e];
  }
  getFrameExtents() {
    return this._frameExtents;
  }
  dispose() {
    this.map && this.map.dispose(), this.mapPass && this.mapPass.dispose();
  }
  copy(e) {
    return this.camera = e.camera.clone(), this.bias = e.bias, this.radius = e.radius, this.mapSize.copy(e.mapSize), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  toJSON() {
    const e = {};
    return this.bias !== 0 && (e.bias = this.bias), this.normalBias !== 0 && (e.normalBias = this.normalBias), this.radius !== 1 && (e.radius = this.radius), (this.mapSize.x !== 512 || this.mapSize.y !== 512) && (e.mapSize = this.mapSize.toArray()), e.camera = this.camera.toJSON(!1).object, delete e.camera.matrix, e;
  }
}
class z_ extends k_ {
  constructor() {
    super(new fs(-5, 5, 5, -5, 0.5, 500)), this.isDirectionalLightShadow = !0;
  }
}
class H_ extends zu {
  constructor(e, t) {
    super(e, t), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(vt.DEFAULT_UP), this.updateMatrix(), this.target = new vt(), this.shadow = new z_();
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(e) {
    return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this;
  }
}
class V_ extends zu {
  constructor(e, t) {
    super(e, t), this.isAmbientLight = !0, this.type = "AmbientLight";
  }
}
class Hu {
  constructor(e = !0) {
    this.autoStart = e, this.startTime = 0, this.oldTime = 0, this.elapsedTime = 0, this.running = !1;
  }
  start() {
    this.startTime = ul(), this.oldTime = this.startTime, this.elapsedTime = 0, this.running = !0;
  }
  stop() {
    this.getElapsedTime(), this.running = !1, this.autoStart = !1;
  }
  getElapsedTime() {
    return this.getDelta(), this.elapsedTime;
  }
  getDelta() {
    let e = 0;
    if (this.autoStart && !this.running)
      return this.start(), 0;
    if (this.running) {
      const t = ul();
      e = (t - this.oldTime) / 1e3, this.oldTime = t, this.elapsedTime += e;
    }
    return e;
  }
}
function ul() {
  return (typeof performance > "u" ? Date : performance).now();
}
const hl = /* @__PURE__ */ new Je();
class Vu {
  constructor(e, t, i = 0, r = 1 / 0) {
    this.ray = new Ma(e, t), this.near = i, this.far = r, this.camera = null, this.layers = new ls(), this.params = {
      Mesh: {},
      Line: { threshold: 1 },
      LOD: {},
      Points: { threshold: 1 },
      Sprite: {}
    };
  }
  set(e, t) {
    this.ray.set(e, t);
  }
  setFromCamera(e, t) {
    t.isPerspectiveCamera ? (this.ray.origin.setFromMatrixPosition(t.matrixWorld), this.ray.direction.set(e.x, e.y, 0.5).unproject(t).sub(this.ray.origin).normalize(), this.camera = t) : t.isOrthographicCamera ? (this.ray.origin.set(e.x, e.y, (t.near + t.far) / (t.near - t.far)).unproject(t), this.ray.direction.set(0, 0, -1).transformDirection(t.matrixWorld), this.camera = t) : console.error("THREE.Raycaster: Unsupported camera type: " + t.type);
  }
  setFromXRController(e) {
    return hl.identity().extractRotation(e.matrixWorld), this.ray.origin.setFromMatrixPosition(e.matrixWorld), this.ray.direction.set(0, 0, -1).applyMatrix4(hl), this;
  }
  intersectObject(e, t = !0, i = []) {
    return Vo(e, this, i, t), i.sort(fl), i;
  }
  intersectObjects(e, t = !0, i = []) {
    for (let r = 0, a = e.length; r < a; r++)
      Vo(e[r], this, i, t);
    return i.sort(fl), i;
  }
}
function fl(n, e) {
  return n.distance - e.distance;
}
function Vo(n, e, t, i) {
  if (n.layers.test(e.layers) && n.raycast(e, t), i === !0) {
    const r = n.children;
    for (let a = 0, o = r.length; a < o; a++)
      Vo(r[a], e, t, !0);
  }
}
class Go {
  constructor(e = 1, t = 0, i = 0) {
    return this.radius = e, this.phi = t, this.theta = i, this;
  }
  set(e, t, i) {
    return this.radius = e, this.phi = t, this.theta = i, this;
  }
  copy(e) {
    return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this;
  }
  // restrict phi to be between EPS and PI-EPS
  makeSafe() {
    return this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi)), this;
  }
  setFromVector3(e) {
    return this.setFromCartesianCoords(e.x, e.y, e.z);
  }
  setFromCartesianCoords(e, t, i) {
    return this.radius = Math.sqrt(e * e + t * t + i * i), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, i), this.phi = Math.acos(mt(t / this.radius, -1, 1))), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  revision: _a
} }));
typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = _a);
const Pi = new yn(), Nn = new Vu(), mn = new le(), dl = new O(), yo = new le(), Kr = new le(), Zr = new O(), xo = new O(), pl = new Je(), ml = new O(), gl = new O();
class G_ extends Qt {
  constructor(e, t, i) {
    super(), i.style.touchAction = "none";
    let r = null, a = null;
    const o = [];
    this.mode = "translate", this.rotateSpeed = 1;
    const s = this;
    function c() {
      i.addEventListener("pointermove", g), i.addEventListener("pointerdown", v), i.addEventListener("pointerup", m), i.addEventListener("pointerleave", m);
    }
    function l() {
      i.removeEventListener("pointermove", g), i.removeEventListener("pointerdown", v), i.removeEventListener("pointerup", m), i.removeEventListener("pointerleave", m), i.style.cursor = "";
    }
    function u() {
      l();
    }
    function h() {
      return e;
    }
    function d(_) {
      e = _;
    }
    function p() {
      return Nn;
    }
    function g(_) {
      if (s.enabled !== !1) {
        if (f(_), Nn.setFromCamera(mn, t), r)
          s.mode === "translate" ? Nn.ray.intersectPlane(Pi, Zr) && r.position.copy(Zr.sub(dl).applyMatrix4(pl)) : s.mode === "rotate" && (yo.subVectors(mn, Kr).multiplyScalar(s.rotateSpeed), r.rotateOnWorldAxis(ml, yo.x), r.rotateOnWorldAxis(gl.normalize(), -yo.y)), s.dispatchEvent({ type: "drag", object: r }), Kr.copy(mn);
        else if (_.pointerType === "mouse" || _.pointerType === "pen")
          if (o.length = 0, Nn.setFromCamera(mn, t), Nn.intersectObjects(e, s.recursive, o), o.length > 0) {
            const x = o[0].object;
            Pi.setFromNormalAndCoplanarPoint(t.getWorldDirection(Pi.normal), xo.setFromMatrixPosition(x.matrixWorld)), a !== x && a !== null && (s.dispatchEvent({ type: "hoveroff", object: a }), i.style.cursor = "auto", a = null), a !== x && (s.dispatchEvent({ type: "hoveron", object: x }), i.style.cursor = "pointer", a = x);
          } else
            a !== null && (s.dispatchEvent({ type: "hoveroff", object: a }), i.style.cursor = "auto", a = null);
        Kr.copy(mn);
      }
    }
    function v(_) {
      s.enabled !== !1 && (f(_), o.length = 0, Nn.setFromCamera(mn, t), Nn.intersectObjects(e, s.recursive, o), o.length > 0 && (s.transformGroup === !0 ? r = M(o[0].object) : r = o[0].object, Pi.setFromNormalAndCoplanarPoint(t.getWorldDirection(Pi.normal), xo.setFromMatrixPosition(r.matrixWorld)), Nn.ray.intersectPlane(Pi, Zr) && (s.mode === "translate" ? (pl.copy(r.parent.matrixWorld).invert(), dl.copy(Zr).sub(xo.setFromMatrixPosition(r.matrixWorld))) : s.mode === "rotate" && (ml.set(0, 1, 0).applyQuaternion(t.quaternion).normalize(), gl.set(1, 0, 0).applyQuaternion(t.quaternion).normalize())), i.style.cursor = "move", s.dispatchEvent({ type: "dragstart", object: r })), Kr.copy(mn));
    }
    function m() {
      s.enabled !== !1 && (r && (s.dispatchEvent({ type: "dragend", object: r }), r = null), i.style.cursor = a ? "pointer" : "auto");
    }
    function f(_) {
      const x = i.getBoundingClientRect();
      mn.x = (_.clientX - x.left) / x.width * 2 - 1, mn.y = -(_.clientY - x.top) / x.height * 2 + 1;
    }
    function M(_, x = null) {
      return _.isGroup && (x = _), _.parent === null ? x : M(_.parent, x);
    }
    c(), this.enabled = !0, this.recursive = !0, this.transformGroup = !1, this.activate = c, this.deactivate = l, this.dispose = u, this.getObjects = h, this.getRaycaster = p, this.setObjects = d;
  }
}
function W_(n, e, t) {
  var i, r = 1;
  n == null && (n = 0), e == null && (e = 0), t == null && (t = 0);
  function a() {
    var o, s = i.length, c, l = 0, u = 0, h = 0;
    for (o = 0; o < s; ++o)
      c = i[o], l += c.x || 0, u += c.y || 0, h += c.z || 0;
    for (l = (l / s - n) * r, u = (u / s - e) * r, h = (h / s - t) * r, o = 0; o < s; ++o)
      c = i[o], l && (c.x -= l), u && (c.y -= u), h && (c.z -= h);
  }
  return a.initialize = function(o) {
    i = o;
  }, a.x = function(o) {
    return arguments.length ? (n = +o, a) : n;
  }, a.y = function(o) {
    return arguments.length ? (e = +o, a) : e;
  }, a.z = function(o) {
    return arguments.length ? (t = +o, a) : t;
  }, a.strength = function(o) {
    return arguments.length ? (r = +o, a) : r;
  }, a;
}
function j_(n) {
  const e = +this._x.call(null, n);
  return Gu(this.cover(e), e, n);
}
function Gu(n, e, t) {
  if (isNaN(e))
    return n;
  var i, r = n._root, a = { data: t }, o = n._x0, s = n._x1, c, l, u, h, d;
  if (!r)
    return n._root = a, n;
  for (; r.length; )
    if ((u = e >= (c = (o + s) / 2)) ? o = c : s = c, i = r, !(r = r[h = +u]))
      return i[h] = a, n;
  if (l = +n._x.call(null, r.data), e === l)
    return a.next = r, i ? i[h] = a : n._root = a, n;
  do
    i = i ? i[h] = new Array(2) : n._root = new Array(2), (u = e >= (c = (o + s) / 2)) ? o = c : s = c;
  while ((h = +u) == (d = +(l >= c)));
  return i[d] = r, i[h] = a, n;
}
function X_(n) {
  Array.isArray(n) || (n = Array.from(n));
  const e = n.length, t = new Float64Array(e);
  let i = 1 / 0, r = -1 / 0;
  for (let a = 0, o; a < e; ++a)
    isNaN(o = +this._x.call(null, n[a])) || (t[a] = o, o < i && (i = o), o > r && (r = o));
  if (i > r)
    return this;
  this.cover(i).cover(r);
  for (let a = 0; a < e; ++a)
    Gu(this, t[a], n[a]);
  return this;
}
function $_(n) {
  if (isNaN(n = +n))
    return this;
  var e = this._x0, t = this._x1;
  if (isNaN(e))
    t = (e = Math.floor(n)) + 1;
  else {
    for (var i = t - e || 1, r = this._root, a, o; e > n || n >= t; )
      switch (o = +(n < e), a = new Array(2), a[o] = r, r = a, i *= 2, o) {
        case 0:
          t = e + i;
          break;
        case 1:
          e = t - i;
          break;
      }
    this._root && this._root.length && (this._root = r);
  }
  return this._x0 = e, this._x1 = t, this;
}
function q_() {
  var n = [];
  return this.visit(function(e) {
    if (!e.length)
      do
        n.push(e.data);
      while (e = e.next);
  }), n;
}
function Y_(n) {
  return arguments.length ? this.cover(+n[0][0]).cover(+n[1][0]) : isNaN(this._x0) ? void 0 : [[this._x0], [this._x1]];
}
function wn(n, e, t) {
  this.node = n, this.x0 = e, this.x1 = t;
}
function K_(n, e) {
  var t, i = this._x0, r, a, o = this._x1, s = [], c = this._root, l, u;
  for (c && s.push(new wn(c, i, o)), e == null ? e = 1 / 0 : (i = n - e, o = n + e); l = s.pop(); )
    if (!(!(c = l.node) || (r = l.x0) > o || (a = l.x1) < i))
      if (c.length) {
        var h = (r + a) / 2;
        s.push(
          new wn(c[1], h, a),
          new wn(c[0], r, h)
        ), (u = +(n >= h)) && (l = s[s.length - 1], s[s.length - 1] = s[s.length - 1 - u], s[s.length - 1 - u] = l);
      } else {
        var d = Math.abs(n - +this._x.call(null, c.data));
        d < e && (e = d, i = n - d, o = n + d, t = c.data);
      }
  return t;
}
function Z_(n) {
  if (isNaN(c = +this._x.call(null, n)))
    return this;
  var e, t = this._root, i, r, a, o = this._x0, s = this._x1, c, l, u, h, d;
  if (!t)
    return this;
  if (t.length)
    for (; ; ) {
      if ((u = c >= (l = (o + s) / 2)) ? o = l : s = l, e = t, !(t = t[h = +u]))
        return this;
      if (!t.length)
        break;
      e[h + 1 & 1] && (i = e, d = h);
    }
  for (; t.data !== n; )
    if (r = t, !(t = t.next))
      return this;
  return (a = t.next) && delete t.next, r ? (a ? r.next = a : delete r.next, this) : e ? (a ? e[h] = a : delete e[h], (t = e[0] || e[1]) && t === (e[1] || e[0]) && !t.length && (i ? i[d] = t : this._root = t), this) : (this._root = a, this);
}
function J_(n) {
  for (var e = 0, t = n.length; e < t; ++e)
    this.remove(n[e]);
  return this;
}
function Q_() {
  return this._root;
}
function e0() {
  var n = 0;
  return this.visit(function(e) {
    if (!e.length)
      do
        ++n;
      while (e = e.next);
  }), n;
}
function t0(n) {
  var e = [], t, i = this._root, r, a, o;
  for (i && e.push(new wn(i, this._x0, this._x1)); t = e.pop(); )
    if (!n(i = t.node, a = t.x0, o = t.x1) && i.length) {
      var s = (a + o) / 2;
      (r = i[1]) && e.push(new wn(r, s, o)), (r = i[0]) && e.push(new wn(r, a, s));
    }
  return this;
}
function n0(n) {
  var e = [], t = [], i;
  for (this._root && e.push(new wn(this._root, this._x0, this._x1)); i = e.pop(); ) {
    var r = i.node;
    if (r.length) {
      var a, o = i.x0, s = i.x1, c = (o + s) / 2;
      (a = r[0]) && e.push(new wn(a, o, c)), (a = r[1]) && e.push(new wn(a, c, s));
    }
    t.push(i);
  }
  for (; i = t.pop(); )
    n(i.node, i.x0, i.x1);
  return this;
}
function i0(n) {
  return n[0];
}
function r0(n) {
  return arguments.length ? (this._x = n, this) : this._x;
}
function Wu(n, e) {
  var t = new ys(e ?? i0, NaN, NaN);
  return n == null ? t : t.addAll(n);
}
function ys(n, e, t) {
  this._x = n, this._x0 = e, this._x1 = t, this._root = void 0;
}
function vl(n) {
  for (var e = { data: n.data }, t = e; n = n.next; )
    t = t.next = { data: n.data };
  return e;
}
var Rt = Wu.prototype = ys.prototype;
Rt.copy = function() {
  var n = new ys(this._x, this._x0, this._x1), e = this._root, t, i;
  if (!e)
    return n;
  if (!e.length)
    return n._root = vl(e), n;
  for (t = [{ source: e, target: n._root = new Array(2) }]; e = t.pop(); )
    for (var r = 0; r < 2; ++r)
      (i = e.source[r]) && (i.length ? t.push({ source: i, target: e.target[r] = new Array(2) }) : e.target[r] = vl(i));
  return n;
};
Rt.add = j_;
Rt.addAll = X_;
Rt.cover = $_;
Rt.data = q_;
Rt.extent = Y_;
Rt.find = K_;
Rt.remove = Z_;
Rt.removeAll = J_;
Rt.root = Q_;
Rt.size = e0;
Rt.visit = t0;
Rt.visitAfter = n0;
Rt.x = r0;
function a0(n) {
  const e = +this._x.call(null, n), t = +this._y.call(null, n);
  return ju(this.cover(e, t), e, t, n);
}
function ju(n, e, t, i) {
  if (isNaN(e) || isNaN(t))
    return n;
  var r, a = n._root, o = { data: i }, s = n._x0, c = n._y0, l = n._x1, u = n._y1, h, d, p, g, v, m, f, M;
  if (!a)
    return n._root = o, n;
  for (; a.length; )
    if ((v = e >= (h = (s + l) / 2)) ? s = h : l = h, (m = t >= (d = (c + u) / 2)) ? c = d : u = d, r = a, !(a = a[f = m << 1 | v]))
      return r[f] = o, n;
  if (p = +n._x.call(null, a.data), g = +n._y.call(null, a.data), e === p && t === g)
    return o.next = a, r ? r[f] = o : n._root = o, n;
  do
    r = r ? r[f] = new Array(4) : n._root = new Array(4), (v = e >= (h = (s + l) / 2)) ? s = h : l = h, (m = t >= (d = (c + u) / 2)) ? c = d : u = d;
  while ((f = m << 1 | v) === (M = (g >= d) << 1 | p >= h));
  return r[M] = a, r[f] = o, n;
}
function o0(n) {
  var e, t, i = n.length, r, a, o = new Array(i), s = new Array(i), c = 1 / 0, l = 1 / 0, u = -1 / 0, h = -1 / 0;
  for (t = 0; t < i; ++t)
    isNaN(r = +this._x.call(null, e = n[t])) || isNaN(a = +this._y.call(null, e)) || (o[t] = r, s[t] = a, r < c && (c = r), r > u && (u = r), a < l && (l = a), a > h && (h = a));
  if (c > u || l > h)
    return this;
  for (this.cover(c, l).cover(u, h), t = 0; t < i; ++t)
    ju(this, o[t], s[t], n[t]);
  return this;
}
function s0(n, e) {
  if (isNaN(n = +n) || isNaN(e = +e))
    return this;
  var t = this._x0, i = this._y0, r = this._x1, a = this._y1;
  if (isNaN(t))
    r = (t = Math.floor(n)) + 1, a = (i = Math.floor(e)) + 1;
  else {
    for (var o = r - t || 1, s = this._root, c, l; t > n || n >= r || i > e || e >= a; )
      switch (l = (e < i) << 1 | n < t, c = new Array(4), c[l] = s, s = c, o *= 2, l) {
        case 0:
          r = t + o, a = i + o;
          break;
        case 1:
          t = r - o, a = i + o;
          break;
        case 2:
          r = t + o, i = a - o;
          break;
        case 3:
          t = r - o, i = a - o;
          break;
      }
    this._root && this._root.length && (this._root = s);
  }
  return this._x0 = t, this._y0 = i, this._x1 = r, this._y1 = a, this;
}
function c0() {
  var n = [];
  return this.visit(function(e) {
    if (!e.length)
      do
        n.push(e.data);
      while (e = e.next);
  }), n;
}
function l0(n) {
  return arguments.length ? this.cover(+n[0][0], +n[0][1]).cover(+n[1][0], +n[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]];
}
function Et(n, e, t, i, r) {
  this.node = n, this.x0 = e, this.y0 = t, this.x1 = i, this.y1 = r;
}
function u0(n, e, t) {
  var i, r = this._x0, a = this._y0, o, s, c, l, u = this._x1, h = this._y1, d = [], p = this._root, g, v;
  for (p && d.push(new Et(p, r, a, u, h)), t == null ? t = 1 / 0 : (r = n - t, a = e - t, u = n + t, h = e + t, t *= t); g = d.pop(); )
    if (!(!(p = g.node) || (o = g.x0) > u || (s = g.y0) > h || (c = g.x1) < r || (l = g.y1) < a))
      if (p.length) {
        var m = (o + c) / 2, f = (s + l) / 2;
        d.push(
          new Et(p[3], m, f, c, l),
          new Et(p[2], o, f, m, l),
          new Et(p[1], m, s, c, f),
          new Et(p[0], o, s, m, f)
        ), (v = (e >= f) << 1 | n >= m) && (g = d[d.length - 1], d[d.length - 1] = d[d.length - 1 - v], d[d.length - 1 - v] = g);
      } else {
        var M = n - +this._x.call(null, p.data), _ = e - +this._y.call(null, p.data), x = M * M + _ * _;
        if (x < t) {
          var T = Math.sqrt(t = x);
          r = n - T, a = e - T, u = n + T, h = e + T, i = p.data;
        }
      }
  return i;
}
function h0(n) {
  if (isNaN(u = +this._x.call(null, n)) || isNaN(h = +this._y.call(null, n)))
    return this;
  var e, t = this._root, i, r, a, o = this._x0, s = this._y0, c = this._x1, l = this._y1, u, h, d, p, g, v, m, f;
  if (!t)
    return this;
  if (t.length)
    for (; ; ) {
      if ((g = u >= (d = (o + c) / 2)) ? o = d : c = d, (v = h >= (p = (s + l) / 2)) ? s = p : l = p, e = t, !(t = t[m = v << 1 | g]))
        return this;
      if (!t.length)
        break;
      (e[m + 1 & 3] || e[m + 2 & 3] || e[m + 3 & 3]) && (i = e, f = m);
    }
  for (; t.data !== n; )
    if (r = t, !(t = t.next))
      return this;
  return (a = t.next) && delete t.next, r ? (a ? r.next = a : delete r.next, this) : e ? (a ? e[m] = a : delete e[m], (t = e[0] || e[1] || e[2] || e[3]) && t === (e[3] || e[2] || e[1] || e[0]) && !t.length && (i ? i[f] = t : this._root = t), this) : (this._root = a, this);
}
function f0(n) {
  for (var e = 0, t = n.length; e < t; ++e)
    this.remove(n[e]);
  return this;
}
function d0() {
  return this._root;
}
function p0() {
  var n = 0;
  return this.visit(function(e) {
    if (!e.length)
      do
        ++n;
      while (e = e.next);
  }), n;
}
function m0(n) {
  var e = [], t, i = this._root, r, a, o, s, c;
  for (i && e.push(new Et(i, this._x0, this._y0, this._x1, this._y1)); t = e.pop(); )
    if (!n(i = t.node, a = t.x0, o = t.y0, s = t.x1, c = t.y1) && i.length) {
      var l = (a + s) / 2, u = (o + c) / 2;
      (r = i[3]) && e.push(new Et(r, l, u, s, c)), (r = i[2]) && e.push(new Et(r, a, u, l, c)), (r = i[1]) && e.push(new Et(r, l, o, s, u)), (r = i[0]) && e.push(new Et(r, a, o, l, u));
    }
  return this;
}
function g0(n) {
  var e = [], t = [], i;
  for (this._root && e.push(new Et(this._root, this._x0, this._y0, this._x1, this._y1)); i = e.pop(); ) {
    var r = i.node;
    if (r.length) {
      var a, o = i.x0, s = i.y0, c = i.x1, l = i.y1, u = (o + c) / 2, h = (s + l) / 2;
      (a = r[0]) && e.push(new Et(a, o, s, u, h)), (a = r[1]) && e.push(new Et(a, u, s, c, h)), (a = r[2]) && e.push(new Et(a, o, h, u, l)), (a = r[3]) && e.push(new Et(a, u, h, c, l));
    }
    t.push(i);
  }
  for (; i = t.pop(); )
    n(i.node, i.x0, i.y0, i.x1, i.y1);
  return this;
}
function v0(n) {
  return n[0];
}
function _0(n) {
  return arguments.length ? (this._x = n, this) : this._x;
}
function y0(n) {
  return n[1];
}
function x0(n) {
  return arguments.length ? (this._y = n, this) : this._y;
}
function Xu(n, e, t) {
  var i = new xs(e ?? v0, t ?? y0, NaN, NaN, NaN, NaN);
  return n == null ? i : i.addAll(n);
}
function xs(n, e, t, i, r, a) {
  this._x = n, this._y = e, this._x0 = t, this._y0 = i, this._x1 = r, this._y1 = a, this._root = void 0;
}
function _l(n) {
  for (var e = { data: n.data }, t = e; n = n.next; )
    t = t.next = { data: n.data };
  return e;
}
var At = Xu.prototype = xs.prototype;
At.copy = function() {
  var n = new xs(this._x, this._y, this._x0, this._y0, this._x1, this._y1), e = this._root, t, i;
  if (!e)
    return n;
  if (!e.length)
    return n._root = _l(e), n;
  for (t = [{ source: e, target: n._root = new Array(4) }]; e = t.pop(); )
    for (var r = 0; r < 4; ++r)
      (i = e.source[r]) && (i.length ? t.push({ source: i, target: e.target[r] = new Array(4) }) : e.target[r] = _l(i));
  return n;
};
At.add = a0;
At.addAll = o0;
At.cover = s0;
At.data = c0;
At.extent = l0;
At.find = u0;
At.remove = h0;
At.removeAll = f0;
At.root = d0;
At.size = p0;
At.visit = m0;
At.visitAfter = g0;
At.x = _0;
At.y = x0;
function b0(n) {
  const e = +this._x.call(null, n), t = +this._y.call(null, n), i = +this._z.call(null, n);
  return $u(this.cover(e, t, i), e, t, i, n);
}
function $u(n, e, t, i, r) {
  if (isNaN(e) || isNaN(t) || isNaN(i))
    return n;
  var a, o = n._root, s = { data: r }, c = n._x0, l = n._y0, u = n._z0, h = n._x1, d = n._y1, p = n._z1, g, v, m, f, M, _, x, T, E, A, R;
  if (!o)
    return n._root = s, n;
  for (; o.length; )
    if ((x = e >= (g = (c + h) / 2)) ? c = g : h = g, (T = t >= (v = (l + d) / 2)) ? l = v : d = v, (E = i >= (m = (u + p) / 2)) ? u = m : p = m, a = o, !(o = o[A = E << 2 | T << 1 | x]))
      return a[A] = s, n;
  if (f = +n._x.call(null, o.data), M = +n._y.call(null, o.data), _ = +n._z.call(null, o.data), e === f && t === M && i === _)
    return s.next = o, a ? a[A] = s : n._root = s, n;
  do
    a = a ? a[A] = new Array(8) : n._root = new Array(8), (x = e >= (g = (c + h) / 2)) ? c = g : h = g, (T = t >= (v = (l + d) / 2)) ? l = v : d = v, (E = i >= (m = (u + p) / 2)) ? u = m : p = m;
  while ((A = E << 2 | T << 1 | x) === (R = (_ >= m) << 2 | (M >= v) << 1 | f >= g));
  return a[R] = o, a[A] = s, n;
}
function M0(n) {
  Array.isArray(n) || (n = Array.from(n));
  const e = n.length, t = new Float64Array(e), i = new Float64Array(e), r = new Float64Array(e);
  let a = 1 / 0, o = 1 / 0, s = 1 / 0, c = -1 / 0, l = -1 / 0, u = -1 / 0;
  for (let h = 0, d, p, g, v; h < e; ++h)
    isNaN(p = +this._x.call(null, d = n[h])) || isNaN(g = +this._y.call(null, d)) || isNaN(v = +this._z.call(null, d)) || (t[h] = p, i[h] = g, r[h] = v, p < a && (a = p), p > c && (c = p), g < o && (o = g), g > l && (l = g), v < s && (s = v), v > u && (u = v));
  if (a > c || o > l || s > u)
    return this;
  this.cover(a, o, s).cover(c, l, u);
  for (let h = 0; h < e; ++h)
    $u(this, t[h], i[h], r[h], n[h]);
  return this;
}
function S0(n, e, t) {
  if (isNaN(n = +n) || isNaN(e = +e) || isNaN(t = +t))
    return this;
  var i = this._x0, r = this._y0, a = this._z0, o = this._x1, s = this._y1, c = this._z1;
  if (isNaN(i))
    o = (i = Math.floor(n)) + 1, s = (r = Math.floor(e)) + 1, c = (a = Math.floor(t)) + 1;
  else {
    for (var l = o - i || 1, u = this._root, h, d; i > n || n >= o || r > e || e >= s || a > t || t >= c; )
      switch (d = (t < a) << 2 | (e < r) << 1 | n < i, h = new Array(8), h[d] = u, u = h, l *= 2, d) {
        case 0:
          o = i + l, s = r + l, c = a + l;
          break;
        case 1:
          i = o - l, s = r + l, c = a + l;
          break;
        case 2:
          o = i + l, r = s - l, c = a + l;
          break;
        case 3:
          i = o - l, r = s - l, c = a + l;
          break;
        case 4:
          o = i + l, s = r + l, a = c - l;
          break;
        case 5:
          i = o - l, s = r + l, a = c - l;
          break;
        case 6:
          o = i + l, r = s - l, a = c - l;
          break;
        case 7:
          i = o - l, r = s - l, a = c - l;
          break;
      }
    this._root && this._root.length && (this._root = u);
  }
  return this._x0 = i, this._y0 = r, this._z0 = a, this._x1 = o, this._y1 = s, this._z1 = c, this;
}
function E0() {
  var n = [];
  return this.visit(function(e) {
    if (!e.length)
      do
        n.push(e.data);
      while (e = e.next);
  }), n;
}
function w0(n) {
  return arguments.length ? this.cover(+n[0][0], +n[0][1], +n[0][2]).cover(+n[1][0], +n[1][1], +n[1][2]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0, this._z0], [this._x1, this._y1, this._z1]];
}
function Ze(n, e, t, i, r, a, o) {
  this.node = n, this.x0 = e, this.y0 = t, this.z0 = i, this.x1 = r, this.y1 = a, this.z1 = o;
}
function T0(n, e, t, i) {
  var r, a = this._x0, o = this._y0, s = this._z0, c, l, u, h, d, p, g = this._x1, v = this._y1, m = this._z1, f = [], M = this._root, _, x;
  for (M && f.push(new Ze(M, a, o, s, g, v, m)), i == null ? i = 1 / 0 : (a = n - i, o = e - i, s = t - i, g = n + i, v = e + i, m = t + i, i *= i); _ = f.pop(); )
    if (!(!(M = _.node) || (c = _.x0) > g || (l = _.y0) > v || (u = _.z0) > m || (h = _.x1) < a || (d = _.y1) < o || (p = _.z1) < s))
      if (M.length) {
        var T = (c + h) / 2, E = (l + d) / 2, A = (u + p) / 2;
        f.push(
          new Ze(M[7], T, E, A, h, d, p),
          new Ze(M[6], c, E, A, T, d, p),
          new Ze(M[5], T, l, A, h, E, p),
          new Ze(M[4], c, l, A, T, E, p),
          new Ze(M[3], T, E, u, h, d, A),
          new Ze(M[2], c, E, u, T, d, A),
          new Ze(M[1], T, l, u, h, E, A),
          new Ze(M[0], c, l, u, T, E, A)
        ), (x = (t >= A) << 2 | (e >= E) << 1 | n >= T) && (_ = f[f.length - 1], f[f.length - 1] = f[f.length - 1 - x], f[f.length - 1 - x] = _);
      } else {
        var R = n - +this._x.call(null, M.data), w = e - +this._y.call(null, M.data), b = t - +this._z.call(null, M.data), U = R * R + w * w + b * b;
        if (U < i) {
          var z = Math.sqrt(i = U);
          a = n - z, o = e - z, s = t - z, g = n + z, v = e + z, m = t + z, r = M.data;
        }
      }
  return r;
}
function A0(n) {
  if (isNaN(d = +this._x.call(null, n)) || isNaN(p = +this._y.call(null, n)) || isNaN(g = +this._z.call(null, n)))
    return this;
  var e, t = this._root, i, r, a, o = this._x0, s = this._y0, c = this._z0, l = this._x1, u = this._y1, h = this._z1, d, p, g, v, m, f, M, _, x, T, E;
  if (!t)
    return this;
  if (t.length)
    for (; ; ) {
      if ((M = d >= (v = (o + l) / 2)) ? o = v : l = v, (_ = p >= (m = (s + u) / 2)) ? s = m : u = m, (x = g >= (f = (c + h) / 2)) ? c = f : h = f, e = t, !(t = t[T = x << 2 | _ << 1 | M]))
        return this;
      if (!t.length)
        break;
      (e[T + 1 & 7] || e[T + 2 & 7] || e[T + 3 & 7] || e[T + 4 & 7] || e[T + 5 & 7] || e[T + 6 & 7] || e[T + 7 & 7]) && (i = e, E = T);
    }
  for (; t.data !== n; )
    if (r = t, !(t = t.next))
      return this;
  return (a = t.next) && delete t.next, r ? (a ? r.next = a : delete r.next, this) : e ? (a ? e[T] = a : delete e[T], (t = e[0] || e[1] || e[2] || e[3] || e[4] || e[5] || e[6] || e[7]) && t === (e[7] || e[6] || e[5] || e[4] || e[3] || e[2] || e[1] || e[0]) && !t.length && (i ? i[E] = t : this._root = t), this) : (this._root = a, this);
}
function C0(n) {
  for (var e = 0, t = n.length; e < t; ++e)
    this.remove(n[e]);
  return this;
}
function R0() {
  return this._root;
}
function P0() {
  var n = 0;
  return this.visit(function(e) {
    if (!e.length)
      do
        ++n;
      while (e = e.next);
  }), n;
}
function L0(n) {
  var e = [], t, i = this._root, r, a, o, s, c, l, u;
  for (i && e.push(new Ze(i, this._x0, this._y0, this._z0, this._x1, this._y1, this._z1)); t = e.pop(); )
    if (!n(i = t.node, a = t.x0, o = t.y0, s = t.z0, c = t.x1, l = t.y1, u = t.z1) && i.length) {
      var h = (a + c) / 2, d = (o + l) / 2, p = (s + u) / 2;
      (r = i[7]) && e.push(new Ze(r, h, d, p, c, l, u)), (r = i[6]) && e.push(new Ze(r, a, d, p, h, l, u)), (r = i[5]) && e.push(new Ze(r, h, o, p, c, d, u)), (r = i[4]) && e.push(new Ze(r, a, o, p, h, d, u)), (r = i[3]) && e.push(new Ze(r, h, d, s, c, l, p)), (r = i[2]) && e.push(new Ze(r, a, d, s, h, l, p)), (r = i[1]) && e.push(new Ze(r, h, o, s, c, d, p)), (r = i[0]) && e.push(new Ze(r, a, o, s, h, d, p));
    }
  return this;
}
function D0(n) {
  var e = [], t = [], i;
  for (this._root && e.push(new Ze(this._root, this._x0, this._y0, this._z0, this._x1, this._y1, this._z1)); i = e.pop(); ) {
    var r = i.node;
    if (r.length) {
      var a, o = i.x0, s = i.y0, c = i.z0, l = i.x1, u = i.y1, h = i.z1, d = (o + l) / 2, p = (s + u) / 2, g = (c + h) / 2;
      (a = r[0]) && e.push(new Ze(a, o, s, c, d, p, g)), (a = r[1]) && e.push(new Ze(a, d, s, c, l, p, g)), (a = r[2]) && e.push(new Ze(a, o, p, c, d, u, g)), (a = r[3]) && e.push(new Ze(a, d, p, c, l, u, g)), (a = r[4]) && e.push(new Ze(a, o, s, g, d, p, h)), (a = r[5]) && e.push(new Ze(a, d, s, g, l, p, h)), (a = r[6]) && e.push(new Ze(a, o, p, g, d, u, h)), (a = r[7]) && e.push(new Ze(a, d, p, g, l, u, h));
    }
    t.push(i);
  }
  for (; i = t.pop(); )
    n(i.node, i.x0, i.y0, i.z0, i.x1, i.y1, i.z1);
  return this;
}
function O0(n) {
  return n[0];
}
function I0(n) {
  return arguments.length ? (this._x = n, this) : this._x;
}
function N0(n) {
  return n[1];
}
function U0(n) {
  return arguments.length ? (this._y = n, this) : this._y;
}
function F0(n) {
  return n[2];
}
function B0(n) {
  return arguments.length ? (this._z = n, this) : this._z;
}
function qu(n, e, t, i) {
  var r = new bs(e ?? O0, t ?? N0, i ?? F0, NaN, NaN, NaN, NaN, NaN, NaN);
  return n == null ? r : r.addAll(n);
}
function bs(n, e, t, i, r, a, o, s, c) {
  this._x = n, this._y = e, this._z = t, this._x0 = i, this._y0 = r, this._z0 = a, this._x1 = o, this._y1 = s, this._z1 = c, this._root = void 0;
}
function yl(n) {
  for (var e = { data: n.data }, t = e; n = n.next; )
    t = t.next = { data: n.data };
  return e;
}
var bt = qu.prototype = bs.prototype;
bt.copy = function() {
  var n = new bs(this._x, this._y, this._z, this._x0, this._y0, this._z0, this._x1, this._y1, this._z1), e = this._root, t, i;
  if (!e)
    return n;
  if (!e.length)
    return n._root = yl(e), n;
  for (t = [{ source: e, target: n._root = new Array(8) }]; e = t.pop(); )
    for (var r = 0; r < 8; ++r)
      (i = e.source[r]) && (i.length ? t.push({ source: i, target: e.target[r] = new Array(8) }) : e.target[r] = yl(i));
  return n;
};
bt.add = b0;
bt.addAll = M0;
bt.cover = S0;
bt.data = E0;
bt.extent = w0;
bt.find = T0;
bt.remove = A0;
bt.removeAll = C0;
bt.root = R0;
bt.size = P0;
bt.visit = L0;
bt.visitAfter = D0;
bt.x = I0;
bt.y = U0;
bt.z = B0;
function Sn(n) {
  return function() {
    return n;
  };
}
function xn(n) {
  return (n() - 0.5) * 1e-6;
}
function k0(n) {
  return n.index;
}
function xl(n, e) {
  var t = n.get(e);
  if (!t)
    throw new Error("node not found: " + e);
  return t;
}
function z0(n) {
  var e = k0, t = d, i, r = Sn(30), a, o, s, c, l, u, h = 1;
  n == null && (n = []);
  function d(f) {
    return 1 / Math.min(c[f.source.index], c[f.target.index]);
  }
  function p(f) {
    for (var M = 0, _ = n.length; M < h; ++M)
      for (var x = 0, T, E, A, R = 0, w = 0, b = 0, U, z; x < _; ++x)
        T = n[x], E = T.source, A = T.target, R = A.x + A.vx - E.x - E.vx || xn(u), s > 1 && (w = A.y + A.vy - E.y - E.vy || xn(u)), s > 2 && (b = A.z + A.vz - E.z - E.vz || xn(u)), U = Math.sqrt(R * R + w * w + b * b), U = (U - a[x]) / U * f * i[x], R *= U, w *= U, b *= U, A.vx -= R * (z = l[x]), s > 1 && (A.vy -= w * z), s > 2 && (A.vz -= b * z), E.vx += R * (z = 1 - z), s > 1 && (E.vy += w * z), s > 2 && (E.vz += b * z);
  }
  function g() {
    if (o) {
      var f, M = o.length, _ = n.length, x = new Map(o.map((E, A) => [e(E, A, o), E])), T;
      for (f = 0, c = new Array(M); f < _; ++f)
        T = n[f], T.index = f, typeof T.source != "object" && (T.source = xl(x, T.source)), typeof T.target != "object" && (T.target = xl(x, T.target)), c[T.source.index] = (c[T.source.index] || 0) + 1, c[T.target.index] = (c[T.target.index] || 0) + 1;
      for (f = 0, l = new Array(_); f < _; ++f)
        T = n[f], l[f] = c[T.source.index] / (c[T.source.index] + c[T.target.index]);
      i = new Array(_), v(), a = new Array(_), m();
    }
  }
  function v() {
    if (o)
      for (var f = 0, M = n.length; f < M; ++f)
        i[f] = +t(n[f], f, n);
  }
  function m() {
    if (o)
      for (var f = 0, M = n.length; f < M; ++f)
        a[f] = +r(n[f], f, n);
  }
  return p.initialize = function(f, ...M) {
    o = f, u = M.find((_) => typeof _ == "function") || Math.random, s = M.find((_) => [1, 2, 3].includes(_)) || 2, g();
  }, p.links = function(f) {
    return arguments.length ? (n = f, g(), p) : n;
  }, p.id = function(f) {
    return arguments.length ? (e = f, p) : e;
  }, p.iterations = function(f) {
    return arguments.length ? (h = +f, p) : h;
  }, p.strength = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : Sn(+f), v(), p) : t;
  }, p.distance = function(f) {
    return arguments.length ? (r = typeof f == "function" ? f : Sn(+f), m(), p) : r;
  }, p;
}
var H0 = { value: () => {
} };
function Yu() {
  for (var n = 0, e = arguments.length, t = {}, i; n < e; ++n) {
    if (!(i = arguments[n] + "") || i in t || /[\s.]/.test(i))
      throw new Error("illegal type: " + i);
    t[i] = [];
  }
  return new ia(t);
}
function ia(n) {
  this._ = n;
}
function V0(n, e) {
  return n.trim().split(/^|\s+/).map(function(t) {
    var i = "", r = t.indexOf(".");
    if (r >= 0 && (i = t.slice(r + 1), t = t.slice(0, r)), t && !e.hasOwnProperty(t))
      throw new Error("unknown type: " + t);
    return { type: t, name: i };
  });
}
ia.prototype = Yu.prototype = {
  constructor: ia,
  on: function(n, e) {
    var t = this._, i = V0(n + "", t), r, a = -1, o = i.length;
    if (arguments.length < 2) {
      for (; ++a < o; )
        if ((r = (n = i[a]).type) && (r = G0(t[r], n.name)))
          return r;
      return;
    }
    if (e != null && typeof e != "function")
      throw new Error("invalid callback: " + e);
    for (; ++a < o; )
      if (r = (n = i[a]).type)
        t[r] = bl(t[r], n.name, e);
      else if (e == null)
        for (r in t)
          t[r] = bl(t[r], n.name, null);
    return this;
  },
  copy: function() {
    var n = {}, e = this._;
    for (var t in e)
      n[t] = e[t].slice();
    return new ia(n);
  },
  call: function(n, e) {
    if ((r = arguments.length - 2) > 0)
      for (var t = new Array(r), i = 0, r, a; i < r; ++i)
        t[i] = arguments[i + 2];
    if (!this._.hasOwnProperty(n))
      throw new Error("unknown type: " + n);
    for (a = this._[n], i = 0, r = a.length; i < r; ++i)
      a[i].value.apply(e, t);
  },
  apply: function(n, e, t) {
    if (!this._.hasOwnProperty(n))
      throw new Error("unknown type: " + n);
    for (var i = this._[n], r = 0, a = i.length; r < a; ++r)
      i[r].value.apply(e, t);
  }
};
function G0(n, e) {
  for (var t = 0, i = n.length, r; t < i; ++t)
    if ((r = n[t]).name === e)
      return r.value;
}
function bl(n, e, t) {
  for (var i = 0, r = n.length; i < r; ++i)
    if (n[i].name === e) {
      n[i] = H0, n = n.slice(0, i).concat(n.slice(i + 1));
      break;
    }
  return t != null && n.push({ name: e, value: t }), n;
}
var Vi = 0, or = 0, Qi = 0, Ku = 1e3, ua, sr, ha = 0, ci = 0, Aa = 0, _r = typeof performance == "object" && performance.now ? performance : Date, Zu = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(n) {
  setTimeout(n, 17);
};
function Ju() {
  return ci || (Zu(W0), ci = _r.now() + Aa);
}
function W0() {
  ci = 0;
}
function Wo() {
  this._call = this._time = this._next = null;
}
Wo.prototype = Qu.prototype = {
  constructor: Wo,
  restart: function(n, e, t) {
    if (typeof n != "function")
      throw new TypeError("callback is not a function");
    t = (t == null ? Ju() : +t) + (e == null ? 0 : +e), !this._next && sr !== this && (sr ? sr._next = this : ua = this, sr = this), this._call = n, this._time = t, jo();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, jo());
  }
};
function Qu(n, e, t) {
  var i = new Wo();
  return i.restart(n, e, t), i;
}
function j0() {
  Ju(), ++Vi;
  for (var n = ua, e; n; )
    (e = ci - n._time) >= 0 && n._call.call(void 0, e), n = n._next;
  --Vi;
}
function Ml() {
  ci = (ha = _r.now()) + Aa, Vi = or = 0;
  try {
    j0();
  } finally {
    Vi = 0, $0(), ci = 0;
  }
}
function X0() {
  var n = _r.now(), e = n - ha;
  e > Ku && (Aa -= e, ha = n);
}
function $0() {
  for (var n, e = ua, t, i = 1 / 0; e; )
    e._call ? (i > e._time && (i = e._time), n = e, e = e._next) : (t = e._next, e._next = null, e = n ? n._next = t : ua = t);
  sr = n, jo(i);
}
function jo(n) {
  if (!Vi) {
    or && (or = clearTimeout(or));
    var e = n - ci;
    e > 24 ? (n < 1 / 0 && (or = setTimeout(Ml, n - _r.now() - Aa)), Qi && (Qi = clearInterval(Qi))) : (Qi || (ha = _r.now(), Qi = setInterval(X0, Ku)), Vi = 1, Zu(Ml));
  }
}
const q0 = 1664525, Y0 = 1013904223, Sl = 4294967296;
function K0() {
  let n = 1;
  return () => (n = (q0 * n + Y0) % Sl) / Sl;
}
var El = 3;
function bo(n) {
  return n.x;
}
function wl(n) {
  return n.y;
}
function Z0(n) {
  return n.z;
}
var J0 = 10, Q0 = Math.PI * (3 - Math.sqrt(5)), ey = Math.PI * 20 / (9 + Math.sqrt(221));
function ty(n, e) {
  e = e || 2;
  var t = Math.min(El, Math.max(1, Math.round(e))), i, r = 1, a = 1e-3, o = 1 - Math.pow(a, 1 / 300), s = 0, c = 0.6, l = /* @__PURE__ */ new Map(), u = Qu(p), h = Yu("tick", "end"), d = K0();
  n == null && (n = []);
  function p() {
    g(), h.call("tick", i), r < a && (u.stop(), h.call("end", i));
  }
  function g(f) {
    var M, _ = n.length, x;
    f === void 0 && (f = 1);
    for (var T = 0; T < f; ++T)
      for (r += (s - r) * o, l.forEach(function(E) {
        E(r);
      }), M = 0; M < _; ++M)
        x = n[M], x.fx == null ? x.x += x.vx *= c : (x.x = x.fx, x.vx = 0), t > 1 && (x.fy == null ? x.y += x.vy *= c : (x.y = x.fy, x.vy = 0)), t > 2 && (x.fz == null ? x.z += x.vz *= c : (x.z = x.fz, x.vz = 0));
    return i;
  }
  function v() {
    for (var f = 0, M = n.length, _; f < M; ++f) {
      if (_ = n[f], _.index = f, _.fx != null && (_.x = _.fx), _.fy != null && (_.y = _.fy), _.fz != null && (_.z = _.fz), isNaN(_.x) || t > 1 && isNaN(_.y) || t > 2 && isNaN(_.z)) {
        var x = J0 * (t > 2 ? Math.cbrt(0.5 + f) : t > 1 ? Math.sqrt(0.5 + f) : f), T = f * Q0, E = f * ey;
        t === 1 ? _.x = x : t === 2 ? (_.x = x * Math.cos(T), _.y = x * Math.sin(T)) : (_.x = x * Math.sin(T) * Math.cos(E), _.y = x * Math.cos(T), _.z = x * Math.sin(T) * Math.sin(E));
      }
      (isNaN(_.vx) || t > 1 && isNaN(_.vy) || t > 2 && isNaN(_.vz)) && (_.vx = 0, t > 1 && (_.vy = 0), t > 2 && (_.vz = 0));
    }
  }
  function m(f) {
    return f.initialize && f.initialize(n, d, t), f;
  }
  return v(), i = {
    tick: g,
    restart: function() {
      return u.restart(p), i;
    },
    stop: function() {
      return u.stop(), i;
    },
    numDimensions: function(f) {
      return arguments.length ? (t = Math.min(El, Math.max(1, Math.round(f))), l.forEach(m), i) : t;
    },
    nodes: function(f) {
      return arguments.length ? (n = f, v(), l.forEach(m), i) : n;
    },
    alpha: function(f) {
      return arguments.length ? (r = +f, i) : r;
    },
    alphaMin: function(f) {
      return arguments.length ? (a = +f, i) : a;
    },
    alphaDecay: function(f) {
      return arguments.length ? (o = +f, i) : +o;
    },
    alphaTarget: function(f) {
      return arguments.length ? (s = +f, i) : s;
    },
    velocityDecay: function(f) {
      return arguments.length ? (c = 1 - f, i) : 1 - c;
    },
    randomSource: function(f) {
      return arguments.length ? (d = f, l.forEach(m), i) : d;
    },
    force: function(f, M) {
      return arguments.length > 1 ? (M == null ? l.delete(f) : l.set(f, m(M)), i) : l.get(f);
    },
    find: function() {
      var f = Array.prototype.slice.call(arguments), M = f.shift() || 0, _ = (t > 1 ? f.shift() : null) || 0, x = (t > 2 ? f.shift() : null) || 0, T = f.shift() || 1 / 0, E = 0, A = n.length, R, w, b, U, z, I;
      for (T *= T, E = 0; E < A; ++E)
        z = n[E], R = M - z.x, w = _ - (z.y || 0), b = x - (z.z || 0), U = R * R + w * w + b * b, U < T && (I = z, T = U);
      return I;
    },
    on: function(f, M) {
      return arguments.length > 1 ? (h.on(f, M), i) : h.on(f);
    }
  };
}
function ny() {
  var n, e, t, i, r, a = Sn(-30), o, s = 1, c = 1 / 0, l = 0.81;
  function u(g) {
    var v, m = n.length, f = (e === 1 ? Wu(n, bo) : e === 2 ? Xu(n, bo, wl) : e === 3 ? qu(n, bo, wl, Z0) : null).visitAfter(d);
    for (r = g, v = 0; v < m; ++v)
      t = n[v], f.visit(p);
  }
  function h() {
    if (n) {
      var g, v = n.length, m;
      for (o = new Array(v), g = 0; g < v; ++g)
        m = n[g], o[m.index] = +a(m, g, n);
    }
  }
  function d(g) {
    var v = 0, m, f, M = 0, _, x, T, E, A = g.length;
    if (A) {
      for (_ = x = T = E = 0; E < A; ++E)
        (m = g[E]) && (f = Math.abs(m.value)) && (v += m.value, M += f, _ += f * (m.x || 0), x += f * (m.y || 0), T += f * (m.z || 0));
      v *= Math.sqrt(4 / A), g.x = _ / M, e > 1 && (g.y = x / M), e > 2 && (g.z = T / M);
    } else {
      m = g, m.x = m.data.x, e > 1 && (m.y = m.data.y), e > 2 && (m.z = m.data.z);
      do
        v += o[m.data.index];
      while (m = m.next);
    }
    g.value = v;
  }
  function p(g, v, m, f, M) {
    if (!g.value)
      return !0;
    var _ = [m, f, M][e - 1], x = g.x - t.x, T = e > 1 ? g.y - t.y : 0, E = e > 2 ? g.z - t.z : 0, A = _ - v, R = x * x + T * T + E * E;
    if (A * A / l < R)
      return R < c && (x === 0 && (x = xn(i), R += x * x), e > 1 && T === 0 && (T = xn(i), R += T * T), e > 2 && E === 0 && (E = xn(i), R += E * E), R < s && (R = Math.sqrt(s * R)), t.vx += x * g.value * r / R, e > 1 && (t.vy += T * g.value * r / R), e > 2 && (t.vz += E * g.value * r / R)), !0;
    if (g.length || R >= c)
      return;
    (g.data !== t || g.next) && (x === 0 && (x = xn(i), R += x * x), e > 1 && T === 0 && (T = xn(i), R += T * T), e > 2 && E === 0 && (E = xn(i), R += E * E), R < s && (R = Math.sqrt(s * R)));
    do
      g.data !== t && (A = o[g.data.index] * r / R, t.vx += x * A, e > 1 && (t.vy += T * A), e > 2 && (t.vz += E * A));
    while (g = g.next);
  }
  return u.initialize = function(g, ...v) {
    n = g, i = v.find((m) => typeof m == "function") || Math.random, e = v.find((m) => [1, 2, 3].includes(m)) || 2, h();
  }, u.strength = function(g) {
    return arguments.length ? (a = typeof g == "function" ? g : Sn(+g), h(), u) : a;
  }, u.distanceMin = function(g) {
    return arguments.length ? (s = g * g, u) : Math.sqrt(s);
  }, u.distanceMax = function(g) {
    return arguments.length ? (c = g * g, u) : Math.sqrt(c);
  }, u.theta = function(g) {
    return arguments.length ? (l = g * g, u) : Math.sqrt(l);
  }, u;
}
function iy(n, e, t, i) {
  var r, a, o = Sn(0.1), s, c;
  typeof n != "function" && (n = Sn(+n)), e == null && (e = 0), t == null && (t = 0), i == null && (i = 0);
  function l(h) {
    for (var d = 0, p = r.length; d < p; ++d) {
      var g = r[d], v = g.x - e || 1e-6, m = (g.y || 0) - t || 1e-6, f = (g.z || 0) - i || 1e-6, M = Math.sqrt(v * v + m * m + f * f), _ = (c[d] - M) * s[d] * h / M;
      g.vx += v * _, a > 1 && (g.vy += m * _), a > 2 && (g.vz += f * _);
    }
  }
  function u() {
    if (r) {
      var h, d = r.length;
      for (s = new Array(d), c = new Array(d), h = 0; h < d; ++h)
        c[h] = +n(r[h], h, r), s[h] = isNaN(c[h]) ? 0 : +o(r[h], h, r);
    }
  }
  return l.initialize = function(h, ...d) {
    r = h, a = d.find((p) => [1, 2, 3].includes(p)) || 2, u();
  }, l.strength = function(h) {
    return arguments.length ? (o = typeof h == "function" ? h : Sn(+h), u(), l) : o;
  }, l.radius = function(h) {
    return arguments.length ? (n = typeof h == "function" ? h : Sn(+h), u(), l) : n;
  }, l.x = function(h) {
    return arguments.length ? (e = +h, l) : e;
  }, l.y = function(h) {
    return arguments.length ? (t = +h, l) : t;
  }, l.z = function(h) {
    return arguments.length ? (i = +h, l) : i;
  }, l;
}
var Ms = function(e) {
  ay(e);
  var t = ry(e);
  return e.on = t.on, e.off = t.off, e.fire = t.fire, e;
};
function ry(n) {
  var e = /* @__PURE__ */ Object.create(null);
  return {
    on: function(t, i, r) {
      if (typeof i != "function")
        throw new Error("callback is expected to be a function");
      var a = e[t];
      return a || (a = e[t] = []), a.push({ callback: i, ctx: r }), n;
    },
    off: function(t, i) {
      var r = typeof t > "u";
      if (r)
        return e = /* @__PURE__ */ Object.create(null), n;
      if (e[t]) {
        var a = typeof i != "function";
        if (a)
          delete e[t];
        else
          for (var o = e[t], s = 0; s < o.length; ++s)
            o[s].callback === i && o.splice(s, 1);
      }
      return n;
    },
    fire: function(t) {
      var i = e[t];
      if (!i)
        return n;
      var r;
      arguments.length > 1 && (r = Array.prototype.splice.call(arguments, 1));
      for (var a = 0; a < i.length; ++a) {
        var o = i[a];
        o.callback.apply(o.ctx, r);
      }
      return n;
    }
  };
}
function ay(n) {
  if (!n)
    throw new Error("Eventify cannot use falsy object as events subject");
  for (var e = ["on", "fire", "off"], t = 0; t < e.length; ++t)
    if (n.hasOwnProperty(e[t]))
      throw new Error("Subject cannot be eventified, since it already has property '" + e[t] + "'");
}
var oy = cy, sy = Ms;
function cy(n) {
  if (n = n || {}, "uniqueLinkId" in n && (console.warn(
    "ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\nUse `multigraph` option instead\n",
    `
`,
    `Note: there is also change in default behavior: From now on each graph
is considered to be not a multigraph by default (each edge is unique).`
  ), n.multigraph = n.uniqueLinkId), n.multigraph === void 0 && (n.multigraph = !1), typeof Map != "function")
    throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph");
  var e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), i = {}, r = 0, a = n.multigraph ? x : _, o = [], s = B, c = B, l = B, u = B, h = {
    /**
     * Sometimes duck typing could be slow. Giving clients a hint about data structure
     * via explicit version number here:
     */
    version: 20,
    /**
     * Adds node to the graph. If node with given id already exists in the graph
     * its data is extended with whatever comes in 'data' argument.
     *
     * @param nodeId the node's identifier. A string or number is preferred.
     * @param [data] additional data for the node being added. If node already
     *   exists its data object is augmented with the new one.
     *
     * @return {node} The newly added node or node with given id if it already exists.
     */
    addNode: v,
    /**
     * Adds a link to the graph. The function always create a new
     * link between two nodes. If one of the nodes does not exists
     * a new node is created.
     *
     * @param fromId link start node id;
     * @param toId link end node id;
     * @param [data] additional data to be set on the new link;
     *
     * @return {link} The newly created link
     */
    addLink: M,
    /**
     * Removes link from the graph. If link does not exist does nothing.
     *
     * @param link - object returned by addLink() or getLinks() methods.
     *
     * @returns true if link was removed; false otherwise.
     */
    removeLink: R,
    /**
     * Removes node with given id from the graph. If node does not exist in the graph
     * does nothing.
     *
     * @param nodeId node's identifier passed to addNode() function.
     *
     * @returns true if node was removed; false otherwise.
     */
    removeNode: f,
    /**
     * Gets node with given identifier. If node does not exist undefined value is returned.
     *
     * @param nodeId requested node identifier;
     *
     * @return {node} in with requested identifier or undefined if no such node exists.
     */
    getNode: m,
    /**
     * Gets number of nodes in this graph.
     *
     * @return number of nodes in the graph.
     */
    getNodeCount: T,
    /**
     * Gets total number of links in the graph.
     */
    getLinkCount: E,
    /**
     * Gets total number of links in the graph.
     */
    getEdgeCount: E,
    /**
     * Synonym for `getLinkCount()`
     */
    getLinksCount: E,
    /**
     * Synonym for `getNodeCount()`
     */
    getNodesCount: T,
    /**
     * Gets all links (inbound and outbound) from the node with given id.
     * If node with given id is not found null is returned.
     *
     * @param nodeId requested node identifier.
     *
     * @return Set of links from and to requested node if such node exists;
     *   otherwise null is returned.
     */
    getLinks: A,
    /**
     * Invokes callback on each node of the graph.
     *
     * @param {Function(node)} callback Function to be invoked. The function
     *   is passed one argument: visited node.
     */
    forEachNode: ie,
    /**
     * Invokes callback on every linked (adjacent) node to the given one.
     *
     * @param nodeId Identifier of the requested node.
     * @param {Function(node, link)} callback Function to be called on all linked nodes.
     *   The function is passed two parameters: adjacent node and link object itself.
     * @param oriented if true graph treated as oriented.
     */
    forEachLinkedNode: I,
    /**
     * Enumerates all links in the graph
     *
     * @param {Function(link)} callback Function to be called on all links in the graph.
     *   The function is passed one parameter: graph's link object.
     *
     * Link object contains at least the following fields:
     *  fromId - node id where link starts;
     *  toId - node id where link ends,
     *  data - additional data passed to graph.addLink() method.
     */
    forEachLink: z,
    /**
     * Suspend all notifications about graph changes until
     * endUpdate is called.
     */
    beginUpdate: l,
    /**
     * Resumes all notifications about graph changes and fires
     * graph 'changed' event in case there are any pending changes.
     */
    endUpdate: u,
    /**
     * Removes all nodes and links from the graph.
     */
    clear: U,
    /**
     * Detects whether there is a link between two nodes.
     * Operation complexity is O(n) where n - number of links of a node.
     * NOTE: this function is synonym for getLink()
     *
     * @returns link if there is one. null otherwise.
     */
    hasLink: b,
    /**
     * Detects whether there is a node with given id
     * 
     * Operation complexity is O(1)
     * NOTE: this function is synonym for getNode()
     *
     * @returns node if there is one; Falsy value otherwise.
     */
    hasNode: m,
    /**
     * Gets an edge between two nodes.
     * Operation complexity is O(n) where n - number of links of a node.
     *
     * @param {string} fromId link start identifier
     * @param {string} toId link end identifier
     *
     * @returns link if there is one; undefined otherwise.
     */
    getLink: b
  };
  return sy(h), d(), h;
  function d() {
    var G = h.on;
    h.on = Q;
    function Q() {
      return h.beginUpdate = l = te, h.endUpdate = u = W, s = p, c = g, h.on = G, G.apply(h, arguments);
    }
  }
  function p(G, Q) {
    o.push({
      link: G,
      changeType: Q
    });
  }
  function g(G, Q) {
    o.push({
      node: G,
      changeType: Q
    });
  }
  function v(G, Q) {
    if (G === void 0)
      throw new Error("Invalid node identifier");
    l();
    var se = m(G);
    return se ? (se.data = Q, c(se, "update")) : (se = new ly(G, Q), c(se, "add")), e.set(G, se), u(), se;
  }
  function m(G) {
    return e.get(G);
  }
  function f(G) {
    var Q = m(G);
    if (!Q)
      return !1;
    l();
    var se = Q.links;
    return se && (se.forEach(w), Q.links = null), e.delete(G), c(Q, "remove"), u(), !0;
  }
  function M(G, Q, se) {
    l();
    var xe = m(G) || v(G), k = m(Q) || v(Q), H = a(G, Q, se), Z = t.has(H.id);
    return t.set(H.id, H), Tl(xe, H), G !== Q && Tl(k, H), s(H, Z ? "update" : "add"), u(), H;
  }
  function _(G, Q, se) {
    var xe = Jr(G, Q), k = t.get(xe);
    return k ? (k.data = se, k) : new Al(G, Q, se, xe);
  }
  function x(G, Q, se) {
    var xe = Jr(G, Q), k = i.hasOwnProperty(xe);
    if (k || b(G, Q)) {
      k || (i[xe] = 0);
      var H = "@" + ++i[xe];
      xe = Jr(G + H, Q + H);
    }
    return new Al(G, Q, se, xe);
  }
  function T() {
    return e.size;
  }
  function E() {
    return t.size;
  }
  function A(G) {
    var Q = m(G);
    return Q ? Q.links : null;
  }
  function R(G, Q) {
    return Q !== void 0 && (G = b(G, Q)), w(G);
  }
  function w(G) {
    if (!G || !t.get(G.id))
      return !1;
    l(), t.delete(G.id);
    var Q = m(G.fromId), se = m(G.toId);
    return Q && Q.links.delete(G), se && se.links.delete(G), s(G, "remove"), u(), !0;
  }
  function b(G, Q) {
    if (!(G === void 0 || Q === void 0))
      return t.get(Jr(G, Q));
  }
  function U() {
    l(), ie(function(G) {
      f(G.id);
    }), u();
  }
  function z(G) {
    if (typeof G == "function")
      for (var Q = t.values(), se = Q.next(); !se.done; ) {
        if (G(se.value))
          return !0;
        se = Q.next();
      }
  }
  function I(G, Q, se) {
    var xe = m(G);
    if (xe && xe.links && typeof Q == "function")
      return se ? D(xe.links, G, Q) : L(xe.links, G, Q);
  }
  function L(G, Q, se) {
    for (var xe, k = G.values(), H = k.next(); !H.done; ) {
      var Z = H.value, N = Z.fromId === Q ? Z.toId : Z.fromId;
      if (xe = se(e.get(N), Z), xe)
        return !0;
      H = k.next();
    }
  }
  function D(G, Q, se) {
    for (var xe, k = G.values(), H = k.next(); !H.done; ) {
      var Z = H.value;
      if (Z.fromId === Q && (xe = se(e.get(Z.toId), Z), xe))
        return !0;
      H = k.next();
    }
  }
  function B() {
  }
  function te() {
    r += 1;
  }
  function W() {
    r -= 1, r === 0 && o.length > 0 && (h.fire("changed", o), o.length = 0);
  }
  function ie(G) {
    if (typeof G != "function")
      throw new Error("Function is expected to iterate over graph nodes. You passed " + G);
    for (var Q = e.values(), se = Q.next(); !se.done; ) {
      if (G(se.value))
        return !0;
      se = Q.next();
    }
  }
}
function ly(n, e) {
  this.id = n, this.links = null, this.data = e;
}
function Tl(n, e) {
  n.links ? n.links.add(e) : n.links = /* @__PURE__ */ new Set([e]);
}
function Al(n, e, t, i) {
  this.fromId = n, this.toId = e, this.data = t, this.id = i;
}
function Jr(n, e) {
  return n.toString() + "👉 " + e.toString();
}
const uy = /* @__PURE__ */ su(oy);
var Ss = { exports: {} }, Sr = { exports: {} }, eh = function(e) {
  return e === 0 ? "x" : e === 1 ? "y" : e === 2 ? "z" : "c" + (e + 1);
};
const hy = eh;
var Xi = function(e) {
  return t;
  function t(i, r) {
    let a = r && r.indent || 0, o = r && r.join !== void 0 ? r.join : `
`, s = Array(a + 1).join(" "), c = [];
    for (let l = 0; l < e; ++l) {
      let u = hy(l), h = l === 0 ? "" : s;
      c.push(h + i.replace(/{var}/g, u));
    }
    return c.join(o);
  }
};
const th = Xi;
Sr.exports = fy;
Sr.exports.generateCreateBodyFunctionBody = nh;
Sr.exports.getVectorCode = rh;
Sr.exports.getBodyCode = ih;
function fy(n, e) {
  let t = nh(n, e), { Body: i } = new Function(t)();
  return i;
}
function nh(n, e) {
  return `
${rh(n, e)}
${ih(n)}
return {Body: Body, Vector: Vector};
`;
}
function ih(n) {
  let e = th(n), t = e("{var}", { join: ", " });
  return `
function Body(${t}) {
  this.isPinned = false;
  this.pos = new Vector(${t});
  this.force = new Vector();
  this.velocity = new Vector();
  this.mass = 1;

  this.springCount = 0;
  this.springLength = 0;
}

Body.prototype.reset = function() {
  this.force.reset();
  this.springCount = 0;
  this.springLength = 0;
}

Body.prototype.setPosition = function (${t}) {
  ${e("this.pos.{var} = {var} || 0;", { indent: 2 })}
};`;
}
function rh(n, e) {
  let t = th(n), i = "";
  return e && (i = `${t(`
   var v{var};
Object.defineProperty(this, '{var}', {
  set: function(v) { 
    if (!Number.isFinite(v)) throw new Error('Cannot set non-numbers to {var}');
    v{var} = v; 
  },
  get: function() { return v{var}; }
});`)}`), `function Vector(${t("{var}", { join: ", " })}) {
  ${i}
    if (typeof arguments[0] === 'object') {
      // could be another vector
      let v = arguments[0];
      ${t('if (!Number.isFinite(v.{var})) throw new Error("Expected value is not a finite number at Vector constructor ({var})");', { indent: 4 })}
      ${t("this.{var} = v.{var};", { indent: 4 })}
    } else {
      ${t('this.{var} = typeof {var} === "number" ? {var} : 0;', { indent: 4 })}
    }
  }
  
  Vector.prototype.reset = function () {
    ${t("this.{var} = ", { join: "" })}0;
  };`;
}
var dy = Sr.exports, Wn = { exports: {} };
const Es = Xi, Un = eh;
Wn.exports = py;
Wn.exports.generateQuadTreeFunctionBody = ah;
Wn.exports.getInsertStackCode = uh;
Wn.exports.getQuadNodeCode = lh;
Wn.exports.isSamePosition = oh;
Wn.exports.getChildBodyCode = ch;
Wn.exports.setChildBodyCode = sh;
function py(n) {
  let e = ah(n);
  return new Function(e)();
}
function ah(n) {
  let e = Es(n), t = Math.pow(2, n);
  return `
${uh()}
${lh(n)}
${oh(n)}
${ch(n)}
${sh(n)}

function createQuadTree(options, random) {
  options = options || {};
  options.gravity = typeof options.gravity === 'number' ? options.gravity : -1;
  options.theta = typeof options.theta === 'number' ? options.theta : 0.8;

  var gravity = options.gravity;
  var updateQueue = [];
  var insertStack = new InsertStack();
  var theta = options.theta;

  var nodesCache = [];
  var currentInCache = 0;
  var root = newNode();

  return {
    insertBodies: insertBodies,

    /**
     * Gets root node if it is present
     */
    getRoot: function() {
      return root;
    },

    updateBodyForce: update,

    options: function(newOptions) {
      if (newOptions) {
        if (typeof newOptions.gravity === 'number') {
          gravity = newOptions.gravity;
        }
        if (typeof newOptions.theta === 'number') {
          theta = newOptions.theta;
        }

        return this;
      }

      return {
        gravity: gravity,
        theta: theta
      };
    }
  };

  function newNode() {
    // To avoid pressure on GC we reuse nodes.
    var node = nodesCache[currentInCache];
    if (node) {
${o("      node.")}
      node.body = null;
      node.mass = ${e("node.mass_{var} = ", { join: "" })}0;
      ${e("node.min_{var} = node.max_{var} = ", { join: "" })}0;
    } else {
      node = new QuadNode();
      nodesCache[currentInCache] = node;
    }

    ++currentInCache;
    return node;
  }

  function update(sourceBody) {
    var queue = updateQueue;
    var v;
    ${e("var d{var};", { indent: 4 })}
    var r; 
    ${e("var f{var} = 0;", { indent: 4 })}
    var queueLength = 1;
    var shiftIdx = 0;
    var pushIdx = 1;

    queue[0] = root;

    while (queueLength) {
      var node = queue[shiftIdx];
      var body = node.body;

      queueLength -= 1;
      shiftIdx += 1;
      var differentBody = (body !== sourceBody);
      if (body && differentBody) {
        // If the current node is a leaf node (and it is not source body),
        // calculate the force exerted by the current node on body, and add this
        // amount to body's net force.
        ${e("d{var} = body.pos.{var} - sourceBody.pos.{var};", { indent: 8 })}
        r = Math.sqrt(${e("d{var} * d{var}", { join: " + " })});

        if (r === 0) {
          // Poor man's protection against zero distance.
          ${e("d{var} = (random.nextDouble() - 0.5) / 50;", { indent: 10 })}
          r = Math.sqrt(${e("d{var} * d{var}", { join: " + " })});
        }

        // This is standard gravitation force calculation but we divide
        // by r^3 to save two operations when normalizing force vector.
        v = gravity * body.mass * sourceBody.mass / (r * r * r);
        ${e("f{var} += v * d{var};", { indent: 8 })}
      } else if (differentBody) {
        // Otherwise, calculate the ratio s / r,  where s is the width of the region
        // represented by the internal node, and r is the distance between the body
        // and the node's center-of-mass
        ${e("d{var} = node.mass_{var} / node.mass - sourceBody.pos.{var};", { indent: 8 })}
        r = Math.sqrt(${e("d{var} * d{var}", { join: " + " })});

        if (r === 0) {
          // Sorry about code duplication. I don't want to create many functions
          // right away. Just want to see performance first.
          ${e("d{var} = (random.nextDouble() - 0.5) / 50;", { indent: 10 })}
          r = Math.sqrt(${e("d{var} * d{var}", { join: " + " })});
        }
        // If s / r < θ, treat this internal node as a single body, and calculate the
        // force it exerts on sourceBody, and add this amount to sourceBody's net force.
        if ((node.max_${Un(0)} - node.min_${Un(0)}) / r < theta) {
          // in the if statement above we consider node's width only
          // because the region was made into square during tree creation.
          // Thus there is no difference between using width or height.
          v = gravity * node.mass * sourceBody.mass / (r * r * r);
          ${e("f{var} += v * d{var};", { indent: 10 })}
        } else {
          // Otherwise, run the procedure recursively on each of the current node's children.

          // I intentionally unfolded this loop, to save several CPU cycles.
${a()}
        }
      }
    }

    ${e("sourceBody.force.{var} += f{var};", { indent: 4 })}
  }

  function insertBodies(bodies) {
    ${e("var {var}min = Number.MAX_VALUE;", { indent: 4 })}
    ${e("var {var}max = Number.MIN_VALUE;", { indent: 4 })}
    var i = bodies.length;

    // To reduce quad tree depth we are looking for exact bounding box of all particles.
    while (i--) {
      var pos = bodies[i].pos;
      ${e("if (pos.{var} < {var}min) {var}min = pos.{var};", { indent: 6 })}
      ${e("if (pos.{var} > {var}max) {var}max = pos.{var};", { indent: 6 })}
    }

    // Makes the bounds square.
    var maxSideLength = -Infinity;
    ${e("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;", { indent: 4 })}

    currentInCache = 0;
    root = newNode();
    ${e("root.min_{var} = {var}min;", { indent: 4 })}
    ${e("root.max_{var} = {var}min + maxSideLength;", { indent: 4 })}

    i = bodies.length - 1;
    if (i >= 0) {
      root.body = bodies[i];
    }
    while (i--) {
      insert(bodies[i], root);
    }
  }

  function insert(newBody) {
    insertStack.reset();
    insertStack.push(root, newBody);

    while (!insertStack.isEmpty()) {
      var stackItem = insertStack.pop();
      var node = stackItem.node;
      var body = stackItem.body;

      if (!node.body) {
        // This is internal node. Update the total mass of the node and center-of-mass.
        ${e("var {var} = body.pos.{var};", { indent: 8 })}
        node.mass += body.mass;
        ${e("node.mass_{var} += body.mass * {var};", { indent: 8 })}

        // Recursively insert the body in the appropriate quadrant.
        // But first find the appropriate quadrant.
        var quadIdx = 0; // Assume we are in the 0's quad.
        ${e("var min_{var} = node.min_{var};", { indent: 8 })}
        ${e("var max_{var} = (min_{var} + node.max_{var}) / 2;", { indent: 8 })}

${r(8)}

        var child = getChild(node, quadIdx);

        if (!child) {
          // The node is internal but this quadrant is not taken. Add
          // subnode to it.
          child = newNode();
          ${e("child.min_{var} = min_{var};", { indent: 10 })}
          ${e("child.max_{var} = max_{var};", { indent: 10 })}
          child.body = body;

          setChild(node, quadIdx, child);
        } else {
          // continue searching in this quadrant.
          insertStack.push(child, body);
        }
      } else {
        // We are trying to add to the leaf node.
        // We have to convert current leaf into internal node
        // and continue adding two nodes.
        var oldBody = node.body;
        node.body = null; // internal nodes do not cary bodies

        if (isSamePosition(oldBody.pos, body.pos)) {
          // Prevent infinite subdivision by bumping one node
          // anywhere in this quadrant
          var retriesCount = 3;
          do {
            var offset = random.nextDouble();
            ${e("var d{var} = (node.max_{var} - node.min_{var}) * offset;", { indent: 12 })}

            ${e("oldBody.pos.{var} = node.min_{var} + d{var};", { indent: 12 })}
            retriesCount -= 1;
            // Make sure we don't bump it out of the box. If we do, next iteration should fix it
          } while (retriesCount > 0 && isSamePosition(oldBody.pos, body.pos));

          if (retriesCount === 0 && isSamePosition(oldBody.pos, body.pos)) {
            // This is very bad, we ran out of precision.
            // if we do not return from the method we'll get into
            // infinite loop here. So we sacrifice correctness of layout, and keep the app running
            // Next layout iteration should get larger bounding box in the first step and fix this
            return;
          }
        }
        // Next iteration should subdivide node further.
        insertStack.push(node, oldBody);
        insertStack.push(node, body);
      }
    }
  }
}
return createQuadTree;

`;
  function r(s) {
    let c = [], l = Array(s + 1).join(" ");
    for (let u = 0; u < n; ++u)
      c.push(l + `if (${Un(u)} > max_${Un(u)}) {`), c.push(l + `  quadIdx = quadIdx + ${Math.pow(2, u)};`), c.push(l + `  min_${Un(u)} = max_${Un(u)};`), c.push(l + `  max_${Un(u)} = node.max_${Un(u)};`), c.push(l + "}");
    return c.join(`
`);
  }
  function a() {
    let s = Array(11).join(" "), c = [];
    for (let l = 0; l < t; ++l)
      c.push(s + `if (node.quad${l}) {`), c.push(s + `  queue[pushIdx] = node.quad${l};`), c.push(s + "  queueLength += 1;"), c.push(s + "  pushIdx += 1;"), c.push(s + "}");
    return c.join(`
`);
  }
  function o(s) {
    let c = [];
    for (let l = 0; l < t; ++l)
      c.push(`${s}quad${l} = null;`);
    return c.join(`
`);
  }
}
function oh(n) {
  let e = Es(n);
  return `
  function isSamePosition(point1, point2) {
    ${e("var d{var} = Math.abs(point1.{var} - point2.{var});", { indent: 2 })}
  
    return ${e("d{var} < 1e-8", { join: " && " })};
  }  
`;
}
function sh(n) {
  var e = Math.pow(2, n);
  return `
function setChild(node, idx, child) {
  ${t()}
}`;
  function t() {
    let i = [];
    for (let r = 0; r < e; ++r) {
      let a = r === 0 ? "  " : "  else ";
      i.push(`${a}if (idx === ${r}) node.quad${r} = child;`);
    }
    return i.join(`
`);
  }
}
function ch(n) {
  return `function getChild(node, idx) {
${e()}
  return null;
}`;
  function e() {
    let t = [], i = Math.pow(2, n);
    for (let r = 0; r < i; ++r)
      t.push(`  if (idx === ${r}) return node.quad${r};`);
    return t.join(`
`);
  }
}
function lh(n) {
  let e = Es(n), t = Math.pow(2, n);
  var i = `
function QuadNode() {
  // body stored inside this node. In quad tree only leaf nodes (by construction)
  // contain bodies:
  this.body = null;

  // Child nodes are stored in quads. Each quad is presented by number:
  // 0 | 1
  // -----
  // 2 | 3
${r("  this.")}

  // Total mass of current node
  this.mass = 0;

  // Center of mass coordinates
  ${e("this.mass_{var} = 0;", { indent: 2 })}

  // bounding box coordinates
  ${e("this.min_{var} = 0;", { indent: 2 })}
  ${e("this.max_{var} = 0;", { indent: 2 })}
}
`;
  return i;
  function r(a) {
    let o = [];
    for (let s = 0; s < t; ++s)
      o.push(`${a}quad${s} = null;`);
    return o.join(`
`);
  }
}
function uh() {
  return `
/**
 * Our implementation of QuadTree is non-recursive to avoid GC hit
 * This data structure represent stack of elements
 * which we are trying to insert into quad tree.
 */
function InsertStack () {
    this.stack = [];
    this.popIdx = 0;
}

InsertStack.prototype = {
    isEmpty: function() {
        return this.popIdx === 0;
    },
    push: function (node, body) {
        var item = this.stack[this.popIdx];
        if (!item) {
            // we are trying to avoid memory pressure: create new element
            // only when absolutely necessary
            this.stack[this.popIdx] = new InsertStackElement(node, body);
        } else {
            item.node = node;
            item.body = body;
        }
        ++this.popIdx;
    },
    pop: function () {
        if (this.popIdx > 0) {
            return this.stack[--this.popIdx];
        }
    },
    reset: function () {
        this.popIdx = 0;
    }
};

function InsertStackElement(node, body) {
    this.node = node; // QuadTree node
    this.body = body; // physical body which needs to be inserted to node
}
`;
}
var my = Wn.exports, ws = { exports: {} };
ws.exports = vy;
ws.exports.generateFunctionBody = hh;
const gy = Xi;
function vy(n) {
  let e = hh(n);
  return new Function("bodies", "settings", "random", e);
}
function hh(n) {
  let e = gy(n);
  return `
  var boundingBox = {
    ${e("min_{var}: 0, max_{var}: 0,", { indent: 4 })}
  };

  return {
    box: boundingBox,

    update: updateBoundingBox,

    reset: resetBoundingBox,

    getBestNewPosition: function (neighbors) {
      var ${e("base_{var} = 0", { join: ", " })};

      if (neighbors.length) {
        for (var i = 0; i < neighbors.length; ++i) {
          let neighborPos = neighbors[i].pos;
          ${e("base_{var} += neighborPos.{var};", { indent: 10 })}
        }

        ${e("base_{var} /= neighbors.length;", { indent: 8 })}
      } else {
        ${e("base_{var} = (boundingBox.min_{var} + boundingBox.max_{var}) / 2;", { indent: 8 })}
      }

      var springLength = settings.springLength;
      return {
        ${e("{var}: base_{var} + (random.nextDouble() - 0.5) * springLength,", { indent: 8 })}
      };
    }
  };

  function updateBoundingBox() {
    var i = bodies.length;
    if (i === 0) return; // No bodies - no borders.

    ${e("var max_{var} = -Infinity;", { indent: 4 })}
    ${e("var min_{var} = Infinity;", { indent: 4 })}

    while(i--) {
      // this is O(n), it could be done faster with quadtree, if we check the root node bounds
      var bodyPos = bodies[i].pos;
      ${e("if (bodyPos.{var} < min_{var}) min_{var} = bodyPos.{var};", { indent: 6 })}
      ${e("if (bodyPos.{var} > max_{var}) max_{var} = bodyPos.{var};", { indent: 6 })}
    }

    ${e("boundingBox.min_{var} = min_{var};", { indent: 4 })}
    ${e("boundingBox.max_{var} = max_{var};", { indent: 4 })}
  }

  function resetBoundingBox() {
    ${e("boundingBox.min_{var} = boundingBox.max_{var} = 0;", { indent: 4 })}
  }
`;
}
var _y = ws.exports, Ts = { exports: {} };
const yy = Xi;
Ts.exports = xy;
Ts.exports.generateCreateDragForceFunctionBody = fh;
function xy(n) {
  let e = fh(n);
  return new Function("options", e);
}
function fh(n) {
  return `
  if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number');

  return {
    update: function(body) {
      ${yy(n)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};", { indent: 6 })}
    }
  };
`;
}
var by = Ts.exports, As = { exports: {} };
const My = Xi;
As.exports = Sy;
As.exports.generateCreateSpringForceFunctionBody = dh;
function Sy(n) {
  let e = dh(n);
  return new Function("options", "random", e);
}
function dh(n) {
  let e = My(n);
  return `
  if (!Number.isFinite(options.springCoefficient)) throw new Error('Spring coefficient is not a number');
  if (!Number.isFinite(options.springLength)) throw new Error('Spring length is not a number');

  return {
    /**
     * Updates forces acting on a spring
     */
    update: function (spring) {
      var body1 = spring.from;
      var body2 = spring.to;
      var length = spring.length < 0 ? options.springLength : spring.length;
      ${e("var d{var} = body2.pos.{var} - body1.pos.{var};", { indent: 6 })}
      var r = Math.sqrt(${e("d{var} * d{var}", { join: " + " })});

      if (r === 0) {
        ${e("d{var} = (random.nextDouble() - 0.5) / 50;", { indent: 8 })}
        r = Math.sqrt(${e("d{var} * d{var}", { join: " + " })});
      }

      var d = r - length;
      var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r;

      ${e("body1.force.{var} += coefficient * d{var}", { indent: 6 })};
      body1.springCount += 1;
      body1.springLength += r;

      ${e("body2.force.{var} -= coefficient * d{var}", { indent: 6 })};
      body2.springCount += 1;
      body2.springLength += r;
    }
  };
`;
}
var Ey = As.exports, Cs = { exports: {} };
const wy = Xi;
Cs.exports = Ty;
Cs.exports.generateIntegratorFunctionBody = ph;
function Ty(n) {
  let e = ph(n);
  return new Function("bodies", "timeStep", "adaptiveTimeStepWeight", e);
}
function ph(n) {
  let e = wy(n);
  return `
  var length = bodies.length;
  if (length === 0) return 0;

  ${e("var d{var} = 0, t{var} = 0;", { indent: 2 })}

  for (var i = 0; i < length; ++i) {
    var body = bodies[i];
    if (body.isPinned) continue;

    if (adaptiveTimeStepWeight && body.springCount) {
      timeStep = (adaptiveTimeStepWeight * body.springLength/body.springCount);
    }

    var coeff = timeStep / body.mass;

    ${e("body.velocity.{var} += coeff * body.force.{var};", { indent: 4 })}
    ${e("var v{var} = body.velocity.{var};", { indent: 4 })}
    var v = Math.sqrt(${e("v{var} * v{var}", { join: " + " })});

    if (v > 1) {
      // We normalize it so that we move within timeStep range. 
      // for the case when v <= 1 - we let velocity to fade out.
      ${e("body.velocity.{var} = v{var} / v;", { indent: 6 })}
    }

    ${e("d{var} = timeStep * body.velocity.{var};", { indent: 4 })}

    ${e("body.pos.{var} += d{var};", { indent: 4 })}

    ${e("t{var} += Math.abs(d{var});", { indent: 4 })}
  }

  return (${e("t{var} * t{var}", { join: " + " })})/length;
`;
}
var Ay = Cs.exports, Mo, Cl;
function Cy() {
  if (Cl)
    return Mo;
  Cl = 1, Mo = n;
  function n(e, t, i, r) {
    this.from = e, this.to = t, this.length = i, this.coefficient = r;
  }
  return Mo;
}
var So, Rl;
function Ry() {
  if (Rl)
    return So;
  Rl = 1, So = n;
  function n(e, t) {
    var i;
    if (e || (e = {}), t) {
      for (i in t)
        if (t.hasOwnProperty(i)) {
          var r = e.hasOwnProperty(i), a = typeof t[i], o = !r || typeof e[i] !== a;
          o ? e[i] = t[i] : a === "object" && (e[i] = n(e[i], t[i]));
        }
    }
    return e;
  }
  return So;
}
var er = { exports: {} }, Pl;
function Py() {
  if (Pl)
    return er.exports;
  Pl = 1, er.exports = n, er.exports.random = n, er.exports.randomIterator = s;
  function n(c) {
    var l = typeof c == "number" ? c : +/* @__PURE__ */ new Date();
    return new e(l);
  }
  function e(c) {
    this.seed = c;
  }
  e.prototype.next = o, e.prototype.nextDouble = a, e.prototype.uniform = a, e.prototype.gaussian = t;
  function t() {
    var c, l, u;
    do
      l = this.nextDouble() * 2 - 1, u = this.nextDouble() * 2 - 1, c = l * l + u * u;
    while (c >= 1 || c === 0);
    return l * Math.sqrt(-2 * Math.log(c) / c);
  }
  e.prototype.levy = i;
  function i() {
    var c = 1.5, l = Math.pow(
      r(1 + c) * Math.sin(Math.PI * c / 2) / (r((1 + c) / 2) * c * Math.pow(2, (c - 1) / 2)),
      1 / c
    );
    return this.gaussian() * l / Math.pow(Math.abs(this.gaussian()), 1 / c);
  }
  function r(c) {
    return Math.sqrt(2 * Math.PI / c) * Math.pow(1 / Math.E * (c + 1 / (12 * c - 1 / (10 * c))), c);
  }
  function a() {
    var c = this.seed;
    return c = c + 2127912214 + (c << 12) & 4294967295, c = (c ^ 3345072700 ^ c >>> 19) & 4294967295, c = c + 374761393 + (c << 5) & 4294967295, c = (c + 3550635116 ^ c << 9) & 4294967295, c = c + 4251993797 + (c << 3) & 4294967295, c = (c ^ 3042594569 ^ c >>> 16) & 4294967295, this.seed = c, (c & 268435455) / 268435456;
  }
  function o(c) {
    return Math.floor(this.nextDouble() * c);
  }
  function s(c, l) {
    var u = l || n();
    if (typeof u.next != "function")
      throw new Error("customRandom does not match expected API: next() function is missing");
    return {
      forEach: d,
      /**
       * Shuffles array randomly, in place.
       */
      shuffle: h
    };
    function h() {
      var p, g, v;
      for (p = c.length - 1; p > 0; --p)
        g = u.next(p + 1), v = c[g], c[g] = c[p], c[p] = v;
      return c;
    }
    function d(p) {
      var g, v, m;
      for (g = c.length - 1; g > 0; --g)
        v = u.next(g + 1), m = c[v], c[v] = c[g], c[g] = m, p(m);
      c.length && p(c[0]);
    }
  }
  return er.exports;
}
var mh = Fy, Ly = dy, Dy = my, Oy = _y, Iy = by, Ny = Ey, Uy = Ay, Ll = {};
function Fy(n) {
  var e = Cy(), t = Ry(), i = Ms;
  if (n) {
    if (n.springCoeff !== void 0)
      throw new Error("springCoeff was renamed to springCoefficient");
    if (n.dragCoeff !== void 0)
      throw new Error("dragCoeff was renamed to dragCoefficient");
  }
  n = t(n, {
    /**
     * Ideal length for links (springs in physical model).
     */
    springLength: 10,
    /**
     * Hook's law coefficient. 1 - solid spring.
     */
    springCoefficient: 0.8,
    /**
     * Coulomb's law coefficient. It's used to repel nodes thus should be negative
     * if you make it positive nodes start attract each other :).
     */
    gravity: -12,
    /**
     * Theta coefficient from Barnes Hut simulation. Ranged between (0, 1).
     * The closer it's to 1 the more nodes algorithm will have to go through.
     * Setting it to one makes Barnes Hut simulation no different from
     * brute-force forces calculation (each node is considered).
     */
    theta: 0.8,
    /**
     * Drag force coefficient. Used to slow down system, thus should be less than 1.
     * The closer it is to 0 the less tight system will be.
     */
    dragCoefficient: 0.9,
    // TODO: Need to rename this to something better. E.g. `dragCoefficient`
    /**
     * Default time step (dt) for forces integration
     */
    timeStep: 0.5,
    /**
     * Adaptive time step uses average spring length to compute actual time step:
     * See: https://twitter.com/anvaka/status/1293067160755957760
     */
    adaptiveTimeStepWeight: 0,
    /**
     * This parameter defines number of dimensions of the space where simulation
     * is performed. 
     */
    dimensions: 2,
    /**
     * In debug mode more checks are performed, this will help you catch errors
     * quickly, however for production build it is recommended to turn off this flag
     * to speed up computation.
     */
    debug: !1
  });
  var r = Ll[n.dimensions];
  if (!r) {
    var a = n.dimensions;
    r = {
      Body: Ly(a, n.debug),
      createQuadTree: Dy(a),
      createBounds: Oy(a),
      createDragForce: Iy(a),
      createSpringForce: Ny(a),
      integrate: Uy(a)
    }, Ll[a] = r;
  }
  var o = r.Body, s = r.createQuadTree, c = r.createBounds, l = r.createDragForce, u = r.createSpringForce, h = r.integrate, d = (D) => new o(D), p = Py().random(42), g = [], v = [], m = s(n, p), f = c(g, n, p), M = u(n, p), _ = l(n), x = 0, T = [], E = /* @__PURE__ */ new Map(), A = 0;
  b("nbody", I), b("spring", L);
  var R = {
    /**
     * Array of bodies, registered with current simulator
     *
     * Note: To add new body, use addBody() method. This property is only
     * exposed for testing/performance purposes.
     */
    bodies: g,
    quadTree: m,
    /**
     * Array of springs, registered with current simulator
     *
     * Note: To add new spring, use addSpring() method. This property is only
     * exposed for testing/performance purposes.
     */
    springs: v,
    /**
     * Returns settings with which current simulator was initialized
     */
    settings: n,
    /**
     * Adds a new force to simulation
     */
    addForce: b,
    /**
     * Removes a force from the simulation.
     */
    removeForce: U,
    /**
     * Returns a map of all registered forces.
     */
    getForces: z,
    /**
     * Performs one step of force simulation.
     *
     * @returns {boolean} true if system is considered stable; False otherwise.
     */
    step: function() {
      for (var D = 0; D < T.length; ++D)
        T[D](A);
      var B = h(g, n.timeStep, n.adaptiveTimeStepWeight);
      return A += 1, B;
    },
    /**
     * Adds body to the system
     *
     * @param {ngraph.physics.primitives.Body} body physical body
     *
     * @returns {ngraph.physics.primitives.Body} added body
     */
    addBody: function(D) {
      if (!D)
        throw new Error("Body is required");
      return g.push(D), D;
    },
    /**
     * Adds body to the system at given position
     *
     * @param {Object} pos position of a body
     *
     * @returns {ngraph.physics.primitives.Body} added body
     */
    addBodyAt: function(D) {
      if (!D)
        throw new Error("Body position is required");
      var B = d(D);
      return g.push(B), B;
    },
    /**
     * Removes body from the system
     *
     * @param {ngraph.physics.primitives.Body} body to remove
     *
     * @returns {Boolean} true if body found and removed. falsy otherwise;
     */
    removeBody: function(D) {
      if (D) {
        var B = g.indexOf(D);
        if (!(B < 0))
          return g.splice(B, 1), g.length === 0 && f.reset(), !0;
      }
    },
    /**
     * Adds a spring to this simulation.
     *
     * @returns {Object} - a handle for a spring. If you want to later remove
     * spring pass it to removeSpring() method.
     */
    addSpring: function(D, B, te, W) {
      if (!D || !B)
        throw new Error("Cannot add null spring to force simulator");
      typeof te != "number" && (te = -1);
      var ie = new e(D, B, te, W >= 0 ? W : -1);
      return v.push(ie), ie;
    },
    /**
     * Returns amount of movement performed on last step() call
     */
    getTotalMovement: function() {
      return x;
    },
    /**
     * Removes spring from the system
     *
     * @param {Object} spring to remove. Spring is an object returned by addSpring
     *
     * @returns {Boolean} true if spring found and removed. falsy otherwise;
     */
    removeSpring: function(D) {
      if (D) {
        var B = v.indexOf(D);
        if (B > -1)
          return v.splice(B, 1), !0;
      }
    },
    getBestNewBodyPosition: function(D) {
      return f.getBestNewPosition(D);
    },
    /**
     * Returns bounding box which covers all bodies
     */
    getBBox: w,
    getBoundingBox: w,
    invalidateBBox: function() {
      console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call");
    },
    // TODO: Move the force specific stuff to force
    gravity: function(D) {
      return D !== void 0 ? (n.gravity = D, m.options({ gravity: D }), this) : n.gravity;
    },
    theta: function(D) {
      return D !== void 0 ? (n.theta = D, m.options({ theta: D }), this) : n.theta;
    },
    /**
     * Returns pseudo-random number generator instance.
     */
    random: p
  };
  return By(n, R), i(R), R;
  function w() {
    return f.update(), f.box;
  }
  function b(D, B) {
    if (E.has(D))
      throw new Error("Force " + D + " is already added");
    E.set(D, B), T.push(B);
  }
  function U(D) {
    var B = T.indexOf(E.get(D));
    B < 0 || (T.splice(B, 1), E.delete(D));
  }
  function z() {
    return E;
  }
  function I() {
    if (g.length !== 0) {
      m.insertBodies(g);
      for (var D = g.length; D--; ) {
        var B = g[D];
        B.isPinned || (B.reset(), m.updateBodyForce(B), _.update(B));
      }
    }
  }
  function L() {
    for (var D = v.length; D--; )
      M.update(v[D]);
  }
}
function By(n, e) {
  for (var t in n)
    ky(n, e, t);
}
function ky(n, e, t) {
  if (n.hasOwnProperty(t) && typeof e[t] != "function") {
    var i = Number.isFinite(n[t]);
    i ? e[t] = function(r) {
      if (r !== void 0) {
        if (!Number.isFinite(r))
          throw new Error("Value of " + t + " should be a valid number.");
        return n[t] = r, e;
      }
      return n[t];
    } : e[t] = function(r) {
      return r !== void 0 ? (n[t] = r, e) : n[t];
    };
  }
}
Ss.exports = Hy;
Ss.exports.simulator = mh;
var zy = Ms;
function Hy(n, e) {
  if (!n)
    throw new Error("Graph structure cannot be undefined");
  var t = e && e.createSimulator || mh, i = t(e);
  if (Array.isArray(e))
    throw new Error("Physics settings is expected to be an object");
  var r = n.version > 19 ? I : z;
  e && typeof e.nodeMass == "function" && (r = e.nodeMass);
  var a = /* @__PURE__ */ new Map(), o = {}, s = 0, c = i.settings.springTransform || Vy;
  _(), m();
  var l = !1, u = {
    /**
     * Performs one step of iterative layout algorithm
     *
     * @returns {boolean} true if the system should be considered stable; False otherwise.
     * The system is stable if no further call to `step()` can improve the layout.
     */
    step: function() {
      if (s === 0)
        return h(!0), !0;
      var L = i.step();
      u.lastMove = L, u.fire("step");
      var D = L / s, B = D <= 0.01;
      return h(B), B;
    },
    /**
     * For a given `nodeId` returns position
     */
    getNodePosition: function(L) {
      return U(L).pos;
    },
    /**
     * Sets position of a node to a given coordinates
     * @param {string} nodeId node identifier
     * @param {number} x position of a node
     * @param {number} y position of a node
     * @param {number=} z position of node (only if applicable to body)
     */
    setNodePosition: function(L) {
      var D = U(L);
      D.setPosition.apply(D, Array.prototype.slice.call(arguments, 1));
    },
    /**
     * @returns {Object} Link position by link id
     * @returns {Object.from} {x, y} coordinates of link start
     * @returns {Object.to} {x, y} coordinates of link end
     */
    getLinkPosition: function(L) {
      var D = o[L];
      if (D)
        return {
          from: D.from.pos,
          to: D.to.pos
        };
    },
    /**
     * @returns {Object} area required to fit in the graph. Object contains
     * `x1`, `y1` - top left coordinates
     * `x2`, `y2` - bottom right coordinates
     */
    getGraphRect: function() {
      return i.getBBox();
    },
    /**
     * Iterates over each body in the layout simulator and performs a callback(body, nodeId)
     */
    forEachBody: d,
    /*
     * Requests layout algorithm to pin/unpin node to its current position
     * Pinned nodes should not be affected by layout algorithm and always
     * remain at their position
     */
    pinNode: function(L, D) {
      var B = U(L.id);
      B.isPinned = !!D;
    },
    /**
     * Checks whether given graph's node is currently pinned
     */
    isNodePinned: function(L) {
      return U(L.id).isPinned;
    },
    /**
     * Request to release all resources
     */
    dispose: function() {
      n.off("changed", M), u.fire("disposed");
    },
    /**
     * Gets physical body for a given node id. If node is not found undefined
     * value is returned.
     */
    getBody: v,
    /**
     * Gets spring for a given edge.
     *
     * @param {string} linkId link identifer. If two arguments are passed then
     * this argument is treated as formNodeId
     * @param {string=} toId when defined this parameter denotes head of the link
     * and first argument is treated as tail of the link (fromId)
     */
    getSpring: g,
    /**
     * Returns length of cumulative force vector. The closer this to zero - the more stable the system is
     */
    getForceVectorLength: p,
    /**
     * [Read only] Gets current physics simulator
     */
    simulator: i,
    /**
     * Gets the graph that was used for layout
     */
    graph: n,
    /**
     * Gets amount of movement performed during last step operation
     */
    lastMove: 0
  };
  return zy(u), u;
  function h(L) {
    l !== L && (l = L, f(L));
  }
  function d(L) {
    a.forEach(L);
  }
  function p() {
    var L = 0, D = 0;
    return d(function(B) {
      L += Math.abs(B.force.x), D += Math.abs(B.force.y);
    }), Math.sqrt(L * L + D * D);
  }
  function g(L, D) {
    var B;
    if (D === void 0)
      typeof L != "object" ? B = L : B = L.id;
    else {
      var te = n.hasLink(L, D);
      if (!te)
        return;
      B = te.id;
    }
    return o[B];
  }
  function v(L) {
    return a.get(L);
  }
  function m() {
    n.on("changed", M);
  }
  function f(L) {
    u.fire("stable", L);
  }
  function M(L) {
    for (var D = 0; D < L.length; ++D) {
      var B = L[D];
      B.changeType === "add" ? (B.node && x(B.node.id), B.link && E(B.link)) : B.changeType === "remove" && (B.node && T(B.node), B.link && A(B.link));
    }
    s = n.getNodesCount();
  }
  function _() {
    s = 0, n.forEachNode(function(L) {
      x(L.id), s += 1;
    }), n.forEachLink(E);
  }
  function x(L) {
    var D = a.get(L);
    if (!D) {
      var B = n.getNode(L);
      if (!B)
        throw new Error("initBody() was called with unknown node id");
      var te = B.position;
      if (!te) {
        var W = R(B);
        te = i.getBestNewBodyPosition(W);
      }
      D = i.addBodyAt(te), D.id = L, a.set(L, D), w(L), b(B) && (D.isPinned = !0);
    }
  }
  function T(L) {
    var D = L.id, B = a.get(D);
    B && (a.delete(D), i.removeBody(B));
  }
  function E(L) {
    w(L.fromId), w(L.toId);
    var D = a.get(L.fromId), B = a.get(L.toId), te = i.addSpring(D, B, L.length);
    c(L, te), o[L.id] = te;
  }
  function A(L) {
    var D = o[L.id];
    if (D) {
      var B = n.getNode(L.fromId), te = n.getNode(L.toId);
      B && w(B.id), te && w(te.id), delete o[L.id], i.removeSpring(D);
    }
  }
  function R(L) {
    var D = [];
    if (!L.links)
      return D;
    for (var B = Math.min(L.links.length, 2), te = 0; te < B; ++te) {
      var W = L.links[te], ie = W.fromId !== L.id ? a.get(W.fromId) : a.get(W.toId);
      ie && ie.pos && D.push(ie);
    }
    return D;
  }
  function w(L) {
    var D = a.get(L);
    if (D.mass = r(L), Number.isNaN(D.mass))
      throw new Error("Node mass should be a number");
  }
  function b(L) {
    return L && (L.isPinned || L.data && L.data.isPinned);
  }
  function U(L) {
    var D = a.get(L);
    return D || (x(L), D = a.get(L)), D;
  }
  function z(L) {
    var D = n.getLinks(L);
    return D ? 1 + D.length / 3 : 1;
  }
  function I(L) {
    var D = n.getLinks(L);
    return D ? 1 + D.size / 3 : 1;
  }
}
function Vy() {
}
var Gy = Ss.exports;
const Wy = /* @__PURE__ */ su(Gy);
function Xo(n) {
  var e = typeof n;
  return n != null && (e == "object" || e == "function");
}
var jy = typeof global == "object" && global && global.Object === Object && global, Xy = typeof self == "object" && self && self.Object === Object && self, gh = jy || Xy || Function("return this")(), Eo = function() {
  return gh.Date.now();
}, $y = /\s/;
function qy(n) {
  for (var e = n.length; e-- && $y.test(n.charAt(e)); )
    ;
  return e;
}
var Yy = /^\s+/;
function Ky(n) {
  return n && n.slice(0, qy(n) + 1).replace(Yy, "");
}
var fa = gh.Symbol, vh = Object.prototype, Zy = vh.hasOwnProperty, Jy = vh.toString, tr = fa ? fa.toStringTag : void 0;
function Qy(n) {
  var e = Zy.call(n, tr), t = n[tr];
  try {
    n[tr] = void 0;
    var i = !0;
  } catch {
  }
  var r = Jy.call(n);
  return i && (e ? n[tr] = t : delete n[tr]), r;
}
var ex = Object.prototype, tx = ex.toString;
function nx(n) {
  return tx.call(n);
}
var ix = "[object Null]", rx = "[object Undefined]", Dl = fa ? fa.toStringTag : void 0;
function ax(n) {
  return n == null ? n === void 0 ? rx : ix : Dl && Dl in Object(n) ? Qy(n) : nx(n);
}
function ox(n) {
  return n != null && typeof n == "object";
}
var sx = "[object Symbol]";
function cx(n) {
  return typeof n == "symbol" || ox(n) && ax(n) == sx;
}
var Ol = NaN, lx = /^[-+]0x[0-9a-f]+$/i, ux = /^0b[01]+$/i, hx = /^0o[0-7]+$/i, fx = parseInt;
function Il(n) {
  if (typeof n == "number")
    return n;
  if (cx(n))
    return Ol;
  if (Xo(n)) {
    var e = typeof n.valueOf == "function" ? n.valueOf() : n;
    n = Xo(e) ? e + "" : e;
  }
  if (typeof n != "string")
    return n === 0 ? n : +n;
  n = Ky(n);
  var t = ux.test(n);
  return t || hx.test(n) ? fx(n.slice(2), t ? 2 : 8) : lx.test(n) ? Ol : +n;
}
var dx = "Expected a function", px = Math.max, mx = Math.min;
function gx(n, e, t) {
  var i, r, a, o, s, c, l = 0, u = !1, h = !1, d = !0;
  if (typeof n != "function")
    throw new TypeError(dx);
  e = Il(e) || 0, Xo(t) && (u = !!t.leading, h = "maxWait" in t, a = h ? px(Il(t.maxWait) || 0, e) : a, d = "trailing" in t ? !!t.trailing : d);
  function p(E) {
    var A = i, R = r;
    return i = r = void 0, l = E, o = n.apply(R, A), o;
  }
  function g(E) {
    return l = E, s = setTimeout(f, e), u ? p(E) : o;
  }
  function v(E) {
    var A = E - c, R = E - l, w = e - A;
    return h ? mx(w, a - R) : w;
  }
  function m(E) {
    var A = E - c, R = E - l;
    return c === void 0 || A >= e || A < 0 || h && R >= a;
  }
  function f() {
    var E = Eo();
    if (m(E))
      return M(E);
    s = setTimeout(f, v(E));
  }
  function M(E) {
    return s = void 0, d && i ? p(E) : (i = r = void 0, o);
  }
  function _() {
    s !== void 0 && clearTimeout(s), l = 0, i = c = r = s = void 0;
  }
  function x() {
    return s === void 0 ? o : M(Eo());
  }
  function T() {
    var E = Eo(), A = m(E);
    if (i = arguments, r = this, c = E, A) {
      if (s === void 0)
        return g(c);
      if (h)
        return clearTimeout(s), s = setTimeout(f, e), p(c);
    }
    return s === void 0 && (s = setTimeout(f, e)), o;
  }
  return T.cancel = _, T.flush = x, T;
}
function vx(n, e) {
  var t = n == null ? null : typeof Symbol < "u" && n[Symbol.iterator] || n["@@iterator"];
  if (t != null) {
    var i, r, a, o, s = [], c = !0, l = !1;
    try {
      if (a = (t = t.call(n)).next, e === 0) {
        if (Object(t) !== t)
          return;
        c = !1;
      } else
        for (; !(c = (i = a.call(t)).done) && (s.push(i.value), s.length !== e); c = !0)
          ;
    } catch (u) {
      l = !0, r = u;
    } finally {
      try {
        if (!c && t.return != null && (o = t.return(), Object(o) !== o))
          return;
      } finally {
        if (l)
          throw r;
      }
    }
    return s;
  }
}
function _x(n, e) {
  if (!(n instanceof e))
    throw new TypeError("Cannot call a class as a function");
}
function Nl(n, e) {
  for (var t = 0; t < e.length; t++) {
    var i = e[t];
    i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(n, wx(i.key), i);
  }
}
function yx(n, e, t) {
  return e && Nl(n.prototype, e), t && Nl(n, t), Object.defineProperty(n, "prototype", {
    writable: !1
  }), n;
}
function xx(n, e) {
  return bx(n) || vx(n, e) || Mx(n, e) || Sx();
}
function bx(n) {
  if (Array.isArray(n))
    return n;
}
function Mx(n, e) {
  if (n) {
    if (typeof n == "string")
      return Ul(n, e);
    var t = Object.prototype.toString.call(n).slice(8, -1);
    if (t === "Object" && n.constructor && (t = n.constructor.name), t === "Map" || t === "Set")
      return Array.from(n);
    if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))
      return Ul(n, e);
  }
}
function Ul(n, e) {
  (e == null || e > n.length) && (e = n.length);
  for (var t = 0, i = new Array(e); t < e; t++)
    i[t] = n[t];
  return i;
}
function Sx() {
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Ex(n, e) {
  if (typeof n != "object" || n === null)
    return n;
  var t = n[Symbol.toPrimitive];
  if (t !== void 0) {
    var i = t.call(n, e || "default");
    if (typeof i != "object")
      return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (e === "string" ? String : Number)(n);
}
function wx(n) {
  var e = Ex(n, "string");
  return typeof e == "symbol" ? e : String(e);
}
var Tx = /* @__PURE__ */ yx(function n(e, t) {
  var i = t.default, r = i === void 0 ? null : i, a = t.triggerUpdate, o = a === void 0 ? !0 : a, s = t.onChange, c = s === void 0 ? function(l, u) {
  } : s;
  _x(this, n), this.name = e, this.defaultVal = r, this.triggerUpdate = o, this.onChange = c;
});
function Rs(n) {
  var e = n.stateInit, t = e === void 0 ? function() {
    return {};
  } : e, i = n.props, r = i === void 0 ? {} : i, a = n.methods, o = a === void 0 ? {} : a, s = n.aliases, c = s === void 0 ? {} : s, l = n.init, u = l === void 0 ? function() {
  } : l, h = n.update, d = h === void 0 ? function() {
  } : h, p = Object.keys(r).map(function(g) {
    return new Tx(g, r[g]);
  });
  return function() {
    var g = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, v = Object.assign(
      {},
      t instanceof Function ? t(g) : t,
      // Support plain objects for backwards compatibility
      {
        initialised: !1
      }
    ), m = {};
    function f(x) {
      return M(x, g), _(), f;
    }
    var M = function(T, E) {
      u.call(f, T, v, E), v.initialised = !0;
    }, _ = gx(function() {
      v.initialised && (d.call(f, v, m), m = {});
    }, 1);
    return p.forEach(function(x) {
      f[x.name] = T(x);
      function T(E) {
        var A = E.name, R = E.triggerUpdate, w = R === void 0 ? !1 : R, b = E.onChange, U = b === void 0 ? function(L, D) {
        } : b, z = E.defaultVal, I = z === void 0 ? null : z;
        return function(L) {
          var D = v[A];
          if (!arguments.length)
            return D;
          var B = L === void 0 ? I : L;
          return v[A] = B, U.call(f, B, v, D), !m.hasOwnProperty(A) && (m[A] = D), w && _(), f;
        };
      }
    }), Object.keys(o).forEach(function(x) {
      f[x] = function() {
        for (var T, E = arguments.length, A = new Array(E), R = 0; R < E; R++)
          A[R] = arguments[R];
        return (T = o[x]).call.apply(T, [f, v].concat(A));
      };
    }), Object.entries(c).forEach(function(x) {
      var T = xx(x, 2), E = T[0], A = T[1];
      return f[E] = f[A];
    }), f.resetProps = function() {
      return p.forEach(function(x) {
        f[x.name](x.defaultVal);
      }), f;
    }, f.resetProps(), v._rerender = _, f;
  };
}
var Xe = function(n) {
  return typeof n == "function" ? n : typeof n == "string" ? function(e) {
    return e[n];
  } : function(e) {
    return n;
  };
};
class Fl extends Map {
  constructor(e, t = Rx) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: t } }), e != null)
      for (const [i, r] of e)
        this.set(i, r);
  }
  get(e) {
    return super.get(Bl(this, e));
  }
  has(e) {
    return super.has(Bl(this, e));
  }
  set(e, t) {
    return super.set(Ax(this, e), t);
  }
  delete(e) {
    return super.delete(Cx(this, e));
  }
}
function Bl({ _intern: n, _key: e }, t) {
  const i = e(t);
  return n.has(i) ? n.get(i) : t;
}
function Ax({ _intern: n, _key: e }, t) {
  const i = e(t);
  return n.has(i) ? n.get(i) : (n.set(i, t), t);
}
function Cx({ _intern: n, _key: e }, t) {
  const i = e(t);
  return n.has(i) && (t = n.get(i), n.delete(i)), t;
}
function Rx(n) {
  return n !== null && typeof n == "object" ? n.valueOf() : n;
}
function Px(n, e) {
  let t;
  if (e === void 0)
    for (const i of n)
      i != null && (t < i || t === void 0 && i >= i) && (t = i);
  else {
    let i = -1;
    for (let r of n)
      (r = e(r, ++i, n)) != null && (t < r || t === void 0 && r >= r) && (t = r);
  }
  return t;
}
function Lx(n, e) {
  let t;
  if (e === void 0)
    for (const i of n)
      i != null && (t > i || t === void 0 && i >= i) && (t = i);
  else {
    let i = -1;
    for (let r of n)
      (r = e(r, ++i, n)) != null && (t > r || t === void 0 && r >= r) && (t = r);
  }
  return t;
}
function Dx(n, e) {
  var t = n == null ? null : typeof Symbol < "u" && n[Symbol.iterator] || n["@@iterator"];
  if (t != null) {
    var i, r, a, o, s = [], c = !0, l = !1;
    try {
      if (a = (t = t.call(n)).next, e === 0) {
        if (Object(t) !== t)
          return;
        c = !1;
      } else
        for (; !(c = (i = a.call(t)).done) && (s.push(i.value), s.length !== e); c = !0)
          ;
    } catch (u) {
      l = !0, r = u;
    } finally {
      try {
        if (!c && t.return != null && (o = t.return(), Object(o) !== o))
          return;
      } finally {
        if (l)
          throw r;
      }
    }
    return s;
  }
}
function Ox(n, e) {
  if (n == null)
    return {};
  var t = {}, i = Object.keys(n), r, a;
  for (a = 0; a < i.length; a++)
    r = i[a], !(e.indexOf(r) >= 0) && (t[r] = n[r]);
  return t;
}
function Ix(n, e) {
  if (n == null)
    return {};
  var t = Ox(n, e), i, r;
  if (Object.getOwnPropertySymbols) {
    var a = Object.getOwnPropertySymbols(n);
    for (r = 0; r < a.length; r++)
      i = a[r], !(e.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(n, i) && (t[i] = n[i]);
  }
  return t;
}
function Nx(n, e) {
  return Bx(n) || Dx(n, e) || _h(n, e) || Hx();
}
function Ux(n) {
  return Fx(n) || kx(n) || _h(n) || zx();
}
function Fx(n) {
  if (Array.isArray(n))
    return $o(n);
}
function Bx(n) {
  if (Array.isArray(n))
    return n;
}
function kx(n) {
  if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
    return Array.from(n);
}
function _h(n, e) {
  if (n) {
    if (typeof n == "string")
      return $o(n, e);
    var t = Object.prototype.toString.call(n).slice(8, -1);
    if (t === "Object" && n.constructor && (t = n.constructor.name), t === "Map" || t === "Set")
      return Array.from(n);
    if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))
      return $o(n, e);
  }
}
function $o(n, e) {
  (e == null || e > n.length) && (e = n.length);
  for (var t = 0, i = new Array(e); t < e; t++)
    i[t] = n[t];
  return i;
}
function zx() {
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Hx() {
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Vx(n, e) {
  if (typeof n != "object" || n === null)
    return n;
  var t = n[Symbol.toPrimitive];
  if (t !== void 0) {
    var i = t.call(n, e || "default");
    if (typeof i != "object")
      return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (e === "string" ? String : Number)(n);
}
function Gx(n) {
  var e = Vx(n, "string");
  return typeof e == "symbol" ? e : String(e);
}
var kl = function() {
  var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [], t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !0, i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1, r = (e instanceof Array ? e.length ? e : [void 0] : [e]).map(function(s) {
    return {
      keyAccessor: s,
      isProp: !(s instanceof Function)
    };
  }), a = n.reduce(function(s, c) {
    var l = s, u = c;
    return r.forEach(function(h, d) {
      var p = h.keyAccessor, g = h.isProp, v;
      if (g) {
        var m = u, f = m[p], M = Ix(m, [p].map(Gx));
        v = f, u = M;
      } else
        v = p(u, d);
      d + 1 < r.length ? (l.hasOwnProperty(v) || (l[v] = {}), l = l[v]) : t ? (l.hasOwnProperty(v) || (l[v] = []), l[v].push(u)) : l[v] = u;
    }), s;
  }, {});
  t instanceof Function && function s(c) {
    var l = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
    l === r.length ? Object.keys(c).forEach(function(u) {
      return c[u] = t(c[u]);
    }) : Object.values(c).forEach(function(u) {
      return s(u, l + 1);
    });
  }(a);
  var o = a;
  return i && (o = [], function s(c) {
    var l = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
    l.length === r.length ? o.push({
      keys: l,
      vals: c
    }) : Object.entries(c).forEach(function(u) {
      var h = Nx(u, 2), d = h[0], p = h[1];
      return s(p, [].concat(Ux(l), [d]));
    });
  }(a), e instanceof Array && e.length === 0 && o.length === 1 && (o[0].keys = [])), o;
};
function Wx(n, e) {
  var t = n == null ? null : typeof Symbol < "u" && n[Symbol.iterator] || n["@@iterator"];
  if (t != null) {
    var i, r, a, o, s = [], c = !0, l = !1;
    try {
      if (a = (t = t.call(n)).next, e === 0) {
        if (Object(t) !== t)
          return;
        c = !1;
      } else
        for (; !(c = (i = a.call(t)).done) && (s.push(i.value), s.length !== e); c = !0)
          ;
    } catch (u) {
      l = !0, r = u;
    } finally {
      try {
        if (!c && t.return != null && (o = t.return(), Object(o) !== o))
          return;
      } finally {
        if (l)
          throw r;
      }
    }
    return s;
  }
}
function zl(n, e) {
  var t = Object.keys(n);
  if (Object.getOwnPropertySymbols) {
    var i = Object.getOwnPropertySymbols(n);
    e && (i = i.filter(function(r) {
      return Object.getOwnPropertyDescriptor(n, r).enumerable;
    })), t.push.apply(t, i);
  }
  return t;
}
function jx(n) {
  for (var e = 1; e < arguments.length; e++) {
    var t = arguments[e] != null ? arguments[e] : {};
    e % 2 ? zl(Object(t), !0).forEach(function(i) {
      yh(n, i, t[i]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(t)) : zl(Object(t)).forEach(function(i) {
      Object.defineProperty(n, i, Object.getOwnPropertyDescriptor(t, i));
    });
  }
  return n;
}
function yh(n, e, t) {
  return e = eb(e), e in n ? Object.defineProperty(n, e, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : n[e] = t, n;
}
function Xx(n, e) {
  if (n == null)
    return {};
  var t = {}, i = Object.keys(n), r, a;
  for (a = 0; a < i.length; a++)
    r = i[a], !(e.indexOf(r) >= 0) && (t[r] = n[r]);
  return t;
}
function $x(n, e) {
  if (n == null)
    return {};
  var t = Xx(n, e), i, r;
  if (Object.getOwnPropertySymbols) {
    var a = Object.getOwnPropertySymbols(n);
    for (r = 0; r < a.length; r++)
      i = a[r], !(e.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(n, i) && (t[i] = n[i]);
  }
  return t;
}
function xh(n, e) {
  return Yx(n) || Wx(n, e) || bh(n, e) || Jx();
}
function da(n) {
  return qx(n) || Kx(n) || bh(n) || Zx();
}
function qx(n) {
  if (Array.isArray(n))
    return qo(n);
}
function Yx(n) {
  if (Array.isArray(n))
    return n;
}
function Kx(n) {
  if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
    return Array.from(n);
}
function bh(n, e) {
  if (n) {
    if (typeof n == "string")
      return qo(n, e);
    var t = Object.prototype.toString.call(n).slice(8, -1);
    if (t === "Object" && n.constructor && (t = n.constructor.name), t === "Map" || t === "Set")
      return Array.from(n);
    if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))
      return qo(n, e);
  }
}
function qo(n, e) {
  (e == null || e > n.length) && (e = n.length);
  for (var t = 0, i = new Array(e); t < e; t++)
    i[t] = n[t];
  return i;
}
function Zx() {
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Jx() {
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Qx(n, e) {
  if (typeof n != "object" || n === null)
    return n;
  var t = n[Symbol.toPrimitive];
  if (t !== void 0) {
    var i = t.call(n, e || "default");
    if (typeof i != "object")
      return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (e === "string" ? String : Number)(n);
}
function eb(n) {
  var e = Qx(n, "string");
  return typeof e == "symbol" ? e : String(e);
}
var tb = ["createObj", "updateObj", "exitObj", "objBindAttr", "dataBindAttr"];
function nb(n, e, t) {
  var i = {
    enter: [],
    update: [],
    exit: []
  };
  if (t) {
    var o = kl(n, t, !1), s = kl(e, t, !1), c = Object.assign({}, o, s);
    Object.entries(c).forEach(function(l) {
      var u = xh(l, 2), h = u[0], d = u[1], p = o.hasOwnProperty(h) ? s.hasOwnProperty(h) ? "update" : "exit" : "enter";
      i[p].push(p === "update" ? [o[h], s[h]] : d);
    });
  } else {
    var r = new Set(n), a = new Set(e);
    new Set([].concat(da(r), da(a))).forEach(function(l) {
      var u = r.has(l) ? a.has(l) ? "update" : "exit" : "enter";
      i[u].push(u === "update" ? [l, l] : l);
    });
  }
  return i;
}
function ib(n, e, t) {
  var i = t.objBindAttr, r = i === void 0 ? "__obj" : i, a = t.dataBindAttr, o = a === void 0 ? "__data" : a, s = t.idAccessor, c = t.purge, l = c === void 0 ? !1 : c, u = function(m) {
    return m.hasOwnProperty(o);
  }, h = e.filter(function(v) {
    return !u(v);
  }), d = e.filter(u).map(function(v) {
    return v[o];
  }), p = n, g = l ? {
    enter: p,
    exit: d,
    update: []
  } : nb(d, p, s);
  return g.update = g.update.map(function(v) {
    var m = xh(v, 2), f = m[0], M = m[1];
    return f !== M && (M[r] = f[r], M[r][o] = M), M;
  }), g.exit = g.exit.concat(h.map(function(v) {
    return yh({}, r, v);
  })), g;
}
function rb(n, e, t, i, r) {
  var a = r.createObj, o = a === void 0 ? function(R) {
    return {};
  } : a, s = r.updateObj, c = s === void 0 ? function(R, w) {
  } : s, l = r.exitObj, u = l === void 0 ? function(R) {
  } : l, h = r.objBindAttr, d = h === void 0 ? "__obj" : h, p = r.dataBindAttr, g = p === void 0 ? "__data" : p, v = $x(r, tb), m = ib(n, e, jx({
    objBindAttr: d,
    dataBindAttr: g
  }, v)), f = m.enter, M = m.update, _ = m.exit;
  _.forEach(function(R) {
    var w = R[d];
    delete R[d], u(w), i(w);
  });
  var x = E(f), T = [].concat(da(f), da(M));
  A(T), x.forEach(t);
  function E(R) {
    var w = [];
    return R.forEach(function(b) {
      var U = o(b);
      U && (U[g] = b, b[d] = U, w.push(U));
    }), w;
  }
  function A(R) {
    R.forEach(function(w) {
      var b = w[d];
      b && (b[g] = w, c(b, w));
    });
  }
}
function ab(n, e) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(n);
      break;
    default:
      this.range(e).domain(n);
      break;
  }
  return this;
}
const Hl = Symbol("implicit");
function Mh() {
  var n = new Fl(), e = [], t = [], i = Hl;
  function r(a) {
    let o = n.get(a);
    if (o === void 0) {
      if (i !== Hl)
        return i;
      n.set(a, o = e.push(a) - 1);
    }
    return t[o % t.length];
  }
  return r.domain = function(a) {
    if (!arguments.length)
      return e.slice();
    e = [], n = new Fl();
    for (const o of a)
      n.has(o) || n.set(o, e.push(o) - 1);
    return r;
  }, r.range = function(a) {
    return arguments.length ? (t = Array.from(a), r) : t.slice();
  }, r.unknown = function(a) {
    return arguments.length ? (i = a, r) : i;
  }, r.copy = function() {
    return Mh(e, t).unknown(i);
  }, ab.apply(r, arguments), r;
}
function ob(n) {
  for (var e = n.length / 6 | 0, t = new Array(e), i = 0; i < e; )
    t[i] = "#" + n.slice(i * 6, ++i * 6);
  return t;
}
const sb = ob("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");
function pa(n) {
  "@babel/helpers - typeof";
  return pa = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
    return typeof e;
  } : function(e) {
    return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
  }, pa(n);
}
var cb = /^\s+/, lb = /\s+$/;
function ye(n, e) {
  if (n = n || "", e = e || {}, n instanceof ye)
    return n;
  if (!(this instanceof ye))
    return new ye(n, e);
  var t = ub(n);
  this._originalInput = n, this._r = t.r, this._g = t.g, this._b = t.b, this._a = t.a, this._roundA = Math.round(100 * this._a) / 100, this._format = e.format || t.format, this._gradientType = e.gradientType, this._r < 1 && (this._r = Math.round(this._r)), this._g < 1 && (this._g = Math.round(this._g)), this._b < 1 && (this._b = Math.round(this._b)), this._ok = t.ok;
}
ye.prototype = {
  isDark: function() {
    return this.getBrightness() < 128;
  },
  isLight: function() {
    return !this.isDark();
  },
  isValid: function() {
    return this._ok;
  },
  getOriginalInput: function() {
    return this._originalInput;
  },
  getFormat: function() {
    return this._format;
  },
  getAlpha: function() {
    return this._a;
  },
  getBrightness: function() {
    var e = this.toRgb();
    return (e.r * 299 + e.g * 587 + e.b * 114) / 1e3;
  },
  getLuminance: function() {
    var e = this.toRgb(), t, i, r, a, o, s;
    return t = e.r / 255, i = e.g / 255, r = e.b / 255, t <= 0.03928 ? a = t / 12.92 : a = Math.pow((t + 0.055) / 1.055, 2.4), i <= 0.03928 ? o = i / 12.92 : o = Math.pow((i + 0.055) / 1.055, 2.4), r <= 0.03928 ? s = r / 12.92 : s = Math.pow((r + 0.055) / 1.055, 2.4), 0.2126 * a + 0.7152 * o + 0.0722 * s;
  },
  setAlpha: function(e) {
    return this._a = Sh(e), this._roundA = Math.round(100 * this._a) / 100, this;
  },
  toHsv: function() {
    var e = Gl(this._r, this._g, this._b);
    return {
      h: e.h * 360,
      s: e.s,
      v: e.v,
      a: this._a
    };
  },
  toHsvString: function() {
    var e = Gl(this._r, this._g, this._b), t = Math.round(e.h * 360), i = Math.round(e.s * 100), r = Math.round(e.v * 100);
    return this._a == 1 ? "hsv(" + t + ", " + i + "%, " + r + "%)" : "hsva(" + t + ", " + i + "%, " + r + "%, " + this._roundA + ")";
  },
  toHsl: function() {
    var e = Vl(this._r, this._g, this._b);
    return {
      h: e.h * 360,
      s: e.s,
      l: e.l,
      a: this._a
    };
  },
  toHslString: function() {
    var e = Vl(this._r, this._g, this._b), t = Math.round(e.h * 360), i = Math.round(e.s * 100), r = Math.round(e.l * 100);
    return this._a == 1 ? "hsl(" + t + ", " + i + "%, " + r + "%)" : "hsla(" + t + ", " + i + "%, " + r + "%, " + this._roundA + ")";
  },
  toHex: function(e) {
    return Wl(this._r, this._g, this._b, e);
  },
  toHexString: function(e) {
    return "#" + this.toHex(e);
  },
  toHex8: function(e) {
    return pb(this._r, this._g, this._b, this._a, e);
  },
  toHex8String: function(e) {
    return "#" + this.toHex8(e);
  },
  toRgb: function() {
    return {
      r: Math.round(this._r),
      g: Math.round(this._g),
      b: Math.round(this._b),
      a: this._a
    };
  },
  toRgbString: function() {
    return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
  },
  toPercentageRgb: function() {
    return {
      r: Math.round(it(this._r, 255) * 100) + "%",
      g: Math.round(it(this._g, 255) * 100) + "%",
      b: Math.round(it(this._b, 255) * 100) + "%",
      a: this._a
    };
  },
  toPercentageRgbString: function() {
    return this._a == 1 ? "rgb(" + Math.round(it(this._r, 255) * 100) + "%, " + Math.round(it(this._g, 255) * 100) + "%, " + Math.round(it(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(it(this._r, 255) * 100) + "%, " + Math.round(it(this._g, 255) * 100) + "%, " + Math.round(it(this._b, 255) * 100) + "%, " + this._roundA + ")";
  },
  toName: function() {
    return this._a === 0 ? "transparent" : this._a < 1 ? !1 : Tb[Wl(this._r, this._g, this._b, !0)] || !1;
  },
  toFilter: function(e) {
    var t = "#" + jl(this._r, this._g, this._b, this._a), i = t, r = this._gradientType ? "GradientType = 1, " : "";
    if (e) {
      var a = ye(e);
      i = "#" + jl(a._r, a._g, a._b, a._a);
    }
    return "progid:DXImageTransform.Microsoft.gradient(" + r + "startColorstr=" + t + ",endColorstr=" + i + ")";
  },
  toString: function(e) {
    var t = !!e;
    e = e || this._format;
    var i = !1, r = this._a < 1 && this._a >= 0, a = !t && r && (e === "hex" || e === "hex6" || e === "hex3" || e === "hex4" || e === "hex8" || e === "name");
    return a ? e === "name" && this._a === 0 ? this.toName() : this.toRgbString() : (e === "rgb" && (i = this.toRgbString()), e === "prgb" && (i = this.toPercentageRgbString()), (e === "hex" || e === "hex6") && (i = this.toHexString()), e === "hex3" && (i = this.toHexString(!0)), e === "hex4" && (i = this.toHex8String(!0)), e === "hex8" && (i = this.toHex8String()), e === "name" && (i = this.toName()), e === "hsl" && (i = this.toHslString()), e === "hsv" && (i = this.toHsvString()), i || this.toHexString());
  },
  clone: function() {
    return ye(this.toString());
  },
  _applyModification: function(e, t) {
    var i = e.apply(null, [this].concat([].slice.call(t)));
    return this._r = i._r, this._g = i._g, this._b = i._b, this.setAlpha(i._a), this;
  },
  lighten: function() {
    return this._applyModification(_b, arguments);
  },
  brighten: function() {
    return this._applyModification(yb, arguments);
  },
  darken: function() {
    return this._applyModification(xb, arguments);
  },
  desaturate: function() {
    return this._applyModification(mb, arguments);
  },
  saturate: function() {
    return this._applyModification(gb, arguments);
  },
  greyscale: function() {
    return this._applyModification(vb, arguments);
  },
  spin: function() {
    return this._applyModification(bb, arguments);
  },
  _applyCombination: function(e, t) {
    return e.apply(null, [this].concat([].slice.call(t)));
  },
  analogous: function() {
    return this._applyCombination(Eb, arguments);
  },
  complement: function() {
    return this._applyCombination(Mb, arguments);
  },
  monochromatic: function() {
    return this._applyCombination(wb, arguments);
  },
  splitcomplement: function() {
    return this._applyCombination(Sb, arguments);
  },
  // Disabled until https://github.com/bgrins/TinyColor/issues/254
  // polyad: function (number) {
  //   return this._applyCombination(polyad, [number]);
  // },
  triad: function() {
    return this._applyCombination(Xl, [3]);
  },
  tetrad: function() {
    return this._applyCombination(Xl, [4]);
  }
};
ye.fromRatio = function(n, e) {
  if (pa(n) == "object") {
    var t = {};
    for (var i in n)
      n.hasOwnProperty(i) && (i === "a" ? t[i] = n[i] : t[i] = cr(n[i]));
    n = t;
  }
  return ye(n, e);
};
function ub(n) {
  var e = {
    r: 0,
    g: 0,
    b: 0
  }, t = 1, i = null, r = null, a = null, o = !1, s = !1;
  return typeof n == "string" && (n = Pb(n)), pa(n) == "object" && (gn(n.r) && gn(n.g) && gn(n.b) ? (e = hb(n.r, n.g, n.b), o = !0, s = String(n.r).substr(-1) === "%" ? "prgb" : "rgb") : gn(n.h) && gn(n.s) && gn(n.v) ? (i = cr(n.s), r = cr(n.v), e = db(n.h, i, r), o = !0, s = "hsv") : gn(n.h) && gn(n.s) && gn(n.l) && (i = cr(n.s), a = cr(n.l), e = fb(n.h, i, a), o = !0, s = "hsl"), n.hasOwnProperty("a") && (t = n.a)), t = Sh(t), {
    ok: o,
    format: n.format || s,
    r: Math.min(255, Math.max(e.r, 0)),
    g: Math.min(255, Math.max(e.g, 0)),
    b: Math.min(255, Math.max(e.b, 0)),
    a: t
  };
}
function hb(n, e, t) {
  return {
    r: it(n, 255) * 255,
    g: it(e, 255) * 255,
    b: it(t, 255) * 255
  };
}
function Vl(n, e, t) {
  n = it(n, 255), e = it(e, 255), t = it(t, 255);
  var i = Math.max(n, e, t), r = Math.min(n, e, t), a, o, s = (i + r) / 2;
  if (i == r)
    a = o = 0;
  else {
    var c = i - r;
    switch (o = s > 0.5 ? c / (2 - i - r) : c / (i + r), i) {
      case n:
        a = (e - t) / c + (e < t ? 6 : 0);
        break;
      case e:
        a = (t - n) / c + 2;
        break;
      case t:
        a = (n - e) / c + 4;
        break;
    }
    a /= 6;
  }
  return {
    h: a,
    s: o,
    l: s
  };
}
function fb(n, e, t) {
  var i, r, a;
  n = it(n, 360), e = it(e, 100), t = it(t, 100);
  function o(l, u, h) {
    return h < 0 && (h += 1), h > 1 && (h -= 1), h < 1 / 6 ? l + (u - l) * 6 * h : h < 1 / 2 ? u : h < 2 / 3 ? l + (u - l) * (2 / 3 - h) * 6 : l;
  }
  if (e === 0)
    i = r = a = t;
  else {
    var s = t < 0.5 ? t * (1 + e) : t + e - t * e, c = 2 * t - s;
    i = o(c, s, n + 1 / 3), r = o(c, s, n), a = o(c, s, n - 1 / 3);
  }
  return {
    r: i * 255,
    g: r * 255,
    b: a * 255
  };
}
function Gl(n, e, t) {
  n = it(n, 255), e = it(e, 255), t = it(t, 255);
  var i = Math.max(n, e, t), r = Math.min(n, e, t), a, o, s = i, c = i - r;
  if (o = i === 0 ? 0 : c / i, i == r)
    a = 0;
  else {
    switch (i) {
      case n:
        a = (e - t) / c + (e < t ? 6 : 0);
        break;
      case e:
        a = (t - n) / c + 2;
        break;
      case t:
        a = (n - e) / c + 4;
        break;
    }
    a /= 6;
  }
  return {
    h: a,
    s: o,
    v: s
  };
}
function db(n, e, t) {
  n = it(n, 360) * 6, e = it(e, 100), t = it(t, 100);
  var i = Math.floor(n), r = n - i, a = t * (1 - e), o = t * (1 - r * e), s = t * (1 - (1 - r) * e), c = i % 6, l = [t, o, a, a, s, t][c], u = [s, t, t, o, a, a][c], h = [a, a, s, t, t, o][c];
  return {
    r: l * 255,
    g: u * 255,
    b: h * 255
  };
}
function Wl(n, e, t, i) {
  var r = [Kt(Math.round(n).toString(16)), Kt(Math.round(e).toString(16)), Kt(Math.round(t).toString(16))];
  return i && r[0].charAt(0) == r[0].charAt(1) && r[1].charAt(0) == r[1].charAt(1) && r[2].charAt(0) == r[2].charAt(1) ? r[0].charAt(0) + r[1].charAt(0) + r[2].charAt(0) : r.join("");
}
function pb(n, e, t, i, r) {
  var a = [Kt(Math.round(n).toString(16)), Kt(Math.round(e).toString(16)), Kt(Math.round(t).toString(16)), Kt(Eh(i))];
  return r && a[0].charAt(0) == a[0].charAt(1) && a[1].charAt(0) == a[1].charAt(1) && a[2].charAt(0) == a[2].charAt(1) && a[3].charAt(0) == a[3].charAt(1) ? a[0].charAt(0) + a[1].charAt(0) + a[2].charAt(0) + a[3].charAt(0) : a.join("");
}
function jl(n, e, t, i) {
  var r = [Kt(Eh(i)), Kt(Math.round(n).toString(16)), Kt(Math.round(e).toString(16)), Kt(Math.round(t).toString(16))];
  return r.join("");
}
ye.equals = function(n, e) {
  return !n || !e ? !1 : ye(n).toRgbString() == ye(e).toRgbString();
};
ye.random = function() {
  return ye.fromRatio({
    r: Math.random(),
    g: Math.random(),
    b: Math.random()
  });
};
function mb(n, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ye(n).toHsl();
  return t.s -= e / 100, t.s = Ca(t.s), ye(t);
}
function gb(n, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ye(n).toHsl();
  return t.s += e / 100, t.s = Ca(t.s), ye(t);
}
function vb(n) {
  return ye(n).desaturate(100);
}
function _b(n, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ye(n).toHsl();
  return t.l += e / 100, t.l = Ca(t.l), ye(t);
}
function yb(n, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ye(n).toRgb();
  return t.r = Math.max(0, Math.min(255, t.r - Math.round(255 * -(e / 100)))), t.g = Math.max(0, Math.min(255, t.g - Math.round(255 * -(e / 100)))), t.b = Math.max(0, Math.min(255, t.b - Math.round(255 * -(e / 100)))), ye(t);
}
function xb(n, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ye(n).toHsl();
  return t.l -= e / 100, t.l = Ca(t.l), ye(t);
}
function bb(n, e) {
  var t = ye(n).toHsl(), i = (t.h + e) % 360;
  return t.h = i < 0 ? 360 + i : i, ye(t);
}
function Mb(n) {
  var e = ye(n).toHsl();
  return e.h = (e.h + 180) % 360, ye(e);
}
function Xl(n, e) {
  if (isNaN(e) || e <= 0)
    throw new Error("Argument to polyad must be a positive number");
  for (var t = ye(n).toHsl(), i = [ye(n)], r = 360 / e, a = 1; a < e; a++)
    i.push(ye({
      h: (t.h + a * r) % 360,
      s: t.s,
      l: t.l
    }));
  return i;
}
function Sb(n) {
  var e = ye(n).toHsl(), t = e.h;
  return [ye(n), ye({
    h: (t + 72) % 360,
    s: e.s,
    l: e.l
  }), ye({
    h: (t + 216) % 360,
    s: e.s,
    l: e.l
  })];
}
function Eb(n, e, t) {
  e = e || 6, t = t || 30;
  var i = ye(n).toHsl(), r = 360 / t, a = [ye(n)];
  for (i.h = (i.h - (r * e >> 1) + 720) % 360; --e; )
    i.h = (i.h + r) % 360, a.push(ye(i));
  return a;
}
function wb(n, e) {
  e = e || 6;
  for (var t = ye(n).toHsv(), i = t.h, r = t.s, a = t.v, o = [], s = 1 / e; e--; )
    o.push(ye({
      h: i,
      s: r,
      v: a
    })), a = (a + s) % 1;
  return o;
}
ye.mix = function(n, e, t) {
  t = t === 0 ? 0 : t || 50;
  var i = ye(n).toRgb(), r = ye(e).toRgb(), a = t / 100, o = {
    r: (r.r - i.r) * a + i.r,
    g: (r.g - i.g) * a + i.g,
    b: (r.b - i.b) * a + i.b,
    a: (r.a - i.a) * a + i.a
  };
  return ye(o);
};
ye.readability = function(n, e) {
  var t = ye(n), i = ye(e);
  return (Math.max(t.getLuminance(), i.getLuminance()) + 0.05) / (Math.min(t.getLuminance(), i.getLuminance()) + 0.05);
};
ye.isReadable = function(n, e, t) {
  var i = ye.readability(n, e), r, a;
  switch (a = !1, r = Lb(t), r.level + r.size) {
    case "AAsmall":
    case "AAAlarge":
      a = i >= 4.5;
      break;
    case "AAlarge":
      a = i >= 3;
      break;
    case "AAAsmall":
      a = i >= 7;
      break;
  }
  return a;
};
ye.mostReadable = function(n, e, t) {
  var i = null, r = 0, a, o, s, c;
  t = t || {}, o = t.includeFallbackColors, s = t.level, c = t.size;
  for (var l = 0; l < e.length; l++)
    a = ye.readability(n, e[l]), a > r && (r = a, i = ye(e[l]));
  return ye.isReadable(n, i, {
    level: s,
    size: c
  }) || !o ? i : (t.includeFallbackColors = !1, ye.mostReadable(n, ["#fff", "#000"], t));
};
var Yo = ye.names = {
  aliceblue: "f0f8ff",
  antiquewhite: "faebd7",
  aqua: "0ff",
  aquamarine: "7fffd4",
  azure: "f0ffff",
  beige: "f5f5dc",
  bisque: "ffe4c4",
  black: "000",
  blanchedalmond: "ffebcd",
  blue: "00f",
  blueviolet: "8a2be2",
  brown: "a52a2a",
  burlywood: "deb887",
  burntsienna: "ea7e5d",
  cadetblue: "5f9ea0",
  chartreuse: "7fff00",
  chocolate: "d2691e",
  coral: "ff7f50",
  cornflowerblue: "6495ed",
  cornsilk: "fff8dc",
  crimson: "dc143c",
  cyan: "0ff",
  darkblue: "00008b",
  darkcyan: "008b8b",
  darkgoldenrod: "b8860b",
  darkgray: "a9a9a9",
  darkgreen: "006400",
  darkgrey: "a9a9a9",
  darkkhaki: "bdb76b",
  darkmagenta: "8b008b",
  darkolivegreen: "556b2f",
  darkorange: "ff8c00",
  darkorchid: "9932cc",
  darkred: "8b0000",
  darksalmon: "e9967a",
  darkseagreen: "8fbc8f",
  darkslateblue: "483d8b",
  darkslategray: "2f4f4f",
  darkslategrey: "2f4f4f",
  darkturquoise: "00ced1",
  darkviolet: "9400d3",
  deeppink: "ff1493",
  deepskyblue: "00bfff",
  dimgray: "696969",
  dimgrey: "696969",
  dodgerblue: "1e90ff",
  firebrick: "b22222",
  floralwhite: "fffaf0",
  forestgreen: "228b22",
  fuchsia: "f0f",
  gainsboro: "dcdcdc",
  ghostwhite: "f8f8ff",
  gold: "ffd700",
  goldenrod: "daa520",
  gray: "808080",
  green: "008000",
  greenyellow: "adff2f",
  grey: "808080",
  honeydew: "f0fff0",
  hotpink: "ff69b4",
  indianred: "cd5c5c",
  indigo: "4b0082",
  ivory: "fffff0",
  khaki: "f0e68c",
  lavender: "e6e6fa",
  lavenderblush: "fff0f5",
  lawngreen: "7cfc00",
  lemonchiffon: "fffacd",
  lightblue: "add8e6",
  lightcoral: "f08080",
  lightcyan: "e0ffff",
  lightgoldenrodyellow: "fafad2",
  lightgray: "d3d3d3",
  lightgreen: "90ee90",
  lightgrey: "d3d3d3",
  lightpink: "ffb6c1",
  lightsalmon: "ffa07a",
  lightseagreen: "20b2aa",
  lightskyblue: "87cefa",
  lightslategray: "789",
  lightslategrey: "789",
  lightsteelblue: "b0c4de",
  lightyellow: "ffffe0",
  lime: "0f0",
  limegreen: "32cd32",
  linen: "faf0e6",
  magenta: "f0f",
  maroon: "800000",
  mediumaquamarine: "66cdaa",
  mediumblue: "0000cd",
  mediumorchid: "ba55d3",
  mediumpurple: "9370db",
  mediumseagreen: "3cb371",
  mediumslateblue: "7b68ee",
  mediumspringgreen: "00fa9a",
  mediumturquoise: "48d1cc",
  mediumvioletred: "c71585",
  midnightblue: "191970",
  mintcream: "f5fffa",
  mistyrose: "ffe4e1",
  moccasin: "ffe4b5",
  navajowhite: "ffdead",
  navy: "000080",
  oldlace: "fdf5e6",
  olive: "808000",
  olivedrab: "6b8e23",
  orange: "ffa500",
  orangered: "ff4500",
  orchid: "da70d6",
  palegoldenrod: "eee8aa",
  palegreen: "98fb98",
  paleturquoise: "afeeee",
  palevioletred: "db7093",
  papayawhip: "ffefd5",
  peachpuff: "ffdab9",
  peru: "cd853f",
  pink: "ffc0cb",
  plum: "dda0dd",
  powderblue: "b0e0e6",
  purple: "800080",
  rebeccapurple: "663399",
  red: "f00",
  rosybrown: "bc8f8f",
  royalblue: "4169e1",
  saddlebrown: "8b4513",
  salmon: "fa8072",
  sandybrown: "f4a460",
  seagreen: "2e8b57",
  seashell: "fff5ee",
  sienna: "a0522d",
  silver: "c0c0c0",
  skyblue: "87ceeb",
  slateblue: "6a5acd",
  slategray: "708090",
  slategrey: "708090",
  snow: "fffafa",
  springgreen: "00ff7f",
  steelblue: "4682b4",
  tan: "d2b48c",
  teal: "008080",
  thistle: "d8bfd8",
  tomato: "ff6347",
  turquoise: "40e0d0",
  violet: "ee82ee",
  wheat: "f5deb3",
  white: "fff",
  whitesmoke: "f5f5f5",
  yellow: "ff0",
  yellowgreen: "9acd32"
}, Tb = ye.hexNames = Ab(Yo);
function Ab(n) {
  var e = {};
  for (var t in n)
    n.hasOwnProperty(t) && (e[n[t]] = t);
  return e;
}
function Sh(n) {
  return n = parseFloat(n), (isNaN(n) || n < 0 || n > 1) && (n = 1), n;
}
function it(n, e) {
  Cb(n) && (n = "100%");
  var t = Rb(n);
  return n = Math.min(e, Math.max(0, parseFloat(n))), t && (n = parseInt(n * e, 10) / 100), Math.abs(n - e) < 1e-6 ? 1 : n % e / parseFloat(e);
}
function Ca(n) {
  return Math.min(1, Math.max(0, n));
}
function It(n) {
  return parseInt(n, 16);
}
function Cb(n) {
  return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
}
function Rb(n) {
  return typeof n == "string" && n.indexOf("%") != -1;
}
function Kt(n) {
  return n.length == 1 ? "0" + n : "" + n;
}
function cr(n) {
  return n <= 1 && (n = n * 100 + "%"), n;
}
function Eh(n) {
  return Math.round(parseFloat(n) * 255).toString(16);
}
function $l(n) {
  return It(n) / 255;
}
var Xt = function() {
  var n = "[-\\+]?\\d+%?", e = "[-\\+]?\\d*\\.\\d+%?", t = "(?:" + e + ")|(?:" + n + ")", i = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?", r = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?";
  return {
    CSS_UNIT: new RegExp(t),
    rgb: new RegExp("rgb" + i),
    rgba: new RegExp("rgba" + r),
    hsl: new RegExp("hsl" + i),
    hsla: new RegExp("hsla" + r),
    hsv: new RegExp("hsv" + i),
    hsva: new RegExp("hsva" + r),
    hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
    hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
    hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
    hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
  };
}();
function gn(n) {
  return !!Xt.CSS_UNIT.exec(n);
}
function Pb(n) {
  n = n.replace(cb, "").replace(lb, "").toLowerCase();
  var e = !1;
  if (Yo[n])
    n = Yo[n], e = !0;
  else if (n == "transparent")
    return {
      r: 0,
      g: 0,
      b: 0,
      a: 0,
      format: "name"
    };
  var t;
  return (t = Xt.rgb.exec(n)) ? {
    r: t[1],
    g: t[2],
    b: t[3]
  } : (t = Xt.rgba.exec(n)) ? {
    r: t[1],
    g: t[2],
    b: t[3],
    a: t[4]
  } : (t = Xt.hsl.exec(n)) ? {
    h: t[1],
    s: t[2],
    l: t[3]
  } : (t = Xt.hsla.exec(n)) ? {
    h: t[1],
    s: t[2],
    l: t[3],
    a: t[4]
  } : (t = Xt.hsv.exec(n)) ? {
    h: t[1],
    s: t[2],
    v: t[3]
  } : (t = Xt.hsva.exec(n)) ? {
    h: t[1],
    s: t[2],
    v: t[3],
    a: t[4]
  } : (t = Xt.hex8.exec(n)) ? {
    r: It(t[1]),
    g: It(t[2]),
    b: It(t[3]),
    a: $l(t[4]),
    format: e ? "name" : "hex8"
  } : (t = Xt.hex6.exec(n)) ? {
    r: It(t[1]),
    g: It(t[2]),
    b: It(t[3]),
    format: e ? "name" : "hex"
  } : (t = Xt.hex4.exec(n)) ? {
    r: It(t[1] + "" + t[1]),
    g: It(t[2] + "" + t[2]),
    b: It(t[3] + "" + t[3]),
    a: $l(t[4] + "" + t[4]),
    format: e ? "name" : "hex8"
  } : (t = Xt.hex3.exec(n)) ? {
    r: It(t[1] + "" + t[1]),
    g: It(t[2] + "" + t[2]),
    b: It(t[3] + "" + t[3]),
    format: e ? "name" : "hex"
  } : !1;
}
function Lb(n) {
  var e, t;
  return n = n || {
    level: "AA",
    size: "small"
  }, e = (n.level || "AA").toUpperCase(), t = (n.size || "small").toLowerCase(), e !== "AA" && e !== "AAA" && (e = "AA"), t !== "small" && t !== "large" && (t = "small"), {
    level: e,
    size: t
  };
}
function Db(n, e, t) {
  return e = ma(e), Hb(n, Ps() ? Reflect.construct(e, t || [], ma(n).constructor) : e.apply(n, t));
}
function Ob(n, e, t) {
  if (Ps())
    return Reflect.construct.apply(null, arguments);
  var i = [null];
  i.push.apply(i, e);
  var r = new (n.bind.apply(n, i))();
  return t && ga(r, t.prototype), r;
}
function Ps() {
  try {
    var n = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
    }));
  } catch {
  }
  return (Ps = function() {
    return !!n;
  })();
}
function Ib(n, e) {
  var t = n == null ? null : typeof Symbol < "u" && n[Symbol.iterator] || n["@@iterator"];
  if (t != null) {
    var i, r, a, o, s = [], c = !0, l = !1;
    try {
      if (a = (t = t.call(n)).next, e === 0) {
        if (Object(t) !== t)
          return;
        c = !1;
      } else
        for (; !(c = (i = a.call(t)).done) && (s.push(i.value), s.length !== e); c = !0)
          ;
    } catch (u) {
      l = !0, r = u;
    } finally {
      try {
        if (!c && t.return != null && (o = t.return(), Object(o) !== o))
          return;
      } finally {
        if (l)
          throw r;
      }
    }
    return s;
  }
}
function ql(n, e) {
  var t = Object.keys(n);
  if (Object.getOwnPropertySymbols) {
    var i = Object.getOwnPropertySymbols(n);
    e && (i = i.filter(function(r) {
      return Object.getOwnPropertyDescriptor(n, r).enumerable;
    })), t.push.apply(t, i);
  }
  return t;
}
function wh(n) {
  for (var e = 1; e < arguments.length; e++) {
    var t = arguments[e] != null ? arguments[e] : {};
    e % 2 ? ql(Object(t), !0).forEach(function(i) {
      Ls(n, i, t[i]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(t)) : ql(Object(t)).forEach(function(i) {
      Object.defineProperty(n, i, Object.getOwnPropertyDescriptor(t, i));
    });
  }
  return n;
}
function Nb(n, e) {
  if (typeof n != "object" || !n)
    return n;
  var t = n[Symbol.toPrimitive];
  if (t !== void 0) {
    var i = t.call(n, e || "default");
    if (typeof i != "object")
      return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (e === "string" ? String : Number)(n);
}
function Th(n) {
  var e = Nb(n, "string");
  return typeof e == "symbol" ? e : String(e);
}
function Ko(n) {
  "@babel/helpers - typeof";
  return Ko = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
    return typeof e;
  } : function(e) {
    return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
  }, Ko(n);
}
function Ub(n, e) {
  if (!(n instanceof e))
    throw new TypeError("Cannot call a class as a function");
}
function Yl(n, e) {
  for (var t = 0; t < e.length; t++) {
    var i = e[t];
    i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(n, Th(i.key), i);
  }
}
function Fb(n, e, t) {
  return e && Yl(n.prototype, e), t && Yl(n, t), Object.defineProperty(n, "prototype", {
    writable: !1
  }), n;
}
function Ls(n, e, t) {
  return e = Th(e), e in n ? Object.defineProperty(n, e, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : n[e] = t, n;
}
function Bb(n, e) {
  if (typeof e != "function" && e !== null)
    throw new TypeError("Super expression must either be null or a function");
  n.prototype = Object.create(e && e.prototype, {
    constructor: {
      value: n,
      writable: !0,
      configurable: !0
    }
  }), Object.defineProperty(n, "prototype", {
    writable: !1
  }), e && ga(n, e);
}
function ma(n) {
  return ma = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
    return t.__proto__ || Object.getPrototypeOf(t);
  }, ma(n);
}
function ga(n, e) {
  return ga = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(i, r) {
    return i.__proto__ = r, i;
  }, ga(n, e);
}
function kb(n, e) {
  if (n == null)
    return {};
  var t = {}, i = Object.keys(n), r, a;
  for (a = 0; a < i.length; a++)
    r = i[a], !(e.indexOf(r) >= 0) && (t[r] = n[r]);
  return t;
}
function zb(n, e) {
  if (n == null)
    return {};
  var t = kb(n, e), i, r;
  if (Object.getOwnPropertySymbols) {
    var a = Object.getOwnPropertySymbols(n);
    for (r = 0; r < a.length; r++)
      i = a[r], !(e.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(n, i) && (t[i] = n[i]);
  }
  return t;
}
function Ah(n) {
  if (n === void 0)
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  return n;
}
function Hb(n, e) {
  if (e && (typeof e == "object" || typeof e == "function"))
    return e;
  if (e !== void 0)
    throw new TypeError("Derived constructors may only return object or undefined");
  return Ah(n);
}
function Kl(n, e) {
  return Gb(n) || Ib(n, e) || Ch(n, e) || Xb();
}
function qt(n) {
  return Vb(n) || Wb(n) || Ch(n) || jb();
}
function Vb(n) {
  if (Array.isArray(n))
    return Zo(n);
}
function Gb(n) {
  if (Array.isArray(n))
    return n;
}
function Wb(n) {
  if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
    return Array.from(n);
}
function Ch(n, e) {
  if (n) {
    if (typeof n == "string")
      return Zo(n, e);
    var t = Object.prototype.toString.call(n).slice(8, -1);
    if (t === "Object" && n.constructor && (t = n.constructor.name), t === "Map" || t === "Set")
      return Array.from(n);
    if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))
      return Zo(n, e);
  }
}
function Zo(n, e) {
  (e == null || e > n.length) && (e = n.length);
  for (var t = 0, i = new Array(e); t < e; t++)
    i[t] = n[t];
  return i;
}
function jb() {
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Xb() {
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
var $b = function n(e) {
  e instanceof Array ? e.forEach(n) : (e.map && e.map.dispose(), e.dispose());
}, qb = function n(e) {
  e.geometry && e.geometry.dispose(), e.material && $b(e.material), e.texture && e.texture.dispose(), e.children && e.children.forEach(n);
}, Jo = function(e) {
  for (; e.children.length; ) {
    var t = e.children[0];
    e.remove(t), qb(t);
  }
}, Yb = ["objFilter"];
function nr(n, e) {
  var t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, i = t.objFilter, r = i === void 0 ? function() {
    return !0;
  } : i, a = zb(t, Yb);
  return rb(n, e.children.filter(r), function(o) {
    return e.add(o);
  }, function(o) {
    e.remove(o), Jo(o);
  }, wh({
    objBindAttr: "__threeObj"
  }, a));
}
var ir = function(e) {
  return isNaN(e) ? parseInt(ye(e).toHex(), 16) : e;
}, wo = function(e) {
  return isNaN(e) ? ye(e).getAlpha() : 1;
}, Kb = Mh(sb);
function Zl(n, e, t) {
  !e || typeof t != "string" || n.filter(function(i) {
    return !i[t];
  }).forEach(function(i) {
    i[t] = Kb(e(i));
  });
}
function Zb(n, e) {
  var t = n.nodes, i = n.links, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, a = r.nodeFilter, o = a === void 0 ? function() {
    return !0;
  } : a, s = r.onLoopError, c = s === void 0 ? function(p) {
    throw "Invalid DAG structure! Found cycle in node path: ".concat(p.join(" -> "), ".");
  } : s, l = {};
  t.forEach(function(p) {
    return l[e(p)] = {
      data: p,
      out: [],
      depth: -1,
      skip: !o(p)
    };
  }), i.forEach(function(p) {
    var g = p.source, v = p.target, m = x(g), f = x(v);
    if (!l.hasOwnProperty(m))
      throw "Missing source node with id: ".concat(m);
    if (!l.hasOwnProperty(f))
      throw "Missing target node with id: ".concat(f);
    var M = l[m], _ = l[f];
    M.out.push(_);
    function x(T) {
      return Ko(T) === "object" ? e(T) : T;
    }
  });
  var u = [];
  d(Object.values(l));
  var h = Object.assign.apply(Object, [{}].concat(qt(Object.entries(l).filter(function(p) {
    var g = Kl(p, 2), v = g[1];
    return !v.skip;
  }).map(function(p) {
    var g = Kl(p, 2), v = g[0], m = g[1];
    return Ls({}, v, m.depth);
  }))));
  return h;
  function d(p) {
    for (var g = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [], v = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, m = function() {
      var x = p[f];
      if (g.indexOf(x) !== -1) {
        var T = [].concat(qt(g.slice(g.indexOf(x))), [x]).map(function(E) {
          return e(E.data);
        });
        return u.some(function(E) {
          return E.length === T.length && E.every(function(A, R) {
            return A === T[R];
          });
        }) || (u.push(T), c(T)), 1;
      }
      v > x.depth && (x.depth = v, d(x.out, [].concat(qt(g), [x]), v + (x.skip ? 0 : 1)));
    }, f = 0, M = p.length; f < M; f++)
      m();
  }
}
var Ce = window.THREE ? window.THREE : {
  Group: Oi,
  Mesh: Vt,
  MeshLambertMaterial: I_,
  Color: We,
  BufferGeometry: Nt,
  BufferAttribute: Zt,
  Matrix4: Je,
  Vector3: O,
  SphereGeometry: Ta,
  CylinderGeometry: wa,
  TubeGeometry: vs,
  ConeGeometry: gs,
  Line: __,
  LineBasicMaterial: Fu,
  QuadraticBezierCurve3: ms,
  CubicBezierCurve3: ku,
  Box3: ui
}, Jl = {
  graph: uy,
  forcelayout: Wy
}, Jb = 2, Ql = new Ce.BufferGeometry().setAttribute ? "setAttribute" : "addAttribute", Qr = new Ce.BufferGeometry().applyMatrix4 ? "applyMatrix4" : "applyMatrix", Qb = Rs({
  props: {
    jsonUrl: {
      onChange: function(e, t) {
        var i = this;
        e && !t.fetchingJson && (t.fetchingJson = !0, t.onLoading(), fetch(e).then(function(r) {
          return r.json();
        }).then(function(r) {
          t.fetchingJson = !1, t.onFinishLoading(r), i.graphData(r);
        }));
      },
      triggerUpdate: !1
    },
    graphData: {
      default: {
        nodes: [],
        links: []
      },
      onChange: function(e, t) {
        t.engineRunning = !1;
      }
    },
    numDimensions: {
      default: 3,
      onChange: function(e, t) {
        var i = t.d3ForceLayout.force("charge");
        i && i.strength(e > 2 ? -60 : -30), e < 3 && r(t.graphData.nodes, "z"), e < 2 && r(t.graphData.nodes, "y");
        function r(a, o) {
          a.forEach(function(s) {
            delete s[o], delete s["v".concat(o)];
          });
        }
      }
    },
    dagMode: {
      onChange: function(e, t) {
        !e && t.forceEngine === "d3" && (t.graphData.nodes || []).forEach(function(i) {
          return i.fx = i.fy = i.fz = void 0;
        });
      }
    },
    dagLevelDistance: {},
    dagNodeFilter: {
      default: function(e) {
        return !0;
      }
    },
    onDagError: {
      triggerUpdate: !1
    },
    nodeRelSize: {
      default: 4
    },
    // volume per val unit
    nodeId: {
      default: "id"
    },
    nodeVal: {
      default: "val"
    },
    nodeResolution: {
      default: 8
    },
    // how many slice segments in the sphere's circumference
    nodeColor: {
      default: "color"
    },
    nodeAutoColorBy: {},
    nodeOpacity: {
      default: 0.75
    },
    nodeVisibility: {
      default: !0
    },
    nodeThreeObject: {},
    nodeThreeObjectExtend: {
      default: !1
    },
    nodePositionUpdate: {
      triggerUpdate: !1
    },
    // custom function to call for updating the node's position. Signature: (threeObj, { x, y, z}, node). If the function returns a truthy value, the regular node position update will not run.
    linkSource: {
      default: "source"
    },
    linkTarget: {
      default: "target"
    },
    linkVisibility: {
      default: !0
    },
    linkColor: {
      default: "color"
    },
    linkAutoColorBy: {},
    linkOpacity: {
      default: 0.2
    },
    linkWidth: {},
    // Rounded to nearest decimal. For falsy values use dimensionless line with 1px regardless of distance.
    linkResolution: {
      default: 6
    },
    // how many radial segments in each line tube's geometry
    linkCurvature: {
      default: 0,
      triggerUpdate: !1
    },
    // line curvature radius (0: straight, 1: semi-circle)
    linkCurveRotation: {
      default: 0,
      triggerUpdate: !1
    },
    // line curve rotation along the line axis (0: interection with XY plane, PI: upside down)
    linkMaterial: {},
    linkThreeObject: {},
    linkThreeObjectExtend: {
      default: !1
    },
    linkPositionUpdate: {
      triggerUpdate: !1
    },
    // custom function to call for updating the link's position. Signature: (threeObj, { start: { x, y, z},  end: { x, y, z }}, link). If the function returns a truthy value, the regular link position update will not run.
    linkDirectionalArrowLength: {
      default: 0
    },
    linkDirectionalArrowColor: {},
    linkDirectionalArrowRelPos: {
      default: 0.5,
      triggerUpdate: !1
    },
    // value between 0<>1 indicating the relative pos along the (exposed) line
    linkDirectionalArrowResolution: {
      default: 8
    },
    // how many slice segments in the arrow's conic circumference
    linkDirectionalParticles: {
      default: 0
    },
    // animate photons travelling in the link direction
    linkDirectionalParticleSpeed: {
      default: 0.01,
      triggerUpdate: !1
    },
    // in link length ratio per frame
    linkDirectionalParticleWidth: {
      default: 0.5
    },
    linkDirectionalParticleColor: {},
    linkDirectionalParticleResolution: {
      default: 4
    },
    // how many slice segments in the particle sphere's circumference
    forceEngine: {
      default: "d3"
    },
    // d3 or ngraph
    d3AlphaMin: {
      default: 0
    },
    d3AlphaDecay: {
      default: 0.0228,
      triggerUpdate: !1,
      onChange: function(e, t) {
        t.d3ForceLayout.alphaDecay(e);
      }
    },
    d3AlphaTarget: {
      default: 0,
      triggerUpdate: !1,
      onChange: function(e, t) {
        t.d3ForceLayout.alphaTarget(e);
      }
    },
    d3VelocityDecay: {
      default: 0.4,
      triggerUpdate: !1,
      onChange: function(e, t) {
        t.d3ForceLayout.velocityDecay(e);
      }
    },
    ngraphPhysics: {
      default: {
        // defaults from https://github.com/anvaka/ngraph.physics.simulator/blob/master/index.js
        timeStep: 20,
        gravity: -1.2,
        theta: 0.8,
        springLength: 30,
        springCoefficient: 8e-4,
        dragCoefficient: 0.02
      }
    },
    warmupTicks: {
      default: 0,
      triggerUpdate: !1
    },
    // how many times to tick the force engine at init before starting to render
    cooldownTicks: {
      default: 1 / 0,
      triggerUpdate: !1
    },
    cooldownTime: {
      default: 15e3,
      triggerUpdate: !1
    },
    // ms
    onLoading: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onFinishLoading: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onUpdate: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onFinishUpdate: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onEngineTick: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onEngineStop: {
      default: function() {
      },
      triggerUpdate: !1
    }
  },
  methods: {
    refresh: function(e) {
      return e._flushObjects = !0, e._rerender(), this;
    },
    // Expose d3 forces for external manipulation
    d3Force: function(e, t, i) {
      return i === void 0 ? e.d3ForceLayout.force(t) : (e.d3ForceLayout.force(t, i), this);
    },
    d3ReheatSimulation: function(e) {
      return e.d3ForceLayout.alpha(1), this.resetCountdown(), this;
    },
    // reset cooldown state
    resetCountdown: function(e) {
      return e.cntTicks = 0, e.startTickTime = /* @__PURE__ */ new Date(), e.engineRunning = !0, this;
    },
    tickFrame: function(e) {
      var t = e.forceEngine !== "ngraph";
      return e.engineRunning && i(), r(), a(), this;
      function i() {
        ++e.cntTicks > e.cooldownTicks || /* @__PURE__ */ new Date() - e.startTickTime > e.cooldownTime || t && e.d3AlphaMin > 0 && e.d3ForceLayout.alpha() < e.d3AlphaMin ? (e.engineRunning = !1, e.onEngineStop()) : (e.layout[t ? "tick" : "step"](), e.onEngineTick());
        var o = Xe(e.nodeThreeObjectExtend);
        e.graphData.nodes.forEach(function(d) {
          var p = d.__threeObj;
          if (p) {
            var g = t ? d : e.layout.getNodePosition(d[e.nodeId]), v = o(d);
            (!e.nodePositionUpdate || !e.nodePositionUpdate(v ? p.children[0] : p, {
              x: g.x,
              y: g.y,
              z: g.z
            }, d) || v) && (p.position.x = g.x, p.position.y = g.y || 0, p.position.z = g.z || 0);
          }
        });
        var s = Xe(e.linkWidth), c = Xe(e.linkCurvature), l = Xe(e.linkCurveRotation), u = Xe(e.linkThreeObjectExtend);
        e.graphData.links.forEach(function(d) {
          var p = d.__lineObj;
          if (p) {
            var g = t ? d : e.layout.getLinkPosition(e.layout.graph.getLink(d.source, d.target).id), v = g[t ? "source" : "from"], m = g[t ? "target" : "to"];
            if (!(!v || !m || !v.hasOwnProperty("x") || !m.hasOwnProperty("x"))) {
              h(d);
              var f = u(d);
              if (!(e.linkPositionUpdate && e.linkPositionUpdate(
                f ? p.children[1] : p,
                // pass child custom object if extending the default
                {
                  start: {
                    x: v.x,
                    y: v.y,
                    z: v.z
                  },
                  end: {
                    x: m.x,
                    y: m.y,
                    z: m.z
                  }
                },
                d
              ) && !f)) {
                var M = 30, _ = d.__curve, x = p.children.length ? p.children[0] : p;
                if (x.type === "Line") {
                  if (_)
                    x.geometry.setFromPoints(_.getPoints(M));
                  else {
                    var T = x.geometry.getAttribute("position");
                    (!T || !T.array || T.array.length !== 6) && x.geometry[Ql]("position", T = new Ce.BufferAttribute(new Float32Array(2 * 3), 3)), T.array[0] = v.x, T.array[1] = v.y || 0, T.array[2] = v.z || 0, T.array[3] = m.x, T.array[4] = m.y || 0, T.array[5] = m.z || 0, T.needsUpdate = !0;
                  }
                  x.geometry.computeBoundingSphere();
                } else if (x.type === "Mesh")
                  if (_) {
                    x.geometry.type.match(/^Tube(Buffer)?Geometry$/) || (x.position.set(0, 0, 0), x.rotation.set(0, 0, 0), x.scale.set(1, 1, 1));
                    var z = Math.ceil(s(d) * 10) / 10, I = z / 2, L = new Ce.TubeGeometry(_, M, I, e.linkResolution, !1);
                    x.geometry.dispose(), x.geometry = L;
                  } else {
                    if (!x.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)) {
                      var E = Math.ceil(s(d) * 10) / 10, A = E / 2, R = new Ce.CylinderGeometry(A, A, 1, e.linkResolution, 1, !1);
                      R[Qr](new Ce.Matrix4().makeTranslation(0, 1 / 2, 0)), R[Qr](new Ce.Matrix4().makeRotationX(Math.PI / 2)), x.geometry.dispose(), x.geometry = R;
                    }
                    var w = new Ce.Vector3(v.x, v.y || 0, v.z || 0), b = new Ce.Vector3(m.x, m.y || 0, m.z || 0), U = w.distanceTo(b);
                    x.position.x = w.x, x.position.y = w.y, x.position.z = w.z, x.scale.z = U, x.parent.localToWorld(b), x.lookAt(b);
                  }
              }
            }
          }
        });
        function h(d) {
          var p = t ? d : e.layout.getLinkPosition(e.layout.graph.getLink(d.source, d.target).id), g = p[t ? "source" : "from"], v = p[t ? "target" : "to"];
          if (!(!g || !v || !g.hasOwnProperty("x") || !v.hasOwnProperty("x"))) {
            var m = c(d);
            if (!m)
              d.__curve = null;
            else {
              var f = new Ce.Vector3(g.x, g.y || 0, g.z || 0), M = new Ce.Vector3(v.x, v.y || 0, v.z || 0), _ = f.distanceTo(M), x, T = l(d);
              if (_ > 0) {
                var E = v.x - g.x, A = v.y - g.y || 0, R = new Ce.Vector3().subVectors(M, f), w = R.clone().multiplyScalar(m).cross(E !== 0 || A !== 0 ? new Ce.Vector3(0, 0, 1) : new Ce.Vector3(0, 1, 0)).applyAxisAngle(R.normalize(), T).add(new Ce.Vector3().addVectors(f, M).divideScalar(2));
                x = new Ce.QuadraticBezierCurve3(f, w, M);
              } else {
                var b = m * 70, U = -T, z = U + Math.PI / 2;
                x = new Ce.CubicBezierCurve3(f, new Ce.Vector3(b * Math.cos(z), b * Math.sin(z), 0).add(f), new Ce.Vector3(b * Math.cos(U), b * Math.sin(U), 0).add(f), M);
              }
              d.__curve = x;
            }
          }
        }
      }
      function r() {
        var o = Xe(e.linkDirectionalArrowRelPos), s = Xe(e.linkDirectionalArrowLength), c = Xe(e.nodeVal);
        e.graphData.links.forEach(function(l) {
          var u = l.__arrowObj;
          if (u) {
            var h = t ? l : e.layout.getLinkPosition(e.layout.graph.getLink(l.source, l.target).id), d = h[t ? "source" : "from"], p = h[t ? "target" : "to"];
            if (!(!d || !p || !d.hasOwnProperty("x") || !p.hasOwnProperty("x"))) {
              var g = Math.cbrt(Math.max(0, c(d) || 1)) * e.nodeRelSize, v = Math.cbrt(Math.max(0, c(p) || 1)) * e.nodeRelSize, m = s(l), f = o(l), M = l.__curve ? function(R) {
                return l.__curve.getPoint(R);
              } : function(R) {
                var w = function(U, z, I, L) {
                  return z[U] + (I[U] - z[U]) * L || 0;
                };
                return {
                  x: w("x", d, p, R),
                  y: w("y", d, p, R),
                  z: w("z", d, p, R)
                };
              }, _ = l.__curve ? l.__curve.getLength() : Math.sqrt(["x", "y", "z"].map(function(R) {
                return Math.pow((p[R] || 0) - (d[R] || 0), 2);
              }).reduce(function(R, w) {
                return R + w;
              }, 0)), x = g + m + (_ - g - v - m) * f, T = M(x / _), E = M((x - m) / _);
              ["x", "y", "z"].forEach(function(R) {
                return u.position[R] = E[R];
              });
              var A = Ob(Ce.Vector3, qt(["x", "y", "z"].map(function(R) {
                return T[R];
              })));
              u.parent.localToWorld(A), u.lookAt(A);
            }
          }
        });
      }
      function a() {
        var o = Xe(e.linkDirectionalParticleSpeed);
        e.graphData.links.forEach(function(s) {
          var c = s.__photonsObj && s.__photonsObj.children, l = s.__singleHopPhotonsObj && s.__singleHopPhotonsObj.children;
          if (!((!l || !l.length) && (!c || !c.length))) {
            var u = t ? s : e.layout.getLinkPosition(e.layout.graph.getLink(s.source, s.target).id), h = u[t ? "source" : "from"], d = u[t ? "target" : "to"];
            if (!(!h || !d || !h.hasOwnProperty("x") || !d.hasOwnProperty("x"))) {
              var p = o(s), g = s.__curve ? function(m) {
                return s.__curve.getPoint(m);
              } : function(m) {
                var f = function(_, x, T, E) {
                  return x[_] + (T[_] - x[_]) * E || 0;
                };
                return {
                  x: f("x", h, d, m),
                  y: f("y", h, d, m),
                  z: f("z", h, d, m)
                };
              }, v = [].concat(qt(c || []), qt(l || []));
              v.forEach(function(m, f) {
                var M = m.parent.__linkThreeObjType === "singleHopPhotons";
                if (m.hasOwnProperty("__progressRatio") || (m.__progressRatio = M ? 0 : f / c.length), m.__progressRatio += p, m.__progressRatio >= 1)
                  if (!M)
                    m.__progressRatio = m.__progressRatio % 1;
                  else {
                    m.parent.remove(m), Jo(m);
                    return;
                  }
                var _ = m.__progressRatio, x = g(_);
                ["x", "y", "z"].forEach(function(T) {
                  return m.position[T] = x[T];
                });
              });
            }
          }
        });
      }
    },
    emitParticle: function(e, t) {
      if (t && e.graphData.links.includes(t)) {
        if (!t.__singleHopPhotonsObj) {
          var i = new Ce.Group();
          i.__linkThreeObjType = "singleHopPhotons", t.__singleHopPhotonsObj = i, e.graphScene.add(i);
        }
        var r = Xe(e.linkDirectionalParticleWidth), a = Math.ceil(r(t) * 10) / 10 / 2, o = e.linkDirectionalParticleResolution, s = new Ce.SphereGeometry(a, o, o), c = Xe(e.linkColor), l = Xe(e.linkDirectionalParticleColor), u = l(t) || c(t) || "#f0f0f0", h = new Ce.Color(ir(u)), d = e.linkOpacity * 3, p = new Ce.MeshLambertMaterial({
          color: h,
          transparent: !0,
          opacity: d
        });
        t.__singleHopPhotonsObj.add(new Ce.Mesh(s, p));
      }
      return this;
    },
    getGraphBbox: function(e) {
      var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function() {
        return !0;
      };
      if (!e.initialised)
        return null;
      var i = function r(a) {
        var o = [];
        if (a.geometry) {
          a.geometry.computeBoundingBox();
          var s = new Ce.Box3();
          s.copy(a.geometry.boundingBox).applyMatrix4(a.matrixWorld), o.push(s);
        }
        return o.concat.apply(o, qt((a.children || []).filter(
          function(c) {
            return !c.hasOwnProperty("__graphObjType") || c.__graphObjType === "node" && t(c.__data);
          }
          // exclude filtered out nodes
        ).map(r)));
      }(e.graphScene);
      return i.length ? Object.assign.apply(Object, qt(["x", "y", "z"].map(function(r) {
        return Ls({}, r, [Lx(i, function(a) {
          return a.min[r];
        }), Px(i, function(a) {
          return a.max[r];
        })]);
      }))) : null;
    }
  },
  stateInit: function() {
    return {
      d3ForceLayout: ty().force("link", z0()).force("charge", ny()).force("center", W_()).force("dagRadial", null).stop(),
      engineRunning: !1
    };
  },
  init: function(e, t) {
    t.graphScene = e;
  },
  update: function(e, t) {
    var i = function(H) {
      return H.some(function(Z) {
        return t.hasOwnProperty(Z);
      });
    };
    if (e.engineRunning = !1, e.onUpdate(), e.nodeAutoColorBy !== null && i(["nodeAutoColorBy", "graphData", "nodeColor"]) && Zl(e.graphData.nodes, Xe(e.nodeAutoColorBy), e.nodeColor), e.linkAutoColorBy !== null && i(["linkAutoColorBy", "graphData", "linkColor"]) && Zl(e.graphData.links, Xe(e.linkAutoColorBy), e.linkColor), e._flushObjects || i(["graphData", "nodeThreeObject", "nodeThreeObjectExtend", "nodeVal", "nodeColor", "nodeVisibility", "nodeRelSize", "nodeResolution", "nodeOpacity"])) {
      var r = Xe(e.nodeThreeObject), a = Xe(e.nodeThreeObjectExtend), o = Xe(e.nodeVal), s = Xe(e.nodeColor), c = Xe(e.nodeVisibility), l = {}, u = {};
      nr(e.graphData.nodes.filter(c), e.graphScene, {
        purge: e._flushObjects || i([
          // recreate objects if any of these props have changed
          "nodeThreeObject",
          "nodeThreeObjectExtend"
        ]),
        objFilter: function(H) {
          return H.__graphObjType === "node";
        },
        createObj: function(H) {
          var Z = r(H), N = a(H);
          Z && e.nodeThreeObject === Z && (Z = Z.clone());
          var K;
          return Z && !N ? K = Z : (K = new Ce.Mesh(), K.__graphDefaultObj = !0, Z && N && K.add(Z)), K.__graphObjType = "node", K;
        },
        updateObj: function(H, Z) {
          if (H.__graphDefaultObj) {
            var N = o(Z) || 1, K = Math.cbrt(N) * e.nodeRelSize, oe = e.nodeResolution;
            (!H.geometry.type.match(/^Sphere(Buffer)?Geometry$/) || H.geometry.parameters.radius !== K || H.geometry.parameters.widthSegments !== oe) && (l.hasOwnProperty(N) || (l[N] = new Ce.SphereGeometry(K, oe, oe)), H.geometry.dispose(), H.geometry = l[N]);
            var fe = s(Z), F = new Ce.Color(ir(fe || "#ffffaa")), ge = e.nodeOpacity * wo(fe);
            (H.material.type !== "MeshLambertMaterial" || !H.material.color.equals(F) || H.material.opacity !== ge) && (u.hasOwnProperty(fe) || (u[fe] = new Ce.MeshLambertMaterial({
              color: F,
              transparent: !0,
              opacity: ge
            })), H.material.dispose(), H.material = u[fe]);
          }
        }
      });
    }
    if (e._flushObjects || i(["graphData", "linkThreeObject", "linkThreeObjectExtend", "linkMaterial", "linkColor", "linkWidth", "linkVisibility", "linkResolution", "linkOpacity", "linkDirectionalArrowLength", "linkDirectionalArrowColor", "linkDirectionalArrowResolution", "linkDirectionalParticles", "linkDirectionalParticleWidth", "linkDirectionalParticleColor", "linkDirectionalParticleResolution"])) {
      var h = Xe(e.linkThreeObject), d = Xe(e.linkThreeObjectExtend), p = Xe(e.linkMaterial), g = Xe(e.linkVisibility), v = Xe(e.linkColor), m = Xe(e.linkWidth), f = {}, M = {}, _ = {}, x = e.graphData.links.filter(g);
      if (nr(x, e.graphScene, {
        objBindAttr: "__lineObj",
        purge: e._flushObjects || i([
          // recreate objects if any of these props have changed
          "linkThreeObject",
          "linkThreeObjectExtend",
          "linkWidth"
        ]),
        objFilter: function(H) {
          return H.__graphObjType === "link";
        },
        exitObj: function(H) {
          var Z = H.__data && H.__data.__singleHopPhotonsObj;
          Z && (Z.parent.remove(Z), Jo(Z), delete H.__data.__singleHopPhotonsObj);
        },
        createObj: function(H) {
          var Z = h(H), N = d(H);
          Z && e.linkThreeObject === Z && (Z = Z.clone());
          var K;
          if (!Z || N) {
            var oe = !!m(H);
            if (oe)
              K = new Ce.Mesh();
            else {
              var fe = new Ce.BufferGeometry();
              fe[Ql]("position", new Ce.BufferAttribute(new Float32Array(2 * 3), 3)), K = new Ce.Line(fe);
            }
          }
          var F;
          return Z ? N ? (F = new Ce.Group(), F.__graphDefaultObj = !0, F.add(K), F.add(Z)) : F = Z : (F = K, F.__graphDefaultObj = !0), F.renderOrder = 10, F.__graphObjType = "link", F;
        },
        updateObj: function(H, Z) {
          if (H.__graphDefaultObj) {
            var N = H.children.length ? H.children[0] : H, K = Math.ceil(m(Z) * 10) / 10, oe = !!K;
            if (oe) {
              var fe = K / 2, F = e.linkResolution;
              if (!N.geometry.type.match(/^Cylinder(Buffer)?Geometry$/) || N.geometry.parameters.radiusTop !== fe || N.geometry.parameters.radialSegments !== F) {
                if (!f.hasOwnProperty(K)) {
                  var ge = new Ce.CylinderGeometry(fe, fe, 1, F, 1, !1);
                  ge[Qr](new Ce.Matrix4().makeTranslation(0, 1 / 2, 0)), ge[Qr](new Ce.Matrix4().makeRotationX(Math.PI / 2)), f[K] = ge;
                }
                N.geometry.dispose(), N.geometry = f[K];
              }
            }
            var Se = p(Z);
            if (Se)
              N.material = Se;
            else {
              var ze = v(Z), Ee = new Ce.Color(ir(ze || "#f0f0f0")), Be = e.linkOpacity * wo(ze), P = oe ? "MeshLambertMaterial" : "LineBasicMaterial";
              if (N.material.type !== P || !N.material.color.equals(Ee) || N.material.opacity !== Be) {
                var S = oe ? M : _;
                S.hasOwnProperty(ze) || (S[ze] = new Ce[P]({
                  color: Ee,
                  transparent: Be < 1,
                  opacity: Be,
                  depthWrite: Be >= 1
                  // Prevent transparency issues
                })), N.material.dispose(), N.material = S[ze];
              }
            }
          }
        }
      }), e.linkDirectionalArrowLength || t.hasOwnProperty("linkDirectionalArrowLength")) {
        var T = Xe(e.linkDirectionalArrowLength), E = Xe(e.linkDirectionalArrowColor);
        nr(x.filter(T), e.graphScene, {
          objBindAttr: "__arrowObj",
          objFilter: function(H) {
            return H.__linkThreeObjType === "arrow";
          },
          createObj: function() {
            var H = new Ce.Mesh(void 0, new Ce.MeshLambertMaterial({
              transparent: !0
            }));
            return H.__linkThreeObjType = "arrow", H;
          },
          updateObj: function(H, Z) {
            var N = T(Z), K = e.linkDirectionalArrowResolution;
            if (!H.geometry.type.match(/^Cone(Buffer)?Geometry$/) || H.geometry.parameters.height !== N || H.geometry.parameters.radialSegments !== K) {
              var oe = new Ce.ConeGeometry(N * 0.25, N, K);
              oe.translate(0, N / 2, 0), oe.rotateX(Math.PI / 2), H.geometry.dispose(), H.geometry = oe;
            }
            var fe = E(Z) || v(Z) || "#f0f0f0";
            H.material.color = new Ce.Color(ir(fe)), H.material.opacity = e.linkOpacity * 3 * wo(fe);
          }
        });
      }
      if (e.linkDirectionalParticles || t.hasOwnProperty("linkDirectionalParticles")) {
        var A = Xe(e.linkDirectionalParticles), R = Xe(e.linkDirectionalParticleWidth), w = Xe(e.linkDirectionalParticleColor), b = {}, U = {};
        nr(x.filter(A), e.graphScene, {
          objBindAttr: "__photonsObj",
          objFilter: function(H) {
            return H.__linkThreeObjType === "photons";
          },
          createObj: function() {
            var H = new Ce.Group();
            return H.__linkThreeObjType = "photons", H;
          },
          updateObj: function(H, Z) {
            var N = Math.round(Math.abs(A(Z))), K = !!H.children.length && H.children[0], oe = Math.ceil(R(Z) * 10) / 10 / 2, fe = e.linkDirectionalParticleResolution, F;
            K && K.geometry.parameters.radius === oe && K.geometry.parameters.widthSegments === fe ? F = K.geometry : (U.hasOwnProperty(oe) || (U[oe] = new Ce.SphereGeometry(oe, fe, fe)), F = U[oe], K && K.geometry.dispose());
            var ge = w(Z) || v(Z) || "#f0f0f0", Se = new Ce.Color(ir(ge)), ze = e.linkOpacity * 3, Ee;
            K && K.material.color.equals(Se) && K.material.opacity === ze ? Ee = K.material : (b.hasOwnProperty(ge) || (b[ge] = new Ce.MeshLambertMaterial({
              color: Se,
              transparent: !0,
              opacity: ze
            })), Ee = b[ge], K && K.material.dispose()), nr(qt(new Array(N)).map(function(Be, P) {
              return {
                idx: P
              };
            }), H, {
              idAccessor: function(P) {
                return P.idx;
              },
              createObj: function() {
                return new Ce.Mesh(F, Ee);
              },
              updateObj: function(P) {
                P.geometry = F, P.material = Ee;
              }
            });
          }
        });
      }
    }
    if (e._flushObjects = !1, i(["graphData", "nodeId", "linkSource", "linkTarget", "numDimensions", "forceEngine", "dagMode", "dagNodeFilter", "dagLevelDistance"])) {
      e.engineRunning = !1, e.graphData.links.forEach(function(k) {
        k.source = k[e.linkSource], k.target = k[e.linkTarget];
      });
      var z = e.forceEngine !== "ngraph", I;
      if (z) {
        (I = e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);
        var L = e.d3ForceLayout.force("link");
        L && L.id(function(k) {
          return k[e.nodeId];
        }).links(e.graphData.links);
        var D = e.dagMode && Zb(e.graphData, function(k) {
          return k[e.nodeId];
        }, {
          nodeFilter: e.dagNodeFilter,
          onLoopError: e.onDagError || void 0
        }), B = Math.max.apply(Math, qt(Object.values(D || []))), te = e.dagLevelDistance || e.graphData.nodes.length / (B || 1) * Jb * (["radialin", "radialout"].indexOf(e.dagMode) !== -1 ? 0.7 : 1);
        if (e.dagMode) {
          var W = function(H, Z) {
            return function(N) {
              return H ? (D[N[e.nodeId]] - B / 2) * te * (Z ? -1 : 1) : void 0;
            };
          }, ie = W(["lr", "rl"].indexOf(e.dagMode) !== -1, e.dagMode === "rl"), G = W(["td", "bu"].indexOf(e.dagMode) !== -1, e.dagMode === "td"), Q = W(["zin", "zout"].indexOf(e.dagMode) !== -1, e.dagMode === "zout");
          e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(k) {
            k.fx = ie(k), k.fy = G(k), k.fz = Q(k);
          });
        }
        e.d3ForceLayout.force("dagRadial", ["radialin", "radialout"].indexOf(e.dagMode) !== -1 ? iy(function(k) {
          var H = D[k[e.nodeId]] || -1;
          return (e.dagMode === "radialin" ? B - H : H) * te;
        }).strength(function(k) {
          return e.dagNodeFilter(k) ? 1 : 0;
        }) : null);
      } else {
        var se = Jl.graph();
        e.graphData.nodes.forEach(function(k) {
          se.addNode(k[e.nodeId]);
        }), e.graphData.links.forEach(function(k) {
          se.addLink(k.source, k.target);
        }), I = Jl.forcelayout(se, wh({
          dimensions: e.numDimensions
        }, e.ngraphPhysics)), I.graph = se;
      }
      for (var xe = 0; xe < e.warmupTicks && !(z && e.d3AlphaMin > 0 && e.d3ForceLayout.alpha() < e.d3AlphaMin); xe++)
        I[z ? "tick" : "step"]();
      e.layout = I, this.resetCountdown();
    }
    e.engineRunning = !0, e.onFinishUpdate();
  }
});
function eM(n) {
  var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Object, t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, i = /* @__PURE__ */ function(r) {
    Bb(a, r);
    function a() {
      var o;
      Ub(this, a);
      for (var s = arguments.length, c = new Array(s), l = 0; l < s; l++)
        c[l] = arguments[l];
      return o = Db(this, a, [].concat(c)), o.__kapsuleInstance = n().apply(void 0, [].concat(qt(t ? [Ah(o)] : []), c)), o;
    }
    return Fb(a);
  }(e);
  return Object.keys(n()).forEach(function(r) {
    return i.prototype[r] = function() {
      var a, o = (a = this.__kapsuleInstance)[r].apply(a, arguments);
      return o === this.__kapsuleInstance ? this : o;
    };
  }), i;
}
var tM = window.THREE ? window.THREE : {
  Group: Oi
}, Rh = eM(Qb, tM.Group, !0);
const To = { type: "change" }, Ao = { type: "start" }, Co = { type: "end" };
class nM extends Qt {
  constructor(e, t) {
    super();
    const i = this, r = { NONE: -1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
    this.object = e, this.domElement = t, this.domElement.style.touchAction = "none", this.enabled = !0, this.screen = { left: 0, top: 0, width: 0, height: 0 }, this.rotateSpeed = 1, this.zoomSpeed = 1.2, this.panSpeed = 0.3, this.noRotate = !1, this.noZoom = !1, this.noPan = !1, this.staticMoving = !1, this.dynamicDampingFactor = 0.2, this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.keys = [
      "KeyA",
      "KeyS",
      "KeyD"
      /*D*/
    ], this.mouseButtons = { LEFT: en.ROTATE, MIDDLE: en.DOLLY, RIGHT: en.PAN }, this.target = new O();
    const a = 1e-6, o = new O();
    let s = 1, c = r.NONE, l = r.NONE, u = 0, h = 0, d = 0;
    const p = new O(), g = new le(), v = new le(), m = new O(), f = new le(), M = new le(), _ = new le(), x = new le(), T = [], E = {};
    this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.up0 = this.object.up.clone(), this.zoom0 = this.object.zoom, this.handleResize = function() {
      const N = i.domElement.getBoundingClientRect(), K = i.domElement.ownerDocument.documentElement;
      i.screen.left = N.left + window.pageXOffset - K.clientLeft, i.screen.top = N.top + window.pageYOffset - K.clientTop, i.screen.width = N.width, i.screen.height = N.height;
    };
    const A = function() {
      const N = new le();
      return function(oe, fe) {
        return N.set(
          (oe - i.screen.left) / i.screen.width,
          (fe - i.screen.top) / i.screen.height
        ), N;
      };
    }(), R = function() {
      const N = new le();
      return function(oe, fe) {
        return N.set(
          (oe - i.screen.width * 0.5 - i.screen.left) / (i.screen.width * 0.5),
          (i.screen.height + 2 * (i.screen.top - fe)) / i.screen.width
          // screen.width intentional
        ), N;
      };
    }();
    this.rotateCamera = function() {
      const N = new O(), K = new Jt(), oe = new O(), fe = new O(), F = new O(), ge = new O();
      return function() {
        ge.set(v.x - g.x, v.y - g.y, 0);
        let ze = ge.length();
        ze ? (p.copy(i.object.position).sub(i.target), oe.copy(p).normalize(), fe.copy(i.object.up).normalize(), F.crossVectors(fe, oe).normalize(), fe.setLength(v.y - g.y), F.setLength(v.x - g.x), ge.copy(fe.add(F)), N.crossVectors(ge, p).normalize(), ze *= i.rotateSpeed, K.setFromAxisAngle(N, ze), p.applyQuaternion(K), i.object.up.applyQuaternion(K), m.copy(N), d = ze) : !i.staticMoving && d && (d *= Math.sqrt(1 - i.dynamicDampingFactor), p.copy(i.object.position).sub(i.target), K.setFromAxisAngle(m, d), p.applyQuaternion(K), i.object.up.applyQuaternion(K)), g.copy(v);
      };
    }(), this.zoomCamera = function() {
      let N;
      c === r.TOUCH_ZOOM_PAN ? (N = u / h, u = h, i.object.isPerspectiveCamera ? p.multiplyScalar(N) : i.object.isOrthographicCamera ? (i.object.zoom = zo.clamp(i.object.zoom / N, i.minZoom, i.maxZoom), s !== i.object.zoom && i.object.updateProjectionMatrix()) : console.warn("THREE.TrackballControls: Unsupported camera type")) : (N = 1 + (M.y - f.y) * i.zoomSpeed, N !== 1 && N > 0 && (i.object.isPerspectiveCamera ? p.multiplyScalar(N) : i.object.isOrthographicCamera ? (i.object.zoom = zo.clamp(i.object.zoom / N, i.minZoom, i.maxZoom), s !== i.object.zoom && i.object.updateProjectionMatrix()) : console.warn("THREE.TrackballControls: Unsupported camera type")), i.staticMoving ? f.copy(M) : f.y += (M.y - f.y) * this.dynamicDampingFactor);
    }, this.panCamera = function() {
      const N = new le(), K = new O(), oe = new O();
      return function() {
        if (N.copy(x).sub(_), N.lengthSq()) {
          if (i.object.isOrthographicCamera) {
            const F = (i.object.right - i.object.left) / i.object.zoom / i.domElement.clientWidth, ge = (i.object.top - i.object.bottom) / i.object.zoom / i.domElement.clientWidth;
            N.x *= F, N.y *= ge;
          }
          N.multiplyScalar(p.length() * i.panSpeed), oe.copy(p).cross(i.object.up).setLength(N.x), oe.add(K.copy(i.object.up).setLength(N.y)), i.object.position.add(oe), i.target.add(oe), i.staticMoving ? _.copy(x) : _.add(N.subVectors(x, _).multiplyScalar(i.dynamicDampingFactor));
        }
      };
    }(), this.checkDistances = function() {
      (!i.noZoom || !i.noPan) && (p.lengthSq() > i.maxDistance * i.maxDistance && (i.object.position.addVectors(i.target, p.setLength(i.maxDistance)), f.copy(M)), p.lengthSq() < i.minDistance * i.minDistance && (i.object.position.addVectors(i.target, p.setLength(i.minDistance)), f.copy(M)));
    }, this.update = function() {
      p.subVectors(i.object.position, i.target), i.noRotate || i.rotateCamera(), i.noZoom || i.zoomCamera(), i.noPan || i.panCamera(), i.object.position.addVectors(i.target, p), i.object.isPerspectiveCamera ? (i.checkDistances(), i.object.lookAt(i.target), o.distanceToSquared(i.object.position) > a && (i.dispatchEvent(To), o.copy(i.object.position))) : i.object.isOrthographicCamera ? (i.object.lookAt(i.target), (o.distanceToSquared(i.object.position) > a || s !== i.object.zoom) && (i.dispatchEvent(To), o.copy(i.object.position), s = i.object.zoom)) : console.warn("THREE.TrackballControls: Unsupported camera type");
    }, this.reset = function() {
      c = r.NONE, l = r.NONE, i.target.copy(i.target0), i.object.position.copy(i.position0), i.object.up.copy(i.up0), i.object.zoom = i.zoom0, i.object.updateProjectionMatrix(), p.subVectors(i.object.position, i.target), i.object.lookAt(i.target), i.dispatchEvent(To), o.copy(i.object.position), s = i.object.zoom;
    };
    function w(N) {
      i.enabled !== !1 && (T.length === 0 && (i.domElement.setPointerCapture(N.pointerId), i.domElement.addEventListener("pointermove", b), i.domElement.addEventListener("pointerup", U)), xe(N), N.pointerType === "touch" ? ie(N) : D(N));
    }
    function b(N) {
      i.enabled !== !1 && (N.pointerType === "touch" ? G(N) : B(N));
    }
    function U(N) {
      i.enabled !== !1 && (N.pointerType === "touch" ? Q(N) : te(), k(N), T.length === 0 && (i.domElement.releasePointerCapture(N.pointerId), i.domElement.removeEventListener("pointermove", b), i.domElement.removeEventListener("pointerup", U)));
    }
    function z(N) {
      k(N);
    }
    function I(N) {
      i.enabled !== !1 && (window.removeEventListener("keydown", I), l === r.NONE && (N.code === i.keys[r.ROTATE] && !i.noRotate ? l = r.ROTATE : N.code === i.keys[r.ZOOM] && !i.noZoom ? l = r.ZOOM : N.code === i.keys[r.PAN] && !i.noPan && (l = r.PAN)));
    }
    function L() {
      i.enabled !== !1 && (l = r.NONE, window.addEventListener("keydown", I));
    }
    function D(N) {
      if (c === r.NONE)
        switch (N.button) {
          case i.mouseButtons.LEFT:
            c = r.ROTATE;
            break;
          case i.mouseButtons.MIDDLE:
            c = r.ZOOM;
            break;
          case i.mouseButtons.RIGHT:
            c = r.PAN;
            break;
        }
      const K = l !== r.NONE ? l : c;
      K === r.ROTATE && !i.noRotate ? (v.copy(R(N.pageX, N.pageY)), g.copy(v)) : K === r.ZOOM && !i.noZoom ? (f.copy(A(N.pageX, N.pageY)), M.copy(f)) : K === r.PAN && !i.noPan && (_.copy(A(N.pageX, N.pageY)), x.copy(_)), i.dispatchEvent(Ao);
    }
    function B(N) {
      const K = l !== r.NONE ? l : c;
      K === r.ROTATE && !i.noRotate ? (g.copy(v), v.copy(R(N.pageX, N.pageY))) : K === r.ZOOM && !i.noZoom ? M.copy(A(N.pageX, N.pageY)) : K === r.PAN && !i.noPan && x.copy(A(N.pageX, N.pageY));
    }
    function te() {
      c = r.NONE, i.dispatchEvent(Co);
    }
    function W(N) {
      if (i.enabled !== !1 && i.noZoom !== !0) {
        switch (N.preventDefault(), N.deltaMode) {
          case 2:
            f.y -= N.deltaY * 0.025;
            break;
          case 1:
            f.y -= N.deltaY * 0.01;
            break;
          default:
            f.y -= N.deltaY * 25e-5;
            break;
        }
        i.dispatchEvent(Ao), i.dispatchEvent(Co);
      }
    }
    function ie(N) {
      switch (H(N), T.length) {
        case 1:
          c = r.TOUCH_ROTATE, v.copy(R(T[0].pageX, T[0].pageY)), g.copy(v);
          break;
        default:
          c = r.TOUCH_ZOOM_PAN;
          const K = T[0].pageX - T[1].pageX, oe = T[0].pageY - T[1].pageY;
          h = u = Math.sqrt(K * K + oe * oe);
          const fe = (T[0].pageX + T[1].pageX) / 2, F = (T[0].pageY + T[1].pageY) / 2;
          _.copy(A(fe, F)), x.copy(_);
          break;
      }
      i.dispatchEvent(Ao);
    }
    function G(N) {
      switch (H(N), T.length) {
        case 1:
          g.copy(v), v.copy(R(N.pageX, N.pageY));
          break;
        default:
          const K = Z(N), oe = N.pageX - K.x, fe = N.pageY - K.y;
          h = Math.sqrt(oe * oe + fe * fe);
          const F = (N.pageX + K.x) / 2, ge = (N.pageY + K.y) / 2;
          x.copy(A(F, ge));
          break;
      }
    }
    function Q(N) {
      switch (T.length) {
        case 0:
          c = r.NONE;
          break;
        case 1:
          c = r.TOUCH_ROTATE, v.copy(R(N.pageX, N.pageY)), g.copy(v);
          break;
        case 2:
          c = r.TOUCH_ZOOM_PAN;
          for (let K = 0; K < T.length; K++)
            if (T[K].pointerId !== N.pointerId) {
              const oe = E[T[K].pointerId];
              v.copy(R(oe.x, oe.y)), g.copy(v);
              break;
            }
          break;
      }
      i.dispatchEvent(Co);
    }
    function se(N) {
      i.enabled !== !1 && N.preventDefault();
    }
    function xe(N) {
      T.push(N);
    }
    function k(N) {
      delete E[N.pointerId];
      for (let K = 0; K < T.length; K++)
        if (T[K].pointerId == N.pointerId) {
          T.splice(K, 1);
          return;
        }
    }
    function H(N) {
      let K = E[N.pointerId];
      K === void 0 && (K = new le(), E[N.pointerId] = K), K.set(N.pageX, N.pageY);
    }
    function Z(N) {
      const K = N.pointerId === T[0].pointerId ? T[1] : T[0];
      return E[K.pointerId];
    }
    this.dispose = function() {
      i.domElement.removeEventListener("contextmenu", se), i.domElement.removeEventListener("pointerdown", w), i.domElement.removeEventListener("pointercancel", z), i.domElement.removeEventListener("wheel", W), i.domElement.removeEventListener("pointermove", b), i.domElement.removeEventListener("pointerup", U), window.removeEventListener("keydown", I), window.removeEventListener("keyup", L);
    }, this.domElement.addEventListener("contextmenu", se), this.domElement.addEventListener("pointerdown", w), this.domElement.addEventListener("pointercancel", z), this.domElement.addEventListener("wheel", W, { passive: !1 }), window.addEventListener("keydown", I), window.addEventListener("keyup", L), this.handleResize(), this.update();
  }
}
const eu = { type: "change" }, Ro = { type: "start" }, tu = { type: "end" }, ea = new Ma(), nu = new yn(), iM = Math.cos(70 * zo.DEG2RAD);
class rM extends Qt {
  constructor(e, t) {
    super(), this.object = e, this.domElement = t, this.domElement.style.touchAction = "none", this.enabled = !0, this.target = new O(), this.cursor = new O(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: en.ROTATE, MIDDLE: en.DOLLY, RIGHT: en.PAN }, this.touches = { ONE: fi.ROTATE, TWO: fi.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this.getPolarAngle = function() {
      return s.phi;
    }, this.getAzimuthalAngle = function() {
      return s.theta;
    }, this.getDistance = function() {
      return this.object.position.distanceTo(this.target);
    }, this.listenToKeyEvents = function(y) {
      y.addEventListener("keydown", pe), this._domElementKeyEvents = y;
    }, this.stopListenToKeyEvents = function() {
      this._domElementKeyEvents.removeEventListener("keydown", pe), this._domElementKeyEvents = null;
    }, this.saveState = function() {
      i.target0.copy(i.target), i.position0.copy(i.object.position), i.zoom0 = i.object.zoom;
    }, this.reset = function() {
      i.target.copy(i.target0), i.object.position.copy(i.position0), i.object.zoom = i.zoom0, i.object.updateProjectionMatrix(), i.dispatchEvent(eu), i.update(), a = r.NONE;
    }, this.update = function() {
      const y = new O(), j = new Jt().setFromUnitVectors(e.up, new O(0, 1, 0)), J = j.clone().invert(), ce = new O(), me = new Jt(), Ge = new O(), ke = 2 * Math.PI;
      return function(ft = null) {
        const Ye = i.object.position;
        y.copy(Ye).sub(i.target), y.applyQuaternion(j), s.setFromVector3(y), i.autoRotate && a === r.NONE && z(b(ft)), i.enableDamping ? (s.theta += c.theta * i.dampingFactor, s.phi += c.phi * i.dampingFactor) : (s.theta += c.theta, s.phi += c.phi);
        let ot = i.minAzimuthAngle, st = i.maxAzimuthAngle;
        isFinite(ot) && isFinite(st) && (ot < -Math.PI ? ot += ke : ot > Math.PI && (ot -= ke), st < -Math.PI ? st += ke : st > Math.PI && (st -= ke), ot <= st ? s.theta = Math.max(ot, Math.min(st, s.theta)) : s.theta = s.theta > (ot + st) / 2 ? Math.max(ot, s.theta) : Math.min(st, s.theta)), s.phi = Math.max(i.minPolarAngle, Math.min(i.maxPolarAngle, s.phi)), s.makeSafe(), i.enableDamping === !0 ? i.target.addScaledVector(u, i.dampingFactor) : i.target.add(u), i.target.sub(i.cursor), i.target.clampLength(i.minTargetRadius, i.maxTargetRadius), i.target.add(i.cursor);
        let Pt = !1;
        if (i.zoomToCursor && E || i.object.isOrthographicCamera)
          s.radius = G(s.radius);
        else {
          const Ft = s.radius;
          s.radius = G(s.radius * l), Pt = Ft != s.radius;
        }
        if (y.setFromSpherical(s), y.applyQuaternion(J), Ye.copy(i.target).add(y), i.object.lookAt(i.target), i.enableDamping === !0 ? (c.theta *= 1 - i.dampingFactor, c.phi *= 1 - i.dampingFactor, u.multiplyScalar(1 - i.dampingFactor)) : (c.set(0, 0, 0), u.set(0, 0, 0)), i.zoomToCursor && E) {
          let Ft = null;
          if (i.object.isPerspectiveCamera) {
            const An = y.length();
            Ft = G(An * l);
            const hi = An - Ft;
            i.object.position.addScaledVector(x, hi), i.object.updateMatrixWorld(), Pt = !!hi;
          } else if (i.object.isOrthographicCamera) {
            const An = new O(T.x, T.y, 0);
            An.unproject(i.object);
            const hi = i.object.zoom;
            i.object.zoom = Math.max(i.minZoom, Math.min(i.maxZoom, i.object.zoom / l)), i.object.updateProjectionMatrix(), Pt = hi !== i.object.zoom;
            const $n = new O(T.x, T.y, 0);
            $n.unproject(i.object), i.object.position.sub($n).add(An), i.object.updateMatrixWorld(), Ft = y.length();
          } else
            console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), i.zoomToCursor = !1;
          Ft !== null && (this.screenSpacePanning ? i.target.set(0, 0, -1).transformDirection(i.object.matrix).multiplyScalar(Ft).add(i.object.position) : (ea.origin.copy(i.object.position), ea.direction.set(0, 0, -1).transformDirection(i.object.matrix), Math.abs(i.object.up.dot(ea.direction)) < iM ? e.lookAt(i.target) : (nu.setFromNormalAndCoplanarPoint(i.object.up, i.target), ea.intersectPlane(nu, i.target))));
        } else if (i.object.isOrthographicCamera) {
          const Ft = i.object.zoom;
          i.object.zoom = Math.max(i.minZoom, Math.min(i.maxZoom, i.object.zoom / l)), Ft !== i.object.zoom && (i.object.updateProjectionMatrix(), Pt = !0);
        }
        return l = 1, E = !1, Pt || ce.distanceToSquared(i.object.position) > o || 8 * (1 - me.dot(i.object.quaternion)) > o || Ge.distanceToSquared(i.target) > o ? (i.dispatchEvent(eu), ce.copy(i.object.position), me.copy(i.object.quaternion), Ge.copy(i.target), !0) : !1;
      };
    }(), this.dispose = function() {
      i.domElement.removeEventListener("contextmenu", _e), i.domElement.removeEventListener("pointerdown", Y), i.domElement.removeEventListener("pointercancel", ne), i.domElement.removeEventListener("wheel", ae), i.domElement.removeEventListener("pointermove", ee), i.domElement.removeEventListener("pointerup", ne), i.domElement.getRootNode().removeEventListener("keydown", Ae, { capture: !0 }), i._domElementKeyEvents !== null && (i._domElementKeyEvents.removeEventListener("keydown", pe), i._domElementKeyEvents = null);
    };
    const i = this, r = {
      NONE: -1,
      ROTATE: 0,
      DOLLY: 1,
      PAN: 2,
      TOUCH_ROTATE: 3,
      TOUCH_PAN: 4,
      TOUCH_DOLLY_PAN: 5,
      TOUCH_DOLLY_ROTATE: 6
    };
    let a = r.NONE;
    const o = 1e-6, s = new Go(), c = new Go();
    let l = 1;
    const u = new O(), h = new le(), d = new le(), p = new le(), g = new le(), v = new le(), m = new le(), f = new le(), M = new le(), _ = new le(), x = new O(), T = new le();
    let E = !1;
    const A = [], R = {};
    let w = !1;
    function b(y) {
      return y !== null ? 2 * Math.PI / 60 * i.autoRotateSpeed * y : 2 * Math.PI / 60 / 60 * i.autoRotateSpeed;
    }
    function U(y) {
      const j = Math.abs(y * 0.01);
      return Math.pow(0.95, i.zoomSpeed * j);
    }
    function z(y) {
      c.theta -= y;
    }
    function I(y) {
      c.phi -= y;
    }
    const L = function() {
      const y = new O();
      return function(J, ce) {
        y.setFromMatrixColumn(ce, 0), y.multiplyScalar(-J), u.add(y);
      };
    }(), D = function() {
      const y = new O();
      return function(J, ce) {
        i.screenSpacePanning === !0 ? y.setFromMatrixColumn(ce, 1) : (y.setFromMatrixColumn(ce, 0), y.crossVectors(i.object.up, y)), y.multiplyScalar(J), u.add(y);
      };
    }(), B = function() {
      const y = new O();
      return function(J, ce) {
        const me = i.domElement;
        if (i.object.isPerspectiveCamera) {
          const Ge = i.object.position;
          y.copy(Ge).sub(i.target);
          let ke = y.length();
          ke *= Math.tan(i.object.fov / 2 * Math.PI / 180), L(2 * J * ke / me.clientHeight, i.object.matrix), D(2 * ce * ke / me.clientHeight, i.object.matrix);
        } else
          i.object.isOrthographicCamera ? (L(J * (i.object.right - i.object.left) / i.object.zoom / me.clientWidth, i.object.matrix), D(ce * (i.object.top - i.object.bottom) / i.object.zoom / me.clientHeight, i.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), i.enablePan = !1);
      };
    }();
    function te(y) {
      i.object.isPerspectiveCamera || i.object.isOrthographicCamera ? l /= y : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), i.enableZoom = !1);
    }
    function W(y) {
      i.object.isPerspectiveCamera || i.object.isOrthographicCamera ? l *= y : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), i.enableZoom = !1);
    }
    function ie(y, j) {
      if (!i.zoomToCursor)
        return;
      E = !0;
      const J = i.domElement.getBoundingClientRect(), ce = y - J.left, me = j - J.top, Ge = J.width, ke = J.height;
      T.x = ce / Ge * 2 - 1, T.y = -(me / ke) * 2 + 1, x.set(T.x, T.y, 1).unproject(i.object).sub(i.object.position).normalize();
    }
    function G(y) {
      return Math.max(i.minDistance, Math.min(i.maxDistance, y));
    }
    function Q(y) {
      h.set(y.clientX, y.clientY);
    }
    function se(y) {
      ie(y.clientX, y.clientX), f.set(y.clientX, y.clientY);
    }
    function xe(y) {
      g.set(y.clientX, y.clientY);
    }
    function k(y) {
      d.set(y.clientX, y.clientY), p.subVectors(d, h).multiplyScalar(i.rotateSpeed);
      const j = i.domElement;
      z(2 * Math.PI * p.x / j.clientHeight), I(2 * Math.PI * p.y / j.clientHeight), h.copy(d), i.update();
    }
    function H(y) {
      M.set(y.clientX, y.clientY), _.subVectors(M, f), _.y > 0 ? te(U(_.y)) : _.y < 0 && W(U(_.y)), f.copy(M), i.update();
    }
    function Z(y) {
      v.set(y.clientX, y.clientY), m.subVectors(v, g).multiplyScalar(i.panSpeed), B(m.x, m.y), g.copy(v), i.update();
    }
    function N(y) {
      ie(y.clientX, y.clientY), y.deltaY < 0 ? W(U(y.deltaY)) : y.deltaY > 0 && te(U(y.deltaY)), i.update();
    }
    function K(y) {
      let j = !1;
      switch (y.code) {
        case i.keys.UP:
          y.ctrlKey || y.metaKey || y.shiftKey ? I(2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : B(0, i.keyPanSpeed), j = !0;
          break;
        case i.keys.BOTTOM:
          y.ctrlKey || y.metaKey || y.shiftKey ? I(-2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : B(0, -i.keyPanSpeed), j = !0;
          break;
        case i.keys.LEFT:
          y.ctrlKey || y.metaKey || y.shiftKey ? z(2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : B(i.keyPanSpeed, 0), j = !0;
          break;
        case i.keys.RIGHT:
          y.ctrlKey || y.metaKey || y.shiftKey ? z(-2 * Math.PI * i.rotateSpeed / i.domElement.clientHeight) : B(-i.keyPanSpeed, 0), j = !0;
          break;
      }
      j && (y.preventDefault(), i.update());
    }
    function oe(y) {
      if (A.length === 1)
        h.set(y.pageX, y.pageY);
      else {
        const j = qe(y), J = 0.5 * (y.pageX + j.x), ce = 0.5 * (y.pageY + j.y);
        h.set(J, ce);
      }
    }
    function fe(y) {
      if (A.length === 1)
        g.set(y.pageX, y.pageY);
      else {
        const j = qe(y), J = 0.5 * (y.pageX + j.x), ce = 0.5 * (y.pageY + j.y);
        g.set(J, ce);
      }
    }
    function F(y) {
      const j = qe(y), J = y.pageX - j.x, ce = y.pageY - j.y, me = Math.sqrt(J * J + ce * ce);
      f.set(0, me);
    }
    function ge(y) {
      i.enableZoom && F(y), i.enablePan && fe(y);
    }
    function Se(y) {
      i.enableZoom && F(y), i.enableRotate && oe(y);
    }
    function ze(y) {
      if (A.length == 1)
        d.set(y.pageX, y.pageY);
      else {
        const J = qe(y), ce = 0.5 * (y.pageX + J.x), me = 0.5 * (y.pageY + J.y);
        d.set(ce, me);
      }
      p.subVectors(d, h).multiplyScalar(i.rotateSpeed);
      const j = i.domElement;
      z(2 * Math.PI * p.x / j.clientHeight), I(2 * Math.PI * p.y / j.clientHeight), h.copy(d);
    }
    function Ee(y) {
      if (A.length === 1)
        v.set(y.pageX, y.pageY);
      else {
        const j = qe(y), J = 0.5 * (y.pageX + j.x), ce = 0.5 * (y.pageY + j.y);
        v.set(J, ce);
      }
      m.subVectors(v, g).multiplyScalar(i.panSpeed), B(m.x, m.y), g.copy(v);
    }
    function Be(y) {
      const j = qe(y), J = y.pageX - j.x, ce = y.pageY - j.y, me = Math.sqrt(J * J + ce * ce);
      M.set(0, me), _.set(0, Math.pow(M.y / f.y, i.zoomSpeed)), te(_.y), f.copy(M);
      const Ge = (y.pageX + j.x) * 0.5, ke = (y.pageY + j.y) * 0.5;
      ie(Ge, ke);
    }
    function P(y) {
      i.enableZoom && Be(y), i.enablePan && Ee(y);
    }
    function S(y) {
      i.enableZoom && Be(y), i.enableRotate && ze(y);
    }
    function Y(y) {
      i.enabled !== !1 && (A.length === 0 && (i.domElement.setPointerCapture(y.pointerId), i.domElement.addEventListener("pointermove", ee), i.domElement.addEventListener("pointerup", ne)), !$e(y) && (He(y), y.pointerType === "touch" ? Pe(y) : re(y)));
    }
    function ee(y) {
      i.enabled !== !1 && (y.pointerType === "touch" ? ve(y) : Te(y));
    }
    function ne(y) {
      switch (Ve(y), A.length) {
        case 0:
          i.domElement.releasePointerCapture(y.pointerId), i.domElement.removeEventListener("pointermove", ee), i.domElement.removeEventListener("pointerup", ne), i.dispatchEvent(tu), a = r.NONE;
          break;
        case 1:
          const j = A[0], J = R[j];
          Pe({ pointerId: j, pageX: J.x, pageY: J.y });
          break;
      }
    }
    function re(y) {
      let j;
      switch (y.button) {
        case 0:
          j = i.mouseButtons.LEFT;
          break;
        case 1:
          j = i.mouseButtons.MIDDLE;
          break;
        case 2:
          j = i.mouseButtons.RIGHT;
          break;
        default:
          j = -1;
      }
      switch (j) {
        case en.DOLLY:
          if (i.enableZoom === !1)
            return;
          se(y), a = r.DOLLY;
          break;
        case en.ROTATE:
          if (y.ctrlKey || y.metaKey || y.shiftKey) {
            if (i.enablePan === !1)
              return;
            xe(y), a = r.PAN;
          } else {
            if (i.enableRotate === !1)
              return;
            Q(y), a = r.ROTATE;
          }
          break;
        case en.PAN:
          if (y.ctrlKey || y.metaKey || y.shiftKey) {
            if (i.enableRotate === !1)
              return;
            Q(y), a = r.ROTATE;
          } else {
            if (i.enablePan === !1)
              return;
            xe(y), a = r.PAN;
          }
          break;
        default:
          a = r.NONE;
      }
      a !== r.NONE && i.dispatchEvent(Ro);
    }
    function Te(y) {
      switch (a) {
        case r.ROTATE:
          if (i.enableRotate === !1)
            return;
          k(y);
          break;
        case r.DOLLY:
          if (i.enableZoom === !1)
            return;
          H(y);
          break;
        case r.PAN:
          if (i.enablePan === !1)
            return;
          Z(y);
          break;
      }
    }
    function ae(y) {
      i.enabled === !1 || i.enableZoom === !1 || a !== r.NONE || (y.preventDefault(), i.dispatchEvent(Ro), N(we(y)), i.dispatchEvent(tu));
    }
    function we(y) {
      const j = y.deltaMode, J = {
        clientX: y.clientX,
        clientY: y.clientY,
        deltaY: y.deltaY
      };
      switch (j) {
        case 1:
          J.deltaY *= 16;
          break;
        case 2:
          J.deltaY *= 100;
          break;
      }
      return y.ctrlKey && !w && (J.deltaY *= 10), J;
    }
    function Ae(y) {
      y.key === "Control" && (w = !0, i.domElement.getRootNode().addEventListener("keyup", ue, { passive: !0, capture: !0 }));
    }
    function ue(y) {
      y.key === "Control" && (w = !1, i.domElement.getRootNode().removeEventListener("keyup", ue, { passive: !0, capture: !0 }));
    }
    function pe(y) {
      i.enabled === !1 || i.enablePan === !1 || K(y);
    }
    function Pe(y) {
      switch (je(y), A.length) {
        case 1:
          switch (i.touches.ONE) {
            case fi.ROTATE:
              if (i.enableRotate === !1)
                return;
              oe(y), a = r.TOUCH_ROTATE;
              break;
            case fi.PAN:
              if (i.enablePan === !1)
                return;
              fe(y), a = r.TOUCH_PAN;
              break;
            default:
              a = r.NONE;
          }
          break;
        case 2:
          switch (i.touches.TWO) {
            case fi.DOLLY_PAN:
              if (i.enableZoom === !1 && i.enablePan === !1)
                return;
              ge(y), a = r.TOUCH_DOLLY_PAN;
              break;
            case fi.DOLLY_ROTATE:
              if (i.enableZoom === !1 && i.enableRotate === !1)
                return;
              Se(y), a = r.TOUCH_DOLLY_ROTATE;
              break;
            default:
              a = r.NONE;
          }
          break;
        default:
          a = r.NONE;
      }
      a !== r.NONE && i.dispatchEvent(Ro);
    }
    function ve(y) {
      switch (je(y), a) {
        case r.TOUCH_ROTATE:
          if (i.enableRotate === !1)
            return;
          ze(y), i.update();
          break;
        case r.TOUCH_PAN:
          if (i.enablePan === !1)
            return;
          Ee(y), i.update();
          break;
        case r.TOUCH_DOLLY_PAN:
          if (i.enableZoom === !1 && i.enablePan === !1)
            return;
          P(y), i.update();
          break;
        case r.TOUCH_DOLLY_ROTATE:
          if (i.enableZoom === !1 && i.enableRotate === !1)
            return;
          S(y), i.update();
          break;
        default:
          a = r.NONE;
      }
    }
    function _e(y) {
      i.enabled !== !1 && y.preventDefault();
    }
    function He(y) {
      A.push(y.pointerId);
    }
    function Ve(y) {
      delete R[y.pointerId];
      for (let j = 0; j < A.length; j++)
        if (A[j] == y.pointerId) {
          A.splice(j, 1);
          return;
        }
    }
    function $e(y) {
      for (let j = 0; j < A.length; j++)
        if (A[j] == y.pointerId)
          return !0;
      return !1;
    }
    function je(y) {
      let j = R[y.pointerId];
      j === void 0 && (j = new le(), R[y.pointerId] = j), j.set(y.pageX, y.pageY);
    }
    function qe(y) {
      const j = y.pointerId === A[0] ? A[1] : A[0];
      return R[j];
    }
    i.domElement.addEventListener("contextmenu", _e), i.domElement.addEventListener("pointerdown", Y), i.domElement.addEventListener("pointercancel", ne), i.domElement.addEventListener("wheel", ae, { passive: !1 }), i.domElement.getRootNode().addEventListener("keydown", Ae, { passive: !0, capture: !0 }), this.update();
  }
}
const aM = { type: "change" };
class oM extends Qt {
  constructor(e, t) {
    super(), this.object = e, this.domElement = t, this.enabled = !0, this.movementSpeed = 1, this.rollSpeed = 5e-3, this.dragToLook = !1, this.autoForward = !1;
    const i = this, r = 1e-6, a = new Jt(), o = new O();
    this.tmpQuaternion = new Jt(), this.status = 0, this.moveState = { up: 0, down: 0, left: 0, right: 0, forward: 0, back: 0, pitchUp: 0, pitchDown: 0, yawLeft: 0, yawRight: 0, rollLeft: 0, rollRight: 0 }, this.moveVector = new O(0, 0, 0), this.rotationVector = new O(0, 0, 0), this.keydown = function(g) {
      if (!(g.altKey || this.enabled === !1)) {
        switch (g.code) {
          case "ShiftLeft":
          case "ShiftRight":
            this.movementSpeedMultiplier = 0.1;
            break;
          case "KeyW":
            this.moveState.forward = 1;
            break;
          case "KeyS":
            this.moveState.back = 1;
            break;
          case "KeyA":
            this.moveState.left = 1;
            break;
          case "KeyD":
            this.moveState.right = 1;
            break;
          case "KeyR":
            this.moveState.up = 1;
            break;
          case "KeyF":
            this.moveState.down = 1;
            break;
          case "ArrowUp":
            this.moveState.pitchUp = 1;
            break;
          case "ArrowDown":
            this.moveState.pitchDown = 1;
            break;
          case "ArrowLeft":
            this.moveState.yawLeft = 1;
            break;
          case "ArrowRight":
            this.moveState.yawRight = 1;
            break;
          case "KeyQ":
            this.moveState.rollLeft = 1;
            break;
          case "KeyE":
            this.moveState.rollRight = 1;
            break;
        }
        this.updateMovementVector(), this.updateRotationVector();
      }
    }, this.keyup = function(g) {
      if (this.enabled !== !1) {
        switch (g.code) {
          case "ShiftLeft":
          case "ShiftRight":
            this.movementSpeedMultiplier = 1;
            break;
          case "KeyW":
            this.moveState.forward = 0;
            break;
          case "KeyS":
            this.moveState.back = 0;
            break;
          case "KeyA":
            this.moveState.left = 0;
            break;
          case "KeyD":
            this.moveState.right = 0;
            break;
          case "KeyR":
            this.moveState.up = 0;
            break;
          case "KeyF":
            this.moveState.down = 0;
            break;
          case "ArrowUp":
            this.moveState.pitchUp = 0;
            break;
          case "ArrowDown":
            this.moveState.pitchDown = 0;
            break;
          case "ArrowLeft":
            this.moveState.yawLeft = 0;
            break;
          case "ArrowRight":
            this.moveState.yawRight = 0;
            break;
          case "KeyQ":
            this.moveState.rollLeft = 0;
            break;
          case "KeyE":
            this.moveState.rollRight = 0;
            break;
        }
        this.updateMovementVector(), this.updateRotationVector();
      }
    }, this.pointerdown = function(g) {
      if (this.enabled !== !1)
        if (this.dragToLook)
          this.status++;
        else {
          switch (g.button) {
            case 0:
              this.moveState.forward = 1;
              break;
            case 2:
              this.moveState.back = 1;
              break;
          }
          this.updateMovementVector();
        }
    }, this.pointermove = function(g) {
      if (this.enabled !== !1 && (!this.dragToLook || this.status > 0)) {
        const v = this.getContainerDimensions(), m = v.size[0] / 2, f = v.size[1] / 2;
        this.moveState.yawLeft = -(g.pageX - v.offset[0] - m) / m, this.moveState.pitchDown = (g.pageY - v.offset[1] - f) / f, this.updateRotationVector();
      }
    }, this.pointerup = function(g) {
      if (this.enabled !== !1) {
        if (this.dragToLook)
          this.status--, this.moveState.yawLeft = this.moveState.pitchDown = 0;
        else {
          switch (g.button) {
            case 0:
              this.moveState.forward = 0;
              break;
            case 2:
              this.moveState.back = 0;
              break;
          }
          this.updateMovementVector();
        }
        this.updateRotationVector();
      }
    }, this.pointercancel = function() {
      this.enabled !== !1 && (this.dragToLook ? (this.status = 0, this.moveState.yawLeft = this.moveState.pitchDown = 0) : (this.moveState.forward = 0, this.moveState.back = 0, this.updateMovementVector()), this.updateRotationVector());
    }, this.contextMenu = function(g) {
      this.enabled !== !1 && g.preventDefault();
    }, this.update = function(g) {
      if (this.enabled === !1)
        return;
      const v = g * i.movementSpeed, m = g * i.rollSpeed;
      i.object.translateX(i.moveVector.x * v), i.object.translateY(i.moveVector.y * v), i.object.translateZ(i.moveVector.z * v), i.tmpQuaternion.set(i.rotationVector.x * m, i.rotationVector.y * m, i.rotationVector.z * m, 1).normalize(), i.object.quaternion.multiply(i.tmpQuaternion), (o.distanceToSquared(i.object.position) > r || 8 * (1 - a.dot(i.object.quaternion)) > r) && (i.dispatchEvent(aM), a.copy(i.object.quaternion), o.copy(i.object.position));
    }, this.updateMovementVector = function() {
      const g = this.moveState.forward || this.autoForward && !this.moveState.back ? 1 : 0;
      this.moveVector.x = -this.moveState.left + this.moveState.right, this.moveVector.y = -this.moveState.down + this.moveState.up, this.moveVector.z = -g + this.moveState.back;
    }, this.updateRotationVector = function() {
      this.rotationVector.x = -this.moveState.pitchDown + this.moveState.pitchUp, this.rotationVector.y = -this.moveState.yawRight + this.moveState.yawLeft, this.rotationVector.z = -this.moveState.rollRight + this.moveState.rollLeft;
    }, this.getContainerDimensions = function() {
      return this.domElement != document ? {
        size: [this.domElement.offsetWidth, this.domElement.offsetHeight],
        offset: [this.domElement.offsetLeft, this.domElement.offsetTop]
      } : {
        size: [window.innerWidth, window.innerHeight],
        offset: [0, 0]
      };
    }, this.dispose = function() {
      this.domElement.removeEventListener("contextmenu", s), this.domElement.removeEventListener("pointerdown", l), this.domElement.removeEventListener("pointermove", c), this.domElement.removeEventListener("pointerup", u), this.domElement.removeEventListener("pointercancel", h), window.removeEventListener("keydown", d), window.removeEventListener("keyup", p);
    };
    const s = this.contextMenu.bind(this), c = this.pointermove.bind(this), l = this.pointerdown.bind(this), u = this.pointerup.bind(this), h = this.pointercancel.bind(this), d = this.keydown.bind(this), p = this.keyup.bind(this);
    this.domElement.addEventListener("contextmenu", s), this.domElement.addEventListener("pointerdown", l), this.domElement.addEventListener("pointermove", c), this.domElement.addEventListener("pointerup", u), this.domElement.addEventListener("pointercancel", h), window.addEventListener("keydown", d), window.addEventListener("keyup", p), this.updateMovementVector(), this.updateRotationVector();
  }
}
const sM = {
  name: "CopyShader",
  uniforms: {
    tDiffuse: { value: null },
    opacity: { value: 1 }
  },
  vertexShader: (
    /* glsl */
    `

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`
  ),
  fragmentShader: (
    /* glsl */
    `

		uniform float opacity;

		uniform sampler2D tDiffuse;

		varying vec2 vUv;

		void main() {

			vec4 texel = texture2D( tDiffuse, vUv );
			gl_FragColor = opacity * texel;


		}`
  )
};
class Ra {
  constructor() {
    this.isPass = !0, this.enabled = !0, this.needsSwap = !0, this.clear = !1, this.renderToScreen = !1;
  }
  setSize() {
  }
  render() {
    console.error("THREE.Pass: .render() must be implemented in derived pass.");
  }
  dispose() {
  }
}
const cM = new fs(-1, 1, 1, -1, 0, 1);
class lM extends Nt {
  constructor() {
    super(), this.setAttribute("position", new lt([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3)), this.setAttribute("uv", new lt([0, 2, 0, 0, 2, 0], 2));
  }
}
const uM = new lM();
class hM {
  constructor(e) {
    this._mesh = new Vt(uM, e);
  }
  dispose() {
    this._mesh.geometry.dispose();
  }
  render(e) {
    e.render(this._mesh, cM);
  }
  get material() {
    return this._mesh.material;
  }
  set material(e) {
    this._mesh.material = e;
  }
}
class fM extends Ra {
  constructor(e, t) {
    super(), this.textureID = t !== void 0 ? t : "tDiffuse", e instanceof sn ? (this.uniforms = e.uniforms, this.material = e) : e && (this.uniforms = Au.clone(e.uniforms), this.material = new sn({
      name: e.name !== void 0 ? e.name : "unspecified",
      defines: Object.assign({}, e.defines),
      uniforms: this.uniforms,
      vertexShader: e.vertexShader,
      fragmentShader: e.fragmentShader
    })), this.fsQuad = new hM(this.material);
  }
  render(e, t, i) {
    this.uniforms[this.textureID] && (this.uniforms[this.textureID].value = i.texture), this.fsQuad.material = this.material, this.renderToScreen ? (e.setRenderTarget(null), this.fsQuad.render(e)) : (e.setRenderTarget(t), this.clear && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), this.fsQuad.render(e));
  }
  dispose() {
    this.material.dispose(), this.fsQuad.dispose();
  }
}
class iu extends Ra {
  constructor(e, t) {
    super(), this.scene = e, this.camera = t, this.clear = !0, this.needsSwap = !1, this.inverse = !1;
  }
  render(e, t, i) {
    const r = e.getContext(), a = e.state;
    a.buffers.color.setMask(!1), a.buffers.depth.setMask(!1), a.buffers.color.setLocked(!0), a.buffers.depth.setLocked(!0);
    let o, s;
    this.inverse ? (o = 0, s = 1) : (o = 1, s = 0), a.buffers.stencil.setTest(!0), a.buffers.stencil.setOp(r.REPLACE, r.REPLACE, r.REPLACE), a.buffers.stencil.setFunc(r.ALWAYS, o, 4294967295), a.buffers.stencil.setClear(s), a.buffers.stencil.setLocked(!0), e.setRenderTarget(i), this.clear && e.clear(), e.render(this.scene, this.camera), e.setRenderTarget(t), this.clear && e.clear(), e.render(this.scene, this.camera), a.buffers.color.setLocked(!1), a.buffers.depth.setLocked(!1), a.buffers.color.setMask(!0), a.buffers.depth.setMask(!0), a.buffers.stencil.setLocked(!1), a.buffers.stencil.setFunc(r.EQUAL, 1, 4294967295), a.buffers.stencil.setOp(r.KEEP, r.KEEP, r.KEEP), a.buffers.stencil.setLocked(!0);
  }
}
class dM extends Ra {
  constructor() {
    super(), this.needsSwap = !1;
  }
  render(e) {
    e.state.buffers.stencil.setLocked(!1), e.state.buffers.stencil.setTest(!1);
  }
}
class pM {
  constructor(e, t) {
    if (this.renderer = e, this._pixelRatio = e.getPixelRatio(), t === void 0) {
      const i = e.getSize(new le());
      this._width = i.width, this._height = i.height, t = new Vn(this._width * this._pixelRatio, this._height * this._pixelRatio, { type: pr }), t.texture.name = "EffectComposer.rt1";
    } else
      this._width = t.width, this._height = t.height;
    this.renderTarget1 = t, this.renderTarget2 = t.clone(), this.renderTarget2.texture.name = "EffectComposer.rt2", this.writeBuffer = this.renderTarget1, this.readBuffer = this.renderTarget2, this.renderToScreen = !0, this.passes = [], this.copyPass = new fM(sM), this.copyPass.material.blending = En, this.clock = new Hu();
  }
  swapBuffers() {
    const e = this.readBuffer;
    this.readBuffer = this.writeBuffer, this.writeBuffer = e;
  }
  addPass(e) {
    this.passes.push(e), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
  }
  insertPass(e, t) {
    this.passes.splice(t, 0, e), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
  }
  removePass(e) {
    const t = this.passes.indexOf(e);
    t !== -1 && this.passes.splice(t, 1);
  }
  isLastEnabledPass(e) {
    for (let t = e + 1; t < this.passes.length; t++)
      if (this.passes[t].enabled)
        return !1;
    return !0;
  }
  render(e) {
    e === void 0 && (e = this.clock.getDelta());
    const t = this.renderer.getRenderTarget();
    let i = !1;
    for (let r = 0, a = this.passes.length; r < a; r++) {
      const o = this.passes[r];
      if (o.enabled !== !1) {
        if (o.renderToScreen = this.renderToScreen && this.isLastEnabledPass(r), o.render(this.renderer, this.writeBuffer, this.readBuffer, e, i), o.needsSwap) {
          if (i) {
            const s = this.renderer.getContext(), c = this.renderer.state.buffers.stencil;
            c.setFunc(s.NOTEQUAL, 1, 4294967295), this.copyPass.render(this.renderer, this.writeBuffer, this.readBuffer, e), c.setFunc(s.EQUAL, 1, 4294967295);
          }
          this.swapBuffers();
        }
        iu !== void 0 && (o instanceof iu ? i = !0 : o instanceof dM && (i = !1));
      }
    }
    this.renderer.setRenderTarget(t);
  }
  reset(e) {
    if (e === void 0) {
      const t = this.renderer.getSize(new le());
      this._pixelRatio = this.renderer.getPixelRatio(), this._width = t.width, this._height = t.height, e = this.renderTarget1.clone(), e.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
    }
    this.renderTarget1.dispose(), this.renderTarget2.dispose(), this.renderTarget1 = e, this.renderTarget2 = e.clone(), this.writeBuffer = this.renderTarget1, this.readBuffer = this.renderTarget2;
  }
  setSize(e, t) {
    this._width = e, this._height = t;
    const i = this._width * this._pixelRatio, r = this._height * this._pixelRatio;
    this.renderTarget1.setSize(i, r), this.renderTarget2.setSize(i, r);
    for (let a = 0; a < this.passes.length; a++)
      this.passes[a].setSize(i, r);
  }
  setPixelRatio(e) {
    this._pixelRatio = e, this.setSize(this._width, this._height);
  }
  dispose() {
    this.renderTarget1.dispose(), this.renderTarget2.dispose(), this.copyPass.dispose();
  }
}
class mM extends Ra {
  constructor(e, t, i = null, r = null, a = null) {
    super(), this.scene = e, this.camera = t, this.overrideMaterial = i, this.clearColor = r, this.clearAlpha = a, this.clear = !0, this.clearDepth = !1, this.needsSwap = !1, this._oldClearColor = new We();
  }
  render(e, t, i) {
    const r = e.autoClear;
    e.autoClear = !1;
    let a, o;
    this.overrideMaterial !== null && (o = this.scene.overrideMaterial, this.scene.overrideMaterial = this.overrideMaterial), this.clearColor !== null && (e.getClearColor(this._oldClearColor), e.setClearColor(this.clearColor)), this.clearAlpha !== null && (a = e.getClearAlpha(), e.setClearAlpha(this.clearAlpha)), this.clearDepth == !0 && e.clearDepth(), e.setRenderTarget(this.renderToScreen ? null : i), this.clear === !0 && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil), e.render(this.scene, this.camera), this.clearColor !== null && e.setClearColor(this._oldClearColor), this.clearAlpha !== null && e.setClearAlpha(a), this.overrideMaterial !== null && (this.scene.overrideMaterial = o), e.autoClear = r;
  }
}
function Ct() {
  return Ct = Object.assign ? Object.assign.bind() : function(n) {
    for (var e = 1; e < arguments.length; e++) {
      var t = arguments[e];
      for (var i in t)
        Object.prototype.hasOwnProperty.call(t, i) && (n[i] = t[i]);
    }
    return n;
  }, Ct.apply(this, arguments);
}
function gM(n) {
  if (n === void 0)
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  return n;
}
function yr(n, e) {
  return yr = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(i, r) {
    return i.__proto__ = r, i;
  }, yr(n, e);
}
function vM(n, e) {
  n.prototype = Object.create(e.prototype), n.prototype.constructor = n, yr(n, e);
}
function Qo(n) {
  return Qo = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
    return t.__proto__ || Object.getPrototypeOf(t);
  }, Qo(n);
}
function _M(n) {
  try {
    return Function.toString.call(n).indexOf("[native code]") !== -1;
  } catch {
    return typeof n == "function";
  }
}
function Ph() {
  try {
    var n = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
    }));
  } catch {
  }
  return (Ph = function() {
    return !!n;
  })();
}
function yM(n, e, t) {
  if (Ph())
    return Reflect.construct.apply(null, arguments);
  var i = [null];
  i.push.apply(i, e);
  var r = new (n.bind.apply(n, i))();
  return t && yr(r, t.prototype), r;
}
function es(n) {
  var e = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
  return es = function(i) {
    if (i === null || !_M(i))
      return i;
    if (typeof i != "function")
      throw new TypeError("Super expression must either be null or a function");
    if (typeof e < "u") {
      if (e.has(i))
        return e.get(i);
      e.set(i, r);
    }
    function r() {
      return yM(i, arguments, Qo(this).constructor);
    }
    return r.prototype = Object.create(i.prototype, {
      constructor: {
        value: r,
        enumerable: !1,
        writable: !0,
        configurable: !0
      }
    }), yr(r, i);
  }, es(n);
}
var xM = {
  1: `Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).

`,
  2: `Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).

`,
  3: `Passed an incorrect argument to a color function, please pass a string representation of a color.

`,
  4: `Couldn't generate valid rgb string from %s, it returned %s.

`,
  5: `Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.

`,
  6: `Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).

`,
  7: `Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).

`,
  8: `Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.

`,
  9: `Please provide a number of steps to the modularScale helper.

`,
  10: `Please pass a number or one of the predefined scales to the modularScale helper as the ratio.

`,
  11: `Invalid value passed as base to modularScale, expected number or em string but got "%s"

`,
  12: `Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.

`,
  13: `Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.

`,
  14: `Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.

`,
  15: `Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.

`,
  16: `You must provide a template to this method.

`,
  17: `You passed an unsupported selector state to this method.

`,
  18: `minScreen and maxScreen must be provided as stringified numbers with the same units.

`,
  19: `fromSize and toSize must be provided as stringified numbers with the same units.

`,
  20: `expects either an array of objects or a single object with the properties prop, fromSize, and toSize.

`,
  21: "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
  22: "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
  23: `fontFace expects a name of a font-family.

`,
  24: `fontFace expects either the path to the font file(s) or a name of a local copy.

`,
  25: `fontFace expects localFonts to be an array.

`,
  26: `fontFace expects fileFormats to be an array.

`,
  27: `radialGradient requries at least 2 color-stops to properly render.

`,
  28: `Please supply a filename to retinaImage() as the first argument.

`,
  29: `Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.

`,
  30: "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
  31: `The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation

`,
  32: `To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])
To pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')

`,
  33: `The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation

`,
  34: `borderRadius expects a radius value as a string or number as the second argument.

`,
  35: `borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.

`,
  36: `Property must be a string value.

`,
  37: `Syntax Error at %s.

`,
  38: `Formula contains a function that needs parentheses at %s.

`,
  39: `Formula is missing closing parenthesis at %s.

`,
  40: `Formula has too many closing parentheses at %s.

`,
  41: `All values in a formula must have the same unit or be unitless.

`,
  42: `Please provide a number of steps to the modularScale helper.

`,
  43: `Please pass a number or one of the predefined scales to the modularScale helper as the ratio.

`,
  44: `Invalid value passed as base to modularScale, expected number or em/rem string but got %s.

`,
  45: `Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.

`,
  46: `Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.

`,
  47: `minScreen and maxScreen must be provided as stringified numbers with the same units.

`,
  48: `fromSize and toSize must be provided as stringified numbers with the same units.

`,
  49: `Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.

`,
  50: `Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.

`,
  51: `Expects the first argument object to have the properties prop, fromSize, and toSize.

`,
  52: `fontFace expects either the path to the font file(s) or a name of a local copy.

`,
  53: `fontFace expects localFonts to be an array.

`,
  54: `fontFace expects fileFormats to be an array.

`,
  55: `fontFace expects a name of a font-family.

`,
  56: `linearGradient requries at least 2 color-stops to properly render.

`,
  57: `radialGradient requries at least 2 color-stops to properly render.

`,
  58: `Please supply a filename to retinaImage() as the first argument.

`,
  59: `Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.

`,
  60: "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
  61: `Property must be a string value.

`,
  62: `borderRadius expects a radius value as a string or number as the second argument.

`,
  63: `borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.

`,
  64: `The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.

`,
  65: `To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').

`,
  66: `The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.

`,
  67: `You must provide a template to this method.

`,
  68: `You passed an unsupported selector state to this method.

`,
  69: `Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.

`,
  70: `Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.

`,
  71: `Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.

`,
  72: `Passed invalid base value %s to %s(), please pass a value like "12px" or 12.

`,
  73: `Please provide a valid CSS variable.

`,
  74: `CSS variable not found and no default was provided.

`,
  75: `important requires a valid style object, got a %s instead.

`,
  76: `fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.

`,
  77: `remToPx expects a value in "rem" but you provided it in "%s".

`,
  78: `base must be set in "px" or "%" but you set it in "%s".
`
};
function bM() {
  for (var n = arguments.length, e = new Array(n), t = 0; t < n; t++)
    e[t] = arguments[t];
  var i = e[0], r = [], a;
  for (a = 1; a < e.length; a += 1)
    r.push(e[a]);
  return r.forEach(function(o) {
    i = i.replace(/%[a-z]/, o);
  }), i;
}
var an = /* @__PURE__ */ function(n) {
  vM(e, n);
  function e(t) {
    var i;
    if (process.env.NODE_ENV === "production")
      i = n.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + t + " for more information.") || this;
    else {
      for (var r = arguments.length, a = new Array(r > 1 ? r - 1 : 0), o = 1; o < r; o++)
        a[o - 1] = arguments[o];
      i = n.call(this, bM.apply(void 0, [xM[t]].concat(a))) || this;
    }
    return gM(i);
  }
  return e;
}(/* @__PURE__ */ es(Error));
function Po(n) {
  return Math.round(n * 255);
}
function MM(n, e, t) {
  return Po(n) + "," + Po(e) + "," + Po(t);
}
function xr(n, e, t, i) {
  if (i === void 0 && (i = MM), e === 0)
    return i(t, t, t);
  var r = (n % 360 + 360) % 360 / 60, a = (1 - Math.abs(2 * t - 1)) * e, o = a * (1 - Math.abs(r % 2 - 1)), s = 0, c = 0, l = 0;
  r >= 0 && r < 1 ? (s = a, c = o) : r >= 1 && r < 2 ? (s = o, c = a) : r >= 2 && r < 3 ? (c = a, l = o) : r >= 3 && r < 4 ? (c = o, l = a) : r >= 4 && r < 5 ? (s = o, l = a) : r >= 5 && r < 6 && (s = a, l = o);
  var u = t - a / 2, h = s + u, d = c + u, p = l + u;
  return i(h, d, p);
}
var ru = {
  aliceblue: "f0f8ff",
  antiquewhite: "faebd7",
  aqua: "00ffff",
  aquamarine: "7fffd4",
  azure: "f0ffff",
  beige: "f5f5dc",
  bisque: "ffe4c4",
  black: "000",
  blanchedalmond: "ffebcd",
  blue: "0000ff",
  blueviolet: "8a2be2",
  brown: "a52a2a",
  burlywood: "deb887",
  cadetblue: "5f9ea0",
  chartreuse: "7fff00",
  chocolate: "d2691e",
  coral: "ff7f50",
  cornflowerblue: "6495ed",
  cornsilk: "fff8dc",
  crimson: "dc143c",
  cyan: "00ffff",
  darkblue: "00008b",
  darkcyan: "008b8b",
  darkgoldenrod: "b8860b",
  darkgray: "a9a9a9",
  darkgreen: "006400",
  darkgrey: "a9a9a9",
  darkkhaki: "bdb76b",
  darkmagenta: "8b008b",
  darkolivegreen: "556b2f",
  darkorange: "ff8c00",
  darkorchid: "9932cc",
  darkred: "8b0000",
  darksalmon: "e9967a",
  darkseagreen: "8fbc8f",
  darkslateblue: "483d8b",
  darkslategray: "2f4f4f",
  darkslategrey: "2f4f4f",
  darkturquoise: "00ced1",
  darkviolet: "9400d3",
  deeppink: "ff1493",
  deepskyblue: "00bfff",
  dimgray: "696969",
  dimgrey: "696969",
  dodgerblue: "1e90ff",
  firebrick: "b22222",
  floralwhite: "fffaf0",
  forestgreen: "228b22",
  fuchsia: "ff00ff",
  gainsboro: "dcdcdc",
  ghostwhite: "f8f8ff",
  gold: "ffd700",
  goldenrod: "daa520",
  gray: "808080",
  green: "008000",
  greenyellow: "adff2f",
  grey: "808080",
  honeydew: "f0fff0",
  hotpink: "ff69b4",
  indianred: "cd5c5c",
  indigo: "4b0082",
  ivory: "fffff0",
  khaki: "f0e68c",
  lavender: "e6e6fa",
  lavenderblush: "fff0f5",
  lawngreen: "7cfc00",
  lemonchiffon: "fffacd",
  lightblue: "add8e6",
  lightcoral: "f08080",
  lightcyan: "e0ffff",
  lightgoldenrodyellow: "fafad2",
  lightgray: "d3d3d3",
  lightgreen: "90ee90",
  lightgrey: "d3d3d3",
  lightpink: "ffb6c1",
  lightsalmon: "ffa07a",
  lightseagreen: "20b2aa",
  lightskyblue: "87cefa",
  lightslategray: "789",
  lightslategrey: "789",
  lightsteelblue: "b0c4de",
  lightyellow: "ffffe0",
  lime: "0f0",
  limegreen: "32cd32",
  linen: "faf0e6",
  magenta: "f0f",
  maroon: "800000",
  mediumaquamarine: "66cdaa",
  mediumblue: "0000cd",
  mediumorchid: "ba55d3",
  mediumpurple: "9370db",
  mediumseagreen: "3cb371",
  mediumslateblue: "7b68ee",
  mediumspringgreen: "00fa9a",
  mediumturquoise: "48d1cc",
  mediumvioletred: "c71585",
  midnightblue: "191970",
  mintcream: "f5fffa",
  mistyrose: "ffe4e1",
  moccasin: "ffe4b5",
  navajowhite: "ffdead",
  navy: "000080",
  oldlace: "fdf5e6",
  olive: "808000",
  olivedrab: "6b8e23",
  orange: "ffa500",
  orangered: "ff4500",
  orchid: "da70d6",
  palegoldenrod: "eee8aa",
  palegreen: "98fb98",
  paleturquoise: "afeeee",
  palevioletred: "db7093",
  papayawhip: "ffefd5",
  peachpuff: "ffdab9",
  peru: "cd853f",
  pink: "ffc0cb",
  plum: "dda0dd",
  powderblue: "b0e0e6",
  purple: "800080",
  rebeccapurple: "639",
  red: "f00",
  rosybrown: "bc8f8f",
  royalblue: "4169e1",
  saddlebrown: "8b4513",
  salmon: "fa8072",
  sandybrown: "f4a460",
  seagreen: "2e8b57",
  seashell: "fff5ee",
  sienna: "a0522d",
  silver: "c0c0c0",
  skyblue: "87ceeb",
  slateblue: "6a5acd",
  slategray: "708090",
  slategrey: "708090",
  snow: "fffafa",
  springgreen: "00ff7f",
  steelblue: "4682b4",
  tan: "d2b48c",
  teal: "008080",
  thistle: "d8bfd8",
  tomato: "ff6347",
  turquoise: "40e0d0",
  violet: "ee82ee",
  wheat: "f5deb3",
  white: "fff",
  whitesmoke: "f5f5f5",
  yellow: "ff0",
  yellowgreen: "9acd32"
};
function SM(n) {
  if (typeof n != "string")
    return n;
  var e = n.toLowerCase();
  return ru[e] ? "#" + ru[e] : n;
}
var EM = /^#[a-fA-F0-9]{6}$/, wM = /^#[a-fA-F0-9]{8}$/, TM = /^#[a-fA-F0-9]{3}$/, AM = /^#[a-fA-F0-9]{4}$/, Lo = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i, CM = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i, RM = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i, PM = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
function li(n) {
  if (typeof n != "string")
    throw new an(3);
  var e = SM(n);
  if (e.match(EM))
    return {
      red: parseInt("" + e[1] + e[2], 16),
      green: parseInt("" + e[3] + e[4], 16),
      blue: parseInt("" + e[5] + e[6], 16)
    };
  if (e.match(wM)) {
    var t = parseFloat((parseInt("" + e[7] + e[8], 16) / 255).toFixed(2));
    return {
      red: parseInt("" + e[1] + e[2], 16),
      green: parseInt("" + e[3] + e[4], 16),
      blue: parseInt("" + e[5] + e[6], 16),
      alpha: t
    };
  }
  if (e.match(TM))
    return {
      red: parseInt("" + e[1] + e[1], 16),
      green: parseInt("" + e[2] + e[2], 16),
      blue: parseInt("" + e[3] + e[3], 16)
    };
  if (e.match(AM)) {
    var i = parseFloat((parseInt("" + e[4] + e[4], 16) / 255).toFixed(2));
    return {
      red: parseInt("" + e[1] + e[1], 16),
      green: parseInt("" + e[2] + e[2], 16),
      blue: parseInt("" + e[3] + e[3], 16),
      alpha: i
    };
  }
  var r = Lo.exec(e);
  if (r)
    return {
      red: parseInt("" + r[1], 10),
      green: parseInt("" + r[2], 10),
      blue: parseInt("" + r[3], 10)
    };
  var a = CM.exec(e.substring(0, 50));
  if (a)
    return {
      red: parseInt("" + a[1], 10),
      green: parseInt("" + a[2], 10),
      blue: parseInt("" + a[3], 10),
      alpha: parseFloat("" + a[4]) > 1 ? parseFloat("" + a[4]) / 100 : parseFloat("" + a[4])
    };
  var o = RM.exec(e);
  if (o) {
    var s = parseInt("" + o[1], 10), c = parseInt("" + o[2], 10) / 100, l = parseInt("" + o[3], 10) / 100, u = "rgb(" + xr(s, c, l) + ")", h = Lo.exec(u);
    if (!h)
      throw new an(4, e, u);
    return {
      red: parseInt("" + h[1], 10),
      green: parseInt("" + h[2], 10),
      blue: parseInt("" + h[3], 10)
    };
  }
  var d = PM.exec(e.substring(0, 50));
  if (d) {
    var p = parseInt("" + d[1], 10), g = parseInt("" + d[2], 10) / 100, v = parseInt("" + d[3], 10) / 100, m = "rgb(" + xr(p, g, v) + ")", f = Lo.exec(m);
    if (!f)
      throw new an(4, e, m);
    return {
      red: parseInt("" + f[1], 10),
      green: parseInt("" + f[2], 10),
      blue: parseInt("" + f[3], 10),
      alpha: parseFloat("" + d[4]) > 1 ? parseFloat("" + d[4]) / 100 : parseFloat("" + d[4])
    };
  }
  throw new an(5);
}
function LM(n) {
  var e = n.red / 255, t = n.green / 255, i = n.blue / 255, r = Math.max(e, t, i), a = Math.min(e, t, i), o = (r + a) / 2;
  if (r === a)
    return n.alpha !== void 0 ? {
      hue: 0,
      saturation: 0,
      lightness: o,
      alpha: n.alpha
    } : {
      hue: 0,
      saturation: 0,
      lightness: o
    };
  var s, c = r - a, l = o > 0.5 ? c / (2 - r - a) : c / (r + a);
  switch (r) {
    case e:
      s = (t - i) / c + (t < i ? 6 : 0);
      break;
    case t:
      s = (i - e) / c + 2;
      break;
    default:
      s = (e - t) / c + 4;
      break;
  }
  return s *= 60, n.alpha !== void 0 ? {
    hue: s,
    saturation: l,
    lightness: o,
    alpha: n.alpha
  } : {
    hue: s,
    saturation: l,
    lightness: o
  };
}
function jn(n) {
  return LM(li(n));
}
var DM = function(e) {
  return e.length === 7 && e[1] === e[2] && e[3] === e[4] && e[5] === e[6] ? "#" + e[1] + e[3] + e[5] : e;
}, ts = DM;
function ni(n) {
  var e = n.toString(16);
  return e.length === 1 ? "0" + e : e;
}
function Do(n) {
  return ni(Math.round(n * 255));
}
function OM(n, e, t) {
  return ts("#" + Do(n) + Do(e) + Do(t));
}
function va(n, e, t) {
  return xr(n, e, t, OM);
}
function IM(n, e, t) {
  if (typeof n == "number" && typeof e == "number" && typeof t == "number")
    return va(n, e, t);
  if (typeof n == "object" && e === void 0 && t === void 0)
    return va(n.hue, n.saturation, n.lightness);
  throw new an(1);
}
function NM(n, e, t, i) {
  if (typeof n == "number" && typeof e == "number" && typeof t == "number" && typeof i == "number")
    return i >= 1 ? va(n, e, t) : "rgba(" + xr(n, e, t) + "," + i + ")";
  if (typeof n == "object" && e === void 0 && t === void 0 && i === void 0)
    return n.alpha >= 1 ? va(n.hue, n.saturation, n.lightness) : "rgba(" + xr(n.hue, n.saturation, n.lightness) + "," + n.alpha + ")";
  throw new an(2);
}
function ns(n, e, t) {
  if (typeof n == "number" && typeof e == "number" && typeof t == "number")
    return ts("#" + ni(n) + ni(e) + ni(t));
  if (typeof n == "object" && e === void 0 && t === void 0)
    return ts("#" + ni(n.red) + ni(n.green) + ni(n.blue));
  throw new an(6);
}
function Pa(n, e, t, i) {
  if (typeof n == "string" && typeof e == "number") {
    var r = li(n);
    return "rgba(" + r.red + "," + r.green + "," + r.blue + "," + e + ")";
  } else {
    if (typeof n == "number" && typeof e == "number" && typeof t == "number" && typeof i == "number")
      return i >= 1 ? ns(n, e, t) : "rgba(" + n + "," + e + "," + t + "," + i + ")";
    if (typeof n == "object" && e === void 0 && t === void 0 && i === void 0)
      return n.alpha >= 1 ? ns(n.red, n.green, n.blue) : "rgba(" + n.red + "," + n.green + "," + n.blue + "," + n.alpha + ")";
  }
  throw new an(7);
}
var UM = function(e) {
  return typeof e.red == "number" && typeof e.green == "number" && typeof e.blue == "number" && (typeof e.alpha != "number" || typeof e.alpha > "u");
}, FM = function(e) {
  return typeof e.red == "number" && typeof e.green == "number" && typeof e.blue == "number" && typeof e.alpha == "number";
}, BM = function(e) {
  return typeof e.hue == "number" && typeof e.saturation == "number" && typeof e.lightness == "number" && (typeof e.alpha != "number" || typeof e.alpha > "u");
}, kM = function(e) {
  return typeof e.hue == "number" && typeof e.saturation == "number" && typeof e.lightness == "number" && typeof e.alpha == "number";
};
function Xn(n) {
  if (typeof n != "object")
    throw new an(8);
  if (FM(n))
    return Pa(n);
  if (UM(n))
    return ns(n);
  if (kM(n))
    return NM(n);
  if (BM(n))
    return IM(n);
  throw new an(8);
}
function Lh(n, e, t) {
  return function() {
    var r = t.concat(Array.prototype.slice.call(arguments));
    return r.length >= e ? n.apply(this, r) : Lh(n, e, r);
  };
}
function Ut(n) {
  return Lh(n, n.length, []);
}
function zM(n, e) {
  if (e === "transparent")
    return e;
  var t = jn(e);
  return Xn(Ct({}, t, {
    hue: t.hue + parseFloat(n)
  }));
}
Ut(zM);
function $i(n, e, t) {
  return Math.max(n, Math.min(e, t));
}
function HM(n, e) {
  if (e === "transparent")
    return e;
  var t = jn(e);
  return Xn(Ct({}, t, {
    lightness: $i(0, 1, t.lightness - parseFloat(n))
  }));
}
Ut(HM);
function VM(n, e) {
  if (e === "transparent")
    return e;
  var t = jn(e);
  return Xn(Ct({}, t, {
    saturation: $i(0, 1, t.saturation - parseFloat(n))
  }));
}
Ut(VM);
function GM(n, e) {
  if (e === "transparent")
    return e;
  var t = jn(e);
  return Xn(Ct({}, t, {
    lightness: $i(0, 1, t.lightness + parseFloat(n))
  }));
}
Ut(GM);
function WM(n, e, t) {
  if (e === "transparent")
    return t;
  if (t === "transparent")
    return e;
  if (n === 0)
    return t;
  var i = li(e), r = Ct({}, i, {
    alpha: typeof i.alpha == "number" ? i.alpha : 1
  }), a = li(t), o = Ct({}, a, {
    alpha: typeof a.alpha == "number" ? a.alpha : 1
  }), s = r.alpha - o.alpha, c = parseFloat(n) * 2 - 1, l = c * s === -1 ? c : c + s, u = 1 + c * s, h = (l / u + 1) / 2, d = 1 - h, p = {
    red: Math.floor(r.red * h + o.red * d),
    green: Math.floor(r.green * h + o.green * d),
    blue: Math.floor(r.blue * h + o.blue * d),
    alpha: r.alpha * parseFloat(n) + o.alpha * (1 - parseFloat(n))
  };
  return Pa(p);
}
var jM = Ut(WM), Dh = jM;
function XM(n, e) {
  if (e === "transparent")
    return e;
  var t = li(e), i = typeof t.alpha == "number" ? t.alpha : 1, r = Ct({}, t, {
    alpha: $i(0, 1, (i * 100 + parseFloat(n) * 100) / 100)
  });
  return Pa(r);
}
var $M = Ut(XM), qM = $M;
function YM(n, e) {
  if (e === "transparent")
    return e;
  var t = jn(e);
  return Xn(Ct({}, t, {
    saturation: $i(0, 1, t.saturation + parseFloat(n))
  }));
}
Ut(YM);
function KM(n, e) {
  return e === "transparent" ? e : Xn(Ct({}, jn(e), {
    hue: parseFloat(n)
  }));
}
Ut(KM);
function ZM(n, e) {
  return e === "transparent" ? e : Xn(Ct({}, jn(e), {
    lightness: parseFloat(n)
  }));
}
Ut(ZM);
function JM(n, e) {
  return e === "transparent" ? e : Xn(Ct({}, jn(e), {
    saturation: parseFloat(n)
  }));
}
Ut(JM);
function QM(n, e) {
  return e === "transparent" ? e : Dh(parseFloat(n), "rgb(0, 0, 0)", e);
}
Ut(QM);
function eS(n, e) {
  return e === "transparent" ? e : Dh(parseFloat(n), "rgb(255, 255, 255)", e);
}
Ut(eS);
function tS(n, e) {
  if (e === "transparent")
    return e;
  var t = li(e), i = typeof t.alpha == "number" ? t.alpha : 1, r = Ct({}, t, {
    alpha: $i(0, 1, +(i * 100 - parseFloat(n) * 100).toFixed(2) / 100)
  });
  return Pa(r);
}
Ut(tS);
var si = Object.freeze({
  Linear: Object.freeze({
    None: function(n) {
      return n;
    },
    In: function(n) {
      return this.None(n);
    },
    Out: function(n) {
      return this.None(n);
    },
    InOut: function(n) {
      return this.None(n);
    }
  }),
  Quadratic: Object.freeze({
    In: function(n) {
      return n * n;
    },
    Out: function(n) {
      return n * (2 - n);
    },
    InOut: function(n) {
      return (n *= 2) < 1 ? 0.5 * n * n : -0.5 * (--n * (n - 2) - 1);
    }
  }),
  Cubic: Object.freeze({
    In: function(n) {
      return n * n * n;
    },
    Out: function(n) {
      return --n * n * n + 1;
    },
    InOut: function(n) {
      return (n *= 2) < 1 ? 0.5 * n * n * n : 0.5 * ((n -= 2) * n * n + 2);
    }
  }),
  Quartic: Object.freeze({
    In: function(n) {
      return n * n * n * n;
    },
    Out: function(n) {
      return 1 - --n * n * n * n;
    },
    InOut: function(n) {
      return (n *= 2) < 1 ? 0.5 * n * n * n * n : -0.5 * ((n -= 2) * n * n * n - 2);
    }
  }),
  Quintic: Object.freeze({
    In: function(n) {
      return n * n * n * n * n;
    },
    Out: function(n) {
      return --n * n * n * n * n + 1;
    },
    InOut: function(n) {
      return (n *= 2) < 1 ? 0.5 * n * n * n * n * n : 0.5 * ((n -= 2) * n * n * n * n + 2);
    }
  }),
  Sinusoidal: Object.freeze({
    In: function(n) {
      return 1 - Math.sin((1 - n) * Math.PI / 2);
    },
    Out: function(n) {
      return Math.sin(n * Math.PI / 2);
    },
    InOut: function(n) {
      return 0.5 * (1 - Math.sin(Math.PI * (0.5 - n)));
    }
  }),
  Exponential: Object.freeze({
    In: function(n) {
      return n === 0 ? 0 : Math.pow(1024, n - 1);
    },
    Out: function(n) {
      return n === 1 ? 1 : 1 - Math.pow(2, -10 * n);
    },
    InOut: function(n) {
      return n === 0 ? 0 : n === 1 ? 1 : (n *= 2) < 1 ? 0.5 * Math.pow(1024, n - 1) : 0.5 * (-Math.pow(2, -10 * (n - 1)) + 2);
    }
  }),
  Circular: Object.freeze({
    In: function(n) {
      return 1 - Math.sqrt(1 - n * n);
    },
    Out: function(n) {
      return Math.sqrt(1 - --n * n);
    },
    InOut: function(n) {
      return (n *= 2) < 1 ? -0.5 * (Math.sqrt(1 - n * n) - 1) : 0.5 * (Math.sqrt(1 - (n -= 2) * n) + 1);
    }
  }),
  Elastic: Object.freeze({
    In: function(n) {
      return n === 0 ? 0 : n === 1 ? 1 : -Math.pow(2, 10 * (n - 1)) * Math.sin((n - 1.1) * 5 * Math.PI);
    },
    Out: function(n) {
      return n === 0 ? 0 : n === 1 ? 1 : Math.pow(2, -10 * n) * Math.sin((n - 0.1) * 5 * Math.PI) + 1;
    },
    InOut: function(n) {
      return n === 0 ? 0 : n === 1 ? 1 : (n *= 2, n < 1 ? -0.5 * Math.pow(2, 10 * (n - 1)) * Math.sin((n - 1.1) * 5 * Math.PI) : 0.5 * Math.pow(2, -10 * (n - 1)) * Math.sin((n - 1.1) * 5 * Math.PI) + 1);
    }
  }),
  Back: Object.freeze({
    In: function(n) {
      var e = 1.70158;
      return n === 1 ? 1 : n * n * ((e + 1) * n - e);
    },
    Out: function(n) {
      var e = 1.70158;
      return n === 0 ? 0 : --n * n * ((e + 1) * n + e) + 1;
    },
    InOut: function(n) {
      var e = 2.5949095;
      return (n *= 2) < 1 ? 0.5 * (n * n * ((e + 1) * n - e)) : 0.5 * ((n -= 2) * n * ((e + 1) * n + e) + 2);
    }
  }),
  Bounce: Object.freeze({
    In: function(n) {
      return 1 - si.Bounce.Out(1 - n);
    },
    Out: function(n) {
      return n < 1 / 2.75 ? 7.5625 * n * n : n < 2 / 2.75 ? 7.5625 * (n -= 1.5 / 2.75) * n + 0.75 : n < 2.5 / 2.75 ? 7.5625 * (n -= 2.25 / 2.75) * n + 0.9375 : 7.5625 * (n -= 2.625 / 2.75) * n + 0.984375;
    },
    InOut: function(n) {
      return n < 0.5 ? si.Bounce.In(n * 2) * 0.5 : si.Bounce.Out(n * 2 - 1) * 0.5 + 0.5;
    }
  }),
  generatePow: function(n) {
    return n === void 0 && (n = 4), n = n < Number.EPSILON ? Number.EPSILON : n, n = n > 1e4 ? 1e4 : n, {
      In: function(e) {
        return Math.pow(e, n);
      },
      Out: function(e) {
        return 1 - Math.pow(1 - e, n);
      },
      InOut: function(e) {
        return e < 0.5 ? Math.pow(e * 2, n) / 2 : (1 - Math.pow(2 - e * 2, n)) / 2 + 0.5;
      }
    };
  }
}), lr = function() {
  return performance.now();
}, nS = (
  /** @class */
  function() {
    function n() {
      this._tweens = {}, this._tweensAddedDuringUpdate = {};
    }
    return n.prototype.getAll = function() {
      var e = this;
      return Object.keys(this._tweens).map(function(t) {
        return e._tweens[t];
      });
    }, n.prototype.removeAll = function() {
      this._tweens = {};
    }, n.prototype.add = function(e) {
      this._tweens[e.getId()] = e, this._tweensAddedDuringUpdate[e.getId()] = e;
    }, n.prototype.remove = function(e) {
      delete this._tweens[e.getId()], delete this._tweensAddedDuringUpdate[e.getId()];
    }, n.prototype.update = function(e, t) {
      e === void 0 && (e = lr()), t === void 0 && (t = !1);
      var i = Object.keys(this._tweens);
      if (i.length === 0)
        return !1;
      for (; i.length > 0; ) {
        this._tweensAddedDuringUpdate = {};
        for (var r = 0; r < i.length; r++) {
          var a = this._tweens[i[r]], o = !t;
          a && a.update(e, o) === !1 && !t && delete this._tweens[i[r]];
        }
        i = Object.keys(this._tweensAddedDuringUpdate);
      }
      return !0;
    }, n;
  }()
), Ii = {
  Linear: function(n, e) {
    var t = n.length - 1, i = t * e, r = Math.floor(i), a = Ii.Utils.Linear;
    return e < 0 ? a(n[0], n[1], i) : e > 1 ? a(n[t], n[t - 1], t - i) : a(n[r], n[r + 1 > t ? t : r + 1], i - r);
  },
  Bezier: function(n, e) {
    for (var t = 0, i = n.length - 1, r = Math.pow, a = Ii.Utils.Bernstein, o = 0; o <= i; o++)
      t += r(1 - e, i - o) * r(e, o) * n[o] * a(i, o);
    return t;
  },
  CatmullRom: function(n, e) {
    var t = n.length - 1, i = t * e, r = Math.floor(i), a = Ii.Utils.CatmullRom;
    return n[0] === n[t] ? (e < 0 && (r = Math.floor(i = t * (1 + e))), a(n[(r - 1 + t) % t], n[r], n[(r + 1) % t], n[(r + 2) % t], i - r)) : e < 0 ? n[0] - (a(n[0], n[0], n[1], n[1], -i) - n[0]) : e > 1 ? n[t] - (a(n[t], n[t], n[t - 1], n[t - 1], i - t) - n[t]) : a(n[r ? r - 1 : 0], n[r], n[t < r + 1 ? t : r + 1], n[t < r + 2 ? t : r + 2], i - r);
  },
  Utils: {
    Linear: function(n, e, t) {
      return (e - n) * t + n;
    },
    Bernstein: function(n, e) {
      var t = Ii.Utils.Factorial;
      return t(n) / t(e) / t(n - e);
    },
    Factorial: /* @__PURE__ */ function() {
      var n = [1];
      return function(e) {
        var t = 1;
        if (n[e])
          return n[e];
        for (var i = e; i > 1; i--)
          t *= i;
        return n[e] = t, t;
      };
    }(),
    CatmullRom: function(n, e, t, i, r) {
      var a = (t - n) * 0.5, o = (i - e) * 0.5, s = r * r, c = r * s;
      return (2 * e - 2 * t + a + o) * c + (-3 * e + 3 * t - 2 * a - o) * s + a * r + e;
    }
  }
}, iS = (
  /** @class */
  function() {
    function n() {
    }
    return n.nextId = function() {
      return n._nextId++;
    }, n._nextId = 0, n;
  }()
), is = new nS(), au = (
  /** @class */
  function() {
    function n(e, t) {
      t === void 0 && (t = is), this._object = e, this._group = t, this._isPaused = !1, this._pauseStart = 0, this._valuesStart = {}, this._valuesEnd = {}, this._valuesStartRepeat = {}, this._duration = 1e3, this._isDynamic = !1, this._initialRepeat = 0, this._repeat = 0, this._yoyo = !1, this._isPlaying = !1, this._reversed = !1, this._delayTime = 0, this._startTime = 0, this._easingFunction = si.Linear.None, this._interpolationFunction = Ii.Linear, this._chainedTweens = [], this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._id = iS.nextId(), this._isChainStopped = !1, this._propertiesAreSetUp = !1, this._goToEnd = !1;
    }
    return n.prototype.getId = function() {
      return this._id;
    }, n.prototype.isPlaying = function() {
      return this._isPlaying;
    }, n.prototype.isPaused = function() {
      return this._isPaused;
    }, n.prototype.getDuration = function() {
      return this._duration;
    }, n.prototype.to = function(e, t) {
      if (t === void 0 && (t = 1e3), this._isPlaying)
        throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");
      return this._valuesEnd = e, this._propertiesAreSetUp = !1, this._duration = t < 0 ? 0 : t, this;
    }, n.prototype.duration = function(e) {
      return e === void 0 && (e = 1e3), this._duration = e < 0 ? 0 : e, this;
    }, n.prototype.dynamic = function(e) {
      return e === void 0 && (e = !1), this._isDynamic = e, this;
    }, n.prototype.start = function(e, t) {
      if (e === void 0 && (e = lr()), t === void 0 && (t = !1), this._isPlaying)
        return this;
      if (this._group && this._group.add(this), this._repeat = this._initialRepeat, this._reversed) {
        this._reversed = !1;
        for (var i in this._valuesStartRepeat)
          this._swapEndStartRepeatValues(i), this._valuesStart[i] = this._valuesStartRepeat[i];
      }
      if (this._isPlaying = !0, this._isPaused = !1, this._onStartCallbackFired = !1, this._onEveryStartCallbackFired = !1, this._isChainStopped = !1, this._startTime = e, this._startTime += this._delayTime, !this._propertiesAreSetUp || t) {
        if (this._propertiesAreSetUp = !0, !this._isDynamic) {
          var r = {};
          for (var a in this._valuesEnd)
            r[a] = this._valuesEnd[a];
          this._valuesEnd = r;
        }
        this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, t);
      }
      return this;
    }, n.prototype.startFromCurrentValues = function(e) {
      return this.start(e, !0);
    }, n.prototype._setupProperties = function(e, t, i, r, a) {
      for (var o in i) {
        var s = e[o], c = Array.isArray(s), l = c ? "array" : typeof s, u = !c && Array.isArray(i[o]);
        if (!(l === "undefined" || l === "function")) {
          if (u) {
            var h = i[o];
            if (h.length === 0)
              continue;
            for (var d = [s], p = 0, g = h.length; p < g; p += 1) {
              var v = this._handleRelativeValue(s, h[p]);
              if (isNaN(v)) {
                u = !1, console.warn("Found invalid interpolation list. Skipping.");
                break;
              }
              d.push(v);
            }
            u && (i[o] = d);
          }
          if ((l === "object" || c) && s && !u) {
            t[o] = c ? [] : {};
            var m = s;
            for (var f in m)
              t[o][f] = m[f];
            r[o] = c ? [] : {};
            var h = i[o];
            if (!this._isDynamic) {
              var M = {};
              for (var f in h)
                M[f] = h[f];
              i[o] = h = M;
            }
            this._setupProperties(m, t[o], h, r[o], a);
          } else
            (typeof t[o] > "u" || a) && (t[o] = s), c || (t[o] *= 1), u ? r[o] = i[o].slice().reverse() : r[o] = t[o] || 0;
        }
      }
    }, n.prototype.stop = function() {
      return this._isChainStopped || (this._isChainStopped = !0, this.stopChainedTweens()), this._isPlaying ? (this._group && this._group.remove(this), this._isPlaying = !1, this._isPaused = !1, this._onStopCallback && this._onStopCallback(this._object), this) : this;
    }, n.prototype.end = function() {
      return this._goToEnd = !0, this.update(1 / 0), this;
    }, n.prototype.pause = function(e) {
      return e === void 0 && (e = lr()), this._isPaused || !this._isPlaying ? this : (this._isPaused = !0, this._pauseStart = e, this._group && this._group.remove(this), this);
    }, n.prototype.resume = function(e) {
      return e === void 0 && (e = lr()), !this._isPaused || !this._isPlaying ? this : (this._isPaused = !1, this._startTime += e - this._pauseStart, this._pauseStart = 0, this._group && this._group.add(this), this);
    }, n.prototype.stopChainedTweens = function() {
      for (var e = 0, t = this._chainedTweens.length; e < t; e++)
        this._chainedTweens[e].stop();
      return this;
    }, n.prototype.group = function(e) {
      return e === void 0 && (e = is), this._group = e, this;
    }, n.prototype.delay = function(e) {
      return e === void 0 && (e = 0), this._delayTime = e, this;
    }, n.prototype.repeat = function(e) {
      return e === void 0 && (e = 0), this._initialRepeat = e, this._repeat = e, this;
    }, n.prototype.repeatDelay = function(e) {
      return this._repeatDelayTime = e, this;
    }, n.prototype.yoyo = function(e) {
      return e === void 0 && (e = !1), this._yoyo = e, this;
    }, n.prototype.easing = function(e) {
      return e === void 0 && (e = si.Linear.None), this._easingFunction = e, this;
    }, n.prototype.interpolation = function(e) {
      return e === void 0 && (e = Ii.Linear), this._interpolationFunction = e, this;
    }, n.prototype.chain = function() {
      for (var e = [], t = 0; t < arguments.length; t++)
        e[t] = arguments[t];
      return this._chainedTweens = e, this;
    }, n.prototype.onStart = function(e) {
      return this._onStartCallback = e, this;
    }, n.prototype.onEveryStart = function(e) {
      return this._onEveryStartCallback = e, this;
    }, n.prototype.onUpdate = function(e) {
      return this._onUpdateCallback = e, this;
    }, n.prototype.onRepeat = function(e) {
      return this._onRepeatCallback = e, this;
    }, n.prototype.onComplete = function(e) {
      return this._onCompleteCallback = e, this;
    }, n.prototype.onStop = function(e) {
      return this._onStopCallback = e, this;
    }, n.prototype.update = function(e, t) {
      var i = this, r;
      if (e === void 0 && (e = lr()), t === void 0 && (t = !0), this._isPaused)
        return !0;
      var a, o = this._startTime + this._duration;
      if (!this._goToEnd && !this._isPlaying) {
        if (e > o)
          return !1;
        t && this.start(e, !0);
      }
      if (this._goToEnd = !1, e < this._startTime)
        return !0;
      this._onStartCallbackFired === !1 && (this._onStartCallback && this._onStartCallback(this._object), this._onStartCallbackFired = !0), this._onEveryStartCallbackFired === !1 && (this._onEveryStartCallback && this._onEveryStartCallback(this._object), this._onEveryStartCallbackFired = !0);
      var s = e - this._startTime, c = this._duration + ((r = this._repeatDelayTime) !== null && r !== void 0 ? r : this._delayTime), l = this._duration + this._repeat * c, u = function() {
        if (i._duration === 0 || s > l)
          return 1;
        var m = Math.trunc(s / c), f = s - m * c, M = Math.min(f / i._duration, 1);
        return M === 0 && s === i._duration ? 1 : M;
      }, h = u(), d = this._easingFunction(h);
      if (this._updateProperties(this._object, this._valuesStart, this._valuesEnd, d), this._onUpdateCallback && this._onUpdateCallback(this._object, h), this._duration === 0 || s >= this._duration)
        if (this._repeat > 0) {
          var p = Math.min(Math.trunc((s - this._duration) / c) + 1, this._repeat);
          isFinite(this._repeat) && (this._repeat -= p);
          for (a in this._valuesStartRepeat)
            !this._yoyo && typeof this._valuesEnd[a] == "string" && (this._valuesStartRepeat[a] = // eslint-disable-next-line
            // @ts-ignore FIXME?
            this._valuesStartRepeat[a] + parseFloat(this._valuesEnd[a])), this._yoyo && this._swapEndStartRepeatValues(a), this._valuesStart[a] = this._valuesStartRepeat[a];
          return this._yoyo && (this._reversed = !this._reversed), this._startTime += c * p, this._onRepeatCallback && this._onRepeatCallback(this._object), this._onEveryStartCallbackFired = !1, !0;
        } else {
          this._onCompleteCallback && this._onCompleteCallback(this._object);
          for (var g = 0, v = this._chainedTweens.length; g < v; g++)
            this._chainedTweens[g].start(this._startTime + this._duration, !1);
          return this._isPlaying = !1, !1;
        }
      return !0;
    }, n.prototype._updateProperties = function(e, t, i, r) {
      for (var a in i)
        if (t[a] !== void 0) {
          var o = t[a] || 0, s = i[a], c = Array.isArray(e[a]), l = Array.isArray(s), u = !c && l;
          u ? e[a] = this._interpolationFunction(s, r) : typeof s == "object" && s ? this._updateProperties(e[a], o, s, r) : (s = this._handleRelativeValue(o, s), typeof s == "number" && (e[a] = o + (s - o) * r));
        }
    }, n.prototype._handleRelativeValue = function(e, t) {
      return typeof t != "string" ? t : t.charAt(0) === "+" || t.charAt(0) === "-" ? e + parseFloat(t) : parseFloat(t);
    }, n.prototype._swapEndStartRepeatValues = function(e) {
      var t = this._valuesStartRepeat[e], i = this._valuesEnd[e];
      typeof i == "string" ? this._valuesStartRepeat[e] = this._valuesStartRepeat[e] + parseFloat(i) : this._valuesStartRepeat[e] = this._valuesEnd[e], this._valuesEnd[e] = t;
    }, n;
  }()
), cn = is;
cn.getAll.bind(cn);
cn.removeAll.bind(cn);
cn.add.bind(cn);
cn.remove.bind(cn);
var rS = cn.update.bind(cn);
function aS(n, e) {
  if (e = {}, e.insertAt, !(typeof document > "u")) {
    var t = document.head || document.getElementsByTagName("head")[0], i = document.createElement("style");
    i.type = "text/css", t.appendChild(i), i.styleSheet ? i.styleSheet.cssText = n : i.appendChild(document.createTextNode(n));
  }
}
var oS = `.scene-nav-info {
  bottom: 5px;
  width: 100%;
  text-align: center;
  color: slategrey;
  opacity: 0.7;
  font-size: 10px;
}

.scene-tooltip {
  top: 0;
  color: lavender;
  font-size: 15px;
}

.scene-nav-info, .scene-tooltip {
  position: absolute;
  font-family: sans-serif;
  pointer-events: none;
  user-select: none;
}

.scene-container canvas:focus {
  outline: none;
}`;
aS(oS);
function sS(n, e) {
  var t = n == null ? null : typeof Symbol < "u" && n[Symbol.iterator] || n["@@iterator"];
  if (t != null) {
    var i, r, a, o, s = [], c = !0, l = !1;
    try {
      if (a = (t = t.call(n)).next, e !== 0)
        for (; !(c = (i = a.call(t)).done) && (s.push(i.value), s.length !== e); c = !0)
          ;
    } catch (u) {
      l = !0, r = u;
    } finally {
      try {
        if (!c && t.return != null && (o = t.return(), Object(o) !== o))
          return;
      } finally {
        if (l)
          throw r;
      }
    }
    return s;
  }
}
function cS(n, e) {
  if (typeof n != "object" || !n)
    return n;
  var t = n[Symbol.toPrimitive];
  if (t !== void 0) {
    var i = t.call(n, e);
    if (typeof i != "object")
      return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return String(n);
}
function lS(n) {
  var e = cS(n, "string");
  return typeof e == "symbol" ? e : e + "";
}
function uS(n, e, t) {
  return e = lS(e), e in n ? Object.defineProperty(n, e, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : n[e] = t, n;
}
function hS(n, e) {
  return dS(n) || sS(n, e) || Oh(n, e) || gS();
}
function rr(n) {
  return fS(n) || pS(n) || Oh(n) || mS();
}
function fS(n) {
  if (Array.isArray(n))
    return rs(n);
}
function dS(n) {
  if (Array.isArray(n))
    return n;
}
function pS(n) {
  if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
    return Array.from(n);
}
function Oh(n, e) {
  if (n) {
    if (typeof n == "string")
      return rs(n, e);
    var t = Object.prototype.toString.call(n).slice(8, -1);
    if (t === "Object" && n.constructor && (t = n.constructor.name), t === "Map" || t === "Set")
      return Array.from(n);
    if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))
      return rs(n, e);
  }
}
function rs(n, e) {
  (e == null || e > n.length) && (e = n.length);
  for (var t = 0, i = new Array(e); t < e; t++)
    i[t] = n[t];
  return i;
}
function mS() {
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function gS() {
  throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
var nt = window.THREE ? window.THREE : {
  WebGLRenderer: g_,
  Scene: v_,
  PerspectiveCamera: zt,
  Raycaster: Vu,
  SRGBColorSpace: $t,
  TextureLoader: B_,
  Vector2: le,
  Vector3: O,
  Box3: ui,
  Color: We,
  Mesh: Vt,
  SphereGeometry: Ta,
  MeshBasicMaterial: us,
  BackSide: wt,
  EventDispatcher: Qt,
  MOUSE: en,
  Quaternion: Jt,
  Spherical: Go,
  Clock: Hu
}, Ih = Rs({
  props: {
    width: {
      default: window.innerWidth,
      onChange: function(e, t, i) {
        isNaN(e) && (t.width = i);
      }
    },
    height: {
      default: window.innerHeight,
      onChange: function(e, t, i) {
        isNaN(e) && (t.height = i);
      }
    },
    backgroundColor: {
      default: "#000011"
    },
    backgroundImageUrl: {},
    onBackgroundImageLoaded: {},
    showNavInfo: {
      default: !0
    },
    skyRadius: {
      default: 5e4
    },
    objects: {
      default: []
    },
    lights: {
      default: []
    },
    enablePointerInteraction: {
      default: !0,
      onChange: function(e, t) {
        t.hoverObj = null, t.toolTipElem && (t.toolTipElem.innerHTML = "");
      },
      triggerUpdate: !1
    },
    lineHoverPrecision: {
      default: 1,
      triggerUpdate: !1
    },
    hoverOrderComparator: {
      default: function() {
        return -1;
      },
      triggerUpdate: !1
    },
    // keep existing order by default
    hoverFilter: {
      default: function() {
        return !0;
      },
      triggerUpdate: !1
    },
    // exclude objects from interaction
    tooltipContent: {
      triggerUpdate: !1
    },
    hoverDuringDrag: {
      default: !1,
      triggerUpdate: !1
    },
    clickAfterDrag: {
      default: !1,
      triggerUpdate: !1
    },
    onHover: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onClick: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onRightClick: {
      triggerUpdate: !1
    }
  },
  methods: {
    tick: function(e) {
      if (e.initialised) {
        if (e.controls.update && e.controls.update(Math.min(1, e.clock.getDelta())), e.postProcessingComposer ? e.postProcessingComposer.render() : e.renderer.render(e.scene, e.camera), e.extraRenderers.forEach(function(a) {
          return a.render(e.scene, e.camera);
        }), e.enablePointerInteraction) {
          var t = null;
          if (e.hoverDuringDrag || !e.isPointerDragging) {
            var i = this.intersectingObjects(e.pointerPos.x, e.pointerPos.y).filter(function(a) {
              return e.hoverFilter(a.object);
            }).sort(function(a, o) {
              return e.hoverOrderComparator(a.object, o.object);
            }), r = i.length ? i[0] : null;
            t = r ? r.object : null, e.intersectionPoint = r ? r.point : null;
          }
          t !== e.hoverObj && (e.onHover(t, e.hoverObj), e.toolTipElem.innerHTML = t && Xe(e.tooltipContent)(t) || "", e.hoverObj = t);
        }
        rS();
      }
      return this;
    },
    getPointerPos: function(e) {
      var t = e.pointerPos, i = t.x, r = t.y;
      return {
        x: i,
        y: r
      };
    },
    cameraPosition: function(e, t, i, r) {
      var a = e.camera;
      if (t && e.initialised) {
        var o = t, s = i || {
          x: 0,
          y: 0,
          z: 0
        };
        if (!r)
          u(o), h(s);
        else {
          var c = Object.assign({}, a.position), l = d();
          new au(c).to(o, r).easing(si.Quadratic.Out).onUpdate(u).start(), new au(l).to(s, r / 3).easing(si.Quadratic.Out).onUpdate(h).start();
        }
        return this;
      }
      return Object.assign({}, a.position, {
        lookAt: d()
      });
      function u(p) {
        var g = p.x, v = p.y, m = p.z;
        g !== void 0 && (a.position.x = g), v !== void 0 && (a.position.y = v), m !== void 0 && (a.position.z = m);
      }
      function h(p) {
        var g = new nt.Vector3(p.x, p.y, p.z);
        e.controls.target ? e.controls.target = g : a.lookAt(g);
      }
      function d() {
        return Object.assign(new nt.Vector3(0, 0, -1e3).applyQuaternion(a.quaternion).add(a.position));
      }
    },
    zoomToFit: function(e) {
      for (var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 10, r = arguments.length, a = new Array(r > 3 ? r - 3 : 0), o = 3; o < r; o++)
        a[o - 3] = arguments[o];
      return this.fitToBbox(this.getBbox.apply(this, a), t, i);
    },
    fitToBbox: function(e, t) {
      var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 10, a = e.camera;
      if (t) {
        var o = new nt.Vector3(0, 0, 0), s = Math.max.apply(Math, rr(Object.entries(t).map(function(p) {
          var g = hS(p, 2), v = g[0], m = g[1];
          return Math.max.apply(Math, rr(m.map(function(f) {
            return Math.abs(o[v] - f);
          })));
        }))) * 2, c = (1 - r * 2 / e.height) * a.fov, l = s / Math.atan(c * Math.PI / 180), u = l / a.aspect, h = Math.max(l, u);
        if (h > 0) {
          var d = o.clone().sub(a.position).normalize().multiplyScalar(-h);
          this.cameraPosition(d, o, i);
        }
      }
      return this;
    },
    getBbox: function(e) {
      var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function() {
        return !0;
      }, i = new nt.Box3(new nt.Vector3(0, 0, 0), new nt.Vector3(0, 0, 0)), r = e.objects.filter(t);
      return r.length ? (r.forEach(function(a) {
        return i.expandByObject(a);
      }), Object.assign.apply(Object, rr(["x", "y", "z"].map(function(a) {
        return uS({}, a, [i.min[a], i.max[a]]);
      })))) : null;
    },
    getScreenCoords: function(e, t, i, r) {
      var a = new nt.Vector3(t, i, r);
      return a.project(this.camera()), {
        // align relative pos to canvas dimensions
        x: (a.x + 1) * e.width / 2,
        y: -(a.y - 1) * e.height / 2
      };
    },
    getSceneCoords: function(e, t, i) {
      var r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, a = new nt.Vector2(t / e.width * 2 - 1, -(i / e.height) * 2 + 1), o = new nt.Raycaster();
      return o.setFromCamera(a, e.camera), Object.assign({}, o.ray.at(r, new nt.Vector3()));
    },
    intersectingObjects: function(e, t, i) {
      var r = new nt.Vector2(t / e.width * 2 - 1, -(i / e.height) * 2 + 1), a = new nt.Raycaster();
      return a.params.Line.threshold = e.lineHoverPrecision, a.setFromCamera(r, e.camera), a.intersectObjects(e.objects, !0);
    },
    renderer: function(e) {
      return e.renderer;
    },
    scene: function(e) {
      return e.scene;
    },
    camera: function(e) {
      return e.camera;
    },
    postProcessingComposer: function(e) {
      return e.postProcessingComposer;
    },
    controls: function(e) {
      return e.controls;
    },
    tbControls: function(e) {
      return e.controls;
    }
    // to be deprecated
  },
  stateInit: function() {
    return {
      scene: new nt.Scene(),
      camera: new nt.PerspectiveCamera(),
      clock: new nt.Clock()
    };
  },
  init: function(e, t) {
    var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, r = i.controlType, a = r === void 0 ? "trackball" : r, o = i.rendererConfig, s = o === void 0 ? {} : o, c = i.extraRenderers, l = c === void 0 ? [] : c, u = i.waitForLoadComplete, h = u === void 0 ? !0 : u;
    e.innerHTML = "", e.appendChild(t.container = document.createElement("div")), t.container.className = "scene-container", t.container.style.position = "relative", t.container.appendChild(t.navInfo = document.createElement("div")), t.navInfo.className = "scene-nav-info", t.navInfo.textContent = {
      orbit: "Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",
      trackball: "Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",
      fly: "WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"
    }[a] || "", t.navInfo.style.display = t.showNavInfo ? null : "none", t.toolTipElem = document.createElement("div"), t.toolTipElem.classList.add("scene-tooltip"), t.container.appendChild(t.toolTipElem), t.pointerPos = new nt.Vector2(), t.pointerPos.x = -2, t.pointerPos.y = -2, ["pointermove", "pointerdown"].forEach(function(d) {
      return t.container.addEventListener(d, function(p) {
        if (d === "pointerdown" && (t.isPointerPressed = !0), !t.isPointerDragging && p.type === "pointermove" && (p.pressure > 0 || t.isPointerPressed) && (p.pointerType !== "touch" || p.movementX === void 0 || [p.movementX, p.movementY].some(function(m) {
          return Math.abs(m) > 1;
        })) && (t.isPointerDragging = !0), t.enablePointerInteraction) {
          var g = v(t.container);
          t.pointerPos.x = p.pageX - g.left, t.pointerPos.y = p.pageY - g.top, t.toolTipElem.style.top = "".concat(t.pointerPos.y, "px"), t.toolTipElem.style.left = "".concat(t.pointerPos.x, "px"), t.toolTipElem.style.transform = "translate(-".concat(t.pointerPos.x / t.width * 100, "%, ").concat(
            // flip to above if near bottom
            t.height - t.pointerPos.y < 100 ? "calc(-100% - 8px)" : "21px",
            ")"
          );
        }
        function v(m) {
          var f = m.getBoundingClientRect(), M = window.pageXOffset || document.documentElement.scrollLeft, _ = window.pageYOffset || document.documentElement.scrollTop;
          return {
            top: f.top + _,
            left: f.left + M
          };
        }
      }, {
        passive: !0
      });
    }), t.container.addEventListener("pointerup", function(d) {
      t.isPointerPressed = !1, !(t.isPointerDragging && (t.isPointerDragging = !1, !t.clickAfterDrag)) && requestAnimationFrame(function() {
        d.button === 0 && t.onClick(t.hoverObj || null, d, t.intersectionPoint), d.button === 2 && t.onRightClick && t.onRightClick(t.hoverObj || null, d, t.intersectionPoint);
      });
    }, {
      passive: !0,
      capture: !0
    }), t.container.addEventListener("contextmenu", function(d) {
      t.onRightClick && d.preventDefault();
    }), t.renderer = new nt.WebGLRenderer(Object.assign({
      antialias: !0,
      alpha: !0
    }, s)), t.renderer.setPixelRatio(Math.min(2, window.devicePixelRatio)), t.container.appendChild(t.renderer.domElement), t.extraRenderers = l, t.extraRenderers.forEach(function(d) {
      d.domElement.style.position = "absolute", d.domElement.style.top = "0px", d.domElement.style.pointerEvents = "none", t.container.appendChild(d.domElement);
    }), t.postProcessingComposer = new pM(t.renderer), t.postProcessingComposer.addPass(new mM(t.scene, t.camera)), t.controls = new {
      trackball: nM,
      orbit: rM,
      fly: oM
    }[a](t.camera, t.renderer.domElement), a === "fly" && (t.controls.movementSpeed = 300, t.controls.rollSpeed = Math.PI / 6, t.controls.dragToLook = !0), (a === "trackball" || a === "orbit") && (t.controls.minDistance = 0.1, t.controls.maxDistance = t.skyRadius, t.controls.addEventListener("start", function() {
      t.controlsEngaged = !0;
    }), t.controls.addEventListener("change", function() {
      t.controlsEngaged && (t.controlsDragging = !0);
    }), t.controls.addEventListener("end", function() {
      t.controlsEngaged = !1, t.controlsDragging = !1;
    })), [t.renderer, t.postProcessingComposer].concat(rr(t.extraRenderers)).forEach(function(d) {
      return d.setSize(t.width, t.height);
    }), t.camera.aspect = t.width / t.height, t.camera.updateProjectionMatrix(), t.camera.position.z = 1e3, t.scene.add(t.skysphere = new nt.Mesh()), t.skysphere.visible = !1, t.loadComplete = t.scene.visible = !h, window.scene = t.scene;
  },
  update: function(e, t) {
    if (e.width && e.height && (t.hasOwnProperty("width") || t.hasOwnProperty("height")) && (e.container.style.width = "".concat(e.width, "px"), e.container.style.height = "".concat(e.height, "px"), [e.renderer, e.postProcessingComposer].concat(rr(e.extraRenderers)).forEach(function(a) {
      return a.setSize(e.width, e.height);
    }), e.camera.aspect = e.width / e.height, e.camera.updateProjectionMatrix()), t.hasOwnProperty("skyRadius") && e.skyRadius && (e.controls.hasOwnProperty("maxDistance") && t.skyRadius && (e.controls.maxDistance = Math.min(e.controls.maxDistance, e.skyRadius)), e.camera.far = e.skyRadius * 2.5, e.camera.updateProjectionMatrix(), e.skysphere.geometry = new nt.SphereGeometry(e.skyRadius)), t.hasOwnProperty("backgroundColor")) {
      var i = li(e.backgroundColor).alpha;
      i === void 0 && (i = 1), e.renderer.setClearColor(new nt.Color(qM(1, e.backgroundColor)), i);
    }
    t.hasOwnProperty("backgroundImageUrl") && (e.backgroundImageUrl ? new nt.TextureLoader().load(e.backgroundImageUrl, function(a) {
      a.colorSpace = nt.SRGBColorSpace, e.skysphere.material = new nt.MeshBasicMaterial({
        map: a,
        side: nt.BackSide
      }), e.skysphere.visible = !0, e.onBackgroundImageLoaded && setTimeout(e.onBackgroundImageLoaded), !e.loadComplete && r();
    }) : (e.skysphere.visible = !1, e.skysphere.material.map = null, !e.loadComplete && r())), t.hasOwnProperty("showNavInfo") && (e.navInfo.style.display = e.showNavInfo ? null : "none"), t.hasOwnProperty("lights") && ((t.lights || []).forEach(function(a) {
      return e.scene.remove(a);
    }), e.lights.forEach(function(a) {
      return e.scene.add(a);
    })), t.hasOwnProperty("objects") && ((t.objects || []).forEach(function(a) {
      return e.scene.remove(a);
    }), e.objects.forEach(function(a) {
      return e.scene.add(a);
    }));
    function r() {
      e.loadComplete = e.scene.visible = !0;
    }
  }
});
function vS(n, e) {
  e === void 0 && (e = {});
  var t = e.insertAt;
  if (!(!n || typeof document > "u")) {
    var i = document.head || document.getElementsByTagName("head")[0], r = document.createElement("style");
    r.type = "text/css", t === "top" && i.firstChild ? i.insertBefore(r, i.firstChild) : i.appendChild(r), r.styleSheet ? r.styleSheet.cssText = n : r.appendChild(document.createTextNode(n));
  }
}
var _S = `.graph-info-msg {
  top: 50%;
  width: 100%;
  text-align: center;
  color: lavender;
  opacity: 0.7;
  font-size: 22px;
  position: absolute;
  font-family: Sans-serif;
}

.scene-container .clickable {
  cursor: pointer;
}

.scene-container .grabbable {
  cursor: move;
  cursor: grab;
  cursor: -moz-grab;
  cursor: -webkit-grab;
}

.scene-container .grabbable:active {
  cursor: grabbing;
  cursor: -moz-grabbing;
  cursor: -webkit-grabbing;
}`;
vS(_S);
function ou(n, e) {
  var t = Object.keys(n);
  if (Object.getOwnPropertySymbols) {
    var i = Object.getOwnPropertySymbols(n);
    e && (i = i.filter(function(r) {
      return Object.getOwnPropertyDescriptor(n, r).enumerable;
    })), t.push.apply(t, i);
  }
  return t;
}
function ta(n) {
  for (var e = 1; e < arguments.length; e++) {
    var t = arguments[e] != null ? arguments[e] : {};
    e % 2 ? ou(Object(t), !0).forEach(function(i) {
      Er(n, i, t[i]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(t)) : ou(Object(t)).forEach(function(i) {
      Object.defineProperty(n, i, Object.getOwnPropertyDescriptor(t, i));
    });
  }
  return n;
}
function yS(n, e) {
  if (typeof n != "object" || !n)
    return n;
  var t = n[Symbol.toPrimitive];
  if (t !== void 0) {
    var i = t.call(n, e || "default");
    if (typeof i != "object")
      return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (e === "string" ? String : Number)(n);
}
function xS(n) {
  var e = yS(n, "string");
  return typeof e == "symbol" ? e : e + "";
}
function Er(n, e, t) {
  return e = xS(e), e in n ? Object.defineProperty(n, e, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : n[e] = t, n;
}
function La(n) {
  return bS(n) || MS(n) || SS(n) || ES();
}
function bS(n) {
  if (Array.isArray(n))
    return as(n);
}
function MS(n) {
  if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
    return Array.from(n);
}
function SS(n, e) {
  if (n) {
    if (typeof n == "string")
      return as(n, e);
    var t = Object.prototype.toString.call(n).slice(8, -1);
    if (t === "Object" && n.constructor && (t = n.constructor.name), t === "Map" || t === "Set")
      return Array.from(n);
    if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))
      return as(n, e);
  }
}
function as(n, e) {
  (e == null || e > n.length) && (e = n.length);
  for (var t = 0, i = new Array(e); t < e; t++)
    i[t] = n[t];
  return i;
}
function ES() {
  throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Nh(n, e) {
  var t = new e();
  return t._destructor && t._destructor(), {
    linkProp: function(r) {
      return {
        default: t[r](),
        onChange: function(o, s) {
          s[n][r](o);
        },
        triggerUpdate: !1
      };
    },
    linkMethod: function(r) {
      return function(a) {
        for (var o = a[n], s = arguments.length, c = new Array(s > 1 ? s - 1 : 0), l = 1; l < s; l++)
          c[l - 1] = arguments[l];
        var u = o[r].apply(o, c);
        return u === o ? this : u;
      };
    }
  };
}
var Oo = window.THREE ? window.THREE : {
  AmbientLight: V_,
  DirectionalLight: H_,
  Vector3: O,
  REVISION: _a
}, wS = 170, Uh = Nh("forceGraph", Rh), TS = Object.assign.apply(Object, La(["jsonUrl", "graphData", "numDimensions", "dagMode", "dagLevelDistance", "dagNodeFilter", "onDagError", "nodeRelSize", "nodeId", "nodeVal", "nodeResolution", "nodeColor", "nodeAutoColorBy", "nodeOpacity", "nodeVisibility", "nodeThreeObject", "nodeThreeObjectExtend", "linkSource", "linkTarget", "linkVisibility", "linkColor", "linkAutoColorBy", "linkOpacity", "linkWidth", "linkResolution", "linkCurvature", "linkCurveRotation", "linkMaterial", "linkThreeObject", "linkThreeObjectExtend", "linkPositionUpdate", "linkDirectionalArrowLength", "linkDirectionalArrowColor", "linkDirectionalArrowRelPos", "linkDirectionalArrowResolution", "linkDirectionalParticles", "linkDirectionalParticleSpeed", "linkDirectionalParticleWidth", "linkDirectionalParticleColor", "linkDirectionalParticleResolution", "forceEngine", "d3AlphaDecay", "d3VelocityDecay", "d3AlphaMin", "ngraphPhysics", "warmupTicks", "cooldownTicks", "cooldownTime", "onEngineTick", "onEngineStop"].map(function(n) {
  return Er({}, n, Uh.linkProp(n));
}))), AS = Object.assign.apply(Object, La(["refresh", "getGraphBbox", "d3Force", "d3ReheatSimulation", "emitParticle"].map(function(n) {
  return Er({}, n, Uh.linkMethod(n));
}))), ra = Nh("renderObjs", Ih), CS = Object.assign.apply(Object, La(["width", "height", "backgroundColor", "showNavInfo", "enablePointerInteraction"].map(function(n) {
  return Er({}, n, ra.linkProp(n));
}))), RS = Object.assign.apply(Object, La(["lights", "cameraPosition", "postProcessingComposer"].map(function(n) {
  return Er({}, n, ra.linkMethod(n));
})).concat([{
  graph2ScreenCoords: ra.linkMethod("getScreenCoords"),
  screen2GraphCoords: ra.linkMethod("getSceneCoords")
}])), PS = Rs({
  props: ta(ta({
    nodeLabel: {
      default: "name",
      triggerUpdate: !1
    },
    linkLabel: {
      default: "name",
      triggerUpdate: !1
    },
    linkHoverPrecision: {
      default: 1,
      onChange: function(e, t) {
        return t.renderObjs.lineHoverPrecision(e);
      },
      triggerUpdate: !1
    },
    enableNavigationControls: {
      default: !0,
      onChange: function(e, t) {
        var i = t.renderObjs.controls();
        i && (i.enabled = e, e && i.domElement && i.domElement.dispatchEvent(new PointerEvent("pointerup")));
      },
      triggerUpdate: !1
    },
    enableNodeDrag: {
      default: !0,
      triggerUpdate: !1
    },
    onNodeDrag: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onNodeDragEnd: {
      default: function() {
      },
      triggerUpdate: !1
    },
    onNodeClick: {
      triggerUpdate: !1
    },
    onNodeRightClick: {
      triggerUpdate: !1
    },
    onNodeHover: {
      triggerUpdate: !1
    },
    onLinkClick: {
      triggerUpdate: !1
    },
    onLinkRightClick: {
      triggerUpdate: !1
    },
    onLinkHover: {
      triggerUpdate: !1
    },
    onBackgroundClick: {
      triggerUpdate: !1
    },
    onBackgroundRightClick: {
      triggerUpdate: !1
    }
  }, TS), CS),
  methods: ta(ta({
    zoomToFit: function(e, t, i) {
      for (var r, a = arguments.length, o = new Array(a > 3 ? a - 3 : 0), s = 3; s < a; s++)
        o[s - 3] = arguments[s];
      return e.renderObjs.fitToBbox((r = e.forceGraph).getGraphBbox.apply(r, o), t, i), this;
    },
    pauseAnimation: function(e) {
      return e.animationFrameRequestId !== null && (cancelAnimationFrame(e.animationFrameRequestId), e.animationFrameRequestId = null), this;
    },
    resumeAnimation: function(e) {
      return e.animationFrameRequestId === null && this._animationCycle(), this;
    },
    _animationCycle: function(e) {
      e.enablePointerInteraction && (this.renderer().domElement.style.cursor = null), e.forceGraph.tickFrame(), e.renderObjs.tick(), e.animationFrameRequestId = requestAnimationFrame(this._animationCycle);
    },
    scene: function(e) {
      return e.renderObjs.scene();
    },
    // Expose scene
    camera: function(e) {
      return e.renderObjs.camera();
    },
    // Expose camera
    renderer: function(e) {
      return e.renderObjs.renderer();
    },
    // Expose renderer
    controls: function(e) {
      return e.renderObjs.controls();
    },
    // Expose controls
    tbControls: function(e) {
      return e.renderObjs.tbControls();
    },
    // To be deprecated
    _destructor: function() {
      this.pauseAnimation(), this.graphData({
        nodes: [],
        links: []
      });
    }
  }, AS), RS),
  stateInit: function(e) {
    var t = e.controlType, i = e.rendererConfig, r = e.extraRenderers, a = new Rh();
    return {
      forceGraph: a,
      renderObjs: Ih({
        controlType: t,
        rendererConfig: i,
        extraRenderers: r
      }).objects([a]).lights([new Oo.AmbientLight(13421772, Math.PI), new Oo.DirectionalLight(16777215, 0.6 * Math.PI)])
    };
  },
  init: function(e, t) {
    e.innerHTML = "", e.appendChild(t.container = document.createElement("div")), t.container.style.position = "relative";
    var i = document.createElement("div");
    t.container.appendChild(i), t.renderObjs(i);
    var r = t.renderObjs.camera(), a = t.renderObjs.renderer(), o = t.renderObjs.controls();
    o.enabled = !!t.enableNavigationControls, t.lastSetCameraZ = r.position.z;
    var s;
    t.container.appendChild(s = document.createElement("div")), s.className = "graph-info-msg", s.textContent = "", t.forceGraph.onLoading(function() {
      s.textContent = "Loading...";
    }).onFinishLoading(function() {
      s.textContent = "";
    }).onUpdate(function() {
      t.graphData = t.forceGraph.graphData(), r.position.x === 0 && r.position.y === 0 && r.position.z === t.lastSetCameraZ && t.graphData.nodes.length && (r.lookAt(t.forceGraph.position), t.lastSetCameraZ = r.position.z = Math.cbrt(t.graphData.nodes.length) * wS);
    }).onFinishUpdate(function() {
      if (t._dragControls) {
        var c = t.graphData.nodes.find(function(u) {
          return u.__initialFixedPos && !u.__disposeControlsAfterDrag;
        });
        c ? c.__disposeControlsAfterDrag = !0 : t._dragControls.dispose(), t._dragControls = void 0;
      }
      if (t.enableNodeDrag && t.enablePointerInteraction && t.forceEngine === "d3") {
        var l = t._dragControls = new G_(t.graphData.nodes.map(function(u) {
          return u.__threeObj;
        }).filter(function(u) {
          return u;
        }), r, a.domElement);
        l.addEventListener("dragstart", function(u) {
          o.enabled = !1, u.object.__initialPos = u.object.position.clone(), u.object.__prevPos = u.object.position.clone();
          var h = vn(u.object).__data;
          !h.__initialFixedPos && (h.__initialFixedPos = {
            fx: h.fx,
            fy: h.fy,
            fz: h.fz
          }), !h.__initialPos && (h.__initialPos = {
            x: h.x,
            y: h.y,
            z: h.z
          }), ["x", "y", "z"].forEach(function(d) {
            return h["f".concat(d)] = h[d];
          }), a.domElement.classList.add("grabbable");
        }), l.addEventListener("drag", function(u) {
          var h = vn(u.object);
          if (!u.object.hasOwnProperty("__graphObjType")) {
            var d = u.object.__initialPos, p = u.object.__prevPos, g = u.object.position;
            h.position.add(g.clone().sub(p)), p.copy(g), g.copy(d);
          }
          var v = h.__data, m = h.position, f = {
            x: m.x - v.x,
            y: m.y - v.y,
            z: m.z - v.z
          };
          ["x", "y", "z"].forEach(function(M) {
            return v["f".concat(M)] = v[M] = m[M];
          }), t.forceGraph.d3AlphaTarget(0.3).resetCountdown(), v.__dragged = !0, t.onNodeDrag(v, f);
        }), l.addEventListener("dragend", function(u) {
          delete u.object.__initialPos, delete u.object.__prevPos;
          var h = vn(u.object).__data;
          h.__disposeControlsAfterDrag && (l.dispose(), delete h.__disposeControlsAfterDrag);
          var d = h.__initialFixedPos, p = h.__initialPos, g = {
            x: p.x - h.x,
            y: p.y - h.y,
            z: p.z - h.z
          };
          d && (["x", "y", "z"].forEach(function(v) {
            var m = "f".concat(v);
            d[m] === void 0 && delete h[m];
          }), delete h.__initialFixedPos, delete h.__initialPos, h.__dragged && (delete h.__dragged, t.onNodeDragEnd(h, g))), t.forceGraph.d3AlphaTarget(0).resetCountdown(), t.enableNavigationControls && (o.enabled = !0, o.domElement && o.domElement.ownerDocument && o.domElement.ownerDocument.dispatchEvent(
            // simulate mouseup to ensure the controls don't take over after dragend
            new PointerEvent("pointerup", {
              pointerType: "touch"
            })
          )), a.domElement.classList.remove("grabbable");
        });
      }
    }), Oo.REVISION < 155 && (t.renderObjs.renderer().useLegacyLights = !1), t.renderObjs.hoverOrderComparator(function(c, l) {
      var u = vn(c);
      if (!u)
        return 1;
      var h = vn(l);
      if (!h)
        return -1;
      var d = function(g) {
        return g.__graphObjType === "node";
      };
      return d(h) - d(u);
    }).tooltipContent(function(c) {
      var l = vn(c);
      return l && Xe(t["".concat(l.__graphObjType, "Label")])(l.__data) || "";
    }).hoverDuringDrag(!1).onHover(function(c) {
      var l = vn(c);
      if (l !== t.hoverObj) {
        var u = t.hoverObj ? t.hoverObj.__graphObjType : null, h = t.hoverObj ? t.hoverObj.__data : null, d = l ? l.__graphObjType : null, p = l ? l.__data : null;
        if (u && u !== d) {
          var g = t["on".concat(u === "node" ? "Node" : "Link", "Hover")];
          g && g(null, h);
        }
        if (d) {
          var v = t["on".concat(d === "node" ? "Node" : "Link", "Hover")];
          v && v(p, u === d ? h : null);
        }
        a.domElement.classList[l && t["on".concat(d === "node" ? "Node" : "Link", "Click")] || !l && t.onBackgroundClick ? "add" : "remove"]("clickable"), t.hoverObj = l;
      }
    }).clickAfterDrag(!1).onClick(function(c, l) {
      var u = vn(c);
      if (u) {
        var h = t["on".concat(u.__graphObjType === "node" ? "Node" : "Link", "Click")];
        h && h(u.__data, l);
      } else
        t.onBackgroundClick && t.onBackgroundClick(l);
    }).onRightClick(function(c, l) {
      var u = vn(c);
      if (u) {
        var h = t["on".concat(u.__graphObjType === "node" ? "Node" : "Link", "RightClick")];
        h && h(u.__data, l);
      } else
        t.onBackgroundRightClick && t.onBackgroundRightClick(l);
    }), this._animationCycle();
  }
});
function vn(n) {
  for (var e = n; e && !e.hasOwnProperty("__graphObjType"); )
    e = e.parent;
  return e;
}
function LS({ model: n, el: e }) {
  let t = e.getBoundingClientRect(), i = document.createElement("div");
  e.appendChild(i);
  let r = JSON.parse(n.get("_model_rep")), a = PS()(i).graphData(r).nodeLabel("id").linkOpacity(1).linkAutoColorBy("value").linkDirectionalParticles(1).linkDirectionalParticleSpeed((o) => o.value * 1e-3).linkDirectionalParticleWidth(4).warmupTicks(100).cooldownTicks(0).width(t.width).height(t.width / 2);
  n.on("change:_model_rep", () => {
    a.graphData(JSON.parse(n.get("_model_rep")));
  }), n.on("msg:custom", (o) => {
    switch (o.type) {
      case "create_layout":
        let s = {};
        a.graphData().nodes.forEach((l) => {
          s[l.id] = { x: l.x, y: l.y, z: l.z };
        }), n.send({ type: "layout", positions: s });
        break;
      case "load_layout":
        let c = o.positions;
        a.graphData().nodes.forEach((l) => {
          let u = c[l.id];
          l.fx = u.x, l.fy = u.y, l.fz = u.z;
        }), a.cooldownTicks(1), a.d3ReheatSimulation();
        break;
      default:
        console.log(`Unknown ${o}.`);
    }
  });
}
const OS = { render: LS };
export {
  OS as default
};
