function J(e, t, n, i) {
  function r(s) {
    return s instanceof n ? s : new n(function(o) {
      o(s);
    });
  }
  return new (n || (n = Promise))(function(s, o) {
    function a(l) {
      try {
        u(i.next(l));
      } catch (f) {
        o(f);
      }
    }
    function c(l) {
      try {
        u(i.throw(l));
      } catch (f) {
        o(f);
      }
    }
    function u(l) {
      l.done ? s(l.value) : r(l.value).then(a, c);
    }
    u((i = i.apply(e, t || [])).next());
  });
}
function iy(e) {
  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], i = 0;
  if (n)
    return n.call(e);
  if (e && typeof e.length == "number")
    return {
      next: function() {
        return e && i >= e.length && (e = void 0), { value: e && e[i++], done: !e };
      }
    };
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function ut(e) {
  return this instanceof ut ? (this.v = e, this) : new ut(e);
}
function Xn(e, t, n) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var i = n.apply(e, t || []), r, s = [];
  return r = {}, o("next"), o("throw"), o("return"), r[Symbol.asyncIterator] = function() {
    return this;
  }, r;
  function o(h) {
    i[h] && (r[h] = function(d) {
      return new Promise(function(p, g) {
        s.push([h, d, p, g]) > 1 || a(h, d);
      });
    });
  }
  function a(h, d) {
    try {
      c(i[h](d));
    } catch (p) {
      f(s[0][3], p);
    }
  }
  function c(h) {
    h.value instanceof ut ? Promise.resolve(h.value.v).then(u, l) : f(s[0][2], h);
  }
  function u(h) {
    a("next", h);
  }
  function l(h) {
    a("throw", h);
  }
  function f(h, d) {
    h(d), s.shift(), s.length && a(s[0][0], s[0][1]);
  }
}
function Hc(e) {
  var t, n;
  return t = {}, i("next"), i("throw", function(r) {
    throw r;
  }), i("return"), t[Symbol.iterator] = function() {
    return this;
  }, t;
  function i(r, s) {
    t[r] = e[r] ? function(o) {
      return (n = !n) ? { value: ut(e[r](o)), done: !1 } : s ? s(o) : o;
    } : s;
  }
}
function Cs(e) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var t = e[Symbol.asyncIterator], n;
  return t ? t.call(e) : (e = typeof iy == "function" ? iy(e) : e[Symbol.iterator](), n = {}, i("next"), i("throw"), i("return"), n[Symbol.asyncIterator] = function() {
    return this;
  }, n);
  function i(s) {
    n[s] = e[s] && function(o) {
      return new Promise(function(a, c) {
        o = e[s](o), r(a, c, o.done, o.value);
      });
    };
  }
  function r(s, o, a, c) {
    Promise.resolve(c).then(function(u) {
      s({ value: u, done: a });
    }, o);
  }
}
const P4 = new TextDecoder("utf-8"), ud = (e) => P4.decode(e), Y4 = new TextEncoder(), L0 = (e) => Y4.encode(e), [hq, q4] = (() => {
  const e = () => {
    throw new Error("BigInt is not available in this environment");
  };
  function t() {
    throw e();
  }
  return t.asIntN = () => {
    throw e();
  }, t.asUintN = () => {
    throw e();
  }, typeof BigInt < "u" ? [BigInt, !0] : [t, !1];
})(), [Ya, dq] = (() => {
  const e = () => {
    throw new Error("BigInt64Array is not available in this environment");
  };
  class t {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw e();
    }
    static from() {
      throw e();
    }
    constructor() {
      throw e();
    }
  }
  return typeof BigInt64Array < "u" ? [BigInt64Array, !0] : [t, !1];
})(), [qa, pq] = (() => {
  const e = () => {
    throw new Error("BigUint64Array is not available in this environment");
  };
  class t {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw e();
    }
    static from() {
      throw e();
    }
    constructor() {
      throw e();
    }
  }
  return typeof BigUint64Array < "u" ? [BigUint64Array, !0] : [t, !1];
})(), V4 = (e) => typeof e == "number", j4 = (e) => typeof e == "boolean", Ae = (e) => typeof e == "function", An = (e) => e != null && Object(e) === e, ma = (e) => An(e) && Ae(e.then), Yl = (e) => An(e) && Ae(e[Symbol.iterator]), C0 = (e) => An(e) && Ae(e[Symbol.asyncIterator]), ld = (e) => An(e) && An(e.schema), ub = (e) => An(e) && "done" in e && "value" in e, lb = (e) => An(e) && Ae(e.stat) && V4(e.fd), fb = (e) => An(e) && k0(e.body), hb = (e) => "_getDOMStream" in e && "_getNodeStream" in e, k0 = (e) => An(e) && Ae(e.cancel) && Ae(e.getReader) && !hb(e), db = (e) => An(e) && Ae(e.read) && Ae(e.pipe) && j4(e.readable) && !hb(e), X4 = (e) => An(e) && Ae(e.clear) && Ae(e.bytes) && Ae(e.position) && Ae(e.setPosition) && Ae(e.capacity) && Ae(e.getBufferIdentifier) && Ae(e.createLong), R0 = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function W4(e) {
  const t = e[0] ? [e[0]] : [];
  let n, i, r, s;
  for (let o, a, c = 0, u = 0, l = e.length; ++c < l; ) {
    if (o = t[u], a = e[c], !o || !a || o.buffer !== a.buffer || a.byteOffset < o.byteOffset) {
      a && (t[++u] = a);
      continue;
    }
    if ({ byteOffset: n, byteLength: r } = o, { byteOffset: i, byteLength: s } = a, n + r < i || i + s < n) {
      a && (t[++u] = a);
      continue;
    }
    t[u] = new Uint8Array(o.buffer, n, i - n + s);
  }
  return t;
}
function ry(e, t, n = 0, i = t.byteLength) {
  const r = e.byteLength, s = new Uint8Array(e.buffer, e.byteOffset, r), o = new Uint8Array(t.buffer, t.byteOffset, Math.min(i, r));
  return s.set(o, n), e;
}
function Jn(e, t) {
  const n = W4(e), i = n.reduce((l, f) => l + f.byteLength, 0);
  let r, s, o, a = 0, c = -1;
  const u = Math.min(t || Number.POSITIVE_INFINITY, i);
  for (const l = n.length; ++c < l; ) {
    if (r = n[c], s = r.subarray(0, Math.min(r.length, u - a)), u <= a + s.length) {
      s.length < r.length ? n[c] = r.subarray(s.length) : s.length === r.length && c++, o ? ry(o, s, a) : o = s;
      break;
    }
    ry(o || (o = new Uint8Array(u)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), i - (o ? o.byteLength : 0)];
}
function Ct(e, t) {
  let n = ub(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = L0(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof R0 ? new e(n) : X4(n) ? Ct(e, n.bytes()) : ArrayBuffer.isView(n) ? n.byteLength <= 0 ? new e(0) : new e(n.buffer, n.byteOffset, n.byteLength / e.BYTES_PER_ELEMENT) : e.from(n)) : new e(0);
}
const zo = (e) => Ct(Int32Array, e), Tt = (e) => Ct(Uint8Array, e), fd = (e) => (e.next(), e);
function* H4(e, t) {
  const n = function* (r) {
    yield r;
  }, i = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof R0 ? n(t) : Yl(t) ? t : n(t);
  return yield* fd(function* (r) {
    let s = null;
    do
      s = r.next(yield Ct(e, s));
    while (!s.done);
  }(i[Symbol.iterator]())), new e();
}
const G4 = (e) => H4(Uint8Array, e);
function pb(e, t) {
  return Xn(this, arguments, function* () {
    if (ma(t))
      return yield ut(yield ut(yield* Hc(Cs(pb(e, yield ut(t))))));
    const i = function(o) {
      return Xn(this, arguments, function* () {
        yield yield ut(yield ut(o));
      });
    }, r = function(o) {
      return Xn(this, arguments, function* () {
        yield ut(yield* Hc(Cs(fd(function* (a) {
          let c = null;
          do
            c = a.next(yield c == null ? void 0 : c.value);
          while (!c.done);
        }(o[Symbol.iterator]())))));
      });
    }, s = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof R0 ? i(t) : Yl(t) ? r(t) : C0(t) ? t : i(t);
    return yield ut(
      // otherwise if AsyncIterable, use it
      yield* Hc(Cs(fd(function(o) {
        return Xn(this, arguments, function* () {
          let a = null;
          do
            a = yield ut(o.next(yield yield ut(Ct(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield ut(new e());
  });
}
const Z4 = (e) => pb(Uint8Array, e);
function K4(e, t) {
  let n = 0;
  const i = e.length;
  if (i !== t.length)
    return !1;
  if (i > 0)
    do
      if (e[n] !== t[n])
        return !1;
    while (++n < i);
  return !0;
}
const tn = {
  fromIterable(e) {
    return mc(J4(e));
  },
  fromAsyncIterable(e) {
    return mc(Q4(e));
  },
  fromDOMStream(e) {
    return mc(t8(e));
  },
  fromNodeStream(e) {
    return mc(n8(e));
  },
  // @ts-ignore
  toDOMStream(e, t) {
    throw new Error('"toDOMStream" not available in this environment');
  },
  // @ts-ignore
  toNodeStream(e, t) {
    throw new Error('"toNodeStream" not available in this environment');
  }
}, mc = (e) => (e.next(), e);
function* J4(e) {
  let t, n = !1, i = [], r, s, o, a = 0;
  function c() {
    return s === "peek" ? Jn(i, o)[0] : ([r, i, a] = Jn(i, o), r);
  }
  ({ cmd: s, size: o } = yield null);
  const u = G4(e)[Symbol.iterator]();
  try {
    do
      if ({ done: t, value: r } = Number.isNaN(o - a) ? u.next() : u.next(o - a), !t && r.byteLength > 0 && (i.push(r), a += r.byteLength), t || o <= a)
        do
          ({ cmd: s, size: o } = yield c());
        while (o < a);
    while (!t);
  } catch (l) {
    (n = !0) && typeof u.throw == "function" && u.throw(l);
  } finally {
    n === !1 && typeof u.return == "function" && u.return(null);
  }
  return null;
}
function Q4(e) {
  return Xn(this, arguments, function* () {
    let n, i = !1, r = [], s, o, a, c = 0;
    function u() {
      return o === "peek" ? Jn(r, a)[0] : ([s, r, c] = Jn(r, a), s);
    }
    ({ cmd: o, size: a } = yield yield ut(null));
    const l = Z4(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield ut(l.next()) : yield ut(l.next(a - c)), !n && s.byteLength > 0 && (r.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield ut(u()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && typeof l.throw == "function" && (yield ut(l.throw(f)));
    } finally {
      i === !1 && typeof l.return == "function" && (yield ut(l.return(new Uint8Array(0))));
    }
    return yield ut(null);
  });
}
function t8(e) {
  return Xn(this, arguments, function* () {
    let n = !1, i = !1, r = [], s, o, a, c = 0;
    function u() {
      return o === "peek" ? Jn(r, a)[0] : ([s, r, c] = Jn(r, a), s);
    }
    ({ cmd: o, size: a } = yield yield ut(null));
    const l = new e8(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield ut(l.read()) : yield ut(l.read(a - c)), !n && s.byteLength > 0 && (r.push(Tt(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield ut(u()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && (yield ut(l.cancel(f)));
    } finally {
      i === !1 ? yield ut(l.cancel()) : e.locked && l.releaseLock();
    }
    return yield ut(null);
  });
}
class e8 {
  constructor(t) {
    this.source = t, this.reader = null, this.reader = this.source.getReader(), this.reader.closed.catch(() => {
    });
  }
  get closed() {
    return this.reader ? this.reader.closed.catch(() => {
    }) : Promise.resolve();
  }
  releaseLock() {
    this.reader && this.reader.releaseLock(), this.reader = null;
  }
  cancel(t) {
    return J(this, void 0, void 0, function* () {
      const { reader: n, source: i } = this;
      n && (yield n.cancel(t).catch(() => {
      })), i && i.locked && this.releaseLock();
    });
  }
  read(t) {
    return J(this, void 0, void 0, function* () {
      if (t === 0)
        return { done: this.reader == null, value: new Uint8Array(0) };
      const n = yield this.reader.read();
      return !n.done && (n.value = Tt(n)), n;
    });
  }
}
const oh = (e, t) => {
  const n = (r) => i([t, r]);
  let i;
  return [t, n, new Promise((r) => (i = r) && e.once(t, n))];
};
function n8(e) {
  return Xn(this, arguments, function* () {
    const n = [];
    let i = "error", r = !1, s = null, o, a, c = 0, u = [], l;
    function f() {
      return o === "peek" ? Jn(u, a)[0] : ([l, u, c] = Jn(u, a), l);
    }
    if ({ cmd: o, size: a } = yield yield ut(null), e.isTTY)
      return yield yield ut(new Uint8Array(0)), yield ut(null);
    try {
      n[0] = oh(e, "end"), n[1] = oh(e, "error");
      do {
        if (n[2] = oh(e, "readable"), [i, s] = yield ut(Promise.race(n.map((d) => d[2]))), i === "error")
          break;
        if ((r = i === "end") || (Number.isFinite(a - c) ? (l = Tt(e.read(a - c)), l.byteLength < a - c && (l = Tt(e.read()))) : l = Tt(e.read()), l.byteLength > 0 && (u.push(l), c += l.byteLength)), r || a <= c)
          do
            ({ cmd: o, size: a } = yield yield ut(f()));
          while (a < c);
      } while (!r);
    } finally {
      yield ut(h(n, i === "error" ? s : null));
    }
    return yield ut(null);
    function h(d, p) {
      return l = u = null, new Promise((g, y) => {
        for (const [m, b] of d)
          e.off(m, b);
        try {
          const m = e.destroy;
          m && m.call(e, p), p = void 0;
        } catch (m) {
          p = m || p;
        } finally {
          p != null ? y(p) : g();
        }
      });
    }
  });
}
var rn;
(function(e) {
  e[e.V1 = 0] = "V1", e[e.V2 = 1] = "V2", e[e.V3 = 2] = "V3", e[e.V4 = 3] = "V4", e[e.V5 = 4] = "V5";
})(rn || (rn = {}));
var $n;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})($n || ($n = {}));
var Ce;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(Ce || (Ce = {}));
var Di;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Di || (Di = {}));
var At;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(At || (At = {}));
var tr;
(function(e) {
  e[e.YEAR_MONTH = 0] = "YEAR_MONTH", e[e.DAY_TIME = 1] = "DAY_TIME", e[e.MONTH_DAY_NANO = 2] = "MONTH_DAY_NANO";
})(tr || (tr = {}));
var Bt;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Schema = 1] = "Schema", e[e.DictionaryBatch = 2] = "DictionaryBatch", e[e.RecordBatch = 3] = "RecordBatch", e[e.Tensor = 4] = "Tensor", e[e.SparseTensor = 5] = "SparseTensor";
})(Bt || (Bt = {}));
var B;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Null = 1] = "Null", e[e.Int = 2] = "Int", e[e.Float = 3] = "Float", e[e.Binary = 4] = "Binary", e[e.Utf8 = 5] = "Utf8", e[e.Bool = 6] = "Bool", e[e.Decimal = 7] = "Decimal", e[e.Date = 8] = "Date", e[e.Time = 9] = "Time", e[e.Timestamp = 10] = "Timestamp", e[e.Interval = 11] = "Interval", e[e.List = 12] = "List", e[e.Struct = 13] = "Struct", e[e.Union = 14] = "Union", e[e.FixedSizeBinary = 15] = "FixedSizeBinary", e[e.FixedSizeList = 16] = "FixedSizeList", e[e.Map = 17] = "Map", e[e.Dictionary = -1] = "Dictionary", e[e.Int8 = -2] = "Int8", e[e.Int16 = -3] = "Int16", e[e.Int32 = -4] = "Int32", e[e.Int64 = -5] = "Int64", e[e.Uint8 = -6] = "Uint8", e[e.Uint16 = -7] = "Uint16", e[e.Uint32 = -8] = "Uint32", e[e.Uint64 = -9] = "Uint64", e[e.Float16 = -10] = "Float16", e[e.Float32 = -11] = "Float32", e[e.Float64 = -12] = "Float64", e[e.DateDay = -13] = "DateDay", e[e.DateMillisecond = -14] = "DateMillisecond", e[e.TimestampSecond = -15] = "TimestampSecond", e[e.TimestampMillisecond = -16] = "TimestampMillisecond", e[e.TimestampMicrosecond = -17] = "TimestampMicrosecond", e[e.TimestampNanosecond = -18] = "TimestampNanosecond", e[e.TimeSecond = -19] = "TimeSecond", e[e.TimeMillisecond = -20] = "TimeMillisecond", e[e.TimeMicrosecond = -21] = "TimeMicrosecond", e[e.TimeNanosecond = -22] = "TimeNanosecond", e[e.DenseUnion = -23] = "DenseUnion", e[e.SparseUnion = -24] = "SparseUnion", e[e.IntervalDayTime = -25] = "IntervalDayTime", e[e.IntervalYearMonth = -26] = "IntervalYearMonth";
})(B || (B = {}));
var gi;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(gi || (gi = {}));
const i8 = void 0;
function ya(e) {
  if (e === null)
    return "null";
  if (e === i8)
    return "undefined";
  switch (typeof e) {
    case "number":
      return `${e}`;
    case "bigint":
      return `${e}`;
    case "string":
      return `"${e}"`;
  }
  return typeof e[Symbol.toPrimitive] == "function" ? e[Symbol.toPrimitive]("string") : ArrayBuffer.isView(e) ? e instanceof Ya || e instanceof qa ? `[${[...e].map((t) => ya(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const r8 = Symbol.for("isArrowBigNum");
function Nn(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(Ct(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
Nn.prototype[r8] = !0;
Nn.prototype.toJSON = function() {
  return `"${Yr(this)}"`;
};
Nn.prototype.valueOf = function() {
  return mb(this);
};
Nn.prototype.toString = function() {
  return Yr(this);
};
Nn.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return mb(this);
    case "string":
      return Yr(this);
    case "default":
      return hd(this);
  }
  return Yr(this);
};
function ks(...e) {
  return Nn.apply(this, e);
}
function Rs(...e) {
  return Nn.apply(this, e);
}
function ga(...e) {
  return Nn.apply(this, e);
}
Object.setPrototypeOf(ks.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(Rs.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(ga.prototype, Object.create(Uint32Array.prototype));
Object.assign(ks.prototype, Nn.prototype, { constructor: ks, signed: !0, TypedArray: Int32Array, BigIntArray: Ya });
Object.assign(Rs.prototype, Nn.prototype, { constructor: Rs, signed: !1, TypedArray: Uint32Array, BigIntArray: qa });
Object.assign(ga.prototype, Nn.prototype, { constructor: ga, signed: !0, TypedArray: Uint32Array, BigIntArray: qa });
function mb(e) {
  const { buffer: t, byteOffset: n, length: i, signed: r } = e, s = new qa(t, n, i), o = r && s[s.length - 1] & BigInt(1) << BigInt(63);
  let a = BigInt(o ? 1 : 0), c = BigInt(0);
  if (o) {
    for (const u of s)
      a += ~u * (BigInt(1) << BigInt(32) * c++);
    a *= BigInt(-1);
  } else
    for (const u of s)
      a += u * (BigInt(1) << BigInt(32) * c++);
  return a;
}
let Yr, hd;
q4 ? (hd = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : ah(e), Yr = (e) => e.byteLength === 8 ? `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}` : ah(e)) : (Yr = ah, hd = Yr);
function ah(e) {
  let t = "";
  const n = new Uint32Array(2);
  let i = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  const r = new Uint32Array((i = new Uint16Array(i).reverse()).buffer);
  let s = -1;
  const o = i.length - 1;
  do {
    for (n[0] = i[s = 0]; s < o; )
      i[s++] = n[1] = n[0] / 10, n[0] = (n[0] - n[1] * 10 << 16) + i[s];
    i[s] = n[1] = n[0] / 10, n[0] = n[0] - n[1] * 10, t = `${n[0]}${t}`;
  } while (r[0] || r[1] || r[2] || r[3]);
  return t ?? "0";
}
class U0 {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new ks(t);
      case !1:
        return new Rs(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case Ya:
        return new ks(t);
    }
    return t.byteLength === 16 ? new ga(t) : new Rs(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new ks(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new Rs(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new ga(t);
  }
  constructor(t, n) {
    return U0.new(t, n);
  }
}
var yb, gb, bb, wb, _b, vb, xb, Sb, Mb, Ab, $b, Ib, Tb, Eb, Nb, Ob, Fb, Db, Bb;
class at {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === B.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === B.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === B.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === B.Binary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === B.Utf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === B.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === B.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === B.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === B.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === B.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === B.Interval;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === B.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === B.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === B.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === B.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === B.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === B.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === B.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return at.isUnion(t) && t.mode === $n.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return at.isUnion(t) && t.mode === $n.Sparse;
  }
  get typeId() {
    return B.NONE;
  }
}
yb = Symbol.toStringTag;
at[yb] = ((e) => (e.children = null, e.ArrayType = Array, e[Symbol.toStringTag] = "DataType"))(at.prototype);
let er = class extends at {
  toString() {
    return "Null";
  }
  get typeId() {
    return B.Null;
  }
};
gb = Symbol.toStringTag;
er[gb] = ((e) => e[Symbol.toStringTag] = "Null")(er.prototype);
class nr extends at {
  constructor(t, n) {
    super(), this.isSigned = t, this.bitWidth = n;
  }
  get typeId() {
    return B.Int;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 8:
        return this.isSigned ? Int8Array : Uint8Array;
      case 16:
        return this.isSigned ? Int16Array : Uint16Array;
      case 32:
        return this.isSigned ? Int32Array : Uint32Array;
      case 64:
        return this.isSigned ? Ya : qa;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
}
bb = Symbol.toStringTag;
nr[bb] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(nr.prototype);
class ba extends nr {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
}
Object.defineProperty(ba.prototype, "ArrayType", { value: Int32Array });
class wa extends at {
  constructor(t) {
    super(), this.precision = t;
  }
  get typeId() {
    return B.Float;
  }
  get ArrayType() {
    switch (this.precision) {
      case Ce.HALF:
        return Uint16Array;
      case Ce.SINGLE:
        return Float32Array;
      case Ce.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
}
wb = Symbol.toStringTag;
wa[wb] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(wa.prototype);
let lu = class extends at {
  constructor() {
    super();
  }
  get typeId() {
    return B.Binary;
  }
  toString() {
    return "Binary";
  }
};
_b = Symbol.toStringTag;
lu[_b] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(lu.prototype);
let fu = class extends at {
  constructor() {
    super();
  }
  get typeId() {
    return B.Utf8;
  }
  toString() {
    return "Utf8";
  }
};
vb = Symbol.toStringTag;
fu[vb] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(fu.prototype);
let hu = class extends at {
  constructor() {
    super();
  }
  get typeId() {
    return B.Bool;
  }
  toString() {
    return "Bool";
  }
};
xb = Symbol.toStringTag;
hu[xb] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(hu.prototype);
let du = class extends at {
  constructor(t, n, i = 128) {
    super(), this.scale = t, this.precision = n, this.bitWidth = i;
  }
  get typeId() {
    return B.Decimal;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
};
Sb = Symbol.toStringTag;
du[Sb] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(du.prototype);
class pu extends at {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return B.Date;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${Di[this.unit]}>`;
  }
}
Mb = Symbol.toStringTag;
pu[Mb] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(pu.prototype);
class _a extends at {
  constructor(t, n) {
    super(), this.unit = t, this.bitWidth = n;
  }
  get typeId() {
    return B.Time;
  }
  toString() {
    return `Time${this.bitWidth}<${At[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return Ya;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
}
Ab = Symbol.toStringTag;
_a[Ab] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(_a.prototype);
class mu extends at {
  constructor(t, n) {
    super(), this.unit = t, this.timezone = n;
  }
  get typeId() {
    return B.Timestamp;
  }
  toString() {
    return `Timestamp<${At[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
}
$b = Symbol.toStringTag;
mu[$b] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(mu.prototype);
class yu extends at {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return B.Interval;
  }
  toString() {
    return `Interval<${tr[this.unit]}>`;
  }
}
Ib = Symbol.toStringTag;
yu[Ib] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(yu.prototype);
let gu = class extends at {
  constructor(t) {
    super(), this.children = [t];
  }
  get typeId() {
    return B.List;
  }
  toString() {
    return `List<${this.valueType}>`;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
};
Tb = Symbol.toStringTag;
gu[Tb] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(gu.prototype);
class Ee extends at {
  constructor(t) {
    super(), this.children = t;
  }
  get typeId() {
    return B.Struct;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
Eb = Symbol.toStringTag;
Ee[Eb] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(Ee.prototype);
class bu extends at {
  constructor(t, n, i) {
    super(), this.mode = t, this.children = i, this.typeIds = n = Int32Array.from(n), this.typeIdToChildIndex = n.reduce((r, s, o) => (r[s] = o) && r || r, /* @__PURE__ */ Object.create(null));
  }
  get typeId() {
    return B.Union;
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
}
Nb = Symbol.toStringTag;
bu[Nb] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(bu.prototype);
let wu = class extends at {
  constructor(t) {
    super(), this.byteWidth = t;
  }
  get typeId() {
    return B.FixedSizeBinary;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
};
Ob = Symbol.toStringTag;
wu[Ob] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(wu.prototype);
let _u = class extends at {
  constructor(t, n) {
    super(), this.listSize = t, this.children = [n];
  }
  get typeId() {
    return B.FixedSizeList;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
  toString() {
    return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
  }
};
Fb = Symbol.toStringTag;
_u[Fb] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(_u.prototype);
class vu extends at {
  constructor(t, n = !1) {
    super(), this.children = [t], this.keysSorted = n;
  }
  get typeId() {
    return B.Map;
  }
  get keyType() {
    return this.children[0].type.children[0].type;
  }
  get valueType() {
    return this.children[0].type.children[1].type;
  }
  get childType() {
    return this.children[0].type;
  }
  toString() {
    return `Map<{${this.children[0].type.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
Db = Symbol.toStringTag;
vu[Db] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(vu.prototype);
const s8 = ((e) => () => ++e)(-1);
class Gs extends at {
  constructor(t, n, i, r) {
    super(), this.indices = n, this.dictionary = t, this.isOrdered = r || !1, this.id = i == null ? s8() : typeof i == "number" ? i : i.low;
  }
  get typeId() {
    return B.Dictionary;
  }
  get children() {
    return this.dictionary.children;
  }
  get valueType() {
    return this.dictionary;
  }
  get ArrayType() {
    return this.dictionary.ArrayType;
  }
  toString() {
    return `Dictionary<${this.indices}, ${this.dictionary}>`;
  }
}
Bb = Symbol.toStringTag;
Gs[Bb] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(Gs.prototype);
function bi(e) {
  const t = e;
  switch (e.typeId) {
    case B.Decimal:
      return e.bitWidth / 32;
    case B.Timestamp:
      return 2;
    case B.Date:
      return 1 + t.unit;
    case B.Interval:
      return 1 + t.unit;
    case B.FixedSizeList:
      return t.listSize;
    case B.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
class xt {
  visitMany(t, ...n) {
    return t.map((i, r) => this.visit(i, ...n.map((s) => s[r])));
  }
  visit(...t) {
    return this.getVisitFn(t[0], !1).apply(this, t);
  }
  getVisitFn(t, n = !0) {
    return o8(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return xs(this, t, n);
  }
  visitNull(t, ...n) {
    return null;
  }
  visitBool(t, ...n) {
    return null;
  }
  visitInt(t, ...n) {
    return null;
  }
  visitFloat(t, ...n) {
    return null;
  }
  visitUtf8(t, ...n) {
    return null;
  }
  visitBinary(t, ...n) {
    return null;
  }
  visitFixedSizeBinary(t, ...n) {
    return null;
  }
  visitDate(t, ...n) {
    return null;
  }
  visitTimestamp(t, ...n) {
    return null;
  }
  visitTime(t, ...n) {
    return null;
  }
  visitDecimal(t, ...n) {
    return null;
  }
  visitList(t, ...n) {
    return null;
  }
  visitStruct(t, ...n) {
    return null;
  }
  visitUnion(t, ...n) {
    return null;
  }
  visitDictionary(t, ...n) {
    return null;
  }
  visitInterval(t, ...n) {
    return null;
  }
  visitFixedSizeList(t, ...n) {
    return null;
  }
  visitMap(t, ...n) {
    return null;
  }
}
function o8(e, t, n = !0) {
  return typeof t == "number" ? xs(e, t, n) : typeof t == "string" && t in B ? xs(e, B[t], n) : t && t instanceof at ? xs(e, sy(t), n) : t != null && t.type && t.type instanceof at ? xs(e, sy(t.type), n) : xs(e, B.NONE, n);
}
function xs(e, t, n = !0) {
  let i = null;
  switch (t) {
    case B.Null:
      i = e.visitNull;
      break;
    case B.Bool:
      i = e.visitBool;
      break;
    case B.Int:
      i = e.visitInt;
      break;
    case B.Int8:
      i = e.visitInt8 || e.visitInt;
      break;
    case B.Int16:
      i = e.visitInt16 || e.visitInt;
      break;
    case B.Int32:
      i = e.visitInt32 || e.visitInt;
      break;
    case B.Int64:
      i = e.visitInt64 || e.visitInt;
      break;
    case B.Uint8:
      i = e.visitUint8 || e.visitInt;
      break;
    case B.Uint16:
      i = e.visitUint16 || e.visitInt;
      break;
    case B.Uint32:
      i = e.visitUint32 || e.visitInt;
      break;
    case B.Uint64:
      i = e.visitUint64 || e.visitInt;
      break;
    case B.Float:
      i = e.visitFloat;
      break;
    case B.Float16:
      i = e.visitFloat16 || e.visitFloat;
      break;
    case B.Float32:
      i = e.visitFloat32 || e.visitFloat;
      break;
    case B.Float64:
      i = e.visitFloat64 || e.visitFloat;
      break;
    case B.Utf8:
      i = e.visitUtf8;
      break;
    case B.Binary:
      i = e.visitBinary;
      break;
    case B.FixedSizeBinary:
      i = e.visitFixedSizeBinary;
      break;
    case B.Date:
      i = e.visitDate;
      break;
    case B.DateDay:
      i = e.visitDateDay || e.visitDate;
      break;
    case B.DateMillisecond:
      i = e.visitDateMillisecond || e.visitDate;
      break;
    case B.Timestamp:
      i = e.visitTimestamp;
      break;
    case B.TimestampSecond:
      i = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case B.TimestampMillisecond:
      i = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case B.TimestampMicrosecond:
      i = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case B.TimestampNanosecond:
      i = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case B.Time:
      i = e.visitTime;
      break;
    case B.TimeSecond:
      i = e.visitTimeSecond || e.visitTime;
      break;
    case B.TimeMillisecond:
      i = e.visitTimeMillisecond || e.visitTime;
      break;
    case B.TimeMicrosecond:
      i = e.visitTimeMicrosecond || e.visitTime;
      break;
    case B.TimeNanosecond:
      i = e.visitTimeNanosecond || e.visitTime;
      break;
    case B.Decimal:
      i = e.visitDecimal;
      break;
    case B.List:
      i = e.visitList;
      break;
    case B.Struct:
      i = e.visitStruct;
      break;
    case B.Union:
      i = e.visitUnion;
      break;
    case B.DenseUnion:
      i = e.visitDenseUnion || e.visitUnion;
      break;
    case B.SparseUnion:
      i = e.visitSparseUnion || e.visitUnion;
      break;
    case B.Dictionary:
      i = e.visitDictionary;
      break;
    case B.Interval:
      i = e.visitInterval;
      break;
    case B.IntervalDayTime:
      i = e.visitIntervalDayTime || e.visitInterval;
      break;
    case B.IntervalYearMonth:
      i = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case B.FixedSizeList:
      i = e.visitFixedSizeList;
      break;
    case B.Map:
      i = e.visitMap;
      break;
  }
  if (typeof i == "function")
    return i;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${B[t]}'`);
}
function sy(e) {
  switch (e.typeId) {
    case B.Null:
      return B.Null;
    case B.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? B.Int8 : B.Uint8;
        case 16:
          return n ? B.Int16 : B.Uint16;
        case 32:
          return n ? B.Int32 : B.Uint32;
        case 64:
          return n ? B.Int64 : B.Uint64;
      }
      return B.Int;
    }
    case B.Float:
      switch (e.precision) {
        case Ce.HALF:
          return B.Float16;
        case Ce.SINGLE:
          return B.Float32;
        case Ce.DOUBLE:
          return B.Float64;
      }
      return B.Float;
    case B.Binary:
      return B.Binary;
    case B.Utf8:
      return B.Utf8;
    case B.Bool:
      return B.Bool;
    case B.Decimal:
      return B.Decimal;
    case B.Time:
      switch (e.unit) {
        case At.SECOND:
          return B.TimeSecond;
        case At.MILLISECOND:
          return B.TimeMillisecond;
        case At.MICROSECOND:
          return B.TimeMicrosecond;
        case At.NANOSECOND:
          return B.TimeNanosecond;
      }
      return B.Time;
    case B.Timestamp:
      switch (e.unit) {
        case At.SECOND:
          return B.TimestampSecond;
        case At.MILLISECOND:
          return B.TimestampMillisecond;
        case At.MICROSECOND:
          return B.TimestampMicrosecond;
        case At.NANOSECOND:
          return B.TimestampNanosecond;
      }
      return B.Timestamp;
    case B.Date:
      switch (e.unit) {
        case Di.DAY:
          return B.DateDay;
        case Di.MILLISECOND:
          return B.DateMillisecond;
      }
      return B.Date;
    case B.Interval:
      switch (e.unit) {
        case tr.DAY_TIME:
          return B.IntervalDayTime;
        case tr.YEAR_MONTH:
          return B.IntervalYearMonth;
      }
      return B.Interval;
    case B.Map:
      return B.Map;
    case B.List:
      return B.List;
    case B.Struct:
      return B.Struct;
    case B.Union:
      switch (e.mode) {
        case $n.Dense:
          return B.DenseUnion;
        case $n.Sparse:
          return B.SparseUnion;
      }
      return B.Union;
    case B.FixedSizeBinary:
      return B.FixedSizeBinary;
    case B.FixedSizeList:
      return B.FixedSizeList;
    case B.Dictionary:
      return B.Dictionary;
  }
  throw new Error(`Unrecognized type '${B[e.typeId]}'`);
}
xt.prototype.visitInt8 = null;
xt.prototype.visitInt16 = null;
xt.prototype.visitInt32 = null;
xt.prototype.visitInt64 = null;
xt.prototype.visitUint8 = null;
xt.prototype.visitUint16 = null;
xt.prototype.visitUint32 = null;
xt.prototype.visitUint64 = null;
xt.prototype.visitFloat16 = null;
xt.prototype.visitFloat32 = null;
xt.prototype.visitFloat64 = null;
xt.prototype.visitDateDay = null;
xt.prototype.visitDateMillisecond = null;
xt.prototype.visitTimestampSecond = null;
xt.prototype.visitTimestampMillisecond = null;
xt.prototype.visitTimestampMicrosecond = null;
xt.prototype.visitTimestampNanosecond = null;
xt.prototype.visitTimeSecond = null;
xt.prototype.visitTimeMillisecond = null;
xt.prototype.visitTimeMicrosecond = null;
xt.prototype.visitTimeNanosecond = null;
xt.prototype.visitDenseUnion = null;
xt.prototype.visitSparseUnion = null;
xt.prototype.visitIntervalDayTime = null;
xt.prototype.visitIntervalYearMonth = null;
const Lb = new Float64Array(1), ls = new Uint32Array(Lb.buffer);
function Cb(e) {
  const t = (e & 31744) >> 10, n = (e & 1023) / 1024, i = Math.pow(-1, (e & 32768) >> 15);
  switch (t) {
    case 31:
      return i * (n ? Number.NaN : 1 / 0);
    case 0:
      return i * (n ? 6103515625e-14 * n : 0);
  }
  return i * Math.pow(2, t - 15) * (1 + n);
}
function a8(e) {
  if (e !== e)
    return 32256;
  Lb[0] = e;
  const t = (ls[1] & 2147483648) >> 16 & 65535;
  let n = ls[1] & 2146435072, i = 0;
  return n >= 1089470464 ? ls[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, i = (ls[1] & 1048575) >> 10) : n <= 1056964608 ? (i = 1048576 + (ls[1] & 1048575), i = 1048576 + (i << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, i = (ls[1] & 1048575) + 512 >> 10), t | n | i & 65535;
}
class rt extends xt {
}
function ct(e) {
  return (t, n, i) => {
    if (t.setValid(n, i != null))
      return e(t, n, i);
  };
}
const c8 = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, z0 = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, u8 = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, l8 = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, kb = (e, t, n, i) => {
  if (n + 1 < t.length) {
    const { [n]: r, [n + 1]: s } = t;
    e.set(i.subarray(0, s - r), r);
  }
}, f8 = ({ offset: e, values: t }, n, i) => {
  const r = e + n;
  i ? t[r >> 3] |= 1 << r % 8 : t[r >> 3] &= ~(1 << r % 8);
}, zi = ({ values: e }, t, n) => {
  e[t] = n;
}, P0 = ({ values: e }, t, n) => {
  e[t] = n;
}, Rb = ({ values: e }, t, n) => {
  e[t] = a8(n);
}, h8 = (e, t, n) => {
  switch (e.type.precision) {
    case Ce.HALF:
      return Rb(e, t, n);
    case Ce.SINGLE:
    case Ce.DOUBLE:
      return P0(e, t, n);
  }
}, Ub = ({ values: e }, t, n) => {
  c8(e, t, n.valueOf());
}, zb = ({ values: e }, t, n) => {
  z0(e, t * 2, n.valueOf());
}, d8 = ({ stride: e, values: t }, n, i) => {
  t.set(i.subarray(0, e), e * n);
}, p8 = ({ values: e, valueOffsets: t }, n, i) => kb(e, t, n, i), m8 = ({ values: e, valueOffsets: t }, n, i) => {
  kb(e, t, n, L0(i));
}, y8 = (e, t, n) => {
  e.type.unit === Di.DAY ? Ub(e, t, n) : zb(e, t, n);
}, Pb = ({ values: e }, t, n) => z0(e, t * 2, n / 1e3), Yb = ({ values: e }, t, n) => z0(e, t * 2, n), qb = ({ values: e }, t, n) => u8(e, t * 2, n), Vb = ({ values: e }, t, n) => l8(e, t * 2, n), g8 = (e, t, n) => {
  switch (e.type.unit) {
    case At.SECOND:
      return Pb(e, t, n);
    case At.MILLISECOND:
      return Yb(e, t, n);
    case At.MICROSECOND:
      return qb(e, t, n);
    case At.NANOSECOND:
      return Vb(e, t, n);
  }
}, jb = ({ values: e }, t, n) => {
  e[t] = n;
}, Xb = ({ values: e }, t, n) => {
  e[t] = n;
}, Wb = ({ values: e }, t, n) => {
  e[t] = n;
}, Hb = ({ values: e }, t, n) => {
  e[t] = n;
}, b8 = (e, t, n) => {
  switch (e.type.unit) {
    case At.SECOND:
      return jb(e, t, n);
    case At.MILLISECOND:
      return Xb(e, t, n);
    case At.MICROSECOND:
      return Wb(e, t, n);
    case At.NANOSECOND:
      return Hb(e, t, n);
  }
}, w8 = ({ values: e, stride: t }, n, i) => {
  e.set(i.subarray(0, t), t * n);
}, _8 = (e, t, n) => {
  const i = e.children[0], r = e.valueOffsets, s = hn.getVisitFn(i);
  if (Array.isArray(n))
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n[++o]);
  else
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n.get(++o));
}, v8 = (e, t, n) => {
  const i = e.children[0], { valueOffsets: r } = e, s = hn.getVisitFn(i);
  let { [t]: o, [t + 1]: a } = r;
  const c = n instanceof Map ? n.entries() : Object.entries(n);
  for (const u of c)
    if (s(i, o, u), ++o >= a)
      break;
}, x8 = (e, t) => (n, i, r, s) => i && n(i, e, t[s]), S8 = (e, t) => (n, i, r, s) => i && n(i, e, t.get(s)), M8 = (e, t) => (n, i, r, s) => i && n(i, e, t.get(r.name)), A8 = (e, t) => (n, i, r, s) => i && n(i, e, t[r.name]), $8 = (e, t, n) => {
  const i = e.type.children.map((s) => hn.getVisitFn(s.type)), r = n instanceof Map ? M8(t, n) : n instanceof ee ? S8(t, n) : Array.isArray(n) ? x8(t, n) : A8(t, n);
  e.type.children.forEach((s, o) => r(i[o], e.children[o], s, o));
}, I8 = (e, t, n) => {
  e.type.mode === $n.Dense ? Gb(e, t, n) : Zb(e, t, n);
}, Gb = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  hn.visit(r, e.valueOffsets[t], n);
}, Zb = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  hn.visit(r, t, n);
}, T8 = (e, t, n) => {
  var i;
  (i = e.dictionary) === null || i === void 0 || i.set(e.values[t], n);
}, E8 = (e, t, n) => {
  e.type.unit === tr.DAY_TIME ? Kb(e, t, n) : Jb(e, t, n);
}, Kb = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, Jb = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, N8 = (e, t, n) => {
  const { stride: i } = e, r = e.children[0], s = hn.getVisitFn(r);
  if (Array.isArray(n))
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n[o]);
  else
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n.get(o));
};
rt.prototype.visitBool = ct(f8);
rt.prototype.visitInt = ct(zi);
rt.prototype.visitInt8 = ct(zi);
rt.prototype.visitInt16 = ct(zi);
rt.prototype.visitInt32 = ct(zi);
rt.prototype.visitInt64 = ct(zi);
rt.prototype.visitUint8 = ct(zi);
rt.prototype.visitUint16 = ct(zi);
rt.prototype.visitUint32 = ct(zi);
rt.prototype.visitUint64 = ct(zi);
rt.prototype.visitFloat = ct(h8);
rt.prototype.visitFloat16 = ct(Rb);
rt.prototype.visitFloat32 = ct(P0);
rt.prototype.visitFloat64 = ct(P0);
rt.prototype.visitUtf8 = ct(m8);
rt.prototype.visitBinary = ct(p8);
rt.prototype.visitFixedSizeBinary = ct(d8);
rt.prototype.visitDate = ct(y8);
rt.prototype.visitDateDay = ct(Ub);
rt.prototype.visitDateMillisecond = ct(zb);
rt.prototype.visitTimestamp = ct(g8);
rt.prototype.visitTimestampSecond = ct(Pb);
rt.prototype.visitTimestampMillisecond = ct(Yb);
rt.prototype.visitTimestampMicrosecond = ct(qb);
rt.prototype.visitTimestampNanosecond = ct(Vb);
rt.prototype.visitTime = ct(b8);
rt.prototype.visitTimeSecond = ct(jb);
rt.prototype.visitTimeMillisecond = ct(Xb);
rt.prototype.visitTimeMicrosecond = ct(Wb);
rt.prototype.visitTimeNanosecond = ct(Hb);
rt.prototype.visitDecimal = ct(w8);
rt.prototype.visitList = ct(_8);
rt.prototype.visitStruct = ct($8);
rt.prototype.visitUnion = ct(I8);
rt.prototype.visitDenseUnion = ct(Gb);
rt.prototype.visitSparseUnion = ct(Zb);
rt.prototype.visitDictionary = ct(T8);
rt.prototype.visitInterval = ct(E8);
rt.prototype.visitIntervalDayTime = ct(Kb);
rt.prototype.visitIntervalYearMonth = ct(Jb);
rt.prototype.visitFixedSizeList = ct(N8);
rt.prototype.visitMap = ct(v8);
const hn = new rt(), gn = Symbol.for("parent"), Us = Symbol.for("rowIndex");
class Y0 {
  constructor(t, n) {
    return this[gn] = t, this[Us] = n, new Proxy(this, new F8());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[Us], n = this[gn], i = n.type.children, r = {};
    for (let s = -1, o = i.length; ++s < o; )
      r[i[s].name] = ke.visit(n.children[s], t);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${ya(t)}: ${ya(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new O8(this[gn], this[Us]);
  }
}
class O8 {
  constructor(t, n) {
    this.childIndex = 0, this.children = t.children, this.rowIndex = n, this.childFields = t.type.children, this.numChildren = this.childFields.length;
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    const t = this.childIndex;
    return t < this.numChildren ? (this.childIndex = t + 1, {
      done: !1,
      value: [
        this.childFields[t].name,
        ke.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
}
Object.defineProperties(Y0.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [gn]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [Us]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
class F8 {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[gn].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[gn].type.children.findIndex((i) => i.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[gn].type.children.findIndex((i) => i.name === n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[gn].type.children.findIndex((r) => r.name === n);
    if (i !== -1) {
      const r = ke.visit(t[gn].children[i], t[Us]);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[gn].type.children.findIndex((s) => s.name === n);
    return r !== -1 ? (hn.visit(t[gn].children[r], t[Us], i), Reflect.set(t, n, i)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, i) : !1;
  }
}
class Q extends xt {
}
function st(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const D8 = (e, t) => 864e5 * e[t], q0 = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), B8 = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, L8 = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, Qb = (e) => new Date(e), C8 = (e, t) => Qb(D8(e, t)), k8 = (e, t) => Qb(q0(e, t)), R8 = (e, t) => null, t2 = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const i = t[n], r = t[n + 1];
  return e.subarray(i, r);
}, U8 = ({ offset: e, values: t }, n) => {
  const i = e + n;
  return (t[i >> 3] & 1 << i % 8) !== 0;
}, e2 = ({ values: e }, t) => C8(e, t), n2 = ({ values: e }, t) => k8(e, t * 2), hr = ({ stride: e, values: t }, n) => t[e * n], z8 = ({ stride: e, values: t }, n) => Cb(t[e * n]), i2 = ({ values: e }, t) => e[t], P8 = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), Y8 = ({ values: e, valueOffsets: t }, n) => t2(e, t, n), q8 = ({ values: e, valueOffsets: t }, n) => {
  const i = t2(e, t, n);
  return i !== null ? ud(i) : null;
}, V8 = ({ values: e }, t) => e[t], j8 = ({ type: e, values: t }, n) => e.precision !== Ce.HALF ? t[n] : Cb(t[n]), X8 = (e, t) => e.type.unit === Di.DAY ? e2(e, t) : n2(e, t), r2 = ({ values: e }, t) => 1e3 * q0(e, t * 2), s2 = ({ values: e }, t) => q0(e, t * 2), o2 = ({ values: e }, t) => B8(e, t * 2), a2 = ({ values: e }, t) => L8(e, t * 2), W8 = (e, t) => {
  switch (e.type.unit) {
    case At.SECOND:
      return r2(e, t);
    case At.MILLISECOND:
      return s2(e, t);
    case At.MICROSECOND:
      return o2(e, t);
    case At.NANOSECOND:
      return a2(e, t);
  }
}, c2 = ({ values: e }, t) => e[t], u2 = ({ values: e }, t) => e[t], l2 = ({ values: e }, t) => e[t], f2 = ({ values: e }, t) => e[t], H8 = (e, t) => {
  switch (e.type.unit) {
    case At.SECOND:
      return c2(e, t);
    case At.MILLISECOND:
      return u2(e, t);
    case At.MICROSECOND:
      return l2(e, t);
    case At.NANOSECOND:
      return f2(e, t);
  }
}, G8 = ({ values: e, stride: t }, n) => U0.decimal(e.subarray(t * n, t * (n + 1))), Z8 = (e, t) => {
  const { valueOffsets: n, stride: i, children: r } = e, { [t * i]: s, [t * i + 1]: o } = n, c = r[0].slice(s, o - s);
  return new ee([c]);
}, K8 = (e, t) => {
  const { valueOffsets: n, children: i } = e, { [t]: r, [t + 1]: s } = n, o = i[0];
  return new V0(o.slice(r, s - r));
}, J8 = (e, t) => new Y0(e, t), Q8 = (e, t) => e.type.mode === $n.Dense ? h2(e, t) : d2(e, t), h2 = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return ke.visit(i, e.valueOffsets[t]);
}, d2 = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return ke.visit(i, t);
}, tM = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, eM = (e, t) => e.type.unit === tr.DAY_TIME ? p2(e, t) : m2(e, t), p2 = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), m2 = ({ values: e }, t) => {
  const n = e[t], i = new Int32Array(2);
  return i[0] = Math.trunc(n / 12), i[1] = Math.trunc(n % 12), i;
}, nM = (e, t) => {
  const { stride: n, children: i } = e, s = i[0].slice(t * n, n);
  return new ee([s]);
};
Q.prototype.visitNull = st(R8);
Q.prototype.visitBool = st(U8);
Q.prototype.visitInt = st(V8);
Q.prototype.visitInt8 = st(hr);
Q.prototype.visitInt16 = st(hr);
Q.prototype.visitInt32 = st(hr);
Q.prototype.visitInt64 = st(i2);
Q.prototype.visitUint8 = st(hr);
Q.prototype.visitUint16 = st(hr);
Q.prototype.visitUint32 = st(hr);
Q.prototype.visitUint64 = st(i2);
Q.prototype.visitFloat = st(j8);
Q.prototype.visitFloat16 = st(z8);
Q.prototype.visitFloat32 = st(hr);
Q.prototype.visitFloat64 = st(hr);
Q.prototype.visitUtf8 = st(q8);
Q.prototype.visitBinary = st(Y8);
Q.prototype.visitFixedSizeBinary = st(P8);
Q.prototype.visitDate = st(X8);
Q.prototype.visitDateDay = st(e2);
Q.prototype.visitDateMillisecond = st(n2);
Q.prototype.visitTimestamp = st(W8);
Q.prototype.visitTimestampSecond = st(r2);
Q.prototype.visitTimestampMillisecond = st(s2);
Q.prototype.visitTimestampMicrosecond = st(o2);
Q.prototype.visitTimestampNanosecond = st(a2);
Q.prototype.visitTime = st(H8);
Q.prototype.visitTimeSecond = st(c2);
Q.prototype.visitTimeMillisecond = st(u2);
Q.prototype.visitTimeMicrosecond = st(l2);
Q.prototype.visitTimeNanosecond = st(f2);
Q.prototype.visitDecimal = st(G8);
Q.prototype.visitList = st(Z8);
Q.prototype.visitStruct = st(J8);
Q.prototype.visitUnion = st(Q8);
Q.prototype.visitDenseUnion = st(h2);
Q.prototype.visitSparseUnion = st(d2);
Q.prototype.visitDictionary = st(tM);
Q.prototype.visitInterval = st(eM);
Q.prototype.visitIntervalDayTime = st(p2);
Q.prototype.visitIntervalYearMonth = st(m2);
Q.prototype.visitFixedSizeList = st(nM);
Q.prototype.visitMap = st(K8);
const ke = new Q(), Rn = Symbol.for("keys"), zs = Symbol.for("vals");
class V0 {
  constructor(t) {
    return this[Rn] = new ee([t.children[0]]).memoize(), this[zs] = t.children[1], new Proxy(this, new rM());
  }
  [Symbol.iterator]() {
    return new iM(this[Rn], this[zs]);
  }
  get size() {
    return this[Rn].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[Rn], n = this[zs], i = {};
    for (let r = -1, s = t.length; ++r < s; )
      i[t.get(r)] = ke.visit(n, r);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${ya(t)}: ${ya(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}
class iM {
  constructor(t, n) {
    this.keys = t, this.vals = n, this.keyIndex = 0, this.numKeys = t.length;
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    const t = this.keyIndex;
    return t === this.numKeys ? { done: !0, value: null } : (this.keyIndex++, {
      done: !1,
      value: [
        this.keys.get(t),
        ke.visit(this.vals, t)
      ]
    });
  }
}
class rM {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[Rn].toArray().map(String);
  }
  has(t, n) {
    return t[Rn].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[Rn].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[Rn].indexOf(n);
    if (i !== -1) {
      const r = ke.visit(Reflect.get(t, zs), i);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[Rn].indexOf(n);
    return r !== -1 ? (hn.visit(Reflect.get(t, zs), r, i), Reflect.set(t, n, i)) : Reflect.has(t, n) ? Reflect.set(t, n, i) : !1;
  }
}
Object.defineProperties(V0.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [Rn]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [zs]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let oy;
function y2(e, t, n, i) {
  const { length: r = 0 } = e;
  let s = typeof t != "number" ? 0 : t, o = typeof n != "number" ? r : n;
  return s < 0 && (s = (s % r + r) % r), o < 0 && (o = (o % r + r) % r), o < s && (oy = s, s = o, o = oy), o > r && (o = r), i ? i(e, s, o) : [s, o];
}
const ay = (e) => e !== e;
function vo(e) {
  if (typeof e !== "object" || e === null)
    return ay(e) ? ay : (n) => n === e;
  if (e instanceof Date) {
    const n = e.valueOf();
    return (i) => i instanceof Date ? i.valueOf() === n : !1;
  }
  return ArrayBuffer.isView(e) ? (n) => n ? K4(e, n) : !1 : e instanceof Map ? oM(e) : Array.isArray(e) ? sM(e) : e instanceof ee ? aM(e) : cM(e, !0);
}
function sM(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = vo(e[n]);
  return ql(t);
}
function oM(e) {
  let t = -1;
  const n = [];
  for (const i of e.values())
    n[++t] = vo(i);
  return ql(n);
}
function aM(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = vo(e.get(n));
  return ql(t);
}
function cM(e, t = !1) {
  const n = Object.keys(e);
  if (!t && n.length === 0)
    return () => !1;
  const i = [];
  for (let r = -1, s = n.length; ++r < s; )
    i[r] = vo(e[n[r]]);
  return ql(i, n);
}
function ql(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return uM(e, n);
      case Map:
        return cy(e, n, n.keys());
      case V0:
      case Y0:
      case Object:
      case void 0:
        return cy(e, n, t || Object.keys(n));
    }
    return n instanceof ee ? lM(e, n) : !1;
  };
}
function uM(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t[i]))
      return !1;
  return !0;
}
function lM(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t.get(i)))
      return !1;
  return !0;
}
function cy(e, t, n) {
  const i = n[Symbol.iterator](), r = t instanceof Map ? t.keys() : Object.keys(t)[Symbol.iterator](), s = t instanceof Map ? t.values() : Object.values(t)[Symbol.iterator]();
  let o = 0;
  const a = e.length;
  let c = s.next(), u = i.next(), l = r.next();
  for (; o < a && !u.done && !l.done && !c.done && !(u.value !== l.value || !e[o](c.value)); ++o, u = i.next(), l = r.next(), c = s.next())
    ;
  return o === a && u.done && l.done && c.done ? !0 : (i.return && i.return(), r.return && r.return(), s.return && s.return(), !1);
}
function g2(e, t, n, i) {
  return (n & 1 << i) !== 0;
}
function fM(e, t, n, i) {
  return (n & 1 << i) >> i;
}
function hM(e, t, n) {
  const i = n.byteLength + 7 & -8;
  if (e > 0 || n.byteLength < i) {
    const r = new Uint8Array(i);
    return r.set(e % 8 === 0 ? n.subarray(e >> 3) : (
      // Otherwise iterate each bit from the offset and return a new one
      dd(new j0(n, e, t, null, g2)).subarray(0, i)
    )), r;
  }
  return n;
}
function dd(e) {
  const t = [];
  let n = 0, i = 0, r = 0;
  for (const o of e)
    o && (r |= 1 << i), ++i === 8 && (t[n++] = r, r = i = 0);
  (n === 0 || i > 0) && (t[n++] = r);
  const s = new Uint8Array(t.length + 7 & -8);
  return s.set(t), s;
}
class j0 {
  constructor(t, n, i, r, s) {
    this.bytes = t, this.length = i, this.context = r, this.get = s, this.bit = n % 8, this.byteIndex = n >> 3, this.byte = t[this.byteIndex++], this.index = 0;
  }
  next() {
    return this.index < this.length ? (this.bit === 8 && (this.bit = 0, this.byte = this.bytes[this.byteIndex++]), {
      value: this.get(this.context, this.index++, this.byte, this.bit++)
    }) : { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
function pd(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new j0(e, t, n - t, e, fM))
      s += o;
    return s;
  }
  const i = n >> 3 << 3, r = t + (t % 8 === 0 ? 0 : 8 - t % 8);
  return (
    // Get the popcnt of bits between the left hand side, and the next highest multiple of 8
    pd(e, t, r) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    pd(e, i, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    dM(e, r >> 3, i - r >> 3)
  );
}
function dM(e, t, n) {
  let i = 0, r = Math.trunc(t);
  const s = new DataView(e.buffer, e.byteOffset, e.byteLength), o = n === void 0 ? e.byteLength : r + n;
  for (; o - r >= 4; )
    i += ch(s.getUint32(r)), r += 4;
  for (; o - r >= 2; )
    i += ch(s.getUint16(r)), r += 2;
  for (; o - r >= 1; )
    i += ch(s.getUint8(r)), r += 1;
  return i;
}
function ch(e) {
  let t = Math.trunc(e);
  return t = t - (t >>> 1 & 1431655765), t = (t & 858993459) + (t >>> 2 & 858993459), (t + (t >>> 4) & 252645135) * 16843009 >>> 24;
}
const pM = -1;
class Ut {
  constructor(t, n, i, r, s, o = [], a) {
    this.type = t, this.children = o, this.dictionary = a, this.offset = Math.floor(Math.max(n || 0, 0)), this.length = Math.floor(Math.max(i || 0, 0)), this._nullCount = Math.floor(Math.max(r || 0, -1));
    let c;
    s instanceof Ut ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = bi(t), s && ((c = s[0]) && (this.valueOffsets = c), (c = s[1]) && (this.values = c), (c = s[2]) && (this.nullBitmap = c), (c = s[3]) && (this.typeIds = c))), this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;
  }
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  get byteLength() {
    let t = 0;
    const { valueOffsets: n, values: i, nullBitmap: r, typeIds: s } = this;
    return n && (t += n.byteLength), i && (t += i.byteLength), r && (t += r.byteLength), s && (t += s.byteLength), this.children.reduce((o, a) => o + a.byteLength, t);
  }
  get nullCount() {
    let t = this._nullCount, n;
    return t <= pM && (n = this.nullBitmap) && (this._nullCount = t = this.length - pd(n, this.offset, this.offset + this.length)), t;
  }
  getValid(t) {
    if (this.nullable && this.nullCount > 0) {
      const n = this.offset + t;
      return (this.nullBitmap[n >> 3] & 1 << n % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    if (!this.nullable)
      return n;
    if (!this.nullBitmap || this.nullBitmap.byteLength <= t >> 3) {
      const { nullBitmap: c } = this._changeLengthAndBackfillNullBitmap(this.length);
      Object.assign(this, { nullBitmap: c, _nullCount: 0 });
    }
    const { nullBitmap: i, offset: r } = this, s = r + t >> 3, o = (r + t) % 8, a = i[s] >> o & 1;
    return n ? a === 0 && (i[s] |= 1 << o, this._nullCount = this.nullCount + 1) : a === 1 && (i[s] &= ~(1 << o), this._nullCount = this.nullCount - 1), n;
  }
  clone(t = this.type, n = this.offset, i = this.length, r = this._nullCount, s = this, o = this.children) {
    return new Ut(t, n, i, r, s, o, this.dictionary);
  }
  slice(t, n) {
    const { stride: i, typeId: r, children: s } = this, o = +(this._nullCount === 0) - 1, a = r === 16 ? i : 1, c = this._sliceBuffers(t, n, i, r);
    return this.clone(
      this.type,
      this.offset + t,
      n,
      o,
      c,
      // Don't slice children if we have value offsets (the variable-width types)
      s.length === 0 || this.valueOffsets ? s : this._sliceChildren(s, a * t, a * n)
    );
  }
  _changeLengthAndBackfillNullBitmap(t) {
    if (this.typeId === B.Null)
      return this.clone(this.type, 0, t, 0);
    const { length: n, nullCount: i } = this, r = new Uint8Array((t + 63 & -64) >> 3).fill(255, 0, n >> 3);
    r[n >> 3] = (1 << n - (n & -8)) - 1, i > 0 && r.set(hM(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[gi.VALIDITY] = r, this.clone(this.type, 0, t, i + (t - n), s);
  }
  _sliceBuffers(t, n, i, r) {
    let s;
    const { buffers: o } = this;
    return (s = o[gi.TYPE]) && (o[gi.TYPE] = s.subarray(t, t + n)), (s = o[gi.OFFSET]) && (o[gi.OFFSET] = s.subarray(t, t + n + 1)) || // Otherwise if no offsets, slice the data buffer. Don't slice the data vector for Booleans, since the offset goes by bits not bytes
    (s = o[gi.DATA]) && (o[gi.DATA] = r === 6 ? s : s.subarray(i * t, i * (t + n))), o;
  }
  _sliceChildren(t, n, i) {
    return t.map((r) => r.slice(n, i));
  }
}
Ut.prototype.children = Object.freeze([]);
class oa extends xt {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["length"]: r = 0 } = t;
    return new Ut(n, i, r, 0);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.data), s = Tt(t.nullBitmap), o = zo(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, a, c, [o, r, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.data), s = Tt(t.nullBitmap), o = zo(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, a, c, [o, r, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length / bi(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length / bi(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length / bi(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length / bi(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length / bi(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r } = t, s = Tt(t.nullBitmap), o = zo(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, a, c, [o, void 0, s], [r]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Tt(t.nullBitmap), { length: o = r.reduce((c, { length: u }) => Math.max(c, u), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, void 0, s], r);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Tt(t.nullBitmap), o = Ct(n.ArrayType, t.typeIds), { ["length"]: a = o.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    if (at.isSparseUnion(n))
      return new Ut(n, i, a, c, [void 0, void 0, s, o], r);
    const u = zo(t.valueOffsets);
    return new Ut(n, i, a, c, [u, void 0, s, o], r);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.indices.ArrayType, t.data), { ["dictionary"]: o = new ee([new oa().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, a, c, [void 0, s, r], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Tt(t.nullBitmap), s = Ct(n.ArrayType, t.data), { ["length"]: o = s.length / bi(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, s, r]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new oa().visit({ type: n.valueType }) } = t, s = Tt(t.nullBitmap), { ["length"]: o = r.length / bi(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, o, a, [void 0, void 0, s], [r]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new oa().visit({ type: n.childType }) } = t, s = Tt(t.nullBitmap), o = zo(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Ut(n, i, a, c, [o, void 0, s], [r]);
  }
}
function _t(e) {
  return new oa().visit(e);
}
class uy {
  constructor(t = 0, n) {
    this.numChunks = t, this.getChunkIterator = n, this.chunkIndex = 0, this.chunkIterator = this.getChunkIterator(0);
  }
  next() {
    for (; this.chunkIndex < this.numChunks; ) {
      const t = this.chunkIterator.next();
      if (!t.done)
        return t;
      ++this.chunkIndex < this.numChunks && (this.chunkIterator = this.getChunkIterator(this.chunkIndex));
    }
    return { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
function b2(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function w2(e) {
  return e.reduce((t, n, i) => (t[i + 1] = t[i] + n.length, t), new Uint32Array(e.length + 1));
}
function _2(e, t, n, i) {
  const r = [];
  for (let s = -1, o = e.length; ++s < o; ) {
    const a = e[s], c = t[s], { length: u } = a;
    if (c >= i)
      break;
    if (n >= c + u)
      continue;
    if (c >= n && c + u <= i) {
      r.push(a);
      continue;
    }
    const l = Math.max(0, n - c), f = Math.min(i - c, u);
    r.push(a.slice(l, f - l));
  }
  return r.length === 0 && r.push(e[0].slice(0, 0)), r;
}
function X0(e, t, n, i) {
  let r = 0, s = 0, o = t.length - 1;
  do {
    if (r >= o - 1)
      return n < t[o] ? i(e, r, n - t[r]) : null;
    s = r + Math.trunc((o - r) * 0.5), n < t[s] ? o = s : r = s;
  } while (r < o);
}
function W0(e, t) {
  return e.getValid(t);
}
function Ps(e) {
  function t(n, i, r) {
    return e(n[i], r);
  }
  return function(n) {
    const i = this.data;
    return X0(i, this._offsets, n, t);
  };
}
function v2(e) {
  let t;
  function n(i, r, s) {
    return e(i[r], s, t);
  }
  return function(i, r) {
    const s = this.data;
    t = r;
    const o = X0(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
function x2(e) {
  let t;
  function n(i, r, s) {
    let o = s, a = 0, c = 0;
    for (let u = r - 1, l = i.length; ++u < l; ) {
      const f = i[u];
      if (~(a = e(f, t, o)))
        return c + a;
      o = 0, c += f.length;
    }
    return -1;
  }
  return function(i, r) {
    t = i;
    const s = this.data, o = typeof r != "number" ? n(s, 0, 0) : X0(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
class tt extends xt {
}
function mM(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function yM(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let i = 0;
  for (const r of new j0(n, e.offset + (t || 0), e.length, n, g2)) {
    if (!r)
      return i;
    ++i;
  }
  return -1;
}
function ht(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    return yM(e, n);
  const i = ke.getVisitFn(e), r = vo(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
function S2(e, t, n) {
  const i = ke.getVisitFn(e), r = vo(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
tt.prototype.visitNull = mM;
tt.prototype.visitBool = ht;
tt.prototype.visitInt = ht;
tt.prototype.visitInt8 = ht;
tt.prototype.visitInt16 = ht;
tt.prototype.visitInt32 = ht;
tt.prototype.visitInt64 = ht;
tt.prototype.visitUint8 = ht;
tt.prototype.visitUint16 = ht;
tt.prototype.visitUint32 = ht;
tt.prototype.visitUint64 = ht;
tt.prototype.visitFloat = ht;
tt.prototype.visitFloat16 = ht;
tt.prototype.visitFloat32 = ht;
tt.prototype.visitFloat64 = ht;
tt.prototype.visitUtf8 = ht;
tt.prototype.visitBinary = ht;
tt.prototype.visitFixedSizeBinary = ht;
tt.prototype.visitDate = ht;
tt.prototype.visitDateDay = ht;
tt.prototype.visitDateMillisecond = ht;
tt.prototype.visitTimestamp = ht;
tt.prototype.visitTimestampSecond = ht;
tt.prototype.visitTimestampMillisecond = ht;
tt.prototype.visitTimestampMicrosecond = ht;
tt.prototype.visitTimestampNanosecond = ht;
tt.prototype.visitTime = ht;
tt.prototype.visitTimeSecond = ht;
tt.prototype.visitTimeMillisecond = ht;
tt.prototype.visitTimeMicrosecond = ht;
tt.prototype.visitTimeNanosecond = ht;
tt.prototype.visitDecimal = ht;
tt.prototype.visitList = ht;
tt.prototype.visitStruct = ht;
tt.prototype.visitUnion = ht;
tt.prototype.visitDenseUnion = S2;
tt.prototype.visitSparseUnion = S2;
tt.prototype.visitDictionary = ht;
tt.prototype.visitInterval = ht;
tt.prototype.visitIntervalDayTime = ht;
tt.prototype.visitIntervalYearMonth = ht;
tt.prototype.visitFixedSizeList = ht;
tt.prototype.visitMap = ht;
const xu = new tt();
class et extends xt {
}
function ot(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === B.Timestamp || t instanceof nr && t.bitWidth !== 64 || t instanceof _a && t.bitWidth !== 64 || t instanceof wa && t.precision !== Ce.HALF))
    return new uy(e.data.length, (i) => {
      const r = e.data[i];
      return r.values.subarray(0, r.length)[Symbol.iterator]();
    });
  let n = 0;
  return new uy(e.data.length, (i) => {
    const s = e.data[i].length, o = e.slice(n, n + s);
    return n += s, new gM(o);
  });
}
class gM {
  constructor(t) {
    this.vector = t, this.index = 0;
  }
  next() {
    return this.index < this.vector.length ? {
      value: this.vector.get(this.index++)
    } : { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
et.prototype.visitNull = ot;
et.prototype.visitBool = ot;
et.prototype.visitInt = ot;
et.prototype.visitInt8 = ot;
et.prototype.visitInt16 = ot;
et.prototype.visitInt32 = ot;
et.prototype.visitInt64 = ot;
et.prototype.visitUint8 = ot;
et.prototype.visitUint16 = ot;
et.prototype.visitUint32 = ot;
et.prototype.visitUint64 = ot;
et.prototype.visitFloat = ot;
et.prototype.visitFloat16 = ot;
et.prototype.visitFloat32 = ot;
et.prototype.visitFloat64 = ot;
et.prototype.visitUtf8 = ot;
et.prototype.visitBinary = ot;
et.prototype.visitFixedSizeBinary = ot;
et.prototype.visitDate = ot;
et.prototype.visitDateDay = ot;
et.prototype.visitDateMillisecond = ot;
et.prototype.visitTimestamp = ot;
et.prototype.visitTimestampSecond = ot;
et.prototype.visitTimestampMillisecond = ot;
et.prototype.visitTimestampMicrosecond = ot;
et.prototype.visitTimestampNanosecond = ot;
et.prototype.visitTime = ot;
et.prototype.visitTimeSecond = ot;
et.prototype.visitTimeMillisecond = ot;
et.prototype.visitTimeMicrosecond = ot;
et.prototype.visitTimeNanosecond = ot;
et.prototype.visitDecimal = ot;
et.prototype.visitList = ot;
et.prototype.visitStruct = ot;
et.prototype.visitUnion = ot;
et.prototype.visitDenseUnion = ot;
et.prototype.visitSparseUnion = ot;
et.prototype.visitDictionary = ot;
et.prototype.visitInterval = ot;
et.prototype.visitIntervalDayTime = ot;
et.prototype.visitIntervalYearMonth = ot;
et.prototype.visitFixedSizeList = ot;
et.prototype.visitMap = ot;
const H0 = new et(), bM = (e, t) => e + t;
class dr extends xt {
  visitNull(t, n) {
    return 0;
  }
  visitInt(t, n) {
    return t.type.bitWidth / 8;
  }
  visitFloat(t, n) {
    return t.type.ArrayType.BYTES_PER_ELEMENT;
  }
  visitBool(t, n) {
    return 1 / 8;
  }
  visitDecimal(t, n) {
    return t.type.bitWidth / 8;
  }
  visitDate(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitTime(t, n) {
    return t.type.bitWidth / 8;
  }
  visitTimestamp(t, n) {
    return t.type.unit === At.SECOND ? 4 : 8;
  }
  visitInterval(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitStruct(t, n) {
    return t.children.reduce((i, r) => i + Qn.visit(r, n), 0);
  }
  visitFixedSizeBinary(t, n) {
    return t.type.byteWidth;
  }
  visitMap(t, n) {
    return 8 + t.children.reduce((i, r) => i + Qn.visit(r, n), 0);
  }
  visitDictionary(t, n) {
    var i;
    return t.type.indices.bitWidth / 8 + (((i = t.dictionary) === null || i === void 0 ? void 0 : i.getByteLength(t.values[n])) || 0);
  }
}
const wM = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), _M = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), vM = ({ valueOffsets: e, stride: t, children: n }, i) => {
  const r = n[0], { [i * t]: s } = e, { [i * t + 1]: o } = e, a = Qn.getVisitFn(r.type), c = r.slice(s, o - s);
  let u = 8;
  for (let l = -1, f = o - s; ++l < f; )
    u += a(c, l);
  return u;
}, xM = ({ stride: e, children: t }, n) => {
  const i = t[0], r = i.slice(n * e, e), s = Qn.getVisitFn(i.type);
  let o = 0;
  for (let a = -1, c = r.length; ++a < c; )
    o += s(r, a);
  return o;
}, SM = (e, t) => e.type.mode === $n.Dense ? M2(e, t) : A2(e, t), M2 = ({ type: e, children: t, typeIds: n, valueOffsets: i }, r) => {
  const s = e.typeIdToChildIndex[n[r]];
  return 8 + Qn.visit(t[s], i[r]);
}, A2 = ({ children: e }, t) => 4 + Qn.visitMany(e, e.map(() => t)).reduce(bM, 0);
dr.prototype.visitUtf8 = wM;
dr.prototype.visitBinary = _M;
dr.prototype.visitList = vM;
dr.prototype.visitFixedSizeList = xM;
dr.prototype.visitUnion = SM;
dr.prototype.visitDenseUnion = M2;
dr.prototype.visitSparseUnion = A2;
const Qn = new dr();
var $2;
const I2 = {}, T2 = {};
let ee = class Tr {
  constructor(t) {
    var n, i, r;
    const s = t[0] instanceof Tr ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof Ut)))
      throw new TypeError("Vector constructor expects an Array of Data instances.");
    const o = (n = s[0]) === null || n === void 0 ? void 0 : n.type;
    switch (s.length) {
      case 0:
        this._offsets = [0];
        break;
      case 1: {
        const { get: a, set: c, indexOf: u, byteLength: l } = I2[o.typeId], f = s[0];
        this.isValid = (h) => W0(f, h), this.get = (h) => a(f, h), this.set = (h, d) => c(f, h, d), this.indexOf = (h) => u(f, h), this.getByteLength = (h) => l(f, h), this._offsets = [0, f.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, T2[o.typeId]), this._offsets = w2(s);
        break;
    }
    this.data = s, this.type = o, this.stride = bi(o), this.numChildren = (r = (i = o.children) === null || i === void 0 ? void 0 : i.length) !== null && r !== void 0 ? r : 0, this.length = this._offsets[this._offsets.length - 1];
  }
  /**
   * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
   */
  get byteLength() {
    return this._byteLength === -1 && (this._byteLength = this.data.reduce((t, n) => t + n.byteLength, 0)), this._byteLength;
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return this._nullCount === -1 && (this._nullCount = b2(this.data)), this._nullCount;
  }
  /**
   * The Array or TypedAray constructor used for the JS representation
   *  of the element's values in {@link Vector.prototype.toArray `toArray()`}.
   */
  get ArrayType() {
    return this.type.ArrayType;
  }
  /**
   * The name that should be printed when the Vector is logged in a message.
   */
  get [Symbol.toStringTag]() {
    return `${this.VectorName}<${this.type[Symbol.toStringTag]}>`;
  }
  /**
   * The name of this Vector.
   */
  get VectorName() {
    return `${B[this.type.typeId]}Vector`;
  }
  /**
   * Check whether an element is null.
   * @param index The index at which to read the validity bitmap.
   */
  // @ts-ignore
  isValid(t) {
    return !1;
  }
  /**
   * Get an element value by position.
   * @param index The index of the element to read.
   */
  // @ts-ignore
  get(t) {
    return null;
  }
  /**
   * Set an element value by position.
   * @param index The index of the element to write.
   * @param value The value to set.
   */
  // @ts-ignore
  set(t, n) {
  }
  /**
   * Retrieve the index of the first occurrence of a value in an Vector.
   * @param element The value to locate in the Vector.
   * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.
   */
  // @ts-ignore
  indexOf(t, n) {
    return -1;
  }
  includes(t, n) {
    return this.indexOf(t, n) > 0;
  }
  /**
   * Get the size in bytes of an element by index.
   * @param index The index at which to get the byteLength.
   */
  // @ts-ignore
  getByteLength(t) {
    return 0;
  }
  /**
   * Iterator for the Vector's elements.
   */
  [Symbol.iterator]() {
    return H0.visit(this);
  }
  /**
   * Combines two or more Vectors of the same type.
   * @param others Additional Vectors to add to the end of this Vector.
   */
  concat(...t) {
    return new Tr(this.data.concat(t.flatMap((n) => n.data).flat(Number.POSITIVE_INFINITY)));
  }
  /**
   * Return a zero-copy sub-section of this Vector.
   * @param start The beginning of the specified portion of the Vector.
   * @param end The end of the specified portion of the Vector. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    return new Tr(y2(this, t, n, ({ data: i, _offsets: r }, s, o) => _2(i, r, s, o)));
  }
  toJSON() {
    return [...this];
  }
  /**
   * Return a JavaScript Array or TypedArray of the Vector's elements.
   *
   * @note If this Vector contains a single Data chunk and the Vector's type is a
   *  primitive numeric type corresponding to one of the JavaScript TypedArrays, this
   *  method returns a zero-copy slice of the underlying TypedArray values. If there's
   *  more than one chunk, the resulting TypedArray will be a copy of the data from each
   *  chunk's underlying TypedArray values.
   *
   * @returns An Array or TypedArray of the Vector's elements, based on the Vector's DataType.
   */
  toArray() {
    const { type: t, data: n, length: i, stride: r, ArrayType: s } = this;
    switch (t.typeId) {
      case B.Int:
      case B.Float:
      case B.Decimal:
      case B.Time:
      case B.Timestamp:
        switch (n.length) {
          case 0:
            return new s();
          case 1:
            return n[0].values.subarray(0, i * r);
          default:
            return n.reduce((o, { values: a, length: c }) => (o.array.set(a.subarray(0, c * r), o.offset), o.offset += c * r, o), { array: new s(i * r), offset: 0 }).array;
        }
    }
    return [...this];
  }
  /**
   * Returns a string representation of the Vector.
   *
   * @returns A string representation of the Vector.
   */
  toString() {
    return `[${[...this].join(",")}]`;
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    var n;
    return this.getChildAt((n = this.type.children) === null || n === void 0 ? void 0 : n.findIndex((i) => i.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    return t > -1 && t < this.numChildren ? new Tr(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return at.isDictionary(this.type) ? this.data[0].dictionary.isMemoized : !1;
  }
  /**
   * Adds memoization to the Vector's {@link get} method. For dictionary
   * vectors, this method return a vector that memoizes only the dictionary
   * values.
   *
   * Memoization is very useful when decoding a value is expensive such as
   * Uft8. The memoization creates a cache of the size of the Vector and
   * therfore increases memory usage.
   *
   * @returns A new vector that memoizes calls to {@link get}.
   */
  memoize() {
    if (at.isDictionary(this.type)) {
      const t = new Su(this.data[0].dictionary), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new Tr(n);
    }
    return new Su(this);
  }
  /**
   * Returns a vector without memoization of the {@link get} method. If this
   * vector is not memoized, this method returns this vector.
   *
   * @returns A a vector without memoization.
   */
  unmemoize() {
    if (at.isDictionary(this.type) && this.isMemoized) {
      const t = this.data[0].dictionary.unmemoize(), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new Tr(n);
    }
    return this;
  }
};
$2 = Symbol.toStringTag;
ee[$2] = ((e) => {
  e.type = at.prototype, e.data = [], e.length = 0, e.stride = 1, e.numChildren = 0, e._nullCount = -1, e._byteLength = -1, e._offsets = new Uint32Array([0]), e[Symbol.isConcatSpreadable] = !0;
  const t = Object.keys(B).map((n) => B[n]).filter((n) => typeof n == "number" && n !== B.NONE);
  for (const n of t) {
    const i = ke.getVisitFnByTypeId(n), r = hn.getVisitFnByTypeId(n), s = xu.getVisitFnByTypeId(n), o = Qn.getVisitFnByTypeId(n);
    I2[n] = { get: i, set: r, indexOf: s, byteLength: o }, T2[n] = Object.create(e, {
      isValid: { value: Ps(W0) },
      get: { value: Ps(ke.getVisitFnByTypeId(n)) },
      set: { value: v2(hn.getVisitFnByTypeId(n)) },
      indexOf: { value: x2(xu.getVisitFnByTypeId(n)) },
      getByteLength: { value: Ps(Qn.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(ee.prototype);
class Su extends ee {
  constructor(t) {
    super(t.data);
    const n = this.get, i = this.set, r = this.slice, s = new Array(this.length);
    Object.defineProperty(this, "get", {
      value(o) {
        const a = s[o];
        if (a !== void 0)
          return a;
        const c = n.call(this, o);
        return s[o] = c, c;
      }
    }), Object.defineProperty(this, "set", {
      value(o, a) {
        i.call(this, o, a), s[o] = a;
      }
    }), Object.defineProperty(this, "slice", {
      value: (o, a) => new Su(r.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new ee(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}
class md {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * Index to the start of the RecordBlock (note this is past the Message header)
   */
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * Length of the metadata
   */
  metaDataLength() {
    return this.bb.readInt32(this.bb_pos + 8);
  }
  /**
   * Length of the data (this is aligned so there can be a gap between this and
   * the metadata).
   */
  bodyLength() {
    return this.bb.readInt64(this.bb_pos + 16);
  }
  static sizeOf() {
    return 24;
  }
  static createBlock(t, n, i, r) {
    return t.prep(8, 24), t.writeInt64(r), t.pad(4), t.writeInt32(i), t.writeInt64(n), t.offset();
  }
}
const uh = 2, Un = 4, xi = 4, kt = 4, Xi = new Int32Array(2), ly = new Float32Array(Xi.buffer), fy = new Float64Array(Xi.buffer), yc = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
let Ni = class yd {
  constructor(t, n) {
    this.low = t | 0, this.high = n | 0;
  }
  static create(t, n) {
    return t == 0 && n == 0 ? yd.ZERO : new yd(t, n);
  }
  toFloat64() {
    return (this.low >>> 0) + this.high * 4294967296;
  }
  equals(t) {
    return this.low == t.low && this.high == t.high;
  }
};
Ni.ZERO = new Ni(0, 0);
var gd;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(gd || (gd = {}));
let Zs = class E2 {
  /**
   * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
   */
  constructor(t) {
    this.bytes_ = t, this.position_ = 0;
  }
  /**
   * Create and allocate a new ByteBuffer with a given size.
   */
  static allocate(t) {
    return new E2(new Uint8Array(t));
  }
  clear() {
    this.position_ = 0;
  }
  /**
   * Get the underlying `Uint8Array`.
   */
  bytes() {
    return this.bytes_;
  }
  /**
   * Get the buffer's position.
   */
  position() {
    return this.position_;
  }
  /**
   * Set the buffer's position.
   */
  setPosition(t) {
    this.position_ = t;
  }
  /**
   * Get the buffer's capacity.
   */
  capacity() {
    return this.bytes_.length;
  }
  readInt8(t) {
    return this.readUint8(t) << 24 >> 24;
  }
  readUint8(t) {
    return this.bytes_[t];
  }
  readInt16(t) {
    return this.readUint16(t) << 16 >> 16;
  }
  readUint16(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8;
  }
  readInt32(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8 | this.bytes_[t + 2] << 16 | this.bytes_[t + 3] << 24;
  }
  readUint32(t) {
    return this.readInt32(t) >>> 0;
  }
  readInt64(t) {
    return new Ni(this.readInt32(t), this.readInt32(t + 4));
  }
  readUint64(t) {
    return new Ni(this.readUint32(t), this.readUint32(t + 4));
  }
  readFloat32(t) {
    return Xi[0] = this.readInt32(t), ly[0];
  }
  readFloat64(t) {
    return Xi[yc ? 0 : 1] = this.readInt32(t), Xi[yc ? 1 : 0] = this.readInt32(t + 4), fy[0];
  }
  writeInt8(t, n) {
    this.bytes_[t] = n;
  }
  writeUint8(t, n) {
    this.bytes_[t] = n;
  }
  writeInt16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeUint16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeInt32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeUint32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeInt64(t, n) {
    this.writeInt32(t, n.low), this.writeInt32(t + 4, n.high);
  }
  writeUint64(t, n) {
    this.writeUint32(t, n.low), this.writeUint32(t + 4, n.high);
  }
  writeFloat32(t, n) {
    ly[0] = n, this.writeInt32(t, Xi[0]);
  }
  writeFloat64(t, n) {
    fy[0] = n, this.writeInt32(t, Xi[yc ? 0 : 1]), this.writeInt32(t + 4, Xi[yc ? 1 : 0]);
  }
  /**
   * Return the file identifier.   Behavior is undefined for FlatBuffers whose
   * schema does not include a file_identifier (likely points at padding or the
   * start of a the root vtable).
   */
  getBufferIdentifier() {
    if (this.bytes_.length < this.position_ + Un + xi)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < xi; n++)
      t += String.fromCharCode(this.readInt8(this.position_ + Un + n));
    return t;
  }
  /**
   * Look up a field in the vtable, return an offset into the object, or 0 if the
   * field is not present.
   */
  __offset(t, n) {
    const i = t - this.readInt32(t);
    return n < this.readInt16(i) ? this.readInt16(i + n) : 0;
  }
  /**
   * Initialize any Table-derived type to point to the union at the given offset.
   */
  __union(t, n) {
    return t.bb_pos = n + this.readInt32(n), t.bb = this, t;
  }
  /**
   * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.
   * This allocates a new string and converts to wide chars upon each access.
   *
   * To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as
   * the "optionalEncoding" argument. This is useful for avoiding conversion to
   * and from UTF-16 when the data will just be packaged back up in another
   * FlatBuffer later on.
   *
   * @param offset
   * @param opt_encoding Defaults to UTF16_STRING
   */
  __string(t, n) {
    t += this.readInt32(t);
    const i = this.readInt32(t);
    let r = "", s = 0;
    if (t += Un, n === gd.UTF8_BYTES)
      return this.bytes_.subarray(t, t + i);
    for (; s < i; ) {
      let o;
      const a = this.readUint8(t + s++);
      if (a < 192)
        o = a;
      else {
        const c = this.readUint8(t + s++);
        if (a < 224)
          o = (a & 31) << 6 | c & 63;
        else {
          const u = this.readUint8(t + s++);
          if (a < 240)
            o = (a & 15) << 12 | (c & 63) << 6 | u & 63;
          else {
            const l = this.readUint8(t + s++);
            o = (a & 7) << 18 | (c & 63) << 12 | (u & 63) << 6 | l & 63;
          }
        }
      }
      o < 65536 ? r += String.fromCharCode(o) : (o -= 65536, r += String.fromCharCode((o >> 10) + 55296, (o & (1 << 10) - 1) + 56320));
    }
    return r;
  }
  /**
   * Handle unions that can contain string as its member, if a Table-derived type then initialize it,
   * if a string then return a new one
   *
   * WARNING: strings are immutable in JS so we can't change the string that the user gave us, this
   * makes the behaviour of __union_with_string different compared to __union
   */
  __union_with_string(t, n) {
    return typeof t == "string" ? this.__string(n) : this.__union(t, n);
  }
  /**
   * Retrieve the relative offset stored at "offset"
   */
  __indirect(t) {
    return t + this.readInt32(t);
  }
  /**
   * Get the start of data of a vector whose offset is stored at "offset" in this object.
   */
  __vector(t) {
    return t + this.readInt32(t) + Un;
  }
  /**
   * Get the length of a vector whose offset is stored at "offset" in this object.
   */
  __vector_len(t) {
    return this.readInt32(t + this.readInt32(t));
  }
  __has_identifier(t) {
    if (t.length != xi)
      throw new Error("FlatBuffers: file identifier must be length " + xi);
    for (let n = 0; n < xi; n++)
      if (t.charCodeAt(n) != this.readInt8(this.position() + Un + n))
        return !1;
    return !0;
  }
  /**
   * A helper function to avoid generated code depending on this file directly.
   */
  createLong(t, n) {
    return Ni.create(t, n);
  }
  /**
   * A helper function for generating list for obj api
   */
  createScalarList(t, n) {
    const i = [];
    for (let r = 0; r < n; ++r)
      t(r) !== null && i.push(t(r));
    return i;
  }
  /**
   * A helper function for generating list for obj api
   * @param listAccessor function that accepts an index and return data at that index
   * @param listLength listLength
   * @param res result list
   */
  createObjList(t, n) {
    const i = [];
    for (let r = 0; r < n; ++r) {
      const s = t(r);
      s !== null && i.push(s.unpack());
    }
    return i;
  }
}, N2 = class O2 {
  /**
   * Create a FlatBufferBuilder.
   */
  constructor(t) {
    this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null;
    let n;
    t ? n = t : n = 1024, this.bb = Zs.allocate(n), this.space = n;
  }
  clear() {
    this.bb.clear(), this.space = this.bb.capacity(), this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null;
  }
  /**
   * In order to save space, fields that are set to their default value
   * don't get serialized into the buffer. Forcing defaults provides a
   * way to manually disable this optimization.
   *
   * @param forceDefaults true always serializes default values
   */
  forceDefaults(t) {
    this.force_defaults = t;
  }
  /**
   * Get the ByteBuffer representing the FlatBuffer. Only call this after you've
   * called finish(). The actual data starts at the ByteBuffer's current position,
   * not necessarily at 0.
   */
  dataBuffer() {
    return this.bb;
  }
  /**
   * Get the bytes representing the FlatBuffer. Only call this after you've
   * called finish().
   */
  asUint8Array() {
    return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());
  }
  /**
   * Prepare to write an element of `size` after `additional_bytes` have been
   * written, e.g. if you write a string, you need to align such the int length
   * field is aligned to 4 bytes, and the string data follows it directly. If all
   * you need to do is alignment, `additional_bytes` will be 0.
   *
   * @param size This is the of the new element to write
   * @param additional_bytes The padding size
   */
  prep(t, n) {
    t > this.minalign && (this.minalign = t);
    const i = ~(this.bb.capacity() - this.space + n) + 1 & t - 1;
    for (; this.space < i + t + n; ) {
      const r = this.bb.capacity();
      this.bb = O2.growByteBuffer(this.bb), this.space += this.bb.capacity() - r;
    }
    this.pad(i);
  }
  pad(t) {
    for (let n = 0; n < t; n++)
      this.bb.writeInt8(--this.space, 0);
  }
  writeInt8(t) {
    this.bb.writeInt8(this.space -= 1, t);
  }
  writeInt16(t) {
    this.bb.writeInt16(this.space -= 2, t);
  }
  writeInt32(t) {
    this.bb.writeInt32(this.space -= 4, t);
  }
  writeInt64(t) {
    this.bb.writeInt64(this.space -= 8, t);
  }
  writeFloat32(t) {
    this.bb.writeFloat32(this.space -= 4, t);
  }
  writeFloat64(t) {
    this.bb.writeFloat64(this.space -= 8, t);
  }
  /**
   * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int8` to add the the buffer.
   */
  addInt8(t) {
    this.prep(1, 0), this.writeInt8(t);
  }
  /**
   * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int16` to add the the buffer.
   */
  addInt16(t) {
    this.prep(2, 0), this.writeInt16(t);
  }
  /**
   * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int32` to add the the buffer.
   */
  addInt32(t) {
    this.prep(4, 0), this.writeInt32(t);
  }
  /**
   * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int64` to add the the buffer.
   */
  addInt64(t) {
    this.prep(8, 0), this.writeInt64(t);
  }
  /**
   * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float32` to add the the buffer.
   */
  addFloat32(t) {
    this.prep(4, 0), this.writeFloat32(t);
  }
  /**
   * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float64` to add the the buffer.
   */
  addFloat64(t) {
    this.prep(8, 0), this.writeFloat64(t);
  }
  addFieldInt8(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt8(n), this.slot(t));
  }
  addFieldInt16(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt16(n), this.slot(t));
  }
  addFieldInt32(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt32(n), this.slot(t));
  }
  addFieldInt64(t, n, i) {
    (this.force_defaults || !n.equals(i)) && (this.addInt64(n), this.slot(t));
  }
  addFieldFloat32(t, n, i) {
    (this.force_defaults || n != i) && (this.addFloat32(n), this.slot(t));
  }
  addFieldFloat64(t, n, i) {
    (this.force_defaults || n != i) && (this.addFloat64(n), this.slot(t));
  }
  addFieldOffset(t, n, i) {
    (this.force_defaults || n != i) && (this.addOffset(n), this.slot(t));
  }
  /**
   * Structs are stored inline, so nothing additional is being added. `d` is always 0.
   */
  addFieldStruct(t, n, i) {
    n != i && (this.nested(n), this.slot(t));
  }
  /**
   * Structures are always stored inline, they need to be created right
   * where they're used.  You'll get this assertion failure if you
   * created it elsewhere.
   */
  nested(t) {
    if (t != this.offset())
      throw new Error("FlatBuffers: struct must be serialized inline.");
  }
  /**
   * Should not be creating any other object, string or vector
   * while an object is being constructed
   */
  notNested() {
    if (this.isNested)
      throw new Error("FlatBuffers: object serialization must not be nested.");
  }
  /**
   * Set the current vtable at `voffset` to the current location in the buffer.
   */
  slot(t) {
    this.vtable !== null && (this.vtable[t] = this.offset());
  }
  /**
   * @returns Offset relative to the end of the buffer.
   */
  offset() {
    return this.bb.capacity() - this.space;
  }
  /**
   * Doubles the size of the backing ByteBuffer and copies the old data towards
   * the end of the new buffer (since we build the buffer backwards).
   *
   * @param bb The current buffer with the existing data
   * @returns A new byte buffer with the old data copied
   * to it. The data is located at the end of the buffer.
   *
   * uint8Array.set() formally takes {Array<number>|ArrayBufferView}, so to pass
   * it a uint8Array we need to suppress the type check:
   * @suppress {checkTypes}
   */
  static growByteBuffer(t) {
    const n = t.capacity();
    if (n & 3221225472)
      throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
    const i = n << 1, r = Zs.allocate(i);
    return r.setPosition(i - n), r.bytes().set(t.bytes(), i - n), r;
  }
  /**
   * Adds on offset, relative to where it will be written.
   *
   * @param offset The offset to add.
   */
  addOffset(t) {
    this.prep(Un, 0), this.writeInt32(this.offset() - t + Un);
  }
  /**
   * Start encoding a new object in the buffer.  Users will not usually need to
   * call this directly. The FlatBuffers compiler will generate helper methods
   * that call this method internally.
   */
  startObject(t) {
    this.notNested(), this.vtable == null && (this.vtable = []), this.vtable_in_use = t;
    for (let n = 0; n < t; n++)
      this.vtable[n] = 0;
    this.isNested = !0, this.object_start = this.offset();
  }
  /**
   * Finish off writing the object that is under construction.
   *
   * @returns The offset to the object inside `dataBuffer`
   */
  endObject() {
    if (this.vtable == null || !this.isNested)
      throw new Error("FlatBuffers: endObject called without startObject");
    this.addInt32(0);
    const t = this.offset();
    let n = this.vtable_in_use - 1;
    for (; n >= 0 && this.vtable[n] == 0; n--)
      ;
    const i = n + 1;
    for (; n >= 0; n--)
      this.addInt16(this.vtable[n] != 0 ? t - this.vtable[n] : 0);
    const r = 2;
    this.addInt16(t - this.object_start);
    const s = (i + r) * uh;
    this.addInt16(s);
    let o = 0;
    const a = this.space;
    t:
      for (n = 0; n < this.vtables.length; n++) {
        const c = this.bb.capacity() - this.vtables[n];
        if (s == this.bb.readInt16(c)) {
          for (let u = uh; u < s; u += uh)
            if (this.bb.readInt16(a + u) != this.bb.readInt16(c + u))
              continue t;
          o = this.vtables[n];
          break;
        }
      }
    return o ? (this.space = this.bb.capacity() - t, this.bb.writeInt32(this.space, o - t)) : (this.vtables.push(this.offset()), this.bb.writeInt32(this.bb.capacity() - t, this.offset() - t)), this.isNested = !1, t;
  }
  /**
   * Finalize a buffer, poiting to the given `root_table`.
   */
  finish(t, n, i) {
    const r = i ? kt : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, Un + xi + r), s.length != xi)
        throw new Error("FlatBuffers: file identifier must be length " + xi);
      for (let o = xi - 1; o >= 0; o--)
        this.writeInt8(s.charCodeAt(o));
    }
    this.prep(this.minalign, Un + r), this.addOffset(t), r && this.addInt32(this.bb.capacity() - this.space), this.bb.setPosition(this.space);
  }
  /**
   * Finalize a size prefixed buffer, pointing to the given `root_table`.
   */
  finishSizePrefixed(t, n) {
    this.finish(t, n, !0);
  }
  /**
   * This checks a required field has been set in a given table that has
   * just been constructed.
   */
  requiredField(t, n) {
    const i = this.bb.capacity() - t, r = i - this.bb.readInt32(i);
    if (!(this.bb.readInt16(r + n) != 0))
      throw new Error("FlatBuffers: field " + n + " must be set");
  }
  /**
   * Start a new array/vector of objects.  Users usually will not call
   * this directly. The FlatBuffers compiler will create a start/end
   * method for vector types in generated code.
   *
   * @param elem_size The size of each element in the array
   * @param num_elems The number of elements in the array
   * @param alignment The alignment of the array
   */
  startVector(t, n, i) {
    this.notNested(), this.vector_num_elems = n, this.prep(Un, t * n), this.prep(i, t * n);
  }
  /**
   * Finish off the creation of an array and all its elements. The array must be
   * created with `startVector`.
   *
   * @returns The offset at which the newly created array
   * starts.
   */
  endVector() {
    return this.writeInt32(this.vector_num_elems), this.offset();
  }
  /**
   * Encode the string `s` in the buffer using UTF-8. If the string passed has
   * already been seen, we return the offset of the already written string
   *
   * @param s The string to encode
   * @return The offset in the buffer where the encoded string starts
   */
  createSharedString(t) {
    if (!t)
      return 0;
    if (this.string_maps || (this.string_maps = /* @__PURE__ */ new Map()), this.string_maps.has(t))
      return this.string_maps.get(t);
    const n = this.createString(t);
    return this.string_maps.set(t, n), n;
  }
  /**
   * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed
   * instead of a string, it is assumed to contain valid UTF-8 encoded data.
   *
   * @param s The string to encode
   * @return The offset in the buffer where the encoded string starts
   */
  createString(t) {
    if (!t)
      return 0;
    let n;
    if (t instanceof Uint8Array)
      n = t;
    else {
      n = [];
      let i = 0;
      for (; i < t.length; ) {
        let r;
        const s = t.charCodeAt(i++);
        if (s < 55296 || s >= 56320)
          r = s;
        else {
          const o = t.charCodeAt(i++);
          r = (s << 10) + o + (65536 - (55296 << 10) - 56320);
        }
        r < 128 ? n.push(r) : (r < 2048 ? n.push(r >> 6 & 31 | 192) : (r < 65536 ? n.push(r >> 12 & 15 | 224) : n.push(r >> 18 & 7 | 240, r >> 12 & 63 | 128), n.push(r >> 6 & 63 | 128)), n.push(r & 63 | 128));
      }
    }
    this.addInt8(0), this.startVector(1, n.length, 1), this.bb.setPosition(this.space -= n.length);
    for (let i = 0, r = this.space, s = this.bb.bytes(); i < n.length; i++)
      s[r++] = n[i];
    return this.endVector();
  }
  /**
   * A helper function to avoid generated code depending on this file directly.
   */
  createLong(t, n) {
    return Ni.create(t, n);
  }
  /**
   * A helper function to pack an object
   *
   * @returns offset of obj
   */
  createObjectOffset(t) {
    return t === null ? 0 : typeof t == "string" ? this.createString(t) : t.pack(this);
  }
  /**
   * A helper function to pack a list of object
   *
   * @returns list of offsets of each non null object
   */
  createObjectOffsetList(t) {
    const n = [];
    for (let i = 0; i < t.length; ++i) {
      const r = t[i];
      if (r !== null)
        n.push(this.createObjectOffset(r));
      else
        throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return n;
  }
  createStructOffsetList(t, n) {
    return n(this, t.length), this.createObjectOffsetList(t), this.endVector();
  }
};
class se {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsKeyValue(t, n) {
    return (n || new se()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + kt), (n || new se()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  key(t) {
    const n = this.bb.__offset(this.bb_pos, 4);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  value(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  static startKeyValue(t) {
    t.startObject(2);
  }
  static addKey(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addValue(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endKeyValue(t) {
    return t.endObject();
  }
  static createKeyValue(t, n, i) {
    return se.startKeyValue(t), se.addKey(t, n), se.addValue(t, i), se.endKeyValue(t);
  }
}
var Ks;
(function(e) {
  e[e.V1 = 0] = "V1", e[e.V2 = 1] = "V2", e[e.V3 = 2] = "V3", e[e.V4 = 3] = "V4", e[e.V5 = 4] = "V5";
})(Ks || (Ks = {}));
var Js;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(Js || (Js = {}));
var Mu;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(Mu || (Mu = {}));
class Ye {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsInt(t, n) {
    return (n || new Ye()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + kt), (n || new Ye()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  isSigned() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startInt(t) {
    t.startObject(2);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static addIsSigned(t, n) {
    t.addFieldInt8(1, +n, 0);
  }
  static endInt(t) {
    return t.endObject();
  }
  static createInt(t, n, i) {
    return Ye.startInt(t), Ye.addBitWidth(t, n), Ye.addIsSigned(t, i), Ye.endInt(t);
  }
}
class Si {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDictionaryEncoding(t, n) {
    return (n || new Si()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + kt), (n || new Si()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * The known dictionary id in the application where this data is used. In
   * the file or streaming formats, the dictionary ids are found in the
   * DictionaryBatch messages
   */
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : this.bb.createLong(0, 0);
  }
  /**
   * The dictionary indices are constrained to be non-negative integers. If
   * this field is null, the indices must be signed int32. To maximize
   * cross-language compatibility and performance, implementations are
   * recommended to prefer signed integer types over unsigned integer types
   * and to avoid uint64 indices unless they are required by an application.
   */
  indexType(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Ye()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * By default, dictionaries are not ordered, or the order does not have
   * semantic meaning. In some statistical, applications, dictionary-encoding
   * is used to represent ordered categorical data, and we provide a way to
   * preserve that metadata here
   */
  isOrdered() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  dictionaryKind() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.readInt16(this.bb_pos + t) : Mu.DenseArray;
  }
  static startDictionaryEncoding(t) {
    t.startObject(4);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, t.createLong(0, 0));
  }
  static addIndexType(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsOrdered(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static addDictionaryKind(t, n) {
    t.addFieldInt16(3, n, Mu.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}
class Dr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsBinary(t, n) {
    return (n || new Dr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + kt), (n || new Dr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return Dr.startBinary(t), Dr.endBinary(t);
  }
}
class Br {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsBool(t, n) {
    return (n || new Br()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + kt), (n || new Br()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return Br.startBool(t), Br.endBool(t);
  }
}
var Au;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Au || (Au = {}));
let Gc = class Ss {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDate(t, n) {
    return (n || new Ss()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + kt), (n || new Ss()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Au.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Au.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return Ss.startDate(t), Ss.addUnit(t, n), Ss.endDate(t);
  }
};
class Be {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDecimal(t, n) {
    return (n || new Be()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + kt), (n || new Be()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Total number of decimal digits
   */
  precision() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  /**
   * Number of digits after the decimal point "."
   */
  scale() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  /**
   * Number of bits per value. The only accepted widths are 128 and 256.
   * We use bitWidth for consistency with Int::bitWidth.
   */
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.readInt32(this.bb_pos + t) : 128;
  }
  static startDecimal(t) {
    t.startObject(3);
  }
  static addPrecision(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static addScale(t, n) {
    t.addFieldInt32(1, n, 0);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(2, n, 128);
  }
  static endDecimal(t) {
    return t.endObject();
  }
  static createDecimal(t, n, i, r) {
    return Be.startDecimal(t), Be.addPrecision(t, n), Be.addScale(t, i), Be.addBitWidth(t, r), Be.endDecimal(t);
  }
}
var Qs;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(Qs || (Qs = {}));
class zn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsFixedSizeBinary(t, n) {
    return (n || new zn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + kt), (n || new zn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Number of bytes per value
   */
  byteWidth() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  static startFixedSizeBinary(t) {
    t.startObject(1);
  }
  static addByteWidth(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static endFixedSizeBinary(t) {
    return t.endObject();
  }
  static createFixedSizeBinary(t, n) {
    return zn.startFixedSizeBinary(t), zn.addByteWidth(t, n), zn.endFixedSizeBinary(t);
  }
}
class Pn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsFixedSizeList(t, n) {
    return (n || new Pn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + kt), (n || new Pn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Number of list items per value
   */
  listSize() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  static startFixedSizeList(t) {
    t.startObject(1);
  }
  static addListSize(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static endFixedSizeList(t) {
    return t.endObject();
  }
  static createFixedSizeList(t, n) {
    return Pn.startFixedSizeList(t), Pn.addListSize(t, n), Pn.endFixedSizeList(t);
  }
}
var $u;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})($u || ($u = {}));
class Yn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsFloatingPoint(t, n) {
    return (n || new Yn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + kt), (n || new Yn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  precision() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : $u.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, $u.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return Yn.startFloatingPoint(t), Yn.addPrecision(t, n), Yn.endFloatingPoint(t);
  }
}
var Iu;
(function(e) {
  e[e.YEAR_MONTH = 0] = "YEAR_MONTH", e[e.DAY_TIME = 1] = "DAY_TIME", e[e.MONTH_DAY_NANO = 2] = "MONTH_DAY_NANO";
})(Iu || (Iu = {}));
class qn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsInterval(t, n) {
    return (n || new qn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + kt), (n || new qn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Iu.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Iu.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return qn.startInterval(t), qn.addUnit(t, n), qn.endInterval(t);
  }
}
class Lr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsList(t, n) {
    return (n || new Lr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + kt), (n || new Lr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return Lr.startList(t), Lr.endList(t);
  }
}
let Zc = class Ms {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsMap(t, n) {
    return (n || new Ms()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + kt), (n || new Ms()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Set to true if the keys within each value are sorted
   */
  keysSorted() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startMap(t) {
    t.startObject(1);
  }
  static addKeysSorted(t, n) {
    t.addFieldInt8(0, +n, 0);
  }
  static endMap(t) {
    return t.endObject();
  }
  static createMap(t, n) {
    return Ms.startMap(t), Ms.addKeysSorted(t, n), Ms.endMap(t);
  }
};
class Cr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsNull(t, n) {
    return (n || new Cr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + kt), (n || new Cr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return Cr.startNull(t), Cr.endNull(t);
  }
}
class kr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsStruct_(t, n) {
    return (n || new kr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + kt), (n || new kr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return kr.startStruct_(t), kr.endStruct_(t);
  }
}
class en {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsTime(t, n) {
    return (n || new en()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + kt), (n || new en()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Qs.MILLISECOND;
  }
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readInt32(this.bb_pos + t) : 32;
  }
  static startTime(t) {
    t.startObject(2);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Qs.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, i) {
    return en.startTime(t), en.addUnit(t, n), en.addBitWidth(t, i), en.endTime(t);
  }
}
class nn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsTimestamp(t, n) {
    return (n || new nn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + kt), (n || new nn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Qs.SECOND;
  }
  timezone(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  static startTimestamp(t) {
    t.startObject(2);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Qs.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, i) {
    return nn.startTimestamp(t), nn.addUnit(t, n), nn.addTimezone(t, i), nn.endTimestamp(t);
  }
}
var Tu;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(Tu || (Tu = {}));
class Le {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsUnion(t, n) {
    return (n || new Le()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + kt), (n || new Le()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  mode() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Tu.Sparse;
  }
  typeIds(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.readInt32(this.bb.__vector(this.bb_pos + n) + t * 4) : 0;
  }
  typeIdsLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  typeIdsArray() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? new Int32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + t), this.bb.__vector_len(this.bb_pos + t)) : null;
  }
  static startUnion(t) {
    t.startObject(2);
  }
  static addMode(t, n) {
    t.addFieldInt16(0, n, Tu.Sparse);
  }
  static addTypeIds(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createTypeIdsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addInt32(n[i]);
    return t.endVector();
  }
  static startTypeIdsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endUnion(t) {
    return t.endObject();
  }
  static createUnion(t, n, i) {
    return Le.startUnion(t), Le.addMode(t, n), Le.addTypeIds(t, i), Le.endUnion(t);
  }
}
class Rr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsUtf8(t, n) {
    return (n || new Rr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + kt), (n || new Rr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return Rr.startUtf8(t), Rr.endUtf8(t);
  }
}
var Wt;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Null = 1] = "Null", e[e.Int = 2] = "Int", e[e.FloatingPoint = 3] = "FloatingPoint", e[e.Binary = 4] = "Binary", e[e.Utf8 = 5] = "Utf8", e[e.Bool = 6] = "Bool", e[e.Decimal = 7] = "Decimal", e[e.Date = 8] = "Date", e[e.Time = 9] = "Time", e[e.Timestamp = 10] = "Timestamp", e[e.Interval = 11] = "Interval", e[e.List = 12] = "List", e[e.Struct_ = 13] = "Struct_", e[e.Union = 14] = "Union", e[e.FixedSizeBinary = 15] = "FixedSizeBinary", e[e.FixedSizeList = 16] = "FixedSizeList", e[e.Map = 17] = "Map", e[e.Duration = 18] = "Duration", e[e.LargeBinary = 19] = "LargeBinary", e[e.LargeUtf8 = 20] = "LargeUtf8", e[e.LargeList = 21] = "LargeList";
})(Wt || (Wt = {}));
let Qe = class Kc {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsField(t, n) {
    return (n || new Kc()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + kt), (n || new Kc()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  name(t) {
    const n = this.bb.__offset(this.bb_pos, 4);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  /**
   * Whether or not this field can contain nulls. Should be true in general.
   */
  nullable() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  typeType() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.readUint8(this.bb_pos + t) : Wt.NONE;
  }
  /**
   * This is the type of the decoded value if the field is dictionary encoded.
   */
  // @ts-ignore
  type(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  /**
   * Present only if the field is dictionary encoded.
   */
  dictionary(t) {
    const n = this.bb.__offset(this.bb_pos, 12);
    return n ? (t || new Si()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * children apply only to nested data types like Struct, List and Union. For
   * primitive types children will have length 0.
   */
  children(t, n) {
    const i = this.bb.__offset(this.bb_pos, 14);
    return i ? (n || new Kc()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  childrenLength() {
    const t = this.bb.__offset(this.bb_pos, 14);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * User-defined metadata
   */
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 16);
    return i ? (n || new se()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 16);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startField(t) {
    t.startObject(7);
  }
  static addName(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addNullable(t, n) {
    t.addFieldInt8(1, +n, 0);
  }
  static addTypeType(t, n) {
    t.addFieldInt8(2, n, Wt.NONE);
  }
  static addType(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static addDictionary(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static addChildren(t, n) {
    t.addFieldOffset(5, n, 0);
  }
  static createChildrenVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startChildrenVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(6, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endField(t) {
    return t.endObject();
  }
}, Ln = class mi {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsSchema(t, n) {
    return (n || new mi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsSchema(t, n) {
    return t.setPosition(t.position() + kt), (n || new mi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * endianness of the buffer
   * it is Little Endian by default
   * if endianness doesn't match the underlying system then the vectors need to be converted
   */
  endianness() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Js.Little;
  }
  fields(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new Qe()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  fieldsLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new se()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Features used in the stream/file.
   */
  features(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.readInt64(this.bb.__vector(this.bb_pos + n) + t * 8) : this.bb.createLong(0, 0);
  }
  featuresLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startSchema(t) {
    t.startObject(4);
  }
  static addEndianness(t, n) {
    t.addFieldInt16(0, n, Js.Little);
  }
  static addFields(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createFieldsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startFieldsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addFeatures(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static createFeaturesVector(t, n) {
    t.startVector(8, n.length, 8);
    for (let i = n.length - 1; i >= 0; i--)
      t.addInt64(n[i]);
    return t.endVector();
  }
  static startFeaturesVector(t, n) {
    t.startVector(8, n, 8);
  }
  static endSchema(t) {
    return t.endObject();
  }
  static finishSchemaBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedSchemaBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
  static createSchema(t, n, i, r, s) {
    return mi.startSchema(t), mi.addEndianness(t, n), mi.addFields(t, i), mi.addCustomMetadata(t, r), mi.addFeatures(t, s), mi.endSchema(t);
  }
};
class Pe {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsFooter(t, n) {
    return (n || new Pe()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + kt), (n || new Pe()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  version() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Ks.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Ln()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  dictionaries(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new md()).__init(this.bb.__vector(this.bb_pos + i) + t * 24, this.bb) : null;
  }
  dictionariesLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  recordBatches(t, n) {
    const i = this.bb.__offset(this.bb_pos, 10);
    return i ? (n || new md()).__init(this.bb.__vector(this.bb_pos + i) + t * 24, this.bb) : null;
  }
  recordBatchesLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * User-defined metadata
   */
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new se()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 12);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startFooter(t) {
    t.startObject(5);
  }
  static addVersion(t, n) {
    t.addFieldInt16(0, n, Ks.V1);
  }
  static addSchema(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addDictionaries(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startDictionariesVector(t, n) {
    t.startVector(24, n, 8);
  }
  static addRecordBatches(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static startRecordBatchesVector(t, n) {
    t.startVector(24, n, 8);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endFooter(t) {
    return t.endObject();
  }
  static finishFooterBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedFooterBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
}
class Et {
  constructor(t = [], n, i) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), i || (i = bd(t)), this.dictionaries = i;
  }
  get [Symbol.toStringTag]() {
    return "Schema";
  }
  get names() {
    return this.fields.map((t) => t.name);
  }
  toString() {
    return `Schema<{ ${this.fields.map((t, n) => `${n}: ${t}`).join(", ")} }>`;
  }
  /**
   * Construct a new Schema containing only specified fields.
   *
   * @param fieldNames Names of fields to keep.
   * @returns A new Schema of fields matching the specified names.
   */
  select(t) {
    const n = new Set(t), i = this.fields.filter((r) => n.has(r.name));
    return new Et(i, this.metadata);
  }
  /**
   * Construct a new Schema containing only fields at the specified indices.
   *
   * @param fieldIndices Indices of fields to keep.
   * @returns A new Schema of fields at the specified indices.
   */
  selectAt(t) {
    const n = t.map((i) => this.fields[i]).filter(Boolean);
    return new Et(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof Et ? t[0] : Array.isArray(t[0]) ? new Et(t[0]) : new Et(t), i = [...this.fields], r = gc(gc(/* @__PURE__ */ new Map(), this.metadata), n.metadata), s = n.fields.filter((a) => {
      const c = i.findIndex((u) => u.name === a.name);
      return ~c ? (i[c] = a.clone({
        metadata: gc(gc(/* @__PURE__ */ new Map(), i[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = bd(s, /* @__PURE__ */ new Map());
    return new Et([...i, ...s], r, new Map([...this.dictionaries, ...o]));
  }
}
Et.prototype.fields = null;
Et.prototype.metadata = null;
Et.prototype.dictionaries = null;
class qt {
  constructor(t, n, i = !1, r) {
    this.name = t, this.type = n, this.nullable = i, this.metadata = r || /* @__PURE__ */ new Map();
  }
  /** @nocollapse */
  static new(...t) {
    let [n, i, r, s] = t;
    return t[0] && typeof t[0] == "object" && ({ name: n } = t[0], i === void 0 && (i = t[0].type), r === void 0 && (r = t[0].nullable), s === void 0 && (s = t[0].metadata)), new qt(`${n}`, i, r, s);
  }
  get typeId() {
    return this.type.typeId;
  }
  get [Symbol.toStringTag]() {
    return "Field";
  }
  toString() {
    return `${this.name}: ${this.type}`;
  }
  clone(...t) {
    let [n, i, r, s] = t;
    return !t[0] || typeof t[0] != "object" ? [n = this.name, i = this.type, r = this.nullable, s = this.metadata] = t : { name: n = this.name, type: i = this.type, nullable: r = this.nullable, metadata: s = this.metadata } = t[0], qt.new(n, i, r, s);
  }
}
qt.prototype.type = null;
qt.prototype.name = null;
qt.prototype.nullable = null;
qt.prototype.metadata = null;
function gc(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function bd(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, i = e.length; ++n < i; ) {
    const s = e[n].type;
    if (at.isDictionary(s)) {
      if (!t.has(s.id))
        t.set(s.id, s.dictionary);
      else if (t.get(s.id) !== s.dictionary)
        throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
    }
    s.children && s.children.length > 0 && bd(s.children, t);
  }
  return t;
}
var hy = Ni, MM = N2, AM = Zs;
class G0 {
  constructor(t, n = rn.V4, i, r) {
    this.schema = t, this.version = n, i && (this._recordBatches = i), r && (this._dictionaryBatches = r);
  }
  /** @nocollapse */
  static decode(t) {
    t = new AM(Tt(t));
    const n = Pe.getRootAsFooter(t), i = Et.decode(n.schema());
    return new $M(i, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new MM(), i = Et.encode(n, t.schema);
    Pe.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      to.encode(n, o);
    const r = n.endVector();
    Pe.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      to.encode(n, o);
    const s = n.endVector();
    return Pe.startFooter(n), Pe.addSchema(n, i), Pe.addVersion(n, rn.V4), Pe.addRecordBatches(n, r), Pe.addDictionaries(n, s), Pe.finishFooterBuffer(n, Pe.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  *recordBatches() {
    for (let t, n = -1, i = this.numRecordBatches; ++n < i; )
      (t = this.getRecordBatch(n)) && (yield t);
  }
  *dictionaryBatches() {
    for (let t, n = -1, i = this.numDictionaries; ++n < i; )
      (t = this.getDictionaryBatch(n)) && (yield t);
  }
  getRecordBatch(t) {
    return t >= 0 && t < this.numRecordBatches && this._recordBatches[t] || null;
  }
  getDictionaryBatch(t) {
    return t >= 0 && t < this.numDictionaries && this._dictionaryBatches[t] || null;
  }
}
class $M extends G0 {
  constructor(t, n) {
    super(t, n.version()), this._footer = n;
  }
  get numRecordBatches() {
    return this._footer.recordBatchesLength();
  }
  get numDictionaries() {
    return this._footer.dictionariesLength();
  }
  getRecordBatch(t) {
    if (t >= 0 && t < this.numRecordBatches) {
      const n = this._footer.recordBatches(t);
      if (n)
        return to.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return to.decode(n);
    }
    return null;
  }
}
class to {
  constructor(t, n, i) {
    this.metaDataLength = t, this.offset = typeof i == "number" ? i : i.low, this.bodyLength = typeof n == "number" ? n : n.low;
  }
  /** @nocollapse */
  static decode(t) {
    return new to(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: i } = n, r = new hy(n.offset, 0), s = new hy(n.bodyLength, 0);
    return md.createBlock(t, r, i, s);
  }
}
const Ht = Object.freeze({ done: !0, value: void 0 });
class dy {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}
class F2 {
  tee() {
    return this._getDOMStream().tee();
  }
  pipe(t, n) {
    return this._getNodeStream().pipe(t, n);
  }
  pipeTo(t, n) {
    return this._getDOMStream().pipeTo(t, n);
  }
  pipeThrough(t, n) {
    return this._getDOMStream().pipeThrough(t, n);
  }
  _getDOMStream() {
    return this._DOMStream || (this._DOMStream = this.toDOMStream());
  }
  _getNodeStream() {
    return this._nodeStream || (this._nodeStream = this.toNodeStream());
  }
}
class IM extends F2 {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return J(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  write(t) {
    this._ensureOpen() && (this.resolvers.length <= 0 ? this._values.push(t) : this.resolvers.shift().resolve({ done: !1, value: t }));
  }
  abort(t) {
    this._closedPromiseResolve && (this.resolvers.length <= 0 ? this._error = { error: t } : this.resolvers.shift().reject({ done: !0, value: t }));
  }
  close() {
    if (this._closedPromiseResolve) {
      const { resolvers: t } = this;
      for (; t.length > 0; )
        t.shift().resolve(Ht);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return tn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return tn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return J(this, void 0, void 0, function* () {
      return yield this.abort(t), Ht;
    });
  }
  return(t) {
    return J(this, void 0, void 0, function* () {
      return yield this.close(), Ht;
    });
  }
  read(t) {
    return J(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return J(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(...t) {
    return this._values.length > 0 ? Promise.resolve({ done: !1, value: this._values.shift() }) : this._error ? Promise.reject({ done: !0, value: this._error.error }) : this._closedPromiseResolve ? new Promise((n, i) => {
      this.resolvers.push({ resolve: n, reject: i });
    }) : Promise.resolve(Ht);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}
class TM extends IM {
  write(t) {
    if ((t = Tt(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? ud(this.toUint8Array(!0)) : this.toUint8Array(!1).then(ud);
  }
  toUint8Array(t = !1) {
    return t ? Jn(this._values)[0] : (() => J(this, void 0, void 0, function* () {
      var n, i;
      const r = [];
      let s = 0;
      try {
        for (var o = Cs(this), a; a = yield o.next(), !a.done; ) {
          const c = a.value;
          r.push(c), s += c.byteLength;
        }
      } catch (c) {
        n = { error: c };
      } finally {
        try {
          a && !a.done && (i = o.return) && (yield i.call(o));
        } finally {
          if (n)
            throw n.error;
        }
      }
      return Jn(r, s)[0];
    }))();
  }
}
class Eu {
  constructor(t) {
    t && (this.source = new EM(tn.fromIterable(t)));
  }
  [Symbol.iterator]() {
    return this;
  }
  next(t) {
    return this.source.next(t);
  }
  throw(t) {
    return this.source.throw(t);
  }
  return(t) {
    return this.source.return(t);
  }
  peek(t) {
    return this.source.peek(t);
  }
  read(t) {
    return this.source.read(t);
  }
}
class eo {
  constructor(t) {
    t instanceof eo ? this.source = t.source : t instanceof TM ? this.source = new $r(tn.fromAsyncIterable(t)) : db(t) ? this.source = new $r(tn.fromNodeStream(t)) : k0(t) ? this.source = new $r(tn.fromDOMStream(t)) : fb(t) ? this.source = new $r(tn.fromDOMStream(t.body)) : Yl(t) ? this.source = new $r(tn.fromIterable(t)) : ma(t) ? this.source = new $r(tn.fromAsyncIterable(t)) : C0(t) && (this.source = new $r(tn.fromAsyncIterable(t)));
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next(t) {
    return this.source.next(t);
  }
  throw(t) {
    return this.source.throw(t);
  }
  return(t) {
    return this.source.return(t);
  }
  get closed() {
    return this.source.closed;
  }
  cancel(t) {
    return this.source.cancel(t);
  }
  peek(t) {
    return this.source.peek(t);
  }
  read(t) {
    return this.source.read(t);
  }
}
class EM {
  constructor(t) {
    this.source = t;
  }
  cancel(t) {
    this.return(t);
  }
  peek(t) {
    return this.next(t, "peek").value;
  }
  read(t) {
    return this.next(t, "read").value;
  }
  next(t, n = "read") {
    return this.source.next({ cmd: n, size: t });
  }
  throw(t) {
    return Object.create(this.source.throw && this.source.throw(t) || Ht);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || Ht);
  }
}
class $r {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return J(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return J(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return J(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return J(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return J(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || Ht;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return J(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || Ht;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}
class py extends Eu {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Tt(t), this.size = typeof n > "u" ? this.buffer.byteLength : n;
  }
  readInt32(t) {
    const { buffer: n, byteOffset: i } = this.readAt(t, 4);
    return new DataView(n, i).getInt32(0, !0);
  }
  seek(t) {
    return this.position = Math.min(t, this.size), t < this.size;
  }
  read(t) {
    const { buffer: n, size: i, position: r } = this;
    return n && r < i ? (typeof t != "number" && (t = Number.POSITIVE_INFINITY), this.position = Math.min(i, r + Math.min(i - r, t)), n.subarray(r, this.position)) : null;
  }
  readAt(t, n) {
    const i = this.buffer, r = Math.min(this.size, t + n);
    return i ? i.subarray(t, r) : new Uint8Array(n);
  }
  close() {
    this.buffer && (this.buffer = null);
  }
  throw(t) {
    return this.close(), { done: !0, value: t };
  }
  return(t) {
    return this.close(), { done: !0, value: t };
  }
}
class Nu extends eo {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = (() => J(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    }))();
  }
  readInt32(t) {
    return J(this, void 0, void 0, function* () {
      const { buffer: n, byteOffset: i } = yield this.readAt(t, 4);
      return new DataView(n, i).getInt32(0, !0);
    });
  }
  seek(t) {
    return J(this, void 0, void 0, function* () {
      return this._pending && (yield this._pending), this.position = Math.min(t, this.size), t < this.size;
    });
  }
  read(t) {
    return J(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: n, size: i, position: r } = this;
      if (n && r < i) {
        typeof t != "number" && (t = Number.POSITIVE_INFINITY);
        let s = r, o = 0, a = 0;
        const c = Math.min(i, s + Math.min(i - s, t)), u = new Uint8Array(Math.max(0, (this.position = c) - s));
        for (; (s += a) < c && (o += a) < u.byteLength; )
          ({ bytesRead: a } = yield n.read(u, o, u.byteLength - o, s));
        return u;
      }
      return null;
    });
  }
  readAt(t, n) {
    return J(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: i, size: r } = this;
      if (i && t + n < r) {
        const s = Math.min(r, t + n), o = new Uint8Array(s - t);
        return (yield i.read(o, 0, n, t)).buffer;
      }
      return new Uint8Array(n);
    });
  }
  close() {
    return J(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return J(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return J(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
}
const NM = 1 << 16;
function Is(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const no = 8, Z0 = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
class D2 {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return this.buffer[1];
  }
  low() {
    return this.buffer[0];
  }
  _times(t) {
    const n = new Uint32Array([
      this.buffer[1] >>> 16,
      this.buffer[1] & 65535,
      this.buffer[0] >>> 16,
      this.buffer[0] & 65535
    ]), i = new Uint32Array([
      t.buffer[1] >>> 16,
      t.buffer[1] & 65535,
      t.buffer[0] >>> 16,
      t.buffer[0] & 65535
    ]);
    let r = n[3] * i[3];
    this.buffer[0] = r & 65535;
    let s = r >>> 16;
    return r = n[2] * i[3], s += r, r = n[3] * i[2] >>> 0, s += r, this.buffer[0] += s << 16, this.buffer[1] = s >>> 0 < r ? NM : 0, this.buffer[1] += s >>> 16, this.buffer[1] += n[1] * i[3] + n[2] * i[2] + n[3] * i[1], this.buffer[1] += n[0] * i[3] + n[1] * i[2] + n[2] * i[1] + n[3] * i[0] << 16, this;
  }
  _plus(t) {
    const n = this.buffer[0] + t.buffer[0] >>> 0;
    this.buffer[1] += t.buffer[1], n < this.buffer[0] >>> 0 && ++this.buffer[1], this.buffer[0] = n;
  }
  lessThan(t) {
    return this.buffer[1] < t.buffer[1] || this.buffer[1] === t.buffer[1] && this.buffer[0] < t.buffer[0];
  }
  equals(t) {
    return this.buffer[1] === t.buffer[1] && this.buffer[0] == t.buffer[0];
  }
  greaterThan(t) {
    return t.lessThan(this);
  }
  hex() {
    return `${Is(this.buffer[1])} ${Is(this.buffer[0])}`;
  }
}
class Ft extends D2 {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Ft.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Ft.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.length, r = new Ft(n);
    for (let s = 0; s < i; ) {
      const o = no < i - s ? no : i - s, a = new Ft(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Ft(new Uint32Array([Z0[o], 0]));
      r.times(c), r.plus(a), s += o;
    }
    return r;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      Ft.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Ft(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Ft(new Uint32Array(t.buffer)).plus(n);
  }
}
class Fe extends D2 {
  negate() {
    return this.buffer[0] = ~this.buffer[0] + 1, this.buffer[1] = ~this.buffer[1], this.buffer[0] == 0 && ++this.buffer[1], this;
  }
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  lessThan(t) {
    const n = this.buffer[1] << 0, i = t.buffer[1] << 0;
    return n < i || n === i && this.buffer[0] < t.buffer[0];
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Fe.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Fe.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.startsWith("-"), r = t.length, s = new Fe(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = no < r - o ? no : r - o, c = new Fe(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), u = new Fe(new Uint32Array([Z0[a], 0]));
      s.times(u), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      Fe.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Fe(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Fe(new Uint32Array(t.buffer)).plus(n);
  }
}
class Cn {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new Fe(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new Fe(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset, 2));
  }
  negate() {
    return this.buffer[0] = ~this.buffer[0] + 1, this.buffer[1] = ~this.buffer[1], this.buffer[2] = ~this.buffer[2], this.buffer[3] = ~this.buffer[3], this.buffer[0] == 0 && ++this.buffer[1], this.buffer[1] == 0 && ++this.buffer[2], this.buffer[2] == 0 && ++this.buffer[3], this;
  }
  times(t) {
    const n = new Ft(new Uint32Array([this.buffer[3], 0])), i = new Ft(new Uint32Array([this.buffer[2], 0])), r = new Ft(new Uint32Array([this.buffer[1], 0])), s = new Ft(new Uint32Array([this.buffer[0], 0])), o = new Ft(new Uint32Array([t.buffer[3], 0])), a = new Ft(new Uint32Array([t.buffer[2], 0])), c = new Ft(new Uint32Array([t.buffer[1], 0])), u = new Ft(new Uint32Array([t.buffer[0], 0]));
    let l = Ft.multiply(s, u);
    this.buffer[0] = l.low();
    const f = new Ft(new Uint32Array([l.high(), 0]));
    return l = Ft.multiply(r, u), f.plus(l), l = Ft.multiply(s, c), f.plus(l), this.buffer[1] = f.low(), this.buffer[3] = f.lessThan(l) ? 1 : 0, this.buffer[2] = f.high(), new Ft(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(Ft.multiply(i, u)).plus(Ft.multiply(r, c)).plus(Ft.multiply(s, a)), this.buffer[3] += Ft.multiply(n, u).plus(Ft.multiply(i, c)).plus(Ft.multiply(r, a)).plus(Ft.multiply(s, o)).low(), this;
  }
  plus(t) {
    const n = new Uint32Array(4);
    return n[3] = this.buffer[3] + t.buffer[3] >>> 0, n[2] = this.buffer[2] + t.buffer[2] >>> 0, n[1] = this.buffer[1] + t.buffer[1] >>> 0, n[0] = this.buffer[0] + t.buffer[0] >>> 0, n[0] < this.buffer[0] >>> 0 && ++n[1], n[1] < this.buffer[1] >>> 0 && ++n[2], n[2] < this.buffer[2] >>> 0 && ++n[3], this.buffer[3] = n[3], this.buffer[2] = n[2], this.buffer[1] = n[1], this.buffer[0] = n[0], this;
  }
  hex() {
    return `${Is(this.buffer[3])} ${Is(this.buffer[2])} ${Is(this.buffer[1])} ${Is(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Cn(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Cn(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return Cn.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return Cn.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const i = t.startsWith("-"), r = t.length, s = new Cn(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = no < r - o ? no : r - o, c = new Cn(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), u = new Cn(new Uint32Array([Z0[a], 0, 0, 0]));
      s.times(u), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 4);
    for (let i = -1, r = t.length; ++i < r; )
      Cn.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * i, 4));
    return n;
  }
}
class B2 extends xt {
  constructor(t, n, i, r) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = i, this.dictionaries = r;
  }
  visit(t) {
    return super.visit(t instanceof qt ? t.type : t);
  }
  visitNull(t, { length: n } = this.nextFieldNode()) {
    return _t({ type: t, length: n });
  }
  visitBool(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitInt(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFloat(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitUtf8(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitFixedSizeBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDate(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTimestamp(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTime(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDecimal(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  visitStruct(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), children: this.visitMany(t.children) });
  }
  visitUnion(t) {
    return t.mode === $n.Sparse ? this.visitSparseUnion(t) : this.visitDenseUnion(t);
  }
  visitDenseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), typeIds: this.readTypeIds(t), valueOffsets: this.readOffsets(t), children: this.visitMany(t.children) });
  }
  visitSparseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), typeIds: this.readTypeIds(t), children: this.visitMany(t.children) });
  }
  visitDictionary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t.indices), dictionary: this.readDictionary(t) });
  }
  visitInterval(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFixedSizeList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), child: this.visit(t.children[0]) });
  }
  visitMap(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return _t({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  nextFieldNode() {
    return this.nodes[++this.nodesIndex];
  }
  nextBufferRange() {
    return this.buffers[++this.buffersIndex];
  }
  readNullBitmap(t, n, i = this.nextBufferRange()) {
    return n > 0 && this.readData(t, i) || new Uint8Array(0);
  }
  readOffsets(t, n) {
    return this.readData(t, n);
  }
  readTypeIds(t, n) {
    return this.readData(t, n);
  }
  readData(t, { length: n, offset: i } = this.nextBufferRange()) {
    return this.bytes.subarray(i, i + n);
  }
  readDictionary(t) {
    return this.dictionaries.get(t.id);
  }
}
class OM extends B2 {
  constructor(t, n, i, r) {
    super(new Uint8Array(0), n, i, r), this.sources = t;
  }
  readNullBitmap(t, n, { offset: i } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : dd(this.sources[i]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return Ct(Uint8Array, Ct(Int32Array, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return Ct(Uint8Array, Ct(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: i } = this;
    return at.isTimestamp(t) || (at.isInt(t) || at.isTime(t)) && t.bitWidth === 64 || at.isDate(t) && t.unit === Di.MILLISECOND ? Ct(Uint8Array, Fe.convertArray(i[n])) : at.isDecimal(t) ? Ct(Uint8Array, Cn.convertArray(i[n])) : at.isBinary(t) || at.isFixedSizeBinary(t) ? FM(i[n]) : at.isBool(t) ? dd(i[n]) : at.isUtf8(t) ? L0(i[n].join("")) : Ct(Uint8Array, Ct(t.ArrayType, i[n].map((r) => +r)));
  }
}
function FM(e) {
  const t = e.join(""), n = new Uint8Array(t.length / 2);
  for (let i = 0; i < t.length; i += 2)
    n[i >> 1] = Number.parseInt(t.slice(i, i + 2), 16);
  return n;
}
class nt extends xt {
  compareSchemas(t, n) {
    return t === n || n instanceof t.constructor && this.compareManyFields(t.fields, n.fields);
  }
  compareManyFields(t, n) {
    return t === n || Array.isArray(t) && Array.isArray(n) && t.length === n.length && t.every((i, r) => this.compareFields(i, n[r]));
  }
  compareFields(t, n) {
    return t === n || n instanceof t.constructor && t.name === n.name && t.nullable === n.nullable && this.visit(t.type, n.type);
  }
}
function ze(e, t) {
  return t instanceof e.constructor;
}
function Va(e, t) {
  return e === t || ze(e, t);
}
function Pi(e, t) {
  return e === t || ze(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function Vl(e, t) {
  return e === t || ze(e, t) && e.precision === t.precision;
}
function DM(e, t) {
  return e === t || ze(e, t) && e.byteWidth === t.byteWidth;
}
function K0(e, t) {
  return e === t || ze(e, t) && e.unit === t.unit;
}
function ja(e, t) {
  return e === t || ze(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function Xa(e, t) {
  return e === t || ze(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function BM(e, t) {
  return e === t || ze(e, t) && e.children.length === t.children.length && ir.compareManyFields(e.children, t.children);
}
function LM(e, t) {
  return e === t || ze(e, t) && e.children.length === t.children.length && ir.compareManyFields(e.children, t.children);
}
function J0(e, t) {
  return e === t || ze(e, t) && e.mode === t.mode && e.typeIds.every((n, i) => n === t.typeIds[i]) && ir.compareManyFields(e.children, t.children);
}
function CM(e, t) {
  return e === t || ze(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && ir.visit(e.indices, t.indices) && ir.visit(e.dictionary, t.dictionary);
}
function Q0(e, t) {
  return e === t || ze(e, t) && e.unit === t.unit;
}
function kM(e, t) {
  return e === t || ze(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && ir.compareManyFields(e.children, t.children);
}
function RM(e, t) {
  return e === t || ze(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && ir.compareManyFields(e.children, t.children);
}
nt.prototype.visitNull = Va;
nt.prototype.visitBool = Va;
nt.prototype.visitInt = Pi;
nt.prototype.visitInt8 = Pi;
nt.prototype.visitInt16 = Pi;
nt.prototype.visitInt32 = Pi;
nt.prototype.visitInt64 = Pi;
nt.prototype.visitUint8 = Pi;
nt.prototype.visitUint16 = Pi;
nt.prototype.visitUint32 = Pi;
nt.prototype.visitUint64 = Pi;
nt.prototype.visitFloat = Vl;
nt.prototype.visitFloat16 = Vl;
nt.prototype.visitFloat32 = Vl;
nt.prototype.visitFloat64 = Vl;
nt.prototype.visitUtf8 = Va;
nt.prototype.visitBinary = Va;
nt.prototype.visitFixedSizeBinary = DM;
nt.prototype.visitDate = K0;
nt.prototype.visitDateDay = K0;
nt.prototype.visitDateMillisecond = K0;
nt.prototype.visitTimestamp = ja;
nt.prototype.visitTimestampSecond = ja;
nt.prototype.visitTimestampMillisecond = ja;
nt.prototype.visitTimestampMicrosecond = ja;
nt.prototype.visitTimestampNanosecond = ja;
nt.prototype.visitTime = Xa;
nt.prototype.visitTimeSecond = Xa;
nt.prototype.visitTimeMillisecond = Xa;
nt.prototype.visitTimeMicrosecond = Xa;
nt.prototype.visitTimeNanosecond = Xa;
nt.prototype.visitDecimal = Va;
nt.prototype.visitList = BM;
nt.prototype.visitStruct = LM;
nt.prototype.visitUnion = J0;
nt.prototype.visitDenseUnion = J0;
nt.prototype.visitSparseUnion = J0;
nt.prototype.visitDictionary = CM;
nt.prototype.visitInterval = Q0;
nt.prototype.visitIntervalDayTime = Q0;
nt.prototype.visitIntervalYearMonth = Q0;
nt.prototype.visitFixedSizeList = kM;
nt.prototype.visitMap = RM;
const ir = new nt();
function UM(e, t) {
  return ir.compareSchemas(e, t);
}
function lh(e, t) {
  return zM(e, t.map((n) => n.data.concat()));
}
function zM(e, t) {
  const n = [...e.fields], i = [], r = { numBatches: t.reduce((f, h) => Math.max(f, h.length), 0) };
  let s = 0, o = 0, a = -1;
  const c = t.length;
  let u, l = [];
  for (; r.numBatches-- > 0; ) {
    for (o = Number.POSITIVE_INFINITY, a = -1; ++a < c; )
      l[a] = u = t[a].shift(), o = Math.min(o, u ? u.length : o);
    Number.isFinite(o) && (l = PM(n, o, l, t, r), o > 0 && (i[s++] = _t({
      type: new Ee(n),
      length: o,
      nullCount: 0,
      children: l.slice()
    })));
  }
  return [
    e = e.assign(n),
    i.map((f) => new bn(e, f))
  ];
}
function PM(e, t, n, i, r) {
  var s;
  const o = (t + 63 & -64) >> 3;
  for (let a = -1, c = i.length; ++a < c; ) {
    const u = n[a], l = u == null ? void 0 : u.length;
    if (l >= t)
      l === t ? n[a] = u : (n[a] = u.slice(0, t), r.numBatches = Math.max(r.numBatches, i[a].unshift(u.slice(t, l - t))));
    else {
      const f = e[a];
      e[a] = f.clone({ nullable: !0 }), n[a] = (s = u == null ? void 0 : u._changeLengthAndBackfillNullBitmap(t)) !== null && s !== void 0 ? s : _t({
        type: f.type,
        length: t,
        nullCount: t,
        nullBitmap: new Uint8Array(o)
      });
    }
  }
  return n;
}
var L2;
let va = class Er {
  constructor(...t) {
    var n, i;
    if (t.length === 0)
      return this.batches = [], this.schema = new Et([]), this._offsets = [0], this;
    let r, s;
    t[0] instanceof Et && (r = t.shift()), t[t.length - 1] instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof bn)
          return [c];
        if (c instanceof Er)
          return c.batches;
        if (c instanceof Ut) {
          if (c.type instanceof Ee)
            return [new bn(new Et(c.type.children), c)];
        } else {
          if (Array.isArray(c))
            return c.flatMap((u) => o(u));
          if (typeof c[Symbol.iterator] == "function")
            return [...c].flatMap((u) => o(u));
          if (typeof c == "object") {
            const u = Object.keys(c), l = u.map((d) => new ee([c[d]])), f = new Et(u.map((d, p) => new qt(String(d), l[p].type))), [, h] = lh(f, l);
            return h.length === 0 ? [new bn(c)] : h;
          }
        }
      }
      return [];
    }, a = t.flatMap((c) => o(c));
    if (r = (i = r ?? ((n = a[0]) === null || n === void 0 ? void 0 : n.schema)) !== null && i !== void 0 ? i : new Et([]), !(r instanceof Et))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof bn))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!UM(r, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = r, this.batches = a, this._offsets = s ?? w2(this.data);
  }
  /**
   * The contiguous {@link RecordBatch `RecordBatch`} chunks of the Table rows.
   */
  get data() {
    return this.batches.map(({ data: t }) => t);
  }
  /**
   * The number of columns in this Table.
   */
  get numCols() {
    return this.schema.fields.length;
  }
  /**
   * The number of rows in this Table.
   */
  get numRows() {
    return this.data.reduce((t, n) => t + n.length, 0);
  }
  /**
   * The number of null rows in this Table.
   */
  get nullCount() {
    return this._nullCount === -1 && (this._nullCount = b2(this.data)), this._nullCount;
  }
  /**
   * Check whether an element is null.
   *
   * @param index The index at which to read the validity bitmap.
   */
  // @ts-ignore
  isValid(t) {
    return !1;
  }
  /**
   * Get an element value by position.
   *
   * @param index The index of the element to read.
   */
  // @ts-ignore
  get(t) {
    return null;
  }
  /**
   * Set an element value by position.
   *
   * @param index The index of the element to write.
   * @param value The value to set.
   */
  // @ts-ignore
  set(t, n) {
  }
  /**
   * Retrieve the index of the first occurrence of a value in an Vector.
   *
   * @param element The value to locate in the Vector.
   * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.
   */
  // @ts-ignore
  indexOf(t, n) {
    return -1;
  }
  /**
   * Get the size in bytes of an element by index.
   * @param index The index at which to get the byteLength.
   */
  // @ts-ignore
  getByteLength(t) {
    return 0;
  }
  /**
   * Iterator for rows in this Table.
   */
  [Symbol.iterator]() {
    return this.batches.length > 0 ? H0.visit(new ee(this.data)) : new Array(0)[Symbol.iterator]();
  }
  /**
   * Return a JavaScript Array of the Table rows.
   *
   * @returns An Array of Table rows.
   */
  toArray() {
    return [...this];
  }
  /**
   * Returns a string representation of the Table rows.
   *
   * @returns A string representation of the Table rows.
   */
  toString() {
    return `[
  ${this.toArray().join(`,
  `)}
]`;
  }
  /**
   * Combines two or more Tables of the same schema.
   *
   * @param others Additional Tables to add to the end of this Tables.
   */
  concat(...t) {
    const n = this.schema, i = this.data.concat(t.flatMap(({ data: r }) => r));
    return new Er(n, i.map((r) => new bn(n, r)));
  }
  /**
   * Return a zero-copy sub-section of this Table.
   *
   * @param begin The beginning of the specified portion of the Table.
   * @param end The end of the specified portion of the Table. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    const i = this.schema;
    [t, n] = y2({ length: this.numRows }, t, n);
    const r = _2(this.data, this._offsets, t, n);
    return new Er(i, r.map((s) => new bn(i, s)));
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   *
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    return this.getChildAt(this.schema.fields.findIndex((n) => n.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   *
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    if (t > -1 && t < this.schema.fields.length) {
      const n = this.data.map((i) => i.children[t]);
      if (n.length === 0) {
        const { type: i } = this.schema.fields[t], r = _t({ type: i, length: 0, nullCount: 0 });
        n.push(r._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new ee(n);
    }
    return null;
  }
  /**
   * Sets a child Vector by name.
   *
   * @param name The name of the child to overwrite.
   * @returns A new Table with the supplied child for the specified name.
   */
  setChild(t, n) {
    var i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = [...this.batches];
    if (t > -1 && t < this.numCols) {
      n || (n = new ee([_t({ type: new er(), length: this.numRows })]));
      const s = i.fields.slice(), o = s[t].clone({ type: n.type }), a = this.schema.fields.map((c, u) => this.getChildAt(u));
      [s[t], a[t]] = [o, n], [i, r] = lh(i, a);
    }
    return new Er(i, r);
  }
  /**
   * Construct a new Table containing only specified columns.
   *
   * @param columnNames Names of columns to keep.
   * @returns A new Table of columns matching the specified names.
   */
  select(t) {
    const n = this.schema.fields.reduce((i, r, s) => i.set(r.name, s), /* @__PURE__ */ new Map());
    return this.selectAt(t.map((i) => n.get(i)).filter((i) => i > -1));
  }
  /**
   * Construct a new Table containing only columns at the specified indices.
   *
   * @param columnIndices Indices of columns to keep.
   * @returns A new Table of columns at the specified indices.
   */
  selectAt(t) {
    const n = this.schema.selectAt(t), i = this.batches.map((r) => r.selectAt(t));
    return new Er(n, i);
  }
  assign(t) {
    const n = this.schema.fields, [i, r] = t.schema.fields.reduce((a, c, u) => {
      const [l, f] = a, h = n.findIndex((d) => d.name === c.name);
      return ~h ? f[h] = u : l.push(u), a;
    }, [[], []]), s = this.schema.assign(t.schema), o = [
      ...n.map((a, c) => [c, r[c]]).map(([a, c]) => c === void 0 ? this.getChildAt(a) : t.getChildAt(c)),
      ...i.map((a) => t.getChildAt(a))
    ].filter(Boolean);
    return new Er(...lh(s, o));
  }
};
L2 = Symbol.toStringTag;
va[L2] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = Ps(W0), e.get = Ps(ke.getVisitFn(B.Struct)), e.set = v2(hn.getVisitFn(B.Struct)), e.indexOf = x2(xu.getVisitFn(B.Struct)), e.getByteLength = Ps(Qn.getVisitFn(B.Struct)), "Table"))(va.prototype);
var C2;
let bn = class Ko {
  constructor(...t) {
    switch (t.length) {
      case 2: {
        if ([this.schema] = t, !(this.schema instanceof Et))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = _t({
            nullCount: 0,
            type: new Ee(this.schema.fields),
            children: this.schema.fields.map((n) => _t({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof Ut))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = my(this.schema, this.data.children);
        break;
      }
      case 1: {
        const [n] = t, { fields: i, children: r, length: s } = Object.keys(n).reduce((c, u, l) => (c.children[l] = n[u], c.length = Math.max(c.length, n[u].length), c.fields[l] = qt.new({ name: u, type: n[u].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new Et(i), a = _t({ type: new Ee(i), length: s, children: r, nullCount: 0 });
        [this.schema, this.data] = my(o, a.children, s);
        break;
      }
      default:
        throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.");
    }
  }
  get dictionaries() {
    return this._dictionaries || (this._dictionaries = k2(this.schema.fields, this.data.children));
  }
  /**
   * The number of columns in this RecordBatch.
   */
  get numCols() {
    return this.schema.fields.length;
  }
  /**
   * The number of rows in this RecordBatch.
   */
  get numRows() {
    return this.data.length;
  }
  /**
   * The number of null rows in this RecordBatch.
   */
  get nullCount() {
    return this.data.nullCount;
  }
  /**
   * Check whether an element is null.
   * @param index The index at which to read the validity bitmap.
   */
  isValid(t) {
    return this.data.getValid(t);
  }
  /**
   * Get a row by position.
   * @param index The index of the element to read.
   */
  get(t) {
    return ke.visit(this.data, t);
  }
  /**
   * Set a row by position.
   * @param index The index of the element to write.
   * @param value The value to set.
   */
  set(t, n) {
    return hn.visit(this.data, t, n);
  }
  /**
   * Retrieve the index of the first occurrence of a row in an RecordBatch.
   * @param element The row to locate in the RecordBatch.
   * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.
   */
  indexOf(t, n) {
    return xu.visit(this.data, t, n);
  }
  /**
   * Get the size (in bytes) of a row by index.
   * @param index The row index for which to compute the byteLength.
   */
  getByteLength(t) {
    return Qn.visit(this.data, t);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return H0.visit(new ee([this.data]));
  }
  /**
   * Return a JavaScript Array of the RecordBatch rows.
   * @returns An Array of RecordBatch rows.
   */
  toArray() {
    return [...this];
  }
  /**
   * Combines two or more RecordBatch of the same schema.
   * @param others Additional RecordBatch to add to the end of this RecordBatch.
   */
  concat(...t) {
    return new va(this.schema, [this, ...t]);
  }
  /**
   * Return a zero-copy sub-section of this RecordBatch.
   * @param start The beginning of the specified portion of the RecordBatch.
   * @param end The end of the specified portion of the RecordBatch. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    const [i] = new ee([this.data]).slice(t, n).data;
    return new Ko(this.schema, i);
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    var n;
    return this.getChildAt((n = this.schema.fields) === null || n === void 0 ? void 0 : n.findIndex((i) => i.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    return t > -1 && t < this.schema.fields.length ? new ee([this.data.children[t]]) : null;
  }
  /**
   * Sets a child Vector by name.
   * @param name The name of the child to overwrite.
   * @returns A new RecordBatch with the new child for the specified name.
   */
  setChild(t, n) {
    var i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = this.data;
    if (t > -1 && t < this.numCols) {
      n || (n = new ee([_t({ type: new er(), length: this.numRows })]));
      const s = i.fields.slice(), o = r.children.slice(), a = s[t].clone({ type: n.type });
      [s[t], o[t]] = [a, n.data[0]], i = new Et(s, new Map(this.schema.metadata)), r = _t({ type: new Ee(s), children: o });
    }
    return new Ko(i, r);
  }
  /**
   * Construct a new RecordBatch containing only specified columns.
   *
   * @param columnNames Names of columns to keep.
   * @returns A new RecordBatch of columns matching the specified names.
   */
  select(t) {
    const n = this.schema.select(t), i = new Ee(n.fields), r = [];
    for (const s of t) {
      const o = this.schema.fields.findIndex((a) => a.name === s);
      ~o && (r[o] = this.data.children[o]);
    }
    return new Ko(n, _t({ type: i, length: this.numRows, children: r }));
  }
  /**
   * Construct a new RecordBatch containing only columns at the specified indices.
   *
   * @param columnIndices Indices of columns to keep.
   * @returns A new RecordBatch of columns matching at the specified indices.
   */
  selectAt(t) {
    const n = this.schema.selectAt(t), i = t.map((s) => this.data.children[s]).filter(Boolean), r = _t({ type: new Ee(n.fields), length: this.numRows, children: i });
    return new Ko(n, r);
  }
};
C2 = Symbol.toStringTag;
bn[C2] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(bn.prototype);
function my(e, t, n = t.reduce((i, r) => Math.max(i, r.length), 0)) {
  var i;
  const r = [...e.fields], s = [...t], o = (n + 63 & -64) >> 3;
  for (const [a, c] of e.fields.entries()) {
    const u = t[a];
    (!u || u.length !== n) && (r[a] = c.clone({ nullable: !0 }), s[a] = (i = u == null ? void 0 : u._changeLengthAndBackfillNullBitmap(n)) !== null && i !== void 0 ? i : _t({
      type: c.type,
      length: n,
      nullCount: n,
      nullBitmap: new Uint8Array(o)
    }));
  }
  return [
    e.assign(r),
    _t({ type: new Ee(r), length: n, children: s })
  ];
}
function k2(e, t, n = /* @__PURE__ */ new Map()) {
  for (let i = -1, r = e.length; ++i < r; ) {
    const o = e[i].type, a = t[i];
    if (at.isDictionary(o)) {
      if (!n.has(o.id))
        a.dictionary && n.set(o.id, a.dictionary);
      else if (n.get(o.id) !== a.dictionary)
        throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
    }
    o.children && o.children.length > 0 && k2(o.children, a.children, n);
  }
  return n;
}
class R2 extends bn {
  constructor(t) {
    const n = t.fields.map((r) => _t({ type: r.type })), i = _t({ type: new Ee(t.fields), nullCount: 0, children: n });
    super(t, i);
  }
}
var Ou;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(Ou || (Ou = {}));
var Fu;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(Fu || (Fu = {}));
class Wi {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsBodyCompression(t, n) {
    return (n || new Wi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + kt), (n || new Wi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Compressor library.
   * For LZ4_FRAME, each compressed buffer must consist of a single frame.
   */
  codec() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt8(this.bb_pos + t) : Fu.LZ4_FRAME;
  }
  /**
   * Indicates the way the record batch body was compressed
   */
  method() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readInt8(this.bb_pos + t) : Ou.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, Fu.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, Ou.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, i) {
    return Wi.startBodyCompression(t), Wi.addCodec(t, n), Wi.addMethod(t, i), Wi.endBodyCompression(t);
  }
}
class U2 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * The relative offset into the shared memory page where the bytes for this
   * buffer starts
   */
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * The absolute length (in bytes) of the memory buffer. The memory is found
   * from offset (inclusive) to offset + length (non-inclusive). When building
   * messages using the encapsulated IPC message, padding bytes may be written
   * after a buffer, but such padding bytes do not need to be accounted for in
   * the size here.
   */
  length() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createBuffer(t, n, i) {
    return t.prep(8, 16), t.writeInt64(i), t.writeInt64(n), t.offset();
  }
}
let z2 = class {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * The number of value slots in the Arrow array at this level of a nested
   * tree
   */
  length() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * The number of observed nulls. Fields with null_count == 0 may choose not
   * to write their physical validity bitmap out as a materialized buffer,
   * instead setting the length of the bitmap buffer to 0.
   */
  nullCount() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createFieldNode(t, n, i) {
    return t.prep(8, 16), t.writeInt64(i), t.writeInt64(n), t.offset();
  }
}, wi = class wd {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsRecordBatch(t, n) {
    return (n || new wd()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + kt), (n || new wd()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * number of records / rows. The arrays in the batch should all have this
   * length
   */
  length() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : this.bb.createLong(0, 0);
  }
  /**
   * Nodes correspond to the pre-ordered flattened logical schema
   */
  nodes(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new z2()).__init(this.bb.__vector(this.bb_pos + i) + t * 16, this.bb) : null;
  }
  nodesLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Buffers correspond to the pre-ordered flattened buffer tree
   *
   * The number of buffers appended to this list depends on the schema. For
   * example, most primitive arrays will have 2 buffers, 1 for the validity
   * bitmap and 1 for the values. For struct arrays, there will only be a
   * single buffer for the validity (nulls) bitmap
   */
  buffers(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new U2()).__init(this.bb.__vector(this.bb_pos + i) + t * 16, this.bb) : null;
  }
  buffersLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Optional compression of the message body
   */
  compression(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? (t || new Wi()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  static startRecordBatch(t) {
    t.startObject(4);
  }
  static addLength(t, n) {
    t.addFieldInt64(0, n, t.createLong(0, 0));
  }
  static addNodes(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static startNodesVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addBuffers(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startBuffersVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addCompression(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static endRecordBatch(t) {
    return t.endObject();
  }
}, As = class _d {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDictionaryBatch(t, n) {
    return (n || new _d()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + kt), (n || new _d()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : this.bb.createLong(0, 0);
  }
  data(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new wi()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * If isDelta is true the values in the dictionary are to be appended to a
   * dictionary with the indicated id. If isDelta is false this dictionary
   * should replace the existing dictionary.
   */
  isDelta() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startDictionaryBatch(t) {
    t.startObject(3);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, t.createLong(0, 0));
  }
  static addData(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsDelta(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static endDictionaryBatch(t) {
    return t.endObject();
  }
};
var Du;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Schema = 1] = "Schema", e[e.DictionaryBatch = 2] = "DictionaryBatch", e[e.RecordBatch = 3] = "RecordBatch", e[e.Tensor = 4] = "Tensor", e[e.SparseTensor = 5] = "SparseTensor";
})(Du || (Du = {}));
let Vi = class Bn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsMessage(t, n) {
    return (n || new Bn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + kt), (n || new Bn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  version() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Ks.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : Du.NONE;
  }
  // @ts-ignore
  header(t) {
    const n = this.bb.__offset(this.bb_pos, 8);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  bodyLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.readInt64(this.bb_pos + t) : this.bb.createLong(0, 0);
  }
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new se()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 12);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startMessage(t) {
    t.startObject(5);
  }
  static addVersion(t, n) {
    t.addFieldInt16(0, n, Ks.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, Du.NONE);
  }
  static addHeader(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static addBodyLength(t, n) {
    t.addFieldInt64(3, n, t.createLong(0, 0));
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endMessage(t) {
    return t.endObject();
  }
  static finishMessageBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedMessageBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
  static createMessage(t, n, i, r, s, o) {
    return Bn.startMessage(t), Bn.addVersion(t, n), Bn.addHeaderType(t, i), Bn.addHeader(t, r), Bn.addBodyLength(t, s), Bn.addCustomMetadata(t, o), Bn.endMessage(t);
  }
};
var YM = Ni;
class qM extends xt {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return Cr.startNull(n), Cr.endNull(n);
  }
  visitInt(t, n) {
    return Ye.startInt(n), Ye.addBitWidth(n, t.bitWidth), Ye.addIsSigned(n, t.isSigned), Ye.endInt(n);
  }
  visitFloat(t, n) {
    return Yn.startFloatingPoint(n), Yn.addPrecision(n, t.precision), Yn.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return Dr.startBinary(n), Dr.endBinary(n);
  }
  visitBool(t, n) {
    return Br.startBool(n), Br.endBool(n);
  }
  visitUtf8(t, n) {
    return Rr.startUtf8(n), Rr.endUtf8(n);
  }
  visitDecimal(t, n) {
    return Be.startDecimal(n), Be.addScale(n, t.scale), Be.addPrecision(n, t.precision), Be.addBitWidth(n, t.bitWidth), Be.endDecimal(n);
  }
  visitDate(t, n) {
    return Gc.startDate(n), Gc.addUnit(n, t.unit), Gc.endDate(n);
  }
  visitTime(t, n) {
    return en.startTime(n), en.addUnit(n, t.unit), en.addBitWidth(n, t.bitWidth), en.endTime(n);
  }
  visitTimestamp(t, n) {
    const i = t.timezone && n.createString(t.timezone) || void 0;
    return nn.startTimestamp(n), nn.addUnit(n, t.unit), i !== void 0 && nn.addTimezone(n, i), nn.endTimestamp(n);
  }
  visitInterval(t, n) {
    return qn.startInterval(n), qn.addUnit(n, t.unit), qn.endInterval(n);
  }
  visitList(t, n) {
    return Lr.startList(n), Lr.endList(n);
  }
  visitStruct(t, n) {
    return kr.startStruct_(n), kr.endStruct_(n);
  }
  visitUnion(t, n) {
    Le.startTypeIdsVector(n, t.typeIds.length);
    const i = Le.createTypeIdsVector(n, t.typeIds);
    return Le.startUnion(n), Le.addMode(n, t.mode), Le.addTypeIds(n, i), Le.endUnion(n);
  }
  visitDictionary(t, n) {
    const i = this.visit(t.indices, n);
    return Si.startDictionaryEncoding(n), Si.addId(n, new YM(t.id, 0)), Si.addIsOrdered(n, t.isOrdered), i !== void 0 && Si.addIndexType(n, i), Si.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return zn.startFixedSizeBinary(n), zn.addByteWidth(n, t.byteWidth), zn.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return Pn.startFixedSizeList(n), Pn.addListSize(n, t.listSize), Pn.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return Zc.startMap(n), Zc.addKeysSorted(n, t.keysSorted), Zc.endMap(n);
  }
}
const fh = new qM();
function VM(e, t = /* @__PURE__ */ new Map()) {
  return new Et(XM(e, t), Jc(e.customMetadata), t);
}
function P2(e) {
  return new In(e.count, Y2(e.columns), q2(e.columns));
}
function jM(e) {
  return new Bi(P2(e.data), e.id, e.isDelta);
}
function XM(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => qt.fromJSON(n, t));
}
function yy(e, t) {
  return (e.children || []).filter(Boolean).map((n) => qt.fromJSON(n, t));
}
function Y2(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new xo(n.count, WM(n.VALIDITY)),
    ...Y2(n.children)
  ], []);
}
function q2(e, t = []) {
  for (let n = -1, i = (e || []).length; ++n < i; ) {
    const r = e[n];
    r.VALIDITY && t.push(new Mi(t.length, r.VALIDITY.length)), r.TYPE && t.push(new Mi(t.length, r.TYPE.length)), r.OFFSET && t.push(new Mi(t.length, r.OFFSET.length)), r.DATA && t.push(new Mi(t.length, r.DATA.length)), t = q2(r.children, t);
  }
  return t;
}
function WM(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function HM(e, t) {
  let n, i, r, s, o, a;
  return !t || !(s = e.dictionary) ? (o = by(e, yy(e, t)), r = new qt(e.name, o, e.nullable, Jc(e.customMetadata))) : t.has(n = s.id) ? (i = (i = s.indexType) ? gy(i) : new ba(), a = new Gs(t.get(n), i, n, s.isOrdered), r = new qt(e.name, a, e.nullable, Jc(e.customMetadata))) : (i = (i = s.indexType) ? gy(i) : new ba(), t.set(n, o = by(e, yy(e, t))), a = new Gs(o, i, n, s.isOrdered), r = new qt(e.name, a, e.nullable, Jc(e.customMetadata))), r || null;
}
function Jc(e) {
  return new Map(Object.entries(e || {}));
}
function gy(e) {
  return new nr(e.isSigned, e.bitWidth);
}
function by(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new er();
    case "null":
      return new er();
    case "binary":
      return new lu();
    case "utf8":
      return new fu();
    case "bool":
      return new hu();
    case "list":
      return new gu((t || [])[0]);
    case "struct":
      return new Ee(t || []);
    case "struct_":
      return new Ee(t || []);
  }
  switch (n) {
    case "int": {
      const i = e.type;
      return new nr(i.isSigned, i.bitWidth);
    }
    case "floatingpoint": {
      const i = e.type;
      return new wa(Ce[i.precision]);
    }
    case "decimal": {
      const i = e.type;
      return new du(i.scale, i.precision, i.bitWidth);
    }
    case "date": {
      const i = e.type;
      return new pu(Di[i.unit]);
    }
    case "time": {
      const i = e.type;
      return new _a(At[i.unit], i.bitWidth);
    }
    case "timestamp": {
      const i = e.type;
      return new mu(At[i.unit], i.timezone);
    }
    case "interval": {
      const i = e.type;
      return new yu(tr[i.unit]);
    }
    case "union": {
      const i = e.type;
      return new bu($n[i.mode], i.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const i = e.type;
      return new wu(i.byteWidth);
    }
    case "fixedsizelist": {
      const i = e.type;
      return new _u(i.listSize, (t || [])[0]);
    }
    case "map": {
      const i = e.type;
      return new vu((t || [])[0], i.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var Hr = Ni, GM = N2, ZM = Zs;
class wn {
  constructor(t, n, i, r) {
    this._version = n, this._headerType = i, this.body = new Uint8Array(0), r && (this._createHeader = () => r), this._bodyLength = typeof t == "number" ? t : t.low;
  }
  /** @nocollapse */
  static fromJSON(t, n) {
    const i = new wn(0, rn.V4, n);
    return i._createHeader = KM(t, n), i;
  }
  /** @nocollapse */
  static decode(t) {
    t = new ZM(Tt(t));
    const n = Vi.getRootAsMessage(t), i = n.bodyLength(), r = n.version(), s = n.headerType(), o = new wn(i, r, s);
    return o._createHeader = JM(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new GM();
    let i = -1;
    return t.isSchema() ? i = Et.encode(n, t.header()) : t.isRecordBatch() ? i = In.encode(n, t.header()) : t.isDictionaryBatch() && (i = Bi.encode(n, t.header())), Vi.startMessage(n), Vi.addVersion(n, rn.V4), Vi.addHeader(n, i), Vi.addHeaderType(n, t.headerType), Vi.addBodyLength(n, new Hr(t.bodyLength, 0)), Vi.finishMessageBuffer(n, Vi.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof Et)
      return new wn(0, rn.V4, Bt.Schema, t);
    if (t instanceof In)
      return new wn(n, rn.V4, Bt.RecordBatch, t);
    if (t instanceof Bi)
      return new wn(n, rn.V4, Bt.DictionaryBatch, t);
    throw new Error(`Unrecognized Message header: ${t}`);
  }
  get type() {
    return this.headerType;
  }
  get version() {
    return this._version;
  }
  get headerType() {
    return this._headerType;
  }
  get bodyLength() {
    return this._bodyLength;
  }
  header() {
    return this._createHeader();
  }
  isSchema() {
    return this.headerType === Bt.Schema;
  }
  isRecordBatch() {
    return this.headerType === Bt.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === Bt.DictionaryBatch;
  }
}
class In {
  constructor(t, n, i) {
    this._nodes = n, this._buffers = i, this._length = typeof t == "number" ? t : t.low;
  }
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
}
class Bi {
  constructor(t, n, i = !1) {
    this._data = t, this._isDelta = i, this._id = typeof n == "number" ? n : n.low;
  }
  get id() {
    return this._id;
  }
  get data() {
    return this._data;
  }
  get isDelta() {
    return this._isDelta;
  }
  get length() {
    return this.data.length;
  }
  get nodes() {
    return this.data.nodes;
  }
  get buffers() {
    return this.data.buffers;
  }
}
class Mi {
  constructor(t, n) {
    this.offset = typeof t == "number" ? t : t.low, this.length = typeof n == "number" ? n : n.low;
  }
}
class xo {
  constructor(t, n) {
    this.length = typeof t == "number" ? t : t.low, this.nullCount = typeof n == "number" ? n : n.low;
  }
}
function KM(e, t) {
  return () => {
    switch (t) {
      case Bt.Schema:
        return Et.fromJSON(e);
      case Bt.RecordBatch:
        return In.fromJSON(e);
      case Bt.DictionaryBatch:
        return Bi.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Bt[t]}, type: ${t} }`);
  };
}
function JM(e, t) {
  return () => {
    switch (t) {
      case Bt.Schema:
        return Et.decode(e.header(new Ln()));
      case Bt.RecordBatch:
        return In.decode(e.header(new wi()), e.version());
      case Bt.DictionaryBatch:
        return Bi.decode(e.header(new As()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Bt[t]}, type: ${t} }`);
  };
}
qt.encode = u5;
qt.decode = a5;
qt.fromJSON = HM;
Et.encode = c5;
Et.decode = QM;
Et.fromJSON = VM;
In.encode = l5;
In.decode = t5;
In.fromJSON = P2;
Bi.encode = f5;
Bi.decode = e5;
Bi.fromJSON = jM;
xo.encode = h5;
xo.decode = i5;
Mi.encode = d5;
Mi.decode = n5;
function QM(e, t = /* @__PURE__ */ new Map()) {
  const n = o5(e, t);
  return new Et(n, Qc(e), t);
}
function t5(e, t = rn.V4) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new In(e.length(), r5(e), s5(e, t));
}
function e5(e, t = rn.V4) {
  return new Bi(In.decode(e.data(), t), e.id(), e.isDelta());
}
function n5(e) {
  return new Mi(e.offset(), e.length());
}
function i5(e) {
  return new xo(e.length(), e.nullCount());
}
function r5(e) {
  const t = [];
  for (let n, i = -1, r = -1, s = e.nodesLength(); ++i < s; )
    (n = e.nodes(i)) && (t[++r] = xo.decode(n));
  return t;
}
function s5(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.buffersLength(); ++r < o; )
    (i = e.buffers(r)) && (t < rn.V4 && (i.bb_pos += 8 * (r + 1)), n[++s] = Mi.decode(i));
  return n;
}
function o5(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.fieldsLength(); ++r < o; )
    (i = e.fields(r)) && (n[++s] = qt.decode(i, t));
  return n;
}
function wy(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.childrenLength(); ++r < o; )
    (i = e.children(r)) && (n[++s] = qt.decode(i, t));
  return n;
}
function a5(e, t) {
  let n, i, r, s, o, a;
  return !t || !(a = e.dictionary()) ? (r = vy(e, wy(e, t)), i = new qt(e.name(), r, e.nullable(), Qc(e))) : t.has(n = a.id().low) ? (s = (s = a.indexType()) ? _y(s) : new ba(), o = new Gs(t.get(n), s, n, a.isOrdered()), i = new qt(e.name(), o, e.nullable(), Qc(e))) : (s = (s = a.indexType()) ? _y(s) : new ba(), t.set(n, r = vy(e, wy(e, t))), o = new Gs(r, s, n, a.isOrdered()), i = new qt(e.name(), o, e.nullable(), Qc(e))), i || null;
}
function Qc(e) {
  const t = /* @__PURE__ */ new Map();
  if (e)
    for (let n, i, r = -1, s = Math.trunc(e.customMetadataLength()); ++r < s; )
      (n = e.customMetadata(r)) && (i = n.key()) != null && t.set(i, n.value());
  return t;
}
function _y(e) {
  return new nr(e.isSigned(), e.bitWidth());
}
function vy(e, t) {
  const n = e.typeType();
  switch (n) {
    case Wt.NONE:
      return new er();
    case Wt.Null:
      return new er();
    case Wt.Binary:
      return new lu();
    case Wt.Utf8:
      return new fu();
    case Wt.Bool:
      return new hu();
    case Wt.List:
      return new gu((t || [])[0]);
    case Wt.Struct_:
      return new Ee(t || []);
  }
  switch (n) {
    case Wt.Int: {
      const i = e.type(new Ye());
      return new nr(i.isSigned(), i.bitWidth());
    }
    case Wt.FloatingPoint: {
      const i = e.type(new Yn());
      return new wa(i.precision());
    }
    case Wt.Decimal: {
      const i = e.type(new Be());
      return new du(i.scale(), i.precision(), i.bitWidth());
    }
    case Wt.Date: {
      const i = e.type(new Gc());
      return new pu(i.unit());
    }
    case Wt.Time: {
      const i = e.type(new en());
      return new _a(i.unit(), i.bitWidth());
    }
    case Wt.Timestamp: {
      const i = e.type(new nn());
      return new mu(i.unit(), i.timezone());
    }
    case Wt.Interval: {
      const i = e.type(new qn());
      return new yu(i.unit());
    }
    case Wt.Union: {
      const i = e.type(new Le());
      return new bu(i.mode(), i.typeIdsArray() || [], t || []);
    }
    case Wt.FixedSizeBinary: {
      const i = e.type(new zn());
      return new wu(i.byteWidth());
    }
    case Wt.FixedSizeList: {
      const i = e.type(new Pn());
      return new _u(i.listSize(), (t || [])[0]);
    }
    case Wt.Map: {
      const i = e.type(new Zc());
      return new vu((t || [])[0], i.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${Wt[n]}" (${n})`);
}
function c5(e, t) {
  const n = t.fields.map((s) => qt.encode(e, s));
  Ln.startFieldsVector(e, n.length);
  const i = Ln.createFieldsVector(e, n), r = t.metadata && t.metadata.size > 0 ? Ln.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return se.startKeyValue(e), se.addKey(e, a), se.addValue(e, c), se.endKeyValue(e);
  })) : -1;
  return Ln.startSchema(e), Ln.addFields(e, i), Ln.addEndianness(e, p5 ? Js.Little : Js.Big), r !== -1 && Ln.addCustomMetadata(e, r), Ln.endSchema(e);
}
function u5(e, t) {
  let n = -1, i = -1, r = -1;
  const s = t.type;
  let o = t.typeId;
  at.isDictionary(s) ? (o = s.dictionary.typeId, r = fh.visit(s, e), i = fh.visit(s.dictionary, e)) : i = fh.visit(s, e);
  const a = (s.children || []).map((l) => qt.encode(e, l)), c = Qe.createChildrenVector(e, a), u = t.metadata && t.metadata.size > 0 ? Qe.createCustomMetadataVector(e, [...t.metadata].map(([l, f]) => {
    const h = e.createString(`${l}`), d = e.createString(`${f}`);
    return se.startKeyValue(e), se.addKey(e, h), se.addValue(e, d), se.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), Qe.startField(e), Qe.addType(e, i), Qe.addTypeType(e, o), Qe.addChildren(e, c), Qe.addNullable(e, !!t.nullable), n !== -1 && Qe.addName(e, n), r !== -1 && Qe.addDictionary(e, r), u !== -1 && Qe.addCustomMetadata(e, u), Qe.endField(e);
}
function l5(e, t) {
  const n = t.nodes || [], i = t.buffers || [];
  wi.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    xo.encode(e, o);
  const r = e.endVector();
  wi.startBuffersVector(e, i.length);
  for (const o of i.slice().reverse())
    Mi.encode(e, o);
  const s = e.endVector();
  return wi.startRecordBatch(e), wi.addLength(e, new Hr(t.length, 0)), wi.addNodes(e, r), wi.addBuffers(e, s), wi.endRecordBatch(e);
}
function f5(e, t) {
  const n = In.encode(e, t.data);
  return As.startDictionaryBatch(e), As.addId(e, new Hr(t.id, 0)), As.addIsDelta(e, t.isDelta), As.addData(e, n), As.endDictionaryBatch(e);
}
function h5(e, t) {
  return z2.createFieldNode(e, new Hr(t.length, 0), new Hr(t.nullCount, 0));
}
function d5(e, t) {
  return U2.createBuffer(e, new Hr(t.offset, 0), new Hr(t.length, 0));
}
const p5 = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), tp = (e) => `Expected ${Bt[e]} Message in stream, but was null or length 0.`, ep = (e) => `Header pointer of flatbuffer-encoded ${Bt[e]} Message is null or length 0.`, V2 = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, j2 = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
class X2 {
  constructor(t) {
    this.source = t instanceof Eu ? t : new Eu(t);
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    let t;
    return (t = this.readMetadataLength()).done || t.value === -1 && (t = this.readMetadataLength()).done || (t = this.readMetadata(t.value)).done ? Ht : t;
  }
  throw(t) {
    return this.source.throw(t);
  }
  return(t) {
    return this.source.return(t);
  }
  readMessage(t) {
    let n;
    if ((n = this.next()).done)
      return null;
    if (t != null && n.value.headerType !== t)
      throw new Error(tp(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Tt(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(j2(t, n.byteLength));
    return (
      /* 1. */
      n.byteOffset % 8 === 0 && /* 2. */
      n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
    );
  }
  readSchema(t = !1) {
    const n = Bt.Schema, i = this.readMessage(n), r = i == null ? void 0 : i.header();
    if (t && !r)
      throw new Error(ep(n));
    return r;
  }
  readMetadataLength() {
    const t = this.source.read(jl), n = t && new Zs(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
    return { done: i === 0, value: i };
  }
  readMetadata(t) {
    const n = this.source.read(t);
    if (!n)
      return Ht;
    if (n.byteLength < t)
      throw new Error(V2(t, n.byteLength));
    return { done: !1, value: wn.decode(n) };
  }
}
class m5 {
  constructor(t, n) {
    this.source = t instanceof eo ? t : lb(t) ? new Nu(t, n) : new eo(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return J(this, void 0, void 0, function* () {
      let t;
      return (t = yield this.readMetadataLength()).done || t.value === -1 && (t = yield this.readMetadataLength()).done || (t = yield this.readMetadata(t.value)).done ? Ht : t;
    });
  }
  throw(t) {
    return J(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return J(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return J(this, void 0, void 0, function* () {
      let n;
      if ((n = yield this.next()).done)
        return null;
      if (t != null && n.value.headerType !== t)
        throw new Error(tp(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return J(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Tt(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(j2(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return J(this, void 0, void 0, function* () {
      const n = Bt.Schema, i = yield this.readMessage(n), r = i == null ? void 0 : i.header();
      if (t && !r)
        throw new Error(ep(n));
      return r;
    });
  }
  readMetadataLength() {
    return J(this, void 0, void 0, function* () {
      const t = yield this.source.read(jl), n = t && new Zs(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: i === 0, value: i };
    });
  }
  readMetadata(t) {
    return J(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return Ht;
      if (n.byteLength < t)
        throw new Error(V2(t, n.byteLength));
      return { done: !1, value: wn.decode(n) };
    });
  }
}
class y5 extends X2 {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof dy ? t : new dy(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: wn.fromJSON(t.schema, Bt.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: wn.fromJSON(n, Bt.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: wn.fromJSON(n, Bt.RecordBatch) };
    }
    return this._body = [], Ht;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(i) {
      return (i || []).reduce((r, s) => [
        ...r,
        ...s.VALIDITY && [s.VALIDITY] || [],
        ...s.TYPE && [s.TYPE] || [],
        ...s.OFFSET && [s.OFFSET] || [],
        ...s.DATA && [s.DATA] || [],
        ...n(s.children)
      ], []);
    }
  }
  readMessage(t) {
    let n;
    if ((n = this.next()).done)
      return null;
    if (t != null && n.value.headerType !== t)
      throw new Error(tp(t));
    return n.value;
  }
  readSchema() {
    const t = Bt.Schema, n = this.readMessage(t), i = n == null ? void 0 : n.header();
    if (!n || !i)
      throw new Error(ep(t));
    return i;
  }
}
const jl = 4, vd = "ARROW1", Bu = new Uint8Array(vd.length);
for (let e = 0; e < vd.length; e += 1)
  Bu[e] = vd.codePointAt(e);
function np(e, t = 0) {
  for (let n = -1, i = Bu.length; ++n < i; )
    if (Bu[n] !== e[t + n])
      return !1;
  return !0;
}
const Wa = Bu.length, W2 = Wa + jl, g5 = Wa * 2 + jl;
class Oi extends F2 {
  constructor(t) {
    super(), this._impl = t;
  }
  get closed() {
    return this._impl.closed;
  }
  get schema() {
    return this._impl.schema;
  }
  get autoDestroy() {
    return this._impl.autoDestroy;
  }
  get dictionaries() {
    return this._impl.dictionaries;
  }
  get numDictionaries() {
    return this._impl.numDictionaries;
  }
  get numRecordBatches() {
    return this._impl.numRecordBatches;
  }
  get footer() {
    return this._impl.isFile() ? this._impl.footer : null;
  }
  isSync() {
    return this._impl.isSync();
  }
  isAsync() {
    return this._impl.isAsync();
  }
  isFile() {
    return this._impl.isFile();
  }
  isStream() {
    return this._impl.isStream();
  }
  next() {
    return this._impl.next();
  }
  throw(t) {
    return this._impl.throw(t);
  }
  return(t) {
    return this._impl.return(t);
  }
  cancel() {
    return this._impl.cancel();
  }
  reset(t) {
    return this._impl.reset(t), this._DOMStream = void 0, this._nodeStream = void 0, this;
  }
  open(t) {
    const n = this._impl.open(t);
    return ma(n) ? n.then(() => this) : this;
  }
  readRecordBatch(t) {
    return this._impl.isFile() ? this._impl.readRecordBatch(t) : null;
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
  toDOMStream() {
    return tn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return tn.toNodeStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this }, { objectMode: !0 });
  }
  /** @nocollapse */
  // @ts-ignore
  static throughNode(t) {
    throw new Error('"throughNode" not available in this environment');
  }
  /** @nocollapse */
  static throughDOM(t, n) {
    throw new Error('"throughDOM" not available in this environment');
  }
  /** @nocollapse */
  static from(t) {
    return t instanceof Oi ? t : ld(t) ? v5(t) : lb(t) ? M5(t) : ma(t) ? (() => J(this, void 0, void 0, function* () {
      return yield Oi.from(yield t);
    }))() : fb(t) || k0(t) || db(t) || C0(t) ? S5(new eo(t)) : x5(new Eu(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof Oi ? t.isSync() ? xy(t) : Sy(t) : ld(t) || ArrayBuffer.isView(t) || Yl(t) || ub(t) ? xy(t) : Sy(t);
  }
}
class Lu extends Oi {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return Xn(this, arguments, function* () {
      yield ut(yield* Hc(Cs(this[Symbol.iterator]())));
    });
  }
}
class Cu extends Oi {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n;
    return J(this, void 0, void 0, function* () {
      const i = new Array();
      try {
        for (var r = Cs(this), s; s = yield r.next(), !s.done; ) {
          const o = s.value;
          i.push(o);
        }
      } catch (o) {
        t = { error: o };
      } finally {
        try {
          s && !s.done && (n = r.return) && (yield n.call(r));
        } finally {
          if (t)
            throw t.error;
        }
      }
      return i;
    });
  }
  [Symbol.iterator]() {
    throw new Error("AsyncRecordBatchStreamReader is not Iterable");
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
}
class H2 extends Lu {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class b5 extends Cu {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class G2 {
  constructor(t = /* @__PURE__ */ new Map()) {
    this.closed = !1, this.autoDestroy = !0, this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.dictionaries = t;
  }
  get numDictionaries() {
    return this._dictionaryIndex;
  }
  get numRecordBatches() {
    return this._recordBatchIndex;
  }
  isSync() {
    return !1;
  }
  isAsync() {
    return !1;
  }
  isFile() {
    return !1;
  }
  isStream() {
    return !1;
  }
  reset(t) {
    return this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.schema = t, this.dictionaries = /* @__PURE__ */ new Map(), this;
  }
  _loadRecordBatch(t, n) {
    const i = this._loadVectors(t, n, this.schema.fields), r = _t({ type: new Ee(this.schema.fields), length: t.length, children: i });
    return new bn(this.schema, r);
  }
  _loadDictionaryBatch(t, n) {
    const { id: i, isDelta: r } = t, { dictionaries: s, schema: o } = this, a = s.get(i);
    if (r || !a) {
      const c = o.dictionaries.get(i), u = this._loadVectors(t.data, n, [c]);
      return (a && r ? a.concat(new ee(u)) : new ee(u)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, i) {
    return new B2(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
}
class ku extends G2 {
  constructor(t, n) {
    super(n), this._reader = ld(t) ? new y5(this._handle = t) : new X2(this._handle = t);
  }
  isSync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.iterator]() {
    return this;
  }
  cancel() {
    !this.closed && (this.closed = !0) && (this.reset()._reader.return(), this._reader = null, this.dictionaries = null);
  }
  open(t) {
    return this.closed || (this.autoDestroy = K2(this, t), this.schema || (this.schema = this._reader.readSchema()) || this.cancel()), this;
  }
  throw(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.throw(t) : Ht;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : Ht;
  }
  next() {
    if (this.closed)
      return Ht;
    let t;
    const { _reader: n } = this;
    for (; t = this._readNextMessageAndValidate(); )
      if (t.isSchema())
        this.reset(t.header());
      else if (t.isRecordBatch()) {
        this._recordBatchIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength);
        return { done: !1, value: this._loadRecordBatch(i, r) };
      } else if (t.isDictionaryBatch()) {
        this._dictionaryIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
        this.dictionaries.set(i.id, s);
      }
    return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new R2(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}
class Ru extends G2 {
  constructor(t, n) {
    super(n), this._reader = new m5(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return J(this, void 0, void 0, function* () {
      !this.closed && (this.closed = !0) && (yield this.reset()._reader.return(), this._reader = null, this.dictionaries = null);
    });
  }
  open(t) {
    return J(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = K2(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return J(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : Ht;
    });
  }
  return(t) {
    return J(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : Ht;
    });
  }
  next() {
    return J(this, void 0, void 0, function* () {
      if (this.closed)
        return Ht;
      let t;
      const { _reader: n } = this;
      for (; t = yield this._readNextMessageAndValidate(); )
        if (t.isSchema())
          yield this.reset(t.header());
        else if (t.isRecordBatch()) {
          this._recordBatchIndex++;
          const i = t.header(), r = yield n.readMessageBody(t.bodyLength);
          return { done: !1, value: this._loadRecordBatch(i, r) };
        } else if (t.isDictionaryBatch()) {
          this._dictionaryIndex++;
          const i = t.header(), r = yield n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
          this.dictionaries.set(i.id, s);
        }
      return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new R2(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return J(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}
class Z2 extends ku {
  constructor(t, n) {
    super(t instanceof py ? t : new py(t), n);
  }
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  isSync() {
    return !0;
  }
  isFile() {
    return !0;
  }
  open(t) {
    if (!this.closed && !this._footer) {
      this.schema = (this._footer = this._readFooter()).schema;
      for (const n of this._footer.dictionaryBatches())
        n && this._readDictionaryBatch(this._dictionaryIndex++);
    }
    return super.open(t);
  }
  readRecordBatch(t) {
    var n;
    if (this.closed)
      return null;
    this._footer || this.open();
    const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(Bt.RecordBatch);
      if (r != null && r.isRecordBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength);
        return this._loadRecordBatch(s, o);
      }
    }
    return null;
  }
  _readDictionaryBatch(t) {
    var n;
    const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(Bt.DictionaryBatch);
      if (r != null && r.isDictionaryBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
        this.dictionaries.set(s.id, a);
      }
    }
  }
  _readFooter() {
    const { _handle: t } = this, n = t.size - W2, i = t.readInt32(n), r = t.readAt(n - i, i);
    return G0.decode(r);
  }
  _readNextMessageAndValidate(t) {
    var n;
    if (this._footer || this.open(), this._footer && this._recordBatchIndex < this.numRecordBatches) {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(this._recordBatchIndex);
      if (i && this._handle.seek(i.offset))
        return this._reader.readMessage(t);
    }
    return null;
  }
}
class w5 extends Ru {
  constructor(t, ...n) {
    const i = typeof n[0] != "number" ? n.shift() : void 0, r = n[0] instanceof Map ? n.shift() : void 0;
    super(t instanceof Nu ? t : new Nu(t, i), r);
  }
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return J(this, void 0, void 0, function* () {
      if (!this.closed && !this._footer) {
        this.schema = (this._footer = yield this._readFooter()).schema;
        for (const i of this._footer.dictionaryBatches())
          i && (yield this._readDictionaryBatch(this._dictionaryIndex++));
      }
      return yield n.open.call(this, t);
    });
  }
  readRecordBatch(t) {
    var n;
    return J(this, void 0, void 0, function* () {
      if (this.closed)
        return null;
      this._footer || (yield this.open());
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(Bt.RecordBatch);
        if (r != null && r.isRecordBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength);
          return this._loadRecordBatch(s, o);
        }
      }
      return null;
    });
  }
  _readDictionaryBatch(t) {
    var n;
    return J(this, void 0, void 0, function* () {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(Bt.DictionaryBatch);
        if (r != null && r.isDictionaryBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
          this.dictionaries.set(s.id, a);
        }
      }
    });
  }
  _readFooter() {
    return J(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - W2, i = yield t.readInt32(n), r = yield t.readAt(n - i, i);
      return G0.decode(r);
    });
  }
  _readNextMessageAndValidate(t) {
    return J(this, void 0, void 0, function* () {
      if (this._footer || (yield this.open()), this._footer && this._recordBatchIndex < this.numRecordBatches) {
        const n = this._footer.getRecordBatch(this._recordBatchIndex);
        if (n && (yield this._handle.seek(n.offset)))
          return yield this._reader.readMessage(t);
      }
      return null;
    });
  }
}
class _5 extends ku {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, i) {
    return new OM(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
}
function K2(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* xy(e) {
  const t = Oi.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function Sy(e) {
  return Xn(this, arguments, function* () {
    const n = yield ut(Oi.from(e));
    try {
      if (!(yield ut(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield ut(n);
        while (!(yield ut(n.reset().open())).closed);
    } finally {
      yield ut(n.cancel());
    }
  });
}
function v5(e) {
  return new Lu(new _5(e));
}
function x5(e) {
  const t = e.peek(Wa + 7 & -8);
  return t && t.byteLength >= 4 ? np(t) ? new H2(new Z2(e.read())) : new Lu(new ku(e)) : new Lu(new ku(function* () {
  }()));
}
function S5(e) {
  return J(this, void 0, void 0, function* () {
    const t = yield e.peek(Wa + 7 & -8);
    return t && t.byteLength >= 4 ? np(t) ? new H2(new Z2(yield e.read())) : new Cu(new Ru(e)) : new Cu(new Ru(function() {
      return Xn(this, arguments, function* () {
      });
    }()));
  });
}
function M5(e) {
  return J(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new Nu(e, t);
    return t >= g5 && np(yield n.readAt(0, Wa + 7 & -8)) ? new b5(new w5(n)) : new Cu(new Ru(n));
  });
}
function ip(e) {
  const t = Oi.from(e);
  return ma(t) ? t.then((n) => ip(n)) : t.isAsync() ? t.readAll().then((n) => new va(n)) : new va(t.readAll());
}
function A5(e = "ws://localhost:3000/") {
  const t = [];
  let n = !1, i = null, r;
  const s = {
    open() {
      n = !0, c();
    },
    close() {
      for (n = !1, i = null, r = null; t.length; )
        t.shift().reject("Socket closed");
    },
    error(u) {
      if (i) {
        const { reject: l } = i;
        i = null, c(), l(u);
      } else
        console.error("WebSocket error: ", u);
    },
    message({ data: u }) {
      if (i) {
        const { query: l, resolve: f, reject: h } = i;
        if (i = null, c(), typeof u == "string") {
          const d = JSON.parse(u);
          d.error ? h(d.error) : f(d);
        } else if (l.type === "exec")
          f();
        else if (l.type === "arrow")
          f(ip(u.arrayBuffer()));
        else
          throw new Error(`Unexpected socket data: ${u}`);
      } else
        console.log("WebSocket message: ", u);
    }
  };
  function o() {
    r = new WebSocket(e);
    for (const u in s)
      r.addEventListener(u, s[u]);
  }
  function a(u, l, f) {
    r == null && o(), t.push({ query: u, resolve: l, reject: f }), n && !i && c();
  }
  function c() {
    t.length && (i = t.shift(), r.send(JSON.stringify(i.query)));
  }
  return {
    get connected() {
      return n;
    },
    query(u) {
      return new Promise(
        (l, f) => a(u, l, f)
      );
    }
  };
}
function $5(e) {
  switch (e) {
    case "BIGINT":
    case "HUGEINT":
    case "INTEGER":
    case "SMALLINT":
    case "TINYINT":
    case "UBIGINT":
    case "UINTEGER":
    case "USMALLINT":
    case "UTINYINT":
    case "DOUBLE":
    case "FLOAT":
    case "REAL":
    case "DECIMAL":
      return "number";
    case "DATE":
    case "TIMESTAMP":
    case "TIMESTAMPTZ":
    case "TIME":
      return "date";
    case "BOOLEAN":
      return "boolean";
    case "VARCHAR":
    case "UUID":
      return "string";
    case "LIST":
      return "array";
    case "BLOB":
    case "STRUCT":
    case "MAP":
      return "object";
    default:
      throw new Error(`Unsupported type: ${e}`);
  }
}
class Gr {
  constructor(t, n) {
    t && (this.table = String(t)), n && (this.column = n);
  }
  get columns() {
    return this.column ? [this.column] : [];
  }
  toString() {
    const { table: t, column: n } = this;
    if (n) {
      const i = n === "*" ? n : `"${n}"`;
      return (t ? `"${t}".` : "") + i;
    } else
      return `"${t}"`;
  }
}
function I5(e, t) {
  return e instanceof Gr && e.column === t;
}
function te(e) {
  return typeof e == "string" ? rp(e) : e;
}
function hh(e) {
  return typeof e == "string" ? T5(e) : e;
}
function T5(e) {
  return new Gr(e);
}
function rp(e, t) {
  return arguments.length === 1 ? new Gr(null, e) : new Gr(e, t);
}
function Sn(e) {
  return typeof e == "string" ? `"${e}"` : sp(e);
}
function sp(e) {
  switch (typeof e) {
    case "boolean":
      return e ? "TRUE" : "FALSE";
    case "string":
      return `'${e}'`;
    default:
      return e == null ? "NULL" : e instanceof Date ? `MAKE_DATE(${e.getUTCFullYear()}, ${e.getUTCMonth() + 1}, ${e.getUTCDate()})` : e instanceof RegExp ? `'${e.source}'` : String(e);
  }
}
function E5(e) {
  return e instanceof J2;
}
class J2 {
  constructor(t, n, i) {
    this.expr = t, this.label = i, this.columns = n || [];
  }
  toString() {
    return `${this.expr}`;
  }
}
function q(e, t, n) {
  return new J2(e, t, n);
}
function N5(e) {
  return Object.assign(
    q(`${te(e)} DESC NULLS LAST`, e == null ? void 0 : e.columns, e == null ? void 0 : e.label),
    { desc: !0 }
  );
}
function Xl(e, t) {
  return (n) => q(e(n), te(n).columns, t);
}
class O5 {
  constructor(t) {
    this.value = t;
  }
  toString() {
    return sp(this.value);
  }
}
const Ha = (e) => new O5(e);
function Wl(...e) {
  return e.flat().flatMap((t) => (t == null ? void 0 : t.columns) || []);
}
class F5 {
  constructor(t, n) {
    this.op = t, this.a = te(n);
  }
  get columns() {
    return Wl(this.a);
  }
  visit(t) {
    t(this.op, this);
  }
  toString() {
    const { op: t, a: n } = this;
    return `(${Sn(n)} ${t})`;
  }
}
function Q2(e) {
  return (t) => new F5(e, t);
}
const tw = Q2("IS NULL"), Uu = Q2("IS NOT NULL");
class D5 {
  constructor(t, n, i) {
    this.op = t, this.a = te(n), this.b = te(i);
  }
  get columns() {
    return Wl(this.a, this.b);
  }
  visit(t) {
    t(this.op, this);
  }
  toString() {
    const { op: t, a: n, b: i } = this;
    return `(${Sn(n)} ${t} ${Sn(i)})`;
  }
}
function ew(e) {
  return (t, n) => new D5(e, t, n);
}
const Hl = ew("="), nw = ew(">");
class B5 {
  constructor(t, n, i) {
    this.op = t, this.expr = te(n), this.value = i == null ? void 0 : i.map(te);
  }
  get columns() {
    return Wl(this.expr, this.value);
  }
  visit(t) {
    t(this.op, this);
  }
  toString() {
    const { op: t, expr: n, value: i } = this;
    if (!i)
      return "";
    const [r, s] = i;
    return `(${Sn(n)} ${t} ${Sn(r)} AND ${Sn(s)})`;
  }
}
function L5(e) {
  return (t, n) => new B5(e, t, n);
}
const dn = L5("BETWEEN");
class iw {
  constructor(t, n) {
    this.op = t, this.value = n.map(te);
  }
  get columns() {
    return Wl(this.value);
  }
  visit(t) {
    var n;
    t(this.op, this), (n = this.value) == null || n.forEach((i) => i.visit(t));
  }
  toString() {
    const { op: t, value: n } = this;
    return !n || n.length === 0 ? "" : n.length === 1 ? Sn(n[0]) : `(${n.map(Sn).filter((i) => i).join(` ${t} `)})`;
  }
}
function rr(...e) {
  return new iw("AND", e.flat());
}
function rw(...e) {
  return new iw("OR", e.flat());
}
class C5 {
  constructor(t, n) {
    this.func = t, this.args = (n || []).map(te);
  }
  get column() {
    return this.columns[0];
  }
  get columns() {
    return this.args.flatMap((t) => t.columns || []);
  }
  toString() {
    const { func: t, args: n } = this;
    return `${t}(${n.map(Sn).join(", ")})`;
  }
}
function Gl(e) {
  return (...t) => new C5(e, t);
}
const k5 = Gl("regexp_matches"), R5 = Gl("contains"), U5 = Gl("prefix"), z5 = Gl("suffix");
class P5 {
  constructor(t, n) {
    this.aggregate = t, this.args = (n || []).map(te);
  }
  get label() {
    return this.aggregate.toLowerCase() + (this.args.length ? ` ${this.columns.join(", ")}` : "");
  }
  get column() {
    return this.columns[0];
  }
  get columns() {
    return this.args.flatMap((t) => t.columns || []);
  }
  distinct() {
    return this.isDistinct = !0, this;
  }
  where(t) {
    return this.filter = t, this;
  }
  toString() {
    const { aggregate: t, args: n, isDistinct: i, filter: r } = this, s = n.length === 0 ? "*" : n.map(Sn).join(", "), o = i ? "DISTINCT " : "", a = r ? ` FILTER (WHERE ${Sn(r)})` : "", c = t === "COUNT" ? "::INTEGER" : "";
    return a && c ? `(${t}(${o}${s})${a})${c}` : `${t}(${o}${s})${a}${c}`;
  }
}
function ye(e) {
  return (...t) => new P5(e, t);
}
const aa = ye("COUNT"), Y5 = ye("AVG"), io = ye("MAX"), ro = ye("MIN"), Zl = ye("SUM"), q5 = ye("MEDIAN"), V5 = ye("QUANTILE"), j5 = ye("MODE"), X5 = ye("REGR_INTERCEPT"), W5 = ye("REGR_SLOPE"), H5 = ye("REGR_COUNT"), G5 = ye("REGR_R2"), Z5 = ye("REGR_SYY"), K5 = ye("REGR_SXX"), J5 = ye("REGR_AVGX"), My = ye("ARG_MIN"), Ay = ye("ARG_MAX"), sw = Xl(
  (e) => `(1000 * (epoch(${e}) - second(${e})) + millisecond(${e}))::DOUBLE`
);
class mt {
  static select(...t) {
    return new mt().select(...t);
  }
  static from(...t) {
    return new mt().from(...t);
  }
  static with(...t) {
    return new mt().with(...t);
  }
  static union(...t) {
    return new Ur("UNION", t.flat());
  }
  static unionAll(...t) {
    return new Ur("UNION ALL", t.flat());
  }
  static intersect(...t) {
    return new Ur("INTERSECT", t.flat());
  }
  static except(...t) {
    return new Ur("EXCEPT", t.flat());
  }
  constructor() {
    this.query = {
      with: [],
      select: [],
      from: [],
      where: [],
      groupby: [],
      having: [],
      window: [],
      qualify: [],
      orderby: []
    };
  }
  clone() {
    const t = new mt();
    return t.query = { ...this.query }, t;
  }
  with(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.with;
    {
      const i = [], r = (s, o) => {
        const a = o.clone();
        a.cteFor = this, i.push({ as: s, query: a });
      };
      return t.flat().forEach((s) => {
        if (s != null)
          if (s.as && s.query)
            r(s.as, s.query);
          else
            for (const o in s)
              r(o, s[o]);
      }), n.with = n.with.concat(i), this;
    }
  }
  select(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.select;
    {
      const i = [];
      return t.flat().forEach((r) => {
        if (r != null)
          if (typeof r == "string")
            i.push({ as: r, expr: te(r) });
          else if (r instanceof Gr)
            i.push({ as: r.column, expr: r });
          else if (Array.isArray(r))
            i.push({ as: r[0], expr: r[1] });
          else
            for (const s in r)
              i.push({ as: bc(s), expr: te(r[s]) });
      }), n.select = n.select.concat(i), this;
    }
  }
  $select(...t) {
    return this.query.select = [], this.select(...t);
  }
  distinct(t = !0) {
    return this.query.distinct = !!t, this;
  }
  from(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.from;
    {
      const i = [];
      return t.flat().forEach((r) => {
        if (r != null)
          if (typeof r == "string")
            i.push({ as: r, from: hh(r) });
          else if (r instanceof Gr)
            i.push({ as: r.table, from: r });
          else if (dh(r) || E5(r))
            i.push({ from: r });
          else if (Array.isArray(r))
            i.push({ as: bc(r[0]), from: hh(r[1]) });
          else
            for (const s in r)
              i.push({ as: bc(s), from: hh(r[s]) });
      }), n.from = n.from.concat(i), this;
    }
  }
  $from(...t) {
    return this.query.from = [], this.from(...t);
  }
  sample(t) {
    const { query: n } = this;
    if (arguments.length === 0)
      return n.sample;
    {
      let i = t;
      return typeof t == "number" && (i = t > 0 && t < 1 ? { perc: 100 * t } : { rows: Math.round(t) }), n.sample = i, this;
    }
  }
  where(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.where : (n.where = n.where.concat(
      t.flat().filter((i) => i)
    ), this);
  }
  $where(...t) {
    return this.query.where = [], this.where(...t);
  }
  groupby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.groupby : (n.groupby = n.groupby.concat(
      t.flat().filter((i) => i).map(te)
    ), this);
  }
  having(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.having : (n.having = n.having.concat(
      t.flat().filter((i) => i)
    ), this);
  }
  window(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.window;
    {
      const i = [];
      return t.flat().forEach((r) => {
        if (r != null)
          for (const s in r)
            i.push({ as: bc(s), expr: r[s] });
      }), n.window = n.window.concat(i), this;
    }
  }
  qualify(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.qualify : (n.qualify = n.qualify.concat(
      t.flat().filter((i) => i)
    ), this);
  }
  orderby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.orderby : (n.orderby = n.orderby.concat(
      t.flat().filter((i) => i).map(te)
    ), this);
  }
  limit(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.limit : (n.limit = Number.isFinite(t) ? t : void 0, this);
  }
  offset(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.offset : (n.offset = Number.isFinite(t) ? t : void 0, this);
  }
  get subqueries() {
    const { query: t, cteFor: n } = this, i = ((n == null ? void 0 : n.query) || t).with, r = i == null ? void 0 : i.reduce((o, { as: a, query: c }) => (o[a] = c, o), {}), s = [];
    return t.from.forEach(({ from: o }) => {
      if (dh(o))
        s.push(o);
      else if (r[o.table]) {
        const a = r[o.table];
        s.push(a);
      }
    }), s;
  }
  toString() {
    const {
      select: t,
      distinct: n,
      from: i,
      sample: r,
      where: s,
      groupby: o,
      having: a,
      window: c,
      qualify: u,
      orderby: l,
      limit: f,
      offset: h,
      with: d
    } = this.query, p = [];
    if (d.length) {
      const y = d.map(({ as: m, query: b }) => `"${m}" AS (${b})`);
      p.push(`WITH ${y.join(", ")}`);
    }
    const g = t.map(
      ({ as: y, expr: m }) => I5(m, y) && !m.table ? `${m}` : `${m} AS "${y}"`
    );
    if (p.push(`SELECT${n ? " DISTINCT" : ""} ${g.join(", ")}`), i.length) {
      const y = i.map(({ as: m, from: b }) => {
        const w = dh(b) ? `(${b})` : `${b}`;
        return !m || m === b.table ? w : `${w} AS "${m}"`;
      });
      p.push(`FROM ${y.join(", ")}`);
    }
    if (r) {
      const { rows: y, perc: m, method: b, seed: w } = r, _ = y ? `${y} ROWS` : `${m} PERCENT`, x = b ? ` (${b}${w != null ? `, ${w}` : ""})` : "";
      p.push(`USING SAMPLE ${_}${x}`);
    }
    if (s.length) {
      const y = s.map(String).filter((m) => m).join(" AND ");
      y && p.push(`WHERE ${y}`);
    }
    if (o.length && p.push(`GROUP BY ${o.join(", ")}`), a.length) {
      const y = a.map(String).filter((m) => m).join(" AND ");
      y && p.push(`HAVING ${y}`);
    }
    if (c.length) {
      const y = c.map(({ as: m, expr: b }) => `"${m}" AS (${b})`);
      p.push(`WINDOW ${y.join(", ")}`);
    }
    if (u.length) {
      const y = u.map(String).filter((m) => m).join(" AND ");
      y && p.push(`QUALIFY ${y}`);
    }
    return l.length && p.push(`ORDER BY ${l.join(", ")}`), Number.isFinite(f) && p.push(`LIMIT ${f}`), Number.isFinite(h) && p.push(`OFFSET ${h}`), p.join(" ");
  }
}
class Ur {
  constructor(t, n) {
    this.op = t, this.queries = n.map((i) => i.clone()), this.query = { orderby: [] };
  }
  clone() {
    const t = new Ur(this.op, this.queries);
    return t.query = { ...this.query }, t;
  }
  orderby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.orderby : (n.orderby = n.orderby.concat(
      t.flat().filter((i) => i).map(te)
    ), this);
  }
  limit(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.limit : (n.limit = Number.isFinite(t) ? t : void 0, this);
  }
  offset(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.offset : (n.offset = Number.isFinite(t) ? t : void 0, this);
  }
  get subqueries() {
    const { queries: t, cteFor: n } = this;
    return n && t.forEach((i) => i.cteFor = n), t;
  }
  toString() {
    const { op: t, queries: n, query: { orderby: i, limit: r, offset: s } } = this, o = [n.join(` ${t} `)];
    return i.length && o.push(`ORDER BY ${i.join(", ")}`), Number.isFinite(r) && o.push(`LIMIT ${r}`), Number.isFinite(s) && o.push(`OFFSET ${s}`), o.join(" ");
  }
}
function dh(e) {
  return e instanceof mt || e instanceof Ur;
}
function bc(e) {
  return Q5(e) ? e.slice(1, -1) : e;
}
function Q5(e) {
  return e[0] === '"' && e[e.length - 1] === '"';
}
const tA = "count", eA = "nulls", nA = "max", iA = "min", rA = "distinct", sA = {
  [tA]: aa,
  [rA]: (e) => aa(e).distinct(),
  [nA]: io,
  [iA]: ro,
  [eA]: (e) => aa().where(tw(e))
};
function oA({ table: e, column: t }, n) {
  return mt.from(e).select(n.map((i) => [i, sA[i](t)]));
}
const $y = () => /* @__PURE__ */ Object.create(null);
class aA {
  constructor(t) {
    this.mc = t, this.clear();
  }
  clear() {
    this.tables = $y();
  }
  async tableInfo(t) {
    const n = this.tables;
    if (n[t])
      return n[t];
    const i = this.mc.query(
      `DESCRIBE "${t}"`,
      { type: "json", cache: !1 }
    );
    return n[t] = i.then((r) => {
      const s = $y();
      for (const o of r)
        s[o.column_name] = {
          table: t,
          column: o.column_name,
          sqlType: o.column_type,
          type: $5(o.column_type),
          nullable: o.null === "YES"
        };
      return s;
    });
  }
  async fieldInfo({ table: t, column: n, stats: i }) {
    const s = (await this.tableInfo(t))[n];
    if (s == null)
      return;
    if (!(i != null && i.length))
      return s;
    const o = await this.mc.query(oA(s, i));
    return { ...s, ...Array.from(o)[0] };
  }
  async queryFields(t) {
    const n = await cA(this, t);
    return (await Promise.all(n.map((r) => this.fieldInfo(r)))).filter((r) => r);
  }
}
async function cA(e, t) {
  return t.length === 1 && t[0].column === "*" ? Object.values(await e.tableInfo(t[0].table)) : t;
}
function uA(e) {
  let t = 2166136261;
  for (let n = 0, i = e.length; n < i; ++n) {
    const r = e.charCodeAt(n), s = r & 65280;
    s && (t = Iy(t ^ s >> 8)), t = Iy(t ^ r & 255);
  }
  return lA(t);
}
function Iy(e) {
  return e + (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
}
function lA(e) {
  return e += e << 13, e ^= e >>> 7, e += e << 3, e ^= e >>> 17, e += e << 5, e & 4294967295;
}
function xd(e, t) {
  var n;
  return (n = t == null ? void 0 : t.clients) == null ? void 0 : n.has(e);
}
const ow = (e) => e;
class fA {
  constructor(t, n) {
    this.mc = t, this.selection = n, this.reset();
  }
  reset() {
    this.enabled = !1, this.clients = null, this.indices = null, this.activeView = null;
  }
  index(t, n) {
    var c, u;
    if (this.clients !== t) {
      const l = Array.from(t).map(Ey), f = (c = l[0]) == null ? void 0 : c.from;
      this.enabled = l.every((h) => h && h.from === f), this.clients = t, this.indices = null, this.activeView = null;
    }
    if (!this.enabled)
      return !1;
    n = n || this.selection.active;
    const { source: i } = n;
    if (!i)
      return !1;
    if (i === ((u = this.activeView) == null ? void 0 : u.source))
      return !0;
    const r = this.activeView = hA(n);
    if (!r)
      return !1;
    this.mc.logger().warn("DATA TILE INDEX CONSTRUCTION");
    const s = this.selection.clone().update({ source: i }), o = this.indices = /* @__PURE__ */ new Map(), a = [];
    for (const l of t) {
      if (s.cross && xd(l, n))
        continue;
      const f = Ey(l), h = l.query(s.predicate(l)).select({ ...r.columns, ...f.count }).groupby(Object.keys(r.columns)), [d] = h.subqueries;
      if (d) {
        const m = Object.values(r.columns).map((b) => b.columns[0]);
        yA(d, m);
      }
      const p = h.toString(), y = `tile_index_${(uA(p) >>> 0).toString(16)}`;
      o.set(l, { table: y, ...f }), a.push(mA(this.mc, y, p));
    }
    return a;
  }
  async update() {
    const { clients: t, selection: n, activeView: i } = this, r = i.predicate(n.active.predicate);
    return Promise.all(
      Array.from(t).map((s) => this.updateClient(s, r))
    );
  }
  async updateClient(t, n) {
    const i = this.indices.get(t);
    if (!i)
      return;
    n || (n = this.activeView.predicate(this.selection.active.predicate));
    const { table: r, dims: s, aggr: o } = i;
    return this.mc.updateClient(
      t,
      mt.select(s, o).from(r).groupby(s).where(n)
    );
  }
}
function hA(e) {
  var a;
  const { source: t, schema: n } = e;
  let i = (a = e.predicate) == null ? void 0 : a.columns;
  if (!n || !i)
    return null;
  const { type: r, scales: s } = n;
  let o;
  if (r === "interval" && s) {
    const c = s.map((u) => dA(u));
    if (c.some((u) => u == null))
      return null;
    c.length === 1 ? (o = (u) => u ? dn("active0", u.value.map(c[0])) : [], i = { active0: c[0](e.predicate.expr) }) : (o = (u) => u ? rr(u.value.map(({ value: l }, f) => dn(`active${f}`, l.map(c[f])))) : [], i = Object.fromEntries(
      e.predicate.value.map((u, l) => [`active${l}`, c[l](u.expr)])
    ));
  } else if (r === "point")
    o = ow, i = Object.fromEntries(i.map((c) => [c.toString(), c]));
  else
    return null;
  return { source: t, columns: i, predicate: o };
}
function dA(e) {
  const { type: t, domain: n, range: i } = e;
  let r, s;
  switch (t) {
    case "linear":
      r = ow, s = te;
      break;
    case "log":
      r = Math.log, s = (o) => `LN(${te(o)})`;
      break;
    case "symlog":
      r = (o) => Math.sign(o) * Math.log1p(Math.abs(o)), s = (o) => (o = te(o), `SIGN(${o}) * LN(1 + ABS(${o}))`);
      break;
    case "sqrt":
      r = Math.sqrt, s = (o) => `SQRT(${te(o)})`;
      break;
    case "utc":
    case "time":
      r = (o) => +o, s = (o) => o instanceof Date ? +o : sw(te(o));
      break;
  }
  return r ? pA(n, i, r, s) : null;
}
function pA(e, t, n, i) {
  const r = n(Math.min(e[0], e[1])), s = n(Math.max(e[0], e[1])), o = Math.abs(n(t[1]) - n(t[0])) / (s - r);
  return (a) => q(
    `FLOOR(${o}::DOUBLE * (${i(a)} - ${r}::DOUBLE))`,
    te(a).columns
  );
}
async function mA(e, t, n) {
  try {
    await e.exec(`CREATE TEMP TABLE IF NOT EXISTS ${t} AS ${n}`);
  } catch (i) {
    e.logger().error(i);
  }
}
const Ty = { from: NaN };
function Ey(e) {
  if (!e.filterIndexable)
    return Ty;
  const t = e.query(), n = Sd(t);
  if (!n || !t.groupby)
    return Ty;
  const i = new Set(t.groupby().map((a) => a.column));
  let r = [], s = [], o;
  for (const { as: a, expr: { aggregate: c } } of t.select())
    switch (c == null ? void 0 : c.toUpperCase()) {
      case "COUNT":
      case "SUM":
        r.push({ [a]: q(`SUM("${a}")::DOUBLE`) });
        break;
      case "AVG":
        o = "_count_", r.push({ [a]: q(`(SUM("${a}" * ${o}) / SUM(${o}))::DOUBLE`) });
        break;
      case "MAX":
        r.push({ [a]: q(`MAX("${a}")`) });
        break;
      case "MIN":
        r.push({ [a]: q(`MIN("${a}")`) });
        break;
      default:
        if (i.has(a))
          s.push(a);
        else
          return null;
    }
  return {
    aggr: r,
    dims: s,
    count: o ? { [o]: q("COUNT(*)") } : {},
    from: n
  };
}
function Sd(e) {
  const t = e.subqueries;
  if (e.select) {
    const i = e.from();
    if (!i.length)
      return;
    if (t.length === 0)
      return i[0].from.table;
  }
  let n = Sd(t[0]);
  for (let i = 1; i < t.length; ++i) {
    const r = Sd(t[i]);
    if (r !== void 0 && r !== n)
      return NaN;
  }
  return n;
}
function yA(e, t) {
  const n = /* @__PURE__ */ new Set(), i = (r) => {
    n.has(r) || (n.add(r), r.select && r.from().length && r.select(t), r.subqueries.forEach(i));
  };
  i(e);
}
const Ny = {};
function Kl(e, t = !1) {
  let n, i, r = Ny;
  function s(u) {
    n = e(u).then(() => {
      if (i) {
        const { value: l } = i;
        i = null, s(l);
      } else
        n = null;
    });
  }
  function o(u) {
    i = { event: u };
  }
  function a(u) {
    n ? o(u) : s(u);
  }
  function c(u) {
    r !== u && requestAnimationFrame(() => {
      const l = r;
      r = Ny, a(l);
    }), r = u;
  }
  return t ? c : a;
}
class gA {
  constructor(t, n, i = !0) {
    this.mc = t, this.selection = n, this.clients = /* @__PURE__ */ new Set(), this.indexer = i ? new fA(this.mc, n) : null;
    const { value: r, activate: s } = this.handlers = {
      value: Kl(() => this.update()),
      activate: (o) => {
        var a;
        (a = this.indexer) == null || a.index(this.clients, o);
      }
    };
    n.addEventListener("value", r), n.addEventListener("activate", s);
  }
  finalize() {
    const { value: t, activate: n } = this.handlers;
    this.selection.removeEventListener("value", t), this.selection.removeEventListener("activate", n);
  }
  reset() {
    var t;
    (t = this.indexer) == null || t.reset();
  }
  add(t) {
    return (this.clients = new Set(this.clients)).add(t), this;
  }
  remove(t) {
    return this.clients.has(t) && (this.clients = new Set(this.clients)).delete(t), this;
  }
  async update() {
    const { mc: t, indexer: n, clients: i, selection: r } = this;
    return n != null && n.index(i) ? n.update() : bA(t, i, r);
  }
}
function bA(e, t, n) {
  return Promise.all(Array.from(t).map((i) => {
    const r = n.predicate(i);
    if (r != null)
      return e.updateClient(i, i.query(r));
  }));
}
const wA = typeof requestIdleCallback < "u" ? requestIdleCallback : setTimeout, _A = () => ({
  get: () => {
  },
  set: (e, t) => t,
  clear: () => {
  }
});
class vA {
  constructor({
    max: t = 1e3,
    // max entries
    ttl: n = 3 * 60 * 60 * 1e3
    // time-to-live, default 3 hours
  } = {}) {
    this.max = t, this.ttl = n, this.clear();
  }
  clear() {
    this.cache = /* @__PURE__ */ new Map();
  }
  get(t) {
    const n = this.cache.get(t);
    if (n)
      return n.last = performance.now(), n.promise;
  }
  set(t, n) {
    const { cache: i, max: r } = this;
    return i.set(t, { last: performance.now(), promise: n }), i.size > r && wA(() => this.evict()), n;
  }
  evict() {
    const t = performance.now() - this.ttl;
    let n = null, i = 1 / 0;
    for (const [r, s] of this.cache) {
      const { last: o } = s;
      o < i && (n = r, i = o), t > o && this.cache.delete(r);
    }
    n && this.cache.delete(n);
  }
}
function xA() {
  return {
    debug() {
    },
    info() {
    },
    log() {
    },
    warn() {
    },
    error() {
    }
  };
}
let wc;
function So(e) {
  return e ? wc = e : wc == null && (wc = new SA()), wc;
}
class SA {
  constructor(t = A5(), n = {}) {
    this.catalog = new aA(this), this.logger(n.logger || console), this.configure(n), this.databaseClient(t), this.clear();
  }
  logger(t) {
    return arguments.length ? this._logger = t || xA() : this._logger;
  }
  configure({ cache: t = !0, indexes: n = !0 }) {
    this.cache = t ? new vA() : _A(), this.indexes = n;
  }
  clear({ clients: t = !0, cache: n = !0, catalog: i = !1 } = {}) {
    var r, s;
    t && ((r = this.clients) == null || r.forEach((o) => this.disconnect(o)), (s = this.filterGroups) == null || s.forEach((o) => o.finalize()), this.clients = /* @__PURE__ */ new Set(), this.filterGroups = /* @__PURE__ */ new Map()), n && this.cache.clear(), i && this.catalog.clear();
  }
  databaseClient(t) {
    return arguments.length > 0 && (this.db = t), this.db;
  }
  async exec(t) {
    try {
      await this.db.query({ type: "exec", sql: t });
    } catch (n) {
      this._logger.error(n);
    }
  }
  query(t, { type: n = "arrow", cache: i = !0 } = {}) {
    const r = String(t), s = performance.now(), o = this.cache.get(r);
    if (o)
      return this._logger.debug("Cache"), o;
    {
      const a = this.db.query({ type: n, sql: r }), c = i ? this.cache.set(r, a) : a;
      return c.then(() => this._logger.debug(`Query: ${performance.now() - s}`)), c;
    }
  }
  async updateClient(t, n) {
    let i;
    try {
      t.queryPending(), i = await this.query(n);
    } catch (r) {
      this._logger.error(r), t.queryError(r);
      return;
    }
    try {
      t.queryResult(i).update();
    } catch (r) {
      this._logger.error(r);
    }
  }
  async requestQuery(t, n) {
    var i;
    return (i = this.filterGroups.get(t.filterBy)) == null || i.reset(), n ? this.updateClient(t, n) : t.update();
  }
  async connect(t) {
    const { catalog: n, clients: i, filterGroups: r, indexes: s } = this;
    if (i.has(t))
      throw new Error("Client already connected.");
    i.add(t);
    const o = t.fields();
    o != null && o.length && t.fieldStats(await n.queryFields(o));
    const a = t.filterBy;
    if (a)
      if (r.has(a))
        r.get(a).add(t);
      else {
        const c = new gA(this, a, s);
        r.set(a, c.add(t));
      }
    t.requestQuery();
  }
  disconnect(t) {
    var r;
    const { clients: n, filterGroups: i } = this;
    n.has(t) && (n.delete(t), (r = i.get(t.filterBy)) == null || r.remove(t));
  }
}
class Ga {
  /**
   * Constructor.
   * @param {*} filterSelection An optional selection to interactively filter
   *  this client's data. If provided, a coordinator will re-query and update
   *  the client when the selection updates.
   */
  constructor(t) {
    this._filterBy = t, this._requestUpdate = Kl(() => this.requestQuery(), !0);
  }
  /**
   * Return this client's filter selection.
   */
  get filterBy() {
    return this._filterBy;
  }
  /**
   * Return a boolean indicating if the client query can be indexed. Should
   * return true if changes to the filterBy selection does not change the
   * groupby domain of the client query.
   */
  get filterIndexable() {
    return !0;
  }
  /**
   * Return an array of fields queried by this client.
   */
  fields() {
    return null;
  }
  /**
   * Called by the coordinator to set the field statistics for this client.
   * @returns {this}
   */
  fieldStats() {
    return this;
  }
  /**
   * Return a query specifying the data needed by this client.
   */
  query() {
    return null;
  }
  /**
   * Called by the coordinator to inform the client that a query is pending.
   */
  queryPending() {
    return this;
  }
  /**
   * Called by the coordinator to return a query result.
   */
  queryResult() {
    return this;
  }
  /**
   * Called by the coordinator to report a query execution error.
   */
  queryError(t) {
    return console.error(t), this;
  }
  /**
   * Request the coordinator to execute a query for this client.
   * If an explicit query is not provided, the client query method will
   * be called, filtered by the current filterBy selection.
   */
  requestQuery(t) {
    var i;
    const n = t || this.query((i = this.filterBy) == null ? void 0 : i.predicate(this));
    return So().requestQuery(this, n);
  }
  /**
   * Request that the coordinator perform a throttled update of this client
   * using the default query. Unlike requestQuery, for which every call will
   * result in an executed query, multiple calls to requestUpdate may be
   * consolidated into a single update.
   */
  requestUpdate() {
    this._requestUpdate();
  }
  /**
   * Requests a client update.
   * For example to (re-)render an interface component.
   */
  update() {
    return this;
  }
}
function aw(e, t) {
  return e === t ? !1 : e instanceof Date && t instanceof Date ? +e != +t : Array.isArray(e) && Array.isArray(t) ? MA(e, t) : !0;
}
function MA(e, t) {
  if (e.length !== t.length)
    return !0;
  for (let n = 0; n < e.length; ++n)
    if (e[n] !== t[n])
      return !0;
  return !1;
}
function sr(e) {
  return e instanceof Mo;
}
class Mo {
  constructor(t) {
    this._value = t, this._listeners = /* @__PURE__ */ new Map();
  }
  static value(t) {
    return new Mo(t);
  }
  get value() {
    return this._value;
  }
  update(t, { force: n } = {}) {
    const i = aw(this._value, t);
    return i && (this._value = t), (i || n) && this.emit("value", this.value), this;
  }
  addEventListener(t, n) {
    let i = this._listeners.get(t) || [];
    i.includes(n) || (i = i.concat(n)), this._listeners.set(t, i);
  }
  removeEventListener(t, n) {
    const i = this._listeners.get(t);
    i != null && i.length && this._listeners.set(t, i.filter((r) => r !== n));
  }
  emit(t, n) {
    var i;
    (i = this._listeners.get(t)) == null || i.forEach((r) => r(n));
  }
}
function Zr(e) {
  return e instanceof Zi;
}
let Zi = class $s extends Mo {
  static intersect() {
    return new $s();
  }
  static crossfilter() {
    return new $s({ cross: !0 });
  }
  static union() {
    return new $s({ union: !0 });
  }
  static single() {
    return new $s({ single: !0 });
  }
  constructor({ union: t, cross: n, single: i } = {}) {
    super([]), this.active = null, this.union = !!t, this.cross = !!n, this.single = !!i;
  }
  clone() {
    const t = new $s();
    return t.active = this.active, t.union = this.union, t.cross = this.cross, t._value = this._value, t;
  }
  get value() {
    var n;
    const { clauses: t } = this;
    return (n = t[t.length - 1]) == null ? void 0 : n.value;
  }
  get clauses() {
    return super.value;
  }
  activate(t) {
    this.emit("activate", t);
  }
  update(t) {
    const { source: n, predicate: i } = t;
    this.active = t;
    const r = this.single ? [] : this.clauses.filter((s) => n !== s.source);
    return i && r.push(t), super.update(r);
  }
  predicate(t) {
    const { active: n, clauses: i, cross: r, union: s } = this;
    if (r && xd(t, n))
      return;
    const o = (r ? i.filter((a) => !xd(t, a)) : i).map((a) => a.predicate);
    return s && o.length > 1 ? rw(o) : o;
  }
};
function AA(e, {
  columns: t = Object.keys((e == null ? void 0 : e[0]) || {})
} = {}) {
  let n = [];
  if (Array.isArray(t) ? (n = t, t = n.reduce((r, s) => (r[s] = s, r), {})) : t && (n = Object.keys(t)), !n.length)
    throw new Error("Can not create table from empty column set.");
  const i = [];
  for (const r of e) {
    const s = n.map((o) => `${sp(r[o])} AS "${t[o]}"`);
    i.push(`(SELECT ${s.join(", ")})`);
  }
  return i.join(" UNION ALL ");
}
const $A = [
  "rectY-x",
  "rectX-y",
  "rect-x",
  "rect-y"
];
function IA(e, t) {
  return $A.includes(`${t}-${e}`);
}
function Oy(e, t = { steps: 25 }) {
  return (n, i) => IA(n, i) ? {
    [`${n}1`]: ph(e, t),
    [`${n}2`]: ph(e, { ...t, offset: 1 })
  } : {
    [n]: ph(e, t)
  };
}
function ph(e, t) {
  return new TA(e, t);
}
class TA extends Gr {
  constructor(t, n) {
    super(void 0, t), this.options = n, this.stats = ["min", "max"];
  }
  transform(t) {
    const { column: n, options: i } = this, { min: r, max: s } = t[n], o = EA(r, s, i), a = `(${n} - ${o.min})`, c = `${(o.max - o.min) / o.steps}::DOUBLE`, u = i.offset ? "1 + " : "";
    return q(
      `${r} + ${c} * (${u}FLOOR(${a} / ${c}))`,
      [n]
    );
  }
}
function EA(e, t, n) {
  let { steps: i = 25, minstep: r = 0, nice: s = !0 } = n;
  if (s !== !1) {
    const o = t - e, a = i, c = Math.LN10, u = Math.ceil(Math.log(a) / c);
    let l = Math.max(
      r,
      Math.pow(10, Math.round(Math.log(o) / c) - u)
    );
    for (; Math.ceil(o / l) > a; )
      l *= 10;
    const f = [5, 2];
    let h;
    for (let g = 0, y = f.length; g < y; ++g)
      h = l / f[g], h >= r && o / h <= a && (l = h);
    h = Math.log(l);
    const d = h >= 0 ? 0 : ~~(-h / c) + 1, p = Math.pow(10, -d - 1);
    h = Math.floor(e / l + p) * l, e = e < h ? h - l : h, t = Math.ceil(t / l) * l, i = Math.round((t - e) / l);
  }
  return { min: e, max: t, steps: i };
}
const NA = Xl(
  (e) => `MAKE_DATE(2012, MONTH(${e}), 1)`,
  "month"
), OA = Xl(
  (e) => `MAKE_DATE(2012, MONTH(${e}), DAY(${e}))`,
  "date"
), FA = Xl(
  (e) => `MAKE_DATE(2012, 1, DAY(${e}))`,
  "date"
);
class DA extends Map {
  request(t, n) {
    if (this.has(t))
      n(this.get(t));
    else {
      const i = this.waiting || (this.waiting = /* @__PURE__ */ new Map()), r = i.get(t) || [];
      i.set(t, r.concat(n));
    }
  }
  set(t, n) {
    this.has(t) && console.warn(`Overwriting named plot "${t}".`);
    const { waiting: i } = this;
    return i != null && i.has(t) && (i.get(t).forEach((r) => r(n)), i.delete(t)), super.set(t, n);
  }
}
const cw = new DA();
function BA(e) {
  return (t) => cw.set(e, t);
}
function uw(e, t, n) {
  sr(n) ? (n.addEventListener("value", (i) => {
    e.setAttribute(t, i), e.update();
  }), n.value !== void 0 && e.setAttribute(t, n.value)) : e.setAttribute(t, n);
}
function Y(e, t) {
  return (n) => {
    uw(n, e, t);
  };
}
function op(e) {
  return (t) => {
    for (const [n, i] of Object.entries(e))
      uw(t, n, i);
  };
}
function LA(e) {
  return Y("width", e);
}
function CA(e) {
  return Y("height", e);
}
function kA(e) {
  return Y("margin", e);
}
function RA(e) {
  const { top: t, bottom: n, left: i, right: r } = e, s = {};
  return t !== void 0 && (s.marginTop = t), n !== void 0 && (s.marginBottom = n), i !== void 0 && (s.marginLeft = i), r !== void 0 && (s.marginRight = r), op(s);
}
function UA(e) {
  return Y("marginTop", e);
}
function zA(e) {
  return Y("marginBottom", e);
}
function PA(e) {
  return Y("marginLeft", e);
}
function YA(e) {
  return Y("marginRight", e);
}
function qA(e) {
  return Y("axisX", e);
}
function VA(e) {
  return Y("axisY", e);
}
function jA(e) {
  return Y("axisLineX", e);
}
function XA(e) {
  return Y("axisLineY", e);
}
function WA(e) {
  return Y("insetX", e);
}
function HA(e) {
  return Y("insetY", e);
}
function GA(e) {
  return Y("grid", e);
}
function ZA(e) {
  return Y("gridX", e);
}
function KA(e) {
  return Y("gridY", e);
}
function JA(e) {
  return Y("scaleX", e);
}
function QA(e) {
  return Y("scaleY", e);
}
function t$(e) {
  return Y("domainX", e);
}
function e$(e) {
  return Y("domainY", e);
}
function n$(e) {
  return op({ domainX: e, domainY: e });
}
function i$(e) {
  return Y("domainFX", e);
}
function r$(e) {
  return Y("domainFY", e);
}
function s$(e) {
  return Y("niceX", e);
}
function o$(e) {
  return Y("niceY", e);
}
function a$(e) {
  return Y("zeroX", e);
}
function c$(e) {
  return Y("zeroY", e);
}
function u$(e) {
  return Y("reverseX", e);
}
function l$(e) {
  return Y("reverseY", e);
}
function f$(e) {
  return Y("ticksX", e);
}
function h$(e) {
  return Y("ticksY", e);
}
function d$(e) {
  return Y("tickFormatX", e);
}
function p$(e) {
  return Y("tickFormatY", e);
}
function m$(e) {
  return Y("tickFormatFX", e);
}
function y$(e) {
  return Y("tickFormatFY", e);
}
function g$(e) {
  return Y("tickFormatColor", e);
}
function b$(e) {
  return Y("tickRotateX", e);
}
function w$(e) {
  return Y("tickRotateY", e);
}
function _$(e) {
  return Y("tickSizeX", e);
}
function v$(e) {
  return Y("tickSizeY", e);
}
function x$(e) {
  return Y("labelX", e);
}
function S$(e) {
  return Y("labelY", e);
}
function M$(e) {
  return Y("labelAnchorX", e);
}
function A$(e) {
  return Y("labelAnchorY", e);
}
function $$(e) {
  return Y("labelOffsetX", e);
}
function I$(e) {
  return Y("labelOffsetY", e);
}
function T$(e) {
  return Y("scaleColor", e);
}
function E$(e) {
  return Y("domainColor", e);
}
function N$(e) {
  return Y("rangeColor", e);
}
function O$(e) {
  return Y("schemeColor", e);
}
function F$(e) {
  return Y("interpolateColor", e);
}
function D$(e) {
  return Y("domainR", e);
}
function B$(e) {
  return Y("rangeR", e);
}
function L$(e) {
  return Y("labelFX", e);
}
function C$(e) {
  return Y("labelFX", e);
}
function k$(e) {
  return Y("reverseFX", e);
}
function R$(e) {
  return Y("reverseFY", e);
}
function U$(e) {
  return Y("marginTopFacet", e);
}
function z$(e) {
  return Y("marginRightFacet", e);
}
function P$(e) {
  return Y("marginBottomFacet", e);
}
function Y$(e) {
  return Y("marginLeftFacet", e);
}
function q$(e) {
  return Y("gridFacet", e);
}
function V$(e) {
  return Y("labelFacet", e);
}
const j$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  attribute: Y,
  attributes: op,
  axisLineX: jA,
  axisLineY: XA,
  axisX: qA,
  axisY: VA,
  domainColor: E$,
  domainFX: i$,
  domainFY: r$,
  domainR: D$,
  domainX: t$,
  domainXY: n$,
  domainY: e$,
  grid: GA,
  gridFacet: q$,
  gridX: ZA,
  gridY: KA,
  height: CA,
  insetX: WA,
  insetY: HA,
  interpolateColor: F$,
  labelAnchorX: M$,
  labelAnchorY: A$,
  labelFX: L$,
  labelFY: C$,
  labelFacet: V$,
  labelOffsetX: $$,
  labelOffsetY: I$,
  labelX: x$,
  labelY: S$,
  margin: kA,
  marginBottom: zA,
  marginBottomFacet: P$,
  marginLeft: PA,
  marginLeftFacet: Y$,
  marginRight: YA,
  marginRightFacet: z$,
  marginTop: UA,
  marginTopFacet: U$,
  margins: RA,
  name: BA,
  niceX: s$,
  niceY: o$,
  rangeColor: N$,
  rangeR: B$,
  reverseFX: k$,
  reverseFY: R$,
  reverseX: u$,
  reverseY: l$,
  scaleColor: T$,
  scaleX: JA,
  scaleY: QA,
  schemeColor: O$,
  tickFormatColor: g$,
  tickFormatFX: m$,
  tickFormatFY: y$,
  tickFormatX: d$,
  tickFormatY: p$,
  tickRotateX: b$,
  tickRotateY: w$,
  tickSizeX: _$,
  tickSizeY: v$,
  ticksX: f$,
  ticksY: h$,
  width: LA,
  zeroX: a$,
  zeroY: c$
}, Symbol.toStringTag, { value: "Module" }));
function X$(e, t) {
  return { table: e, options: t };
}
function jt(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Ao(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function ap(e) {
  let t, n, i;
  e.length !== 2 ? (t = jt, n = (a, c) => jt(e(a), c), i = (a, c) => e(a) - c) : (t = e === jt || e === Ao ? e : W$, n = e, i = e);
  function r(a, c, u = 0, l = a.length) {
    if (u < l) {
      if (t(c, c) !== 0)
        return l;
      do {
        const f = u + l >>> 1;
        n(a[f], c) < 0 ? u = f + 1 : l = f;
      } while (u < l);
    }
    return u;
  }
  function s(a, c, u = 0, l = a.length) {
    if (u < l) {
      if (t(c, c) !== 0)
        return l;
      do {
        const f = u + l >>> 1;
        n(a[f], c) <= 0 ? u = f + 1 : l = f;
      } while (u < l);
    }
    return u;
  }
  function o(a, c, u = 0, l = a.length) {
    const f = r(a, c, u, l - 1);
    return f > u && i(a[f - 1], c) > -i(a[f], c) ? f - 1 : f;
  }
  return { left: r, center: o, right: s };
}
function W$() {
  return 0;
}
function lw(e) {
  return e === null ? NaN : +e;
}
function* H$(e, t) {
  if (t === void 0)
    for (let n of e)
      n != null && (n = +n) >= n && (yield n);
  else {
    let n = -1;
    for (let i of e)
      (i = t(i, ++n, e)) != null && (i = +i) >= i && (yield i);
  }
}
const G$ = ap(jt), Z$ = G$.right;
ap(lw).center;
const Jl = Z$, fw = hw(dw), K$ = hw(J$);
function hw(e) {
  return function(t, n, i = n) {
    if (!((n = +n) >= 0))
      throw new RangeError("invalid rx");
    if (!((i = +i) >= 0))
      throw new RangeError("invalid ry");
    let { data: r, width: s, height: o } = t;
    if (!((s = Math.floor(s)) >= 0))
      throw new RangeError("invalid width");
    if (!((o = Math.floor(o !== void 0 ? o : r.length / s)) >= 0))
      throw new RangeError("invalid height");
    if (!s || !o || !n && !i)
      return t;
    const a = n && e(n), c = i && e(i), u = r.slice();
    return a && c ? (fs(a, u, r, s, o), fs(a, r, u, s, o), fs(a, u, r, s, o), hs(c, r, u, s, o), hs(c, u, r, s, o), hs(c, r, u, s, o)) : a ? (fs(a, r, u, s, o), fs(a, u, r, s, o), fs(a, r, u, s, o)) : c && (hs(c, r, u, s, o), hs(c, u, r, s, o), hs(c, r, u, s, o)), t;
  };
}
function fs(e, t, n, i, r) {
  for (let s = 0, o = i * r; s < o; )
    e(t, n, s, s += i, 1);
}
function hs(e, t, n, i, r) {
  for (let s = 0, o = i * r; s < i; ++s)
    e(t, n, s, s + o, i);
}
function J$(e) {
  const t = dw(e);
  return (n, i, r, s, o) => {
    r <<= 2, s <<= 2, o <<= 2, t(n, i, r + 0, s + 0, o), t(n, i, r + 1, s + 1, o), t(n, i, r + 2, s + 2, o), t(n, i, r + 3, s + 3, o);
  };
}
function dw(e) {
  const t = Math.floor(e);
  if (t === e)
    return Q$(e);
  const n = e - t, i = 2 * e + 1;
  return (r, s, o, a, c) => {
    if (!((a -= c) >= o))
      return;
    let u = t * s[o];
    const l = c * t, f = l + c;
    for (let h = o, d = o + l; h < d; h += c)
      u += s[Math.min(a, h)];
    for (let h = o, d = a; h <= d; h += c)
      u += s[Math.min(a, h + l)], r[h] = (u + n * (s[Math.max(o, h - f)] + s[Math.min(a, h + f)])) / i, u -= s[Math.max(o, h - l)];
  };
}
function Q$(e) {
  const t = 2 * e + 1;
  return (n, i, r, s, o) => {
    if (!((s -= o) >= r))
      return;
    let a = e * i[r];
    const c = o * e;
    for (let u = r, l = r + c; u < l; u += o)
      a += i[Math.min(s, u)];
    for (let u = r, l = s; u <= l; u += o)
      a += i[Math.min(s, u + c)], n[u] = a / t, a -= i[Math.max(r, u - c)];
  };
}
function Ql(e, t) {
  let n = 0;
  if (t === void 0)
    for (let i of e)
      i != null && (i = +i) >= i && ++n;
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (r = +r) >= r && ++n;
  }
  return n;
}
function t7(e) {
  return e.length | 0;
}
function e7(e) {
  return !(e > 0);
}
function n7(e) {
  return typeof e != "object" || "length" in e ? e : Array.from(e);
}
function i7(e) {
  return (t) => e(...t);
}
function r7(...e) {
  const t = typeof e[e.length - 1] == "function" && i7(e.pop());
  e = e.map(n7);
  const n = e.map(t7), i = e.length - 1, r = new Array(i + 1).fill(0), s = [];
  if (i < 0 || n.some(e7))
    return s;
  for (; ; ) {
    s.push(r.map((a, c) => e[c][a]));
    let o = i;
    for (; ++r[o] === n[o]; ) {
      if (o === 0)
        return t ? s.map(t) : s;
      r[o--] = 0;
    }
  }
}
function s7(e, t) {
  var n = 0, i = 0;
  return Float64Array.from(e, t === void 0 ? (r) => n += +r || 0 : (r) => n += +t(r, i++, e) || 0);
}
function cp(e, t) {
  let n = 0, i, r = 0, s = 0;
  if (t === void 0)
    for (let o of e)
      o != null && (o = +o) >= o && (i = o - r, r += i / ++n, s += i * (o - r));
  else {
    let o = -1;
    for (let a of e)
      (a = t(a, ++o, e)) != null && (a = +a) >= a && (i = a - r, r += i / ++n, s += i * (a - r));
  }
  if (n > 1)
    return s / (n - 1);
}
function tf(e, t) {
  const n = cp(e, t);
  return n && Math.sqrt(n);
}
function Ne(e, t) {
  let n, i;
  if (t === void 0)
    for (const r of e)
      r != null && (n === void 0 ? r >= r && (n = i = r) : (n > r && (n = r), i < r && (i = r)));
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n === void 0 ? s >= s && (n = i = s) : (n > s && (n = s), i < s && (i = s)));
  }
  return [n, i];
}
class Gn {
  constructor() {
    this._partials = new Float64Array(32), this._n = 0;
  }
  add(t) {
    const n = this._partials;
    let i = 0;
    for (let r = 0; r < this._n && r < 32; r++) {
      const s = n[r], o = t + s, a = Math.abs(t) < Math.abs(s) ? t - (o - s) : s - (o - t);
      a && (n[i++] = a), t = o;
    }
    return n[i] = t, this._n = i + 1, this;
  }
  valueOf() {
    const t = this._partials;
    let n = this._n, i, r, s, o = 0;
    if (n > 0) {
      for (o = t[--n]; n > 0 && (i = o, r = t[--n], o = i + r, s = r - (o - i), !s); )
        ;
      n > 0 && (s < 0 && t[n - 1] < 0 || s > 0 && t[n - 1] > 0) && (r = s * 2, i = o + r, r == i - o && (o = i));
    }
    return o;
  }
}
class so extends Map {
  constructor(t, n = yw) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const [i, r] of t)
        this.set(i, r);
  }
  get(t) {
    return super.get(Md(this, t));
  }
  has(t) {
    return super.has(Md(this, t));
  }
  set(t, n) {
    return super.set(pw(this, t), n);
  }
  delete(t) {
    return super.delete(mw(this, t));
  }
}
class up extends Set {
  constructor(t, n = yw) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const i of t)
        this.add(i);
  }
  has(t) {
    return super.has(Md(this, t));
  }
  add(t) {
    return super.add(pw(this, t));
  }
  delete(t) {
    return super.delete(mw(this, t));
  }
}
function Md({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : n;
}
function pw({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : (e.set(i, n), n);
}
function mw({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) && (n = e.get(i), e.delete(i)), n;
}
function yw(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function Ad(e) {
  return e;
}
function Yi(e, ...t) {
  return gw(e, Ad, Ad, t);
}
function qr(e, t, ...n) {
  return gw(e, Ad, t, n);
}
function gw(e, t, n, i) {
  return function r(s, o) {
    if (o >= i.length)
      return n(s);
    const a = new so(), c = i[o++];
    let u = -1;
    for (const l of s) {
      const f = c(l, ++u, s), h = a.get(f);
      h ? h.push(l) : a.set(f, [l]);
    }
    for (const [l, f] of a)
      a.set(l, r(f, o));
    return t(a);
  }(e, 0);
}
function o7(e, t) {
  return Array.from(t, (n) => e[n]);
}
function oo(e, ...t) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  e = Array.from(e);
  let [n] = t;
  if (n && n.length !== 2 || t.length > 1) {
    const i = Uint32Array.from(e, (r, s) => s);
    return t.length > 1 ? (t = t.map((r) => e.map(r)), i.sort((r, s) => {
      for (const o of t) {
        const a = xa(o[r], o[s]);
        if (a)
          return a;
      }
    })) : (n = e.map(n), i.sort((r, s) => xa(n[r], n[s]))), o7(e, i);
  }
  return e.sort(lp(n));
}
function lp(e = jt) {
  if (e === jt)
    return xa;
  if (typeof e != "function")
    throw new TypeError("compare is not a function");
  return (t, n) => {
    const i = e(t, n);
    return i || i === 0 ? i : (e(n, n) === 0) - (e(t, t) === 0);
  };
}
function xa(e, t) {
  return (e == null || !(e >= e)) - (t == null || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0);
}
function fp(e, t, n) {
  return (t.length !== 2 ? oo(qr(e, t, n), ([i, r], [s, o]) => jt(r, o) || jt(i, s)) : oo(Yi(e, n), ([i, r], [s, o]) => t(r, o) || jt(i, s))).map(([i]) => i);
}
const a7 = Math.sqrt(50), c7 = Math.sqrt(10), u7 = Math.sqrt(2);
function zu(e, t, n) {
  const i = (t - e) / Math.max(0, n), r = Math.floor(Math.log10(i)), s = i / Math.pow(10, r), o = s >= a7 ? 10 : s >= c7 ? 5 : s >= u7 ? 2 : 1;
  let a, c, u;
  return r < 0 ? (u = Math.pow(10, -r) / o, a = Math.round(e * u), c = Math.round(t * u), a / u < e && ++a, c / u > t && --c, u = -u) : (u = Math.pow(10, r) * o, a = Math.round(e / u), c = Math.round(t / u), a * u < e && ++a, c * u > t && --c), c < a && 0.5 <= n && n < 2 ? zu(e, t, n * 2) : [a, c, u];
}
function or(e, t, n) {
  if (t = +t, e = +e, n = +n, !(n > 0))
    return [];
  if (e === t)
    return [e];
  const i = t < e, [r, s, o] = i ? zu(t, e, n) : zu(e, t, n);
  if (!(s >= r))
    return [];
  const a = s - r + 1, c = new Array(a);
  if (i)
    if (o < 0)
      for (let u = 0; u < a; ++u)
        c[u] = (s - u) / -o;
    else
      for (let u = 0; u < a; ++u)
        c[u] = (s - u) * o;
  else if (o < 0)
    for (let u = 0; u < a; ++u)
      c[u] = (r + u) / -o;
  else
    for (let u = 0; u < a; ++u)
      c[u] = (r + u) * o;
  return c;
}
function Sa(e, t, n) {
  return t = +t, e = +e, n = +n, zu(e, t, n)[2];
}
function $d(e, t, n) {
  t = +t, e = +e, n = +n;
  const i = t < e, r = i ? Sa(t, e, n) : Sa(e, t, n);
  return (i ? -1 : 1) * (r < 0 ? 1 / -r : r);
}
function bw(e, t, n) {
  let i;
  for (; ; ) {
    const r = Sa(e, t, n);
    if (r === i || r === 0 || !isFinite(r))
      return [e, t];
    r > 0 ? (e = Math.floor(e / r) * r, t = Math.ceil(t / r) * r) : r < 0 && (e = Math.ceil(e * r) / r, t = Math.floor(t * r) / r), i = r;
  }
}
function hp(e) {
  return Math.ceil(Math.log(Ql(e)) / Math.LN2) + 1;
}
function Gt(e, t) {
  let n;
  if (t === void 0)
    for (const i of e)
      i != null && (n < i || n === void 0 && i >= i) && (n = i);
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (n < r || n === void 0 && r >= r) && (n = r);
  }
  return n;
}
function l7(e, t) {
  let n, i = -1, r = -1;
  if (t === void 0)
    for (const s of e)
      ++r, s != null && (n < s || n === void 0 && s >= s) && (n = s, i = r);
  else
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n < s || n === void 0 && s >= s) && (n = s, i = r);
  return i;
}
function he(e, t) {
  let n;
  if (t === void 0)
    for (const i of e)
      i != null && (n > i || n === void 0 && i >= i) && (n = i);
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (n > r || n === void 0 && r >= r) && (n = r);
  }
  return n;
}
function f7(e, t) {
  let n, i = -1, r = -1;
  if (t === void 0)
    for (const s of e)
      ++r, s != null && (n > s || n === void 0 && s >= s) && (n = s, i = r);
  else
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n > s || n === void 0 && s >= s) && (n = s, i = r);
  return i;
}
function ww(e, t, n = 0, i = 1 / 0, r) {
  if (t = Math.floor(t), n = Math.floor(Math.max(0, n)), i = Math.floor(Math.min(e.length - 1, i)), !(n <= t && t <= i))
    return e;
  for (r = r === void 0 ? xa : lp(r); i > n; ) {
    if (i - n > 600) {
      const c = i - n + 1, u = t - n + 1, l = Math.log(c), f = 0.5 * Math.exp(2 * l / 3), h = 0.5 * Math.sqrt(l * f * (c - f) / c) * (u - c / 2 < 0 ? -1 : 1), d = Math.max(n, Math.floor(t - u * f / c + h)), p = Math.min(i, Math.floor(t + (c - u) * f / c + h));
      ww(e, t, d, p, r);
    }
    const s = e[t];
    let o = n, a = i;
    for (Po(e, n, t), r(e[i], s) > 0 && Po(e, n, i); o < a; ) {
      for (Po(e, o, a), ++o, --a; r(e[o], s) < 0; )
        ++o;
      for (; r(e[a], s) > 0; )
        --a;
    }
    r(e[n], s) === 0 ? Po(e, n, a) : (++a, Po(e, a, i)), a <= t && (n = a + 1), t <= a && (i = a - 1);
  }
  return e;
}
function Po(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function dp(e, t = jt) {
  let n, i = !1;
  if (t.length === 1) {
    let r;
    for (const s of e) {
      const o = t(s);
      (i ? jt(o, r) > 0 : jt(o, o) === 0) && (n = s, r = o, i = !0);
    }
  } else
    for (const r of e)
      (i ? t(r, n) > 0 : t(r, r) === 0) && (n = r, i = !0);
  return n;
}
function ar(e, t, n) {
  if (e = Float64Array.from(H$(e, n)), !(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return he(e);
    if (t >= 1)
      return Gt(e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = Gt(ww(e, s).subarray(0, s + 1)), a = he(e.subarray(s + 1));
    return o + (a - o) * (r - s);
  }
}
function h7(e, t, n = lw) {
  if (!(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return +n(e[0], 0, e);
    if (t >= 1)
      return +n(e[i - 1], i - 1, e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = +n(e[s], s, e), a = +n(e[s + 1], s + 1, e);
    return o + (a - o) * (r - s);
  }
}
function d7(e, t, n) {
  return Math.ceil((n - t) / (2 * (ar(e, 0.75) - ar(e, 0.25)) * Math.pow(Ql(e), -1 / 3)));
}
function _w(e, t, n) {
  return Math.ceil((n - t) * Math.cbrt(Ql(e)) / (3.49 * tf(e)));
}
function pp(e, t) {
  let n = 0, i = 0;
  if (t === void 0)
    for (let r of e)
      r != null && (r = +r) >= r && (++n, i += r);
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (s = +s) >= s && (++n, i += s);
  }
  if (n)
    return i / n;
}
function Ma(e, t) {
  return ar(e, 0.5, t);
}
function* p7(e) {
  for (const t of e)
    yield* t;
}
function vw(e) {
  return Array.from(p7(e));
}
function xw(e, t) {
  const n = new so();
  if (t === void 0)
    for (let s of e)
      s != null && s >= s && n.set(s, (n.get(s) || 0) + 1);
  else {
    let s = -1;
    for (let o of e)
      (o = t(o, ++s, e)) != null && o >= o && n.set(o, (n.get(o) || 0) + 1);
  }
  let i, r = 0;
  for (const [s, o] of n)
    o > r && (r = o, i = s);
  return i;
}
function m7(e, t = y7) {
  const n = [];
  let i, r = !1;
  for (const s of e)
    r && n.push(t(i, s)), i = s, r = !0;
  return n;
}
function y7(e, t) {
  return [e, t];
}
function sn(e, t, n) {
  e = +e, t = +t, n = (r = arguments.length) < 2 ? (t = e, e = 0, 1) : r < 3 ? 1 : +n;
  for (var i = -1, r = Math.max(0, Math.ceil((t - e) / n)) | 0, s = new Array(r); ++i < r; )
    s[i] = e + i * n;
  return s;
}
function Sw(e, t = jt) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  let n = Array.from(e);
  const i = new Float64Array(n.length);
  t.length !== 2 && (n = n.map(t), t = jt);
  const r = (a, c) => t(n[a], n[c]);
  let s, o;
  return Uint32Array.from(n, (a, c) => c).sort(t === jt ? (a, c) => xa(n[a], n[c]) : lp(r)).forEach((a, c) => {
    const u = r(a, s === void 0 ? a : s);
    u >= 0 ? ((s === void 0 || u > 0) && (s = a, o = c), i[a] = o) : i[a] = NaN;
  }), i;
}
function g7(e, t = jt) {
  let n, i = !1;
  if (t.length === 1) {
    let r;
    for (const s of e) {
      const o = t(s);
      (i ? jt(o, r) < 0 : jt(o, o) === 0) && (n = s, r = o, i = !0);
    }
  } else
    for (const r of e)
      (i ? t(r, n) < 0 : t(r, r) === 0) && (n = r, i = !0);
  return n;
}
function ti(e, t) {
  let n = 0;
  if (t === void 0)
    for (let i of e)
      (i = +i) && (n += i);
  else {
    let i = -1;
    for (let r of e)
      (r = +t(r, ++i, e)) && (n += r);
  }
  return n;
}
function Fy(e, t) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  if (typeof t != "function")
    throw new TypeError("mapper is not a function");
  return Array.from(e, (n, i) => t(n, i, e));
}
function Pu(e) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  return Array.from(e).reverse();
}
function b7(e) {
  return e;
}
var mh = 1, yh = 2, Id = 3, _c = 4, Dy = 1e-6;
function w7(e) {
  return "translate(" + e + ",0)";
}
function _7(e) {
  return "translate(0," + e + ")";
}
function v7(e) {
  return (t) => +e(t);
}
function x7(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (n) => +e(n) + t;
}
function S7() {
  return !this.__axis;
}
function M7(e, t) {
  var n = [], i = null, r = null, s = 6, o = 6, a = 3, c = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, u = e === mh || e === _c ? -1 : 1, l = e === _c || e === yh ? "x" : "y", f = e === mh || e === Id ? w7 : _7;
  function h(d) {
    var p = i ?? (t.ticks ? t.ticks.apply(t, n) : t.domain()), g = r ?? (t.tickFormat ? t.tickFormat.apply(t, n) : b7), y = Math.max(s, 0) + a, m = t.range(), b = +m[0] + c, w = +m[m.length - 1] + c, _ = (t.bandwidth ? x7 : v7)(t.copy(), c), x = d.selection ? d.selection() : d, S = x.selectAll(".domain").data([null]), I = x.selectAll(".tick").data(p, t).order(), N = I.exit(), F = I.enter().append("g").attr("class", "tick"), $ = I.select("line"), T = I.select("text");
    S = S.merge(S.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), I = I.merge(F), $ = $.merge(F.append("line").attr("stroke", "currentColor").attr(l + "2", u * s)), T = T.merge(F.append("text").attr("fill", "currentColor").attr(l, u * y).attr("dy", e === mh ? "0em" : e === Id ? "0.71em" : "0.32em")), d !== x && (S = S.transition(d), I = I.transition(d), $ = $.transition(d), T = T.transition(d), N = N.transition(d).attr("opacity", Dy).attr("transform", function(D) {
      return isFinite(D = _(D)) ? f(D + c) : this.getAttribute("transform");
    }), F.attr("opacity", Dy).attr("transform", function(D) {
      var E = this.parentNode.__axis;
      return f((E && isFinite(E = E(D)) ? E : _(D)) + c);
    })), N.remove(), S.attr("d", e === _c || e === yh ? o ? "M" + u * o + "," + b + "H" + c + "V" + w + "H" + u * o : "M" + c + "," + b + "V" + w : o ? "M" + b + "," + u * o + "V" + c + "H" + w + "V" + u * o : "M" + b + "," + c + "H" + w), I.attr("opacity", 1).attr("transform", function(D) {
      return f(_(D) + c);
    }), $.attr(l + "2", u * s), T.attr(l, u * y).text(g), x.filter(S7).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === yh ? "start" : e === _c ? "end" : "middle"), x.each(function() {
      this.__axis = _;
    });
  }
  return h.scale = function(d) {
    return arguments.length ? (t = d, h) : t;
  }, h.ticks = function() {
    return n = Array.from(arguments), h;
  }, h.tickArguments = function(d) {
    return arguments.length ? (n = d == null ? [] : Array.from(d), h) : n.slice();
  }, h.tickValues = function(d) {
    return arguments.length ? (i = d == null ? null : Array.from(d), h) : i && i.slice();
  }, h.tickFormat = function(d) {
    return arguments.length ? (r = d, h) : r;
  }, h.tickSize = function(d) {
    return arguments.length ? (s = o = +d, h) : s;
  }, h.tickSizeInner = function(d) {
    return arguments.length ? (s = +d, h) : s;
  }, h.tickSizeOuter = function(d) {
    return arguments.length ? (o = +d, h) : o;
  }, h.tickPadding = function(d) {
    return arguments.length ? (a = +d, h) : a;
  }, h.offset = function(d) {
    return arguments.length ? (c = +d, h) : c;
  }, h;
}
function A7(e) {
  return M7(Id, e);
}
var $7 = { value: () => {
} };
function ef() {
  for (var e = 0, t = arguments.length, n = {}, i; e < t; ++e) {
    if (!(i = arguments[e] + "") || i in n || /[\s.]/.test(i))
      throw new Error("illegal type: " + i);
    n[i] = [];
  }
  return new tu(n);
}
function tu(e) {
  this._ = e;
}
function I7(e, t) {
  return e.trim().split(/^|\s+/).map(function(n) {
    var i = "", r = n.indexOf(".");
    if (r >= 0 && (i = n.slice(r + 1), n = n.slice(0, r)), n && !t.hasOwnProperty(n))
      throw new Error("unknown type: " + n);
    return { type: n, name: i };
  });
}
tu.prototype = ef.prototype = {
  constructor: tu,
  on: function(e, t) {
    var n = this._, i = I7(e + "", n), r, s = -1, o = i.length;
    if (arguments.length < 2) {
      for (; ++s < o; )
        if ((r = (e = i[s]).type) && (r = T7(n[r], e.name)))
          return r;
      return;
    }
    if (t != null && typeof t != "function")
      throw new Error("invalid callback: " + t);
    for (; ++s < o; )
      if (r = (e = i[s]).type)
        n[r] = By(n[r], e.name, t);
      else if (t == null)
        for (r in n)
          n[r] = By(n[r], e.name, null);
    return this;
  },
  copy: function() {
    var e = {}, t = this._;
    for (var n in t)
      e[n] = t[n].slice();
    return new tu(e);
  },
  call: function(e, t) {
    if ((r = arguments.length - 2) > 0)
      for (var n = new Array(r), i = 0, r, s; i < r; ++i)
        n[i] = arguments[i + 2];
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (s = this._[e], i = 0, r = s.length; i < r; ++i)
      s[i].value.apply(t, n);
  },
  apply: function(e, t, n) {
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (var i = this._[e], r = 0, s = i.length; r < s; ++r)
      i[r].value.apply(t, n);
  }
};
function T7(e, t) {
  for (var n = 0, i = e.length, r; n < i; ++n)
    if ((r = e[n]).name === t)
      return r.value;
}
function By(e, t, n) {
  for (var i = 0, r = e.length; i < r; ++i)
    if (e[i].name === t) {
      e[i] = $7, e = e.slice(0, i).concat(e.slice(i + 1));
      break;
    }
  return n != null && e.push({ name: t, value: n }), e;
}
var Td = "http://www.w3.org/1999/xhtml";
const ao = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: Td,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function nf(e) {
  var t = e += "", n = t.indexOf(":");
  return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), ao.hasOwnProperty(t) ? { space: ao[t], local: e } : e;
}
function E7(e) {
  return function() {
    var t = this.ownerDocument, n = this.namespaceURI;
    return n === Td && t.documentElement.namespaceURI === Td ? t.createElement(e) : t.createElementNS(n, e);
  };
}
function N7(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function rf(e) {
  var t = nf(e);
  return (t.local ? N7 : E7)(t);
}
function O7() {
}
function mp(e) {
  return e == null ? O7 : function() {
    return this.querySelector(e);
  };
}
function F7(e) {
  typeof e != "function" && (e = mp(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = new Array(o), c, u, l = 0; l < o; ++l)
      (c = s[l]) && (u = e.call(c, c.__data__, l, s)) && ("__data__" in c && (u.__data__ = c.__data__), a[l] = u);
  return new Xe(i, this._parents);
}
function D7(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function B7() {
  return [];
}
function Mw(e) {
  return e == null ? B7 : function() {
    return this.querySelectorAll(e);
  };
}
function L7(e) {
  return function() {
    return D7(e.apply(this, arguments));
  };
}
function C7(e) {
  typeof e == "function" ? e = L7(e) : e = Mw(e);
  for (var t = this._groups, n = t.length, i = [], r = [], s = 0; s < n; ++s)
    for (var o = t[s], a = o.length, c, u = 0; u < a; ++u)
      (c = o[u]) && (i.push(e.call(c, c.__data__, u, o)), r.push(c));
  return new Xe(i, r);
}
function Aw(e) {
  return function() {
    return this.matches(e);
  };
}
function $w(e) {
  return function(t) {
    return t.matches(e);
  };
}
var k7 = Array.prototype.find;
function R7(e) {
  return function() {
    return k7.call(this.children, e);
  };
}
function U7() {
  return this.firstElementChild;
}
function z7(e) {
  return this.select(e == null ? U7 : R7(typeof e == "function" ? e : $w(e)));
}
var P7 = Array.prototype.filter;
function Y7() {
  return Array.from(this.children);
}
function q7(e) {
  return function() {
    return P7.call(this.children, e);
  };
}
function V7(e) {
  return this.selectAll(e == null ? Y7 : q7(typeof e == "function" ? e : $w(e)));
}
function j7(e) {
  typeof e != "function" && (e = Aw(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = [], c, u = 0; u < o; ++u)
      (c = s[u]) && e.call(c, c.__data__, u, s) && a.push(c);
  return new Xe(i, this._parents);
}
function Iw(e) {
  return new Array(e.length);
}
function X7() {
  return new Xe(this._enter || this._groups.map(Iw), this._parents);
}
function Yu(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
Yu.prototype = {
  constructor: Yu,
  appendChild: function(e) {
    return this._parent.insertBefore(e, this._next);
  },
  insertBefore: function(e, t) {
    return this._parent.insertBefore(e, t);
  },
  querySelector: function(e) {
    return this._parent.querySelector(e);
  },
  querySelectorAll: function(e) {
    return this._parent.querySelectorAll(e);
  }
};
function W7(e) {
  return function() {
    return e;
  };
}
function H7(e, t, n, i, r, s) {
  for (var o = 0, a, c = t.length, u = s.length; o < u; ++o)
    (a = t[o]) ? (a.__data__ = s[o], i[o] = a) : n[o] = new Yu(e, s[o]);
  for (; o < c; ++o)
    (a = t[o]) && (r[o] = a);
}
function G7(e, t, n, i, r, s, o) {
  var a, c, u = /* @__PURE__ */ new Map(), l = t.length, f = s.length, h = new Array(l), d;
  for (a = 0; a < l; ++a)
    (c = t[a]) && (h[a] = d = o.call(c, c.__data__, a, t) + "", u.has(d) ? r[a] = c : u.set(d, c));
  for (a = 0; a < f; ++a)
    d = o.call(e, s[a], a, s) + "", (c = u.get(d)) ? (i[a] = c, c.__data__ = s[a], u.delete(d)) : n[a] = new Yu(e, s[a]);
  for (a = 0; a < l; ++a)
    (c = t[a]) && u.get(h[a]) === c && (r[a] = c);
}
function Z7(e) {
  return e.__data__;
}
function K7(e, t) {
  if (!arguments.length)
    return Array.from(this, Z7);
  var n = t ? G7 : H7, i = this._parents, r = this._groups;
  typeof e != "function" && (e = W7(e));
  for (var s = r.length, o = new Array(s), a = new Array(s), c = new Array(s), u = 0; u < s; ++u) {
    var l = i[u], f = r[u], h = f.length, d = J7(e.call(l, l && l.__data__, u, i)), p = d.length, g = a[u] = new Array(p), y = o[u] = new Array(p), m = c[u] = new Array(h);
    n(l, f, g, y, m, d, t);
    for (var b = 0, w = 0, _, x; b < p; ++b)
      if (_ = g[b]) {
        for (b >= w && (w = b + 1); !(x = y[w]) && ++w < p; )
          ;
        _._next = x || null;
      }
  }
  return o = new Xe(o, i), o._enter = a, o._exit = c, o;
}
function J7(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function Q7() {
  return new Xe(this._exit || this._groups.map(Iw), this._parents);
}
function tI(e, t, n) {
  var i = this.enter(), r = this, s = this.exit();
  return typeof e == "function" ? (i = e(i), i && (i = i.selection())) : i = i.append(e + ""), t != null && (r = t(r), r && (r = r.selection())), n == null ? s.remove() : n(s), i && r ? i.merge(r).order() : r;
}
function eI(e) {
  for (var t = e.selection ? e.selection() : e, n = this._groups, i = t._groups, r = n.length, s = i.length, o = Math.min(r, s), a = new Array(r), c = 0; c < o; ++c)
    for (var u = n[c], l = i[c], f = u.length, h = a[c] = new Array(f), d, p = 0; p < f; ++p)
      (d = u[p] || l[p]) && (h[p] = d);
  for (; c < r; ++c)
    a[c] = n[c];
  return new Xe(a, this._parents);
}
function nI() {
  for (var e = this._groups, t = -1, n = e.length; ++t < n; )
    for (var i = e[t], r = i.length - 1, s = i[r], o; --r >= 0; )
      (o = i[r]) && (s && o.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(o, s), s = o);
  return this;
}
function iI(e) {
  e || (e = rI);
  function t(f, h) {
    return f && h ? e(f.__data__, h.__data__) : !f - !h;
  }
  for (var n = this._groups, i = n.length, r = new Array(i), s = 0; s < i; ++s) {
    for (var o = n[s], a = o.length, c = r[s] = new Array(a), u, l = 0; l < a; ++l)
      (u = o[l]) && (c[l] = u);
    c.sort(t);
  }
  return new Xe(r, this._parents).order();
}
function rI(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function sI() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function oI() {
  return Array.from(this);
}
function aI() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var i = e[t], r = 0, s = i.length; r < s; ++r) {
      var o = i[r];
      if (o)
        return o;
    }
  return null;
}
function cI() {
  let e = 0;
  for (const t of this)
    ++e;
  return e;
}
function uI() {
  return !this.node();
}
function lI(e) {
  for (var t = this._groups, n = 0, i = t.length; n < i; ++n)
    for (var r = t[n], s = 0, o = r.length, a; s < o; ++s)
      (a = r[s]) && e.call(a, a.__data__, s, r);
  return this;
}
function fI(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function hI(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function dI(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function pI(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function mI(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
  };
}
function yI(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttributeNS(e.space, e.local) : this.setAttributeNS(e.space, e.local, n);
  };
}
function gI(e, t) {
  var n = nf(e);
  if (arguments.length < 2) {
    var i = this.node();
    return n.local ? i.getAttributeNS(n.space, n.local) : i.getAttribute(n);
  }
  return this.each((t == null ? n.local ? hI : fI : typeof t == "function" ? n.local ? yI : mI : n.local ? pI : dI)(n, t));
}
function Tw(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function bI(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function wI(e, t, n) {
  return function() {
    this.style.setProperty(e, t, n);
  };
}
function _I(e, t, n) {
  return function() {
    var i = t.apply(this, arguments);
    i == null ? this.style.removeProperty(e) : this.style.setProperty(e, i, n);
  };
}
function vI(e, t, n) {
  return arguments.length > 1 ? this.each((t == null ? bI : typeof t == "function" ? _I : wI)(e, t, n ?? "")) : co(this.node(), e);
}
function co(e, t) {
  return e.style.getPropertyValue(t) || Tw(e).getComputedStyle(e, null).getPropertyValue(t);
}
function xI(e) {
  return function() {
    delete this[e];
  };
}
function SI(e, t) {
  return function() {
    this[e] = t;
  };
}
function MI(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? delete this[e] : this[e] = n;
  };
}
function AI(e, t) {
  return arguments.length > 1 ? this.each((t == null ? xI : typeof t == "function" ? MI : SI)(e, t)) : this.node()[e];
}
function Ew(e) {
  return e.trim().split(/^|\s+/);
}
function yp(e) {
  return e.classList || new Nw(e);
}
function Nw(e) {
  this._node = e, this._names = Ew(e.getAttribute("class") || "");
}
Nw.prototype = {
  add: function(e) {
    var t = this._names.indexOf(e);
    t < 0 && (this._names.push(e), this._node.setAttribute("class", this._names.join(" ")));
  },
  remove: function(e) {
    var t = this._names.indexOf(e);
    t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" ")));
  },
  contains: function(e) {
    return this._names.indexOf(e) >= 0;
  }
};
function Ow(e, t) {
  for (var n = yp(e), i = -1, r = t.length; ++i < r; )
    n.add(t[i]);
}
function Fw(e, t) {
  for (var n = yp(e), i = -1, r = t.length; ++i < r; )
    n.remove(t[i]);
}
function $I(e) {
  return function() {
    Ow(this, e);
  };
}
function II(e) {
  return function() {
    Fw(this, e);
  };
}
function TI(e, t) {
  return function() {
    (t.apply(this, arguments) ? Ow : Fw)(this, e);
  };
}
function EI(e, t) {
  var n = Ew(e + "");
  if (arguments.length < 2) {
    for (var i = yp(this.node()), r = -1, s = n.length; ++r < s; )
      if (!i.contains(n[r]))
        return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? TI : t ? $I : II)(n, t));
}
function NI() {
  this.textContent = "";
}
function OI(e) {
  return function() {
    this.textContent = e;
  };
}
function FI(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function DI(e) {
  return arguments.length ? this.each(e == null ? NI : (typeof e == "function" ? FI : OI)(e)) : this.node().textContent;
}
function BI() {
  this.innerHTML = "";
}
function LI(e) {
  return function() {
    this.innerHTML = e;
  };
}
function CI(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function kI(e) {
  return arguments.length ? this.each(e == null ? BI : (typeof e == "function" ? CI : LI)(e)) : this.node().innerHTML;
}
function RI() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function UI() {
  return this.each(RI);
}
function zI() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function PI() {
  return this.each(zI);
}
function YI(e) {
  var t = typeof e == "function" ? e : rf(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function qI() {
  return null;
}
function VI(e, t) {
  var n = typeof e == "function" ? e : rf(e), i = t == null ? qI : typeof t == "function" ? t : mp(t);
  return this.select(function() {
    return this.insertBefore(n.apply(this, arguments), i.apply(this, arguments) || null);
  });
}
function jI() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function XI() {
  return this.each(jI);
}
function WI() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function HI() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function GI(e) {
  return this.select(e ? HI : WI);
}
function ZI(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function KI(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function JI(e) {
  return e.trim().split(/^|\s+/).map(function(t) {
    var n = "", i = t.indexOf(".");
    return i >= 0 && (n = t.slice(i + 1), t = t.slice(0, i)), { type: t, name: n };
  });
}
function QI(e) {
  return function() {
    var t = this.__on;
    if (t) {
      for (var n = 0, i = -1, r = t.length, s; n < r; ++n)
        s = t[n], (!e.type || s.type === e.type) && s.name === e.name ? this.removeEventListener(s.type, s.listener, s.options) : t[++i] = s;
      ++i ? t.length = i : delete this.__on;
    }
  };
}
function tT(e, t, n) {
  return function() {
    var i = this.__on, r, s = KI(t);
    if (i) {
      for (var o = 0, a = i.length; o < a; ++o)
        if ((r = i[o]).type === e.type && r.name === e.name) {
          this.removeEventListener(r.type, r.listener, r.options), this.addEventListener(r.type, r.listener = s, r.options = n), r.value = t;
          return;
        }
    }
    this.addEventListener(e.type, s, n), r = { type: e.type, name: e.name, value: t, listener: s, options: n }, i ? i.push(r) : this.__on = [r];
  };
}
function eT(e, t, n) {
  var i = JI(e + ""), r, s = i.length, o;
  if (arguments.length < 2) {
    var a = this.node().__on;
    if (a) {
      for (var c = 0, u = a.length, l; c < u; ++c)
        for (r = 0, l = a[c]; r < s; ++r)
          if ((o = i[r]).type === l.type && o.name === l.name)
            return l.value;
    }
    return;
  }
  for (a = t ? tT : QI, r = 0; r < s; ++r)
    this.each(a(i[r], t, n));
  return this;
}
function Dw(e, t, n) {
  var i = Tw(e), r = i.CustomEvent;
  typeof r == "function" ? r = new r(t, n) : (r = i.document.createEvent("Event"), n ? (r.initEvent(t, n.bubbles, n.cancelable), r.detail = n.detail) : r.initEvent(t, !1, !1)), e.dispatchEvent(r);
}
function nT(e, t) {
  return function() {
    return Dw(this, e, t);
  };
}
function iT(e, t) {
  return function() {
    return Dw(this, e, t.apply(this, arguments));
  };
}
function rT(e, t) {
  return this.each((typeof t == "function" ? iT : nT)(e, t));
}
function* sT() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var i = e[t], r = 0, s = i.length, o; r < s; ++r)
      (o = i[r]) && (yield o);
}
var Bw = [null];
function Xe(e, t) {
  this._groups = e, this._parents = t;
}
function Za() {
  return new Xe([[document.documentElement]], Bw);
}
function oT() {
  return this;
}
Xe.prototype = Za.prototype = {
  constructor: Xe,
  select: F7,
  selectAll: C7,
  selectChild: z7,
  selectChildren: V7,
  filter: j7,
  data: K7,
  enter: X7,
  exit: Q7,
  join: tI,
  merge: eI,
  selection: oT,
  order: nI,
  sort: iI,
  call: sI,
  nodes: oI,
  node: aI,
  size: cI,
  empty: uI,
  each: lI,
  attr: gI,
  style: vI,
  property: AI,
  classed: EI,
  text: DI,
  html: kI,
  raise: UI,
  lower: PI,
  append: YI,
  insert: VI,
  remove: XI,
  clone: GI,
  datum: ZI,
  on: eT,
  dispatch: rT,
  [Symbol.iterator]: sT
};
function zt(e) {
  return typeof e == "string" ? new Xe([[document.querySelector(e)]], [document.documentElement]) : new Xe([[e]], Bw);
}
function aT(e) {
  return zt(rf(e).call(document.documentElement));
}
function cT(e) {
  let t;
  for (; t = e.sourceEvent; )
    e = t;
  return e;
}
function kn(e, t) {
  if (e = cT(e), t === void 0 && (t = e.currentTarget), t) {
    var n = t.ownerSVGElement || t;
    if (n.createSVGPoint) {
      var i = n.createSVGPoint();
      return i.x = e.clientX, i.y = e.clientY, i = i.matrixTransform(t.getScreenCTM().inverse()), [i.x, i.y];
    }
    if (t.getBoundingClientRect) {
      var r = t.getBoundingClientRect();
      return [e.clientX - r.left - t.clientLeft, e.clientY - r.top - t.clientTop];
    }
  }
  return [e.pageX, e.pageY];
}
const Ed = { capture: !0, passive: !1 };
function Nd(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function Lw(e) {
  var t = e.document.documentElement, n = zt(e).on("dragstart.drag", Nd, Ed);
  "onselectstart" in t ? n.on("selectstart.drag", Nd, Ed) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function Cw(e, t) {
  var n = e.document.documentElement, i = zt(e).on("dragstart.drag", null);
  t && (i.on("click.drag", Nd, Ed), setTimeout(function() {
    i.on("click.drag", null);
  }, 0)), "onselectstart" in n ? i.on("selectstart.drag", null) : (n.style.MozUserSelect = n.__noselect, delete n.__noselect);
}
function $o(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function Ka(e, t) {
  var n = Object.create(e.prototype);
  for (var i in t)
    n[i] = t[i];
  return n;
}
function pr() {
}
var Kr = 0.7, uo = 1 / Kr, Ys = "\\s*([+-]?\\d+)\\s*", Aa = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", Zn = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", uT = /^#([0-9a-f]{3,8})$/, lT = new RegExp(`^rgb\\(${Ys},${Ys},${Ys}\\)$`), fT = new RegExp(`^rgb\\(${Zn},${Zn},${Zn}\\)$`), hT = new RegExp(`^rgba\\(${Ys},${Ys},${Ys},${Aa}\\)$`), dT = new RegExp(`^rgba\\(${Zn},${Zn},${Zn},${Aa}\\)$`), pT = new RegExp(`^hsl\\(${Aa},${Zn},${Zn}\\)$`), mT = new RegExp(`^hsla\\(${Aa},${Zn},${Zn},${Aa}\\)$`), Ly = {
  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
};
$o(pr, Li, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: Cy,
  // Deprecated! Use color.formatHex.
  formatHex: Cy,
  formatHex8: yT,
  formatHsl: gT,
  formatRgb: ky,
  toString: ky
});
function Cy() {
  return this.rgb().formatHex();
}
function yT() {
  return this.rgb().formatHex8();
}
function gT() {
  return kw(this).formatHsl();
}
function ky() {
  return this.rgb().formatRgb();
}
function Li(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = uT.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? Ry(t) : n === 3 ? new fe(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? vc(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? vc(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = lT.exec(e)) ? new fe(t[1], t[2], t[3], 1) : (t = fT.exec(e)) ? new fe(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = hT.exec(e)) ? vc(t[1], t[2], t[3], t[4]) : (t = dT.exec(e)) ? vc(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = pT.exec(e)) ? Py(t[1], t[2] / 100, t[3] / 100, 1) : (t = mT.exec(e)) ? Py(t[1], t[2] / 100, t[3] / 100, t[4]) : Ly.hasOwnProperty(e) ? Ry(Ly[e]) : e === "transparent" ? new fe(NaN, NaN, NaN, 0) : null;
}
function Ry(e) {
  return new fe(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function vc(e, t, n, i) {
  return i <= 0 && (e = t = n = NaN), new fe(e, t, n, i);
}
function gp(e) {
  return e instanceof pr || (e = Li(e)), e ? (e = e.rgb(), new fe(e.r, e.g, e.b, e.opacity)) : new fe();
}
function pn(e, t, n, i) {
  return arguments.length === 1 ? gp(e) : new fe(e, t, n, i ?? 1);
}
function fe(e, t, n, i) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +i;
}
$o(fe, pn, Ka(pr, {
  brighter(e) {
    return e = e == null ? uo : Math.pow(uo, e), new fe(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Kr : Math.pow(Kr, e), new fe(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new fe(Vr(this.r), Vr(this.g), Vr(this.b), qu(this.opacity));
  },
  displayable() {
    return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
  },
  hex: Uy,
  // Deprecated! Use color.formatHex.
  formatHex: Uy,
  formatHex8: bT,
  formatRgb: zy,
  toString: zy
}));
function Uy() {
  return `#${zr(this.r)}${zr(this.g)}${zr(this.b)}`;
}
function bT() {
  return `#${zr(this.r)}${zr(this.g)}${zr(this.b)}${zr((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function zy() {
  const e = qu(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${Vr(this.r)}, ${Vr(this.g)}, ${Vr(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function qu(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function Vr(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function zr(e) {
  return e = Vr(e), (e < 16 ? "0" : "") + e.toString(16);
}
function Py(e, t, n, i) {
  return i <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new _n(e, t, n, i);
}
function kw(e) {
  if (e instanceof _n)
    return new _n(e.h, e.s, e.l, e.opacity);
  if (e instanceof pr || (e = Li(e)), !e)
    return new _n();
  if (e instanceof _n)
    return e;
  e = e.rgb();
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = Math.min(t, n, i), s = Math.max(t, n, i), o = NaN, a = s - r, c = (s + r) / 2;
  return a ? (t === s ? o = (n - i) / a + (n < i) * 6 : n === s ? o = (i - t) / a + 2 : o = (t - n) / a + 4, a /= c < 0.5 ? s + r : 2 - s - r, o *= 60) : a = c > 0 && c < 1 ? 0 : o, new _n(o, a, c, e.opacity);
}
function Od(e, t, n, i) {
  return arguments.length === 1 ? kw(e) : new _n(e, t, n, i ?? 1);
}
function _n(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
$o(_n, Od, Ka(pr, {
  brighter(e) {
    return e = e == null ? uo : Math.pow(uo, e), new _n(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Kr : Math.pow(Kr, e), new _n(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, i = n + (n < 0.5 ? n : 1 - n) * t, r = 2 * n - i;
    return new fe(
      gh(e >= 240 ? e - 240 : e + 120, r, i),
      gh(e, r, i),
      gh(e < 120 ? e + 240 : e - 120, r, i),
      this.opacity
    );
  },
  clamp() {
    return new _n(Yy(this.h), xc(this.s), xc(this.l), qu(this.opacity));
  },
  displayable() {
    return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
  },
  formatHsl() {
    const e = qu(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${Yy(this.h)}, ${xc(this.s) * 100}%, ${xc(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function Yy(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function xc(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function gh(e, t, n) {
  return (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) * 255;
}
const Rw = Math.PI / 180, Uw = 180 / Math.PI, Vu = 18, zw = 0.96422, Pw = 1, Yw = 0.82521, qw = 4 / 29, qs = 6 / 29, Vw = 3 * qs * qs, wT = qs * qs * qs;
function jw(e) {
  if (e instanceof Kn)
    return new Kn(e.l, e.a, e.b, e.opacity);
  if (e instanceof Ai)
    return Xw(e);
  e instanceof fe || (e = gp(e));
  var t = vh(e.r), n = vh(e.g), i = vh(e.b), r = bh((0.2225045 * t + 0.7168786 * n + 0.0606169 * i) / Pw), s, o;
  return t === n && n === i ? s = o = r : (s = bh((0.4360747 * t + 0.3850649 * n + 0.1430804 * i) / zw), o = bh((0.0139322 * t + 0.0971045 * n + 0.7141733 * i) / Yw)), new Kn(116 * r - 16, 500 * (s - r), 200 * (r - o), e.opacity);
}
function Fd(e, t, n, i) {
  return arguments.length === 1 ? jw(e) : new Kn(e, t, n, i ?? 1);
}
function Kn(e, t, n, i) {
  this.l = +e, this.a = +t, this.b = +n, this.opacity = +i;
}
$o(Kn, Fd, Ka(pr, {
  brighter(e) {
    return new Kn(this.l + Vu * (e ?? 1), this.a, this.b, this.opacity);
  },
  darker(e) {
    return new Kn(this.l - Vu * (e ?? 1), this.a, this.b, this.opacity);
  },
  rgb() {
    var e = (this.l + 16) / 116, t = isNaN(this.a) ? e : e + this.a / 500, n = isNaN(this.b) ? e : e - this.b / 200;
    return t = zw * wh(t), e = Pw * wh(e), n = Yw * wh(n), new fe(
      _h(3.1338561 * t - 1.6168667 * e - 0.4906146 * n),
      _h(-0.9787684 * t + 1.9161415 * e + 0.033454 * n),
      _h(0.0719453 * t - 0.2289914 * e + 1.4052427 * n),
      this.opacity
    );
  }
}));
function bh(e) {
  return e > wT ? Math.pow(e, 1 / 3) : e / Vw + qw;
}
function wh(e) {
  return e > qs ? e * e * e : Vw * (e - qw);
}
function _h(e) {
  return 255 * (e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055);
}
function vh(e) {
  return (e /= 255) <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function _T(e) {
  if (e instanceof Ai)
    return new Ai(e.h, e.c, e.l, e.opacity);
  if (e instanceof Kn || (e = jw(e)), e.a === 0 && e.b === 0)
    return new Ai(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
  var t = Math.atan2(e.b, e.a) * Uw;
  return new Ai(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function Dd(e, t, n, i) {
  return arguments.length === 1 ? _T(e) : new Ai(e, t, n, i ?? 1);
}
function Ai(e, t, n, i) {
  this.h = +e, this.c = +t, this.l = +n, this.opacity = +i;
}
function Xw(e) {
  if (isNaN(e.h))
    return new Kn(e.l, 0, 0, e.opacity);
  var t = e.h * Rw;
  return new Kn(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
$o(Ai, Dd, Ka(pr, {
  brighter(e) {
    return new Ai(this.h, this.c, this.l + Vu * (e ?? 1), this.opacity);
  },
  darker(e) {
    return new Ai(this.h, this.c, this.l - Vu * (e ?? 1), this.opacity);
  },
  rgb() {
    return Xw(this).rgb();
  }
}));
var Ww = -0.14861, bp = 1.78277, wp = -0.29227, sf = -0.90649, $a = 1.97294, qy = $a * sf, Vy = $a * bp, jy = bp * wp - sf * Ww;
function vT(e) {
  if (e instanceof jr)
    return new jr(e.h, e.s, e.l, e.opacity);
  e instanceof fe || (e = gp(e));
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = (jy * i + qy * t - Vy * n) / (jy + qy - Vy), s = i - r, o = ($a * (n - r) - wp * s) / sf, a = Math.sqrt(o * o + s * s) / ($a * r * (1 - r)), c = a ? Math.atan2(o, s) * Uw - 120 : NaN;
  return new jr(c < 0 ? c + 360 : c, a, r, e.opacity);
}
function ei(e, t, n, i) {
  return arguments.length === 1 ? vT(e) : new jr(e, t, n, i ?? 1);
}
function jr(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
$o(jr, ei, Ka(pr, {
  brighter(e) {
    return e = e == null ? uo : Math.pow(uo, e), new jr(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Kr : Math.pow(Kr, e), new jr(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = isNaN(this.h) ? 0 : (this.h + 120) * Rw, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), i = Math.cos(e), r = Math.sin(e);
    return new fe(
      255 * (t + n * (Ww * i + bp * r)),
      255 * (t + n * (wp * i + sf * r)),
      255 * (t + n * ($a * i)),
      this.opacity
    );
  }
}));
function xT(e, t, n, i, r) {
  var s = e * e, o = s * e;
  return ((1 - 3 * e + 3 * s - o) * t + (4 - 6 * s + 3 * o) * n + (1 + 3 * e + 3 * s - 3 * o) * i + o * r) / 6;
}
function ST(e) {
  var t = e.length - 1;
  return function(n) {
    var i = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), r = e[i], s = e[i + 1], o = i > 0 ? e[i - 1] : 2 * r - s, a = i < t - 1 ? e[i + 2] : 2 * s - r;
    return xT((n - i / t) * t, o, r, s, a);
  };
}
const of = (e) => () => e;
function Hw(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function MT(e, t, n) {
  return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function(i) {
    return Math.pow(e + i * t, n);
  };
}
function _p(e, t) {
  var n = t - e;
  return n ? Hw(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : of(isNaN(e) ? t : e);
}
function AT(e) {
  return (e = +e) == 1 ? xe : function(t, n) {
    return n - t ? MT(t, n, e) : of(isNaN(t) ? n : t);
  };
}
function xe(e, t) {
  var n = t - e;
  return n ? Hw(e, n) : of(isNaN(e) ? t : e);
}
const Jr = function e(t) {
  var n = AT(t);
  function i(r, s) {
    var o = n((r = pn(r)).r, (s = pn(s)).r), a = n(r.g, s.g), c = n(r.b, s.b), u = xe(r.opacity, s.opacity);
    return function(l) {
      return r.r = o(l), r.g = a(l), r.b = c(l), r.opacity = u(l), r + "";
    };
  }
  return i.gamma = e, i;
}(1);
function $T(e) {
  return function(t) {
    var n = t.length, i = new Array(n), r = new Array(n), s = new Array(n), o, a;
    for (o = 0; o < n; ++o)
      a = pn(t[o]), i[o] = a.r || 0, r[o] = a.g || 0, s[o] = a.b || 0;
    return i = e(i), r = e(r), s = e(s), a.opacity = 1, function(c) {
      return a.r = i(c), a.g = r(c), a.b = s(c), a + "";
    };
  };
}
var IT = $T(ST);
function TT(e, t) {
  t || (t = []);
  var n = e ? Math.min(t.length, e.length) : 0, i = t.slice(), r;
  return function(s) {
    for (r = 0; r < n; ++r)
      i[r] = e[r] * (1 - s) + t[r] * s;
    return i;
  };
}
function ET(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function NT(e, t) {
  var n = t ? t.length : 0, i = e ? Math.min(n, e.length) : 0, r = new Array(i), s = new Array(n), o;
  for (o = 0; o < i; ++o)
    r[o] = Io(e[o], t[o]);
  for (; o < n; ++o)
    s[o] = t[o];
  return function(a) {
    for (o = 0; o < i; ++o)
      s[o] = r[o](a);
    return s;
  };
}
function OT(e, t) {
  var n = new Date();
  return e = +e, t = +t, function(i) {
    return n.setTime(e * (1 - i) + t * i), n;
  };
}
function ve(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function FT(e, t) {
  var n = {}, i = {}, r;
  (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
  for (r in t)
    r in e ? n[r] = Io(e[r], t[r]) : i[r] = t[r];
  return function(s) {
    for (r in n)
      i[r] = n[r](s);
    return i;
  };
}
var Bd = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, xh = new RegExp(Bd.source, "g");
function DT(e) {
  return function() {
    return e;
  };
}
function BT(e) {
  return function(t) {
    return e(t) + "";
  };
}
function Gw(e, t) {
  var n = Bd.lastIndex = xh.lastIndex = 0, i, r, s, o = -1, a = [], c = [];
  for (e = e + "", t = t + ""; (i = Bd.exec(e)) && (r = xh.exec(t)); )
    (s = r.index) > n && (s = t.slice(n, s), a[o] ? a[o] += s : a[++o] = s), (i = i[0]) === (r = r[0]) ? a[o] ? a[o] += r : a[++o] = r : (a[++o] = null, c.push({ i: o, x: ve(i, r) })), n = xh.lastIndex;
  return n < t.length && (s = t.slice(n), a[o] ? a[o] += s : a[++o] = s), a.length < 2 ? c[0] ? BT(c[0].x) : DT(t) : (t = c.length, function(u) {
    for (var l = 0, f; l < t; ++l)
      a[(f = c[l]).i] = f.x(u);
    return a.join("");
  });
}
function Io(e, t) {
  var n = typeof t, i;
  return t == null || n === "boolean" ? of(t) : (n === "number" ? ve : n === "string" ? (i = Li(t)) ? (t = i, Jr) : Gw : t instanceof Li ? Jr : t instanceof Date ? OT : ET(t) ? TT : Array.isArray(t) ? NT : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? FT : ve)(e, t);
}
function vp(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
var Xy = 180 / Math.PI, Ld = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function Zw(e, t, n, i, r, s) {
  var o, a, c;
  return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (c = e * n + t * i) && (n -= e * c, i -= t * c), (a = Math.sqrt(n * n + i * i)) && (n /= a, i /= a, c /= a), e * i < t * n && (e = -e, t = -t, c = -c, o = -o), {
    translateX: r,
    translateY: s,
    rotate: Math.atan2(t, e) * Xy,
    skewX: Math.atan(c) * Xy,
    scaleX: o,
    scaleY: a
  };
}
var Sc;
function LT(e) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
  return t.isIdentity ? Ld : Zw(t.a, t.b, t.c, t.d, t.e, t.f);
}
function CT(e) {
  return e == null || (Sc || (Sc = document.createElementNS("http://www.w3.org/2000/svg", "g")), Sc.setAttribute("transform", e), !(e = Sc.transform.baseVal.consolidate())) ? Ld : (e = e.matrix, Zw(e.a, e.b, e.c, e.d, e.e, e.f));
}
function Kw(e, t, n, i) {
  function r(u) {
    return u.length ? u.pop() + " " : "";
  }
  function s(u, l, f, h, d, p) {
    if (u !== f || l !== h) {
      var g = d.push("translate(", null, t, null, n);
      p.push({ i: g - 4, x: ve(u, f) }, { i: g - 2, x: ve(l, h) });
    } else
      (f || h) && d.push("translate(" + f + t + h + n);
  }
  function o(u, l, f, h) {
    u !== l ? (u - l > 180 ? l += 360 : l - u > 180 && (u += 360), h.push({ i: f.push(r(f) + "rotate(", null, i) - 2, x: ve(u, l) })) : l && f.push(r(f) + "rotate(" + l + i);
  }
  function a(u, l, f, h) {
    u !== l ? h.push({ i: f.push(r(f) + "skewX(", null, i) - 2, x: ve(u, l) }) : l && f.push(r(f) + "skewX(" + l + i);
  }
  function c(u, l, f, h, d, p) {
    if (u !== f || l !== h) {
      var g = d.push(r(d) + "scale(", null, ",", null, ")");
      p.push({ i: g - 4, x: ve(u, f) }, { i: g - 2, x: ve(l, h) });
    } else
      (f !== 1 || h !== 1) && d.push(r(d) + "scale(" + f + "," + h + ")");
  }
  return function(u, l) {
    var f = [], h = [];
    return u = e(u), l = e(l), s(u.translateX, u.translateY, l.translateX, l.translateY, f, h), o(u.rotate, l.rotate, f, h), a(u.skewX, l.skewX, f, h), c(u.scaleX, u.scaleY, l.scaleX, l.scaleY, f, h), u = l = null, function(d) {
      for (var p = -1, g = h.length, y; ++p < g; )
        f[(y = h[p]).i] = y.x(d);
      return f.join("");
    };
  };
}
var kT = Kw(LT, "px, ", "px)", "deg)"), RT = Kw(CT, ", ", ")", ")"), UT = 1e-12;
function Wy(e) {
  return ((e = Math.exp(e)) + 1 / e) / 2;
}
function zT(e) {
  return ((e = Math.exp(e)) - 1 / e) / 2;
}
function PT(e) {
  return ((e = Math.exp(2 * e)) - 1) / (e + 1);
}
const YT = function e(t, n, i) {
  function r(s, o) {
    var a = s[0], c = s[1], u = s[2], l = o[0], f = o[1], h = o[2], d = l - a, p = f - c, g = d * d + p * p, y, m;
    if (g < UT)
      m = Math.log(h / u) / t, y = function(I) {
        return [
          a + I * d,
          c + I * p,
          u * Math.exp(t * I * m)
        ];
      };
    else {
      var b = Math.sqrt(g), w = (h * h - u * u + i * g) / (2 * u * n * b), _ = (h * h - u * u - i * g) / (2 * h * n * b), x = Math.log(Math.sqrt(w * w + 1) - w), S = Math.log(Math.sqrt(_ * _ + 1) - _);
      m = (S - x) / t, y = function(I) {
        var N = I * m, F = Wy(x), $ = u / (n * b) * (F * PT(t * N + x) - zT(x));
        return [
          a + $ * d,
          c + $ * p,
          u * F / Wy(t * N + x)
        ];
      };
    }
    return y.duration = m * 1e3 * t / Math.SQRT2, y;
  }
  return r.rho = function(s) {
    var o = Math.max(1e-3, +s), a = o * o, c = a * a;
    return e(o, a, c);
  }, r;
}(Math.SQRT2, 2, 4);
function qT(e) {
  return function(t, n) {
    var i = e((t = Od(t)).h, (n = Od(n)).h), r = xe(t.s, n.s), s = xe(t.l, n.l), o = xe(t.opacity, n.opacity);
    return function(a) {
      return t.h = i(a), t.s = r(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const VT = qT(_p);
function jT(e, t) {
  var n = xe((e = Fd(e)).l, (t = Fd(t)).l), i = xe(e.a, t.a), r = xe(e.b, t.b), s = xe(e.opacity, t.opacity);
  return function(o) {
    return e.l = n(o), e.a = i(o), e.b = r(o), e.opacity = s(o), e + "";
  };
}
function XT(e) {
  return function(t, n) {
    var i = e((t = Dd(t)).h, (n = Dd(n)).h), r = xe(t.c, n.c), s = xe(t.l, n.l), o = xe(t.opacity, n.opacity);
    return function(a) {
      return t.h = i(a), t.c = r(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const WT = XT(_p);
function Jw(e) {
  return function t(n) {
    n = +n;
    function i(r, s) {
      var o = e((r = ei(r)).h, (s = ei(s)).h), a = xe(r.s, s.s), c = xe(r.l, s.l), u = xe(r.opacity, s.opacity);
      return function(l) {
        return r.h = o(l), r.s = a(l), r.l = c(Math.pow(l, n)), r.opacity = u(l), r + "";
      };
    }
    return i.gamma = t, i;
  }(1);
}
Jw(_p);
var xp = Jw(xe);
function Sp(e, t) {
  t === void 0 && (t = e, e = Io);
  for (var n = 0, i = t.length - 1, r = t[0], s = new Array(i < 0 ? 0 : i); n < i; )
    s[n] = e(r, r = t[++n]);
  return function(o) {
    var a = Math.max(0, Math.min(i - 1, Math.floor(o *= i)));
    return s[a](o - a);
  };
}
function Tn(e, t) {
  for (var n = new Array(t), i = 0; i < t; ++i)
    n[i] = e(i / (t - 1));
  return n;
}
var lo = 0, Jo = 0, Yo = 0, Qw = 1e3, ju, Qo, Xu = 0, Qr = 0, af = 0, Ia = typeof performance == "object" && performance.now ? performance : Date, t_ = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
  setTimeout(e, 17);
};
function Mp() {
  return Qr || (t_(HT), Qr = Ia.now() + af);
}
function HT() {
  Qr = 0;
}
function Wu() {
  this._call = this._time = this._next = null;
}
Wu.prototype = e_.prototype = {
  constructor: Wu,
  restart: function(e, t, n) {
    if (typeof e != "function")
      throw new TypeError("callback is not a function");
    n = (n == null ? Mp() : +n) + (t == null ? 0 : +t), !this._next && Qo !== this && (Qo ? Qo._next = this : ju = this, Qo = this), this._call = e, this._time = n, Cd();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, Cd());
  }
};
function e_(e, t, n) {
  var i = new Wu();
  return i.restart(e, t, n), i;
}
function GT() {
  Mp(), ++lo;
  for (var e = ju, t; e; )
    (t = Qr - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
  --lo;
}
function Hy() {
  Qr = (Xu = Ia.now()) + af, lo = Jo = 0;
  try {
    GT();
  } finally {
    lo = 0, KT(), Qr = 0;
  }
}
function ZT() {
  var e = Ia.now(), t = e - Xu;
  t > Qw && (af -= t, Xu = e);
}
function KT() {
  for (var e, t = ju, n, i = 1 / 0; t; )
    t._call ? (i > t._time && (i = t._time), e = t, t = t._next) : (n = t._next, t._next = null, t = e ? e._next = n : ju = n);
  Qo = e, Cd(i);
}
function Cd(e) {
  if (!lo) {
    Jo && (Jo = clearTimeout(Jo));
    var t = e - Qr;
    t > 24 ? (e < 1 / 0 && (Jo = setTimeout(Hy, e - Ia.now() - af)), Yo && (Yo = clearInterval(Yo))) : (Yo || (Xu = Ia.now(), Yo = setInterval(ZT, Qw)), lo = 1, t_(Hy));
  }
}
function Gy(e, t, n) {
  var i = new Wu();
  return t = t == null ? 0 : +t, i.restart((r) => {
    i.stop(), e(r + t);
  }, t, n), i;
}
var JT = ef("start", "end", "cancel", "interrupt"), QT = [], n_ = 0, Zy = 1, kd = 2, eu = 3, Ky = 4, Rd = 5, nu = 6;
function cf(e, t, n, i, r, s) {
  var o = e.__transition;
  if (!o)
    e.__transition = {};
  else if (n in o)
    return;
  t9(e, n, {
    name: t,
    index: i,
    // For context during callback.
    group: r,
    // For context during callback.
    on: JT,
    tween: QT,
    time: s.time,
    delay: s.delay,
    duration: s.duration,
    ease: s.ease,
    timer: null,
    state: n_
  });
}
function Ap(e, t) {
  var n = On(e, t);
  if (n.state > n_)
    throw new Error("too late; already scheduled");
  return n;
}
function si(e, t) {
  var n = On(e, t);
  if (n.state > eu)
    throw new Error("too late; already running");
  return n;
}
function On(e, t) {
  var n = e.__transition;
  if (!n || !(n = n[t]))
    throw new Error("transition not found");
  return n;
}
function t9(e, t, n) {
  var i = e.__transition, r;
  i[t] = n, n.timer = e_(s, 0, n.time);
  function s(u) {
    n.state = Zy, n.timer.restart(o, n.delay, n.time), n.delay <= u && o(u - n.delay);
  }
  function o(u) {
    var l, f, h, d;
    if (n.state !== Zy)
      return c();
    for (l in i)
      if (d = i[l], d.name === n.name) {
        if (d.state === eu)
          return Gy(o);
        d.state === Ky ? (d.state = nu, d.timer.stop(), d.on.call("interrupt", e, e.__data__, d.index, d.group), delete i[l]) : +l < t && (d.state = nu, d.timer.stop(), d.on.call("cancel", e, e.__data__, d.index, d.group), delete i[l]);
      }
    if (Gy(function() {
      n.state === eu && (n.state = Ky, n.timer.restart(a, n.delay, n.time), a(u));
    }), n.state = kd, n.on.call("start", e, e.__data__, n.index, n.group), n.state === kd) {
      for (n.state = eu, r = new Array(h = n.tween.length), l = 0, f = -1; l < h; ++l)
        (d = n.tween[l].value.call(e, e.__data__, n.index, n.group)) && (r[++f] = d);
      r.length = f + 1;
    }
  }
  function a(u) {
    for (var l = u < n.duration ? n.ease.call(null, u / n.duration) : (n.timer.restart(c), n.state = Rd, 1), f = -1, h = r.length; ++f < h; )
      r[f].call(e, l);
    n.state === Rd && (n.on.call("end", e, e.__data__, n.index, n.group), c());
  }
  function c() {
    n.state = nu, n.timer.stop(), delete i[t];
    for (var u in i)
      return;
    delete e.__transition;
  }
}
function Vs(e, t) {
  var n = e.__transition, i, r, s = !0, o;
  if (n) {
    t = t == null ? null : t + "";
    for (o in n) {
      if ((i = n[o]).name !== t) {
        s = !1;
        continue;
      }
      r = i.state > kd && i.state < Rd, i.state = nu, i.timer.stop(), i.on.call(r ? "interrupt" : "cancel", e, e.__data__, i.index, i.group), delete n[o];
    }
    s && delete e.__transition;
  }
}
function e9(e) {
  return this.each(function() {
    Vs(this, e);
  });
}
function n9(e, t) {
  var n, i;
  return function() {
    var r = si(this, e), s = r.tween;
    if (s !== n) {
      i = n = s;
      for (var o = 0, a = i.length; o < a; ++o)
        if (i[o].name === t) {
          i = i.slice(), i.splice(o, 1);
          break;
        }
    }
    r.tween = i;
  };
}
function i9(e, t, n) {
  var i, r;
  if (typeof n != "function")
    throw new Error();
  return function() {
    var s = si(this, e), o = s.tween;
    if (o !== i) {
      r = (i = o).slice();
      for (var a = { name: t, value: n }, c = 0, u = r.length; c < u; ++c)
        if (r[c].name === t) {
          r[c] = a;
          break;
        }
      c === u && r.push(a);
    }
    s.tween = r;
  };
}
function r9(e, t) {
  var n = this._id;
  if (e += "", arguments.length < 2) {
    for (var i = On(this.node(), n).tween, r = 0, s = i.length, o; r < s; ++r)
      if ((o = i[r]).name === e)
        return o.value;
    return null;
  }
  return this.each((t == null ? n9 : i9)(n, e, t));
}
function $p(e, t, n) {
  var i = e._id;
  return e.each(function() {
    var r = si(this, i);
    (r.value || (r.value = {}))[t] = n.apply(this, arguments);
  }), function(r) {
    return On(r, i).value[t];
  };
}
function i_(e, t) {
  var n;
  return (typeof t == "number" ? ve : t instanceof Li ? Jr : (n = Li(t)) ? (t = n, Jr) : Gw)(e, t);
}
function s9(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function o9(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function a9(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = this.getAttribute(e);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function c9(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = this.getAttributeNS(e.space, e.local);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function u9(e, t, n) {
  var i, r, s;
  return function() {
    var o, a = n(this), c;
    return a == null ? void this.removeAttribute(e) : (o = this.getAttribute(e), c = a + "", o === c ? null : o === i && c === r ? s : (r = c, s = t(i = o, a)));
  };
}
function l9(e, t, n) {
  var i, r, s;
  return function() {
    var o, a = n(this), c;
    return a == null ? void this.removeAttributeNS(e.space, e.local) : (o = this.getAttributeNS(e.space, e.local), c = a + "", o === c ? null : o === i && c === r ? s : (r = c, s = t(i = o, a)));
  };
}
function f9(e, t) {
  var n = nf(e), i = n === "transform" ? RT : i_;
  return this.attrTween(e, typeof t == "function" ? (n.local ? l9 : u9)(n, i, $p(this, "attr." + e, t)) : t == null ? (n.local ? o9 : s9)(n) : (n.local ? c9 : a9)(n, i, t));
}
function h9(e, t) {
  return function(n) {
    this.setAttribute(e, t.call(this, n));
  };
}
function d9(e, t) {
  return function(n) {
    this.setAttributeNS(e.space, e.local, t.call(this, n));
  };
}
function p9(e, t) {
  var n, i;
  function r() {
    var s = t.apply(this, arguments);
    return s !== i && (n = (i = s) && d9(e, s)), n;
  }
  return r._value = t, r;
}
function m9(e, t) {
  var n, i;
  function r() {
    var s = t.apply(this, arguments);
    return s !== i && (n = (i = s) && h9(e, s)), n;
  }
  return r._value = t, r;
}
function y9(e, t) {
  var n = "attr." + e;
  if (arguments.length < 2)
    return (n = this.tween(n)) && n._value;
  if (t == null)
    return this.tween(n, null);
  if (typeof t != "function")
    throw new Error();
  var i = nf(e);
  return this.tween(n, (i.local ? p9 : m9)(i, t));
}
function g9(e, t) {
  return function() {
    Ap(this, e).delay = +t.apply(this, arguments);
  };
}
function b9(e, t) {
  return t = +t, function() {
    Ap(this, e).delay = t;
  };
}
function w9(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? g9 : b9)(t, e)) : On(this.node(), t).delay;
}
function _9(e, t) {
  return function() {
    si(this, e).duration = +t.apply(this, arguments);
  };
}
function v9(e, t) {
  return t = +t, function() {
    si(this, e).duration = t;
  };
}
function x9(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? _9 : v9)(t, e)) : On(this.node(), t).duration;
}
function S9(e, t) {
  if (typeof t != "function")
    throw new Error();
  return function() {
    si(this, e).ease = t;
  };
}
function M9(e) {
  var t = this._id;
  return arguments.length ? this.each(S9(t, e)) : On(this.node(), t).ease;
}
function A9(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    if (typeof n != "function")
      throw new Error();
    si(this, e).ease = n;
  };
}
function $9(e) {
  if (typeof e != "function")
    throw new Error();
  return this.each(A9(this._id, e));
}
function I9(e) {
  typeof e != "function" && (e = Aw(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = [], c, u = 0; u < o; ++u)
      (c = s[u]) && e.call(c, c.__data__, u, s) && a.push(c);
  return new Ci(i, this._parents, this._name, this._id);
}
function T9(e) {
  if (e._id !== this._id)
    throw new Error();
  for (var t = this._groups, n = e._groups, i = t.length, r = n.length, s = Math.min(i, r), o = new Array(i), a = 0; a < s; ++a)
    for (var c = t[a], u = n[a], l = c.length, f = o[a] = new Array(l), h, d = 0; d < l; ++d)
      (h = c[d] || u[d]) && (f[d] = h);
  for (; a < i; ++a)
    o[a] = t[a];
  return new Ci(o, this._parents, this._name, this._id);
}
function E9(e) {
  return (e + "").trim().split(/^|\s+/).every(function(t) {
    var n = t.indexOf(".");
    return n >= 0 && (t = t.slice(0, n)), !t || t === "start";
  });
}
function N9(e, t, n) {
  var i, r, s = E9(t) ? Ap : si;
  return function() {
    var o = s(this, e), a = o.on;
    a !== i && (r = (i = a).copy()).on(t, n), o.on = r;
  };
}
function O9(e, t) {
  var n = this._id;
  return arguments.length < 2 ? On(this.node(), n).on.on(e) : this.each(N9(n, e, t));
}
function F9(e) {
  return function() {
    var t = this.parentNode;
    for (var n in this.__transition)
      if (+n !== e)
        return;
    t && t.removeChild(this);
  };
}
function D9() {
  return this.on("end.remove", F9(this._id));
}
function B9(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = mp(e));
  for (var i = this._groups, r = i.length, s = new Array(r), o = 0; o < r; ++o)
    for (var a = i[o], c = a.length, u = s[o] = new Array(c), l, f, h = 0; h < c; ++h)
      (l = a[h]) && (f = e.call(l, l.__data__, h, a)) && ("__data__" in l && (f.__data__ = l.__data__), u[h] = f, cf(u[h], t, n, h, u, On(l, n)));
  return new Ci(s, this._parents, t, n);
}
function L9(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = Mw(e));
  for (var i = this._groups, r = i.length, s = [], o = [], a = 0; a < r; ++a)
    for (var c = i[a], u = c.length, l, f = 0; f < u; ++f)
      if (l = c[f]) {
        for (var h = e.call(l, l.__data__, f, c), d, p = On(l, n), g = 0, y = h.length; g < y; ++g)
          (d = h[g]) && cf(d, t, n, g, h, p);
        s.push(h), o.push(l);
      }
  return new Ci(s, o, t, n);
}
var C9 = Za.prototype.constructor;
function k9() {
  return new C9(this._groups, this._parents);
}
function R9(e, t) {
  var n, i, r;
  return function() {
    var s = co(this, e), o = (this.style.removeProperty(e), co(this, e));
    return s === o ? null : s === n && o === i ? r : r = t(n = s, i = o);
  };
}
function r_(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function U9(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = co(this, e);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function z9(e, t, n) {
  var i, r, s;
  return function() {
    var o = co(this, e), a = n(this), c = a + "";
    return a == null && (c = a = (this.style.removeProperty(e), co(this, e))), o === c ? null : o === i && c === r ? s : (r = c, s = t(i = o, a));
  };
}
function P9(e, t) {
  var n, i, r, s = "style." + t, o = "end." + s, a;
  return function() {
    var c = si(this, e), u = c.on, l = c.value[s] == null ? a || (a = r_(t)) : void 0;
    (u !== n || r !== l) && (i = (n = u).copy()).on(o, r = l), c.on = i;
  };
}
function Y9(e, t, n) {
  var i = (e += "") == "transform" ? kT : i_;
  return t == null ? this.styleTween(e, R9(e, i)).on("end.style." + e, r_(e)) : typeof t == "function" ? this.styleTween(e, z9(e, i, $p(this, "style." + e, t))).each(P9(this._id, e)) : this.styleTween(e, U9(e, i, t), n).on("end.style." + e, null);
}
function q9(e, t, n) {
  return function(i) {
    this.style.setProperty(e, t.call(this, i), n);
  };
}
function V9(e, t, n) {
  var i, r;
  function s() {
    var o = t.apply(this, arguments);
    return o !== r && (i = (r = o) && q9(e, o, n)), i;
  }
  return s._value = t, s;
}
function j9(e, t, n) {
  var i = "style." + (e += "");
  if (arguments.length < 2)
    return (i = this.tween(i)) && i._value;
  if (t == null)
    return this.tween(i, null);
  if (typeof t != "function")
    throw new Error();
  return this.tween(i, V9(e, t, n ?? ""));
}
function X9(e) {
  return function() {
    this.textContent = e;
  };
}
function W9(e) {
  return function() {
    var t = e(this);
    this.textContent = t ?? "";
  };
}
function H9(e) {
  return this.tween("text", typeof e == "function" ? W9($p(this, "text", e)) : X9(e == null ? "" : e + ""));
}
function G9(e) {
  return function(t) {
    this.textContent = e.call(this, t);
  };
}
function Z9(e) {
  var t, n;
  function i() {
    var r = e.apply(this, arguments);
    return r !== n && (t = (n = r) && G9(r)), t;
  }
  return i._value = e, i;
}
function K9(e) {
  var t = "text";
  if (arguments.length < 1)
    return (t = this.tween(t)) && t._value;
  if (e == null)
    return this.tween(t, null);
  if (typeof e != "function")
    throw new Error();
  return this.tween(t, Z9(e));
}
function J9() {
  for (var e = this._name, t = this._id, n = s_(), i = this._groups, r = i.length, s = 0; s < r; ++s)
    for (var o = i[s], a = o.length, c, u = 0; u < a; ++u)
      if (c = o[u]) {
        var l = On(c, t);
        cf(c, e, n, u, o, {
          time: l.time + l.delay + l.duration,
          delay: 0,
          duration: l.duration,
          ease: l.ease
        });
      }
  return new Ci(i, this._parents, e, n);
}
function Q9() {
  var e, t, n = this, i = n._id, r = n.size();
  return new Promise(function(s, o) {
    var a = { value: o }, c = { value: function() {
      --r === 0 && s();
    } };
    n.each(function() {
      var u = si(this, i), l = u.on;
      l !== e && (t = (e = l).copy(), t._.cancel.push(a), t._.interrupt.push(a), t._.end.push(c)), u.on = t;
    }), r === 0 && s();
  });
}
var tE = 0;
function Ci(e, t, n, i) {
  this._groups = e, this._parents = t, this._name = n, this._id = i;
}
function s_() {
  return ++tE;
}
var ui = Za.prototype;
Ci.prototype = {
  constructor: Ci,
  select: B9,
  selectAll: L9,
  selectChild: ui.selectChild,
  selectChildren: ui.selectChildren,
  filter: I9,
  merge: T9,
  selection: k9,
  transition: J9,
  call: ui.call,
  nodes: ui.nodes,
  node: ui.node,
  size: ui.size,
  empty: ui.empty,
  each: ui.each,
  on: O9,
  attr: f9,
  attrTween: y9,
  style: Y9,
  styleTween: j9,
  text: H9,
  textTween: K9,
  remove: D9,
  tween: r9,
  delay: w9,
  duration: x9,
  ease: M9,
  easeVarying: $9,
  end: Q9,
  [Symbol.iterator]: ui[Symbol.iterator]
};
function eE(e) {
  return ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2;
}
var nE = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: eE
};
function iE(e, t) {
  for (var n; !(n = e.__transition) || !(n = n[t]); )
    if (!(e = e.parentNode))
      throw new Error(`transition ${t} not found`);
  return n;
}
function rE(e) {
  var t, n;
  e instanceof Ci ? (t = e._id, e = e._name) : (t = s_(), (n = nE).time = Mp(), e = e == null ? null : e + "");
  for (var i = this._groups, r = i.length, s = 0; s < r; ++s)
    for (var o = i[s], a = o.length, c, u = 0; u < a; ++u)
      (c = o[u]) && cf(c, e, t, u, o, n || iE(c, t));
  return new Ci(i, this._parents, e, t);
}
Za.prototype.interrupt = e9;
Za.prototype.transition = rE;
const Sh = (e) => () => e;
function sE(e, {
  sourceEvent: t,
  target: n,
  selection: i,
  mode: r,
  dispatch: s
}) {
  Object.defineProperties(this, {
    type: { value: e, enumerable: !0, configurable: !0 },
    sourceEvent: { value: t, enumerable: !0, configurable: !0 },
    target: { value: n, enumerable: !0, configurable: !0 },
    selection: { value: i, enumerable: !0, configurable: !0 },
    mode: { value: r, enumerable: !0, configurable: !0 },
    _: { value: s }
  });
}
function oE(e) {
  e.stopImmediatePropagation();
}
function Mh(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
var Jy = { name: "drag" }, Ah = { name: "space" }, ds = { name: "handle" }, ps = { name: "center" };
const { abs: Qy, max: be, min: we } = Math;
function tg(e) {
  return [+e[0], +e[1]];
}
function Ud(e) {
  return [tg(e[0]), tg(e[1])];
}
var iu = {
  name: "x",
  handles: ["w", "e"].map(Ta),
  input: function(e, t) {
    return e == null ? null : [[+e[0], t[0][1]], [+e[1], t[1][1]]];
  },
  output: function(e) {
    return e && [e[0][0], e[1][0]];
  }
}, ru = {
  name: "y",
  handles: ["n", "s"].map(Ta),
  input: function(e, t) {
    return e == null ? null : [[t[0][0], +e[0]], [t[1][0], +e[1]]];
  },
  output: function(e) {
    return e && [e[0][1], e[1][1]];
  }
}, aE = {
  name: "xy",
  handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(Ta),
  input: function(e) {
    return e == null ? null : Ud(e);
  },
  output: function(e) {
    return e;
  }
}, li = {
  overlay: "crosshair",
  selection: "move",
  n: "ns-resize",
  e: "ew-resize",
  s: "ns-resize",
  w: "ew-resize",
  nw: "nwse-resize",
  ne: "nesw-resize",
  se: "nwse-resize",
  sw: "nesw-resize"
}, eg = {
  e: "w",
  w: "e",
  nw: "ne",
  ne: "nw",
  se: "sw",
  sw: "se"
}, ng = {
  n: "s",
  s: "n",
  nw: "sw",
  ne: "se",
  se: "ne",
  sw: "nw"
}, cE = {
  overlay: 1,
  selection: 1,
  n: null,
  e: 1,
  s: null,
  w: -1,
  nw: -1,
  ne: 1,
  se: 1,
  sw: -1
}, uE = {
  overlay: 1,
  selection: 1,
  n: -1,
  e: null,
  s: 1,
  w: null,
  nw: -1,
  ne: -1,
  se: 1,
  sw: 1
};
function Ta(e) {
  return { type: e };
}
function lE(e) {
  return !e.ctrlKey && !e.button;
}
function fE() {
  var e = this.ownerSVGElement || this;
  return e.hasAttribute("viewBox") ? (e = e.viewBox.baseVal, [[e.x, e.y], [e.x + e.width, e.y + e.height]]) : [[0, 0], [e.width.baseVal.value, e.height.baseVal.value]];
}
function hE() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function $h(e) {
  for (; !e.__brush; )
    if (!(e = e.parentNode))
      return;
  return e.__brush;
}
function dE(e) {
  return e[0][0] === e[1][0] || e[0][1] === e[1][1];
}
function pE() {
  return Ip(iu);
}
function mE() {
  return Ip(ru);
}
function yE() {
  return Ip(aE);
}
function Ip(e) {
  var t = fE, n = lE, i = hE, r = !0, s = ef("start", "brush", "end"), o = 6, a;
  function c(y) {
    var m = y.property("__brush", g).selectAll(".overlay").data([Ta("overlay")]);
    m.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", li.overlay).merge(m).each(function() {
      var w = $h(this).extent;
      zt(this).attr("x", w[0][0]).attr("y", w[0][1]).attr("width", w[1][0] - w[0][0]).attr("height", w[1][1] - w[0][1]);
    }), y.selectAll(".selection").data([Ta("selection")]).enter().append("rect").attr("class", "selection").attr("cursor", li.selection).attr("fill", "#777").attr("fill-opacity", 0.3).attr("stroke", "#fff").attr("shape-rendering", "crispEdges");
    var b = y.selectAll(".handle").data(e.handles, function(w) {
      return w.type;
    });
    b.exit().remove(), b.enter().append("rect").attr("class", function(w) {
      return "handle handle--" + w.type;
    }).attr("cursor", function(w) {
      return li[w.type];
    }), y.each(u).attr("fill", "none").attr("pointer-events", "all").on("mousedown.brush", h).filter(i).on("touchstart.brush", h).on("touchmove.brush", d).on("touchend.brush touchcancel.brush", p).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  c.move = function(y, m, b) {
    y.tween ? y.on("start.brush", function(w) {
      l(this, arguments).beforestart().start(w);
    }).on("interrupt.brush end.brush", function(w) {
      l(this, arguments).end(w);
    }).tween("brush", function() {
      var w = this, _ = w.__brush, x = l(w, arguments), S = _.selection, I = e.input(typeof m == "function" ? m.apply(this, arguments) : m, _.extent), N = Io(S, I);
      function F($) {
        _.selection = $ === 1 && I === null ? null : N($), u.call(w), x.brush();
      }
      return S !== null && I !== null ? F : F(1);
    }) : y.each(function() {
      var w = this, _ = arguments, x = w.__brush, S = e.input(typeof m == "function" ? m.apply(w, _) : m, x.extent), I = l(w, _).beforestart();
      Vs(w), x.selection = S === null ? null : S, u.call(w), I.start(b).brush(b).end(b);
    });
  }, c.clear = function(y, m) {
    c.move(y, null, m);
  };
  function u() {
    var y = zt(this), m = $h(this).selection;
    m ? (y.selectAll(".selection").style("display", null).attr("x", m[0][0]).attr("y", m[0][1]).attr("width", m[1][0] - m[0][0]).attr("height", m[1][1] - m[0][1]), y.selectAll(".handle").style("display", null).attr("x", function(b) {
      return b.type[b.type.length - 1] === "e" ? m[1][0] - o / 2 : m[0][0] - o / 2;
    }).attr("y", function(b) {
      return b.type[0] === "s" ? m[1][1] - o / 2 : m[0][1] - o / 2;
    }).attr("width", function(b) {
      return b.type === "n" || b.type === "s" ? m[1][0] - m[0][0] + o : o;
    }).attr("height", function(b) {
      return b.type === "e" || b.type === "w" ? m[1][1] - m[0][1] + o : o;
    })) : y.selectAll(".selection,.handle").style("display", "none").attr("x", null).attr("y", null).attr("width", null).attr("height", null);
  }
  function l(y, m, b) {
    var w = y.__brush.emitter;
    return w && (!b || !w.clean) ? w : new f(y, m, b);
  }
  function f(y, m, b) {
    this.that = y, this.args = m, this.state = y.__brush, this.active = 0, this.clean = b;
  }
  f.prototype = {
    beforestart: function() {
      return ++this.active === 1 && (this.state.emitter = this, this.starting = !0), this;
    },
    start: function(y, m) {
      return this.starting ? (this.starting = !1, this.emit("start", y, m)) : this.emit("brush", y), this;
    },
    brush: function(y, m) {
      return this.emit("brush", y, m), this;
    },
    end: function(y, m) {
      return --this.active === 0 && (delete this.state.emitter, this.emit("end", y, m)), this;
    },
    emit: function(y, m, b) {
      var w = zt(this.that).datum();
      s.call(
        y,
        this.that,
        new sE(y, {
          sourceEvent: m,
          target: c,
          selection: e.output(this.state.selection),
          mode: b,
          dispatch: s
        }),
        w
      );
    }
  };
  function h(y) {
    if (a && !y.touches || !n.apply(this, arguments))
      return;
    var m = this, b = y.target.__data__.type, w = (r && y.metaKey ? b = "overlay" : b) === "selection" ? Jy : r && y.altKey ? ps : ds, _ = e === ru ? null : cE[b], x = e === iu ? null : uE[b], S = $h(m), I = S.extent, N = S.selection, F = I[0][0], $, T, D = I[0][1], E, v, M = I[1][0], A, O, L = I[1][1], C, k, R = 0, z = 0, G, Z = _ && x && r && y.shiftKey, pt, Ot, gt = Array.from(y.touches || [y], (X) => {
      const Vt = X.identifier;
      return X = kn(X, m), X.point0 = X.slice(), X.identifier = Vt, X;
    });
    Vs(m);
    var bt = l(m, arguments, !0).beforestart();
    if (b === "overlay") {
      N && (G = !0);
      const X = [gt[0], gt[1] || gt[0]];
      S.selection = N = [[
        $ = e === ru ? F : we(X[0][0], X[1][0]),
        E = e === iu ? D : we(X[0][1], X[1][1])
      ], [
        A = e === ru ? M : be(X[0][0], X[1][0]),
        C = e === iu ? L : be(X[0][1], X[1][1])
      ]], gt.length > 1 && It(y);
    } else
      $ = N[0][0], E = N[0][1], A = N[1][0], C = N[1][1];
    T = $, v = E, O = A, k = C;
    var P = zt(m).attr("pointer-events", "none"), V = P.selectAll(".overlay").attr("cursor", li[b]);
    if (y.touches)
      bt.moved = U, bt.ended = wt;
    else {
      var it = zt(y.view).on("mousemove.brush", U, !0).on("mouseup.brush", wt, !0);
      r && it.on("keydown.brush", Lt, !0).on("keyup.brush", ne, !0), Lw(y.view);
    }
    u.call(m), bt.start(y, w.name);
    function U(X) {
      for (const Vt of X.changedTouches || [X])
        for (const Sr of gt)
          Sr.identifier === Vt.identifier && (Sr.cur = kn(Vt, m));
      if (Z && !pt && !Ot && gt.length === 1) {
        const Vt = gt[0];
        Qy(Vt.cur[0] - Vt[0]) > Qy(Vt.cur[1] - Vt[1]) ? Ot = !0 : pt = !0;
      }
      for (const Vt of gt)
        Vt.cur && (Vt[0] = Vt.cur[0], Vt[1] = Vt.cur[1]);
      G = !0, Mh(X), It(X);
    }
    function It(X) {
      const Vt = gt[0], Sr = Vt.point0;
      var Dn;
      switch (R = Vt[0] - Sr[0], z = Vt[1] - Sr[1], w) {
        case Ah:
        case Jy: {
          _ && (R = be(F - $, we(M - A, R)), T = $ + R, O = A + R), x && (z = be(D - E, we(L - C, z)), v = E + z, k = C + z);
          break;
        }
        case ds: {
          gt[1] ? (_ && (T = be(F, we(M, gt[0][0])), O = be(F, we(M, gt[1][0])), _ = 1), x && (v = be(D, we(L, gt[0][1])), k = be(D, we(L, gt[1][1])), x = 1)) : (_ < 0 ? (R = be(F - $, we(M - $, R)), T = $ + R, O = A) : _ > 0 && (R = be(F - A, we(M - A, R)), T = $, O = A + R), x < 0 ? (z = be(D - E, we(L - E, z)), v = E + z, k = C) : x > 0 && (z = be(D - C, we(L - C, z)), v = E, k = C + z));
          break;
        }
        case ps: {
          _ && (T = be(F, we(M, $ - R * _)), O = be(F, we(M, A + R * _))), x && (v = be(D, we(L, E - z * x)), k = be(D, we(L, C + z * x)));
          break;
        }
      }
      O < T && (_ *= -1, Dn = $, $ = A, A = Dn, Dn = T, T = O, O = Dn, b in eg && V.attr("cursor", li[b = eg[b]])), k < v && (x *= -1, Dn = E, E = C, C = Dn, Dn = v, v = k, k = Dn, b in ng && V.attr("cursor", li[b = ng[b]])), S.selection && (N = S.selection), pt && (T = N[0][0], O = N[1][0]), Ot && (v = N[0][1], k = N[1][1]), (N[0][0] !== T || N[0][1] !== v || N[1][0] !== O || N[1][1] !== k) && (S.selection = [[T, v], [O, k]], u.call(m), bt.brush(X, w.name));
    }
    function wt(X) {
      if (oE(X), X.touches) {
        if (X.touches.length)
          return;
        a && clearTimeout(a), a = setTimeout(function() {
          a = null;
        }, 500);
      } else
        Cw(X.view, G), it.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
      P.attr("pointer-events", "all"), V.attr("cursor", li.overlay), S.selection && (N = S.selection), dE(N) && (S.selection = null, u.call(m)), bt.end(X, w.name);
    }
    function Lt(X) {
      switch (X.keyCode) {
        case 16: {
          Z = _ && x;
          break;
        }
        case 18: {
          w === ds && (_ && (A = O - R * _, $ = T + R * _), x && (C = k - z * x, E = v + z * x), w = ps, It(X));
          break;
        }
        case 32: {
          (w === ds || w === ps) && (_ < 0 ? A = O - R : _ > 0 && ($ = T - R), x < 0 ? C = k - z : x > 0 && (E = v - z), w = Ah, V.attr("cursor", li.selection), It(X));
          break;
        }
        default:
          return;
      }
      Mh(X);
    }
    function ne(X) {
      switch (X.keyCode) {
        case 16: {
          Z && (pt = Ot = Z = !1, It(X));
          break;
        }
        case 18: {
          w === ps && (_ < 0 ? A = O : _ > 0 && ($ = T), x < 0 ? C = k : x > 0 && (E = v), w = ds, It(X));
          break;
        }
        case 32: {
          w === Ah && (X.altKey ? (_ && (A = O - R * _, $ = T + R * _), x && (C = k - z * x, E = v + z * x), w = ps) : (_ < 0 ? A = O : _ > 0 && ($ = T), x < 0 ? C = k : x > 0 && (E = v), w = ds), V.attr("cursor", li[b]), It(X));
          break;
        }
        default:
          return;
      }
      Mh(X);
    }
  }
  function d(y) {
    l(this, arguments).moved(y);
  }
  function p(y) {
    l(this, arguments).ended(y);
  }
  function g() {
    var y = this.__brush || { selection: null };
    return y.extent = Ud(t.apply(this, arguments)), y.dim = e, y;
  }
  return c.extent = function(y) {
    return arguments.length ? (t = typeof y == "function" ? y : Sh(Ud(y)), c) : t;
  }, c.filter = function(y) {
    return arguments.length ? (n = typeof y == "function" ? y : Sh(!!y), c) : n;
  }, c.touchable = function(y) {
    return arguments.length ? (i = typeof y == "function" ? y : Sh(!!y), c) : i;
  }, c.handleSize = function(y) {
    return arguments.length ? (o = +y, c) : o;
  }, c.keyModifiers = function(y) {
    return arguments.length ? (r = !!y, c) : r;
  }, c.on = function() {
    var y = s.on.apply(s, arguments);
    return y === s ? c : y;
  }, c;
}
const zd = Math.PI, Pd = 2 * zd, Nr = 1e-6, gE = Pd - Nr;
function o_(e) {
  this._ += e[0];
  for (let t = 1, n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function bE(e) {
  let t = Math.floor(e);
  if (!(t >= 0))
    throw new Error(`invalid digits: ${e}`);
  if (t > 15)
    return o_;
  const n = 10 ** t;
  return function(i) {
    this._ += i[0];
    for (let r = 1, s = i.length; r < s; ++r)
      this._ += Math.round(arguments[r] * n) / n + i[r];
  };
}
let a_ = class {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? o_ : bE(t);
  }
  moveTo(t, n) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`);
  }
  lineTo(t, n) {
    this._append`L${this._x1 = +t},${this._y1 = +n}`;
  }
  quadraticCurveTo(t, n, i, r) {
    this._append`Q${+t},${+n},${this._x1 = +i},${this._y1 = +r}`;
  }
  bezierCurveTo(t, n, i, r, s, o) {
    this._append`C${+t},${+n},${+i},${+r},${this._x1 = +s},${this._y1 = +o}`;
  }
  arcTo(t, n, i, r, s) {
    if (t = +t, n = +n, i = +i, r = +r, s = +s, s < 0)
      throw new Error(`negative radius: ${s}`);
    let o = this._x1, a = this._y1, c = i - t, u = r - n, l = o - t, f = a - n, h = l * l + f * f;
    if (this._x1 === null)
      this._append`M${this._x1 = t},${this._y1 = n}`;
    else if (h > Nr)
      if (!(Math.abs(f * c - u * l) > Nr) || !s)
        this._append`L${this._x1 = t},${this._y1 = n}`;
      else {
        let d = i - o, p = r - a, g = c * c + u * u, y = d * d + p * p, m = Math.sqrt(g), b = Math.sqrt(h), w = s * Math.tan((zd - Math.acos((g + h - y) / (2 * m * b))) / 2), _ = w / b, x = w / m;
        Math.abs(_ - 1) > Nr && this._append`L${t + _ * l},${n + _ * f}`, this._append`A${s},${s},0,0,${+(f * d > l * p)},${this._x1 = t + x * c},${this._y1 = n + x * u}`;
      }
  }
  arc(t, n, i, r, s, o) {
    if (t = +t, n = +n, i = +i, o = !!o, i < 0)
      throw new Error(`negative radius: ${i}`);
    let a = i * Math.cos(r), c = i * Math.sin(r), u = t + a, l = n + c, f = 1 ^ o, h = o ? r - s : s - r;
    this._x1 === null ? this._append`M${u},${l}` : (Math.abs(this._x1 - u) > Nr || Math.abs(this._y1 - l) > Nr) && this._append`L${u},${l}`, i && (h < 0 && (h = h % Pd + Pd), h > gE ? this._append`A${i},${i},0,1,${f},${t - a},${n - c}A${i},${i},0,1,${f},${this._x1 = u},${this._y1 = l}` : h > Nr && this._append`A${i},${i},0,${+(h >= zd)},${f},${this._x1 = t + i * Math.cos(s)},${this._y1 = n + i * Math.sin(s)}`);
  }
  rect(t, n, i, r) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${i = +i}v${+r}h${-i}Z`;
  }
  toString() {
    return this._;
  }
};
function $i(e = 3) {
  return new a_(+e);
}
var wE = Array.prototype, c_ = wE.slice;
function _E(e, t) {
  return e - t;
}
function vE(e) {
  for (var t = 0, n = e.length, i = e[n - 1][1] * e[0][0] - e[n - 1][0] * e[0][1]; ++t < n; )
    i += e[t - 1][1] * e[t][0] - e[t - 1][0] * e[t][1];
  return i;
}
const Hi = (e) => () => e;
function xE(e, t) {
  for (var n = -1, i = t.length, r; ++n < i; )
    if (r = SE(e, t[n]))
      return r;
  return 0;
}
function SE(e, t) {
  for (var n = t[0], i = t[1], r = -1, s = 0, o = e.length, a = o - 1; s < o; a = s++) {
    var c = e[s], u = c[0], l = c[1], f = e[a], h = f[0], d = f[1];
    if (ME(c, f, t))
      return 0;
    l > i != d > i && n < (h - u) * (i - l) / (d - l) + u && (r = -r);
  }
  return r;
}
function ME(e, t, n) {
  var i;
  return AE(e, t, n) && $E(e[i = +(e[0] === t[0])], n[i], t[i]);
}
function AE(e, t, n) {
  return (t[0] - e[0]) * (n[1] - e[1]) === (n[0] - e[0]) * (t[1] - e[1]);
}
function $E(e, t, n) {
  return e <= t && t <= n || n <= t && t <= e;
}
function IE() {
}
var fi = [
  [],
  [[[1, 1.5], [0.5, 1]]],
  [[[1.5, 1], [1, 1.5]]],
  [[[1.5, 1], [0.5, 1]]],
  [[[1, 0.5], [1.5, 1]]],
  [[[1, 1.5], [0.5, 1]], [[1, 0.5], [1.5, 1]]],
  [[[1, 0.5], [1, 1.5]]],
  [[[1, 0.5], [0.5, 1]]],
  [[[0.5, 1], [1, 0.5]]],
  [[[1, 1.5], [1, 0.5]]],
  [[[0.5, 1], [1, 0.5]], [[1.5, 1], [1, 1.5]]],
  [[[1.5, 1], [1, 0.5]]],
  [[[0.5, 1], [1.5, 1]]],
  [[[1, 1.5], [1.5, 1]]],
  [[[0.5, 1], [1, 1.5]]],
  []
];
function Hu() {
  var e = 1, t = 1, n = hp, i = c;
  function r(u) {
    var l = n(u);
    if (Array.isArray(l))
      l = l.slice().sort(_E);
    else {
      const f = Ne(u, TE);
      for (l = or(...bw(f[0], f[1], l), l); l[l.length - 1] >= f[1]; )
        l.pop();
      for (; l[1] < f[0]; )
        l.shift();
    }
    return l.map((f) => s(u, f));
  }
  function s(u, l) {
    const f = l == null ? NaN : +l;
    if (isNaN(f))
      throw new Error(`invalid value: ${l}`);
    var h = [], d = [];
    return o(u, f, function(p) {
      i(p, u, f), vE(p) > 0 ? h.push([p]) : d.push(p);
    }), d.forEach(function(p) {
      for (var g = 0, y = h.length, m; g < y; ++g)
        if (xE((m = h[g])[0], p) !== -1) {
          m.push(p);
          return;
        }
    }), {
      type: "MultiPolygon",
      value: l,
      coordinates: h
    };
  }
  function o(u, l, f) {
    var h = new Array(), d = new Array(), p, g, y, m, b, w;
    for (p = g = -1, m = Ir(u[0], l), fi[m << 1].forEach(_); ++p < e - 1; )
      y = m, m = Ir(u[p + 1], l), fi[y | m << 1].forEach(_);
    for (fi[m << 0].forEach(_); ++g < t - 1; ) {
      for (p = -1, m = Ir(u[g * e + e], l), b = Ir(u[g * e], l), fi[m << 1 | b << 2].forEach(_); ++p < e - 1; )
        y = m, m = Ir(u[g * e + e + p + 1], l), w = b, b = Ir(u[g * e + p + 1], l), fi[y | m << 1 | b << 2 | w << 3].forEach(_);
      fi[m | b << 3].forEach(_);
    }
    for (p = -1, b = u[g * e] >= l, fi[b << 2].forEach(_); ++p < e - 1; )
      w = b, b = Ir(u[g * e + p + 1], l), fi[b << 2 | w << 3].forEach(_);
    fi[b << 3].forEach(_);
    function _(x) {
      var S = [x[0][0] + p, x[0][1] + g], I = [x[1][0] + p, x[1][1] + g], N = a(S), F = a(I), $, T;
      ($ = d[N]) ? (T = h[F]) ? (delete d[$.end], delete h[T.start], $ === T ? ($.ring.push(I), f($.ring)) : h[$.start] = d[T.end] = { start: $.start, end: T.end, ring: $.ring.concat(T.ring) }) : (delete d[$.end], $.ring.push(I), d[$.end = F] = $) : ($ = h[F]) ? (T = d[N]) ? (delete h[$.start], delete d[T.end], $ === T ? ($.ring.push(I), f($.ring)) : h[T.start] = d[$.end] = { start: T.start, end: $.end, ring: T.ring.concat($.ring) }) : (delete h[$.start], $.ring.unshift(S), h[$.start = N] = $) : h[N] = d[F] = { start: N, end: F, ring: [S, I] };
    }
  }
  function a(u) {
    return u[0] * 2 + u[1] * (e + 1) * 4;
  }
  function c(u, l, f) {
    u.forEach(function(h) {
      var d = h[0], p = h[1], g = d | 0, y = p | 0, m = Ih(l[y * e + g]);
      d > 0 && d < e && g === d && (h[0] = ig(d, Ih(l[y * e + g - 1]), m, f)), p > 0 && p < t && y === p && (h[1] = ig(p, Ih(l[(y - 1) * e + g]), m, f));
    });
  }
  return r.contour = s, r.size = function(u) {
    if (!arguments.length)
      return [e, t];
    var l = Math.floor(u[0]), f = Math.floor(u[1]);
    if (!(l >= 0 && f >= 0))
      throw new Error("invalid size");
    return e = l, t = f, r;
  }, r.thresholds = function(u) {
    return arguments.length ? (n = typeof u == "function" ? u : Array.isArray(u) ? Hi(c_.call(u)) : Hi(u), r) : n;
  }, r.smooth = function(u) {
    return arguments.length ? (i = u ? c : IE, r) : i === c;
  }, r;
}
function TE(e) {
  return isFinite(e) ? e : NaN;
}
function Ir(e, t) {
  return e == null ? !1 : +e >= t;
}
function Ih(e) {
  return e == null || isNaN(e = +e) ? -1 / 0 : e;
}
function ig(e, t, n, i) {
  const r = i - t, s = n - t, o = isFinite(r) || isFinite(s) ? r / s : Math.sign(r) / Math.sign(s);
  return isNaN(o) ? e : e + o - 0.5;
}
function EE(e) {
  return e[0];
}
function NE(e) {
  return e[1];
}
function OE() {
  return 1;
}
function FE() {
  var e = EE, t = NE, n = OE, i = 960, r = 500, s = 20, o = 2, a = s * 3, c = i + a * 2 >> o, u = r + a * 2 >> o, l = Hi(20);
  function f(b) {
    var w = new Float32Array(c * u), _ = Math.pow(2, -o), x = -1;
    for (const E of b) {
      var S = (e(E, ++x, b) + a) * _, I = (t(E, x, b) + a) * _, N = +n(E, x, b);
      if (N && S >= 0 && S < c && I >= 0 && I < u) {
        var F = Math.floor(S), $ = Math.floor(I), T = S - F - 0.5, D = I - $ - 0.5;
        w[F + $ * c] += (1 - T) * (1 - D) * N, w[F + 1 + $ * c] += T * (1 - D) * N, w[F + 1 + ($ + 1) * c] += T * D * N, w[F + ($ + 1) * c] += (1 - T) * D * N;
      }
    }
    return fw({ data: w, width: c, height: u }, s * _), w;
  }
  function h(b) {
    var w = f(b), _ = l(w), x = Math.pow(2, 2 * o);
    return Array.isArray(_) || (_ = or(Number.MIN_VALUE, Gt(w) / x, _)), Hu().size([c, u]).thresholds(_.map((S) => S * x))(w).map((S, I) => (S.value = +_[I], d(S)));
  }
  h.contours = function(b) {
    var w = f(b), _ = Hu().size([c, u]), x = Math.pow(2, 2 * o), S = (I) => {
      I = +I;
      var N = d(_.contour(w, I * x));
      return N.value = I, N;
    };
    return Object.defineProperty(S, "max", { get: () => Gt(w) / x }), S;
  };
  function d(b) {
    return b.coordinates.forEach(p), b;
  }
  function p(b) {
    b.forEach(g);
  }
  function g(b) {
    b.forEach(y);
  }
  function y(b) {
    b[0] = b[0] * Math.pow(2, o) - a, b[1] = b[1] * Math.pow(2, o) - a;
  }
  function m() {
    return a = s * 3, c = i + a * 2 >> o, u = r + a * 2 >> o, h;
  }
  return h.x = function(b) {
    return arguments.length ? (e = typeof b == "function" ? b : Hi(+b), h) : e;
  }, h.y = function(b) {
    return arguments.length ? (t = typeof b == "function" ? b : Hi(+b), h) : t;
  }, h.weight = function(b) {
    return arguments.length ? (n = typeof b == "function" ? b : Hi(+b), h) : n;
  }, h.size = function(b) {
    if (!arguments.length)
      return [i, r];
    var w = +b[0], _ = +b[1];
    if (!(w >= 0 && _ >= 0))
      throw new Error("invalid size");
    return i = w, r = _, m();
  }, h.cellSize = function(b) {
    if (!arguments.length)
      return 1 << o;
    if (!((b = +b) >= 1))
      throw new Error("invalid cell size");
    return o = Math.floor(Math.log(b) / Math.LN2), m();
  }, h.thresholds = function(b) {
    return arguments.length ? (l = typeof b == "function" ? b : Array.isArray(b) ? Hi(c_.call(b)) : Hi(b), h) : l;
  }, h.bandwidth = function(b) {
    if (!arguments.length)
      return Math.sqrt(s * (s + 1));
    if (!((b = +b) >= 0))
      throw new Error("invalid bandwidth");
    return s = (Math.sqrt(4 * b * b + 1) - 1) / 2, m();
  }, h;
}
const Fi = 11102230246251565e-32, _e = 134217729, DE = (3 + 8 * Fi) * Fi;
function Th(e, t, n, i, r) {
  let s, o, a, c, u = t[0], l = i[0], f = 0, h = 0;
  l > u == l > -u ? (s = u, u = t[++f]) : (s = l, l = i[++h]);
  let d = 0;
  if (f < e && h < n)
    for (l > u == l > -u ? (o = u + s, a = s - (o - u), u = t[++f]) : (o = l + s, a = s - (o - l), l = i[++h]), s = o, a !== 0 && (r[d++] = a); f < e && h < n; )
      l > u == l > -u ? (o = s + u, c = o - s, a = s - (o - c) + (u - c), u = t[++f]) : (o = s + l, c = o - s, a = s - (o - c) + (l - c), l = i[++h]), s = o, a !== 0 && (r[d++] = a);
  for (; f < e; )
    o = s + u, c = o - s, a = s - (o - c) + (u - c), u = t[++f], s = o, a !== 0 && (r[d++] = a);
  for (; h < n; )
    o = s + l, c = o - s, a = s - (o - c) + (l - c), l = i[++h], s = o, a !== 0 && (r[d++] = a);
  return (s !== 0 || d === 0) && (r[d++] = s), d;
}
function BE(e, t) {
  let n = t[0];
  for (let i = 1; i < e; i++)
    n += t[i];
  return n;
}
function Ja(e) {
  return new Float64Array(e);
}
const LE = (3 + 16 * Fi) * Fi, CE = (2 + 12 * Fi) * Fi, kE = (9 + 64 * Fi) * Fi * Fi, ms = Ja(4), rg = Ja(8), sg = Ja(12), og = Ja(16), Me = Ja(4);
function RE(e, t, n, i, r, s, o) {
  let a, c, u, l, f, h, d, p, g, y, m, b, w, _, x, S, I, N;
  const F = e - r, $ = n - r, T = t - s, D = i - s;
  _ = F * D, h = _e * F, d = h - (h - F), p = F - d, h = _e * D, g = h - (h - D), y = D - g, x = p * y - (_ - d * g - p * g - d * y), S = T * $, h = _e * T, d = h - (h - T), p = T - d, h = _e * $, g = h - (h - $), y = $ - g, I = p * y - (S - d * g - p * g - d * y), m = x - I, f = x - m, ms[0] = x - (m + f) + (f - I), b = _ + m, f = b - _, w = _ - (b - f) + (m - f), m = w - S, f = w - m, ms[1] = w - (m + f) + (f - S), N = b + m, f = N - b, ms[2] = b - (N - f) + (m - f), ms[3] = N;
  let E = BE(4, ms), v = CE * o;
  if (E >= v || -E >= v || (f = e - F, a = e - (F + f) + (f - r), f = n - $, u = n - ($ + f) + (f - r), f = t - T, c = t - (T + f) + (f - s), f = i - D, l = i - (D + f) + (f - s), a === 0 && c === 0 && u === 0 && l === 0) || (v = kE * o + DE * Math.abs(E), E += F * l + D * a - (T * u + $ * c), E >= v || -E >= v))
    return E;
  _ = a * D, h = _e * a, d = h - (h - a), p = a - d, h = _e * D, g = h - (h - D), y = D - g, x = p * y - (_ - d * g - p * g - d * y), S = c * $, h = _e * c, d = h - (h - c), p = c - d, h = _e * $, g = h - (h - $), y = $ - g, I = p * y - (S - d * g - p * g - d * y), m = x - I, f = x - m, Me[0] = x - (m + f) + (f - I), b = _ + m, f = b - _, w = _ - (b - f) + (m - f), m = w - S, f = w - m, Me[1] = w - (m + f) + (f - S), N = b + m, f = N - b, Me[2] = b - (N - f) + (m - f), Me[3] = N;
  const M = Th(4, ms, 4, Me, rg);
  _ = F * l, h = _e * F, d = h - (h - F), p = F - d, h = _e * l, g = h - (h - l), y = l - g, x = p * y - (_ - d * g - p * g - d * y), S = T * u, h = _e * T, d = h - (h - T), p = T - d, h = _e * u, g = h - (h - u), y = u - g, I = p * y - (S - d * g - p * g - d * y), m = x - I, f = x - m, Me[0] = x - (m + f) + (f - I), b = _ + m, f = b - _, w = _ - (b - f) + (m - f), m = w - S, f = w - m, Me[1] = w - (m + f) + (f - S), N = b + m, f = N - b, Me[2] = b - (N - f) + (m - f), Me[3] = N;
  const A = Th(M, rg, 4, Me, sg);
  _ = a * l, h = _e * a, d = h - (h - a), p = a - d, h = _e * l, g = h - (h - l), y = l - g, x = p * y - (_ - d * g - p * g - d * y), S = c * u, h = _e * c, d = h - (h - c), p = c - d, h = _e * u, g = h - (h - u), y = u - g, I = p * y - (S - d * g - p * g - d * y), m = x - I, f = x - m, Me[0] = x - (m + f) + (f - I), b = _ + m, f = b - _, w = _ - (b - f) + (m - f), m = w - S, f = w - m, Me[1] = w - (m + f) + (f - S), N = b + m, f = N - b, Me[2] = b - (N - f) + (m - f), Me[3] = N;
  const O = Th(A, sg, 4, Me, og);
  return og[O - 1];
}
function Mc(e, t, n, i, r, s) {
  const o = (t - s) * (n - r), a = (e - r) * (i - s), c = o - a;
  if (o === 0 || a === 0 || o > 0 != a > 0)
    return c;
  const u = Math.abs(o + a);
  return Math.abs(c) >= LE * u ? c : -RE(e, t, n, i, r, s, u);
}
const ag = Math.pow(2, -52), Ac = new Uint32Array(512);
class Gu {
  static from(t, n = qE, i = VE) {
    const r = t.length, s = new Float64Array(r * 2);
    for (let o = 0; o < r; o++) {
      const a = t[o];
      s[2 * o] = n(a), s[2 * o + 1] = i(a);
    }
    return new Gu(s);
  }
  constructor(t) {
    const n = t.length >> 1;
    if (n > 0 && typeof t[0] != "number")
      throw new Error("Expected coords to contain numbers.");
    this.coords = t;
    const i = Math.max(2 * n - 5, 0);
    this._triangles = new Uint32Array(i * 3), this._halfedges = new Int32Array(i * 3), this._hashSize = Math.ceil(Math.sqrt(n)), this._hullPrev = new Uint32Array(n), this._hullNext = new Uint32Array(n), this._hullTri = new Uint32Array(n), this._hullHash = new Int32Array(this._hashSize).fill(-1), this._ids = new Uint32Array(n), this._dists = new Float64Array(n), this.update();
  }
  update() {
    const { coords: t, _hullPrev: n, _hullNext: i, _hullTri: r, _hullHash: s } = this, o = t.length >> 1;
    let a = 1 / 0, c = 1 / 0, u = -1 / 0, l = -1 / 0;
    for (let $ = 0; $ < o; $++) {
      const T = t[2 * $], D = t[2 * $ + 1];
      T < a && (a = T), D < c && (c = D), T > u && (u = T), D > l && (l = D), this._ids[$] = $;
    }
    const f = (a + u) / 2, h = (c + l) / 2;
    let d = 1 / 0, p, g, y;
    for (let $ = 0; $ < o; $++) {
      const T = Eh(f, h, t[2 * $], t[2 * $ + 1]);
      T < d && (p = $, d = T);
    }
    const m = t[2 * p], b = t[2 * p + 1];
    d = 1 / 0;
    for (let $ = 0; $ < o; $++) {
      if ($ === p)
        continue;
      const T = Eh(m, b, t[2 * $], t[2 * $ + 1]);
      T < d && T > 0 && (g = $, d = T);
    }
    let w = t[2 * g], _ = t[2 * g + 1], x = 1 / 0;
    for (let $ = 0; $ < o; $++) {
      if ($ === p || $ === g)
        continue;
      const T = PE(m, b, w, _, t[2 * $], t[2 * $ + 1]);
      T < x && (y = $, x = T);
    }
    let S = t[2 * y], I = t[2 * y + 1];
    if (x === 1 / 0) {
      for (let D = 0; D < o; D++)
        this._dists[D] = t[2 * D] - t[0] || t[2 * D + 1] - t[1];
      Ts(this._ids, this._dists, 0, o - 1);
      const $ = new Uint32Array(o);
      let T = 0;
      for (let D = 0, E = -1 / 0; D < o; D++) {
        const v = this._ids[D];
        this._dists[v] > E && ($[T++] = v, E = this._dists[v]);
      }
      this.hull = $.subarray(0, T), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
      return;
    }
    if (Mc(m, b, w, _, S, I) < 0) {
      const $ = g, T = w, D = _;
      g = y, w = S, _ = I, y = $, S = T, I = D;
    }
    const N = YE(m, b, w, _, S, I);
    this._cx = N.x, this._cy = N.y;
    for (let $ = 0; $ < o; $++)
      this._dists[$] = Eh(t[2 * $], t[2 * $ + 1], N.x, N.y);
    Ts(this._ids, this._dists, 0, o - 1), this._hullStart = p;
    let F = 3;
    i[p] = n[y] = g, i[g] = n[p] = y, i[y] = n[g] = p, r[p] = 0, r[g] = 1, r[y] = 2, s.fill(-1), s[this._hashKey(m, b)] = p, s[this._hashKey(w, _)] = g, s[this._hashKey(S, I)] = y, this.trianglesLen = 0, this._addTriangle(p, g, y, -1, -1, -1);
    for (let $ = 0, T, D; $ < this._ids.length; $++) {
      const E = this._ids[$], v = t[2 * E], M = t[2 * E + 1];
      if ($ > 0 && Math.abs(v - T) <= ag && Math.abs(M - D) <= ag || (T = v, D = M, E === p || E === g || E === y))
        continue;
      let A = 0;
      for (let R = 0, z = this._hashKey(v, M); R < this._hashSize && (A = s[(z + R) % this._hashSize], !(A !== -1 && A !== i[A])); R++)
        ;
      A = n[A];
      let O = A, L;
      for (; L = i[O], Mc(v, M, t[2 * O], t[2 * O + 1], t[2 * L], t[2 * L + 1]) >= 0; )
        if (O = L, O === A) {
          O = -1;
          break;
        }
      if (O === -1)
        continue;
      let C = this._addTriangle(O, E, i[O], -1, -1, r[O]);
      r[E] = this._legalize(C + 2), r[O] = C, F++;
      let k = i[O];
      for (; L = i[k], Mc(v, M, t[2 * k], t[2 * k + 1], t[2 * L], t[2 * L + 1]) < 0; )
        C = this._addTriangle(k, E, L, r[E], -1, r[k]), r[E] = this._legalize(C + 2), i[k] = k, F--, k = L;
      if (O === A)
        for (; L = n[O], Mc(v, M, t[2 * L], t[2 * L + 1], t[2 * O], t[2 * O + 1]) < 0; )
          C = this._addTriangle(L, E, O, -1, r[O], r[L]), this._legalize(C + 2), r[L] = C, i[O] = O, F--, O = L;
      this._hullStart = n[E] = O, i[O] = n[k] = E, i[E] = k, s[this._hashKey(v, M)] = E, s[this._hashKey(t[2 * O], t[2 * O + 1])] = O;
    }
    this.hull = new Uint32Array(F);
    for (let $ = 0, T = this._hullStart; $ < F; $++)
      this.hull[$] = T, T = i[T];
    this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
  }
  _hashKey(t, n) {
    return Math.floor(UE(t - this._cx, n - this._cy) * this._hashSize) % this._hashSize;
  }
  _legalize(t) {
    const { _triangles: n, _halfedges: i, coords: r } = this;
    let s = 0, o = 0;
    for (; ; ) {
      const a = i[t], c = t - t % 3;
      if (o = c + (t + 2) % 3, a === -1) {
        if (s === 0)
          break;
        t = Ac[--s];
        continue;
      }
      const u = a - a % 3, l = c + (t + 1) % 3, f = u + (a + 2) % 3, h = n[o], d = n[t], p = n[l], g = n[f];
      if (zE(
        r[2 * h],
        r[2 * h + 1],
        r[2 * d],
        r[2 * d + 1],
        r[2 * p],
        r[2 * p + 1],
        r[2 * g],
        r[2 * g + 1]
      )) {
        n[t] = g, n[a] = h;
        const m = i[f];
        if (m === -1) {
          let w = this._hullStart;
          do {
            if (this._hullTri[w] === f) {
              this._hullTri[w] = t;
              break;
            }
            w = this._hullPrev[w];
          } while (w !== this._hullStart);
        }
        this._link(t, m), this._link(a, i[o]), this._link(o, f);
        const b = u + (a + 1) % 3;
        s < Ac.length && (Ac[s++] = b);
      } else {
        if (s === 0)
          break;
        t = Ac[--s];
      }
    }
    return o;
  }
  _link(t, n) {
    this._halfedges[t] = n, n !== -1 && (this._halfedges[n] = t);
  }
  // add a new triangle given vertex indices and adjacent half-edge ids
  _addTriangle(t, n, i, r, s, o) {
    const a = this.trianglesLen;
    return this._triangles[a] = t, this._triangles[a + 1] = n, this._triangles[a + 2] = i, this._link(a, r), this._link(a + 1, s), this._link(a + 2, o), this.trianglesLen += 3, a;
  }
}
function UE(e, t) {
  const n = e / (Math.abs(e) + Math.abs(t));
  return (t > 0 ? 3 - n : 1 + n) / 4;
}
function Eh(e, t, n, i) {
  const r = e - n, s = t - i;
  return r * r + s * s;
}
function zE(e, t, n, i, r, s, o, a) {
  const c = e - o, u = t - a, l = n - o, f = i - a, h = r - o, d = s - a, p = c * c + u * u, g = l * l + f * f, y = h * h + d * d;
  return c * (f * y - g * d) - u * (l * y - g * h) + p * (l * d - f * h) < 0;
}
function PE(e, t, n, i, r, s) {
  const o = n - e, a = i - t, c = r - e, u = s - t, l = o * o + a * a, f = c * c + u * u, h = 0.5 / (o * u - a * c), d = (u * l - a * f) * h, p = (o * f - c * l) * h;
  return d * d + p * p;
}
function YE(e, t, n, i, r, s) {
  const o = n - e, a = i - t, c = r - e, u = s - t, l = o * o + a * a, f = c * c + u * u, h = 0.5 / (o * u - a * c), d = e + (u * l - a * f) * h, p = t + (o * f - c * l) * h;
  return { x: d, y: p };
}
function Ts(e, t, n, i) {
  if (i - n <= 20)
    for (let r = n + 1; r <= i; r++) {
      const s = e[r], o = t[s];
      let a = r - 1;
      for (; a >= n && t[e[a]] > o; )
        e[a + 1] = e[a--];
      e[a + 1] = s;
    }
  else {
    const r = n + i >> 1;
    let s = n + 1, o = i;
    qo(e, r, s), t[e[n]] > t[e[i]] && qo(e, n, i), t[e[s]] > t[e[i]] && qo(e, s, i), t[e[n]] > t[e[s]] && qo(e, n, s);
    const a = e[s], c = t[a];
    for (; ; ) {
      do
        s++;
      while (t[e[s]] < c);
      do
        o--;
      while (t[e[o]] > c);
      if (o < s)
        break;
      qo(e, s, o);
    }
    e[n + 1] = e[o], e[o] = a, i - s + 1 >= o - n ? (Ts(e, t, s, i), Ts(e, t, n, o - 1)) : (Ts(e, t, n, o - 1), Ts(e, t, s, i));
  }
}
function qo(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function qE(e) {
  return e[0];
}
function VE(e) {
  return e[1];
}
const cg = 1e-6;
class Pr {
  constructor() {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "";
  }
  moveTo(t, n) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z");
  }
  lineTo(t, n) {
    this._ += `L${this._x1 = +t},${this._y1 = +n}`;
  }
  arc(t, n, i) {
    t = +t, n = +n, i = +i;
    const r = t + i, s = n;
    if (i < 0)
      throw new Error("negative radius");
    this._x1 === null ? this._ += `M${r},${s}` : (Math.abs(this._x1 - r) > cg || Math.abs(this._y1 - s) > cg) && (this._ += "L" + r + "," + s), i && (this._ += `A${i},${i},0,1,1,${t - i},${n}A${i},${i},0,1,1,${this._x1 = r},${this._y1 = s}`);
  }
  rect(t, n, i, r) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${+i}v${+r}h${-i}Z`;
  }
  value() {
    return this._ || null;
  }
}
class Yd {
  constructor() {
    this._ = [];
  }
  moveTo(t, n) {
    this._.push([t, n]);
  }
  closePath() {
    this._.push(this._[0].slice());
  }
  lineTo(t, n) {
    this._.push([t, n]);
  }
  value() {
    return this._.length ? this._ : null;
  }
}
let jE = class {
  constructor(t, [n, i, r, s] = [0, 0, 960, 500]) {
    if (!((r = +r) >= (n = +n)) || !((s = +s) >= (i = +i)))
      throw new Error("invalid bounds");
    this.delaunay = t, this._circumcenters = new Float64Array(t.points.length * 2), this.vectors = new Float64Array(t.points.length * 2), this.xmax = r, this.xmin = n, this.ymax = s, this.ymin = i, this._init();
  }
  update() {
    return this.delaunay.update(), this._init(), this;
  }
  _init() {
    const { delaunay: { points: t, hull: n, triangles: i }, vectors: r } = this, s = this.circumcenters = this._circumcenters.subarray(0, i.length / 3 * 2);
    for (let d = 0, p = 0, g = i.length, y, m; d < g; d += 3, p += 2) {
      const b = i[d] * 2, w = i[d + 1] * 2, _ = i[d + 2] * 2, x = t[b], S = t[b + 1], I = t[w], N = t[w + 1], F = t[_], $ = t[_ + 1], T = I - x, D = N - S, E = F - x, v = $ - S, M = (T * v - D * E) * 2;
      if (Math.abs(M) < 1e-9) {
        let A = 1e9;
        const O = i[0] * 2;
        A *= Math.sign((t[O] - x) * v - (t[O + 1] - S) * E), y = (x + F) / 2 - A * v, m = (S + $) / 2 + A * E;
      } else {
        const A = 1 / M, O = T * T + D * D, L = E * E + v * v;
        y = x + (v * O - D * L) * A, m = S + (T * L - E * O) * A;
      }
      s[p] = y, s[p + 1] = m;
    }
    let o = n[n.length - 1], a, c = o * 4, u, l = t[2 * o], f, h = t[2 * o + 1];
    r.fill(0);
    for (let d = 0; d < n.length; ++d)
      o = n[d], a = c, u = l, f = h, c = o * 4, l = t[2 * o], h = t[2 * o + 1], r[a + 2] = r[c] = f - h, r[a + 3] = r[c + 1] = l - u;
  }
  render(t) {
    const n = t == null ? t = new Pr() : void 0, { delaunay: { halfedges: i, inedges: r, hull: s }, circumcenters: o, vectors: a } = this;
    if (s.length <= 1)
      return null;
    for (let l = 0, f = i.length; l < f; ++l) {
      const h = i[l];
      if (h < l)
        continue;
      const d = Math.floor(l / 3) * 2, p = Math.floor(h / 3) * 2, g = o[d], y = o[d + 1], m = o[p], b = o[p + 1];
      this._renderSegment(g, y, m, b, t);
    }
    let c, u = s[s.length - 1];
    for (let l = 0; l < s.length; ++l) {
      c = u, u = s[l];
      const f = Math.floor(r[u] / 3) * 2, h = o[f], d = o[f + 1], p = c * 4, g = this._project(h, d, a[p + 2], a[p + 3]);
      g && this._renderSegment(h, d, g[0], g[1], t);
    }
    return n && n.value();
  }
  renderBounds(t) {
    const n = t == null ? t = new Pr() : void 0;
    return t.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin), n && n.value();
  }
  renderCell(t, n) {
    const i = n == null ? n = new Pr() : void 0, r = this._clip(t);
    if (r === null || !r.length)
      return;
    n.moveTo(r[0], r[1]);
    let s = r.length;
    for (; r[0] === r[s - 2] && r[1] === r[s - 1] && s > 1; )
      s -= 2;
    for (let o = 2; o < s; o += 2)
      (r[o] !== r[o - 2] || r[o + 1] !== r[o - 1]) && n.lineTo(r[o], r[o + 1]);
    return n.closePath(), i && i.value();
  }
  *cellPolygons() {
    const { delaunay: { points: t } } = this;
    for (let n = 0, i = t.length / 2; n < i; ++n) {
      const r = this.cellPolygon(n);
      r && (r.index = n, yield r);
    }
  }
  cellPolygon(t) {
    const n = new Yd();
    return this.renderCell(t, n), n.value();
  }
  _renderSegment(t, n, i, r, s) {
    let o;
    const a = this._regioncode(t, n), c = this._regioncode(i, r);
    a === 0 && c === 0 ? (s.moveTo(t, n), s.lineTo(i, r)) : (o = this._clipSegment(t, n, i, r, a, c)) && (s.moveTo(o[0], o[1]), s.lineTo(o[2], o[3]));
  }
  contains(t, n, i) {
    return n = +n, n !== n || (i = +i, i !== i) ? !1 : this.delaunay._step(t, n, i) === t;
  }
  *neighbors(t) {
    const n = this._clip(t);
    if (n)
      for (const i of this.delaunay.neighbors(t)) {
        const r = this._clip(i);
        if (r) {
          t:
            for (let s = 0, o = n.length; s < o; s += 2)
              for (let a = 0, c = r.length; a < c; a += 2)
                if (n[s] == r[a] && n[s + 1] == r[a + 1] && n[(s + 2) % o] == r[(a + c - 2) % c] && n[(s + 3) % o] == r[(a + c - 1) % c]) {
                  yield i;
                  break t;
                }
        }
      }
  }
  _cell(t) {
    const { circumcenters: n, delaunay: { inedges: i, halfedges: r, triangles: s } } = this, o = i[t];
    if (o === -1)
      return null;
    const a = [];
    let c = o;
    do {
      const u = Math.floor(c / 3);
      if (a.push(n[u * 2], n[u * 2 + 1]), c = c % 3 === 2 ? c - 2 : c + 1, s[c] !== t)
        break;
      c = r[c];
    } while (c !== o && c !== -1);
    return a;
  }
  _clip(t) {
    if (t === 0 && this.delaunay.hull.length === 1)
      return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
    const n = this._cell(t);
    if (n === null)
      return null;
    const { vectors: i } = this, r = t * 4;
    return i[r] || i[r + 1] ? this._clipInfinite(t, n, i[r], i[r + 1], i[r + 2], i[r + 3]) : this._clipFinite(t, n);
  }
  _clipFinite(t, n) {
    const i = n.length;
    let r = null, s, o, a = n[i - 2], c = n[i - 1], u, l = this._regioncode(a, c), f, h = 0;
    for (let d = 0; d < i; d += 2)
      if (s = a, o = c, a = n[d], c = n[d + 1], u = l, l = this._regioncode(a, c), u === 0 && l === 0)
        f = h, h = 0, r ? r.push(a, c) : r = [a, c];
      else {
        let p, g, y, m, b;
        if (u === 0) {
          if ((p = this._clipSegment(s, o, a, c, u, l)) === null)
            continue;
          [g, y, m, b] = p;
        } else {
          if ((p = this._clipSegment(a, c, s, o, l, u)) === null)
            continue;
          [m, b, g, y] = p, f = h, h = this._edgecode(g, y), f && h && this._edge(t, f, h, r, r.length), r ? r.push(g, y) : r = [g, y];
        }
        f = h, h = this._edgecode(m, b), f && h && this._edge(t, f, h, r, r.length), r ? r.push(m, b) : r = [m, b];
      }
    if (r)
      f = h, h = this._edgecode(r[0], r[1]), f && h && this._edge(t, f, h, r, r.length);
    else if (this.contains(t, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2))
      return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
    return r;
  }
  _clipSegment(t, n, i, r, s, o) {
    for (; ; ) {
      if (s === 0 && o === 0)
        return [t, n, i, r];
      if (s & o)
        return null;
      let a, c, u = s || o;
      u & 8 ? (a = t + (i - t) * (this.ymax - n) / (r - n), c = this.ymax) : u & 4 ? (a = t + (i - t) * (this.ymin - n) / (r - n), c = this.ymin) : u & 2 ? (c = n + (r - n) * (this.xmax - t) / (i - t), a = this.xmax) : (c = n + (r - n) * (this.xmin - t) / (i - t), a = this.xmin), s ? (t = a, n = c, s = this._regioncode(t, n)) : (i = a, r = c, o = this._regioncode(i, r));
    }
  }
  _clipInfinite(t, n, i, r, s, o) {
    let a = Array.from(n), c;
    if ((c = this._project(a[0], a[1], i, r)) && a.unshift(c[0], c[1]), (c = this._project(a[a.length - 2], a[a.length - 1], s, o)) && a.push(c[0], c[1]), a = this._clipFinite(t, a))
      for (let u = 0, l = a.length, f, h = this._edgecode(a[l - 2], a[l - 1]); u < l; u += 2)
        f = h, h = this._edgecode(a[u], a[u + 1]), f && h && (u = this._edge(t, f, h, a, u), l = a.length);
    else
      this.contains(t, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2) && (a = [this.xmin, this.ymin, this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax]);
    return a;
  }
  _edge(t, n, i, r, s) {
    for (; n !== i; ) {
      let o, a;
      switch (n) {
        case 5:
          n = 4;
          continue;
        case 4:
          n = 6, o = this.xmax, a = this.ymin;
          break;
        case 6:
          n = 2;
          continue;
        case 2:
          n = 10, o = this.xmax, a = this.ymax;
          break;
        case 10:
          n = 8;
          continue;
        case 8:
          n = 9, o = this.xmin, a = this.ymax;
          break;
        case 9:
          n = 1;
          continue;
        case 1:
          n = 5, o = this.xmin, a = this.ymin;
          break;
      }
      (r[s] !== o || r[s + 1] !== a) && this.contains(t, o, a) && (r.splice(s, 0, o, a), s += 2);
    }
    if (r.length > 4)
      for (let o = 0; o < r.length; o += 2) {
        const a = (o + 2) % r.length, c = (o + 4) % r.length;
        (r[o] === r[a] && r[a] === r[c] || r[o + 1] === r[a + 1] && r[a + 1] === r[c + 1]) && (r.splice(a, 2), o -= 2);
      }
    return s;
  }
  _project(t, n, i, r) {
    let s = 1 / 0, o, a, c;
    if (r < 0) {
      if (n <= this.ymin)
        return null;
      (o = (this.ymin - n) / r) < s && (c = this.ymin, a = t + (s = o) * i);
    } else if (r > 0) {
      if (n >= this.ymax)
        return null;
      (o = (this.ymax - n) / r) < s && (c = this.ymax, a = t + (s = o) * i);
    }
    if (i > 0) {
      if (t >= this.xmax)
        return null;
      (o = (this.xmax - t) / i) < s && (a = this.xmax, c = n + (s = o) * r);
    } else if (i < 0) {
      if (t <= this.xmin)
        return null;
      (o = (this.xmin - t) / i) < s && (a = this.xmin, c = n + (s = o) * r);
    }
    return [a, c];
  }
  _edgecode(t, n) {
    return (t === this.xmin ? 1 : t === this.xmax ? 2 : 0) | (n === this.ymin ? 4 : n === this.ymax ? 8 : 0);
  }
  _regioncode(t, n) {
    return (t < this.xmin ? 1 : t > this.xmax ? 2 : 0) | (n < this.ymin ? 4 : n > this.ymax ? 8 : 0);
  }
};
const XE = 2 * Math.PI, ys = Math.pow;
function WE(e) {
  return e[0];
}
function HE(e) {
  return e[1];
}
function GE(e) {
  const { triangles: t, coords: n } = e;
  for (let i = 0; i < t.length; i += 3) {
    const r = 2 * t[i], s = 2 * t[i + 1], o = 2 * t[i + 2];
    if ((n[o] - n[r]) * (n[s + 1] - n[r + 1]) - (n[s] - n[r]) * (n[o + 1] - n[r + 1]) > 1e-10)
      return !1;
  }
  return !0;
}
function ZE(e, t, n) {
  return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n];
}
class ki {
  static from(t, n = WE, i = HE, r) {
    return new ki("length" in t ? KE(t, n, i, r) : Float64Array.from(JE(t, n, i, r)));
  }
  constructor(t) {
    this._delaunator = new Gu(t), this.inedges = new Int32Array(t.length / 2), this._hullIndex = new Int32Array(t.length / 2), this.points = this._delaunator.coords, this._init();
  }
  update() {
    return this._delaunator.update(), this._init(), this;
  }
  _init() {
    const t = this._delaunator, n = this.points;
    if (t.hull && t.hull.length > 2 && GE(t)) {
      this.collinear = Int32Array.from({ length: n.length / 2 }, (h, d) => d).sort((h, d) => n[2 * h] - n[2 * d] || n[2 * h + 1] - n[2 * d + 1]);
      const c = this.collinear[0], u = this.collinear[this.collinear.length - 1], l = [n[2 * c], n[2 * c + 1], n[2 * u], n[2 * u + 1]], f = 1e-8 * Math.hypot(l[3] - l[1], l[2] - l[0]);
      for (let h = 0, d = n.length / 2; h < d; ++h) {
        const p = ZE(n[2 * h], n[2 * h + 1], f);
        n[2 * h] = p[0], n[2 * h + 1] = p[1];
      }
      this._delaunator = new Gu(n);
    } else
      delete this.collinear;
    const i = this.halfedges = this._delaunator.halfedges, r = this.hull = this._delaunator.hull, s = this.triangles = this._delaunator.triangles, o = this.inedges.fill(-1), a = this._hullIndex.fill(-1);
    for (let c = 0, u = i.length; c < u; ++c) {
      const l = s[c % 3 === 2 ? c - 2 : c + 1];
      (i[c] === -1 || o[l] === -1) && (o[l] = c);
    }
    for (let c = 0, u = r.length; c < u; ++c)
      a[r[c]] = c;
    r.length <= 2 && r.length > 0 && (this.triangles = new Int32Array(3).fill(-1), this.halfedges = new Int32Array(3).fill(-1), this.triangles[0] = r[0], o[r[0]] = 1, r.length === 2 && (o[r[1]] = 0, this.triangles[1] = r[1], this.triangles[2] = r[1]));
  }
  voronoi(t) {
    return new jE(this, t);
  }
  *neighbors(t) {
    const { inedges: n, hull: i, _hullIndex: r, halfedges: s, triangles: o, collinear: a } = this;
    if (a) {
      const f = a.indexOf(t);
      f > 0 && (yield a[f - 1]), f < a.length - 1 && (yield a[f + 1]);
      return;
    }
    const c = n[t];
    if (c === -1)
      return;
    let u = c, l = -1;
    do {
      if (yield l = o[u], u = u % 3 === 2 ? u - 2 : u + 1, o[u] !== t)
        return;
      if (u = s[u], u === -1) {
        const f = i[(r[t] + 1) % i.length];
        f !== l && (yield f);
        return;
      }
    } while (u !== c);
  }
  find(t, n, i = 0) {
    if (t = +t, t !== t || (n = +n, n !== n))
      return -1;
    const r = i;
    let s;
    for (; (s = this._step(i, t, n)) >= 0 && s !== i && s !== r; )
      i = s;
    return s;
  }
  _step(t, n, i) {
    const { inedges: r, hull: s, _hullIndex: o, halfedges: a, triangles: c, points: u } = this;
    if (r[t] === -1 || !u.length)
      return (t + 1) % (u.length >> 1);
    let l = t, f = ys(n - u[t * 2], 2) + ys(i - u[t * 2 + 1], 2);
    const h = r[t];
    let d = h;
    do {
      let p = c[d];
      const g = ys(n - u[p * 2], 2) + ys(i - u[p * 2 + 1], 2);
      if (g < f && (f = g, l = p), d = d % 3 === 2 ? d - 2 : d + 1, c[d] !== t)
        break;
      if (d = a[d], d === -1) {
        if (d = s[(o[t] + 1) % s.length], d !== p && ys(n - u[d * 2], 2) + ys(i - u[d * 2 + 1], 2) < f)
          return d;
        break;
      }
    } while (d !== h);
    return l;
  }
  render(t) {
    const n = t == null ? t = new Pr() : void 0, { points: i, halfedges: r, triangles: s } = this;
    for (let o = 0, a = r.length; o < a; ++o) {
      const c = r[o];
      if (c < o)
        continue;
      const u = s[o] * 2, l = s[c] * 2;
      t.moveTo(i[u], i[u + 1]), t.lineTo(i[l], i[l + 1]);
    }
    return this.renderHull(t), n && n.value();
  }
  renderPoints(t, n) {
    n === void 0 && (!t || typeof t.moveTo != "function") && (n = t, t = null), n = n == null ? 2 : +n;
    const i = t == null ? t = new Pr() : void 0, { points: r } = this;
    for (let s = 0, o = r.length; s < o; s += 2) {
      const a = r[s], c = r[s + 1];
      t.moveTo(a + n, c), t.arc(a, c, n, 0, XE);
    }
    return i && i.value();
  }
  renderHull(t) {
    const n = t == null ? t = new Pr() : void 0, { hull: i, points: r } = this, s = i[0] * 2, o = i.length;
    t.moveTo(r[s], r[s + 1]);
    for (let a = 1; a < o; ++a) {
      const c = 2 * i[a];
      t.lineTo(r[c], r[c + 1]);
    }
    return t.closePath(), n && n.value();
  }
  hullPolygon() {
    const t = new Yd();
    return this.renderHull(t), t.value();
  }
  renderTriangle(t, n) {
    const i = n == null ? n = new Pr() : void 0, { points: r, triangles: s } = this, o = s[t *= 3] * 2, a = s[t + 1] * 2, c = s[t + 2] * 2;
    return n.moveTo(r[o], r[o + 1]), n.lineTo(r[a], r[a + 1]), n.lineTo(r[c], r[c + 1]), n.closePath(), i && i.value();
  }
  *trianglePolygons() {
    const { triangles: t } = this;
    for (let n = 0, i = t.length / 3; n < i; ++n)
      yield this.trianglePolygon(n);
  }
  trianglePolygon(t) {
    const n = new Yd();
    return this.renderTriangle(t, n), n.value();
  }
}
function KE(e, t, n, i) {
  const r = e.length, s = new Float64Array(r * 2);
  for (let o = 0; o < r; ++o) {
    const a = e[o];
    s[o * 2] = t.call(i, a, o, e), s[o * 2 + 1] = n.call(i, a, o, e);
  }
  return s;
}
function* JE(e, t, n, i) {
  let r = 0;
  for (const s of e)
    yield t.call(i, s, r, e), yield n.call(i, s, r, e), ++r;
}
function QE(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function Zu(e, t) {
  if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0)
    return null;
  var n, i = e.slice(0, n);
  return [
    i.length > 1 ? i[0] + i.slice(2) : i,
    +e.slice(n + 1)
  ];
}
function fo(e) {
  return e = Zu(Math.abs(e)), e ? e[1] : NaN;
}
function tN(e, t) {
  return function(n, i) {
    for (var r = n.length, s = [], o = 0, a = e[0], c = 0; r > 0 && a > 0 && (c + a + 1 > i && (a = Math.max(1, i - c)), s.push(n.substring(r -= a, r + a)), !((c += a + 1) > i)); )
      a = e[o = (o + 1) % e.length];
    return s.reverse().join(t);
  };
}
function eN(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var nN = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function Ea(e) {
  if (!(t = nN.exec(e)))
    throw new Error("invalid format: " + e);
  var t;
  return new Tp({
    fill: t[1],
    align: t[2],
    sign: t[3],
    symbol: t[4],
    zero: t[5],
    width: t[6],
    comma: t[7],
    precision: t[8] && t[8].slice(1),
    trim: t[9],
    type: t[10]
  });
}
Ea.prototype = Tp.prototype;
function Tp(e) {
  this.fill = e.fill === void 0 ? " " : e.fill + "", this.align = e.align === void 0 ? ">" : e.align + "", this.sign = e.sign === void 0 ? "-" : e.sign + "", this.symbol = e.symbol === void 0 ? "" : e.symbol + "", this.zero = !!e.zero, this.width = e.width === void 0 ? void 0 : +e.width, this.comma = !!e.comma, this.precision = e.precision === void 0 ? void 0 : +e.precision, this.trim = !!e.trim, this.type = e.type === void 0 ? "" : e.type + "";
}
Tp.prototype.toString = function() {
  return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
};
function iN(e) {
  t:
    for (var t = e.length, n = 1, i = -1, r; n < t; ++n)
      switch (e[n]) {
        case ".":
          i = r = n;
          break;
        case "0":
          i === 0 && (i = n), r = n;
          break;
        default:
          if (!+e[n])
            break t;
          i > 0 && (i = 0);
          break;
      }
  return i > 0 ? e.slice(0, i) + e.slice(r + 1) : e;
}
var u_;
function rN(e, t) {
  var n = Zu(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1], s = r - (u_ = Math.max(-8, Math.min(8, Math.floor(r / 3))) * 3) + 1, o = i.length;
  return s === o ? i : s > o ? i + new Array(s - o + 1).join("0") : s > 0 ? i.slice(0, s) + "." + i.slice(s) : "0." + new Array(1 - s).join("0") + Zu(e, Math.max(0, t + s - 1))[0];
}
function ug(e, t) {
  var n = Zu(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1];
  return r < 0 ? "0." + new Array(-r).join("0") + i : i.length > r + 1 ? i.slice(0, r + 1) + "." + i.slice(r + 1) : i + new Array(r - i.length + 2).join("0");
}
const lg = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: QE,
  e: (e, t) => e.toExponential(t),
  f: (e, t) => e.toFixed(t),
  g: (e, t) => e.toPrecision(t),
  o: (e) => Math.round(e).toString(8),
  p: (e, t) => ug(e * 100, t),
  r: ug,
  s: rN,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function fg(e) {
  return e;
}
var hg = Array.prototype.map, dg = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function sN(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? fg : tN(hg.call(e.grouping, Number), e.thousands + ""), n = e.currency === void 0 ? "" : e.currency[0] + "", i = e.currency === void 0 ? "" : e.currency[1] + "", r = e.decimal === void 0 ? "." : e.decimal + "", s = e.numerals === void 0 ? fg : eN(hg.call(e.numerals, String)), o = e.percent === void 0 ? "%" : e.percent + "", a = e.minus === void 0 ? "−" : e.minus + "", c = e.nan === void 0 ? "NaN" : e.nan + "";
  function u(f) {
    f = Ea(f);
    var h = f.fill, d = f.align, p = f.sign, g = f.symbol, y = f.zero, m = f.width, b = f.comma, w = f.precision, _ = f.trim, x = f.type;
    x === "n" ? (b = !0, x = "g") : lg[x] || (w === void 0 && (w = 12), _ = !0, x = "g"), (y || h === "0" && d === "=") && (y = !0, h = "0", d = "=");
    var S = g === "$" ? n : g === "#" && /[boxX]/.test(x) ? "0" + x.toLowerCase() : "", I = g === "$" ? i : /[%p]/.test(x) ? o : "", N = lg[x], F = /[defgprs%]/.test(x);
    w = w === void 0 ? 6 : /[gprs]/.test(x) ? Math.max(1, Math.min(21, w)) : Math.max(0, Math.min(20, w));
    function $(T) {
      var D = S, E = I, v, M, A;
      if (x === "c")
        E = N(T) + E, T = "";
      else {
        T = +T;
        var O = T < 0 || 1 / T < 0;
        if (T = isNaN(T) ? c : N(Math.abs(T), w), _ && (T = iN(T)), O && +T == 0 && p !== "+" && (O = !1), D = (O ? p === "(" ? p : a : p === "-" || p === "(" ? "" : p) + D, E = (x === "s" ? dg[8 + u_ / 3] : "") + E + (O && p === "(" ? ")" : ""), F) {
          for (v = -1, M = T.length; ++v < M; )
            if (A = T.charCodeAt(v), 48 > A || A > 57) {
              E = (A === 46 ? r + T.slice(v + 1) : T.slice(v)) + E, T = T.slice(0, v);
              break;
            }
        }
      }
      b && !y && (T = t(T, 1 / 0));
      var L = D.length + T.length + E.length, C = L < m ? new Array(m - L + 1).join(h) : "";
      switch (b && y && (T = t(C + T, C.length ? m - E.length : 1 / 0), C = ""), d) {
        case "<":
          T = D + T + E + C;
          break;
        case "=":
          T = D + C + T + E;
          break;
        case "^":
          T = C.slice(0, L = C.length >> 1) + D + T + E + C.slice(L);
          break;
        default:
          T = C + D + T + E;
          break;
      }
      return s(T);
    }
    return $.toString = function() {
      return f + "";
    }, $;
  }
  function l(f, h) {
    var d = u((f = Ea(f), f.type = "f", f)), p = Math.max(-8, Math.min(8, Math.floor(fo(h) / 3))) * 3, g = Math.pow(10, -p), y = dg[8 + p / 3];
    return function(m) {
      return d(g * m) + y;
    };
  }
  return {
    format: u,
    formatPrefix: l
  };
}
var $c, To, l_;
oN({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function oN(e) {
  return $c = sN(e), To = $c.format, l_ = $c.formatPrefix, $c;
}
function aN(e) {
  return Math.max(0, -fo(Math.abs(e)));
}
function cN(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(fo(t) / 3))) * 3 - fo(Math.abs(e)));
}
function uN(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, fo(t) - fo(e)) + 1;
}
var W = 1e-6, Ku = 1e-12, yt = Math.PI, Jt = yt / 2, pg = yt / 4, We = yt * 2, pe = 180 / yt, St = yt / 180, $t = Math.abs, Eo = Math.atan, En = Math.atan2, H = Math.cos, Ic = Math.ceil, f_ = Math.exp, qd = Math.hypot, Ju = Math.log, Nh = Math.pow, j = Math.sin, on = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, Oe = Math.sqrt, Ep = Math.tan;
function h_(e) {
  return e > 1 ? 0 : e < -1 ? yt : Math.acos(e);
}
function Re(e) {
  return e > 1 ? Jt : e < -1 ? -Jt : Math.asin(e);
}
function qe() {
}
function Qu(e, t) {
  e && yg.hasOwnProperty(e.type) && yg[e.type](e, t);
}
var mg = {
  Feature: function(e, t) {
    Qu(e.geometry, t);
  },
  FeatureCollection: function(e, t) {
    for (var n = e.features, i = -1, r = n.length; ++i < r; )
      Qu(n[i].geometry, t);
  }
}, yg = {
  Sphere: function(e, t) {
    t.sphere();
  },
  Point: function(e, t) {
    e = e.coordinates, t.point(e[0], e[1], e[2]);
  },
  MultiPoint: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      e = n[i], t.point(e[0], e[1], e[2]);
  },
  LineString: function(e, t) {
    Vd(e.coordinates, t, 0);
  },
  MultiLineString: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      Vd(n[i], t, 0);
  },
  Polygon: function(e, t) {
    gg(e.coordinates, t);
  },
  MultiPolygon: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      gg(n[i], t);
  },
  GeometryCollection: function(e, t) {
    for (var n = e.geometries, i = -1, r = n.length; ++i < r; )
      Qu(n[i], t);
  }
};
function Vd(e, t, n) {
  var i = -1, r = e.length - n, s;
  for (t.lineStart(); ++i < r; )
    s = e[i], t.point(s[0], s[1], s[2]);
  t.lineEnd();
}
function gg(e, t) {
  var n = -1, i = e.length;
  for (t.polygonStart(); ++n < i; )
    Vd(e[n], t, 1);
  t.polygonEnd();
}
function Fr(e, t) {
  e && mg.hasOwnProperty(e.type) ? mg[e.type](e, t) : Qu(e, t);
}
function jd(e) {
  return [En(e[1], e[0]), Re(e[2])];
}
function ho(e) {
  var t = e[0], n = e[1], i = H(n);
  return [i * H(t), i * j(t), j(n)];
}
function Tc(e, t) {
  return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
}
function tl(e, t) {
  return [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]];
}
function Oh(e, t) {
  e[0] += t[0], e[1] += t[1], e[2] += t[2];
}
function Ec(e, t) {
  return [e[0] * t, e[1] * t, e[2] * t];
}
function Xd(e) {
  var t = Oe(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= t, e[1] /= t, e[2] /= t;
}
var ta, el, nl, il, rl, sl, ol, al, Wd, Hd, Gd, d_, p_, $e, Ie, Te, xn = {
  sphere: qe,
  point: Np,
  lineStart: bg,
  lineEnd: wg,
  polygonStart: function() {
    xn.lineStart = hN, xn.lineEnd = dN;
  },
  polygonEnd: function() {
    xn.lineStart = bg, xn.lineEnd = wg;
  }
};
function Np(e, t) {
  e *= St, t *= St;
  var n = H(t);
  Qa(n * H(e), n * j(e), j(t));
}
function Qa(e, t, n) {
  ++ta, nl += (e - nl) / ta, il += (t - il) / ta, rl += (n - rl) / ta;
}
function bg() {
  xn.point = lN;
}
function lN(e, t) {
  e *= St, t *= St;
  var n = H(t);
  $e = n * H(e), Ie = n * j(e), Te = j(t), xn.point = fN, Qa($e, Ie, Te);
}
function fN(e, t) {
  e *= St, t *= St;
  var n = H(t), i = n * H(e), r = n * j(e), s = j(t), o = En(Oe((o = Ie * s - Te * r) * o + (o = Te * i - $e * s) * o + (o = $e * r - Ie * i) * o), $e * i + Ie * r + Te * s);
  el += o, sl += o * ($e + ($e = i)), ol += o * (Ie + (Ie = r)), al += o * (Te + (Te = s)), Qa($e, Ie, Te);
}
function wg() {
  xn.point = Np;
}
function hN() {
  xn.point = pN;
}
function dN() {
  m_(d_, p_), xn.point = Np;
}
function pN(e, t) {
  d_ = e, p_ = t, e *= St, t *= St, xn.point = m_;
  var n = H(t);
  $e = n * H(e), Ie = n * j(e), Te = j(t), Qa($e, Ie, Te);
}
function m_(e, t) {
  e *= St, t *= St;
  var n = H(t), i = n * H(e), r = n * j(e), s = j(t), o = Ie * s - Te * r, a = Te * i - $e * s, c = $e * r - Ie * i, u = qd(o, a, c), l = Re(u), f = u && -l / u;
  Wd.add(f * o), Hd.add(f * a), Gd.add(f * c), el += l, sl += l * ($e + ($e = i)), ol += l * (Ie + (Ie = r)), al += l * (Te + (Te = s)), Qa($e, Ie, Te);
}
function mN(e) {
  ta = el = nl = il = rl = sl = ol = al = 0, Wd = new Gn(), Hd = new Gn(), Gd = new Gn(), Fr(e, xn);
  var t = +Wd, n = +Hd, i = +Gd, r = qd(t, n, i);
  return r < Ku && (t = sl, n = ol, i = al, el < W && (t = nl, n = il, i = rl), r = qd(t, n, i), r < Ku) ? [NaN, NaN] : [En(n, t) * pe, Re(i / r) * pe];
}
function Zd(e, t) {
  function n(i, r) {
    return i = e(i, r), t(i[0], i[1]);
  }
  return e.invert && t.invert && (n.invert = function(i, r) {
    return i = t.invert(i, r), i && e.invert(i[0], i[1]);
  }), n;
}
function Kd(e, t) {
  return $t(e) > yt && (e -= Math.round(e / We) * We), [e, t];
}
Kd.invert = Kd;
function y_(e, t, n) {
  return (e %= We) ? t || n ? Zd(vg(e), xg(t, n)) : vg(e) : t || n ? xg(t, n) : Kd;
}
function _g(e) {
  return function(t, n) {
    return t += e, $t(t) > yt && (t -= Math.round(t / We) * We), [t, n];
  };
}
function vg(e) {
  var t = _g(e);
  return t.invert = _g(-e), t;
}
function xg(e, t) {
  var n = H(e), i = j(e), r = H(t), s = j(t);
  function o(a, c) {
    var u = H(c), l = H(a) * u, f = j(a) * u, h = j(c), d = h * n + l * i;
    return [
      En(f * r - d * s, l * n - h * i),
      Re(d * r + f * s)
    ];
  }
  return o.invert = function(a, c) {
    var u = H(c), l = H(a) * u, f = j(a) * u, h = j(c), d = h * r - f * s;
    return [
      En(f * r + h * s, l * n + d * i),
      Re(d * n - l * i)
    ];
  }, o;
}
function yN(e) {
  e = y_(e[0] * St, e[1] * St, e.length > 2 ? e[2] * St : 0);
  function t(n) {
    return n = e(n[0] * St, n[1] * St), n[0] *= pe, n[1] *= pe, n;
  }
  return t.invert = function(n) {
    return n = e.invert(n[0] * St, n[1] * St), n[0] *= pe, n[1] *= pe, n;
  }, t;
}
function gN(e, t, n, i, r, s) {
  if (n) {
    var o = H(t), a = j(t), c = i * n;
    r == null ? (r = t + i * We, s = t - c / 2) : (r = Sg(o, r), s = Sg(o, s), (i > 0 ? r < s : r > s) && (r += i * We));
    for (var u, l = r; i > 0 ? l > s : l < s; l -= c)
      u = jd([o, -a * H(l), -a * j(l)]), e.point(u[0], u[1]);
  }
}
function Sg(e, t) {
  t = ho(t), t[0] -= e, Xd(t);
  var n = h_(-t[1]);
  return ((-t[2] < 0 ? -n : n) + We - W) % We;
}
function g_() {
  var e = [], t;
  return {
    point: function(n, i, r) {
      t.push([n, i, r]);
    },
    lineStart: function() {
      e.push(t = []);
    },
    lineEnd: qe,
    rejoin: function() {
      e.length > 1 && e.push(e.pop().concat(e.shift()));
    },
    result: function() {
      var n = e;
      return e = [], t = null, n;
    }
  };
}
function su(e, t) {
  return $t(e[0] - t[0]) < W && $t(e[1] - t[1]) < W;
}
function Nc(e, t, n, i) {
  this.x = e, this.z = t, this.o = n, this.e = i, this.v = !1, this.n = this.p = null;
}
function b_(e, t, n, i, r) {
  var s = [], o = [], a, c;
  if (e.forEach(function(p) {
    if (!((g = p.length - 1) <= 0)) {
      var g, y = p[0], m = p[g], b;
      if (su(y, m)) {
        if (!y[2] && !m[2]) {
          for (r.lineStart(), a = 0; a < g; ++a)
            r.point((y = p[a])[0], y[1]);
          r.lineEnd();
          return;
        }
        m[0] += 2 * W;
      }
      s.push(b = new Nc(y, p, null, !0)), o.push(b.o = new Nc(y, null, b, !1)), s.push(b = new Nc(m, p, null, !1)), o.push(b.o = new Nc(m, null, b, !0));
    }
  }), !!s.length) {
    for (o.sort(t), Mg(s), Mg(o), a = 0, c = o.length; a < c; ++a)
      o[a].e = n = !n;
    for (var u = s[0], l, f; ; ) {
      for (var h = u, d = !0; h.v; )
        if ((h = h.n) === u)
          return;
      l = h.z, r.lineStart();
      do {
        if (h.v = h.o.v = !0, h.e) {
          if (d)
            for (a = 0, c = l.length; a < c; ++a)
              r.point((f = l[a])[0], f[1]);
          else
            i(h.x, h.n.x, 1, r);
          h = h.n;
        } else {
          if (d)
            for (l = h.p.z, a = l.length - 1; a >= 0; --a)
              r.point((f = l[a])[0], f[1]);
          else
            i(h.x, h.p.x, -1, r);
          h = h.p;
        }
        h = h.o, l = h.z, d = !d;
      } while (!h.v);
      r.lineEnd();
    }
  }
}
function Mg(e) {
  if (t = e.length) {
    for (var t, n = 0, i = e[0], r; ++n < t; )
      i.n = r = e[n], r.p = i, i = r;
    i.n = r = e[0], r.p = i;
  }
}
function Fh(e) {
  return $t(e[0]) <= yt ? e[0] : on(e[0]) * (($t(e[0]) + yt) % We - yt);
}
function bN(e, t) {
  var n = Fh(t), i = t[1], r = j(i), s = [j(n), -H(n), 0], o = 0, a = 0, c = new Gn();
  r === 1 ? i = Jt + W : r === -1 && (i = -Jt - W);
  for (var u = 0, l = e.length; u < l; ++u)
    if (h = (f = e[u]).length)
      for (var f, h, d = f[h - 1], p = Fh(d), g = d[1] / 2 + pg, y = j(g), m = H(g), b = 0; b < h; ++b, p = _, y = S, m = I, d = w) {
        var w = f[b], _ = Fh(w), x = w[1] / 2 + pg, S = j(x), I = H(x), N = _ - p, F = N >= 0 ? 1 : -1, $ = F * N, T = $ > yt, D = y * S;
        if (c.add(En(D * F * j($), m * I + D * H($))), o += T ? N + F * We : N, T ^ p >= n ^ _ >= n) {
          var E = tl(ho(d), ho(w));
          Xd(E);
          var v = tl(s, E);
          Xd(v);
          var M = (T ^ N >= 0 ? -1 : 1) * Re(v[2]);
          (i > M || i === M && (E[0] || E[1])) && (a += T ^ N >= 0 ? 1 : -1);
        }
      }
  return (o < -W || o < W && c < -Ku) ^ a & 1;
}
function w_(e, t, n, i) {
  return function(r) {
    var s = t(r), o = g_(), a = t(o), c = !1, u, l, f, h = {
      point: d,
      lineStart: g,
      lineEnd: y,
      polygonStart: function() {
        h.point = m, h.lineStart = b, h.lineEnd = w, l = [], u = [];
      },
      polygonEnd: function() {
        h.point = d, h.lineStart = g, h.lineEnd = y, l = vw(l);
        var _ = bN(u, i);
        l.length ? (c || (r.polygonStart(), c = !0), b_(l, _N, _, n, r)) : _ && (c || (r.polygonStart(), c = !0), r.lineStart(), n(null, null, 1, r), r.lineEnd()), c && (r.polygonEnd(), c = !1), l = u = null;
      },
      sphere: function() {
        r.polygonStart(), r.lineStart(), n(null, null, 1, r), r.lineEnd(), r.polygonEnd();
      }
    };
    function d(_, x) {
      e(_, x) && r.point(_, x);
    }
    function p(_, x) {
      s.point(_, x);
    }
    function g() {
      h.point = p, s.lineStart();
    }
    function y() {
      h.point = d, s.lineEnd();
    }
    function m(_, x) {
      f.push([_, x]), a.point(_, x);
    }
    function b() {
      a.lineStart(), f = [];
    }
    function w() {
      m(f[0][0], f[0][1]), a.lineEnd();
      var _ = a.clean(), x = o.result(), S, I = x.length, N, F, $;
      if (f.pop(), u.push(f), f = null, !!I) {
        if (_ & 1) {
          if (F = x[0], (N = F.length - 1) > 0) {
            for (c || (r.polygonStart(), c = !0), r.lineStart(), S = 0; S < N; ++S)
              r.point(($ = F[S])[0], $[1]);
            r.lineEnd();
          }
          return;
        }
        I > 1 && _ & 2 && x.push(x.pop().concat(x.shift())), l.push(x.filter(wN));
      }
    }
    return h;
  };
}
function wN(e) {
  return e.length > 1;
}
function _N(e, t) {
  return ((e = e.x)[0] < 0 ? e[1] - Jt - W : Jt - e[1]) - ((t = t.x)[0] < 0 ? t[1] - Jt - W : Jt - t[1]);
}
const Ag = w_(
  function() {
    return !0;
  },
  vN,
  SN,
  [-yt, -Jt]
);
function vN(e) {
  var t = NaN, n = NaN, i = NaN, r;
  return {
    lineStart: function() {
      e.lineStart(), r = 1;
    },
    point: function(s, o) {
      var a = s > 0 ? yt : -yt, c = $t(s - t);
      $t(c - yt) < W ? (e.point(t, n = (n + o) / 2 > 0 ? Jt : -Jt), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), e.point(s, n), r = 0) : i !== a && c >= yt && ($t(t - i) < W && (t -= i * W), $t(s - a) < W && (s -= a * W), n = xN(t, n, s, o), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), r = 0), e.point(t = s, n = o), i = a;
    },
    lineEnd: function() {
      e.lineEnd(), t = n = NaN;
    },
    clean: function() {
      return 2 - r;
    }
  };
}
function xN(e, t, n, i) {
  var r, s, o = j(e - n);
  return $t(o) > W ? Eo((j(t) * (s = H(i)) * j(n) - j(i) * (r = H(t)) * j(e)) / (r * s * o)) : (t + i) / 2;
}
function SN(e, t, n, i) {
  var r;
  if (e == null)
    r = n * Jt, i.point(-yt, r), i.point(0, r), i.point(yt, r), i.point(yt, 0), i.point(yt, -r), i.point(0, -r), i.point(-yt, -r), i.point(-yt, 0), i.point(-yt, r);
  else if ($t(e[0] - t[0]) > W) {
    var s = e[0] < t[0] ? yt : -yt;
    r = n * s / 2, i.point(-s, r), i.point(0, r), i.point(s, r);
  } else
    i.point(t[0], t[1]);
}
function MN(e) {
  var t = H(e), n = 6 * St, i = t > 0, r = $t(t) > W;
  function s(l, f, h, d) {
    gN(d, e, n, h, l, f);
  }
  function o(l, f) {
    return H(l) * H(f) > t;
  }
  function a(l) {
    var f, h, d, p, g;
    return {
      lineStart: function() {
        p = d = !1, g = 1;
      },
      point: function(y, m) {
        var b = [y, m], w, _ = o(y, m), x = i ? _ ? 0 : u(y, m) : _ ? u(y + (y < 0 ? yt : -yt), m) : 0;
        if (!f && (p = d = _) && l.lineStart(), _ !== d && (w = c(f, b), (!w || su(f, w) || su(b, w)) && (b[2] = 1)), _ !== d)
          g = 0, _ ? (l.lineStart(), w = c(b, f), l.point(w[0], w[1])) : (w = c(f, b), l.point(w[0], w[1], 2), l.lineEnd()), f = w;
        else if (r && f && i ^ _) {
          var S;
          !(x & h) && (S = c(b, f, !0)) && (g = 0, i ? (l.lineStart(), l.point(S[0][0], S[0][1]), l.point(S[1][0], S[1][1]), l.lineEnd()) : (l.point(S[1][0], S[1][1]), l.lineEnd(), l.lineStart(), l.point(S[0][0], S[0][1], 3)));
        }
        _ && (!f || !su(f, b)) && l.point(b[0], b[1]), f = b, d = _, h = x;
      },
      lineEnd: function() {
        d && l.lineEnd(), f = null;
      },
      // Rejoin first and last segments if there were intersections and the first
      // and last points were visible.
      clean: function() {
        return g | (p && d) << 1;
      }
    };
  }
  function c(l, f, h) {
    var d = ho(l), p = ho(f), g = [1, 0, 0], y = tl(d, p), m = Tc(y, y), b = y[0], w = m - b * b;
    if (!w)
      return !h && l;
    var _ = t * m / w, x = -t * b / w, S = tl(g, y), I = Ec(g, _), N = Ec(y, x);
    Oh(I, N);
    var F = S, $ = Tc(I, F), T = Tc(F, F), D = $ * $ - T * (Tc(I, I) - 1);
    if (!(D < 0)) {
      var E = Oe(D), v = Ec(F, (-$ - E) / T);
      if (Oh(v, I), v = jd(v), !h)
        return v;
      var M = l[0], A = f[0], O = l[1], L = f[1], C;
      A < M && (C = M, M = A, A = C);
      var k = A - M, R = $t(k - yt) < W, z = R || k < W;
      if (!R && L < O && (C = O, O = L, L = C), z ? R ? O + L > 0 ^ v[1] < ($t(v[0] - M) < W ? O : L) : O <= v[1] && v[1] <= L : k > yt ^ (M <= v[0] && v[0] <= A)) {
        var G = Ec(F, (-$ + E) / T);
        return Oh(G, I), [v, jd(G)];
      }
    }
  }
  function u(l, f) {
    var h = i ? e : yt - e, d = 0;
    return l < -h ? d |= 1 : l > h && (d |= 2), f < -h ? d |= 4 : f > h && (d |= 8), d;
  }
  return w_(o, a, s, i ? [0, -e] : [-yt, e - yt]);
}
function AN(e, t, n, i, r, s) {
  var o = e[0], a = e[1], c = t[0], u = t[1], l = 0, f = 1, h = c - o, d = u - a, p;
  if (p = n - o, !(!h && p > 0)) {
    if (p /= h, h < 0) {
      if (p < l)
        return;
      p < f && (f = p);
    } else if (h > 0) {
      if (p > f)
        return;
      p > l && (l = p);
    }
    if (p = r - o, !(!h && p < 0)) {
      if (p /= h, h < 0) {
        if (p > f)
          return;
        p > l && (l = p);
      } else if (h > 0) {
        if (p < l)
          return;
        p < f && (f = p);
      }
      if (p = i - a, !(!d && p > 0)) {
        if (p /= d, d < 0) {
          if (p < l)
            return;
          p < f && (f = p);
        } else if (d > 0) {
          if (p > f)
            return;
          p > l && (l = p);
        }
        if (p = s - a, !(!d && p < 0)) {
          if (p /= d, d < 0) {
            if (p > f)
              return;
            p > l && (l = p);
          } else if (d > 0) {
            if (p < l)
              return;
            p < f && (f = p);
          }
          return l > 0 && (e[0] = o + l * h, e[1] = a + l * d), f < 1 && (t[0] = o + f * h, t[1] = a + f * d), !0;
        }
      }
    }
  }
}
var ea = 1e9, Oc = -ea;
function __(e, t, n, i) {
  function r(u, l) {
    return e <= u && u <= n && t <= l && l <= i;
  }
  function s(u, l, f, h) {
    var d = 0, p = 0;
    if (u == null || (d = o(u, f)) !== (p = o(l, f)) || c(u, l) < 0 ^ f > 0)
      do
        h.point(d === 0 || d === 3 ? e : n, d > 1 ? i : t);
      while ((d = (d + f + 4) % 4) !== p);
    else
      h.point(l[0], l[1]);
  }
  function o(u, l) {
    return $t(u[0] - e) < W ? l > 0 ? 0 : 3 : $t(u[0] - n) < W ? l > 0 ? 2 : 1 : $t(u[1] - t) < W ? l > 0 ? 1 : 0 : l > 0 ? 3 : 2;
  }
  function a(u, l) {
    return c(u.x, l.x);
  }
  function c(u, l) {
    var f = o(u, 1), h = o(l, 1);
    return f !== h ? f - h : f === 0 ? l[1] - u[1] : f === 1 ? u[0] - l[0] : f === 2 ? u[1] - l[1] : l[0] - u[0];
  }
  return function(u) {
    var l = u, f = g_(), h, d, p, g, y, m, b, w, _, x, S, I = {
      point: N,
      lineStart: D,
      lineEnd: E,
      polygonStart: $,
      polygonEnd: T
    };
    function N(M, A) {
      r(M, A) && l.point(M, A);
    }
    function F() {
      for (var M = 0, A = 0, O = d.length; A < O; ++A)
        for (var L = d[A], C = 1, k = L.length, R = L[0], z, G, Z = R[0], pt = R[1]; C < k; ++C)
          z = Z, G = pt, R = L[C], Z = R[0], pt = R[1], G <= i ? pt > i && (Z - z) * (i - G) > (pt - G) * (e - z) && ++M : pt <= i && (Z - z) * (i - G) < (pt - G) * (e - z) && --M;
      return M;
    }
    function $() {
      l = f, h = [], d = [], S = !0;
    }
    function T() {
      var M = F(), A = S && M, O = (h = vw(h)).length;
      (A || O) && (u.polygonStart(), A && (u.lineStart(), s(null, null, 1, u), u.lineEnd()), O && b_(h, a, M, s, u), u.polygonEnd()), l = u, h = d = p = null;
    }
    function D() {
      I.point = v, d && d.push(p = []), x = !0, _ = !1, b = w = NaN;
    }
    function E() {
      h && (v(g, y), m && _ && f.rejoin(), h.push(f.result())), I.point = N, _ && l.lineEnd();
    }
    function v(M, A) {
      var O = r(M, A);
      if (d && p.push([M, A]), x)
        g = M, y = A, m = O, x = !1, O && (l.lineStart(), l.point(M, A));
      else if (O && _)
        l.point(M, A);
      else {
        var L = [b = Math.max(Oc, Math.min(ea, b)), w = Math.max(Oc, Math.min(ea, w))], C = [M = Math.max(Oc, Math.min(ea, M)), A = Math.max(Oc, Math.min(ea, A))];
        AN(L, C, e, t, n, i) ? (_ || (l.lineStart(), l.point(L[0], L[1])), l.point(C[0], C[1]), O || l.lineEnd(), S = !1) : O && (l.lineStart(), l.point(M, A), S = !1);
      }
      b = M, w = A, _ = O;
    }
    return I;
  };
}
function $g(e, t, n) {
  var i = sn(e, t - W, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [r, s];
    });
  };
}
function Ig(e, t, n) {
  var i = sn(e, t - W, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [s, r];
    });
  };
}
function $N() {
  var e, t, n, i, r, s, o, a, c = 10, u = c, l = 90, f = 360, h, d, p, g, y = 2.5;
  function m() {
    return { type: "MultiLineString", coordinates: b() };
  }
  function b() {
    return sn(Ic(i / l) * l, n, l).map(p).concat(sn(Ic(a / f) * f, o, f).map(g)).concat(sn(Ic(t / c) * c, e, c).filter(function(w) {
      return $t(w % l) > W;
    }).map(h)).concat(sn(Ic(s / u) * u, r, u).filter(function(w) {
      return $t(w % f) > W;
    }).map(d));
  }
  return m.lines = function() {
    return b().map(function(w) {
      return { type: "LineString", coordinates: w };
    });
  }, m.outline = function() {
    return {
      type: "Polygon",
      coordinates: [
        p(i).concat(
          g(o).slice(1),
          p(n).reverse().slice(1),
          g(a).reverse().slice(1)
        )
      ]
    };
  }, m.extent = function(w) {
    return arguments.length ? m.extentMajor(w).extentMinor(w) : m.extentMinor();
  }, m.extentMajor = function(w) {
    return arguments.length ? (i = +w[0][0], n = +w[1][0], a = +w[0][1], o = +w[1][1], i > n && (w = i, i = n, n = w), a > o && (w = a, a = o, o = w), m.precision(y)) : [[i, a], [n, o]];
  }, m.extentMinor = function(w) {
    return arguments.length ? (t = +w[0][0], e = +w[1][0], s = +w[0][1], r = +w[1][1], t > e && (w = t, t = e, e = w), s > r && (w = s, s = r, r = w), m.precision(y)) : [[t, s], [e, r]];
  }, m.step = function(w) {
    return arguments.length ? m.stepMajor(w).stepMinor(w) : m.stepMinor();
  }, m.stepMajor = function(w) {
    return arguments.length ? (l = +w[0], f = +w[1], m) : [l, f];
  }, m.stepMinor = function(w) {
    return arguments.length ? (c = +w[0], u = +w[1], m) : [c, u];
  }, m.precision = function(w) {
    return arguments.length ? (y = +w, h = $g(s, r, 90), d = Ig(t, e, y), p = $g(a, o, 90), g = Ig(i, n, y), m) : y;
  }, m.extentMajor([[-180, -90 + W], [180, 90 - W]]).extentMinor([[-180, -80 - W], [180, 80 + W]]);
}
function IN() {
  return $N()();
}
const Jd = (e) => e;
var Dh = new Gn(), Qd = new Gn(), v_, x_, t0, e0, Gi = {
  point: qe,
  lineStart: qe,
  lineEnd: qe,
  polygonStart: function() {
    Gi.lineStart = TN, Gi.lineEnd = NN;
  },
  polygonEnd: function() {
    Gi.lineStart = Gi.lineEnd = Gi.point = qe, Dh.add($t(Qd)), Qd = new Gn();
  },
  result: function() {
    var e = Dh / 2;
    return Dh = new Gn(), e;
  }
};
function TN() {
  Gi.point = EN;
}
function EN(e, t) {
  Gi.point = S_, v_ = t0 = e, x_ = e0 = t;
}
function S_(e, t) {
  Qd.add(e0 * e - t0 * t), t0 = e, e0 = t;
}
function NN() {
  S_(v_, x_);
}
const Tg = Gi;
var po = 1 / 0, cl = po, Na = -po, ul = Na, ON = {
  point: FN,
  lineStart: qe,
  lineEnd: qe,
  polygonStart: qe,
  polygonEnd: qe,
  result: function() {
    var e = [[po, cl], [Na, ul]];
    return Na = ul = -(cl = po = 1 / 0), e;
  }
};
function FN(e, t) {
  e < po && (po = e), e > Na && (Na = e), t < cl && (cl = t), t > ul && (ul = t);
}
const ll = ON;
var n0 = 0, i0 = 0, na = 0, fl = 0, hl = 0, Es = 0, r0 = 0, s0 = 0, ia = 0, M_, A_, Vn, jn, vn = {
  point: ts,
  lineStart: Eg,
  lineEnd: Ng,
  polygonStart: function() {
    vn.lineStart = LN, vn.lineEnd = CN;
  },
  polygonEnd: function() {
    vn.point = ts, vn.lineStart = Eg, vn.lineEnd = Ng;
  },
  result: function() {
    var e = ia ? [r0 / ia, s0 / ia] : Es ? [fl / Es, hl / Es] : na ? [n0 / na, i0 / na] : [NaN, NaN];
    return n0 = i0 = na = fl = hl = Es = r0 = s0 = ia = 0, e;
  }
};
function ts(e, t) {
  n0 += e, i0 += t, ++na;
}
function Eg() {
  vn.point = DN;
}
function DN(e, t) {
  vn.point = BN, ts(Vn = e, jn = t);
}
function BN(e, t) {
  var n = e - Vn, i = t - jn, r = Oe(n * n + i * i);
  fl += r * (Vn + e) / 2, hl += r * (jn + t) / 2, Es += r, ts(Vn = e, jn = t);
}
function Ng() {
  vn.point = ts;
}
function LN() {
  vn.point = kN;
}
function CN() {
  $_(M_, A_);
}
function kN(e, t) {
  vn.point = $_, ts(M_ = Vn = e, A_ = jn = t);
}
function $_(e, t) {
  var n = e - Vn, i = t - jn, r = Oe(n * n + i * i);
  fl += r * (Vn + e) / 2, hl += r * (jn + t) / 2, Es += r, r = jn * e - Vn * t, r0 += r * (Vn + e), s0 += r * (jn + t), ia += r * 3, ts(Vn = e, jn = t);
}
const Og = vn;
function I_(e) {
  this._context = e;
}
I_.prototype = {
  _radius: 4.5,
  pointRadius: function(e) {
    return this._radius = e, this;
  },
  polygonStart: function() {
    this._line = 0;
  },
  polygonEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._point = 0;
  },
  lineEnd: function() {
    this._line === 0 && this._context.closePath(), this._point = NaN;
  },
  point: function(e, t) {
    switch (this._point) {
      case 0: {
        this._context.moveTo(e, t), this._point = 1;
        break;
      }
      case 1: {
        this._context.lineTo(e, t);
        break;
      }
      default: {
        this._context.moveTo(e + this._radius, t), this._context.arc(e, t, this._radius, 0, We);
        break;
      }
    }
  },
  result: qe
};
var o0 = new Gn(), Bh, T_, E_, ra, sa, dl = {
  point: qe,
  lineStart: function() {
    dl.point = RN;
  },
  lineEnd: function() {
    Bh && N_(T_, E_), dl.point = qe;
  },
  polygonStart: function() {
    Bh = !0;
  },
  polygonEnd: function() {
    Bh = null;
  },
  result: function() {
    var e = +o0;
    return o0 = new Gn(), e;
  }
};
function RN(e, t) {
  dl.point = N_, T_ = ra = e, E_ = sa = t;
}
function N_(e, t) {
  ra -= e, sa -= t, o0.add(Oe(ra * ra + sa * sa)), ra = e, sa = t;
}
const Fg = dl;
let Dg, pl, Bg, Lg;
class Cg {
  constructor(t) {
    this._append = t == null ? O_ : UN(t), this._radius = 4.5, this._ = "";
  }
  pointRadius(t) {
    return this._radius = +t, this;
  }
  polygonStart() {
    this._line = 0;
  }
  polygonEnd() {
    this._line = NaN;
  }
  lineStart() {
    this._point = 0;
  }
  lineEnd() {
    this._line === 0 && (this._ += "Z"), this._point = NaN;
  }
  point(t, n) {
    switch (this._point) {
      case 0: {
        this._append`M${t},${n}`, this._point = 1;
        break;
      }
      case 1: {
        this._append`L${t},${n}`;
        break;
      }
      default: {
        if (this._append`M${t},${n}`, this._radius !== Bg || this._append !== pl) {
          const i = this._radius, r = this._;
          this._ = "", this._append`m0,${i}a${i},${i} 0 1,1 0,${-2 * i}a${i},${i} 0 1,1 0,${2 * i}z`, Bg = i, pl = this._append, Lg = this._, this._ = r;
        }
        this._ += Lg;
        break;
      }
    }
  }
  result() {
    const t = this._;
    return this._ = "", t.length ? t : null;
  }
}
function O_(e) {
  let t = 1;
  this._ += e[0];
  for (const n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function UN(e) {
  const t = Math.floor(e);
  if (!(t >= 0))
    throw new RangeError(`invalid digits: ${e}`);
  if (t > 15)
    return O_;
  if (t !== Dg) {
    const n = 10 ** t;
    Dg = t, pl = function(r) {
      let s = 1;
      this._ += r[0];
      for (const o = r.length; s < o; ++s)
        this._ += Math.round(arguments[s] * n) / n + r[s];
    };
  }
  return pl;
}
function rs(e, t) {
  let n = 3, i = 4.5, r, s;
  function o(a) {
    return a && (typeof i == "function" && s.pointRadius(+i.apply(this, arguments)), Fr(a, r(s))), s.result();
  }
  return o.area = function(a) {
    return Fr(a, r(Tg)), Tg.result();
  }, o.measure = function(a) {
    return Fr(a, r(Fg)), Fg.result();
  }, o.bounds = function(a) {
    return Fr(a, r(ll)), ll.result();
  }, o.centroid = function(a) {
    return Fr(a, r(Og)), Og.result();
  }, o.projection = function(a) {
    return arguments.length ? (r = a == null ? (e = null, Jd) : (e = a).stream, o) : e;
  }, o.context = function(a) {
    return arguments.length ? (s = a == null ? (t = null, new Cg(n)) : new I_(t = a), typeof i != "function" && s.pointRadius(i), o) : t;
  }, o.pointRadius = function(a) {
    return arguments.length ? (i = typeof a == "function" ? a : (s.pointRadius(+a), +a), o) : i;
  }, o.digits = function(a) {
    if (!arguments.length)
      return n;
    if (a == null)
      n = null;
    else {
      const c = Math.floor(a);
      if (!(c >= 0))
        throw new RangeError(`invalid digits: ${a}`);
      n = c;
    }
    return t === null && (s = new Cg(n)), o;
  }, o.projection(e).digits(n).context(t);
}
function ml(e) {
  return {
    stream: uf(e)
  };
}
function uf(e) {
  return function(t) {
    var n = new a0();
    for (var i in e)
      n[i] = e[i];
    return n.stream = t, n;
  };
}
function a0() {
}
a0.prototype = {
  constructor: a0,
  point: function(e, t) {
    this.stream.point(e, t);
  },
  sphere: function() {
    this.stream.sphere();
  },
  lineStart: function() {
    this.stream.lineStart();
  },
  lineEnd: function() {
    this.stream.lineEnd();
  },
  polygonStart: function() {
    this.stream.polygonStart();
  },
  polygonEnd: function() {
    this.stream.polygonEnd();
  }
};
function Op(e, t, n) {
  var i = e.clipExtent && e.clipExtent();
  return e.scale(150).translate([0, 0]), i != null && e.clipExtent(null), Fr(n, e.stream(ll)), t(ll.result()), i != null && e.clipExtent(i), e;
}
function Fp(e, t, n) {
  return Op(e, function(i) {
    var r = t[1][0] - t[0][0], s = t[1][1] - t[0][1], o = Math.min(r / (i[1][0] - i[0][0]), s / (i[1][1] - i[0][1])), a = +t[0][0] + (r - o * (i[1][0] + i[0][0])) / 2, c = +t[0][1] + (s - o * (i[1][1] + i[0][1])) / 2;
    e.scale(150 * o).translate([a, c]);
  }, n);
}
function F_(e, t, n) {
  return Fp(e, [[0, 0], t], n);
}
function D_(e, t, n) {
  return Op(e, function(i) {
    var r = +t, s = r / (i[1][0] - i[0][0]), o = (r - s * (i[1][0] + i[0][0])) / 2, a = -s * i[0][1];
    e.scale(150 * s).translate([o, a]);
  }, n);
}
function B_(e, t, n) {
  return Op(e, function(i) {
    var r = +t, s = r / (i[1][1] - i[0][1]), o = -s * i[0][0], a = (r - s * (i[1][1] + i[0][1])) / 2;
    e.scale(150 * s).translate([o, a]);
  }, n);
}
var kg = 16, zN = H(30 * St);
function Rg(e, t) {
  return +t ? YN(e, t) : PN(e);
}
function PN(e) {
  return uf({
    point: function(t, n) {
      t = e(t, n), this.stream.point(t[0], t[1]);
    }
  });
}
function YN(e, t) {
  function n(i, r, s, o, a, c, u, l, f, h, d, p, g, y) {
    var m = u - i, b = l - r, w = m * m + b * b;
    if (w > 4 * t && g--) {
      var _ = o + h, x = a + d, S = c + p, I = Oe(_ * _ + x * x + S * S), N = Re(S /= I), F = $t($t(S) - 1) < W || $t(s - f) < W ? (s + f) / 2 : En(x, _), $ = e(F, N), T = $[0], D = $[1], E = T - i, v = D - r, M = b * E - m * v;
      (M * M / w > t || $t((m * E + b * v) / w - 0.5) > 0.3 || o * h + a * d + c * p < zN) && (n(i, r, s, o, a, c, T, D, F, _ /= I, x /= I, S, g, y), y.point(T, D), n(T, D, F, _, x, S, u, l, f, h, d, p, g, y));
    }
  }
  return function(i) {
    var r, s, o, a, c, u, l, f, h, d, p, g, y = {
      point: m,
      lineStart: b,
      lineEnd: _,
      polygonStart: function() {
        i.polygonStart(), y.lineStart = x;
      },
      polygonEnd: function() {
        i.polygonEnd(), y.lineStart = b;
      }
    };
    function m(N, F) {
      N = e(N, F), i.point(N[0], N[1]);
    }
    function b() {
      f = NaN, y.point = w, i.lineStart();
    }
    function w(N, F) {
      var $ = ho([N, F]), T = e(N, F);
      n(f, h, l, d, p, g, f = T[0], h = T[1], l = N, d = $[0], p = $[1], g = $[2], kg, i), i.point(f, h);
    }
    function _() {
      y.point = m, i.lineEnd();
    }
    function x() {
      b(), y.point = S, y.lineEnd = I;
    }
    function S(N, F) {
      w(r = N, F), s = f, o = h, a = d, c = p, u = g, y.point = w;
    }
    function I() {
      n(f, h, l, d, p, g, s, o, r, a, c, u, kg, i), y.lineEnd = _, _();
    }
    return y;
  };
}
var qN = uf({
  point: function(e, t) {
    this.stream.point(e * St, t * St);
  }
});
function VN(e) {
  return uf({
    point: function(t, n) {
      var i = e(t, n);
      return this.stream.point(i[0], i[1]);
    }
  });
}
function jN(e, t, n, i, r) {
  function s(o, a) {
    return o *= i, a *= r, [t + e * o, n - e * a];
  }
  return s.invert = function(o, a) {
    return [(o - t) / e * i, (n - a) / e * r];
  }, s;
}
function Ug(e, t, n, i, r, s) {
  if (!s)
    return jN(e, t, n, i, r);
  var o = H(s), a = j(s), c = o * e, u = a * e, l = o / e, f = a / e, h = (a * n - o * t) / e, d = (a * t + o * n) / e;
  function p(g, y) {
    return g *= i, y *= r, [c * g - u * y + t, n - u * g - c * y];
  }
  return p.invert = function(g, y) {
    return [i * (l * g - f * y + h), r * (d - f * g - l * y)];
  }, p;
}
function mr(e) {
  return L_(function() {
    return e;
  })();
}
function L_(e) {
  var t, n = 150, i = 480, r = 250, s = 0, o = 0, a = 0, c = 0, u = 0, l, f = 0, h = 1, d = 1, p = null, g = Ag, y = null, m, b, w, _ = Jd, x = 0.5, S, I, N, F, $;
  function T(M) {
    return N(M[0] * St, M[1] * St);
  }
  function D(M) {
    return M = N.invert(M[0], M[1]), M && [M[0] * pe, M[1] * pe];
  }
  T.stream = function(M) {
    return F && $ === M ? F : F = qN(VN(l)(g(S(_($ = M)))));
  }, T.preclip = function(M) {
    return arguments.length ? (g = M, p = void 0, v()) : g;
  }, T.postclip = function(M) {
    return arguments.length ? (_ = M, y = m = b = w = null, v()) : _;
  }, T.clipAngle = function(M) {
    return arguments.length ? (g = +M ? MN(p = M * St) : (p = null, Ag), v()) : p * pe;
  }, T.clipExtent = function(M) {
    return arguments.length ? (_ = M == null ? (y = m = b = w = null, Jd) : __(y = +M[0][0], m = +M[0][1], b = +M[1][0], w = +M[1][1]), v()) : y == null ? null : [[y, m], [b, w]];
  }, T.scale = function(M) {
    return arguments.length ? (n = +M, E()) : n;
  }, T.translate = function(M) {
    return arguments.length ? (i = +M[0], r = +M[1], E()) : [i, r];
  }, T.center = function(M) {
    return arguments.length ? (s = M[0] % 360 * St, o = M[1] % 360 * St, E()) : [s * pe, o * pe];
  }, T.rotate = function(M) {
    return arguments.length ? (a = M[0] % 360 * St, c = M[1] % 360 * St, u = M.length > 2 ? M[2] % 360 * St : 0, E()) : [a * pe, c * pe, u * pe];
  }, T.angle = function(M) {
    return arguments.length ? (f = M % 360 * St, E()) : f * pe;
  }, T.reflectX = function(M) {
    return arguments.length ? (h = M ? -1 : 1, E()) : h < 0;
  }, T.reflectY = function(M) {
    return arguments.length ? (d = M ? -1 : 1, E()) : d < 0;
  }, T.precision = function(M) {
    return arguments.length ? (S = Rg(I, x = M * M), v()) : Oe(x);
  }, T.fitExtent = function(M, A) {
    return Fp(T, M, A);
  }, T.fitSize = function(M, A) {
    return F_(T, M, A);
  }, T.fitWidth = function(M, A) {
    return D_(T, M, A);
  }, T.fitHeight = function(M, A) {
    return B_(T, M, A);
  };
  function E() {
    var M = Ug(n, 0, 0, h, d, f).apply(null, t(s, o)), A = Ug(n, i - M[0], r - M[1], h, d, f);
    return l = y_(a, c, u), I = Zd(t, A), N = Zd(l, I), S = Rg(I, x), v();
  }
  function v() {
    return F = $ = null, T;
  }
  return function() {
    return t = e.apply(this, arguments), T.invert = t.invert && D, E();
  };
}
function Dp(e) {
  var t = 0, n = yt / 3, i = L_(e), r = i(t, n);
  return r.parallels = function(s) {
    return arguments.length ? i(t = s[0] * St, n = s[1] * St) : [t * pe, n * pe];
  }, r;
}
function XN(e) {
  var t = H(e);
  function n(i, r) {
    return [i * t, j(r) / t];
  }
  return n.invert = function(i, r) {
    return [i / t, Re(r * t)];
  }, n;
}
function WN(e, t) {
  var n = j(e), i = (n + j(t)) / 2;
  if ($t(i) < W)
    return XN(e);
  var r = 1 + n * (2 * i - n), s = Oe(r) / i;
  function o(a, c) {
    var u = Oe(r - 2 * i * j(c)) / i;
    return [u * j(a *= i), s - u * H(a)];
  }
  return o.invert = function(a, c) {
    var u = s - c, l = En(a, $t(u)) * on(u);
    return u * i < 0 && (l -= yt * on(a) * on(u)), [l / i, Re((r - (a * a + u * u) * i * i) / (2 * i))];
  }, o;
}
function yl() {
  return Dp(WN).scale(155.424).center([0, 33.6442]);
}
function C_() {
  return yl().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
}
function HN(e) {
  var t = e.length;
  return {
    point: function(n, i) {
      for (var r = -1; ++r < t; )
        e[r].point(n, i);
    },
    sphere: function() {
      for (var n = -1; ++n < t; )
        e[n].sphere();
    },
    lineStart: function() {
      for (var n = -1; ++n < t; )
        e[n].lineStart();
    },
    lineEnd: function() {
      for (var n = -1; ++n < t; )
        e[n].lineEnd();
    },
    polygonStart: function() {
      for (var n = -1; ++n < t; )
        e[n].polygonStart();
    },
    polygonEnd: function() {
      for (var n = -1; ++n < t; )
        e[n].polygonEnd();
    }
  };
}
function GN() {
  var e, t, n = C_(), i, r = yl().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), s, o = yl().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), a, c, u = { point: function(h, d) {
    c = [h, d];
  } };
  function l(h) {
    var d = h[0], p = h[1];
    return c = null, i.point(d, p), c || (s.point(d, p), c) || (a.point(d, p), c);
  }
  l.invert = function(h) {
    var d = n.scale(), p = n.translate(), g = (h[0] - p[0]) / d, y = (h[1] - p[1]) / d;
    return (y >= 0.12 && y < 0.234 && g >= -0.425 && g < -0.214 ? r : y >= 0.166 && y < 0.234 && g >= -0.214 && g < -0.115 ? o : n).invert(h);
  }, l.stream = function(h) {
    return e && t === h ? e : e = HN([n.stream(t = h), r.stream(h), o.stream(h)]);
  }, l.precision = function(h) {
    return arguments.length ? (n.precision(h), r.precision(h), o.precision(h), f()) : n.precision();
  }, l.scale = function(h) {
    return arguments.length ? (n.scale(h), r.scale(h * 0.35), o.scale(h), l.translate(n.translate())) : n.scale();
  }, l.translate = function(h) {
    if (!arguments.length)
      return n.translate();
    var d = n.scale(), p = +h[0], g = +h[1];
    return i = n.translate(h).clipExtent([[p - 0.455 * d, g - 0.238 * d], [p + 0.455 * d, g + 0.238 * d]]).stream(u), s = r.translate([p - 0.307 * d, g + 0.201 * d]).clipExtent([[p - 0.425 * d + W, g + 0.12 * d + W], [p - 0.214 * d - W, g + 0.234 * d - W]]).stream(u), a = o.translate([p - 0.205 * d, g + 0.212 * d]).clipExtent([[p - 0.214 * d + W, g + 0.166 * d + W], [p - 0.115 * d - W, g + 0.234 * d - W]]).stream(u), f();
  }, l.fitExtent = function(h, d) {
    return Fp(l, h, d);
  }, l.fitSize = function(h, d) {
    return F_(l, h, d);
  }, l.fitWidth = function(h, d) {
    return D_(l, h, d);
  }, l.fitHeight = function(h, d) {
    return B_(l, h, d);
  };
  function f() {
    return e = t = null, l;
  }
  return l.scale(1070);
}
function k_(e) {
  return function(t, n) {
    var i = H(t), r = H(n), s = e(i * r);
    return s === 1 / 0 ? [2, 0] : [
      s * r * j(t),
      s * j(n)
    ];
  };
}
function tc(e) {
  return function(t, n) {
    var i = Oe(t * t + n * n), r = e(i), s = j(r), o = H(r);
    return [
      En(t * s, i * o),
      Re(i && n * s / i)
    ];
  };
}
var R_ = k_(function(e) {
  return Oe(2 / (1 + e));
});
R_.invert = tc(function(e) {
  return 2 * Re(e / 2);
});
function ZN() {
  return mr(R_).scale(124.75).clipAngle(180 - 1e-3);
}
var U_ = k_(function(e) {
  return (e = h_(e)) && e / j(e);
});
U_.invert = tc(function(e) {
  return e;
});
function KN() {
  return mr(U_).scale(79.4188).clipAngle(180 - 1e-3);
}
function lf(e, t) {
  return [e, Ju(Ep((Jt + t) / 2))];
}
lf.invert = function(e, t) {
  return [e, 2 * Eo(f_(t)) - Jt];
};
function JN() {
  return z_(lf).scale(961 / We);
}
function z_(e) {
  var t = mr(e), n = t.center, i = t.scale, r = t.translate, s = t.clipExtent, o = null, a, c, u;
  t.scale = function(f) {
    return arguments.length ? (i(f), l()) : i();
  }, t.translate = function(f) {
    return arguments.length ? (r(f), l()) : r();
  }, t.center = function(f) {
    return arguments.length ? (n(f), l()) : n();
  }, t.clipExtent = function(f) {
    return arguments.length ? (f == null ? o = a = c = u = null : (o = +f[0][0], a = +f[0][1], c = +f[1][0], u = +f[1][1]), l()) : o == null ? null : [[o, a], [c, u]];
  };
  function l() {
    var f = yt * i(), h = t(yN(t.rotate()).invert([0, 0]));
    return s(o == null ? [[h[0] - f, h[1] - f], [h[0] + f, h[1] + f]] : e === lf ? [[Math.max(h[0] - f, o), a], [Math.min(h[0] + f, c), u]] : [[o, Math.max(h[1] - f, a)], [c, Math.min(h[1] + f, u)]]);
  }
  return l();
}
function Fc(e) {
  return Ep((Jt + e) / 2);
}
function QN(e, t) {
  var n = H(e), i = e === t ? j(e) : Ju(n / H(t)) / Ju(Fc(t) / Fc(e)), r = n * Nh(Fc(e), i) / i;
  if (!i)
    return lf;
  function s(o, a) {
    r > 0 ? a < -Jt + W && (a = -Jt + W) : a > Jt - W && (a = Jt - W);
    var c = r / Nh(Fc(a), i);
    return [c * j(i * o), r - c * H(i * o)];
  }
  return s.invert = function(o, a) {
    var c = r - a, u = on(i) * Oe(o * o + c * c), l = En(o, $t(c)) * on(c);
    return c * i < 0 && (l -= yt * on(o) * on(c)), [l / i, 2 * Eo(Nh(r / u, 1 / i)) - Jt];
  }, s;
}
function tO() {
  return Dp(QN).scale(109.5).parallels([30, 30]);
}
function gl(e, t) {
  return [e, t];
}
gl.invert = gl;
function eO() {
  return mr(gl).scale(152.63);
}
function nO(e, t) {
  var n = H(e), i = e === t ? j(e) : (n - H(t)) / (t - e), r = n / i + e;
  if ($t(i) < W)
    return gl;
  function s(o, a) {
    var c = r - a, u = i * o;
    return [c * j(u), r - c * H(u)];
  }
  return s.invert = function(o, a) {
    var c = r - a, u = En(o, $t(c)) * on(c);
    return c * i < 0 && (u -= yt * on(o) * on(c)), [u / i, r - on(i) * Oe(o * o + c * c)];
  }, s;
}
function iO() {
  return Dp(nO).scale(131.154).center([0, 13.9389]);
}
var ca = 1.340264, ua = -0.081106, la = 893e-6, fa = 3796e-6, bl = Oe(3) / 2, rO = 12;
function P_(e, t) {
  var n = Re(bl * j(t)), i = n * n, r = i * i * i;
  return [
    e * H(n) / (bl * (ca + 3 * ua * i + r * (7 * la + 9 * fa * i))),
    n * (ca + ua * i + r * (la + fa * i))
  ];
}
P_.invert = function(e, t) {
  for (var n = t, i = n * n, r = i * i * i, s = 0, o, a, c; s < rO && (a = n * (ca + ua * i + r * (la + fa * i)) - t, c = ca + 3 * ua * i + r * (7 * la + 9 * fa * i), n -= o = a / c, i = n * n, r = i * i * i, !($t(o) < Ku)); ++s)
    ;
  return [
    bl * e * (ca + 3 * ua * i + r * (7 * la + 9 * fa * i)) / H(n),
    Re(j(n) / bl)
  ];
};
function sO() {
  return mr(P_).scale(177.158);
}
function Y_(e, t) {
  var n = H(t), i = H(e) * n;
  return [n * j(e) / i, j(t) / i];
}
Y_.invert = tc(Eo);
function oO() {
  return mr(Y_).scale(144.049).clipAngle(60);
}
function q_(e, t) {
  return [H(t) * j(e), j(t)];
}
q_.invert = tc(Re);
function aO() {
  return mr(q_).scale(249.5).clipAngle(90 + W);
}
function V_(e, t) {
  var n = H(t), i = 1 + H(e) * n;
  return [n * j(e) / i, j(t) / i];
}
V_.invert = tc(function(e) {
  return 2 * Eo(e);
});
function cO() {
  return mr(V_).scale(250).clipAngle(142);
}
function j_(e, t) {
  return [Ju(Ep((Jt + t) / 2)), -e];
}
j_.invert = function(e, t) {
  return [-t, 2 * Eo(f_(e)) - Jt];
};
function uO() {
  var e = z_(j_), t = e.center, n = e.rotate;
  return e.center = function(i) {
    return arguments.length ? t([-i[1], i[0]]) : (i = t(), [i[1], -i[0]]);
  }, e.rotate = function(i) {
    return arguments.length ? n([i[0], i[1], i.length > 2 ? i[2] + 90 : 90]) : (i = n(), [i[0], i[1], i[2] - 90]);
  }, n([0, 0, 90]).scale(159.155);
}
function lO(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function fO(e) {
  return e.reduce(hO, 0) / e.length;
}
function hO(e, t) {
  return e + t.x;
}
function dO(e) {
  return 1 + e.reduce(pO, 0);
}
function pO(e, t) {
  return Math.max(e, t.y);
}
function mO(e) {
  for (var t; t = e.children; )
    e = t[0];
  return e;
}
function yO(e) {
  for (var t; t = e.children; )
    e = t[t.length - 1];
  return e;
}
function gO() {
  var e = lO, t = 1, n = 1, i = !1;
  function r(s) {
    var o, a = 0;
    s.eachAfter(function(h) {
      var d = h.children;
      d ? (h.x = fO(d), h.y = dO(d)) : (h.x = o ? a += e(h, o) : 0, h.y = 0, o = h);
    });
    var c = mO(s), u = yO(s), l = c.x - e(c, u) / 2, f = u.x + e(u, c) / 2;
    return s.eachAfter(i ? function(h) {
      h.x = (h.x - s.x) * t, h.y = (s.y - h.y) * n;
    } : function(h) {
      h.x = (h.x - l) / (f - l) * t, h.y = (1 - (s.y ? h.y / s.y : 1)) * n;
    });
  }
  return r.separation = function(s) {
    return arguments.length ? (e = s, r) : e;
  }, r.size = function(s) {
    return arguments.length ? (i = !1, t = +s[0], n = +s[1], r) : i ? null : [t, n];
  }, r.nodeSize = function(s) {
    return arguments.length ? (i = !0, t = +s[0], n = +s[1], r) : i ? [t, n] : null;
  }, r;
}
function bO(e) {
  var t = 0, n = e.children, i = n && n.length;
  if (!i)
    t = 1;
  else
    for (; --i >= 0; )
      t += n[i].value;
  e.value = t;
}
function wO() {
  return this.eachAfter(bO);
}
function _O(e, t) {
  let n = -1;
  for (const i of this)
    e.call(t, i, ++n, this);
  return this;
}
function vO(e, t) {
  for (var n = this, i = [n], r, s, o = -1; n = i.pop(); )
    if (e.call(t, n, ++o, this), r = n.children)
      for (s = r.length - 1; s >= 0; --s)
        i.push(r[s]);
  return this;
}
function xO(e, t) {
  for (var n = this, i = [n], r = [], s, o, a, c = -1; n = i.pop(); )
    if (r.push(n), s = n.children)
      for (o = 0, a = s.length; o < a; ++o)
        i.push(s[o]);
  for (; n = r.pop(); )
    e.call(t, n, ++c, this);
  return this;
}
function SO(e, t) {
  let n = -1;
  for (const i of this)
    if (e.call(t, i, ++n, this))
      return i;
}
function MO(e) {
  return this.eachAfter(function(t) {
    for (var n = +e(t.data) || 0, i = t.children, r = i && i.length; --r >= 0; )
      n += i[r].value;
    t.value = n;
  });
}
function AO(e) {
  return this.eachBefore(function(t) {
    t.children && t.children.sort(e);
  });
}
function $O(e) {
  for (var t = this, n = IO(t, e), i = [t]; t !== n; )
    t = t.parent, i.push(t);
  for (var r = i.length; e !== n; )
    i.splice(r, 0, e), e = e.parent;
  return i;
}
function IO(e, t) {
  if (e === t)
    return e;
  var n = e.ancestors(), i = t.ancestors(), r = null;
  for (e = n.pop(), t = i.pop(); e === t; )
    r = e, e = n.pop(), t = i.pop();
  return r;
}
function TO() {
  for (var e = this, t = [e]; e = e.parent; )
    t.push(e);
  return t;
}
function EO() {
  return Array.from(this);
}
function NO() {
  var e = [];
  return this.eachBefore(function(t) {
    t.children || e.push(t);
  }), e;
}
function OO() {
  var e = this, t = [];
  return e.each(function(n) {
    n !== e && t.push({ source: n.parent, target: n });
  }), t;
}
function* FO() {
  var e = this, t, n = [e], i, r, s;
  do
    for (t = n.reverse(), n = []; e = t.pop(); )
      if (yield e, i = e.children)
        for (r = 0, s = i.length; r < s; ++r)
          n.push(i[r]);
  while (n.length);
}
function X_(e, t) {
  e instanceof Map ? (e = [void 0, e], t === void 0 && (t = LO)) : t === void 0 && (t = BO);
  for (var n = new mo(e), i, r = [n], s, o, a, c; i = r.pop(); )
    if ((o = t(i.data)) && (c = (o = Array.from(o)).length))
      for (i.children = o, a = c - 1; a >= 0; --a)
        r.push(s = o[a] = new mo(o[a])), s.parent = i, s.depth = i.depth + 1;
  return n.eachBefore(W_);
}
function DO() {
  return X_(this).eachBefore(CO);
}
function BO(e) {
  return e.children;
}
function LO(e) {
  return Array.isArray(e) ? e[1] : null;
}
function CO(e) {
  e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
}
function W_(e) {
  var t = 0;
  do
    e.height = t;
  while ((e = e.parent) && e.height < ++t);
}
function mo(e) {
  this.data = e, this.depth = this.height = 0, this.parent = null;
}
mo.prototype = X_.prototype = {
  constructor: mo,
  count: wO,
  each: _O,
  eachAfter: xO,
  eachBefore: vO,
  find: SO,
  sum: MO,
  sort: AO,
  path: $O,
  ancestors: TO,
  descendants: EO,
  leaves: NO,
  links: OO,
  copy: DO,
  [Symbol.iterator]: FO
};
function Lh(e) {
  return e == null ? null : kO(e);
}
function kO(e) {
  if (typeof e != "function")
    throw new Error();
  return e;
}
var RO = { depth: -1 }, zg = {}, Ch = {};
function UO(e) {
  return e.id;
}
function zO(e) {
  return e.parentId;
}
function H_() {
  var e = UO, t = zO, n;
  function i(r) {
    var s = Array.from(r), o = e, a = t, c, u, l, f, h, d, p, g, y = /* @__PURE__ */ new Map();
    if (n != null) {
      const m = s.map((_, x) => PO(n(_, x, r))), b = m.map(Pg), w = new Set(m).add("");
      for (const _ of b)
        w.has(_) || (w.add(_), m.push(_), b.push(Pg(_)), s.push(Ch));
      o = (_, x) => m[x], a = (_, x) => b[x];
    }
    for (l = 0, c = s.length; l < c; ++l)
      u = s[l], d = s[l] = new mo(u), (p = o(u, l, r)) != null && (p += "") && (g = d.id = p, y.set(g, y.has(g) ? zg : d)), (p = a(u, l, r)) != null && (p += "") && (d.parent = p);
    for (l = 0; l < c; ++l)
      if (d = s[l], p = d.parent) {
        if (h = y.get(p), !h)
          throw new Error("missing: " + p);
        if (h === zg)
          throw new Error("ambiguous: " + p);
        h.children ? h.children.push(d) : h.children = [d], d.parent = h;
      } else {
        if (f)
          throw new Error("multiple roots");
        f = d;
      }
    if (!f)
      throw new Error("no root");
    if (n != null) {
      for (; f.data === Ch && f.children.length === 1; )
        f = f.children[0], --c;
      for (let m = s.length - 1; m >= 0 && (d = s[m], d.data === Ch); --m)
        d.data = null;
    }
    if (f.parent = RO, f.eachBefore(function(m) {
      m.depth = m.parent.depth + 1, --c;
    }).eachBefore(W_), f.parent = null, c > 0)
      throw new Error("cycle");
    return f;
  }
  return i.id = function(r) {
    return arguments.length ? (e = Lh(r), i) : e;
  }, i.parentId = function(r) {
    return arguments.length ? (t = Lh(r), i) : t;
  }, i.path = function(r) {
    return arguments.length ? (n = Lh(r), i) : n;
  }, i;
}
function PO(e) {
  e = `${e}`;
  let t = e.length;
  return c0(e, t - 1) && !c0(e, t - 2) && (e = e.slice(0, -1)), e[0] === "/" ? e : `/${e}`;
}
function Pg(e) {
  let t = e.length;
  if (t < 2)
    return "";
  for (; --t > 1 && !c0(e, t); )
    ;
  return e.slice(0, t);
}
function c0(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
function YO(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function kh(e) {
  var t = e.children;
  return t ? t[0] : e.t;
}
function Rh(e) {
  var t = e.children;
  return t ? t[t.length - 1] : e.t;
}
function qO(e, t, n) {
  var i = n / (t.i - e.i);
  t.c -= i, t.s += n, e.c += i, t.z += n, t.m += n;
}
function VO(e) {
  for (var t = 0, n = 0, i = e.children, r = i.length, s; --r >= 0; )
    s = i[r], s.z += t, s.m += t, t += s.s + (n += s.c);
}
function jO(e, t, n) {
  return e.a.parent === t.parent ? e.a : n;
}
function ou(e, t) {
  this._ = e, this.parent = null, this.children = null, this.A = null, this.a = this, this.z = 0, this.m = 0, this.c = 0, this.s = 0, this.t = null, this.i = t;
}
ou.prototype = Object.create(mo.prototype);
function XO(e) {
  for (var t = new ou(e, 0), n, i = [t], r, s, o, a; n = i.pop(); )
    if (s = n._.children)
      for (n.children = new Array(a = s.length), o = a - 1; o >= 0; --o)
        i.push(r = n.children[o] = new ou(s[o], o)), r.parent = n;
  return (t.parent = new ou(null, 0)).children = [t], t;
}
function G_() {
  var e = YO, t = 1, n = 1, i = null;
  function r(u) {
    var l = XO(u);
    if (l.eachAfter(s), l.parent.m = -l.z, l.eachBefore(o), i)
      u.eachBefore(c);
    else {
      var f = u, h = u, d = u;
      u.eachBefore(function(b) {
        b.x < f.x && (f = b), b.x > h.x && (h = b), b.depth > d.depth && (d = b);
      });
      var p = f === h ? 1 : e(f, h) / 2, g = p - f.x, y = t / (h.x + p + g), m = n / (d.depth || 1);
      u.eachBefore(function(b) {
        b.x = (b.x + g) * y, b.y = b.depth * m;
      });
    }
    return u;
  }
  function s(u) {
    var l = u.children, f = u.parent.children, h = u.i ? f[u.i - 1] : null;
    if (l) {
      VO(u);
      var d = (l[0].z + l[l.length - 1].z) / 2;
      h ? (u.z = h.z + e(u._, h._), u.m = u.z - d) : u.z = d;
    } else
      h && (u.z = h.z + e(u._, h._));
    u.parent.A = a(u, h, u.parent.A || f[0]);
  }
  function o(u) {
    u._.x = u.z + u.parent.m, u.m += u.parent.m;
  }
  function a(u, l, f) {
    if (l) {
      for (var h = u, d = u, p = l, g = h.parent.children[0], y = h.m, m = d.m, b = p.m, w = g.m, _; p = Rh(p), h = kh(h), p && h; )
        g = kh(g), d = Rh(d), d.a = u, _ = p.z + b - h.z - y + e(p._, h._), _ > 0 && (qO(jO(p, u, f), u, _), y += _, m += _), b += p.m, y += h.m, w += g.m, m += d.m;
      p && !Rh(d) && (d.t = p, d.m += b - m), h && !kh(g) && (g.t = h, g.m += y - w, f = u);
    }
    return f;
  }
  function c(u) {
    u.x *= t, u.y = u.depth * n;
  }
  return r.separation = function(u) {
    return arguments.length ? (e = u, r) : e;
  }, r.size = function(u) {
    return arguments.length ? (i = !1, t = +u[0], n = +u[1], r) : i ? null : [t, n];
  }, r.nodeSize = function(u) {
    return arguments.length ? (i = !0, t = +u[0], n = +u[1], r) : i ? [t, n] : null;
  }, r;
}
const WO = 1664525, HO = 1013904223, Yg = 1 / 4294967296;
function Bp(e = Math.random()) {
  let t = (0 <= e && e < 1 ? e / Yg : Math.abs(e)) | 0;
  return () => (t = WO * t + HO | 0, Yg * (t >>> 0));
}
function oi(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
function ff(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1: {
      typeof e == "function" ? this.interpolator(e) : this.range(e);
      break;
    }
    default: {
      this.domain(e), typeof t == "function" ? this.interpolator(t) : this.range(t);
      break;
    }
  }
  return this;
}
const u0 = Symbol("implicit");
function Lp() {
  var e = new so(), t = [], n = [], i = u0;
  function r(s) {
    let o = e.get(s);
    if (o === void 0) {
      if (i !== u0)
        return i;
      e.set(s, o = t.push(s) - 1);
    }
    return n[o % n.length];
  }
  return r.domain = function(s) {
    if (!arguments.length)
      return t.slice();
    t = [], e = new so();
    for (const o of s)
      e.has(o) || e.set(o, t.push(o) - 1);
    return r;
  }, r.range = function(s) {
    return arguments.length ? (n = Array.from(s), r) : n.slice();
  }, r.unknown = function(s) {
    return arguments.length ? (i = s, r) : i;
  }, r.copy = function() {
    return Lp(t, n).unknown(i);
  }, oi.apply(r, arguments), r;
}
function hf() {
  var e = Lp().unknown(void 0), t = e.domain, n = e.range, i = 0, r = 1, s, o, a = !1, c = 0, u = 0, l = 0.5;
  delete e.unknown;
  function f() {
    var h = t().length, d = r < i, p = d ? r : i, g = d ? i : r;
    s = (g - p) / Math.max(1, h - c + u * 2), a && (s = Math.floor(s)), p += (g - p - s * (h - c)) * l, o = s * (1 - c), a && (p = Math.round(p), o = Math.round(o));
    var y = sn(h).map(function(m) {
      return p + s * m;
    });
    return n(d ? y.reverse() : y);
  }
  return e.domain = function(h) {
    return arguments.length ? (t(h), f()) : t();
  }, e.range = function(h) {
    return arguments.length ? ([i, r] = h, i = +i, r = +r, f()) : [i, r];
  }, e.rangeRound = function(h) {
    return [i, r] = h, i = +i, r = +r, a = !0, f();
  }, e.bandwidth = function() {
    return o;
  }, e.step = function() {
    return s;
  }, e.round = function(h) {
    return arguments.length ? (a = !!h, f()) : a;
  }, e.padding = function(h) {
    return arguments.length ? (c = Math.min(1, u = +h), f()) : c;
  }, e.paddingInner = function(h) {
    return arguments.length ? (c = Math.min(1, h), f()) : c;
  }, e.paddingOuter = function(h) {
    return arguments.length ? (u = +h, f()) : u;
  }, e.align = function(h) {
    return arguments.length ? (l = Math.max(0, Math.min(1, h)), f()) : l;
  }, e.copy = function() {
    return hf(t(), [i, r]).round(a).paddingInner(c).paddingOuter(u).align(l);
  }, oi.apply(f(), arguments);
}
function Z_(e) {
  var t = e.copy;
  return e.padding = e.paddingOuter, delete e.paddingInner, delete e.paddingOuter, e.copy = function() {
    return Z_(t());
  }, e;
}
function GO() {
  return Z_(hf.apply(null, arguments).paddingInner(1));
}
function ZO(e) {
  return function() {
    return e;
  };
}
function l0(e) {
  return +e;
}
var qg = [0, 1];
function an(e) {
  return e;
}
function f0(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : ZO(isNaN(t) ? NaN : 0.5);
}
function KO(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(i) {
    return Math.max(e, Math.min(t, i));
  };
}
function JO(e, t, n) {
  var i = e[0], r = e[1], s = t[0], o = t[1];
  return r < i ? (i = f0(r, i), s = n(o, s)) : (i = f0(i, r), s = n(s, o)), function(a) {
    return s(i(a));
  };
}
function QO(e, t, n) {
  var i = Math.min(e.length, t.length) - 1, r = new Array(i), s = new Array(i), o = -1;
  for (e[i] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++o < i; )
    r[o] = f0(e[o], e[o + 1]), s[o] = n(t[o], t[o + 1]);
  return function(a) {
    var c = Jl(e, a, 1, i) - 1;
    return s[c](r[c](a));
  };
}
function ec(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function df() {
  var e = qg, t = qg, n = Io, i, r, s, o = an, a, c, u;
  function l() {
    var h = Math.min(e.length, t.length);
    return o !== an && (o = KO(e[0], e[h - 1])), a = h > 2 ? QO : JO, c = u = null, f;
  }
  function f(h) {
    return h == null || isNaN(h = +h) ? s : (c || (c = a(e.map(i), t, n)))(i(o(h)));
  }
  return f.invert = function(h) {
    return o(r((u || (u = a(t, e.map(i), ve)))(h)));
  }, f.domain = function(h) {
    return arguments.length ? (e = Array.from(h, l0), l()) : e.slice();
  }, f.range = function(h) {
    return arguments.length ? (t = Array.from(h), l()) : t.slice();
  }, f.rangeRound = function(h) {
    return t = Array.from(h), n = vp, l();
  }, f.clamp = function(h) {
    return arguments.length ? (o = h ? !0 : an, l()) : o !== an;
  }, f.interpolate = function(h) {
    return arguments.length ? (n = h, l()) : n;
  }, f.unknown = function(h) {
    return arguments.length ? (s = h, f) : s;
  }, function(h, d) {
    return i = h, r = d, l();
  };
}
function K_() {
  return df()(an, an);
}
function tF(e, t, n, i) {
  var r = $d(e, t, n), s;
  switch (i = Ea(i ?? ",f"), i.type) {
    case "s": {
      var o = Math.max(Math.abs(e), Math.abs(t));
      return i.precision == null && !isNaN(s = cN(r, o)) && (i.precision = s), l_(i, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      i.precision == null && !isNaN(s = uN(r, Math.max(Math.abs(e), Math.abs(t)))) && (i.precision = s - (i.type === "e"));
      break;
    }
    case "f":
    case "%": {
      i.precision == null && !isNaN(s = aN(r)) && (i.precision = s - (i.type === "%") * 2);
      break;
    }
  }
  return To(i);
}
function nc(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var i = t();
    return or(i[0], i[i.length - 1], n ?? 10);
  }, e.tickFormat = function(n, i) {
    var r = t();
    return tF(r[0], r[r.length - 1], n ?? 10, i);
  }, e.nice = function(n) {
    n == null && (n = 10);
    var i = t(), r = 0, s = i.length - 1, o = i[r], a = i[s], c, u, l = 10;
    for (a < o && (u = o, o = a, a = u, u = r, r = s, s = u); l-- > 0; ) {
      if (u = Sa(o, a, n), u === c)
        return i[r] = o, i[s] = a, t(i);
      if (u > 0)
        o = Math.floor(o / u) * u, a = Math.ceil(a / u) * u;
      else if (u < 0)
        o = Math.ceil(o * u) / u, a = Math.floor(a * u) / u;
      else
        break;
      c = u;
    }
    return e;
  }, e;
}
function pf() {
  var e = K_();
  return e.copy = function() {
    return ec(e, pf());
  }, oi.apply(e, arguments), nc(e);
}
function J_(e) {
  var t;
  function n(i) {
    return i == null || isNaN(i = +i) ? t : i;
  }
  return n.invert = n, n.domain = n.range = function(i) {
    return arguments.length ? (e = Array.from(i, l0), n) : e.slice();
  }, n.unknown = function(i) {
    return arguments.length ? (t = i, n) : t;
  }, n.copy = function() {
    return J_(e).unknown(t);
  }, e = arguments.length ? Array.from(e, l0) : [0, 1], nc(n);
}
function Q_(e, t) {
  e = e.slice();
  var n = 0, i = e.length - 1, r = e[n], s = e[i], o;
  return s < r && (o = n, n = i, i = o, o = r, r = s, s = o), e[n] = t.floor(r), e[i] = t.ceil(s), e;
}
function Vg(e) {
  return Math.log(e);
}
function jg(e) {
  return Math.exp(e);
}
function eF(e) {
  return -Math.log(-e);
}
function nF(e) {
  return -Math.exp(-e);
}
function iF(e) {
  return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e;
}
function rF(e) {
  return e === 10 ? iF : e === Math.E ? Math.exp : (t) => Math.pow(e, t);
}
function sF(e) {
  return e === Math.E ? Math.log : e === 10 && Math.log10 || e === 2 && Math.log2 || (e = Math.log(e), (t) => Math.log(t) / e);
}
function Xg(e) {
  return (t, n) => -e(-t, n);
}
function tv(e) {
  const t = e(Vg, jg), n = t.domain;
  let i = 10, r, s;
  function o() {
    return r = sF(i), s = rF(i), n()[0] < 0 ? (r = Xg(r), s = Xg(s), e(eF, nF)) : e(Vg, jg), t;
  }
  return t.base = function(a) {
    return arguments.length ? (i = +a, o()) : i;
  }, t.domain = function(a) {
    return arguments.length ? (n(a), o()) : n();
  }, t.ticks = (a) => {
    const c = n();
    let u = c[0], l = c[c.length - 1];
    const f = l < u;
    f && ([u, l] = [l, u]);
    let h = r(u), d = r(l), p, g;
    const y = a == null ? 10 : +a;
    let m = [];
    if (!(i % 1) && d - h < y) {
      if (h = Math.floor(h), d = Math.ceil(d), u > 0) {
        for (; h <= d; ++h)
          for (p = 1; p < i; ++p)
            if (g = h < 0 ? p / s(-h) : p * s(h), !(g < u)) {
              if (g > l)
                break;
              m.push(g);
            }
      } else
        for (; h <= d; ++h)
          for (p = i - 1; p >= 1; --p)
            if (g = h > 0 ? p / s(-h) : p * s(h), !(g < u)) {
              if (g > l)
                break;
              m.push(g);
            }
      m.length * 2 < y && (m = or(u, l, y));
    } else
      m = or(h, d, Math.min(d - h, y)).map(s);
    return f ? m.reverse() : m;
  }, t.tickFormat = (a, c) => {
    if (a == null && (a = 10), c == null && (c = i === 10 ? "s" : ","), typeof c != "function" && (!(i % 1) && (c = Ea(c)).precision == null && (c.trim = !0), c = To(c)), a === 1 / 0)
      return c;
    const u = Math.max(1, i * a / t.ticks().length);
    return (l) => {
      let f = l / s(Math.round(r(l)));
      return f * i < i - 0.5 && (f *= i), f <= u ? c(l) : "";
    };
  }, t.nice = () => n(Q_(n(), {
    floor: (a) => s(Math.floor(r(a))),
    ceil: (a) => s(Math.ceil(r(a)))
  })), t;
}
function ev() {
  const e = tv(df()).domain([1, 10]);
  return e.copy = () => ec(e, ev()).base(e.base()), oi.apply(e, arguments), e;
}
function Wg(e) {
  return function(t) {
    return Math.sign(t) * Math.log1p(Math.abs(t / e));
  };
}
function Hg(e) {
  return function(t) {
    return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
  };
}
function nv(e) {
  var t = 1, n = e(Wg(t), Hg(t));
  return n.constant = function(i) {
    return arguments.length ? e(Wg(t = +i), Hg(t)) : t;
  }, nc(n);
}
function iv() {
  var e = nv(df());
  return e.copy = function() {
    return ec(e, iv()).constant(e.constant());
  }, oi.apply(e, arguments);
}
function Gg(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function oF(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function aF(e) {
  return e < 0 ? -e * e : e * e;
}
function rv(e) {
  var t = e(an, an), n = 1;
  function i() {
    return n === 1 ? e(an, an) : n === 0.5 ? e(oF, aF) : e(Gg(n), Gg(1 / n));
  }
  return t.exponent = function(r) {
    return arguments.length ? (n = +r, i()) : n;
  }, nc(t);
}
function sv() {
  var e = rv(df());
  return e.copy = function() {
    return ec(e, sv()).exponent(e.exponent());
  }, oi.apply(e, arguments), e;
}
function ov() {
  var e = [], t = [], n = [], i;
  function r() {
    var o = 0, a = Math.max(1, t.length);
    for (n = new Array(a - 1); ++o < a; )
      n[o - 1] = h7(e, o / a);
    return s;
  }
  function s(o) {
    return o == null || isNaN(o = +o) ? i : t[Jl(n, o)];
  }
  return s.invertExtent = function(o) {
    var a = t.indexOf(o);
    return a < 0 ? [NaN, NaN] : [
      a > 0 ? n[a - 1] : e[0],
      a < n.length ? n[a] : e[e.length - 1]
    ];
  }, s.domain = function(o) {
    if (!arguments.length)
      return e.slice();
    e = [];
    for (let a of o)
      a != null && !isNaN(a = +a) && e.push(a);
    return e.sort(jt), r();
  }, s.range = function(o) {
    return arguments.length ? (t = Array.from(o), r()) : t.slice();
  }, s.unknown = function(o) {
    return arguments.length ? (i = o, s) : i;
  }, s.quantiles = function() {
    return n.slice();
  }, s.copy = function() {
    return ov().domain(e).range(t).unknown(i);
  }, oi.apply(s, arguments);
}
function av() {
  var e = [0.5], t = [0, 1], n, i = 1;
  function r(s) {
    return s != null && s <= s ? t[Jl(e, s, 0, i)] : n;
  }
  return r.domain = function(s) {
    return arguments.length ? (e = Array.from(s), i = Math.min(e.length, t.length - 1), r) : e.slice();
  }, r.range = function(s) {
    return arguments.length ? (t = Array.from(s), i = Math.min(e.length, t.length - 1), r) : t.slice();
  }, r.invertExtent = function(s) {
    var o = t.indexOf(s);
    return [e[o - 1], e[o]];
  }, r.unknown = function(s) {
    return arguments.length ? (n = s, r) : n;
  }, r.copy = function() {
    return av().domain(e).range(t).unknown(n);
  }, oi.apply(r, arguments);
}
const Uh = new Date(), zh = new Date();
function oe(e, t, n, i) {
  function r(s) {
    return e(s = arguments.length === 0 ? new Date() : new Date(+s)), s;
  }
  return r.floor = (s) => (e(s = new Date(+s)), s), r.ceil = (s) => (e(s = new Date(s - 1)), t(s, 1), e(s), s), r.round = (s) => {
    const o = r(s), a = r.ceil(s);
    return s - o < a - s ? o : a;
  }, r.offset = (s, o) => (t(s = new Date(+s), o == null ? 1 : Math.floor(o)), s), r.range = (s, o, a) => {
    const c = [];
    if (s = r.ceil(s), a = a == null ? 1 : Math.floor(a), !(s < o) || !(a > 0))
      return c;
    let u;
    do
      c.push(u = new Date(+s)), t(s, a), e(s);
    while (u < s && s < o);
    return c;
  }, r.filter = (s) => oe((o) => {
    if (o >= o)
      for (; e(o), !s(o); )
        o.setTime(o - 1);
  }, (o, a) => {
    if (o >= o)
      if (a < 0)
        for (; ++a <= 0; )
          for (; t(o, -1), !s(o); )
            ;
      else
        for (; --a >= 0; )
          for (; t(o, 1), !s(o); )
            ;
  }), n && (r.count = (s, o) => (Uh.setTime(+s), zh.setTime(+o), e(Uh), e(zh), Math.floor(n(Uh, zh))), r.every = (s) => (s = Math.floor(s), !isFinite(s) || !(s > 0) ? null : s > 1 ? r.filter(i ? (o) => i(o) % s === 0 : (o) => r.count(0, o) % s === 0) : r)), r;
}
const wl = oe(() => {
}, (e, t) => {
  e.setTime(+e + t);
}, (e, t) => t - e);
wl.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? oe((t) => {
  t.setTime(Math.floor(t / e) * e);
}, (t, n) => {
  t.setTime(+t + n * e);
}, (t, n) => (n - t) / e) : wl);
wl.range;
const Ii = 1e3, cn = Ii * 60, Ti = cn * 60, Ri = Ti * 24, Cp = Ri * 7, Zg = Ri * 30, Ph = Ri * 365, Ei = oe((e) => {
  e.setTime(e - e.getMilliseconds());
}, (e, t) => {
  e.setTime(+e + t * Ii);
}, (e, t) => (t - e) / Ii, (e) => e.getUTCSeconds());
Ei.range;
const mf = oe((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Ii);
}, (e, t) => {
  e.setTime(+e + t * cn);
}, (e, t) => (t - e) / cn, (e) => e.getMinutes());
mf.range;
const yf = oe((e) => {
  e.setUTCSeconds(0, 0);
}, (e, t) => {
  e.setTime(+e + t * cn);
}, (e, t) => (t - e) / cn, (e) => e.getUTCMinutes());
yf.range;
const gf = oe((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Ii - e.getMinutes() * cn);
}, (e, t) => {
  e.setTime(+e + t * Ti);
}, (e, t) => (t - e) / Ti, (e) => e.getHours());
gf.range;
const bf = oe((e) => {
  e.setUTCMinutes(0, 0, 0);
}, (e, t) => {
  e.setTime(+e + t * Ti);
}, (e, t) => (t - e) / Ti, (e) => e.getUTCHours());
bf.range;
const No = oe(
  (e) => e.setHours(0, 0, 0, 0),
  (e, t) => e.setDate(e.getDate() + t),
  (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * cn) / Ri,
  (e) => e.getDate() - 1
);
No.range;
const ic = oe((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / Ri, (e) => e.getUTCDate() - 1);
ic.range;
const cv = oe((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / Ri, (e) => Math.floor(e / Ri));
cv.range;
function ss(e) {
  return oe((t) => {
    t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0);
  }, (t, n) => {
    t.setDate(t.getDate() + n * 7);
  }, (t, n) => (n - t - (n.getTimezoneOffset() - t.getTimezoneOffset()) * cn) / Cp);
}
const yo = ss(0), Oa = ss(1), uv = ss(2), lv = ss(3), es = ss(4), fv = ss(5), hv = ss(6);
yo.range;
Oa.range;
uv.range;
lv.range;
es.range;
fv.range;
hv.range;
function os(e) {
  return oe((t) => {
    t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0);
  }, (t, n) => {
    t.setUTCDate(t.getUTCDate() + n * 7);
  }, (t, n) => (n - t) / Cp);
}
const go = os(0), Fa = os(1), dv = os(2), pv = os(3), ns = os(4), mv = os(5), yv = os(6);
go.range;
Fa.range;
dv.range;
pv.range;
ns.range;
mv.range;
yv.range;
const wf = oe((e) => {
  e.setDate(1), e.setHours(0, 0, 0, 0);
}, (e, t) => {
  e.setMonth(e.getMonth() + t);
}, (e, t) => t.getMonth() - e.getMonth() + (t.getFullYear() - e.getFullYear()) * 12, (e) => e.getMonth());
wf.range;
const _f = oe((e) => {
  e.setUTCDate(1), e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCMonth(e.getUTCMonth() + t);
}, (e, t) => t.getUTCMonth() - e.getUTCMonth() + (t.getUTCFullYear() - e.getUTCFullYear()) * 12, (e) => e.getUTCMonth());
_f.range;
const ni = oe((e) => {
  e.setMonth(0, 1), e.setHours(0, 0, 0, 0);
}, (e, t) => {
  e.setFullYear(e.getFullYear() + t);
}, (e, t) => t.getFullYear() - e.getFullYear(), (e) => e.getFullYear());
ni.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : oe((t) => {
  t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0);
}, (t, n) => {
  t.setFullYear(t.getFullYear() + n * e);
});
ni.range;
const ii = oe((e) => {
  e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCFullYear(e.getUTCFullYear() + t);
}, (e, t) => t.getUTCFullYear() - e.getUTCFullYear(), (e) => e.getUTCFullYear());
ii.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : oe((t) => {
  t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0);
}, (t, n) => {
  t.setUTCFullYear(t.getUTCFullYear() + n * e);
});
ii.range;
function gv(e, t, n, i, r, s) {
  const o = [
    [Ei, 1, Ii],
    [Ei, 5, 5 * Ii],
    [Ei, 15, 15 * Ii],
    [Ei, 30, 30 * Ii],
    [s, 1, cn],
    [s, 5, 5 * cn],
    [s, 15, 15 * cn],
    [s, 30, 30 * cn],
    [r, 1, Ti],
    [r, 3, 3 * Ti],
    [r, 6, 6 * Ti],
    [r, 12, 12 * Ti],
    [i, 1, Ri],
    [i, 2, 2 * Ri],
    [n, 1, Cp],
    [t, 1, Zg],
    [t, 3, 3 * Zg],
    [e, 1, Ph]
  ];
  function a(u, l, f) {
    const h = l < u;
    h && ([u, l] = [l, u]);
    const d = f && typeof f.range == "function" ? f : c(u, l, f), p = d ? d.range(u, +l + 1) : [];
    return h ? p.reverse() : p;
  }
  function c(u, l, f) {
    const h = Math.abs(l - u) / f, d = ap(([, , y]) => y).right(o, h);
    if (d === o.length)
      return e.every($d(u / Ph, l / Ph, f));
    if (d === 0)
      return wl.every(Math.max($d(u, l, f), 1));
    const [p, g] = o[h / o[d - 1][2] < o[d][2] / h ? d - 1 : d];
    return p.every(g);
  }
  return [a, c];
}
const [cF, bv] = gv(ii, _f, go, cv, bf, yf), [uF, lF] = gv(ni, wf, yo, No, gf, mf);
function Yh(e) {
  if (0 <= e.y && e.y < 100) {
    var t = new Date(-1, e.m, e.d, e.H, e.M, e.S, e.L);
    return t.setFullYear(e.y), t;
  }
  return new Date(e.y, e.m, e.d, e.H, e.M, e.S, e.L);
}
function qh(e) {
  if (0 <= e.y && e.y < 100) {
    var t = new Date(Date.UTC(-1, e.m, e.d, e.H, e.M, e.S, e.L));
    return t.setUTCFullYear(e.y), t;
  }
  return new Date(Date.UTC(e.y, e.m, e.d, e.H, e.M, e.S, e.L));
}
function Vo(e, t, n) {
  return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 };
}
function fF(e) {
  var t = e.dateTime, n = e.date, i = e.time, r = e.periods, s = e.days, o = e.shortDays, a = e.months, c = e.shortMonths, u = jo(r), l = Xo(r), f = jo(s), h = Xo(s), d = jo(o), p = Xo(o), g = jo(a), y = Xo(a), m = jo(c), b = Xo(c), w = {
    a: O,
    A: L,
    b: C,
    B: k,
    c: null,
    d: n1,
    e: n1,
    f: BF,
    g: VF,
    G: XF,
    H: OF,
    I: FF,
    j: DF,
    L: wv,
    m: LF,
    M: CF,
    p: R,
    q: z,
    Q: s1,
    s: o1,
    S: kF,
    u: RF,
    U: UF,
    V: zF,
    w: PF,
    W: YF,
    x: null,
    X: null,
    y: qF,
    Y: jF,
    Z: WF,
    "%": r1
  }, _ = {
    a: G,
    A: Z,
    b: pt,
    B: Ot,
    c: null,
    d: i1,
    e: i1,
    f: KF,
    g: aD,
    G: uD,
    H: HF,
    I: GF,
    j: ZF,
    L: vv,
    m: JF,
    M: QF,
    p: gt,
    q: bt,
    Q: s1,
    s: o1,
    S: tD,
    u: eD,
    U: nD,
    V: iD,
    w: rD,
    W: sD,
    x: null,
    X: null,
    y: oD,
    Y: cD,
    Z: lD,
    "%": r1
  }, x = {
    a: $,
    A: T,
    b: D,
    B: E,
    c: v,
    d: t1,
    e: t1,
    f: IF,
    g: Qg,
    G: Jg,
    H: e1,
    I: e1,
    j: SF,
    L: $F,
    m: xF,
    M: MF,
    p: F,
    q: vF,
    Q: EF,
    s: NF,
    S: AF,
    u: yF,
    U: gF,
    V: bF,
    w: mF,
    W: wF,
    x: M,
    X: A,
    y: Qg,
    Y: Jg,
    Z: _F,
    "%": TF
  };
  w.x = S(n, w), w.X = S(i, w), w.c = S(t, w), _.x = S(n, _), _.X = S(i, _), _.c = S(t, _);
  function S(P, V) {
    return function(it) {
      var U = [], It = -1, wt = 0, Lt = P.length, ne, X, Vt;
      for (it instanceof Date || (it = new Date(+it)); ++It < Lt; )
        P.charCodeAt(It) === 37 && (U.push(P.slice(wt, It)), (X = Kg[ne = P.charAt(++It)]) != null ? ne = P.charAt(++It) : X = ne === "e" ? " " : "0", (Vt = V[ne]) && (ne = Vt(it, X)), U.push(ne), wt = It + 1);
      return U.push(P.slice(wt, It)), U.join("");
    };
  }
  function I(P, V) {
    return function(it) {
      var U = Vo(1900, void 0, 1), It = N(U, P, it += "", 0), wt, Lt;
      if (It != it.length)
        return null;
      if ("Q" in U)
        return new Date(U.Q);
      if ("s" in U)
        return new Date(U.s * 1e3 + ("L" in U ? U.L : 0));
      if (V && !("Z" in U) && (U.Z = 0), "p" in U && (U.H = U.H % 12 + U.p * 12), U.m === void 0 && (U.m = "q" in U ? U.q : 0), "V" in U) {
        if (U.V < 1 || U.V > 53)
          return null;
        "w" in U || (U.w = 1), "Z" in U ? (wt = qh(Vo(U.y, 0, 1)), Lt = wt.getUTCDay(), wt = Lt > 4 || Lt === 0 ? Fa.ceil(wt) : Fa(wt), wt = ic.offset(wt, (U.V - 1) * 7), U.y = wt.getUTCFullYear(), U.m = wt.getUTCMonth(), U.d = wt.getUTCDate() + (U.w + 6) % 7) : (wt = Yh(Vo(U.y, 0, 1)), Lt = wt.getDay(), wt = Lt > 4 || Lt === 0 ? Oa.ceil(wt) : Oa(wt), wt = No.offset(wt, (U.V - 1) * 7), U.y = wt.getFullYear(), U.m = wt.getMonth(), U.d = wt.getDate() + (U.w + 6) % 7);
      } else
        ("W" in U || "U" in U) && ("w" in U || (U.w = "u" in U ? U.u % 7 : "W" in U ? 1 : 0), Lt = "Z" in U ? qh(Vo(U.y, 0, 1)).getUTCDay() : Yh(Vo(U.y, 0, 1)).getDay(), U.m = 0, U.d = "W" in U ? (U.w + 6) % 7 + U.W * 7 - (Lt + 5) % 7 : U.w + U.U * 7 - (Lt + 6) % 7);
      return "Z" in U ? (U.H += U.Z / 100 | 0, U.M += U.Z % 100, qh(U)) : Yh(U);
    };
  }
  function N(P, V, it, U) {
    for (var It = 0, wt = V.length, Lt = it.length, ne, X; It < wt; ) {
      if (U >= Lt)
        return -1;
      if (ne = V.charCodeAt(It++), ne === 37) {
        if (ne = V.charAt(It++), X = x[ne in Kg ? V.charAt(It++) : ne], !X || (U = X(P, it, U)) < 0)
          return -1;
      } else if (ne != it.charCodeAt(U++))
        return -1;
    }
    return U;
  }
  function F(P, V, it) {
    var U = u.exec(V.slice(it));
    return U ? (P.p = l.get(U[0].toLowerCase()), it + U[0].length) : -1;
  }
  function $(P, V, it) {
    var U = d.exec(V.slice(it));
    return U ? (P.w = p.get(U[0].toLowerCase()), it + U[0].length) : -1;
  }
  function T(P, V, it) {
    var U = f.exec(V.slice(it));
    return U ? (P.w = h.get(U[0].toLowerCase()), it + U[0].length) : -1;
  }
  function D(P, V, it) {
    var U = m.exec(V.slice(it));
    return U ? (P.m = b.get(U[0].toLowerCase()), it + U[0].length) : -1;
  }
  function E(P, V, it) {
    var U = g.exec(V.slice(it));
    return U ? (P.m = y.get(U[0].toLowerCase()), it + U[0].length) : -1;
  }
  function v(P, V, it) {
    return N(P, t, V, it);
  }
  function M(P, V, it) {
    return N(P, n, V, it);
  }
  function A(P, V, it) {
    return N(P, i, V, it);
  }
  function O(P) {
    return o[P.getDay()];
  }
  function L(P) {
    return s[P.getDay()];
  }
  function C(P) {
    return c[P.getMonth()];
  }
  function k(P) {
    return a[P.getMonth()];
  }
  function R(P) {
    return r[+(P.getHours() >= 12)];
  }
  function z(P) {
    return 1 + ~~(P.getMonth() / 3);
  }
  function G(P) {
    return o[P.getUTCDay()];
  }
  function Z(P) {
    return s[P.getUTCDay()];
  }
  function pt(P) {
    return c[P.getUTCMonth()];
  }
  function Ot(P) {
    return a[P.getUTCMonth()];
  }
  function gt(P) {
    return r[+(P.getUTCHours() >= 12)];
  }
  function bt(P) {
    return 1 + ~~(P.getUTCMonth() / 3);
  }
  return {
    format: function(P) {
      var V = S(P += "", w);
      return V.toString = function() {
        return P;
      }, V;
    },
    parse: function(P) {
      var V = I(P += "", !1);
      return V.toString = function() {
        return P;
      }, V;
    },
    utcFormat: function(P) {
      var V = S(P += "", _);
      return V.toString = function() {
        return P;
      }, V;
    },
    utcParse: function(P) {
      var V = I(P += "", !0);
      return V.toString = function() {
        return P;
      }, V;
    }
  };
}
var Kg = { "-": "", _: " ", 0: "0" }, de = /^\s*\d+/, hF = /^%/, dF = /[\\^$*+?|[\]().{}]/g;
function Mt(e, t, n) {
  var i = e < 0 ? "-" : "", r = (i ? -e : e) + "", s = r.length;
  return i + (s < n ? new Array(n - s + 1).join(t) + r : r);
}
function pF(e) {
  return e.replace(dF, "\\$&");
}
function jo(e) {
  return new RegExp("^(?:" + e.map(pF).join("|") + ")", "i");
}
function Xo(e) {
  return new Map(e.map((t, n) => [t.toLowerCase(), n]));
}
function mF(e, t, n) {
  var i = de.exec(t.slice(n, n + 1));
  return i ? (e.w = +i[0], n + i[0].length) : -1;
}
function yF(e, t, n) {
  var i = de.exec(t.slice(n, n + 1));
  return i ? (e.u = +i[0], n + i[0].length) : -1;
}
function gF(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.U = +i[0], n + i[0].length) : -1;
}
function bF(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.V = +i[0], n + i[0].length) : -1;
}
function wF(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.W = +i[0], n + i[0].length) : -1;
}
function Jg(e, t, n) {
  var i = de.exec(t.slice(n, n + 4));
  return i ? (e.y = +i[0], n + i[0].length) : -1;
}
function Qg(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.y = +i[0] + (+i[0] > 68 ? 1900 : 2e3), n + i[0].length) : -1;
}
function _F(e, t, n) {
  var i = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6));
  return i ? (e.Z = i[1] ? 0 : -(i[2] + (i[3] || "00")), n + i[0].length) : -1;
}
function vF(e, t, n) {
  var i = de.exec(t.slice(n, n + 1));
  return i ? (e.q = i[0] * 3 - 3, n + i[0].length) : -1;
}
function xF(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.m = i[0] - 1, n + i[0].length) : -1;
}
function t1(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.d = +i[0], n + i[0].length) : -1;
}
function SF(e, t, n) {
  var i = de.exec(t.slice(n, n + 3));
  return i ? (e.m = 0, e.d = +i[0], n + i[0].length) : -1;
}
function e1(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.H = +i[0], n + i[0].length) : -1;
}
function MF(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.M = +i[0], n + i[0].length) : -1;
}
function AF(e, t, n) {
  var i = de.exec(t.slice(n, n + 2));
  return i ? (e.S = +i[0], n + i[0].length) : -1;
}
function $F(e, t, n) {
  var i = de.exec(t.slice(n, n + 3));
  return i ? (e.L = +i[0], n + i[0].length) : -1;
}
function IF(e, t, n) {
  var i = de.exec(t.slice(n, n + 6));
  return i ? (e.L = Math.floor(i[0] / 1e3), n + i[0].length) : -1;
}
function TF(e, t, n) {
  var i = hF.exec(t.slice(n, n + 1));
  return i ? n + i[0].length : -1;
}
function EF(e, t, n) {
  var i = de.exec(t.slice(n));
  return i ? (e.Q = +i[0], n + i[0].length) : -1;
}
function NF(e, t, n) {
  var i = de.exec(t.slice(n));
  return i ? (e.s = +i[0], n + i[0].length) : -1;
}
function n1(e, t) {
  return Mt(e.getDate(), t, 2);
}
function OF(e, t) {
  return Mt(e.getHours(), t, 2);
}
function FF(e, t) {
  return Mt(e.getHours() % 12 || 12, t, 2);
}
function DF(e, t) {
  return Mt(1 + No.count(ni(e), e), t, 3);
}
function wv(e, t) {
  return Mt(e.getMilliseconds(), t, 3);
}
function BF(e, t) {
  return wv(e, t) + "000";
}
function LF(e, t) {
  return Mt(e.getMonth() + 1, t, 2);
}
function CF(e, t) {
  return Mt(e.getMinutes(), t, 2);
}
function kF(e, t) {
  return Mt(e.getSeconds(), t, 2);
}
function RF(e) {
  var t = e.getDay();
  return t === 0 ? 7 : t;
}
function UF(e, t) {
  return Mt(yo.count(ni(e) - 1, e), t, 2);
}
function _v(e) {
  var t = e.getDay();
  return t >= 4 || t === 0 ? es(e) : es.ceil(e);
}
function zF(e, t) {
  return e = _v(e), Mt(es.count(ni(e), e) + (ni(e).getDay() === 4), t, 2);
}
function PF(e) {
  return e.getDay();
}
function YF(e, t) {
  return Mt(Oa.count(ni(e) - 1, e), t, 2);
}
function qF(e, t) {
  return Mt(e.getFullYear() % 100, t, 2);
}
function VF(e, t) {
  return e = _v(e), Mt(e.getFullYear() % 100, t, 2);
}
function jF(e, t) {
  return Mt(e.getFullYear() % 1e4, t, 4);
}
function XF(e, t) {
  var n = e.getDay();
  return e = n >= 4 || n === 0 ? es(e) : es.ceil(e), Mt(e.getFullYear() % 1e4, t, 4);
}
function WF(e) {
  var t = e.getTimezoneOffset();
  return (t > 0 ? "-" : (t *= -1, "+")) + Mt(t / 60 | 0, "0", 2) + Mt(t % 60, "0", 2);
}
function i1(e, t) {
  return Mt(e.getUTCDate(), t, 2);
}
function HF(e, t) {
  return Mt(e.getUTCHours(), t, 2);
}
function GF(e, t) {
  return Mt(e.getUTCHours() % 12 || 12, t, 2);
}
function ZF(e, t) {
  return Mt(1 + ic.count(ii(e), e), t, 3);
}
function vv(e, t) {
  return Mt(e.getUTCMilliseconds(), t, 3);
}
function KF(e, t) {
  return vv(e, t) + "000";
}
function JF(e, t) {
  return Mt(e.getUTCMonth() + 1, t, 2);
}
function QF(e, t) {
  return Mt(e.getUTCMinutes(), t, 2);
}
function tD(e, t) {
  return Mt(e.getUTCSeconds(), t, 2);
}
function eD(e) {
  var t = e.getUTCDay();
  return t === 0 ? 7 : t;
}
function nD(e, t) {
  return Mt(go.count(ii(e) - 1, e), t, 2);
}
function xv(e) {
  var t = e.getUTCDay();
  return t >= 4 || t === 0 ? ns(e) : ns.ceil(e);
}
function iD(e, t) {
  return e = xv(e), Mt(ns.count(ii(e), e) + (ii(e).getUTCDay() === 4), t, 2);
}
function rD(e) {
  return e.getUTCDay();
}
function sD(e, t) {
  return Mt(Fa.count(ii(e) - 1, e), t, 2);
}
function oD(e, t) {
  return Mt(e.getUTCFullYear() % 100, t, 2);
}
function aD(e, t) {
  return e = xv(e), Mt(e.getUTCFullYear() % 100, t, 2);
}
function cD(e, t) {
  return Mt(e.getUTCFullYear() % 1e4, t, 4);
}
function uD(e, t) {
  var n = e.getUTCDay();
  return e = n >= 4 || n === 0 ? ns(e) : ns.ceil(e), Mt(e.getUTCFullYear() % 1e4, t, 4);
}
function lD() {
  return "+0000";
}
function r1() {
  return "%";
}
function s1(e) {
  return +e;
}
function o1(e) {
  return Math.floor(+e / 1e3);
}
var gs, Sv, vf;
fD({
  dateTime: "%x, %X",
  date: "%-m/%-d/%Y",
  time: "%-I:%M:%S %p",
  periods: ["AM", "PM"],
  days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
  shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
});
function fD(e) {
  return gs = fF(e), Sv = gs.format, gs.parse, vf = gs.utcFormat, gs.utcParse, gs;
}
function hD(e) {
  return new Date(e);
}
function dD(e) {
  return e instanceof Date ? +e : +new Date(+e);
}
function kp(e, t, n, i, r, s, o, a, c, u) {
  var l = K_(), f = l.invert, h = l.domain, d = u(".%L"), p = u(":%S"), g = u("%I:%M"), y = u("%I %p"), m = u("%a %d"), b = u("%b %d"), w = u("%B"), _ = u("%Y");
  function x(S) {
    return (c(S) < S ? d : a(S) < S ? p : o(S) < S ? g : s(S) < S ? y : i(S) < S ? r(S) < S ? m : b : n(S) < S ? w : _)(S);
  }
  return l.invert = function(S) {
    return new Date(f(S));
  }, l.domain = function(S) {
    return arguments.length ? h(Array.from(S, dD)) : h().map(hD);
  }, l.ticks = function(S) {
    var I = h();
    return e(I[0], I[I.length - 1], S ?? 10);
  }, l.tickFormat = function(S, I) {
    return I == null ? x : u(I);
  }, l.nice = function(S) {
    var I = h();
    return (!S || typeof S.range != "function") && (S = t(I[0], I[I.length - 1], S ?? 10)), S ? h(Q_(I, S)) : l;
  }, l.copy = function() {
    return ec(l, kp(e, t, n, i, r, s, o, a, c, u));
  }, l;
}
function pD() {
  return oi.apply(kp(uF, lF, ni, wf, yo, No, gf, mf, Ei, Sv).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
function mD() {
  return oi.apply(kp(cF, bv, ii, _f, go, ic, bf, yf, Ei, vf).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
}
function xf(e, t) {
  return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown());
}
function Sf() {
  var e = 0, t = 0.5, n = 1, i = 1, r, s, o, a, c, u = an, l, f = !1, h;
  function d(g) {
    return isNaN(g = +g) ? h : (g = 0.5 + ((g = +l(g)) - s) * (i * g < i * s ? a : c), u(f ? Math.max(0, Math.min(1, g)) : g));
  }
  d.domain = function(g) {
    return arguments.length ? ([e, t, n] = g, r = l(e = +e), s = l(t = +t), o = l(n = +n), a = r === s ? 0 : 0.5 / (s - r), c = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, d) : [e, t, n];
  }, d.clamp = function(g) {
    return arguments.length ? (f = !!g, d) : f;
  }, d.interpolator = function(g) {
    return arguments.length ? (u = g, d) : u;
  };
  function p(g) {
    return function(y) {
      var m, b, w;
      return arguments.length ? ([m, b, w] = y, u = Sp(g, [m, b, w]), d) : [u(0), u(0.5), u(1)];
    };
  }
  return d.range = p(Io), d.rangeRound = p(vp), d.unknown = function(g) {
    return arguments.length ? (h = g, d) : h;
  }, function(g) {
    return l = g, r = g(e), s = g(t), o = g(n), a = r === s ? 0 : 0.5 / (s - r), c = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, d;
  };
}
function Mv() {
  var e = nc(Sf()(an));
  return e.copy = function() {
    return xf(e, Mv());
  }, ff.apply(e, arguments);
}
function Av() {
  var e = tv(Sf()).domain([0.1, 1, 10]);
  return e.copy = function() {
    return xf(e, Av()).base(e.base());
  }, ff.apply(e, arguments);
}
function $v() {
  var e = nv(Sf());
  return e.copy = function() {
    return xf(e, $v()).constant(e.constant());
  }, ff.apply(e, arguments);
}
function Iv() {
  var e = rv(Sf());
  return e.copy = function() {
    return xf(e, Iv()).exponent(e.exponent());
  }, ff.apply(e, arguments);
}
function ft(e) {
  for (var t = e.length / 6 | 0, n = new Array(t), i = 0; i < t; )
    n[i] = "#" + e.slice(i * 6, ++i * 6);
  return n;
}
const yD = ft("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"), gD = ft("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"), bD = ft("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"), wD = ft("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"), _D = ft("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"), vD = ft("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"), xD = ft("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"), SD = ft("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"), MD = ft("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"), AD = ft("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"), Rt = (e) => IT(e[e.length - 1]);
var Tv = new Array(3).concat(
  "d8b365f5f5f55ab4ac",
  "a6611adfc27d80cdc1018571",
  "a6611adfc27df5f5f580cdc1018571",
  "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
  "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
  "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
  "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
  "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
  "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
).map(ft);
const Ev = Rt(Tv);
var Nv = new Array(3).concat(
  "af8dc3f7f7f77fbf7b",
  "7b3294c2a5cfa6dba0008837",
  "7b3294c2a5cff7f7f7a6dba0008837",
  "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
  "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
  "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
  "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
  "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
  "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
).map(ft);
const Ov = Rt(Nv);
var Fv = new Array(3).concat(
  "e9a3c9f7f7f7a1d76a",
  "d01c8bf1b6dab8e1864dac26",
  "d01c8bf1b6daf7f7f7b8e1864dac26",
  "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
  "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
  "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
  "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
  "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
  "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
).map(ft);
const Dv = Rt(Fv);
var Bv = new Array(3).concat(
  "998ec3f7f7f7f1a340",
  "5e3c99b2abd2fdb863e66101",
  "5e3c99b2abd2f7f7f7fdb863e66101",
  "542788998ec3d8daebfee0b6f1a340b35806",
  "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
  "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
  "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
  "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
  "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
).map(ft);
const Lv = Rt(Bv);
var h0 = new Array(3).concat(
  "ef8a62f7f7f767a9cf",
  "ca0020f4a58292c5de0571b0",
  "ca0020f4a582f7f7f792c5de0571b0",
  "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
  "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
  "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
  "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
  "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
  "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
).map(ft);
const _l = Rt(h0);
var Cv = new Array(3).concat(
  "ef8a62ffffff999999",
  "ca0020f4a582bababa404040",
  "ca0020f4a582ffffffbababa404040",
  "b2182bef8a62fddbc7e0e0e09999994d4d4d",
  "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
  "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
  "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
  "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
  "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
).map(ft);
const kv = Rt(Cv);
var d0 = new Array(3).concat(
  "fc8d59ffffbf91bfdb",
  "d7191cfdae61abd9e92c7bb6",
  "d7191cfdae61ffffbfabd9e92c7bb6",
  "d73027fc8d59fee090e0f3f891bfdb4575b4",
  "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
  "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
  "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
  "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
  "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
).map(ft);
const vl = Rt(d0);
var Rv = new Array(3).concat(
  "fc8d59ffffbf91cf60",
  "d7191cfdae61a6d96a1a9641",
  "d7191cfdae61ffffbfa6d96a1a9641",
  "d73027fc8d59fee08bd9ef8b91cf601a9850",
  "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
  "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
  "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
  "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
  "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
).map(ft);
const Uv = Rt(Rv);
var zv = new Array(3).concat(
  "fc8d59ffffbf99d594",
  "d7191cfdae61abdda42b83ba",
  "d7191cfdae61ffffbfabdda42b83ba",
  "d53e4ffc8d59fee08be6f59899d5943288bd",
  "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
  "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
  "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
  "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
  "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
).map(ft);
const Pv = Rt(zv);
var Yv = new Array(3).concat(
  "e5f5f999d8c92ca25f",
  "edf8fbb2e2e266c2a4238b45",
  "edf8fbb2e2e266c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
).map(ft);
const qv = Rt(Yv);
var Vv = new Array(3).concat(
  "e0ecf49ebcda8856a7",
  "edf8fbb3cde38c96c688419d",
  "edf8fbb3cde38c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
).map(ft);
const jv = Rt(Vv);
var Xv = new Array(3).concat(
  "e0f3dba8ddb543a2ca",
  "f0f9e8bae4bc7bccc42b8cbe",
  "f0f9e8bae4bc7bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
).map(ft);
const Wv = Rt(Xv);
var Hv = new Array(3).concat(
  "fee8c8fdbb84e34a33",
  "fef0d9fdcc8afc8d59d7301f",
  "fef0d9fdcc8afc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
).map(ft);
const Gv = Rt(Hv);
var Zv = new Array(3).concat(
  "ece2f0a6bddb1c9099",
  "f6eff7bdc9e167a9cf02818a",
  "f6eff7bdc9e167a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
).map(ft);
const Kv = Rt(Zv);
var Jv = new Array(3).concat(
  "ece7f2a6bddb2b8cbe",
  "f1eef6bdc9e174a9cf0570b0",
  "f1eef6bdc9e174a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
).map(ft);
const Qv = Rt(Jv);
var tx = new Array(3).concat(
  "e7e1efc994c7dd1c77",
  "f1eef6d7b5d8df65b0ce1256",
  "f1eef6d7b5d8df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
).map(ft);
const ex = Rt(tx);
var nx = new Array(3).concat(
  "fde0ddfa9fb5c51b8a",
  "feebe2fbb4b9f768a1ae017e",
  "feebe2fbb4b9f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
).map(ft);
const ix = Rt(nx);
var rx = new Array(3).concat(
  "edf8b17fcdbb2c7fb8",
  "ffffcca1dab441b6c4225ea8",
  "ffffcca1dab441b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
).map(ft);
const sx = Rt(rx);
var ox = new Array(3).concat(
  "f7fcb9addd8e31a354",
  "ffffccc2e69978c679238443",
  "ffffccc2e69978c67931a354006837",
  "ffffccd9f0a3addd8e78c67931a354006837",
  "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
).map(ft);
const ax = Rt(ox);
var cx = new Array(3).concat(
  "fff7bcfec44fd95f0e",
  "ffffd4fed98efe9929cc4c02",
  "ffffd4fed98efe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
).map(ft);
const ux = Rt(cx);
var lx = new Array(3).concat(
  "ffeda0feb24cf03b20",
  "ffffb2fecc5cfd8d3ce31a1c",
  "ffffb2fecc5cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
).map(ft);
const fx = Rt(lx);
var hx = new Array(3).concat(
  "deebf79ecae13182bd",
  "eff3ffbdd7e76baed62171b5",
  "eff3ffbdd7e76baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
).map(ft);
const dx = Rt(hx);
var px = new Array(3).concat(
  "e5f5e0a1d99b31a354",
  "edf8e9bae4b374c476238b45",
  "edf8e9bae4b374c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
).map(ft);
const mx = Rt(px);
var yx = new Array(3).concat(
  "f0f0f0bdbdbd636363",
  "f7f7f7cccccc969696525252",
  "f7f7f7cccccc969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
).map(ft);
const gx = Rt(yx);
var bx = new Array(3).concat(
  "efedf5bcbddc756bb1",
  "f2f0f7cbc9e29e9ac86a51a3",
  "f2f0f7cbc9e29e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
).map(ft);
const wx = Rt(bx);
var _x = new Array(3).concat(
  "fee0d2fc9272de2d26",
  "fee5d9fcae91fb6a4acb181d",
  "fee5d9fcae91fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
).map(ft);
const vx = Rt(_x);
var xx = new Array(3).concat(
  "fee6cefdae6be6550d",
  "feeddefdbe85fd8d3cd94701",
  "feeddefdbe85fd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
).map(ft);
const Sx = Rt(xx);
function Mx(e) {
  return e = Math.max(0, Math.min(1, e)), "rgb(" + Math.max(0, Math.min(255, Math.round(-4.54 - e * (35.34 - e * (2381.73 - e * (6402.7 - e * (7024.72 - e * 2710.57))))))) + ", " + Math.max(0, Math.min(255, Math.round(32.49 + e * (170.73 + e * (52.82 - e * (131.46 - e * (176.58 - e * 67.37))))))) + ", " + Math.max(0, Math.min(255, Math.round(81.24 + e * (442.36 - e * (2482.43 - e * (6167.24 - e * (6614.94 - e * 2475.67))))))) + ")";
}
const Ax = xp(ei(300, 0.5, 0), ei(-240, 0.5, 1));
var $x = xp(ei(-100, 0.75, 0.35), ei(80, 1.5, 0.8)), Ix = xp(ei(260, 0.75, 0.35), ei(80, 1.5, 0.8)), Dc = ei();
function Tx(e) {
  (e < 0 || e > 1) && (e -= Math.floor(e));
  var t = Math.abs(e - 0.5);
  return Dc.h = 360 * e - 100, Dc.s = 1.5 - 1.5 * t, Dc.l = 0.8 - 0.9 * t, Dc + "";
}
var Bc = pn(), $D = Math.PI / 3, ID = Math.PI * 2 / 3;
function Ex(e) {
  var t;
  return e = (0.5 - e) * Math.PI, Bc.r = 255 * (t = Math.sin(e)) * t, Bc.g = 255 * (t = Math.sin(e + $D)) * t, Bc.b = 255 * (t = Math.sin(e + ID)) * t, Bc + "";
}
function Nx(e) {
  return e = Math.max(0, Math.min(1, e)), "rgb(" + Math.max(0, Math.min(255, Math.round(34.61 + e * (1172.33 - e * (10793.56 - e * (33300.12 - e * (38394.49 - e * 14825.05))))))) + ", " + Math.max(0, Math.min(255, Math.round(23.31 + e * (557.33 + e * (1225.33 - e * (3574.96 - e * (1073.77 + e * 707.56))))))) + ", " + Math.max(0, Math.min(255, Math.round(27.2 + e * (3211.1 - e * (15327.97 - e * (27814 - e * (22569.18 - e * 6838.66))))))) + ")";
}
function Mf(e) {
  var t = e.length;
  return function(n) {
    return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))];
  };
}
const Ox = Mf(ft("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
var Fx = Mf(ft("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")), Dx = Mf(ft("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")), Bx = Mf(ft("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
function ue(e) {
  return function() {
    return e;
  };
}
const Lx = Math.cos, Rp = Math.min, xl = Math.sin, ae = Math.sqrt, a1 = 1e-12, Sl = Math.PI, Af = 2 * Sl;
function Cx(e) {
  let t = 3;
  return e.digits = function(n) {
    if (!arguments.length)
      return t;
    if (n == null)
      t = null;
    else {
      const i = Math.floor(n);
      if (!(i >= 0))
        throw new RangeError(`invalid digits: ${n}`);
      t = i;
    }
    return e;
  }, () => new a_(t);
}
function kx(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function Rx(e) {
  this._context = e;
}
Rx.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
      default:
        this._context.lineTo(e, t);
        break;
    }
  }
};
function rc(e) {
  return new Rx(e);
}
function Ux(e) {
  return e[0];
}
function zx(e) {
  return e[1];
}
function Px(e, t) {
  var n = ue(!0), i = null, r = rc, s = null, o = Cx(a);
  e = typeof e == "function" ? e : e === void 0 ? Ux : ue(e), t = typeof t == "function" ? t : t === void 0 ? zx : ue(t);
  function a(c) {
    var u, l = (c = kx(c)).length, f, h = !1, d;
    for (i == null && (s = r(d = o())), u = 0; u <= l; ++u)
      !(u < l && n(f = c[u], u, c)) === h && ((h = !h) ? s.lineStart() : s.lineEnd()), h && s.point(+e(f, u, c), +t(f, u, c));
    if (d)
      return s = null, d + "" || null;
  }
  return a.x = function(c) {
    return arguments.length ? (e = typeof c == "function" ? c : ue(+c), a) : e;
  }, a.y = function(c) {
    return arguments.length ? (t = typeof c == "function" ? c : ue(+c), a) : t;
  }, a.defined = function(c) {
    return arguments.length ? (n = typeof c == "function" ? c : ue(!!c), a) : n;
  }, a.curve = function(c) {
    return arguments.length ? (r = c, i != null && (s = r(i)), a) : r;
  }, a.context = function(c) {
    return arguments.length ? (c == null ? i = s = null : s = r(i = c), a) : i;
  }, a;
}
function Up(e, t, n) {
  var i = null, r = ue(!0), s = null, o = rc, a = null, c = Cx(u);
  e = typeof e == "function" ? e : e === void 0 ? Ux : ue(+e), t = typeof t == "function" ? t : ue(t === void 0 ? 0 : +t), n = typeof n == "function" ? n : n === void 0 ? zx : ue(+n);
  function u(f) {
    var h, d, p, g = (f = kx(f)).length, y, m = !1, b, w = new Array(g), _ = new Array(g);
    for (s == null && (a = o(b = c())), h = 0; h <= g; ++h) {
      if (!(h < g && r(y = f[h], h, f)) === m)
        if (m = !m)
          d = h, a.areaStart(), a.lineStart();
        else {
          for (a.lineEnd(), a.lineStart(), p = h - 1; p >= d; --p)
            a.point(w[p], _[p]);
          a.lineEnd(), a.areaEnd();
        }
      m && (w[h] = +e(y, h, f), _[h] = +t(y, h, f), a.point(i ? +i(y, h, f) : w[h], n ? +n(y, h, f) : _[h]));
    }
    if (b)
      return a = null, b + "" || null;
  }
  function l() {
    return Px().defined(r).curve(o).context(s);
  }
  return u.x = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : ue(+f), i = null, u) : e;
  }, u.x0 = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : ue(+f), u) : e;
  }, u.x1 = function(f) {
    return arguments.length ? (i = f == null ? null : typeof f == "function" ? f : ue(+f), u) : i;
  }, u.y = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : ue(+f), n = null, u) : t;
  }, u.y0 = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : ue(+f), u) : t;
  }, u.y1 = function(f) {
    return arguments.length ? (n = f == null ? null : typeof f == "function" ? f : ue(+f), u) : n;
  }, u.lineX0 = u.lineY0 = function() {
    return l().x(e).y(t);
  }, u.lineY1 = function() {
    return l().x(e).y(n);
  }, u.lineX1 = function() {
    return l().x(i).y(t);
  }, u.defined = function(f) {
    return arguments.length ? (r = typeof f == "function" ? f : ue(!!f), u) : r;
  }, u.curve = function(f) {
    return arguments.length ? (o = f, s != null && (a = o(s)), u) : o;
  }, u.context = function(f) {
    return arguments.length ? (f == null ? s = a = null : a = o(s = f), u) : s;
  }, u;
}
class Yx {
  constructor(t, n) {
    this._context = t, this._x = n;
  }
  areaStart() {
    this._line = 0;
  }
  areaEnd() {
    this._line = NaN;
  }
  lineStart() {
    this._point = 0;
  }
  lineEnd() {
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  }
  point(t, n) {
    switch (t = +t, n = +n, this._point) {
      case 0: {
        this._point = 1, this._line ? this._context.lineTo(t, n) : this._context.moveTo(t, n);
        break;
      }
      case 1:
        this._point = 2;
      default: {
        this._x ? this._context.bezierCurveTo(this._x0 = (this._x0 + t) / 2, this._y0, this._x0, n, t, n) : this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + n) / 2, t, this._y0, t, n);
        break;
      }
    }
    this._x0 = t, this._y0 = n;
  }
}
function TD(e) {
  return new Yx(e, !0);
}
function ED(e) {
  return new Yx(e, !1);
}
const ND = ae(3), qx = {
  draw(e, t) {
    const n = ae(t + Rp(t / 28, 0.75)) * 0.59436, i = n / 2, r = i * ND;
    e.moveTo(0, n), e.lineTo(0, -n), e.moveTo(-r, -i), e.lineTo(r, i), e.moveTo(-r, i), e.lineTo(r, -i);
  }
}, Da = {
  draw(e, t) {
    const n = ae(t / Sl);
    e.moveTo(n, 0), e.arc(0, 0, n, 0, Af);
  }
}, Vx = {
  draw(e, t) {
    const n = ae(t / 5) / 2;
    e.moveTo(-3 * n, -n), e.lineTo(-n, -n), e.lineTo(-n, -3 * n), e.lineTo(n, -3 * n), e.lineTo(n, -n), e.lineTo(3 * n, -n), e.lineTo(3 * n, n), e.lineTo(n, n), e.lineTo(n, 3 * n), e.lineTo(-n, 3 * n), e.lineTo(-n, n), e.lineTo(-3 * n, n), e.closePath();
  }
}, jx = ae(1 / 3), OD = jx * 2, Xx = {
  draw(e, t) {
    const n = ae(t / OD), i = n * jx;
    e.moveTo(0, -n), e.lineTo(i, 0), e.lineTo(0, n), e.lineTo(-i, 0), e.closePath();
  }
}, Wx = {
  draw(e, t) {
    const n = ae(t) * 0.62625;
    e.moveTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.lineTo(-n, 0), e.closePath();
  }
}, Hx = {
  draw(e, t) {
    const n = ae(t - Rp(t / 7, 2)) * 0.87559;
    e.moveTo(-n, 0), e.lineTo(n, 0), e.moveTo(0, n), e.lineTo(0, -n);
  }
}, Gx = {
  draw(e, t) {
    const n = ae(t), i = -n / 2;
    e.rect(i, i, n, n);
  }
}, Zx = {
  draw(e, t) {
    const n = ae(t) * 0.4431;
    e.moveTo(n, n), e.lineTo(n, -n), e.lineTo(-n, -n), e.lineTo(-n, n), e.closePath();
  }
}, FD = 0.8908130915292852, Kx = xl(Sl / 10) / xl(7 * Sl / 10), DD = xl(Af / 10) * Kx, BD = -Lx(Af / 10) * Kx, Jx = {
  draw(e, t) {
    const n = ae(t * FD), i = DD * n, r = BD * n;
    e.moveTo(0, -n), e.lineTo(i, r);
    for (let s = 1; s < 5; ++s) {
      const o = Af * s / 5, a = Lx(o), c = xl(o);
      e.lineTo(c * n, -a * n), e.lineTo(a * i - c * r, c * i + a * r);
    }
    e.closePath();
  }
}, Vh = ae(3), Qx = {
  draw(e, t) {
    const n = -ae(t / (Vh * 3));
    e.moveTo(0, n * 2), e.lineTo(-Vh * n, -n), e.lineTo(Vh * n, -n), e.closePath();
  }
}, LD = ae(3), t3 = {
  draw(e, t) {
    const n = ae(t) * 0.6824, i = n / 2, r = n * LD / 2;
    e.moveTo(0, -n), e.lineTo(r, i), e.lineTo(-r, i), e.closePath();
  }
}, Ke = -0.5, Je = ae(3) / 2, p0 = 1 / ae(12), CD = (p0 / 2 + 1) * 3, e3 = {
  draw(e, t) {
    const n = ae(t / CD), i = n / 2, r = n * p0, s = i, o = n * p0 + n, a = -s, c = o;
    e.moveTo(i, r), e.lineTo(s, o), e.lineTo(a, c), e.lineTo(Ke * i - Je * r, Je * i + Ke * r), e.lineTo(Ke * s - Je * o, Je * s + Ke * o), e.lineTo(Ke * a - Je * c, Je * a + Ke * c), e.lineTo(Ke * i + Je * r, Ke * r - Je * i), e.lineTo(Ke * s + Je * o, Ke * o - Je * s), e.lineTo(Ke * a + Je * c, Ke * c - Je * a), e.closePath();
  }
}, n3 = {
  draw(e, t) {
    const n = ae(t - Rp(t / 6, 1.7)) * 0.6189;
    e.moveTo(-n, -n), e.lineTo(n, n), e.moveTo(-n, n), e.lineTo(n, -n);
  }
}, kD = [
  Da,
  Vx,
  Xx,
  Gx,
  Jx,
  Qx,
  e3
], RD = [
  Da,
  Hx,
  n3,
  t3,
  qx,
  Zx,
  Wx
];
function cr() {
}
function Ml(e, t, n) {
  e._context.bezierCurveTo(
    (2 * e._x0 + e._x1) / 3,
    (2 * e._y0 + e._y1) / 3,
    (e._x0 + 2 * e._x1) / 3,
    (e._y0 + 2 * e._y1) / 3,
    (e._x0 + 4 * e._x1 + t) / 6,
    (e._y0 + 4 * e._y1 + n) / 6
  );
}
function $f(e) {
  this._context = e;
}
$f.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 3:
        Ml(this, this._x1, this._y1);
      case 2:
        this._context.lineTo(this._x1, this._y1);
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3, this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
      default:
        Ml(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function UD(e) {
  return new $f(e);
}
function i3(e) {
  this._context = e;
}
i3.prototype = {
  areaStart: cr,
  areaEnd: cr,
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 1: {
        this._context.moveTo(this._x2, this._y2), this._context.closePath();
        break;
      }
      case 2: {
        this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3), this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3), this._context.closePath();
        break;
      }
      case 3: {
        this.point(this._x2, this._y2), this.point(this._x3, this._y3), this.point(this._x4, this._y4);
        break;
      }
    }
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._x2 = e, this._y2 = t;
        break;
      case 1:
        this._point = 2, this._x3 = e, this._y3 = t;
        break;
      case 2:
        this._point = 3, this._x4 = e, this._y4 = t, this._context.moveTo((this._x0 + 4 * this._x1 + e) / 6, (this._y0 + 4 * this._y1 + t) / 6);
        break;
      default:
        Ml(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function zD(e) {
  return new i3(e);
}
function r3(e) {
  this._context = e;
}
r3.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3;
        var n = (this._x0 + 4 * this._x1 + e) / 6, i = (this._y0 + 4 * this._y1 + t) / 6;
        this._line ? this._context.lineTo(n, i) : this._context.moveTo(n, i);
        break;
      case 3:
        this._point = 4;
      default:
        Ml(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function PD(e) {
  return new r3(e);
}
function s3(e, t) {
  this._basis = new $f(e), this._beta = t;
}
s3.prototype = {
  lineStart: function() {
    this._x = [], this._y = [], this._basis.lineStart();
  },
  lineEnd: function() {
    var e = this._x, t = this._y, n = e.length - 1;
    if (n > 0)
      for (var i = e[0], r = t[0], s = e[n] - i, o = t[n] - r, a = -1, c; ++a <= n; )
        c = a / n, this._basis.point(
          this._beta * e[a] + (1 - this._beta) * (i + c * s),
          this._beta * t[a] + (1 - this._beta) * (r + c * o)
        );
    this._x = this._y = null, this._basis.lineEnd();
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
const YD = function e(t) {
  function n(i) {
    return t === 1 ? new $f(i) : new s3(i, t);
  }
  return n.beta = function(i) {
    return e(+i);
  }, n;
}(0.85);
function Al(e, t, n) {
  e._context.bezierCurveTo(
    e._x1 + e._k * (e._x2 - e._x0),
    e._y1 + e._k * (e._y2 - e._y0),
    e._x2 + e._k * (e._x1 - t),
    e._y2 + e._k * (e._y1 - n),
    e._x2,
    e._y2
  );
}
function zp(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
zp.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 2:
        this._context.lineTo(this._x2, this._y2);
        break;
      case 3:
        Al(this, this._x1, this._y1);
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2, this._x1 = e, this._y1 = t;
        break;
      case 2:
        this._point = 3;
      default:
        Al(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const qD = function e(t) {
  function n(i) {
    return new zp(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function Pp(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Pp.prototype = {
  areaStart: cr,
  areaEnd: cr,
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 1: {
        this._context.moveTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 2: {
        this._context.lineTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 3: {
        this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5);
        break;
      }
    }
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._x3 = e, this._y3 = t;
        break;
      case 1:
        this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t);
        break;
      case 2:
        this._point = 3, this._x5 = e, this._y5 = t;
        break;
      default:
        Al(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const VD = function e(t) {
  function n(i) {
    return new Pp(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function Yp(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Yp.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
        break;
      case 3:
        this._point = 4;
      default:
        Al(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const jD = function e(t) {
  function n(i) {
    return new Yp(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function qp(e, t, n) {
  var i = e._x1, r = e._y1, s = e._x2, o = e._y2;
  if (e._l01_a > a1) {
    var a = 2 * e._l01_2a + 3 * e._l01_a * e._l12_a + e._l12_2a, c = 3 * e._l01_a * (e._l01_a + e._l12_a);
    i = (i * a - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / c, r = (r * a - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / c;
  }
  if (e._l23_a > a1) {
    var u = 2 * e._l23_2a + 3 * e._l23_a * e._l12_a + e._l12_2a, l = 3 * e._l23_a * (e._l23_a + e._l12_a);
    s = (s * u + e._x1 * e._l23_2a - t * e._l12_2a) / l, o = (o * u + e._y1 * e._l23_2a - n * e._l12_2a) / l;
  }
  e._context.bezierCurveTo(i, r, s, o, e._x2, e._y2);
}
function o3(e, t) {
  this._context = e, this._alpha = t;
}
o3.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 2:
        this._context.lineTo(this._x2, this._y2);
        break;
      case 3:
        this.point(this._x2, this._y2);
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3;
      default:
        qp(this, e, t);
        break;
    }
    this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const XD = function e(t) {
  function n(i) {
    return t ? new o3(i, t) : new zp(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function a3(e, t) {
  this._context = e, this._alpha = t;
}
a3.prototype = {
  areaStart: cr,
  areaEnd: cr,
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 1: {
        this._context.moveTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 2: {
        this._context.lineTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 3: {
        this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5);
        break;
      }
    }
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1, this._x3 = e, this._y3 = t;
        break;
      case 1:
        this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t);
        break;
      case 2:
        this._point = 3, this._x5 = e, this._y5 = t;
        break;
      default:
        qp(this, e, t);
        break;
    }
    this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const WD = function e(t) {
  function n(i) {
    return t ? new a3(i, t) : new Pp(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function c3(e, t) {
  this._context = e, this._alpha = t;
}
c3.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
        break;
      case 3:
        this._point = 4;
      default:
        qp(this, e, t);
        break;
    }
    this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
  }
};
const HD = function e(t) {
  function n(i) {
    return t ? new c3(i, t) : new Yp(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function u3(e) {
  this._context = e;
}
u3.prototype = {
  areaStart: cr,
  areaEnd: cr,
  lineStart: function() {
    this._point = 0;
  },
  lineEnd: function() {
    this._point && this._context.closePath();
  },
  point: function(e, t) {
    e = +e, t = +t, this._point ? this._context.lineTo(e, t) : (this._point = 1, this._context.moveTo(e, t));
  }
};
function GD(e) {
  return new u3(e);
}
function c1(e) {
  return e < 0 ? -1 : 1;
}
function u1(e, t, n) {
  var i = e._x1 - e._x0, r = t - e._x1, s = (e._y1 - e._y0) / (i || r < 0 && -0), o = (n - e._y1) / (r || i < 0 && -0), a = (s * r + o * i) / (i + r);
  return (c1(s) + c1(o)) * Math.min(Math.abs(s), Math.abs(o), 0.5 * Math.abs(a)) || 0;
}
function l1(e, t) {
  var n = e._x1 - e._x0;
  return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
}
function jh(e, t, n) {
  var i = e._x0, r = e._y0, s = e._x1, o = e._y1, a = (s - i) / 3;
  e._context.bezierCurveTo(i + a, r + a * t, s - a, o - a * n, s, o);
}
function $l(e) {
  this._context = e;
}
$l.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN, this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 2:
        this._context.lineTo(this._x1, this._y1);
        break;
      case 3:
        jh(this, this._t0, l1(this, this._t0));
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    var n = NaN;
    if (e = +e, t = +t, !(e === this._x1 && t === this._y1)) {
      switch (this._point) {
        case 0:
          this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
          break;
        case 1:
          this._point = 2;
          break;
        case 2:
          this._point = 3, jh(this, l1(this, n = u1(this, e, t)), n);
          break;
        default:
          jh(this, this._t0, n = u1(this, e, t));
          break;
      }
      this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
    }
  }
};
function l3(e) {
  this._context = new f3(e);
}
(l3.prototype = Object.create($l.prototype)).point = function(e, t) {
  $l.prototype.point.call(this, t, e);
};
function f3(e) {
  this._context = e;
}
f3.prototype = {
  moveTo: function(e, t) {
    this._context.moveTo(t, e);
  },
  closePath: function() {
    this._context.closePath();
  },
  lineTo: function(e, t) {
    this._context.lineTo(t, e);
  },
  bezierCurveTo: function(e, t, n, i, r, s) {
    this._context.bezierCurveTo(t, e, i, n, s, r);
  }
};
function ZD(e) {
  return new $l(e);
}
function KD(e) {
  return new l3(e);
}
function h3(e) {
  this._context = e;
}
h3.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x = [], this._y = [];
  },
  lineEnd: function() {
    var e = this._x, t = this._y, n = e.length;
    if (n)
      if (this._line ? this._context.lineTo(e[0], t[0]) : this._context.moveTo(e[0], t[0]), n === 2)
        this._context.lineTo(e[1], t[1]);
      else
        for (var i = f1(e), r = f1(t), s = 0, o = 1; o < n; ++s, ++o)
          this._context.bezierCurveTo(i[0][s], r[0][s], i[1][s], r[1][s], e[o], t[o]);
    (this._line || this._line !== 0 && n === 1) && this._context.closePath(), this._line = 1 - this._line, this._x = this._y = null;
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
function f1(e) {
  var t, n = e.length - 1, i, r = new Array(n), s = new Array(n), o = new Array(n);
  for (r[0] = 0, s[0] = 2, o[0] = e[0] + 2 * e[1], t = 1; t < n - 1; ++t)
    r[t] = 1, s[t] = 4, o[t] = 4 * e[t] + 2 * e[t + 1];
  for (r[n - 1] = 2, s[n - 1] = 7, o[n - 1] = 8 * e[n - 1] + e[n], t = 1; t < n; ++t)
    i = r[t] / s[t - 1], s[t] -= i, o[t] -= i * o[t - 1];
  for (r[n - 1] = o[n - 1] / s[n - 1], t = n - 2; t >= 0; --t)
    r[t] = (o[t] - r[t + 1]) / s[t];
  for (s[n - 1] = (e[n] + r[n - 1]) / 2, t = 0; t < n - 1; ++t)
    s[t] = 2 * e[t + 1] - r[t + 1];
  return [r, s];
}
function JD(e) {
  return new h3(e);
}
function If(e, t) {
  this._context = e, this._t = t;
}
If.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x = this._y = NaN, this._point = 0;
  },
  lineEnd: function() {
    0 < this._t && this._t < 1 && this._point === 2 && this._context.lineTo(this._x, this._y), (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line >= 0 && (this._t = 1 - this._t, this._line = 1 - this._line);
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
      default: {
        if (this._t <= 0)
          this._context.lineTo(this._x, t), this._context.lineTo(e, t);
        else {
          var n = this._x * (1 - this._t) + e * this._t;
          this._context.lineTo(n, this._y), this._context.lineTo(n, t);
        }
        break;
      }
    }
    this._x = e, this._y = t;
  }
};
function QD(e) {
  return new If(e, 0.5);
}
function tB(e) {
  return new If(e, 0);
}
function eB(e) {
  return new If(e, 1);
}
const Lc = (e) => () => e;
function nB(e, {
  sourceEvent: t,
  target: n,
  transform: i,
  dispatch: r
}) {
  Object.defineProperties(this, {
    type: { value: e, enumerable: !0, configurable: !0 },
    sourceEvent: { value: t, enumerable: !0, configurable: !0 },
    target: { value: n, enumerable: !0, configurable: !0 },
    transform: { value: i, enumerable: !0, configurable: !0 },
    _: { value: r }
  });
}
function Wn(e, t, n) {
  this.k = e, this.x = t, this.y = n;
}
Wn.prototype = {
  constructor: Wn,
  scale: function(e) {
    return e === 1 ? this : new Wn(this.k * e, this.x, this.y);
  },
  translate: function(e, t) {
    return e === 0 & t === 0 ? this : new Wn(this.k, this.x + this.k * e, this.y + this.k * t);
  },
  apply: function(e) {
    return [e[0] * this.k + this.x, e[1] * this.k + this.y];
  },
  applyX: function(e) {
    return e * this.k + this.x;
  },
  applyY: function(e) {
    return e * this.k + this.y;
  },
  invert: function(e) {
    return [(e[0] - this.x) / this.k, (e[1] - this.y) / this.k];
  },
  invertX: function(e) {
    return (e - this.x) / this.k;
  },
  invertY: function(e) {
    return (e - this.y) / this.k;
  },
  rescaleX: function(e) {
    return e.copy().domain(e.range().map(this.invertX, this).map(e.invert, e));
  },
  rescaleY: function(e) {
    return e.copy().domain(e.range().map(this.invertY, this).map(e.invert, e));
  },
  toString: function() {
    return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
  }
};
var d3 = new Wn(1, 0, 0);
Wn.prototype;
function Xh(e) {
  e.stopImmediatePropagation();
}
function Wo(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function iB(e) {
  return (!e.ctrlKey || e.type === "wheel") && !e.button;
}
function rB() {
  var e = this;
  return e instanceof SVGElement ? (e = e.ownerSVGElement || e, e.hasAttribute("viewBox") ? (e = e.viewBox.baseVal, [[e.x, e.y], [e.x + e.width, e.y + e.height]]) : [[0, 0], [e.width.baseVal.value, e.height.baseVal.value]]) : [[0, 0], [e.clientWidth, e.clientHeight]];
}
function h1() {
  return this.__zoom || d3;
}
function sB(e) {
  return -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 2e-3) * (e.ctrlKey ? 10 : 1);
}
function oB() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function aB(e, t, n) {
  var i = e.invertX(t[0][0]) - n[0][0], r = e.invertX(t[1][0]) - n[1][0], s = e.invertY(t[0][1]) - n[0][1], o = e.invertY(t[1][1]) - n[1][1];
  return e.translate(
    r > i ? (i + r) / 2 : Math.min(0, i) || Math.max(0, r),
    o > s ? (s + o) / 2 : Math.min(0, s) || Math.max(0, o)
  );
}
function cB() {
  var e = iB, t = rB, n = aB, i = sB, r = oB, s = [0, 1 / 0], o = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], a = 250, c = YT, u = ef("start", "zoom", "end"), l, f, h, d = 500, p = 150, g = 0, y = 10;
  function m(v) {
    v.property("__zoom", h1).on("wheel.zoom", N, { passive: !1 }).on("mousedown.zoom", F).on("dblclick.zoom", $).filter(r).on("touchstart.zoom", T).on("touchmove.zoom", D).on("touchend.zoom touchcancel.zoom", E).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  m.transform = function(v, M, A, O) {
    var L = v.selection ? v.selection() : v;
    L.property("__zoom", h1), v !== L ? x(v, M, A, O) : L.interrupt().each(function() {
      S(this, arguments).event(O).start().zoom(null, typeof M == "function" ? M.apply(this, arguments) : M).end();
    });
  }, m.scaleBy = function(v, M, A, O) {
    m.scaleTo(v, function() {
      var L = this.__zoom.k, C = typeof M == "function" ? M.apply(this, arguments) : M;
      return L * C;
    }, A, O);
  }, m.scaleTo = function(v, M, A, O) {
    m.transform(v, function() {
      var L = t.apply(this, arguments), C = this.__zoom, k = A == null ? _(L) : typeof A == "function" ? A.apply(this, arguments) : A, R = C.invert(k), z = typeof M == "function" ? M.apply(this, arguments) : M;
      return n(w(b(C, z), k, R), L, o);
    }, A, O);
  }, m.translateBy = function(v, M, A, O) {
    m.transform(v, function() {
      return n(this.__zoom.translate(
        typeof M == "function" ? M.apply(this, arguments) : M,
        typeof A == "function" ? A.apply(this, arguments) : A
      ), t.apply(this, arguments), o);
    }, null, O);
  }, m.translateTo = function(v, M, A, O, L) {
    m.transform(v, function() {
      var C = t.apply(this, arguments), k = this.__zoom, R = O == null ? _(C) : typeof O == "function" ? O.apply(this, arguments) : O;
      return n(d3.translate(R[0], R[1]).scale(k.k).translate(
        typeof M == "function" ? -M.apply(this, arguments) : -M,
        typeof A == "function" ? -A.apply(this, arguments) : -A
      ), C, o);
    }, O, L);
  };
  function b(v, M) {
    return M = Math.max(s[0], Math.min(s[1], M)), M === v.k ? v : new Wn(M, v.x, v.y);
  }
  function w(v, M, A) {
    var O = M[0] - A[0] * v.k, L = M[1] - A[1] * v.k;
    return O === v.x && L === v.y ? v : new Wn(v.k, O, L);
  }
  function _(v) {
    return [(+v[0][0] + +v[1][0]) / 2, (+v[0][1] + +v[1][1]) / 2];
  }
  function x(v, M, A, O) {
    v.on("start.zoom", function() {
      S(this, arguments).event(O).start();
    }).on("interrupt.zoom end.zoom", function() {
      S(this, arguments).event(O).end();
    }).tween("zoom", function() {
      var L = this, C = arguments, k = S(L, C).event(O), R = t.apply(L, C), z = A == null ? _(R) : typeof A == "function" ? A.apply(L, C) : A, G = Math.max(R[1][0] - R[0][0], R[1][1] - R[0][1]), Z = L.__zoom, pt = typeof M == "function" ? M.apply(L, C) : M, Ot = c(Z.invert(z).concat(G / Z.k), pt.invert(z).concat(G / pt.k));
      return function(gt) {
        if (gt === 1)
          gt = pt;
        else {
          var bt = Ot(gt), P = G / bt[2];
          gt = new Wn(P, z[0] - bt[0] * P, z[1] - bt[1] * P);
        }
        k.zoom(null, gt);
      };
    });
  }
  function S(v, M, A) {
    return !A && v.__zooming || new I(v, M);
  }
  function I(v, M) {
    this.that = v, this.args = M, this.active = 0, this.sourceEvent = null, this.extent = t.apply(v, M), this.taps = 0;
  }
  I.prototype = {
    event: function(v) {
      return v && (this.sourceEvent = v), this;
    },
    start: function() {
      return ++this.active === 1 && (this.that.__zooming = this, this.emit("start")), this;
    },
    zoom: function(v, M) {
      return this.mouse && v !== "mouse" && (this.mouse[1] = M.invert(this.mouse[0])), this.touch0 && v !== "touch" && (this.touch0[1] = M.invert(this.touch0[0])), this.touch1 && v !== "touch" && (this.touch1[1] = M.invert(this.touch1[0])), this.that.__zoom = M, this.emit("zoom"), this;
    },
    end: function() {
      return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
    },
    emit: function(v) {
      var M = zt(this.that).datum();
      u.call(
        v,
        this.that,
        new nB(v, {
          sourceEvent: this.sourceEvent,
          target: m,
          type: v,
          transform: this.that.__zoom,
          dispatch: u
        }),
        M
      );
    }
  };
  function N(v, ...M) {
    if (!e.apply(this, arguments))
      return;
    var A = S(this, M).event(v), O = this.__zoom, L = Math.max(s[0], Math.min(s[1], O.k * Math.pow(2, i.apply(this, arguments)))), C = kn(v);
    if (A.wheel)
      (A.mouse[0][0] !== C[0] || A.mouse[0][1] !== C[1]) && (A.mouse[1] = O.invert(A.mouse[0] = C)), clearTimeout(A.wheel);
    else {
      if (O.k === L)
        return;
      A.mouse = [C, O.invert(C)], Vs(this), A.start();
    }
    Wo(v), A.wheel = setTimeout(k, p), A.zoom("mouse", n(w(b(O, L), A.mouse[0], A.mouse[1]), A.extent, o));
    function k() {
      A.wheel = null, A.end();
    }
  }
  function F(v, ...M) {
    if (h || !e.apply(this, arguments))
      return;
    var A = v.currentTarget, O = S(this, M, !0).event(v), L = zt(v.view).on("mousemove.zoom", z, !0).on("mouseup.zoom", G, !0), C = kn(v, A), k = v.clientX, R = v.clientY;
    Lw(v.view), Xh(v), O.mouse = [C, this.__zoom.invert(C)], Vs(this), O.start();
    function z(Z) {
      if (Wo(Z), !O.moved) {
        var pt = Z.clientX - k, Ot = Z.clientY - R;
        O.moved = pt * pt + Ot * Ot > g;
      }
      O.event(Z).zoom("mouse", n(w(O.that.__zoom, O.mouse[0] = kn(Z, A), O.mouse[1]), O.extent, o));
    }
    function G(Z) {
      L.on("mousemove.zoom mouseup.zoom", null), Cw(Z.view, O.moved), Wo(Z), O.event(Z).end();
    }
  }
  function $(v, ...M) {
    if (e.apply(this, arguments)) {
      var A = this.__zoom, O = kn(v.changedTouches ? v.changedTouches[0] : v, this), L = A.invert(O), C = A.k * (v.shiftKey ? 0.5 : 2), k = n(w(b(A, C), O, L), t.apply(this, M), o);
      Wo(v), a > 0 ? zt(this).transition().duration(a).call(x, k, O, v) : zt(this).call(m.transform, k, O, v);
    }
  }
  function T(v, ...M) {
    if (e.apply(this, arguments)) {
      var A = v.touches, O = A.length, L = S(this, M, v.changedTouches.length === O).event(v), C, k, R, z;
      for (Xh(v), k = 0; k < O; ++k)
        R = A[k], z = kn(R, this), z = [z, this.__zoom.invert(z), R.identifier], L.touch0 ? !L.touch1 && L.touch0[2] !== z[2] && (L.touch1 = z, L.taps = 0) : (L.touch0 = z, C = !0, L.taps = 1 + !!l);
      l && (l = clearTimeout(l)), C && (L.taps < 2 && (f = z[0], l = setTimeout(function() {
        l = null;
      }, d)), Vs(this), L.start());
    }
  }
  function D(v, ...M) {
    if (this.__zooming) {
      var A = S(this, M).event(v), O = v.changedTouches, L = O.length, C, k, R, z;
      for (Wo(v), C = 0; C < L; ++C)
        k = O[C], R = kn(k, this), A.touch0 && A.touch0[2] === k.identifier ? A.touch0[0] = R : A.touch1 && A.touch1[2] === k.identifier && (A.touch1[0] = R);
      if (k = A.that.__zoom, A.touch1) {
        var G = A.touch0[0], Z = A.touch0[1], pt = A.touch1[0], Ot = A.touch1[1], gt = (gt = pt[0] - G[0]) * gt + (gt = pt[1] - G[1]) * gt, bt = (bt = Ot[0] - Z[0]) * bt + (bt = Ot[1] - Z[1]) * bt;
        k = b(k, Math.sqrt(gt / bt)), R = [(G[0] + pt[0]) / 2, (G[1] + pt[1]) / 2], z = [(Z[0] + Ot[0]) / 2, (Z[1] + Ot[1]) / 2];
      } else if (A.touch0)
        R = A.touch0[0], z = A.touch0[1];
      else
        return;
      A.zoom("touch", n(w(k, R, z), A.extent, o));
    }
  }
  function E(v, ...M) {
    if (this.__zooming) {
      var A = S(this, M).event(v), O = v.changedTouches, L = O.length, C, k;
      for (Xh(v), h && clearTimeout(h), h = setTimeout(function() {
        h = null;
      }, d), C = 0; C < L; ++C)
        k = O[C], A.touch0 && A.touch0[2] === k.identifier ? delete A.touch0 : A.touch1 && A.touch1[2] === k.identifier && delete A.touch1;
      if (A.touch1 && !A.touch0 && (A.touch0 = A.touch1, delete A.touch1), A.touch0)
        A.touch0[1] = this.__zoom.invert(A.touch0[0]);
      else if (A.end(), A.taps === 2 && (k = kn(k, this), Math.hypot(f[0] - k[0], f[1] - k[1]) < y)) {
        var R = zt(this).on("dblclick.zoom");
        R && R.apply(this, arguments);
      }
    }
  }
  return m.wheelDelta = function(v) {
    return arguments.length ? (i = typeof v == "function" ? v : Lc(+v), m) : i;
  }, m.filter = function(v) {
    return arguments.length ? (e = typeof v == "function" ? v : Lc(!!v), m) : e;
  }, m.touchable = function(v) {
    return arguments.length ? (r = typeof v == "function" ? v : Lc(!!v), m) : r;
  }, m.extent = function(v) {
    return arguments.length ? (t = typeof v == "function" ? v : Lc([[+v[0][0], +v[0][1]], [+v[1][0], +v[1][1]]]), m) : t;
  }, m.scaleExtent = function(v) {
    return arguments.length ? (s[0] = +v[0], s[1] = +v[1], m) : [s[0], s[1]];
  }, m.translateExtent = function(v) {
    return arguments.length ? (o[0][0] = +v[0][0], o[1][0] = +v[1][0], o[0][1] = +v[0][1], o[1][1] = +v[1][1], m) : [[o[0][0], o[0][1]], [o[1][0], o[1][1]]];
  }, m.constrain = function(v) {
    return arguments.length ? (n = v, m) : n;
  }, m.duration = function(v) {
    return arguments.length ? (a = +v, m) : a;
  }, m.interpolate = function(v) {
    return arguments.length ? (c = v, m) : c;
  }, m.on = function() {
    var v = u.on.apply(u, arguments);
    return v === u ? m : v;
  }, m.clickDistance = function(v) {
    return arguments.length ? (g = (v = +v) * v, m) : Math.sqrt(g);
  }, m.tapDistance = function(v) {
    return arguments.length ? (y = +v, m) : y;
  }, m;
}
function p3(e) {
  return typeof e != "string" ? !1 : (e = e.toLowerCase().trim(), e === "none" || e === "currentcolor" || e.startsWith("url(") && e.endsWith(")") || // <funciri>, e.g. pattern or gradient
  e.startsWith("var(") && e.endsWith(")") || // CSS variable
  Li(e) !== null);
}
const uB = /* @__PURE__ */ new Set([
  "order",
  "curve",
  "tension",
  "marker",
  "textAnchor",
  "lineAnchor",
  "lineHeight",
  "monospace",
  "fontFamily",
  "fontStyle",
  "fontVariant",
  "fontWeight",
  "frameAnchor",
  "strokeLinejoin",
  "strokeLinecap",
  "strokeMiterlimit",
  "strokeDasharray",
  "strokeDashoffset",
  "mixBlendMode",
  "shapeRendering",
  "paintOrder",
  "pointerEvents"
]), lB = (e) => typeof (e == null ? void 0 : e.addEventListener) == "function", fB = (e) => e === "stroke" || e === "fill", hB = (e) => uB.has(e);
let Oo = class extends Ga {
  constructor(t, n, i, r = {}) {
    var c;
    super((c = n == null ? void 0 : n.options) == null ? void 0 : c.filterBy), this.type = t, this.reqs = r, this.source = n, Array.isArray(this.source) && (this.data = this.source);
    const s = this.channels = [], o = this.params = /* @__PURE__ */ new Set(), a = (u, l) => {
      const f = typeof l;
      if (f === "function") {
        const h = l(u, this.type);
        for (const d in h)
          a(d, h[d]);
      } else if (f === "string")
        hB(u) || fB(u) && p3(l) ? s.push({ channel: u, value: l }) : s.push({ channel: u, field: rp(l) });
      else if (lB(l))
        if (l.columns)
          s.push({ channel: u, field: l }), o.add(l);
        else {
          const h = { channel: u, value: l.value };
          s.push(h), l.addEventListener("value", (d) => {
            h.value = d, this.update();
          });
        }
      else
        f === "object" ? s.push({ channel: u, field: l }) : s.push({ channel: u, value: l });
    };
    for (const u in i)
      a(u, i[u]);
  }
  setPlot(t, n) {
    var i;
    this.plot = t, this.index = n, t.addParams(this, this.params), (i = this.source) != null && i.table && this.queryPending();
  }
  hasOwnData() {
    return this.source == null || Array.isArray(this.source);
  }
  channel(t) {
    return this.channels.find((n) => n.channel === t);
  }
  channelField(...t) {
    var i;
    const n = t.flat();
    for (const r of n) {
      const s = (i = this.channel(r)) == null ? void 0 : i.field;
      if (s)
        return s;
    }
    return null;
  }
  fields() {
    var s, o, a;
    if (this.hasOwnData())
      return null;
    const { source: { table: t }, channels: n, reqs: i } = this, r = /* @__PURE__ */ new Map();
    for (const { channel: c, field: u } of n) {
      const l = u == null ? void 0 : u.column;
      if (l) {
        if ((s = u.stats) != null && s.length || i[c]) {
          r.has(l) || r.set(l, /* @__PURE__ */ new Set());
          const f = r.get(l);
          (o = i[c]) == null || o.forEach((h) => f.add(h)), (a = u.stats) == null || a.forEach((h) => f.add(h));
        }
      } else
        continue;
    }
    return Array.from(r, ([c, u]) => ({ table: t, column: c, stats: Array.from(u) }));
  }
  fieldStats(t) {
    return this.stats = t.reduce(
      (n, i) => (n[i.column] = i, n),
      /* @__PURE__ */ Object.create(null)
    ), this;
  }
  query(t = []) {
    var c;
    if (this.hasOwnData())
      return null;
    const { channels: n, source: { table: i }, stats: r } = this, s = mt.from({ source: i }), o = [];
    let a = !1;
    for (const u of n)
      if (u.channel === "order")
        s.orderby(u.value);
      else if (u.field) {
        const { channel: l, field: f } = u, h = ((c = f.transform) == null ? void 0 : c.call(f, r)) || f;
        h.aggregate ? a = !0 : o.push(l), s.select({ [l]: h });
      }
    return a && s.groupby(o), s.where(t);
  }
  queryPending() {
    return this.plot.pending(this), this;
  }
  queryResult(t) {
    return this.data = Array.from(t), this;
  }
  update() {
    return this.plot.update(this), this;
  }
  plotSpecs() {
    const { type: t, data: n, channels: i } = this, r = {};
    for (const s of i)
      r[s.channel] = Object.hasOwn(s, "value") ? s.value : s.channel;
    return [{ type: t, data: n, options: r }];
  }
};
const Vp = Symbol("Fixed"), is = Symbol("Transient"), m3 = { x: ["min", "max"] }, y3 = { y: ["min", "max"] }, g3 = { ...m3, ...y3 };
function b3(e, t, n, i, r) {
  const { plot: s, stats: o } = e, a = s.getAttribute(i), c = s.getAttribute(r);
  if (Array.isArray(a) && !a[is])
    return a;
  {
    const { column: u } = e.channelField(n), { min: l, max: f } = o[u], h = w3(t, u) || (c ? pf().domain([l, f]).nice().domain() : [l, f]);
    return a !== Vp && (h[is] = !0), s.setAttribute(i, h, { silent: !0 }), h;
  }
}
function Tf(e, t) {
  return b3(e, t, "x", "domainX", "niceX");
}
function Ef(e, t) {
  return b3(e, t, "y", "domainY", "niceY");
}
function w3(e, t) {
  if (!e)
    return;
  let n, i;
  const r = (s, o) => {
    if (s === "BETWEEN" && o.expr.column === t) {
      const { value: a } = o;
      a && (n == null || a[0] < n) && (n = a[0]), a && (i == null || a[1] > i) && (i = a[1]);
    }
  };
  return Array.isArray(e) ? e.forEach((s) => {
    var o;
    return (o = s.visit) == null ? void 0 : o.call(s, r);
  }) : e.visit && e.visit(r), n != null && i != null && n !== i ? [n, i] : void 0;
}
class dB extends Oo {
  constructor(t, n, i) {
    const r = t.endsWith("X") ? "y" : "x", s = { [r]: ["count", "min", "max"] };
    super(t, n, i, s), this.dim = r;
  }
  query(t = []) {
    const { plot: n, dim: i, source: r, stats: s } = this, { optimize: o = !0 } = r.options || {}, a = super.query(t);
    if (o) {
      const { column: c } = this.channelField(i), { count: u, max: l, min: f, type: h } = s[c], d = i === "x" ? n.innerWidth() : n.innerHeight(), [p, g] = w3(t, c) || [f, l], y = (g - p) / (l - f);
      if (u * y > d * 4) {
        const m = h === "date" ? sw(i) : i, b = i === "x" ? "y" : "x", w = a.select().map((_) => _.as).filter((_) => _ !== "x" && _ !== "y");
        return pB(a, m, i, b, p, g, d, w);
      }
    }
    return a.orderby(i);
  }
}
function pB(e, t, n, i, r, s, o, a = []) {
  const c = q(`FLOOR(${o / (s - r)}::DOUBLE * (${t} - ${+r}::DOUBLE))`), u = (l) => mt.from(e).select(l).groupby(c, a);
  return mt.union(
    u([{ [n]: ro(n), [i]: My(i, n) }, ...a]),
    u([{ [n]: io(n), [i]: Ay(i, n) }, ...a]),
    u([{ [n]: My(n, i), [i]: ro(i) }, ...a]),
    u([{ [n]: Ay(n, i), [i]: io(i) }, ...a])
  ).orderby(a, n);
}
function mB(e, t) {
  const n = new Float64Array(e);
  for (const i of t)
    n[i.index] = i.weight;
  return n;
}
function yB(e, t, n, i = []) {
  if (i.length) {
    const r = {};
    for (const s of n) {
      const o = i.map((c) => s[c]), { grid: a } = r[o] || (r[o] = { key: o, grid: new Float64Array(e * t) });
      a[s.index] = s.weight;
    }
    return Object.values(r);
  } else {
    const r = new Float64Array(e * t);
    for (const s of n)
      r[s.index] = s.weight;
    return [{ grid: r }];
  }
}
function m0(e, t = !1) {
  const n = new Float64Array(5), i = new Float64Array(4);
  gB(n, i, e);
  const r = Float64Array.of(
    0,
    i[1] - n[1] * i[0],
    i[2] - n[2] * i[0],
    i[3] - n[3] * i[0],
    -n[4] * i[0]
  ), s = 1 + n[1] + n[2] + n[3] + n[4], o = (i[0] + i[1] + i[2] + i[3]) / s, a = (r[1] + r[2] + r[3] + r[4]) / s;
  return {
    sigma: e,
    negative: t,
    a: n,
    b_causal: i,
    b_anticausal: r,
    sum_causal: o,
    sum_anticausal: a
  };
}
function gB(e, t, n) {
  const r = Float64Array.of(
    0.84,
    1.8675,
    0.84,
    -1.8675,
    -0.34015,
    -0.1299,
    -0.34015,
    0.1299
  ), s = Math.exp(-1.783 / n), o = Math.exp(-1.723 / n), a = 0.6318 / n, c = 1.997 / n, u = Float64Array.of(
    -s * Math.cos(a),
    s * Math.sin(a),
    -s * Math.cos(-a),
    s * Math.sin(-a),
    -o * Math.cos(c),
    o * Math.sin(c),
    -o * Math.cos(-c),
    o * Math.sin(-c)
  ), l = n * 2.5066282746310007, f = Float64Array.of(r[0], r[1], 0, 0, 0, 0, 0, 0), h = Float64Array.of(1, 0, u[0], u[1], 0, 0, 0, 0, 0, 0);
  let d, p;
  for (p = 2; p < 8; p += 2) {
    for (f[p] = u[p] * f[p - 2] - u[p + 1] * f[p - 1], f[p + 1] = u[p] * f[p - 1] + u[p + 1] * f[p - 2], d = p - 2; d > 0; d -= 2)
      f[d] += u[p] * f[d - 2] - u[p + 1] * f[d - 1], f[d + 1] += u[p] * f[d - 1] + u[p + 1] * f[d - 2];
    for (d = 0; d <= p; d += 2)
      f[d] += r[p] * h[d] - r[p + 1] * h[d + 1], f[d + 1] += r[p] * h[d + 1] + r[p + 1] * h[d];
    for (h[p + 2] = u[p] * h[p] - u[p + 1] * h[p + 1], h[p + 3] = u[p] * h[p + 1] + u[p + 1] * h[p], d = p; d > 0; d -= 2)
      h[d] += u[p] * h[d - 2] - u[p + 1] * h[d - 1], h[d + 1] += u[p] * h[d - 1] + u[p + 1] * h[d - 2];
  }
  for (p = 0; p < 4; ++p)
    d = p << 1, t[p] = f[d] / l, e[p + 1] = h[d + 2];
}
function bB(e, t, n, [i, r]) {
  const s = new Float64Array(Math.max(i, r)), o = new Float64Array(Math.max(i, r)), a = new Float64Array(5), c = new Float64Array(n.length);
  for (let u = 0, l = 0; u < r; ++u, l += i) {
    const f = c.subarray(l);
    y0(e, n.subarray(l), i, 1, s, o, a, f);
  }
  for (let u = 0; u < i; ++u) {
    const l = c.subarray(u);
    y0(t, l, r, i, s, o, a, l);
  }
  return c;
}
function y0(e, t, n, i = 1, r = new Float64Array(n), s = new Float64Array(n), o = new Float64Array(5), a = r, c = wB) {
  const u = i * 2, l = i * 3, f = i * 4, h = i * n;
  let d, p;
  for (c(
    r,
    t,
    n,
    i,
    e.b_causal,
    3,
    e.a,
    4,
    e.sum_causal,
    o,
    e.sigma
  ), p = 4, d = f; p < n; ++p, d += i)
    r[p] = e.b_causal[0] * t[d] + e.b_causal[1] * t[d - i] + e.b_causal[2] * t[d - u] + e.b_causal[3] * t[d - l] - e.a[1] * r[p - 1] - e.a[2] * r[p - 2] - e.a[3] * r[p - 3] - e.a[4] * r[p - 4];
  for (c(
    s,
    t,
    n,
    -i,
    e.b_anticausal,
    4,
    e.a,
    4,
    e.sum_anticausal,
    o,
    e.sigma
  ), p = 4, d = h - i * 5; p < n; ++p, d -= i)
    s[p] = e.b_anticausal[1] * t[d + i] + e.b_anticausal[2] * t[d + u] + e.b_anticausal[3] * t[d + l] + e.b_anticausal[4] * t[d + f] - e.a[1] * s[p - 1] - e.a[2] * s[p - 2] - e.a[3] * s[p - 3] - e.a[4] * s[p - 4];
  if (e.negative)
    for (p = 0, d = 0; p < n; ++p, d += i)
      a[d] = r[p] + s[n - p - 1];
  else
    for (p = 0, d = 0; p < n; ++p, d += i)
      a[d] = Math.max(0, r[p] + s[n - p - 1]);
  return a;
}
function wB(e, t, n, i, r, s, o, a, c, u) {
  const l = Math.abs(i) * n, f = i < 0 ? l + i : 0;
  let h, d, p;
  for (d = 0; d < a; ++d)
    for (u[d] = d <= s ? r[d] : 0, p = 1; p <= a && p <= d; ++p)
      u[d] -= o[p] * u[d - p];
  for (p = 0; p < a; ++p)
    for (e[p] = 0, d = 1; d <= p; ++d)
      h = f + i * d, h >= 0 && h < l && (e[p] += u[p - d] * t[h]);
  const g = t[f];
  if (g > 0)
    for (p = 0; p < a; ++p)
      e[p] += u[p] * g;
}
class _3 extends Oo {
  constructor(t, n, i) {
    const { bins: r = 1024, bandwidth: s = 0.1, ...o } = i, a = t.endsWith("X") ? "y" : "x";
    super(t, n, o, a === "x" ? m3 : y3), this.dim = a, this.bins = r, this.bandwidth = s, sr(s) && (s.addEventListener("value", (c) => {
      this.bandwidth = c, this.grid && this.convolve().update();
    }), this.bandwidth = s.value);
  }
  get filterIndexable() {
    const t = "domainX", n = this.plot.getAttribute(t);
    return n && !n[is];
  }
  query(t = []) {
    this.extent = (this.dim === "x" ? Tf : Ef)(this, t);
    const [n, i] = this.extent, r = this.channelField("weight") ? "weight" : 1;
    return _B(super.query(t), "x", n, i, this.bins, r);
  }
  queryResult(t) {
    return this.grid = mB(this.bins, t), this.convolve();
  }
  convolve() {
    const { bins: t, bandwidth: n, grid: i, extent: [r, s] } = this, o = i.some((h) => h < 0), a = (s - r) / (t - 1), c = 1 / a, u = m0(n * c, o), l = y0(u, i, t), f = this.data = [];
    for (let h = 0; h < t; ++h)
      f.push({
        x: r + h * a,
        y: l[h] * c
      });
    return this;
  }
  plotSpecs() {
    const { type: t, data: n, channels: i } = this, r = { y: "y" };
    for (const s of i)
      r[s.channel] = Object.hasOwn(s, "value") ? s.value : s.channel;
    return [{ type: t, data: n, options: r }];
  }
}
function _B(e, t, n, i, r, s) {
  const o = s && s !== 1 ? `* ${s}` : "", a = q(`(${t} - ${n}::DOUBLE) * ${(r - 1) / (i - n)}::DOUBLE`), c = mt.select({ p: a, i: q("FLOOR(p)::INTEGER"), w: q(`(i + 1 - p)${o}`) }).from(e).where(dn(t, [n, i])), u = mt.select({ p: a, i: q("FLOOR(p)::INTEGER + 1"), w: q(`(p - FLOOR(p))${o}`) }).from(e).where(dn(t, [n, i]));
  return mt.from(mt.unionAll(c, u)).select({ index: "i", weight: Zl("w") }).groupby("index").having(nw("weight", 0));
}
function v3(e, t) {
  if (e instanceof Date || (e = new Date(+e)), isNaN(e))
    return typeof t == "function" ? t(e) : t;
  const n = e.getUTCHours(), i = e.getUTCMinutes(), r = e.getUTCSeconds(), s = e.getUTCMilliseconds();
  return `${vB(e.getUTCFullYear())}-${_i(e.getUTCMonth() + 1, 2)}-${_i(e.getUTCDate(), 2)}${n || i || r || s ? `T${_i(n, 2)}:${_i(i, 2)}${r || s ? `:${_i(r, 2)}${s ? `.${_i(s, 3)}` : ""}` : ""}Z` : ""}`;
}
function vB(e) {
  return e < 0 ? `-${_i(-e, 6)}` : e > 9999 ? `+${_i(e, 6)}` : _i(e, 4);
}
function _i(e, t) {
  return `${e}`.padStart(t, "0");
}
const xB = /^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;
function x3(e, t) {
  return xB.test(e += "") ? new Date(e) : typeof t == "function" ? t(e) : t;
}
const SB = /* @__PURE__ */ new Map([
  ["second", Ei],
  ["minute", mf],
  ["hour", gf],
  ["day", No],
  ["week", yo],
  ["month", wf],
  ["year", ni],
  ["monday", Oa],
  ["tuesday", uv],
  ["wednesday", lv],
  ["thursday", es],
  ["friday", fv],
  ["saturday", hv],
  ["sunday", yo]
]), MB = /* @__PURE__ */ new Map([
  ["second", Ei],
  ["minute", yf],
  ["hour", bf],
  ["day", ic],
  ["week", go],
  ["month", _f],
  ["year", ii],
  ["monday", Fa],
  ["tuesday", dv],
  ["wednesday", pv],
  ["thursday", ns],
  ["friday", mv],
  ["saturday", yv],
  ["sunday", go]
]);
function AB(e) {
  const t = SB.get(`${e}`.toLowerCase());
  if (!t)
    throw new Error(`unknown interval: ${e}`);
  return t;
}
function $B(e) {
  const t = MB.get(`${e}`.toLowerCase());
  if (!t)
    throw new Error(`unknown interval: ${e}`);
  return t;
}
const S3 = Object.getPrototypeOf(Uint8Array), IB = Object.prototype.toString;
function dt(e, t, n) {
  const i = typeof t;
  return i === "string" ? ie(e, M3(t), n) : i === "function" ? ie(e, t, n) : i === "number" || t instanceof Date || i === "boolean" ? ie(e, He(t), n) : t && typeof t.transform == "function" ? mn(t.transform(e), n) : mn(t, n);
}
const M3 = (e) => (t) => t[e], Ze = (e, t) => t, lt = { transform: (e) => e }, jp = () => 1, TB = () => !0, un = (e) => e == null ? e : `${e}`, vt = (e) => e == null ? e : +e, sc = (e) => e ? e[0] : void 0, Ba = (e) => e ? e[1] : void 0, EB = (e) => e ? e[2] : void 0, He = (e) => () => e;
function Xp(e) {
  const t = +`${e}`.slice(1) / 100;
  return (n, i) => ar(n, t, i);
}
function Ge(e, t) {
  return e === void 0 && (e = t), e === null ? [void 0, "none"] : oc(e) ? [void 0, e] : [e, void 0];
}
function Se(e, t) {
  return e === void 0 && (e = t), e === null || typeof e == "number" ? [void 0, e] : [e, void 0];
}
function A3(e, t, n) {
  if (e != null)
    return yr(e, t, n);
}
function yr(e, t, n) {
  const i = `${e}`.toLowerCase();
  if (!n.includes(i))
    throw new Error(`invalid ${t}: ${e}`);
  return i;
}
function mn(e, t) {
  return e == null ? e : t === void 0 ? e instanceof Array || e instanceof S3 ? e : Array.from(e) : e instanceof t ? e : t.from(e);
}
function ie(e, t, n = Array) {
  return e instanceof n ? e.map(t) : n.from(e, t);
}
function g0(e, t = Array) {
  return e instanceof t ? e.slice() : t.from(e);
}
function $3(e) {
  return e instanceof S3;
}
function Fo(e) {
  return (e == null ? void 0 : e.toString) === IB;
}
function Xr(e) {
  return Fo(e) && (e.type !== void 0 || e.domain !== void 0);
}
function vi(e) {
  return Fo(e) && typeof e.transform != "function";
}
function La(e) {
  return vi(e) && e.value === void 0 && e.channel === void 0;
}
function I3(e, t, n, i = lt) {
  return t === void 0 && n === void 0 ? (t = 0, n = e === void 0 ? i : e) : t === void 0 ? t = e === void 0 ? 0 : e : n === void 0 && (n = e === void 0 ? 0 : e), [t, n];
}
function ai(e, t) {
  return e === void 0 && t === void 0 ? [sc, Ba] : [e, t];
}
function gr({ z: e, fill: t, stroke: n } = {}) {
  return e === void 0 && ([e] = Ge(t)), e === void 0 && ([e] = Ge(n)), e;
}
function br(e) {
  const t = e.length, n = new Uint32Array(t);
  for (let i = 0; i < t; ++i)
    n[i] = i;
  return n;
}
function Ji(e, t) {
  return ie(t, (n) => e[n]);
}
function Wh(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function T3(e, t) {
  if (t[e] !== void 0)
    return t[e];
  switch (e) {
    case "x1":
    case "x2":
      e = "x";
      break;
    case "y1":
    case "y2":
      e = "y";
      break;
  }
  return t[e];
}
function Ve(e) {
  let t;
  return [
    {
      transform: () => t,
      label: ln(e)
    },
    (n) => t = n
  ];
}
function De(e) {
  return e == null ? [e] : Ve(e);
}
function ln(e, t) {
  return typeof e == "string" ? e : e && e.label !== void 0 ? e.label : t;
}
function Il(e, t) {
  return {
    transform(n) {
      const i = e.transform(n), r = t.transform(n);
      return Ue(i) || Ue(r) ? ie(i, (s, o) => new Date((+i[o] + +r[o]) / 2)) : ie(i, (s, o) => (+i[o] + +r[o]) / 2, Float64Array);
    },
    label: e.label
  };
}
function wr(e, t) {
  if (e != null) {
    if (typeof e == "number") {
      const n = e;
      return {
        floor: (i) => n * Math.floor(i / n),
        offset: (i) => i + n,
        range: (i, r) => sn(Math.ceil(i / n), r / n).map((s) => n * s)
      };
    }
    if (typeof e == "string")
      return (t === "time" ? AB : $B)(e);
    if (typeof e.floor != "function")
      throw new Error("invalid interval; missing floor method");
    if (typeof e.offset != "function")
      throw new Error("invalid interval; missing offset method");
    return e;
  }
}
function Nf(e) {
  return e === void 0 || vi(e) ? e : { value: e };
}
function NB(e) {
  return e == null ? null : {
    transform: (t) => dt(t, e, Float64Array),
    label: ln(e)
  };
}
function OB(e) {
  if (!qi(e))
    return !1;
  for (const t of e)
    if (t != null)
      return typeof t == "object" && "0" in t && "1" in t;
}
function qi(e) {
  return e && typeof e[Symbol.iterator] == "function";
}
function FB(e) {
  for (const t of e)
    if (t != null)
      return typeof t != "object" || t instanceof Date;
}
function Kt(e) {
  for (const t of e) {
    if (t == null)
      continue;
    const n = typeof t;
    return n === "string" || n === "boolean";
  }
}
function Ue(e) {
  for (const t of e)
    if (t != null)
      return t instanceof Date;
}
function DB(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "string" && isNaN(t) && x3(t);
}
function BB(e) {
  for (const t of e)
    if (t != null) {
      if (typeof t != "string")
        return !1;
      if (t.trim())
        return !isNaN(t);
    }
}
function E3(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "number";
}
function d1(e, t) {
  for (const n of e)
    if (n != null)
      return t(n);
}
function p1(e, t) {
  for (const n of e)
    if (n != null && !t(n))
      return !1;
  return !0;
}
function oc(e) {
  return typeof e != "string" ? !1 : (e = e.toLowerCase().trim(), e === "none" || e === "currentcolor" || e.startsWith("url(") && e.endsWith(")") || // <funciri>, e.g. pattern or gradient
  e.startsWith("var(") && e.endsWith(")") || // CSS variable
  Li(e) !== null);
}
function le(e) {
  return e == null || bo(e);
}
function bo(e) {
  return /^\s*none\s*$/i.test(e);
}
function LB(e) {
  return /^\s*round\s*$/i.test(e);
}
function Of(e = "middle") {
  return yr(e, "frameAnchor", [
    "middle",
    "top-left",
    "top",
    "top-right",
    "right",
    "bottom-right",
    "bottom",
    "bottom-left",
    "left"
  ]);
}
function Ca(e) {
  if (e == null)
    return;
  const t = e[0], n = e[e.length - 1];
  return Ao(t, n);
}
function CB(e = {}, ...t) {
  let n = e;
  for (const i of t)
    for (const r in i)
      if (n[r] === void 0) {
        const s = i[r];
        n === e ? n = { ...n, [r]: s } : n[r] = s;
      }
  return n;
}
function kB(e) {
  console.warn("named iterables are deprecated; please use an object instead");
  const t = /* @__PURE__ */ new Set();
  return Object.fromEntries(Array.from(e, (n) => {
    const { name: i } = n;
    if (i == null)
      throw new Error("missing name");
    const r = `${i}`;
    if (r === "__proto__")
      throw new Error(`illegal name: ${r}`);
    if (t.has(r))
      throw new Error(`duplicate name: ${r}`);
    return t.add(r), [i, n];
  }));
}
function b0(e) {
  return qi(e) ? kB(e) : e;
}
const Hn = Symbol("position"), Mn = Symbol("color"), Ff = Symbol("radius"), Df = Symbol("length"), Bf = Symbol("opacity"), ka = Symbol("symbol"), Qt = /* @__PURE__ */ new Map([
  ["x", Hn],
  ["y", Hn],
  ["fx", Hn],
  ["fy", Hn],
  ["r", Ff],
  ["color", Mn],
  ["opacity", Bf],
  ["symbol", ka],
  ["length", Df]
]);
function je(e) {
  return e != null && !Number.isNaN(e);
}
function wo(e, t) {
  return +je(t) - +je(e) || jt(e, t);
}
function RB(e, t) {
  return +je(t) - +je(e) || Ao(e, t);
}
function Wp(e) {
  return e != null && `${e}` != "";
}
function Tl(e) {
  return isFinite(e) ? e : NaN;
}
function ur(e) {
  return e > 0 && isFinite(e) ? e : NaN;
}
function Lf(e) {
  return e < 0 && isFinite(e) ? e : NaN;
}
function ci(e = {}, t) {
  let { filter: n, sort: i, reverse: r, transform: s, initializer: o, ...a } = e;
  if (s === void 0 && (n != null && (s = Hp(n)), i != null && !La(i) && (s = Hh(s, Zp(i))), r && (s = Hh(s, Gp))), t != null && o != null)
    throw new Error("transforms cannot be applied after initializers");
  return {
    ...a,
    ...(i === null || La(i)) && { sort: i },
    transform: Hh(s, t)
  };
}
function Fn(e = {}, t) {
  let { filter: n, sort: i, reverse: r, initializer: s, ...o } = e;
  return s === void 0 && (n != null && (s = Hp(n)), i != null && !La(i) && (s = Gh(s, Zp(i))), r && (s = Gh(s, Gp))), {
    ...o,
    ...(i === null || La(i)) && { sort: i },
    initializer: Gh(s, t)
  };
}
function Hh(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, i) {
    return { data: n, facets: i } = e.call(this, n, i), t.call(this, mn(n), i);
  };
}
function Gh(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, i, r, ...s) {
    let o, a, c, u, l, f;
    return { data: a = n, facets: c = i, channels: o } = e.call(this, n, i, r, ...s), { data: l = a, facets: f = c, channels: u } = t.call(this, a, c, { ...r, ...o }, ...s), { data: l, facets: f, channels: { ...o, ...u } };
  };
}
function Cf(e, t) {
  return (e.initializer != null ? Fn : ci)(e, t);
}
function UB(e, t) {
  return Cf(t, Hp(e));
}
function Hp(e) {
  return (t, n) => {
    const i = dt(t, e);
    return { data: t, facets: n.map((r) => r.filter((s) => i[s])) };
  };
}
function zB(e) {
  return { ...Cf(e, Gp), sort: null };
}
function Gp(e, t) {
  return { data: e, facets: t.map((n) => n.slice().reverse()) };
}
function PB(e = {}) {
  const { seed: t, ...n } = e;
  return { ...Cf(n, O3(t == null ? Math.random : Bp(t))), sort: null };
}
function N3(e, t) {
  return {
    ...(vi(e) && e.channel !== void 0 ? Fn : Cf)(t, Zp(e)),
    sort: null
  };
}
function Zp(e) {
  return (typeof e == "function" && e.length !== 1 ? YB : O3)(e);
}
function YB(e) {
  return (t, n) => {
    const i = (r, s) => e(t[r], t[s]);
    return { data: t, facets: n.map((r) => r.slice().sort(i)) };
  };
}
function O3(e) {
  let t, n;
  if ({ channel: t, value: e, order: n = wo } = { ...Nf(e) }, typeof n != "function")
    switch (`${n}`.toLowerCase()) {
      case "ascending":
        n = wo;
        break;
      case "descending":
        n = RB;
        break;
      default:
        throw new Error(`invalid order: ${n}`);
    }
  return (i, r, s) => {
    let o;
    if (t === void 0)
      o = dt(i, e);
    else {
      if (s === void 0)
        throw new Error("channel sort requires an initializer");
      if (o = s[t], !o)
        return {};
      o = o.value;
    }
    const a = (c, u) => n(o[c], o[u]);
    return { data: i, facets: r.map((c) => c.slice().sort(a)) };
  };
}
function Kp(e, t) {
  return kf(null, null, e, t);
}
function El(e = { y: "count" }, t = {}) {
  const { x: n = lt } = t;
  if (n == null)
    throw new Error("missing channel: x");
  return kf(n, null, e, t);
}
function Nl(e = { x: "count" }, t = {}) {
  const { y: n = lt } = t;
  if (n == null)
    throw new Error("missing channel: y");
  return kf(null, n, e, t);
}
function F3(e = { fill: "count" }, t = {}) {
  let { x: n, y: i } = t;
  if ([n, i] = ai(n, i), n == null)
    throw new Error("missing channel: x");
  if (i == null)
    throw new Error("missing channel: y");
  return kf(n, i, e, t);
}
function kf(e, t, {
  data: n = B3,
  filter: i,
  sort: r,
  reverse: s,
  ...o
  // output channel definitions
} = {}, a = {}) {
  o = Jp(o, a), n = Rf(n, lt), r = r == null ? void 0 : Qp("sort", r, a), i = i == null ? void 0 : tm("filter", i, a);
  const [c, u] = De(e), [l, f] = De(t), {
    z: h,
    fill: d,
    stroke: p,
    x1: g,
    x2: y,
    // consumed if x is an output
    y1: m,
    y2: b,
    // consumed if y is an output
    ...w
  } = a, [_, x] = De(h), [S] = Ge(d), [I] = Ge(p), [N, F] = De(S), [$, T] = De(I);
  return {
    ..."z" in a && { z: _ || h },
    ..."fill" in a && { fill: N || d },
    ..."stroke" in a && { stroke: $ || p },
    ...ci(w, (D, E) => {
      const v = dt(D, e), M = dt(D, t), A = dt(D, h), O = dt(D, S), L = dt(D, I), C = em(o, { z: A, fill: O, stroke: L }), k = [], R = [], z = v && u([]), G = M && f([]), Z = A && x([]), pt = O && F([]), Ot = L && T([]);
      let gt = 0;
      for (const bt of o)
        bt.initialize(D);
      r && r.initialize(D), i && i.initialize(D);
      for (const bt of E) {
        const P = [];
        for (const V of o)
          V.scope("facet", bt);
        r && r.scope("facet", bt), i && i.scope("facet", bt);
        for (const [V, it] of js(bt, C))
          for (const [U, It] of js(it, M))
            for (const [wt, Lt] of js(It, v))
              if (!(i && !i.reduce(Lt))) {
                P.push(gt++), R.push(n.reduce(Lt, D)), v && z.push(wt), M && G.push(U), A && Z.push(C === A ? V : A[Lt[0]]), O && pt.push(C === O ? V : O[Lt[0]]), L && Ot.push(C === L ? V : L[Lt[0]]);
                for (const ne of o)
                  ne.reduce(Lt);
                r && r.reduce(Lt);
              }
        k.push(P);
      }
      return D3(k, r, s), { data: R, facets: k };
    }),
    ...!Ki(o, "x") && (c ? { x: c } : { x1: g, x2: y }),
    ...!Ki(o, "y") && (l ? { y: l } : { y1: m, y2: b }),
    ...Object.fromEntries(o.map(({ name: D, output: E }) => [D, E]))
  };
}
function Ki(e, ...t) {
  for (const { name: n } of e)
    if (t.includes(n))
      return !0;
  return !1;
}
function Jp(e, t) {
  const n = Object.entries(e);
  return t.title != null && e.title === void 0 && n.push(["title", VB]), t.href != null && e.href === void 0 && n.push(["href", nm]), n.filter(([, i]) => i !== void 0).map(([i, r]) => r === null ? { name: i, initialize() {
  }, scope() {
  }, reduce() {
  } } : Qp(i, r, t));
}
function Qp(e, t, n) {
  const i = tm(e, t, n), [r, s] = Ve(i.label);
  let o;
  return {
    name: e,
    output: r,
    initialize(a) {
      i.initialize(a), o = s([]);
    },
    scope(a, c) {
      i.scope(a, c);
    },
    reduce(a, c) {
      o.push(i.reduce(a, c));
    }
  };
}
function tm(e, t, n) {
  const i = T3(e, n), r = Rf(t, i);
  let s, o;
  return {
    label: ln(r === Ol ? null : i, r.label),
    initialize(a) {
      s = i === void 0 ? a : dt(a, i), r.scope === "data" && (o = r.reduce(br(a), s));
    },
    scope(a, c) {
      r.scope === a && (o = r.reduce(c, s));
    },
    reduce(a, c) {
      return r.scope == null ? r.reduce(a, s, c) : r.reduce(a, s, o, c);
    }
  };
}
function js(e, t) {
  return t ? oo(Yi(e, (n) => t[n]), sc) : [[, e]];
}
function Rf(e, t) {
  if (e && typeof e.reduce == "function")
    return e;
  if (typeof e == "function")
    return qB(e);
  if (/^p\d{2}$/i.test(e))
    return yi(Xp(e));
  switch (`${e}`.toLowerCase()) {
    case "first":
      return nm;
    case "last":
      return jB;
    case "count":
      return Ol;
    case "distinct":
      return XB;
    case "sum":
      return t == null ? Ol : WB;
    case "proportion":
      return y1(t, "data");
    case "proportion-facet":
      return y1(t, "facet");
    case "deviation":
      return yi(tf);
    case "min":
      return yi(he);
    case "min-index":
      return yi(f7);
    case "max":
      return yi(Gt);
    case "max-index":
      return yi(l7);
    case "mean":
      return m1(pp);
    case "median":
      return m1(Ma);
    case "variance":
      return yi(cp);
    case "mode":
      return yi(xw);
    case "x":
      return HB;
    case "x1":
      return ZB;
    case "x2":
      return KB;
    case "y":
      return GB;
    case "y1":
      return JB;
    case "y2":
      return QB;
  }
  throw new Error(`invalid reduce: ${e}`);
}
function em(e, t) {
  for (const n in t) {
    const i = t[n];
    if (i !== void 0 && !e.some((r) => r.name === n))
      return i;
  }
}
function D3(e, t, n) {
  if (t) {
    const i = t.output.transform(), r = (s, o) => wo(i[s], i[o]);
    e.forEach((s) => s.sort(r));
  }
  n && e.forEach((i) => i.reverse());
}
function qB(e) {
  return {
    reduce(t, n, i) {
      return e(Ji(n, t), i);
    }
  };
}
function yi(e) {
  return {
    reduce(t, n) {
      return e(t, (i) => n[i]);
    }
  };
}
function m1(e) {
  return {
    reduce(t, n) {
      const i = e(t, (r) => n[r]);
      return Ue(n) ? new Date(i) : i;
    }
  };
}
const B3 = {
  reduce(e, t) {
    return Ji(t, e);
  }
}, nm = {
  reduce(e, t) {
    return t[e[0]];
  }
}, VB = {
  reduce(e, t) {
    const i = oo(qr(e, (s) => s.length, (s) => t[s]), Ba), r = i.slice(-5).reverse();
    if (r.length < i.length) {
      const s = i.slice(0, -4);
      r[5 - 1] = [`… ${s.length.toLocaleString("en-US")} more`, ti(s, Ba)];
    }
    return r.map(([s, o]) => `${s} (${o.toLocaleString("en-US")})`).join(`
`);
  }
}, jB = {
  reduce(e, t) {
    return t[e[e.length - 1]];
  }
}, Ol = {
  label: "Frequency",
  reduce(e) {
    return e.length;
  }
}, XB = {
  label: "Distinct",
  reduce: (e, t) => {
    const n = new up();
    for (const i of e)
      n.add(t[i]);
    return n.size;
  }
}, WB = yi(ti);
function y1(e, t) {
  return e == null ? { scope: t, label: "Frequency", reduce: (n, i, r = 1) => n.length / r } : { scope: t, reduce: (n, i, r = 1) => ti(n, (s) => i[s]) / r };
}
function L3(e, t) {
  const n = (+e + +t) / 2;
  return e instanceof Date ? new Date(n) : n;
}
const HB = {
  reduce(e, t, { x1: n, x2: i }) {
    return L3(n, i);
  }
}, GB = {
  reduce(e, t, { y1: n, y2: i }) {
    return L3(n, i);
  }
}, ZB = {
  reduce(e, t, { x1: n }) {
    return n;
  }
}, KB = {
  reduce(e, t, { x2: n }) {
    return n;
  }
}, JB = {
  reduce(e, t, { y1: n }) {
    return n;
  }
}, QB = {
  reduce(e, t, { y2: n }) {
    return n;
  }
};
function Ra(e, { scale: t, type: n, value: i, filter: r, hint: s }) {
  return {
    scale: t,
    type: n,
    value: dt(e, i),
    label: ln(i),
    filter: r,
    hint: s
  };
}
function C3(e, t) {
  return Object.fromEntries(Object.entries(e).map(([n, i]) => [n, Ra(t, i)]));
}
function im(e, t) {
  return Object.fromEntries(Object.entries(e).map(([n, { scale: i, value: r }]) => {
    let s;
    return i !== void 0 && (s = t[i]), [n, s === void 0 ? r : ie(r, s)];
  }));
}
function tL(e, t, n, i) {
  const { reverse: r, reduce: s = !0, limit: o } = i;
  for (const a in i) {
    if (!Qt.has(a))
      continue;
    let { value: c, reverse: u = r, reduce: l = s, limit: f = o } = Nf(i[a]);
    if (u === void 0 && (u = c === "width" || c === "height"), l == null || l === !1)
      continue;
    const h = g1(e, a) || t && g1(t, a);
    if (!h)
      throw new Error(`missing channel for scale: ${a}`);
    const d = h.value, [p = 0, g = 1 / 0] = qi(f) ? f : f < 0 ? [f] : [0, f];
    if (c == null)
      h.domain = () => {
        let y = d;
        return u && (y = y.slice().reverse()), (p !== 0 || g !== 1 / 0) && (y = y.slice(p, g)), y;
      };
    else {
      const y = c === "data" ? n : c === "height" ? b1(e, "y1", "y2") : c === "width" ? b1(e, "x1", "x2") : w0(e, c, c === "y" ? "y2" : c === "x" ? "x2" : void 0), m = Rf(l === !0 ? "max" : l, y);
      h.domain = () => {
        let b = qr(br(d), (w) => m.reduce(w, y), (w) => d[w]);
        return b = oo(b, u ? nL : eL), (p !== 0 || g !== 1 / 0) && (b = b.slice(p, g)), b.map(sc);
      };
    }
  }
}
function g1(e, t) {
  for (const n in e) {
    const i = e[n];
    if (i.scale === t)
      return i;
  }
}
function b1(e, t, n) {
  const i = w0(e, t), r = w0(e, n);
  return ie(r, (s, o) => Math.abs(s - i[o]), Float64Array);
}
function w0(e, t, n) {
  let i = e[t];
  if (!i && n !== void 0 && (i = e[n]), i)
    return i.value;
  throw new Error(`missing channel: ${t}`);
}
function eL([e, t], [n, i]) {
  return jt(t, i) || jt(e, n);
}
function nL([e, t], [n, i]) {
  return Ao(t, i) || jt(e, n);
}
const w1 = /* @__PURE__ */ new Map([
  // categorical
  ["accent", gD],
  ["category10", yD],
  ["dark2", bD],
  ["paired", wD],
  ["pastel1", _D],
  ["pastel2", vD],
  ["set1", xD],
  ["set2", SD],
  ["set3", MD],
  ["tableau10", AD],
  // diverging
  ["brbg", hi(Tv, Ev)],
  ["prgn", hi(Nv, Ov)],
  ["piyg", hi(Fv, Dv)],
  ["puor", hi(Bv, Lv)],
  ["rdbu", hi(h0, _l)],
  ["rdgy", hi(Cv, kv)],
  ["rdylbu", hi(d0, vl)],
  ["rdylgn", hi(Rv, Uv)],
  ["spectral", hi(zv, Pv)],
  // reversed diverging (for temperature data)
  ["burd", _1(h0, _l)],
  ["buylrd", _1(d0, vl)],
  // sequential (single-hue)
  ["blues", ce(hx, dx)],
  ["greens", ce(px, mx)],
  ["greys", ce(yx, gx)],
  ["oranges", ce(xx, Sx)],
  ["purples", ce(bx, wx)],
  ["reds", ce(_x, vx)],
  // sequential (multi-hue)
  ["turbo", di(Nx)],
  ["viridis", di(Ox)],
  ["magma", di(Fx)],
  ["inferno", di(Dx)],
  ["plasma", di(Bx)],
  ["cividis", di(Mx)],
  ["cubehelix", di(Ax)],
  ["warm", di($x)],
  ["cool", di(Ix)],
  ["bugn", ce(Yv, qv)],
  ["bupu", ce(Vv, jv)],
  ["gnbu", ce(Xv, Wv)],
  ["orrd", ce(Hv, Gv)],
  ["pubu", ce(Jv, Qv)],
  ["pubugn", ce(Zv, Kv)],
  ["purd", ce(tx, ex)],
  ["rdpu", ce(nx, ix)],
  ["ylgn", ce(ox, ax)],
  ["ylgnbu", ce(rx, sx)],
  ["ylorbr", ce(cx, ux)],
  ["ylorrd", ce(lx, fx)],
  // cyclical
  ["rainbow", v1(Tx)],
  ["sinebow", v1(Ex)]
]);
function ce(e, t) {
  return ({ length: n }) => n === 1 ? [e[3][1]] : n === 2 ? [e[3][1], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 9 ? Tn(t, n) : e[n]);
}
function hi(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][0], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 11 ? Tn(t, n) : e[n]);
}
function _1(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][2], e[3][0]] : (n = Math.max(3, Math.floor(n)), n > 11 ? Tn((i) => t(1 - i), n) : e[n].slice().reverse());
}
function di(e) {
  return ({ length: t }) => Tn(e, Math.max(2, Math.floor(t)));
}
function v1(e) {
  return ({ length: t }) => Tn(e, Math.floor(t) + 1).slice(0, -1);
}
function k3(e) {
  const t = `${e}`.toLowerCase();
  if (!w1.has(t))
    throw new Error(`unknown ordinal scheme: ${t}`);
  return w1.get(t);
}
function Uf(e, t) {
  const n = k3(e), i = typeof n == "function" ? n({ length: t }) : n;
  return i.length !== t ? i.slice(0, t) : i;
}
function iL(e, t = "greys") {
  const n = /* @__PURE__ */ new Set(), [i, r] = Uf(t, 2);
  for (const s of e)
    if (s != null)
      if (s === !0)
        n.add(r);
      else if (s === !1)
        n.add(i);
      else
        return;
  return [...n];
}
const x1 = /* @__PURE__ */ new Map([
  // diverging
  ["brbg", Ev],
  ["prgn", Ov],
  ["piyg", Dv],
  ["puor", Lv],
  ["rdbu", _l],
  ["rdgy", kv],
  ["rdylbu", vl],
  ["rdylgn", Uv],
  ["spectral", Pv],
  // reversed diverging (for temperature data)
  ["burd", (e) => _l(1 - e)],
  ["buylrd", (e) => vl(1 - e)],
  // sequential (single-hue)
  ["blues", dx],
  ["greens", mx],
  ["greys", gx],
  ["purples", wx],
  ["reds", vx],
  ["oranges", Sx],
  // sequential (multi-hue)
  ["turbo", Nx],
  ["viridis", Ox],
  ["magma", Fx],
  ["inferno", Dx],
  ["plasma", Bx],
  ["cividis", Mx],
  ["cubehelix", Ax],
  ["warm", $x],
  ["cool", Ix],
  ["bugn", qv],
  ["bupu", jv],
  ["gnbu", Wv],
  ["orrd", Gv],
  ["pubugn", Kv],
  ["pubu", Qv],
  ["purd", ex],
  ["rdpu", ix],
  ["ylgnbu", sx],
  ["ylgn", ax],
  ["ylorbr", ux],
  ["ylorrd", fx],
  // cyclical
  ["rainbow", Tx],
  ["sinebow", Ex]
]);
function rm(e) {
  const t = `${e}`.toLowerCase();
  if (!x1.has(t))
    throw new Error(`unknown quantitative scheme: ${t}`);
  return x1.get(t);
}
const rL = /* @__PURE__ */ new Set([
  "brbg",
  "prgn",
  "piyg",
  "puor",
  "rdbu",
  "rdgy",
  "rdylbu",
  "rdylgn",
  "spectral",
  "burd",
  "buylrd"
]);
function S1(e) {
  return e != null && rL.has(`${e}`.toLowerCase());
}
const R3 = (e) => (t) => e(1 - t), Zh = [0, 1], M1 = /* @__PURE__ */ new Map([
  // numbers
  ["number", ve],
  // color spaces
  ["rgb", Jr],
  ["hsl", VT],
  ["hcl", WT],
  ["lab", jT]
]);
function U3(e) {
  const t = `${e}`.toLowerCase();
  if (!M1.has(t))
    throw new Error(`unknown interpolator: ${t}`);
  return M1.get(t);
}
function ac(e, t, n, { type: i, nice: r, clamp: s, zero: o, domain: a = P3(e, n), unknown: c, round: u, scheme: l, interval: f, range: h = Qt.get(e) === Ff ? pL(n, a) : Qt.get(e) === Df ? mL(n, a) : Qt.get(e) === Bf ? Zh : void 0, interpolate: d = Qt.get(e) === Mn ? l == null && h !== void 0 ? Jr : rm(l !== void 0 ? l : i === "cyclical" ? "rainbow" : "turbo") : u ? vp : ve, reverse: p }) {
  if (f = wr(f, i), (i === "cyclical" || i === "sequential") && (i = "linear"), p = !!p, typeof d != "function" && (d = U3(d)), d.length === 1 ? (p && (d = R3(d), p = !1), h === void 0 && (h = Float64Array.from(a, (g, y) => y / (a.length - 1)), h.length === 2 && (h = Zh)), t.interpolate((h === Zh ? He : om)(d))) : t.interpolate(d), o) {
    const [g, y] = Ne(a);
    (g > 0 || y < 0) && (a = g0(a), Ca(a) !== Math.sign(g) ? a[a.length - 1] = 0 : a[0] = 0);
  }
  return p && (a = Pu(a)), t.domain(a).unknown(c), r && (t.nice(r === !0 ? void 0 : r), a = t.domain()), h !== void 0 && t.range(h), s && t.clamp(s), { type: i, domain: a, range: h, scale: t, interpolate: d, interval: f };
}
function sL(e, t, n) {
  return ac(e, pf(), t, n);
}
function oL(e, t, n) {
  return z3(e, t, { ...n, exponent: 0.5 });
}
function z3(e, t, { exponent: n = 1, ...i }) {
  return ac(e, sv().exponent(n), t, { ...i, type: "pow" });
}
function aL(e, t, { base: n = 10, domain: i = yL(t), ...r }) {
  return ac(e, ev().base(n), t, { ...r, domain: i });
}
function cL(e, t, { constant: n = 1, ...i }) {
  return ac(e, iv().constant(n), t, i);
}
function uL(e, t, {
  range: n,
  quantiles: i = n === void 0 ? 5 : (n = [...n]).length,
  // deprecated; use n instead
  n: r = i,
  scheme: s = "rdylbu",
  domain: o = gL(t),
  interpolate: a,
  reverse: c
}) {
  return n === void 0 && (n = a !== void 0 ? Tn(a, r) : Qt.get(e) === Mn ? Uf(s, r) : void 0), o.length > 0 && (o = ov(o, n === void 0 ? { length: r } : n).quantiles()), sm(e, t, { domain: o, range: n, reverse: c });
}
function lL(e, t, { range: n, n: i = n === void 0 ? 5 : (n = [...n]).length, scheme: r = "rdylbu", domain: s = P3(e, t), unknown: o, interpolate: a, reverse: c }) {
  const [u, l] = Ne(s);
  let f;
  return n === void 0 ? (f = or(u, l, i), f[0] <= u && f.splice(0, 1), f[f.length - 1] >= l && f.pop(), i = f.length + 1, n = a !== void 0 ? Tn(a, i) : Qt.get(e) === Mn ? Uf(r, i) : void 0) : (f = Tn(ve(u, l), i + 1).slice(1, -1), u instanceof Date && (f = f.map((h) => new Date(h)))), Ca(mn(s)) < 0 && f.reverse(), sm(e, t, { domain: f, range: n, reverse: c, unknown: o });
}
function sm(e, t, {
  domain: n = [0],
  // explicit thresholds in ascending order
  unknown: i,
  scheme: r = "rdylbu",
  interpolate: s,
  range: o = s !== void 0 ? Tn(s, n.length + 1) : Qt.get(e) === Mn ? Uf(r, n.length + 1) : void 0,
  reverse: a
}) {
  const c = Ca(mn(n));
  if (!m7(n).every(([u, l]) => fL(u, l, c)))
    throw new Error(`the ${e} scale has a non-monotonic domain`);
  return a && (o = Pu(o)), {
    type: "threshold",
    scale: av(c < 0 ? Pu(n) : n, o === void 0 ? [] : o).unknown(i),
    domain: n,
    range: o
  };
}
function fL(e, t, n) {
  const i = Ao(e, t);
  return i === 0 || i === n;
}
function hL() {
  return { type: "identity", scale: J_() };
}
function Ua(e, t = Tl) {
  return e.length ? [
    he(e, ({ value: n }) => n === void 0 ? n : he(n, t)),
    Gt(e, ({ value: n }) => n === void 0 ? n : Gt(n, t))
  ] : [0, 1];
}
function P3(e, t) {
  const n = Qt.get(e);
  return (n === Ff || n === Bf || n === Df ? dL : Ua)(t);
}
function dL(e) {
  return [0, e.length ? Gt(e, ({ value: t }) => t === void 0 ? t : Gt(t, Tl)) : 1];
}
function pL(e, t) {
  const n = e.find(({ radius: o }) => o !== void 0);
  if (n !== void 0)
    return [0, n.radius];
  const i = ar(e, 0.5, ({ value: o }) => o === void 0 ? NaN : ar(o, 0.25, ur)), r = t.map((o) => 3 * Math.sqrt(o / i)), s = 30 / Gt(r);
  return s < 1 ? r.map((o) => o * s) : r;
}
function mL(e, t) {
  const n = Ma(e, ({ value: s }) => s === void 0 ? NaN : Ma(s, Math.abs)), i = t.map((s) => 12 * s / n), r = 60 / Gt(i);
  return r < 1 ? i.map((s) => s * r) : i;
}
function yL(e) {
  for (const { value: t } of e)
    if (t !== void 0)
      for (let n of t) {
        if (n = +n, n > 0)
          return Ua(e, ur);
        if (n < 0)
          return Ua(e, Lf);
      }
  return [1, 10];
}
function gL(e) {
  const t = [];
  for (const { value: n } of e)
    if (n !== void 0)
      for (const i of n)
        t.push(i);
  return t;
}
function om(e) {
  return (t, n) => (i) => e(t + i * (n - t));
}
function zf(e, t, n, i, { type: r, nice: s, clamp: o, domain: a = Ua(i), unknown: c, pivot: u = 0, scheme: l, range: f, symmetric: h = !0, interpolate: d = Qt.get(e) === Mn ? l == null && f !== void 0 ? Jr : rm(l !== void 0 ? l : "rdbu") : ve, reverse: p }) {
  u = +u;
  let [g, y] = a;
  if (Ao(g, y) < 0 && ([g, y] = [y, g], p = !p), g = Math.min(g, u), y = Math.max(y, u), typeof d != "function" && (d = U3(d)), f !== void 0 && (d = d.length === 1 ? om(d)(...f) : Sp(d, f)), p && (d = R3(d)), h) {
    const m = n.apply(u), b = m - n.apply(g), w = n.apply(y) - m;
    b < w ? g = n.invert(m - w) : b > w && (y = n.invert(m + b));
  }
  return t.domain([g, u, y]).unknown(c).interpolator(d), o && t.clamp(o), s && t.nice(s), { type: r, domain: [g, y], pivot: u, interpolate: d, scale: t };
}
function bL(e, t, n) {
  return zf(e, Mv(), xL, t, n);
}
function wL(e, t, n) {
  return Y3(e, t, { ...n, exponent: 0.5 });
}
function Y3(e, t, { exponent: n = 1, ...i }) {
  return zf(e, Iv().exponent(n = +n), AL(n), t, {
    ...i,
    type: "diverging-pow"
  });
}
function _L(e, t, { base: n = 10, pivot: i = 1, domain: r = Ua(t, i < 0 ? Lf : ur), ...s }) {
  return zf(e, Av().base(n = +n), SL, t, { domain: r, pivot: i, ...s });
}
function vL(e, t, { constant: n = 1, ...i }) {
  return zf(e, $v().constant(n = +n), $L(n), t, i);
}
const xL = {
  apply(e) {
    return e;
  },
  invert(e) {
    return e;
  }
}, SL = {
  apply: Math.log,
  invert: Math.exp
}, ML = {
  apply(e) {
    return Math.sign(e) * Math.sqrt(Math.abs(e));
  },
  invert(e) {
    return Math.sign(e) * (e * e);
  }
};
function AL(e) {
  return e === 0.5 ? ML : {
    apply(t) {
      return Math.sign(t) * Math.pow(Math.abs(t), e);
    },
    invert(t) {
      return Math.sign(t) * Math.pow(Math.abs(t), 1 / e);
    }
  };
}
function $L(e) {
  return {
    apply(t) {
      return Math.sign(t) * Math.log1p(Math.abs(t / e));
    },
    invert(t) {
      return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
    }
  };
}
function q3(e, t, n, i) {
  return ac(e, t, n, i);
}
function IL(e, t, n) {
  return q3(e, pD(), t, n);
}
function TL(e, t, n) {
  return q3(e, mD(), t, n);
}
const V3 = Math.sqrt(3), j3 = 2 / V3, EL = {
  draw(e, t) {
    const n = Math.sqrt(t / Math.PI), i = n * j3, r = i / 2;
    e.moveTo(0, i), e.lineTo(n, r), e.lineTo(n, -r), e.lineTo(0, -i), e.lineTo(-n, -r), e.lineTo(-n, r), e.closePath();
  }
}, am = /* @__PURE__ */ new Map([
  ["asterisk", qx],
  ["circle", Da],
  ["cross", Vx],
  ["diamond", Xx],
  ["diamond2", Wx],
  ["hexagon", EL],
  ["plus", Hx],
  ["square", Gx],
  ["square2", Zx],
  ["star", Jx],
  ["times", n3],
  ["triangle", Qx],
  ["triangle2", t3],
  ["wye", e3]
]);
function cm(e) {
  return e && typeof e.draw == "function";
}
function NL(e) {
  return cm(e) ? !0 : typeof e != "string" ? !1 : am.has(e.toLowerCase());
}
function X3(e) {
  if (e == null || cm(e))
    return e;
  const t = am.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid symbol: ${e}`);
}
function OL(e) {
  if (e == null || cm(e))
    return [void 0, e];
  if (typeof e == "string") {
    const t = am.get(`${e}`.toLowerCase());
    if (t)
      return [void 0, t];
  }
  return [e, void 0];
}
const cc = Symbol("ordinal");
function W3(e, t, n, { type: i, interval: r, domain: s, range: o, reverse: a, hint: c }) {
  return r = wr(r, i), s === void 0 && (s = G3(n, r, e)), (i === "categorical" || i === cc) && (i = "ordinal"), a && (s = Pu(s)), t.domain(s), o !== void 0 && (typeof o == "function" && (o = o(s)), t.range(o)), { type: i, domain: s, range: o, scale: t, hint: c, interval: r };
}
function FL(e, t, { type: n, interval: i, domain: r, range: s, scheme: o, unknown: a, ...c }) {
  i = wr(i, n), r === void 0 && (r = G3(t, i, e));
  let u;
  if (Qt.get(e) === ka)
    u = LL(t), s = s === void 0 ? CL(u) : ie(s, X3);
  else if (Qt.get(e) === Mn && (s === void 0 && (n === "ordinal" || n === cc) && (s = iL(r, o), s !== void 0 && (o = void 0)), o === void 0 && s === void 0 && (o = n === "ordinal" ? "turbo" : "tableau10"), o !== void 0))
    if (s !== void 0) {
      const l = rm(o), f = s[0], h = s[1] - s[0];
      s = ({ length: d }) => Tn((p) => l(f + h * p), d);
    } else
      s = k3(o);
  if (a === u0)
    throw new Error("implicit unknown is not supported");
  return W3(e, Lp().unknown(a), t, { ...c, type: n, domain: r, range: s, hint: u });
}
function DL(e, t, { align: n = 0.5, padding: i = 0.5, ...r }) {
  return H3(GO().align(n).padding(i), t, r, e);
}
function BL(e, t, { align: n = 0.5, padding: i = 0.1, paddingInner: r = i, paddingOuter: s = e === "fx" || e === "fy" ? 0 : i, ...o }) {
  return H3(hf().align(n).paddingInner(r).paddingOuter(s), t, o, e);
}
function H3(e, t, n, i) {
  let { round: r } = n;
  return r !== void 0 && e.round(r = !!r), e = W3(i, e, t, n), e.round = r, e;
}
function G3(e, t, n) {
  const i = new up();
  for (const { value: r, domain: s } of e) {
    if (s !== void 0)
      return s();
    if (r !== void 0)
      for (const o of r)
        i.add(o);
  }
  if (t !== void 0) {
    const [r, s] = Ne(i).map(t.floor, t);
    return t.range(r, t.offset(s));
  }
  if (i.size > 1e4 && Qt.get(n) === Hn)
    throw new Error("implicit ordinal position domain has more than 10,000 values");
  return oo(i, wo);
}
function A1(e, t) {
  let n;
  for (const { hint: i } of e) {
    const r = i == null ? void 0 : i[t];
    if (r !== void 0) {
      if (n === void 0)
        n = r;
      else if (n !== r)
        return;
    }
  }
  return n;
}
function LL(e) {
  return {
    fill: A1(e, "fill"),
    stroke: A1(e, "stroke")
  };
}
function CL(e) {
  return le(e.fill) ? RD : kD;
}
let _0 = 0;
function kL() {
  const e = _0;
  return _0 = 0, e;
}
function Wr(e) {
  console.warn(e), ++_0;
}
function v0(e, { label: t, inset: n = 0, insetTop: i = n, insetRight: r = n, insetBottom: s = n, insetLeft: o = n, round: a, nice: c, clamp: u, zero: l, align: f, padding: h, projection: d, facet: { label: p = t } = {}, ...g } = {}) {
  const y = {};
  for (const [m, b] of e) {
    const w = g[m], _ = Q3(m, b, {
      round: Qt.get(m) === Hn ? a : void 0,
      nice: c,
      clamp: u,
      zero: l,
      align: f,
      padding: h,
      projection: d,
      ...w
    });
    if (_) {
      let {
        label: x = m === "fx" || m === "fy" ? p : t,
        percent: S,
        transform: I,
        inset: N,
        insetTop: F = N !== void 0 ? N : m === "y" ? i : 0,
        // not fy
        insetRight: $ = N !== void 0 ? N : m === "x" ? r : 0,
        // not fx
        insetBottom: T = N !== void 0 ? N : m === "y" ? s : 0,
        // not fy
        insetLeft: D = N !== void 0 ? N : m === "x" ? o : 0
        // not fx
      } = w || {};
      if (I == null)
        I = void 0;
      else if (typeof I != "function")
        throw new Error("invalid scale transform; not a function");
      _.percent = !!S, _.label = x === void 0 ? UL(b, _) : x, _.transform = I, m === "x" || m === "fx" ? (_.insetLeft = +D, _.insetRight = +$) : (m === "y" || m === "fy") && (_.insetTop = +F, _.insetBottom = +T), y[m] = _;
    }
  }
  return y;
}
function $1(e) {
  return Object.fromEntries(Object.entries(e).filter(([, { scale: t }]) => t).map(([t, { scale: n, type: i, interval: r, label: s }]) => (n.type = i, r != null && (n.interval = r), s != null && (n.label = s), [t, n])));
}
function RL(e, t) {
  const { x: n, y: i, fx: r, fy: s } = e, o = r || s ? um(t) : t;
  r && I1(r, o), s && T1(s, o);
  const a = r || s ? Z3(e, t) : t;
  n && I1(n, a), i && T1(i, a);
}
function UL(e = [], t) {
  let n;
  for (const { label: i } of e)
    if (i !== void 0) {
      if (n === void 0)
        n = i;
      else if (n !== i)
        return;
    }
  if (n !== void 0 && !(t6(t) && /^(date|time|year)$/i.test(n)))
    return !as(t) && t.percent && (n = `${n} (%)`), { inferred: !0, toString: () => n };
}
function um(e) {
  const { marginTop: t, marginRight: n, marginBottom: i, marginLeft: r, width: s, height: o, facet: { marginTop: a, marginRight: c, marginBottom: u, marginLeft: l } } = e;
  return {
    marginTop: Math.max(t, a),
    marginRight: Math.max(n, c),
    marginBottom: Math.max(i, u),
    marginLeft: Math.max(r, l),
    width: s,
    height: o
  };
}
function Z3({ fx: e, fy: t }, n) {
  const { marginTop: i, marginRight: r, marginBottom: s, marginLeft: o, width: a, height: c } = um(n);
  return {
    marginTop: i,
    marginRight: r,
    marginBottom: s,
    marginLeft: o,
    width: e ? e.scale.bandwidth() + o + r : a,
    height: t ? t.scale.bandwidth() + i + s : c
  };
}
function I1(e, t) {
  if (e.range === void 0) {
    const { insetLeft: n, insetRight: i } = e, { width: r, marginLeft: s = 0, marginRight: o = 0 } = t, a = s + n, c = r - o - i;
    e.range = [a, Math.max(a, c)], as(e) || (e.range = J3(e)), e.scale.range(e.range);
  }
  K3(e);
}
function T1(e, t) {
  if (e.range === void 0) {
    const { insetTop: n, insetBottom: i } = e, { height: r, marginTop: s = 0, marginBottom: o = 0 } = t, a = s + n, c = r - o - i;
    e.range = [Math.max(a, c), a], as(e) ? e.range.reverse() : e.range = J3(e), e.scale.range(e.range);
  }
  K3(e);
}
function K3(e) {
  e.round === void 0 && YL(e) && zL(e) <= 30 && e.scale.round(!0);
}
function zL({ scale: e }) {
  const t = e.domain().length, [n, i] = e.range(), r = e.paddingInner ? e.paddingInner() : 1, s = e.paddingOuter ? e.paddingOuter() : e.padding(), o = t - r, a = Math.abs(i - n) / Math.max(1, o + s * 2);
  return (a - Math.floor(a)) * o;
}
function J3(e) {
  const t = e.scale.domain().length + e6(e);
  if (!(t > 2))
    return e.range;
  const [n, i] = e.range;
  return Array.from({ length: t }, (r, s) => n + s / (t - 1) * (i - n));
}
function x0(e, t, n) {
  return Q3(e, n === void 0 ? void 0 : [{ hint: n }], { ...t });
}
function Q3(e, t = [], n = {}) {
  const i = PL(e, t, n);
  if (n.type === void 0 && n.domain === void 0 && n.range === void 0 && n.interval == null && e !== "fx" && e !== "fy" && as({ type: i })) {
    const r = t.map(({ value: s }) => s).filter((s) => s !== void 0);
    r.some(Ue) ? Wr(`Warning: some data associated with the ${e} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${bs(i)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${e} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${e} scale to "${bs(i)}".`) : r.some(DB) ? Wr(`Warning: some data associated with the ${e} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${bs(i)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${e} scale to "${bs(i)}".`) : r.some(BB) && Wr(`Warning: some data associated with the ${e} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${bs(i)}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${e} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${e} scale to "${bs(i)}".`);
  }
  switch (n.type = i, i) {
    case "diverging":
    case "diverging-sqrt":
    case "diverging-pow":
    case "diverging-log":
    case "diverging-symlog":
    case "cyclical":
    case "sequential":
    case "linear":
    case "sqrt":
    case "threshold":
    case "quantile":
    case "pow":
    case "log":
    case "symlog":
      n = Cc(t, n, Ui);
      break;
    case "identity":
      switch (Qt.get(e)) {
        case Hn:
          n = Cc(t, n, Ui);
          break;
        case ka:
          n = Cc(t, n, qL);
          break;
      }
      break;
    case "utc":
    case "time":
      n = Cc(t, n, VL);
      break;
  }
  switch (i) {
    case "diverging":
      return bL(e, t, n);
    case "diverging-sqrt":
      return wL(e, t, n);
    case "diverging-pow":
      return Y3(e, t, n);
    case "diverging-log":
      return _L(e, t, n);
    case "diverging-symlog":
      return vL(e, t, n);
    case "categorical":
    case "ordinal":
    case cc:
      return FL(e, t, n);
    case "cyclical":
    case "sequential":
    case "linear":
      return sL(e, t, n);
    case "sqrt":
      return oL(e, t, n);
    case "threshold":
      return sm(e, t, n);
    case "quantile":
      return uL(e, t, n);
    case "quantize":
      return lL(e, t, n);
    case "pow":
      return z3(e, t, n);
    case "log":
      return aL(e, t, n);
    case "symlog":
      return cL(e, t, n);
    case "utc":
      return TL(e, t, n);
    case "time":
      return IL(e, t, n);
    case "point":
      return DL(e, t, n);
    case "band":
      return BL(e, t, n);
    case "identity":
      return Qt.get(e) === Hn ? hL() : { type: "identity" };
    case void 0:
      return;
    default:
      throw new Error(`unknown scale type: ${i}`);
  }
}
function bs(e) {
  return typeof e == "symbol" ? e.description : e;
}
const E1 = { toString: () => "projection" };
function PL(e, t, { type: n, domain: i, range: r, scheme: s, pivot: o, projection: a }) {
  if (e === "fx" || e === "fy")
    return "band";
  (e === "x" || e === "y") && a != null && (n = E1);
  for (const { type: l } of t)
    if (l !== void 0) {
      if (n === void 0)
        n = l;
      else if (n !== l)
        throw new Error(`scale incompatible with channel: ${n} !== ${l}`);
    }
  if (n === E1)
    return;
  if (n !== void 0)
    return n;
  if (i === void 0 && !t.some(({ value: l }) => l !== void 0))
    return;
  const c = Qt.get(e);
  if (c === Mn && r === void 0 && s === void 0 && N1(i, t, oc) || c === ka && r === void 0 && N1(i, t, NL))
    return "identity";
  if (c === Ff)
    return "sqrt";
  if (c === Bf || c === Df)
    return "linear";
  if (c === ka)
    return "ordinal";
  if ((i || r || []).length > 2)
    return Kh(c);
  if (i !== void 0)
    return Kt(i) ? Kh(c) : Ue(i) ? "utc" : c === Mn && (o != null || S1(s)) ? "diverging" : "linear";
  const u = t.map(({ value: l }) => l).filter((l) => l !== void 0);
  return u.some(Kt) ? Kh(c) : u.some(Ue) ? "utc" : c === Mn && (o != null || S1(s)) ? "diverging" : "linear";
}
function Kh(e) {
  switch (e) {
    case Hn:
      return "point";
    case Mn:
      return cc;
    default:
      return "ordinal";
  }
}
function N1(e, t, n) {
  return e !== void 0 ? d1(e, n) && p1(e, n) : t.some(({ value: i }) => i !== void 0 && d1(i, n)) && t.every(({ value: i }) => i === void 0 || p1(i, n));
}
function t6({ type: e }) {
  return e === "time" || e === "utc";
}
function as({ type: e }) {
  return e === "ordinal" || e === "point" || e === "band" || e === cc;
}
function e6({ type: e }) {
  return e === "threshold";
}
function YL({ type: e }) {
  return e === "point" || e === "band";
}
function fn(e) {
  if (e === void 0)
    return !0;
  const t = e.domain(), n = e(t[0]);
  for (let i = 1, r = t.length; i < r; ++i)
    if (e(t[i]) - n)
      return !1;
  return !0;
}
function Cc(e, { domain: t, ...n }, i) {
  for (const r of e)
    r.value !== void 0 && (r.value = i(r.value));
  return {
    domain: t === void 0 ? t : i(t),
    ...n
  };
}
function qL(e) {
  return ie(e, X3);
}
function VL(e) {
  return ie(e, n6);
}
function Ui(e) {
  return $3(e) ? e : ie(e, lm, Float64Array);
}
function lm(e) {
  return e == null ? NaN : +e;
}
function n6(e) {
  return e instanceof Date && !isNaN(e) ? e : typeof e == "string" ? x3(e) : e == null || isNaN(e = +e) ? void 0 : new Date(e);
}
function Fl(e = {}) {
  let t;
  for (const n in e)
    if (Qt.has(n) && Xr(e[n])) {
      if (t !== void 0)
        throw new Error("ambiguous scale definition; multiple scales found");
      t = i6(x0(n, e[n]));
    }
  if (t === void 0)
    throw new Error("invalid scale definition; no scale found");
  return t;
}
function jL(e) {
  return (t) => {
    if (!Qt.has(t = `${t}`))
      throw new Error(`unknown scale: ${t}`);
    return t in e ? i6(e[t]) : void 0;
  };
}
function i6({ scale: e, type: t, domain: n, range: i, interpolate: r, interval: s, transform: o, percent: a, pivot: c }) {
  if (t === "identity")
    return { type: "identity", apply: (l) => l, invert: (l) => l };
  const u = e.unknown ? e.unknown() : void 0;
  return {
    type: t,
    domain: g0(n),
    ...i !== void 0 && { range: g0(i) },
    ...o !== void 0 && { transform: o },
    ...a && { percent: a },
    ...u !== void 0 && { unknown: u },
    ...s !== void 0 && { interval: s },
    // quantitative
    ...r !== void 0 && { interpolate: r },
    ...e.clamp && { clamp: e.clamp() },
    // diverging (always asymmetric; we never want to apply the symmetric transform twice)
    ...c !== void 0 && { pivot: c, symmetric: !1 },
    // log, diverging-log
    ...e.base && { base: e.base() },
    // pow, diverging-pow
    ...e.exponent && { exponent: e.exponent() },
    // symlog, diverging-symlog
    ...e.constant && { constant: e.constant() },
    // band, point
    ...e.align && { align: e.align(), round: e.round() },
    ...e.padding && (e.paddingInner ? { paddingInner: e.paddingInner(), paddingOuter: e.paddingOuter() } : { padding: e.padding() }),
    ...e.bandwidth && { bandwidth: e.bandwidth(), step: e.step() },
    // utilities
    apply: (l) => e(l),
    ...e.invert && { invert: (l) => e.invert(l) }
  };
}
const r6 = Math.PI, pi = 2 * r6, Jh = 0.618;
function XL({ projection: e, inset: t = 0, insetTop: n = t, insetRight: i = t, insetBottom: r = t, insetLeft: s = t } = {}, o) {
  if (e == null)
    return;
  if (typeof e.stream == "function")
    return e;
  let a, c, u = "frame";
  if (Fo(e)) {
    let x;
    if ({
      type: e,
      domain: c,
      inset: x,
      insetTop: n = x !== void 0 ? x : n,
      insetRight: i = x !== void 0 ? x : i,
      insetBottom: r = x !== void 0 ? x : r,
      insetLeft: s = x !== void 0 ? x : s,
      clip: u = u,
      ...a
    } = e, e == null)
      return;
  }
  typeof e != "function" && ({ type: e } = s6(e));
  const { width: l, height: f, marginLeft: h, marginRight: d, marginTop: p, marginBottom: g } = o, y = l - h - d - s - i, m = f - p - g - n - r;
  if (e = e == null ? void 0 : e({ width: y, height: m, clip: u, ...a }), e == null)
    return;
  u = WL(u, h, p, l - d, f - g);
  let b = h + s, w = p + n, _;
  if (c != null) {
    const [[x, S], [I, N]] = rs(e).bounds(c), F = Math.min(y / (I - x), m / (N - S));
    F > 0 ? (b -= (F * (x + I) - y) / 2, w -= (F * (S + N) - m) / 2, _ = ml({
      point($, T) {
        this.stream.point($ * F + b, T * F + w);
      }
    })) : Wr("Warning: the projection could not be fit to the specified domain; using the default scale.");
  }
  return _ ?? (_ = b === 0 && w === 0 ? o6() : ml({
    point(x, S) {
      this.stream.point(x + b, S + w);
    }
  })), { stream: (x) => e.stream(_.stream(u(x))) };
}
function s6(e) {
  switch (`${e}`.toLowerCase()) {
    case "albers-usa":
      return yn(GN, 0.7463, 0.4673);
    case "albers":
      return kc(C_, 0.7463, 0.4673);
    case "azimuthal-equal-area":
      return yn(ZN, 4, 4);
    case "azimuthal-equidistant":
      return yn(KN, pi, pi);
    case "conic-conformal":
      return kc(tO, pi, pi);
    case "conic-equal-area":
      return kc(yl, 6.1702, 2.9781);
    case "conic-equidistant":
      return kc(iO, 7.312, 3.6282);
    case "equal-earth":
      return yn(sO, 5.4133, 2.6347);
    case "equirectangular":
      return yn(eO, pi, r6);
    case "gnomonic":
      return yn(oO, 3.4641, 3.4641);
    case "identity":
      return { type: o6 };
    case "reflect-y":
      return { type: HL };
    case "mercator":
      return yn(JN, pi, pi);
    case "orthographic":
      return yn(aO, 2, 2);
    case "stereographic":
      return yn(cO, 2, 2);
    case "transverse-mercator":
      return yn(uO, pi, pi);
    default:
      throw new Error(`unknown projection type: ${e}`);
  }
}
function WL(e, t, n, i, r) {
  if (e === !1 || e == null || typeof e == "number")
    return (s) => s;
  switch (e === !0 && (e = "frame"), `${e}`.toLowerCase()) {
    case "frame":
      return __(t, n, i, r);
    default:
      throw new Error(`unknown projection clip type: ${e}`);
  }
}
function yn(e, t, n) {
  return {
    type: ({ width: i, height: r, rotate: s, precision: o = 0.15, clip: a }) => {
      var u, l, f;
      const c = e();
      return o != null && ((u = c.precision) == null || u.call(c, o)), s != null && ((l = c.rotate) == null || l.call(c, s)), typeof a == "number" && ((f = c.clipAngle) == null || f.call(c, a)), c.scale(Math.min(i / t, r / n)), c.translate([i / 2, r / 2]), c;
    },
    aspectRatio: n / t
  };
}
function kc(e, t, n) {
  const { type: i, aspectRatio: r } = yn(e, t, n);
  return {
    type: (s) => {
      const { parallels: o, domain: a, width: c, height: u } = s, l = i(s);
      return o != null && (l.parallels(o), a === void 0 && l.fitSize([c, u], { type: "Sphere" })), l;
    },
    aspectRatio: r
  };
}
const o6 = He({ stream: (e) => e }), HL = He(ml({
  point(e, t) {
    this.stream.point(e, -t);
  }
}));
function au(e, t, n, i, r) {
  const s = n[e] && n[e].scale === "x", o = n[t] && n[t].scale === "y";
  if (s && o)
    GL(e, t, i, r.projection);
  else {
    if (s)
      throw new Error(`projection requires paired x and y channels; ${e} is missing ${t}`);
    if (o)
      throw new Error(`projection requires paired x and y channels; ${t} is missing ${e}`);
  }
}
function GL(e, t, n, i) {
  const r = n[e], s = n[t], o = r.length, a = n[e] = new Float64Array(o).fill(NaN), c = n[t] = new Float64Array(o).fill(NaN);
  let u;
  const l = i.stream({
    point(f, h) {
      a[u] = f, c[u] = h;
    }
  });
  for (u = 0; u < o; ++u)
    l.point(r[u], s[u]);
}
function ZL(e, t) {
  if (typeof (e == null ? void 0 : e.stream) == "function")
    return Jh;
  if (Fo(e) && (e = e.type), e == null)
    return KL(t) ? Jh : void 0;
  if (typeof e != "function") {
    const { aspectRatio: n } = s6(e);
    if (n)
      return n;
  }
  return Jh;
}
function Pf(e, t, n) {
  const { x: i, y: r } = e;
  let s = {};
  return i && (s.x = i), r && (s.y = r), s = im(s, t), n.projection && au("x", "y", e, s, n), i && (s.x = Ui(s.x)), r && (s.y = Ui(s.y)), s;
}
function KL(e) {
  for (const t of e)
    if (t.channels.geometry)
      return !0;
  return !1;
}
function Yf(e = {}, t) {
  const { document: n = typeof window < "u" ? window.document : void 0 } = e;
  return { document: n, projection: XL(e, t) };
}
function Nt(e, { document: t }) {
  return zt(rf(e).call(t.documentElement));
}
function fm(e) {
  let t, n;
  return (...i) => (((n == null ? void 0 : n.length) !== i.length || n.some((r, s) => r !== i[s])) && (n = i, t = e(...i)), t);
}
const JL = fm((e) => new Intl.NumberFormat(e)), QL = fm((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { month: t } })), tC = fm((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { weekday: t } }));
function eC(e = "en-US") {
  const t = JL(e);
  return (n) => n != null && !isNaN(n) ? t.format(n) : void 0;
}
function nC(e = "en-US", t = "short") {
  const n = QL(e, t);
  return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2e3, +i))) ? n.format(i) : void 0;
}
function iC(e = "en-US", t = "short") {
  const n = tC(e, t);
  return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2001, 0, +i))) ? n.format(i) : void 0;
}
function hm(e) {
  return v3(e, "Invalid Date");
}
function rC(e = "en-US") {
  const t = eC(e);
  return (n) => (n instanceof Date ? hm : typeof n == "number" ? t : un)(n);
}
const qf = rC(), me = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5;
let sC = 0;
function O1() {
  return `plot-clip-${++sC}`;
}
function a6(e, { title: t, href: n, ariaLabel: i, ariaDescription: r, ariaHidden: s, target: o, fill: a, fillOpacity: c, stroke: u, strokeWidth: l, strokeOpacity: f, strokeLinejoin: h, strokeLinecap: d, strokeMiterlimit: p, strokeDasharray: g, strokeDashoffset: y, opacity: m, mixBlendMode: b, paintOrder: w, pointerEvents: _, shapeRendering: x }, { ariaLabel: S, fill: I = "currentColor", fillOpacity: N, stroke: F = "none", strokeOpacity: $, strokeWidth: T, strokeLinecap: D, strokeLinejoin: E, strokeMiterlimit: v, paintOrder: M }) {
  I === null && (a = null, c = null), F === null && (u = null, f = null), le(I) ? !le(F) && !le(a) && (F = "none") : le(F) && !le(u) && (I = "none");
  const [A, O] = Ge(a, I), [L, C] = Se(c, N), [k, R] = Ge(u, F), [z, G] = Se(f, $), [Z, pt] = Se(m);
  bo(R) || (l === void 0 && (l = T), d === void 0 && (d = D), h === void 0 && (h = E), p === void 0 && !LB(h) && (p = v), !bo(O) && w === void 0 && (w = M));
  const [Ot, gt] = Se(l);
  return I !== null && (e.fill = re(O, "currentColor"), e.fillOpacity = Ho(C, 1)), F !== null && (e.stroke = re(R, "none"), e.strokeWidth = Ho(gt, 1), e.strokeOpacity = Ho(G, 1), e.strokeLinejoin = re(h, "miter"), e.strokeLinecap = re(d, "butt"), e.strokeMiterlimit = Ho(p, 4), e.strokeDasharray = re(g, "none"), e.strokeDashoffset = re(y, "0")), e.target = un(o), e.ariaLabel = un(S), e.ariaDescription = un(r), e.ariaHidden = un(s), e.opacity = Ho(pt, 1), e.mixBlendMode = re(b, "normal"), e.paintOrder = re(w, "normal"), e.pointerEvents = re(_, "auto"), e.shapeRendering = re(x, "auto"), {
    title: { value: t, optional: !0 },
    href: { value: n, optional: !0 },
    ariaLabel: { value: i, optional: !0 },
    fill: { value: A, scale: "color", optional: !0 },
    fillOpacity: { value: L, scale: "opacity", optional: !0 },
    stroke: { value: k, scale: "color", optional: !0 },
    strokeOpacity: { value: z, scale: "opacity", optional: !0 },
    strokeWidth: { value: Ot, optional: !0 },
    opacity: { value: Z, scale: "opacity", optional: !0 }
  };
}
function oC(e, t) {
  t && e.filter((n) => Wp(t[n])).append("title").call(cC, t);
}
function aC(e, t) {
  t && e.filter(([n]) => Wp(t[n])).append("title").call(uC, t);
}
function cC(e, t) {
  t && e.text((n) => qf(t[n]));
}
function uC(e, t) {
  t && e.text(([n]) => qf(t[n]));
}
function ge(e, { target: t }, { ariaLabel: n, title: i, fill: r, fillOpacity: s, stroke: o, strokeOpacity: a, strokeWidth: c, opacity: u, href: l }) {
  n && K(e, "aria-label", (f) => n[f]), r && K(e, "fill", (f) => r[f]), s && K(e, "fill-opacity", (f) => s[f]), o && K(e, "stroke", (f) => o[f]), a && K(e, "stroke-opacity", (f) => a[f]), c && K(e, "stroke-width", (f) => c[f]), u && K(e, "opacity", (f) => u[f]), l && u6(e, (f) => l[f], t), oC(e, i);
}
function Dl(e, { target: t }, { ariaLabel: n, title: i, fill: r, fillOpacity: s, stroke: o, strokeOpacity: a, strokeWidth: c, opacity: u, href: l }) {
  n && K(e, "aria-label", ([f]) => n[f]), r && K(e, "fill", ([f]) => r[f]), s && K(e, "fill-opacity", ([f]) => s[f]), o && K(e, "stroke", ([f]) => o[f]), a && K(e, "stroke-opacity", ([f]) => a[f]), c && K(e, "stroke-width", ([f]) => c[f]), u && K(e, "opacity", ([f]) => u[f]), l && u6(e, ([f]) => l[f], t), aC(e, i);
}
function lC({ ariaLabel: e, title: t, fill: n, fillOpacity: i, stroke: r, strokeOpacity: s, strokeWidth: o, opacity: a, href: c }) {
  return [e, t, n, i, r, s, o, a, c].filter((u) => u !== void 0);
}
function dm(e, t, n) {
  const i = Yi(e, (r) => t[r]);
  return n === void 0 && i.size > e.length >> 1 && Wr("Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null."), i.values();
}
function* c6(e, t, { z: n }, i) {
  const { z: r } = i, s = lC(i), o = [...t, ...s];
  for (const a of r ? dm(e, r, n) : [e]) {
    let c, u;
    t:
      for (const l of a) {
        for (const f of o)
          if (!je(f[l])) {
            u && u.push(-1);
            continue t;
          }
        if (c === void 0) {
          u && (yield u), c = s.map((f) => Wh(f[l])), u = [l];
          continue;
        }
        u.push(l);
        for (let f = 0; f < s.length; ++f)
          if (Wh(s[f][l]) !== c[f]) {
            yield u, c = s.map((d) => Wh(d[l])), u = [l];
            continue t;
          }
      }
    u && (yield u);
  }
}
function fC(e) {
  return e === !0 ? e = "frame" : e === !1 && (e = null), A3(e, "clip", ["frame", "sphere"]);
}
function hC(e, t, n, i) {
  let r;
  switch (t.clip) {
    case "frame": {
      const { width: s, height: o, marginLeft: a, marginRight: c, marginTop: u, marginBottom: l } = n, f = O1();
      r = `url(#${f})`, e = Nt("svg:g", i).call((h) => h.append("svg:clipPath").attr("id", f).append("rect").attr("x", a).attr("y", u).attr("width", s - c - a).attr("height", o - u - l)).each(function() {
        this.appendChild(e.node()), e.node = () => this;
      });
      break;
    }
    case "sphere": {
      const { projection: s } = i;
      if (!s)
        throw new Error('the "sphere" clip option requires a projection');
      const o = O1();
      r = `url(#${o})`, e.append("clipPath").attr("id", o).append("path").attr("d", rs(s)({ type: "Sphere" }));
      break;
    }
  }
  K(e, "aria-label", t.ariaLabel), K(e, "aria-description", t.ariaDescription), K(e, "aria-hidden", t.ariaHidden), K(e, "clip-path", r);
}
function Zt(e, t, n, i) {
  hC(e, t, n, i), K(e, "fill", t.fill), K(e, "fill-opacity", t.fillOpacity), K(e, "stroke", t.stroke), K(e, "stroke-width", t.strokeWidth), K(e, "stroke-opacity", t.strokeOpacity), K(e, "stroke-linejoin", t.strokeLinejoin), K(e, "stroke-linecap", t.strokeLinecap), K(e, "stroke-miterlimit", t.strokeMiterlimit), K(e, "stroke-dasharray", t.strokeDasharray), K(e, "stroke-dashoffset", t.strokeDashoffset), K(e, "shape-rendering", t.shapeRendering), K(e, "paint-order", t.paintOrder), K(e, "pointer-events", t.pointerEvents);
}
function Xt(e, t) {
  dC(e, "mix-blend-mode", t.mixBlendMode), K(e, "opacity", t.opacity);
}
function u6(e, t, n) {
  e.each(function(i) {
    const r = t(i);
    if (r != null) {
      const s = this.ownerDocument.createElementNS(ao.svg, "a");
      s.setAttribute("fill", "inherit"), s.setAttributeNS(ao.xlink, "href", r), n != null && s.setAttribute("target", n), this.parentNode.insertBefore(s, this).appendChild(this);
    }
  });
}
function K(e, t, n) {
  n != null && e.attr(t, n);
}
function dC(e, t, n) {
  n != null && e.style(t, n);
}
function Pt(e, t, { x: n, y: i }, r = me, s = me) {
  r += t.dx, s += t.dy, n != null && n.bandwidth && (r += n.bandwidth() / 2), i != null && i.bandwidth && (s += i.bandwidth() / 2), (r || s) && e.attr("transform", `translate(${r},${s})`);
}
function re(e, t) {
  if ((e = un(e)) !== t)
    return e;
}
function Ho(e, t) {
  if ((e = vt(e)) !== t)
    return e;
}
const pC = /^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/;
function pm(e) {
  if (e === void 0)
    return `plot-${Math.random().toString(16).slice(2)}`;
  if (e = `${e}`, !pC.test(e))
    throw new Error(`invalid class name: ${e}`);
  return e;
}
function mm(e, t) {
  if (typeof t == "string")
    e.property("style", t);
  else if (t != null)
    for (const n of e)
      Object.assign(n.style, t);
}
function _r({ frameAnchor: e }, { width: t, height: n, marginTop: i, marginRight: r, marginBottom: s, marginLeft: o }) {
  return [
    /left$/.test(e) ? o : /right$/.test(e) ? t - r : (o + t - r) / 2,
    /^top/.test(e) ? i : /^bottom/.test(e) ? n - s : (i + n - s) / 2
  ];
}
function mC(e, t, n = {}) {
  let i = 0.5 - me, r = 0.5 + me, s = 0.5 + me, o = 0.5 - me;
  for (const { marginTop: g, marginRight: y, marginBottom: m, marginLeft: b } of t)
    g > i && (i = g), y > r && (r = y), m > s && (s = m), b > o && (o = b);
  let { margin: a, marginTop: c = a !== void 0 ? a : i, marginRight: u = a !== void 0 ? a : r, marginBottom: l = a !== void 0 ? a : s, marginLeft: f = a !== void 0 ? a : o } = n;
  c = +c, u = +u, l = +l, f = +f;
  let { width: h = 640, height: d = yC(e, t, n, {
    width: h,
    marginTopDefault: i,
    marginRightDefault: r,
    marginBottomDefault: s,
    marginLeftDefault: o
  }) + Math.max(0, c - i + l - s) } = n;
  h = +h, d = +d;
  const p = {
    width: h,
    height: d,
    marginTop: c,
    marginRight: u,
    marginBottom: l,
    marginLeft: f
  };
  if (e.fx || e.fy) {
    let { margin: g, marginTop: y = g !== void 0 ? g : c, marginRight: m = g !== void 0 ? g : u, marginBottom: b = g !== void 0 ? g : l, marginLeft: w = g !== void 0 ? g : f } = n.facet ?? {};
    y = +y, m = +m, b = +b, w = +w, p.facet = {
      marginTop: y,
      marginRight: m,
      marginBottom: b,
      marginLeft: w
    };
  }
  return p;
}
function yC({ y: e, fy: t, fx: n }, i, { projection: r }, { width: s, marginTopDefault: o, marginRightDefault: a, marginBottomDefault: c, marginLeftDefault: u }) {
  const l = t ? t.scale.domain().length : 1, f = ZL(r, i);
  if (f) {
    const d = n ? n.scale.domain().length : 1, p = (1.1 * l - 0.1) / (1.1 * d - 0.1) * f, g = Math.max(0.1, Math.min(10, p));
    return Math.round((s - u - a) * g + o + c);
  }
  const h = e ? as(e) ? e.scale.domain().length : Math.max(7, 17 / l) : 1;
  return !!(e || t) * Math.max(1, Math.min(60, h * l)) * 20 + !!n * 30 + 60;
}
function gC(e, t) {
  const { fx: n, fy: i } = v0(e, t), r = n == null ? void 0 : n.scale.domain(), s = i == null ? void 0 : i.scale.domain();
  return r && s ? r7(r, s).map(([o, a], c) => ({ x: o, y: a, i: c })) : r ? r.map((o, a) => ({ x: o, i: a })) : s ? s.map((o, a) => ({ y: o, i: a })) : void 0;
}
function bC({ x: e, y: t }) {
  const n = e && new Map(e.map((r, s) => [r, s])), i = t && new Map(t.map((r, s) => [r, s]));
  return e && t ? (r, s) => n.get(r.x) - n.get(s.x) || i.get(r.y) - i.get(s.y) : e ? (r, s) => n.get(r.x) - n.get(s.x) : (r, s) => i.get(r.y) - i.get(s.y);
}
function ym(e, { fx: t, fy: n }) {
  const i = br(e), r = t == null ? void 0 : t.value, s = n == null ? void 0 : n.value;
  return t && n ? qr(i, (o) => (o.fx = r[o[0]], o.fy = s[o[0]], o), (o) => r[o], (o) => s[o]) : t ? qr(i, (o) => (o.fx = r[o[0]], o), (o) => r[o]) : qr(i, (o) => (o.fy = s[o[0]], o), (o) => s[o]);
}
function wC(e, t, { marginTop: n, marginLeft: i }) {
  return e && t ? ({ x: r, y: s }) => `translate(${e(r) - i},${t(s) - n})` : e ? ({ x: r }) => `translate(${e(r) - i},0)` : ({ y: r }) => `translate(0,${t(r) - n})`;
}
function _C(e) {
  const t = [], n = new Uint32Array(ti(e, (i) => i.length));
  for (const i of e) {
    let r = 0;
    for (const s of e)
      i !== s && (n.set(s, r), r += s.length);
    t.push(n.slice(0, r));
  }
  return t;
}
const vC = /* @__PURE__ */ new Map([
  ["top", Qh],
  ["right", nd],
  ["bottom", td],
  ["left", ed],
  ["top-left", Rc(Qh, ed)],
  ["top-right", Rc(Qh, nd)],
  ["bottom-left", Rc(td, ed)],
  ["bottom-right", Rc(td, nd)],
  ["top-empty", SC],
  ["right-empty", $C],
  ["bottom-empty", MC],
  ["left-empty", AC]
]);
function xC(e) {
  if (e == null)
    return null;
  const t = vC.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid facet anchor: ${e}`);
}
function Qh(e, { y: t }, { y: n }) {
  return t ? t.indexOf(n) === 0 : !0;
}
function td(e, { y: t }, { y: n }) {
  return t ? t.indexOf(n) === t.length - 1 : !0;
}
function ed(e, { x: t }, { x: n }) {
  return t ? t.indexOf(n) === 0 : !0;
}
function nd(e, { x: t }, { x: n }) {
  return t ? t.indexOf(n) === t.length - 1 : !0;
}
function SC(e, { y: t }, { x: n, y: i, empty: r }) {
  var o;
  if (r)
    return !1;
  const s = t == null ? void 0 : t.indexOf(i);
  if (s > 0) {
    const a = t[s - 1];
    return (o = e.find((c) => c.x === n && c.y === a)) == null ? void 0 : o.empty;
  }
}
function MC(e, { y: t }, { x: n, y: i, empty: r }) {
  var o;
  if (r)
    return !1;
  const s = t == null ? void 0 : t.indexOf(i);
  if (s < (t == null ? void 0 : t.length) - 1) {
    const a = t[s + 1];
    return (o = e.find((c) => c.x === n && c.y === a)) == null ? void 0 : o.empty;
  }
}
function AC(e, { x: t }, { x: n, y: i, empty: r }) {
  var o;
  if (r)
    return !1;
  const s = t == null ? void 0 : t.indexOf(n);
  if (s > 0) {
    const a = t[s - 1];
    return (o = e.find((c) => c.x === a && c.y === i)) == null ? void 0 : o.empty;
  }
}
function $C(e, { x: t }, { x: n, y: i, empty: r }) {
  var o;
  if (r)
    return !1;
  const s = t == null ? void 0 : t.indexOf(n);
  if (s < (t == null ? void 0 : t.length) - 1) {
    const a = t[s + 1];
    return (o = e.find((c) => c.x === a && c.y === i)) == null ? void 0 : o.empty;
  }
}
function Rc(e, t) {
  return function() {
    return e.apply(null, arguments) && t.apply(null, arguments);
  };
}
function id(e, { channels: { fx: t, fy: n }, groups: i }) {
  return t && n ? e.map(({ x: r, y: s }) => {
    var o;
    return ((o = i.get(r)) == null ? void 0 : o.get(s)) ?? [];
  }) : t ? e.map(({ x: r }) => i.get(r) ?? []) : e.map(({ y: r }) => i.get(r) ?? []);
}
function l6(e) {
  return as(e) && e.interval === void 0 ? void 0 : "tabular-nums";
}
function IC(e, t) {
  return e === void 0 ? Ue(t) ? hm : un : typeof e == "function" ? e : (typeof e == "string" ? Ue(t) ? vf : To : He)(e);
}
function TC(e, t) {
  let { label: n = e.label, tickSize: i = 6, width: r = 240, height: s = 44 + i, marginTop: o = 18, marginRight: a = 0, marginBottom: c = 16 + i, marginLeft: u = 0, style: l, ticks: f = (r - u - a) / 64, tickFormat: h, fontVariant: d = l6(e), round: p = !0, className: g } = t;
  const y = Yf(t);
  g = pm(g), h === null && (h = () => null);
  const m = Nt("svg", y).attr("class", g).attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("width", r).attr("height", s).attr("viewBox", `0 0 ${r} ${s}`).call((T) => T.append("style").text(`
        .${g} {
          display: block;
          background: white;
          height: auto;
          height: intrinsic;
          max-width: 100%;
          overflow: visible;
        }
        .${g} text {
          white-space: pre;
        }
      `)).call(mm, l);
  let b = (T) => T.selectAll(".tick line").attr("y1", o + c - s), w;
  const _ = p ? (T, D) => T.rangeRound(D) : (T, D) => T.range(D), { type: x, domain: S, range: I, interpolate: N, scale: F, pivot: $ } = e;
  if (N) {
    const T = I === void 0 ? N : Sp(N.length === 1 ? om(N) : N, I);
    w = _(F.copy(), Tn(ve(u, r - a), Math.min(S.length + ($ !== void 0), I === void 0 ? 1 / 0 : I.length)));
    const D = 256, E = y.document.createElement("canvas");
    E.width = D, E.height = 1;
    const v = E.getContext("2d");
    for (let M = 0, A = D - 1; M < D; ++M)
      v.fillStyle = T(M / A), v.fillRect(M, 0, 1, 1);
    m.append("image").attr("x", u).attr("y", o).attr("width", r - u - a).attr("height", s - o - c).attr("preserveAspectRatio", "none").attr("xlink:href", E.toDataURL());
  } else if (x === "threshold") {
    const T = S, D = h === void 0 ? (E) => E : typeof h == "string" ? To(h) : h;
    w = _(pf().domain([-1, I.length - 1]), [u, r - a]), m.append("g").selectAll().data(I).enter().append("rect").attr("x", (E, v) => w(v - 1)).attr("y", o).attr("width", (E, v) => w(v) - w(v - 1)).attr("height", s - o - c).attr("fill", (E) => E), f = ie(T, (E, v) => v), h = (E) => D(T[E], E);
  } else
    w = _(hf().domain(S), [u, r - a]), m.append("g").selectAll().data(S).enter().append("rect").attr("x", w).attr("y", o).attr("width", Math.max(0, w.bandwidth() - 1)).attr("height", s - o - c).attr("fill", F), b = () => {
    };
  return m.append("g").attr("transform", `translate(0,${s - c})`).call(A7(w).ticks(Array.isArray(f) ? null : f, typeof h == "string" ? h : void 0).tickFormat(typeof h == "function" ? h : void 0).tickSize(i).tickValues(Array.isArray(f) ? f : null)).attr("font-size", null).attr("font-family", null).attr("font-variant", re(d, "normal")).call(b).call((T) => T.select(".domain").remove()), n !== void 0 && m.append("text").attr("x", u).attr("y", o - 6).attr("fill", "currentColor").attr("font-weight", "bold").text(n), m.node();
}
function F1(e, t) {
  if (t == null)
    return t;
  const n = e(t);
  if (!n)
    throw new Error(`scale not found: ${t}`);
  return n;
}
function EC(e, t) {
  if (!as(e) && !e6(e))
    throw new Error(`swatches legend requires ordinal or threshold color scale (not ${e.type})`);
  return f6(e, t, (n, i) => n.append("svg").attr("fill", i.scale).append("rect").attr("width", "100%").attr("height", "100%"), (n) => `.${n}-swatch svg {
        width: var(--swatchWidth);
        height: var(--swatchHeight);
        margin-right: 0.5em;
      }`);
}
function NC(e, { fill: t = ((u) => (u = e.hint) == null ? void 0 : u.fill)() !== void 0 ? e.hint.fill : "none", fillOpacity: n = 1, stroke: i = ((l) => (l = e.hint) == null ? void 0 : l.stroke)() !== void 0 ? e.hint.stroke : le(t) ? "currentColor" : "none", strokeOpacity: r = 1, strokeWidth: s = 1.5, r: o = 4.5, ...a } = {}, c) {
  const [f, h] = Ge(t), [d, p] = Ge(i), g = F1(c, f), y = F1(c, d), m = o * o * Math.PI;
  return n = Se(n)[1], r = Se(r)[1], s = Se(s)[1], f6(e, a, (b) => b.append("svg").attr("viewBox", "-8 -8 16 16").attr("fill", f === "color" ? (w) => g.scale(w) : null).attr("stroke", d === "color" ? (w) => y.scale(w) : null).append("path").attr("d", (w) => {
    const _ = $i();
    return e.scale(w).draw(_, m), _;
  }), (b) => `.${b}-swatch > svg {
        width: var(--swatchWidth);
        height: var(--swatchHeight);
        margin-right: 0.5em;
        overflow: visible;
        fill: ${h};
        fill-opacity: ${n};
        stroke: ${p};
        stroke-width: ${s}px;
        stroke-opacity: ${r};
      }`);
}
function f6(e, t = {}, n, i) {
  let {
    columns: r,
    tickFormat: s,
    fontVariant: o = l6(e),
    // TODO label,
    swatchSize: a = 15,
    swatchWidth: c = a,
    swatchHeight: u = a,
    marginLeft: l = 0,
    className: f,
    style: h,
    width: d
  } = t;
  const p = Yf(t);
  f = pm(f), s = IC(s, e.domain);
  const g = Nt("div", p).attr("class", f).attr("style", `
        --swatchWidth: ${+c}px;
        --swatchHeight: ${+u}px;
      `);
  let y;
  return r != null ? (y = `
      .${f}-swatch {
        display: flex;
        align-items: center;
        break-inside: avoid;
        padding-bottom: 1px;
      }
      .${f}-swatch::before {
        flex-shrink: 0;
      }
      .${f}-label {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    `, g.style("columns", r).selectAll().data(e.domain).enter().append("div").attr("class", `${f}-swatch`).call(n, e).call((m) => m.append("div").attr("class", `${f}-label`).attr("title", s).text(s))) : (y = `
      .${f} {
        display: flex;
        align-items: center;
        min-height: 33px;
        flex-wrap: wrap;
      }
      .${f}-swatch {
        display: inline-flex;
        align-items: center;
        margin-right: 1em;
      }
    `, g.selectAll().data(e.domain).enter().append("span").attr("class", `${f}-swatch`).call(n, e).append(function() {
    return this.ownerDocument.createTextNode(s.apply(this, arguments));
  })), g.call((m) => m.insert("style", "*").text(`
        .${f} {
          font-family: system-ui, sans-serif;
          font-size: 10px;
          margin-bottom: 0.5em;${l === void 0 ? "" : `
          margin-left: ${+l}px;`}${d === void 0 ? "" : `
          width: ${d}px;`}
        }
        ${i(f)}
        ${y}
      `)).style("font-variant", re(o, "normal")).call(mm, h).node();
}
const Bl = /* @__PURE__ */ new Map([
  ["symbol", NC],
  ["color", h6],
  ["opacity", DC]
]);
function OC(e = {}) {
  for (const [t, n] of Bl) {
    const i = e[t];
    if (Xr(i)) {
      const r = Yf(e);
      let s;
      if (t === "symbol") {
        const { fill: o, stroke: a = o === void 0 && Xr(e.color) ? "color" : void 0 } = e;
        s = { fill: o, stroke: a };
      }
      return n(x0(t, i, s), gm(r, i, e), (o) => Xr(e[o]) ? x0(o, e[o]) : null);
    }
  }
  throw new Error("unknown legend type; no scale found");
}
function FC(e, t, n = {}) {
  return (i, r) => {
    if (!Bl.has(i))
      throw new Error(`unknown legend type: ${i}`);
    if (i in e)
      return Bl.get(i)(e[i], gm(t, n[i], r), (s) => e[s]);
  };
}
function gm(e, { label: t, ticks: n, tickFormat: i } = {}, r) {
  return CB(r, e, { label: t, ticks: n, tickFormat: i });
}
function h6(e, { legend: t = !0, ...n }) {
  if (t === !0 && (t = e.type === "ordinal" ? "swatches" : "ramp"), e.domain !== void 0)
    switch (`${t}`.toLowerCase()) {
      case "swatches":
        return EC(e, n);
      case "ramp":
        return TC(e, n);
      default:
        throw new Error(`unknown legend type: ${t}`);
    }
}
function DC({ type: e, interpolate: t, ...n }, { legend: i = !0, color: r = pn(0, 0, 0), ...s }) {
  if (!t)
    throw new Error(`${e} opacity scales are not supported`);
  if (i === !0 && (i = "ramp"), `${i}`.toLowerCase() !== "ramp")
    throw new Error(`${i} opacity legends are not supported`);
  return h6({ type: e, ...n, interpolate: BC(r) }, { legend: i, ...s });
}
function BC(e) {
  const { r: t, g: n, b: i } = pn(e) || pn(0, 0, 0);
  return (r) => `rgba(${t},${n},${i},${r})`;
}
function LC(e, t, n) {
  const i = [];
  for (const [r, s] of Bl) {
    const o = n[r];
    if (o != null && o.legend && r in e) {
      const a = s(e[r], gm(t, e[r], o), (c) => e[c]);
      a != null && i.push(a);
    }
  }
  return i;
}
class Yt {
  constructor(t, n = {}, i = {}, r) {
    const { facet: s = "auto", facetAnchor: o, fx: a, fy: c, sort: u, dx: l = 0, dy: f = 0, margin: h = 0, marginTop: d = h, marginRight: p = h, marginBottom: g = h, marginLeft: y = h, clip: m, channels: b } = i;
    if (this.data = t, this.sort = La(u) ? u : null, this.initializer = Fn(i).initializer, this.transform = this.initializer ? i.transform : ci(i).transform, s === null || s === !1 ? this.facet = null : (this.facet = yr(s === !0 ? "include" : s, "facet", ["auto", "include", "exclude", "super"]), this.fx = a, this.fy = c), this.facetAnchor = xC(o), n = b0(n), b !== void 0 && (n = { ...b0(b), ...n }), r !== void 0 && (n = { ...a6(this, i, r), ...n }), this.channels = Object.fromEntries(Object.entries(n).filter(([w, { value: _, optional: x }]) => {
      if (_ != null)
        return !0;
      if (x)
        return !1;
      throw new Error(`missing channel value: ${w}`);
    })), this.dx = +l, this.dy = +f, this.marginTop = +d, this.marginRight = +p, this.marginBottom = +g, this.marginLeft = +y, this.clip = fC(m), this.facet === "super") {
      if (a || c)
        throw new Error("super-faceting cannot use fx or fy");
      for (const w in this.channels) {
        const { scale: _ } = n[w];
        if (!(_ !== "x" && _ !== "y"))
          throw new Error("super-faceting cannot use x or y");
      }
    }
  }
  initialize(t, n) {
    let i = mn(this.data);
    t === void 0 && i != null && (t = [br(i)]), this.transform != null && ({ facets: t, data: i } = this.transform(i, t), i = mn(i));
    const r = C3(this.channels, i);
    return this.sort != null && tL(r, n, i, this.sort), { data: i, facets: t, channels: r };
  }
  filter(t, n, i) {
    for (const r in n) {
      const { filter: s = je } = n[r];
      if (s !== null) {
        const o = i[r];
        t = t.filter((a) => s(o[a]));
      }
    }
    return t;
  }
  // If there is a projection, and there are both x and y channels (or x1 and
  // y1, or x2 and y2 channels), and those channels are associated with the x
  // and y scale respectively (and not already in screen coordinates as with an
  // initializer), then apply the projection, replacing the x and y values. Note
  // that the x and y scales themselves don’t exist if there is a projection,
  // but whether the channels are associated with scales still determines
  // whether the projection should apply; think of the projection as a
  // combination xy-scale.
  project(t, n, i) {
    au("x", "y", t, n, i), au("x1", "y1", t, n, i), au("x2", "y2", t, n, i);
  }
  scale(t, n, i) {
    const r = im(t, n);
    return i.projection && this.project(t, r, i), r;
  }
}
function lr(...e) {
  return e.plot = Yt.prototype.plot, e;
}
const Ll = Math.PI / 180;
function uc({ inset: e, insetLeft: t, insetRight: n, ...i } = {}) {
  return [t, n] = d6(e, t, n), { inset: e, insetLeft: t, insetRight: n, ...i };
}
function lc({ inset: e, insetTop: t, insetBottom: n, ...i } = {}) {
  return [t, n] = d6(e, t, n), { inset: e, insetTop: t, insetBottom: n, ...i };
}
function d6(e, t, n) {
  return e === void 0 && t === void 0 && n === void 0 ? me ? [1, 0] : [0.5, 0.5] : [t, n];
}
function p6(e, { interval: t }) {
  return e = { ...Nf(e) }, e.interval = wr(e.interval === void 0 ? t : e.interval), e;
}
function Vf(e, t, n, i) {
  const { [e]: r, [`${e}1`]: s, [`${e}2`]: o } = n, { value: a, interval: c } = p6(r, n);
  if (a == null || c == null && !i)
    return n;
  const u = ln(r);
  if (c == null) {
    let d;
    const p = { transform: (g) => d || (d = dt(g, a)), label: u };
    return {
      ...n,
      [e]: void 0,
      [`${e}1`]: s === void 0 ? p : s,
      [`${e}2`]: o === void 0 ? p : o
    };
  }
  let l, f;
  function h(d) {
    return f !== void 0 && d === l ? f : f = ie(dt(l = d, a), (p) => c.floor(p));
  }
  return t({
    ...n,
    [e]: void 0,
    [`${e}1`]: s === void 0 ? { transform: h, label: u } : s,
    [`${e}2`]: o === void 0 ? { transform: (d) => h(d).map((p) => c.offset(p)), label: u } : o
  });
}
function m6(e, t, n) {
  const { [e]: i } = n, { value: r, interval: s } = p6(i, n);
  return r == null || s == null ? n : t({
    ...n,
    [e]: {
      label: ln(i),
      transform: (o) => {
        const a = ie(dt(o, r), (u) => s.floor(u)), c = a.map((u) => s.offset(u));
        return a.map(Ue(a) ? (u, l) => u == null || isNaN(u = +u) || (l = c[l], l == null) || isNaN(l = +l) ? void 0 : new Date((u + l) / 2) : (u, l) => u == null || (l = c[l], l == null) ? NaN : (+u + +l) / 2);
      }
    }
  });
}
function y6(e = {}) {
  return Vf("x", uc, e, !0);
}
function g6(e = {}) {
  return Vf("y", lc, e, !0);
}
function b6(e = {}) {
  return Vf("x", uc, e);
}
function w6(e = {}) {
  return Vf("y", lc, e);
}
function _6(e = {}) {
  return m6("x", uc, e);
}
function v6(e = {}) {
  return m6("y", lc, e);
}
const x6 = {
  ariaLabel: "rule",
  fill: null,
  stroke: "currentColor"
};
class S6 extends Yt {
  constructor(t, n = {}) {
    const { x: i, y1: r, y2: s, inset: o = 0, insetTop: a = o, insetBottom: c = o } = n;
    super(t, {
      x: { value: i, scale: "x", optional: !0 },
      y1: { value: r, scale: "y", optional: !0 },
      y2: { value: s, scale: "y", optional: !0 }
    }, n, x6), this.insetTop = vt(a), this.insetBottom = vt(c);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y1: u, y2: l } = i, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: g, marginBottom: y } = r, { insetTop: m, insetBottom: b } = this;
    return Nt("svg:g", s).call(Zt, this, r).call(Pt, this, { x: c && o }, me, 0).call((w) => w.selectAll().data(t).enter().append("line").call(Xt, this).attr("x1", c ? (_) => c[_] : (g + f - p) / 2).attr("x2", c ? (_) => c[_] : (g + f - p) / 2).attr("y1", u && !fn(a) ? (_) => u[_] + m : d + m).attr("y2", l && !fn(a) ? a.bandwidth ? (_) => l[_] + a.bandwidth() - b : (_) => l[_] - b : h - y - b).call(ge, this, i)).node();
  }
}
class M6 extends Yt {
  constructor(t, n = {}) {
    const { x1: i, x2: r, y: s, inset: o = 0, insetRight: a = o, insetLeft: c = o } = n;
    super(t, {
      y: { value: s, scale: "y", optional: !0 },
      x1: { value: i, scale: "x", optional: !0 },
      x2: { value: r, scale: "x", optional: !0 }
    }, n, x6), this.insetRight = vt(a), this.insetLeft = vt(c);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { y: c, x1: u, x2: l } = i, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: g, marginBottom: y } = r, { insetLeft: m, insetRight: b } = this;
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, { y: c && a }, 0, me).call((w) => w.selectAll().data(t).enter().append("line").call(Xt, this).attr("x1", u && !fn(o) ? (_) => u[_] + m : g + m).attr("x2", l && !fn(o) ? o.bandwidth ? (_) => l[_] + o.bandwidth() - b : (_) => l[_] - b : f - p - b).attr("y1", c ? (_) => c[_] : (d + h - y) / 2).attr("y2", c ? (_) => c[_] : (d + h - y) / 2).call(ge, this, i)).node();
  }
}
function za(e, t) {
  let { x: n = lt, y: i, y1: r, y2: s, ...o } = w6(t);
  return [r, s] = A6(i, r, s), new S6(e, { ...o, x: n, y1: r, y2: s });
}
function Pa(e, t) {
  let { y: n = lt, x: i, x1: r, x2: s, ...o } = b6(t);
  return [r, s] = A6(i, r, s), new M6(e, { ...o, y: n, x1: r, x2: s });
}
function A6(e, t, n) {
  if (e === void 0) {
    if (t === void 0) {
      if (n !== void 0)
        return [0, n];
    } else if (n === void 0)
      return [0, t];
  } else {
    if (t === void 0)
      return n === void 0 ? [0, e] : [e, n];
    if (n === void 0)
      return [e, t];
  }
  return [t, n];
}
function bm(e, ...t) {
  let n = t.length;
  for (let i = 0, r = !0; i < n; ++i)
    typeof t[i] != "function" && (r && (e = e.slice(), r = !1), e.splice(i, 2, e[i] + t[i] + e[i + 1]), t.splice(i, 1), --i, --n);
  return (i) => {
    let r = e[0];
    for (let s = 0; s < n; ++s)
      r += t[s](i) + e[s + 1];
    return r;
  };
}
const CC = {
  ariaLabel: "text",
  strokeLinejoin: "round",
  strokeWidth: 3,
  paintOrder: "stroke"
}, $6 = "­";
class jf extends Yt {
  constructor(t, n = {}) {
    const { x: i, y: r, text: s = qi(t) && FB(t) ? lt : Ze, frameAnchor: o, textAnchor: a = /right$/i.test(o) ? "end" : /left$/i.test(o) ? "start" : "middle", lineAnchor: c = /^top/i.test(o) ? "top" : /^bottom/i.test(o) ? "bottom" : "middle", lineHeight: u = 1, lineWidth: l = 1 / 0, monospace: f, fontFamily: h = f ? "ui-monospace, monospace" : void 0, fontSize: d, fontStyle: p, fontVariant: g, fontWeight: y, rotate: m } = n, [b, w] = Se(m, 0), [_, x] = zC(d);
    super(t, {
      x: { value: i, scale: "x", optional: !0 },
      y: { value: r, scale: "y", optional: !0 },
      fontSize: { value: _, optional: !0 },
      rotate: { value: NB(b), optional: !0 },
      text: { value: s, filter: Wp, optional: !0 }
    }, n, CC), this.rotate = w, this.textAnchor = re(a, "middle"), this.lineAnchor = yr(c, "lineAnchor", ["top", "middle", "bottom"]), this.lineHeight = +u, this.lineWidth = +l, this.monospace = !!f, this.fontFamily = un(h), this.fontSize = x, this.fontStyle = un(p), this.fontVariant = un(g), this.fontWeight = un(y), this.frameAnchor = Of(o);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: u, rotate: l, text: f, fontSize: h } = i, { rotate: d } = this, [p, g] = _r(this, r);
    return Nt("svg:g", s).call(Zt, this, r, s).call(RC, this, f, r).call(Pt, this, { x: c && o, y: u && a }).call((y) => y.selectAll().data(t).enter().append("text").call(Xt, this).call(kC, this, f).attr("transform", bm`translate(${c ? (m) => c[m] : p},${u ? (m) => u[m] : g})${l ? (m) => ` rotate(${l[m]})` : d ? ` rotate(${d})` : ""}`).call(K, "font-size", h && ((m) => h[m])).call(ge, this, i)).node();
  }
}
function kC(e, { monospace: t, lineAnchor: n, lineHeight: i, lineWidth: r }, s) {
  if (!s)
    return;
  const o = isFinite(r) ? t ? (a) => D1(a, r, qC) : (a) => D1(a, r * 100, YC) : (a) => a.split(/\r\n?|\n/g);
  e.each(function(a) {
    const c = o(qf(s[a])), u = c.length, l = n === "top" ? 0.71 : n === "bottom" ? 1 - u : (164 - u * 100) / 200;
    if (u > 1)
      for (let f = 0; f < u; ++f) {
        if (!c[f])
          continue;
        const h = this.ownerDocument.createElementNS(ao.svg, "tspan");
        h.setAttribute("x", 0), h.setAttribute("y", `${(l + f) * i}em`), h.textContent = c[f], this.appendChild(h);
      }
    else
      l && this.setAttribute("y", `${l * i}em`), this.textContent = c[0];
  });
}
function Xf(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return t.frameAnchor === void 0 && ([n, i] = ai(n, i)), new jf(e, { ...r, x: n, y: i });
}
function I6(e, t = {}) {
  const { x: n = lt, ...i } = t;
  return new jf(e, v6({ ...i, x: n }));
}
function T6(e, t = {}) {
  const { y: n = lt, ...i } = t;
  return new jf(e, _6({ ...i, y: n }));
}
function RC(e, t, n) {
  K(e, "text-anchor", t.textAnchor), K(e, "font-family", t.fontFamily), K(e, "font-size", t.fontSize), K(e, "font-style", t.fontStyle), K(e, "font-variant", t.fontVariant === void 0 && (E3(n) || Ue(n)) ? "tabular-nums" : t.fontVariant), K(e, "font-weight", t.fontWeight);
}
const UC = /* @__PURE__ */ new Set([
  // global keywords
  "inherit",
  "initial",
  "revert",
  "unset",
  // absolute keywords
  "xx-small",
  "x-small",
  "small",
  "medium",
  "large",
  "x-large",
  "xx-large",
  "xxx-large",
  // relative keywords
  "larger",
  "smaller"
]);
function zC(e) {
  return e == null || typeof e == "number" ? [void 0, e] : typeof e != "string" ? [e, void 0] : (e = e.trim().toLowerCase(), UC.has(e) || /^[+-]?\d*\.?\d+(e[+-]?\d+)?(\w*|%)$/.test(e) ? [void 0, e] : [e, void 0]);
}
function D1(e, t, n = (i, r, s) => s - r) {
  const i = [];
  let r, s = 0;
  for (const [o, a, c] of PC(e)) {
    if (r === void 0 && (r = o), s > r && n(e, r, a) > t && (i.push(e.slice(r, s) + (e[s - 1] === $6 ? "-" : "")), r = o), c) {
      i.push(e.slice(r, a)), r = void 0;
      continue;
    }
    s = a;
  }
  return i;
}
function* PC(e) {
  let t = 0, n = 0;
  const i = e.length;
  for (; n < i; ) {
    let r = 1;
    switch (e[n]) {
      case $6:
      case "-":
        ++n, yield [t, n, !1], t = n;
        break;
      case " ":
        for (yield [t, n, !1]; e[++n] === " "; )
          ;
        t = n;
        break;
      case "\r":
        e[n + 1] === `
` && ++r;
      case `
`:
        yield [t, n, !0], n += r, t = n;
        break;
      default:
        ++n;
        break;
    }
  }
  yield [t, n, !0];
}
const B1 = {
  a: 56,
  b: 63,
  c: 57,
  d: 63,
  e: 58,
  f: 37,
  g: 62,
  h: 60,
  i: 26,
  j: 26,
  k: 55,
  l: 26,
  m: 88,
  n: 60,
  o: 60,
  p: 62,
  q: 62,
  r: 39,
  s: 54,
  t: 38,
  u: 60,
  v: 55,
  w: 79,
  x: 54,
  y: 55,
  z: 55,
  A: 69,
  B: 67,
  C: 73,
  D: 74,
  E: 61,
  F: 58,
  G: 76,
  H: 75,
  I: 28,
  J: 55,
  K: 67,
  L: 58,
  M: 89,
  N: 75,
  O: 78,
  P: 65,
  Q: 78,
  R: 67,
  S: 65,
  T: 65,
  U: 75,
  V: 69,
  W: 98,
  X: 69,
  Y: 67,
  Z: 67,
  0: 64,
  1: 48,
  2: 62,
  3: 64,
  4: 66,
  5: 63,
  6: 65,
  7: 58,
  8: 65,
  9: 65,
  " ": 29,
  "!": 32,
  '"': 49,
  "'": 31,
  "(": 39,
  ")": 39,
  ",": 31,
  "-": 48,
  ".": 31,
  "/": 32,
  ":": 31,
  ";": 31,
  "?": 52,
  "‘": 31,
  "’": 31,
  "“": 47,
  "”": 47
};
function YC(e, t, n) {
  let i = 0;
  for (let r = t; r < n; ++r) {
    i += B1[e[r]] || B1.e;
    const s = e.charCodeAt(r);
    if (s >= 55296 && s <= 56319) {
      const o = e.charCodeAt(r + 1);
      o >= 56320 && o <= 57343 && ++r;
    }
  }
  return i;
}
function qC(e, t, n) {
  return n - t;
}
const E6 = {
  ariaLabel: "vector",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinejoin: "round",
  strokeLinecap: "round"
}, N6 = 3.5, VC = N6 * 5, O6 = {
  draw(e, t, n) {
    const i = t * n / VC;
    e.moveTo(0, 0), e.lineTo(0, -t), e.moveTo(-i, i - t), e.lineTo(0, -t), e.lineTo(i, i - t);
  }
}, F6 = {
  draw(e, t, n) {
    e.moveTo(-n, 0), e.lineTo(0, -t), e.lineTo(n, 0);
  }
}, jC = /* @__PURE__ */ new Map([
  ["arrow", O6],
  ["spike", F6]
]);
function XC(e) {
  return e && typeof e.draw == "function";
}
function WC(e) {
  if (XC(e))
    return e;
  const t = jC.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid shape: ${e}`);
}
class Wf extends Yt {
  constructor(t, n = {}) {
    const { x: i, y: r, r: s = N6, length: o, rotate: a, shape: c = O6, anchor: u = "middle", frameAnchor: l } = n, [f, h] = Se(o, 12), [d, p] = Se(a, 0);
    super(t, {
      x: { value: i, scale: "x", optional: !0 },
      y: { value: r, scale: "y", optional: !0 },
      length: { value: f, scale: "length", optional: !0 },
      rotate: { value: d, optional: !0 }
    }, n, E6), this.r = +s, this.length = h, this.rotate = p, this.shape = WC(c), this.anchor = yr(u, "anchor", ["start", "middle", "end"]), this.frameAnchor = Of(l);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: u, length: l, rotate: f } = i, { length: h, rotate: d, anchor: p, shape: g, r: y } = this, [m, b] = _r(this, r);
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, { x: c && o, y: u && a }).call((w) => w.selectAll().data(t).enter().append("path").call(Xt, this).attr("transform", bm`translate(${c ? (_) => c[_] : m},${u ? (_) => u[_] : b})${f ? (_) => ` rotate(${f[_]})` : d ? ` rotate(${d})` : ""}${p === "start" ? "" : p === "end" ? l ? (_) => ` translate(0,${l[_]})` : ` translate(0,${h})` : l ? (_) => ` translate(0,${l[_] / 2})` : ` translate(0,${h / 2})`}`).attr("d", l ? (_) => {
      const x = $i();
      return g.draw(x, l[_], y), x;
    } : (() => {
      const _ = $i();
      return g.draw(_, h, y), _;
    })()).call(ge, this, i)).node();
  }
}
function D6(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return t.frameAnchor === void 0 && ([n, i] = ai(n, i)), new Wf(e, { ...r, x: n, y: i });
}
function B6(e, t = {}) {
  const { x: n = lt, ...i } = t;
  return new Wf(e, { ...i, x: n });
}
function L6(e, t = {}) {
  const { y: n = lt, ...i } = t;
  return new Wf(e, { ...i, y: n });
}
function HC(e, t = {}) {
  const { shape: n = F6, stroke: i = E6.stroke, strokeWidth: r = 1, fill: s = i, fillOpacity: o = 0.3, anchor: a = "start", ...c } = t;
  return D6(e, { ...c, shape: n, stroke: i, strokeWidth: r, fill: s, fillOpacity: o, anchor: a });
}
function vr(e, t) {
  return arguments.length < 2 && !qi(e) && (t = e, e = null), t === void 0 && (t = {}), [e, t];
}
function Hf({ anchor: e } = {}, t) {
  return e === void 0 ? t[0] : yr(e, "anchor", t);
}
function C6(e) {
  return Hf(e, ["left", "right"]);
}
function k6(e) {
  return Hf(e, ["right", "left"]);
}
function R6(e) {
  return Hf(e, ["bottom", "top"]);
}
function U6(e) {
  return Hf(e, ["top", "bottom"]);
}
function wm() {
  const [e, t] = vr(...arguments);
  return Y6("y", C6(t), e, t);
}
function z6() {
  const [e, t] = vr(...arguments);
  return Y6("fy", k6(t), e, t);
}
function _m() {
  const [e, t] = vr(...arguments);
  return q6("x", R6(t), e, t);
}
function P6() {
  const [e, t] = vr(...arguments);
  return q6("fx", U6(t), e, t);
}
function Y6(e, t, n, { color: i = "currentColor", opacity: r = 1, stroke: s = i, strokeOpacity: o = r, strokeWidth: a = 1, fill: c = i, fillOpacity: u = r, textAnchor: l, textStroke: f, textStrokeOpacity: h, textStrokeWidth: d, tickSize: p = e === "y" ? 6 : 0, tickPadding: g, tickRotate: y, x: m, marginTop: b = 20, marginRight: w = t === "right" ? 40 : 0, marginBottom: _ = 20, marginLeft: x = t === "left" ? 40 : 0, label: S, labelOffset: I, labelAnchor: N, ...F }) {
  return p = vt(p), g = vt(g), y = vt(y), N !== void 0 && (N = yr(N, "labelAnchor", ["center", "top", "bottom"])), lr(p && !le(s) ? GC(e, t, n, {
    stroke: s,
    strokeOpacity: o,
    strokeWidth: a,
    tickSize: p,
    tickPadding: g,
    tickRotate: y,
    x: m,
    ...F
  }) : null, le(c) ? null : KC(e, t, n, {
    fill: c,
    fillOpacity: u,
    stroke: f,
    strokeOpacity: h,
    strokeWidth: d,
    textAnchor: l,
    tickSize: p,
    tickPadding: g,
    tickRotate: y,
    x: m,
    marginTop: b,
    marginRight: w,
    marginBottom: _,
    marginLeft: x,
    ...F
  }), !le(c) && S !== null ? Xf([], {
    fill: c,
    fillOpacity: u,
    ...F,
    facet: "super",
    x: null,
    y: null,
    initializer: function($, T, D, E, v) {
      const M = E[e], { marginTop: A, marginRight: O, marginBottom: L, marginLeft: C } = e === "y" && v.inset || v, k = N ?? (M.bandwidth ? "center" : "top"), R = I ?? (t === "right" ? O : C) - 3;
      return k === "center" ? (this.textAnchor = void 0, this.lineAnchor = t === "right" ? "bottom" : "top", this.frameAnchor = t, this.rotate = -90) : (this.textAnchor = t === "right" ? "end" : "start", this.lineAnchor = k, this.frameAnchor = `${k}-${t}`, this.rotate = 0), this.dy = k === "top" ? 3 - A : k === "bottom" ? L - 3 : 0, this.dx = t === "right" ? R : -R, this.ariaLabel = `${e}-axis label`, {
        facets: [[0]],
        channels: {
          text: {
            value: [S === void 0 ? Q6(e, M, k) : S]
          }
        }
      };
    }
  }) : null);
}
function q6(e, t, n, { color: i = "currentColor", opacity: r = 1, stroke: s = i, strokeOpacity: o = r, strokeWidth: a = 1, fill: c = i, fillOpacity: u = r, textAnchor: l, textStroke: f, textStrokeOpacity: h, textStrokeWidth: d, tickSize: p = e === "x" ? 6 : 0, tickPadding: g, tickRotate: y, y: m, marginTop: b = t === "top" ? 30 : 0, marginRight: w = 20, marginBottom: _ = t === "bottom" ? 30 : 0, marginLeft: x = 20, label: S, labelAnchor: I, labelOffset: N, ...F }) {
  return p = vt(p), g = vt(g), y = vt(y), I !== void 0 && (I = yr(I, "labelAnchor", ["center", "left", "right"])), lr(p && !le(s) ? ZC(e, t, n, {
    stroke: s,
    strokeOpacity: o,
    strokeWidth: a,
    tickSize: p,
    tickPadding: g,
    tickRotate: y,
    y: m,
    ...F
  }) : null, le(c) ? null : JC(e, t, n, {
    fill: c,
    fillOpacity: u,
    stroke: f,
    strokeOpacity: h,
    strokeWidth: d,
    textAnchor: l,
    tickSize: p,
    tickPadding: g,
    tickRotate: y,
    y: m,
    marginTop: b,
    marginRight: w,
    marginBottom: _,
    marginLeft: x,
    ...F
  }), !le(c) && S !== null ? Xf([], {
    fill: c,
    fillOpacity: u,
    ...F,
    facet: "super",
    x: null,
    y: null,
    initializer: function($, T, D, E, v) {
      const M = E[e], { marginTop: A, marginRight: O, marginBottom: L, marginLeft: C } = e === "x" && v.inset || v, k = I ?? (M.bandwidth ? "center" : "right"), R = N ?? (t === "top" ? A : L) - 3;
      return k === "center" ? (this.frameAnchor = t, this.textAnchor = void 0) : (this.frameAnchor = `${t}-${k}`, this.textAnchor = k === "right" ? "end" : "start"), this.lineAnchor = t, this.dy = t === "top" ? -R : R, this.dx = k === "right" ? O - 3 : k === "left" ? 3 - C : 0, this.ariaLabel = `${e}-axis label`, {
        facets: [[0]],
        channels: {
          text: {
            value: [S === void 0 ? Q6(e, M, k) : S]
          }
        }
      };
    }
  }) : null);
}
function GC(e, t, n, { strokeWidth: i = 1, strokeLinecap: r = null, strokeLinejoin: s = null, facetAnchor: o = t + (e === "y" ? "-empty" : ""), frameAnchor: a = t, tickSize: c, inset: u = 0, insetLeft: l = u, insetRight: f = u, dx: h = 0, y: d = e === "y" ? void 0 : null, ...p }) {
  return Do(L6, e, `${e}-axis tick`, n, {
    strokeWidth: i,
    strokeLinecap: r,
    strokeLinejoin: s,
    facetAnchor: o,
    frameAnchor: a,
    y: d,
    ...p,
    dx: t === "left" ? +h - me + +l : +h + me - f,
    anchor: "start",
    length: c,
    shape: t === "left" ? nk : ik
  });
}
function ZC(e, t, n, { strokeWidth: i = 1, strokeLinecap: r = null, strokeLinejoin: s = null, facetAnchor: o = t + (e === "x" ? "-empty" : ""), frameAnchor: a = t, tickSize: c, inset: u = 0, insetTop: l = u, insetBottom: f = u, dy: h = 0, x: d = e === "x" ? void 0 : null, ...p }) {
  return Do(B6, e, `${e}-axis tick`, n, {
    strokeWidth: i,
    strokeLinejoin: s,
    strokeLinecap: r,
    facetAnchor: o,
    frameAnchor: a,
    x: d,
    ...p,
    dy: t === "bottom" ? +h - me - f : +h + me + +l,
    anchor: "start",
    length: c,
    shape: t === "bottom" ? tk : ek
  });
}
function KC(e, t, n, { facetAnchor: i = t + (e === "y" ? "-empty" : ""), frameAnchor: r = t, tickSize: s, tickRotate: o = 0, tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) > 60 ? 4 * Math.cos(o * Ll) : 0), tickFormat: c, text: u = typeof c == "function" ? c : void 0, textAnchor: l = Math.abs(o) > 60 ? "middle" : t === "left" ? "end" : "start", lineAnchor: f = o > 60 ? "top" : o < -60 ? "bottom" : "middle", fontVariant: h, inset: d = 0, insetLeft: p = d, insetRight: g = d, dx: y = 0, y: m = e === "y" ? void 0 : null, ...b }) {
  return Do(T6, e, `${e}-axis tick label`, n, {
    facetAnchor: i,
    frameAnchor: r,
    text: u === void 0 ? null : u,
    textAnchor: l,
    lineAnchor: f,
    fontVariant: h,
    rotate: o,
    y: m,
    ...b,
    dx: t === "left" ? +y - s - a + +p : +y + +s + +a - g
  }, function(w, _, x) {
    h === void 0 && (this.fontVariant = J6(w)), u === void 0 && (x.text = K6(w, _, c));
  });
}
function JC(e, t, n, { facetAnchor: i = t + (e === "x" ? "-empty" : ""), frameAnchor: r = t, tickSize: s, tickRotate: o = 0, tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) >= 10 ? 4 * Math.cos(o * Ll) : 0), tickFormat: c, text: u = typeof c == "function" ? c : void 0, textAnchor: l = Math.abs(o) >= 10 ? o < 0 ^ t === "bottom" ? "start" : "end" : "middle", lineAnchor: f = Math.abs(o) >= 10 ? "middle" : t === "bottom" ? "top" : "bottom", fontVariant: h, inset: d = 0, insetTop: p = d, insetBottom: g = d, dy: y = 0, x: m = e === "x" ? void 0 : null, ...b }) {
  return Do(I6, e, `${e}-axis tick label`, n, {
    facetAnchor: i,
    frameAnchor: r,
    text: u === void 0 ? null : u,
    textAnchor: l,
    lineAnchor: f,
    fontVariant: h,
    rotate: o,
    x: m,
    ...b,
    dy: t === "bottom" ? +y + +s + +a - g : +y - s - a + +p
  }, function(w, _, x) {
    h === void 0 && (this.fontVariant = J6(w)), u === void 0 && (x.text = K6(w, _, c));
  });
}
function V6() {
  const [e, t] = vr(...arguments);
  return H6("y", C6(t), e, t);
}
function j6() {
  const [e, t] = vr(...arguments);
  return H6("fy", k6(t), e, t);
}
function X6() {
  const [e, t] = vr(...arguments);
  return G6("x", R6(t), e, t);
}
function W6() {
  const [e, t] = vr(...arguments);
  return G6("fx", U6(t), e, t);
}
function H6(e, t, n, { y: i = e === "y" ? void 0 : null, x: r = null, x1: s = t === "left" ? r : null, x2: o = t === "right" ? r : null, ...a }) {
  return Do(Pa, e, `${e}-grid`, n, { y: i, x1: s, x2: o, ...Z6(a) });
}
function G6(e, t, n, { x: i = e === "x" ? void 0 : null, y: r = null, y1: s = t === "top" ? r : null, y2: o = t === "bottom" ? r : null, ...a }) {
  return Do(za, e, `${e}-grid`, n, { x: i, y1: s, y2: o, ...Z6(a) });
}
function Z6({ color: e = "currentColor", opacity: t = 0.1, stroke: n = e, strokeOpacity: i = t, strokeWidth: r = 1, ...s }) {
  return { stroke: n, strokeOpacity: i, strokeWidth: r, ...s };
}
function Do(e, t, n, i, r, s) {
  let o;
  const a = e(i, Fn(r, function(c, u, l, f) {
    const { [t]: h } = f;
    if (!h)
      throw new Error(`missing scale: ${t}`);
    let { ticks: d, tickSpacing: p, interval: g } = r;
    if (t6(h) && typeof d == "string" && (g = d, d = void 0), c == null) {
      if (qi(d))
        c = mn(d);
      else if (h.ticks)
        if (d !== void 0)
          c = h.ticks(d);
        else if (g = wr(g === void 0 ? h.interval : g, h.type), g !== void 0) {
          const [y, m] = Ne(h.domain());
          c = g.range(y, g.offset(g.floor(m)));
        } else {
          const [y, m] = Ne(h.range());
          d = (m - y) / (p === void 0 ? t === "x" ? 80 : 35 : p), c = h.ticks(d);
        }
      else
        c = h.domain();
      t === "y" || t === "x" ? u = [br(c)] : (o[t] = { scale: t, value: lt }, u = void 0);
    }
    return s == null || s.call(this, h, d, o), {
      data: c,
      facets: u,
      channels: Object.fromEntries(Object.entries(o).map(([y, m]) => [y, { ...m, value: dt(c, m.value) }]))
    };
  }));
  return i == null ? (o = a.channels, a.channels = {}) : o = {}, a.ariaLabel = n, a;
}
function K6(e, t, n) {
  return { value: QC(e, t, n) };
}
function QC(e, t, n) {
  return e.tickFormat ? e.tickFormat(qi(t) ? null : t, n) : n === void 0 ? qf : typeof n == "string" ? (Ue(e.domain()) ? vf : To)(n) : He(n);
}
const tk = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, t);
  }
}, ek = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, -t);
  }
}, nk = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(-t, 0);
  }
}, ik = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(t, 0);
  }
};
function J6(e) {
  return e.bandwidth && e.interval === void 0 ? void 0 : "tabular-nums";
}
function rk(e) {
  return Math.sign(Ca(e.domain())) * Math.sign(Ca(e.range()));
}
function Q6(e, t, n) {
  const i = t.label;
  if (t.bandwidth || !(i != null && i.inferred))
    return i;
  const r = rk(t);
  return r ? e === "x" || n === "center" ? e === "x" == r < 0 ? `← ${i}` : `${i} →` : `${r < 0 ? "↑ " : "↓ "}${i}` : i;
}
const sk = {
  ariaLabel: "frame",
  fill: "none",
  stroke: "currentColor"
}, ok = {
  ariaLabel: "frame",
  fill: null,
  stroke: "currentColor",
  strokeLinecap: "square"
};
class tS extends Yt {
  constructor(t = {}) {
    const { anchor: n = null, inset: i = 0, insetTop: r = i, insetRight: s = i, insetBottom: o = i, insetLeft: a = i, rx: c, ry: u } = t;
    super(void 0, void 0, t, n == null ? sk : ok), this.anchor = A3(n, "anchor", ["top", "right", "bottom", "left"]), this.insetTop = vt(r), this.insetRight = vt(s), this.insetBottom = vt(o), this.insetLeft = vt(a), this.rx = vt(c), this.ry = vt(u);
  }
  render(t, n, i, r, s) {
    const { marginTop: o, marginRight: a, marginBottom: c, marginLeft: u, width: l, height: f } = r, { anchor: h, insetTop: d, insetRight: p, insetBottom: g, insetLeft: y, rx: m, ry: b } = this, w = u + y, _ = l - a - p, x = o + d, S = f - c - g;
    return Nt(h ? "svg:line" : "svg:rect", s).call(Zt, this, r, s).call(Xt, this).call(Pt, this, {}).call(h === "left" ? (I) => I.attr("x1", w).attr("x2", w).attr("y1", x).attr("y2", S) : h === "right" ? (I) => I.attr("x1", _).attr("x2", _).attr("y1", x).attr("y2", S) : h === "top" ? (I) => I.attr("x1", w).attr("x2", _).attr("y1", x).attr("y2", x) : h === "bottom" ? (I) => I.attr("x1", w).attr("x2", _).attr("y1", S).attr("y2", S) : (I) => I.attr("x", w).attr("y", x).attr("width", _ - w).attr("height", S - x).attr("rx", m).attr("ry", b)).node();
  }
}
function vm(e) {
  return new tS(e);
}
function xm(e = {}) {
  const { facet: t, style: n, caption: i, ariaLabel: r, ariaDescription: s } = e, o = pm(e.className), a = e.marks === void 0 ? [] : L1(e.marks), c = fk(t, e), u = /* @__PURE__ */ new Map();
  for (const E of a) {
    const v = C1(E, c, e);
    v && u.set(E, v);
  }
  const l = /* @__PURE__ */ new Map();
  c && Go(l, [c]), Go(l, u);
  const f = L1(hk(a, l, e));
  for (const E of f) {
    const v = C1(E, c, e);
    v && u.set(E, v);
  }
  a.unshift(...f);
  const h = gC(l, e);
  if (h !== void 0) {
    const E = c ? id(h, c) : void 0;
    for (const M of a) {
      if (M.facet === null || M.facet === "super")
        continue;
      const A = u.get(M);
      A !== void 0 && (A.facetsIndex = M.fx != null || M.fy != null ? id(h, A) : E);
    }
    const v = /* @__PURE__ */ new Set();
    for (const { facetsIndex: M } of u.values())
      M == null || M.forEach((A, O) => {
        (A == null ? void 0 : A.length) > 0 && v.add(O);
      });
    h.forEach(0 < v.size && v.size < h.length ? (M, A) => M.empty = !v.has(A) : (M) => M.empty = !1);
    for (const M of a)
      if (M.facet === "exclude") {
        const A = u.get(M);
        A.facetsIndex = _C(A.facetsIndex);
      }
  }
  for (const E of Qt.keys())
    Xr(e[E]) && E !== "fx" && E !== "fy" && l.set(E, []);
  const d = /* @__PURE__ */ new Map();
  for (const E of a) {
    if (d.has(E))
      throw new Error("duplicate mark; each mark must be unique");
    const { facetsIndex: v, channels: M } = u.get(E) ?? {}, { data: A, facets: O, channels: L } = E.initialize(v, M);
    Sm(L, e), d.set(E, { data: A, facets: O, channels: L });
  }
  const p = v0(Go(l, d), e), g = $1(p), y = mC(p, a, e);
  RL(p, y);
  const { fx: m, fy: b } = g, w = m || b ? Z3(p, y) : y, _ = m || b ? wk(g, y) : y, x = Yf(e, w), S = /* @__PURE__ */ new Set();
  for (const [E, v] of d)
    if (E.initializer != null) {
      const M = E.facet === "super" ? _ : w, A = E.initializer(v.data, v.facets, v.channels, g, M, x);
      if (A.data !== void 0 && (v.data = A.data), A.facets !== void 0 && (v.facets = A.facets), A.channels !== void 0) {
        lk(A.channels), Object.assign(v.channels, A.channels);
        for (const C of Object.values(A.channels)) {
          const { scale: k } = C;
          k != null && Qt.get(k) !== Hn && (eS(C, e), S.add(k));
        }
        const { fx: O, fy: L } = A.channels;
        if (O != null || L != null) {
          const C = u.get(E) ?? { channels: {} };
          O != null && (C.channels.fx = O), L != null && (C.channels.fy = L), C.groups = ym(v.data, C.channels), C.facetsIndex = v.facets = id(h, C), u.set(E, C);
        }
      }
    }
  if (S.size) {
    const E = /* @__PURE__ */ new Map();
    Go(E, d, (A) => S.has(A)), Go(l, d, (A) => S.has(A));
    const v = bk(v0(E, e), p), M = $1(v);
    Object.assign(p, v), Object.assign(g, M);
  }
  for (const [E, v] of d)
    v.values = E.scale(v.channels, g, x);
  const { width: I, height: N } = y, F = Nt("svg", x).attr("class", o).attr("fill", "currentColor").attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("text-anchor", "middle").attr("width", I).attr("height", N).attr("viewBox", `0 0 ${I} ${N}`).attr("aria-label", r).attr("aria-description", s).call((E) => E.append("style").text(`
        .${o} {
          display: block;
          background: white;
          height: auto;
          height: intrinsic;
          max-width: 100%;
        }
        .${o} text,
        .${o} tspan {
          white-space: pre;
        }
      `)).call(mm, n).node();
  if (h !== void 0) {
    const E = { x: m == null ? void 0 : m.domain(), y: b == null ? void 0 : b.domain() };
    h.sort(bC(E)), zt(F).selectAll().data(h).enter().append("g").attr("aria-label", "facet").attr("transform", wC(m, b, y)).each(function(v) {
      var A;
      let M = !0;
      for (const O of a) {
        if (O.facet === "super")
          continue;
        const { channels: L, values: C, facets: k } = d.get(O);
        if (!(((A = O.facetAnchor) == null ? void 0 : A.call(O, h, E, v)) ?? !v.empty))
          continue;
        let R = null;
        if (k) {
          if (R = k[u.has(O) ? v.i : 0], R = O.filter(R, L, C), R.length === 0)
            continue;
          R.fi = v.i;
        }
        const z = O.render(R, g, C, w, x);
        z != null && (M = !1, this.appendChild(z));
      }
      M && this.remove();
    });
  }
  for (const E of a) {
    if (h !== void 0 && E.facet !== "super")
      continue;
    const { channels: v, values: M, facets: A } = d.get(E);
    let O = null;
    if (A && (O = A[0], O = E.filter(O, v, M), O.length === 0))
      continue;
    const L = E.render(O, g, M, _, x);
    L != null && F.appendChild(L);
  }
  let $ = F;
  const T = LC(p, x, e);
  if (i != null || T.length > 0) {
    const { document: E } = x;
    $ = E.createElement("figure"), $.style.maxWidth = "initial";
    for (const v of T)
      $.appendChild(v);
    if ($.appendChild(F), i != null) {
      const v = E.createElement("figcaption");
      v.appendChild(i instanceof Node ? i : E.createTextNode(i)), $.appendChild(v);
    }
  }
  $.scale = jL(p), $.legend = FC(p, x, e);
  const D = kL();
  return D > 0 && zt(F).append("text").attr("x", I).attr("y", 20).attr("dy", "-1em").attr("text-anchor", "end").attr("font-family", "initial").text("⚠️").append("title").text(`${D.toLocaleString("en-US")} warning${D === 1 ? "" : "s"}. Please check the console.`), $;
}
function ak({ marks: e = [], ...t } = {}) {
  return xm({ ...t, marks: [...e, this] });
}
Yt.prototype.plot = ak;
function L1(e) {
  return e.flat(1 / 0).filter((t) => t != null).map(ck);
}
function ck(e) {
  return typeof e.render == "function" ? e : new uk(e);
}
class uk extends Yt {
  constructor(t) {
    if (typeof t != "function")
      throw new TypeError("invalid mark; missing render function");
    super(), this.render = t;
  }
  render() {
  }
}
function Sm(e, t) {
  for (const n in e)
    eS(e[n], t);
  return e;
}
function eS(e, t) {
  var a;
  const { scale: n } = e;
  if (n == null)
    return;
  const { type: i, percent: r, interval: s, transform: o = r ? (c) => c * 100 : (a = wr(s, i)) == null ? void 0 : a.floor } = t[n] ?? {};
  o != null && (e.value = ie(e.value, o));
}
function lk(e) {
  for (const t in e) {
    const n = e[t];
    let { scale: i } = n;
    if (i === !0) {
      switch (t) {
        case "fill":
        case "stroke":
          i = "color";
          break;
        case "fillOpacity":
        case "strokeOpacity":
        case "opacity":
          i = "opacity";
          break;
        default:
          i = Qt.has(t) ? t : null;
          break;
      }
      n.scale = i;
    }
  }
}
function Go(e, t, n = TB) {
  for (const { channels: i } of t.values())
    for (const r in i) {
      const s = i[r], { scale: o } = s;
      if (o != null && n(o)) {
        const a = e.get(o);
        a !== void 0 ? a.push(s) : e.set(o, [s]);
      }
    }
  return e;
}
function fk(e, t) {
  if (e == null)
    return;
  const { x: n, y: i } = e;
  if (n == null && i == null)
    return;
  const r = mn(e.data ?? n ?? i);
  if (r === void 0)
    throw new Error("missing facet data");
  const s = {};
  n != null && (s.fx = Ra(r, { value: n, scale: "fx" })), i != null && (s.fy = Ra(r, { value: i, scale: "fy" })), Sm(s, t);
  const o = ym(r, s);
  return { channels: s, groups: o, data: e.data };
}
function C1(e, t, n) {
  var c;
  if (e.facet === null || e.facet === "super")
    return;
  const { fx: i, fy: r } = e;
  if (i != null || r != null) {
    const u = mn(e.data ?? i ?? r);
    if (u === void 0)
      throw new Error(`missing facet data in ${e.ariaLabel}`);
    if (u === null)
      return;
    const l = {};
    return i != null && (l.fx = Ra(u, { value: i, scale: "fx" })), r != null && (l.fy = Ra(u, { value: r, scale: "fy" })), Sm(l, n), { channels: l, groups: ym(u, l) };
  }
  if (t === void 0)
    return;
  const { channels: s, groups: o, data: a } = t;
  if (e.facet !== "auto" || e.data === a)
    return { channels: s, groups: o };
  (o.size > 1 || o.size === 1 && s.fx && s.fy && [...o][0][1].size > 1) && ((c = mn(e.data)) == null ? void 0 : c.length) === a.length && Wr(`Warning: the ${e.ariaLabel} mark appears to use faceted data, but isn’t faceted. The mark data has the same length as the facet data and the mark facet option is "auto", but the mark data and facet data are distinct. If this mark should be faceted, set the mark facet option to true; otherwise, suppress this warning by setting the mark facet option to false.`);
}
function hk(e, t, n) {
  let { projection: i, x: r = {}, y: s = {}, fx: o = {}, fy: a = {}, axis: c, grid: u, facet: l = {}, facet: { axis: f = c, grid: h } = l, x: { axis: d = c, grid: p = d === null ? null : u } = r, y: { axis: g = c, grid: y = g === null ? null : u } = s, fx: { axis: m = f, grid: b = m === null ? null : h } = o, fy: { axis: w = f, grid: _ = w === null ? null : h } = a } = n;
  (i || !Xr(r) && !k1("x", e)) && (d = p = null), (i || !Xr(s) && !k1("y", e)) && (g = y = null), t.has("fx") || (m = b = null), t.has("fy") || (w = _ = null), d === void 0 && (d = !Pc(e, "x")), g === void 0 && (g = !Pc(e, "y")), m === void 0 && (m = !Pc(e, "fx")), w === void 0 && (w = !Pc(e, "fy")), d === !0 && (d = "bottom"), g === !0 && (g = "left"), m === !0 && (m = d === "top" || d === null ? "bottom" : "top"), w === !0 && (w = g === "right" || g === null ? "left" : "right");
  const x = [];
  return zc(x, _, j6, a), Uc(x, w, z6, "right", "left", l, a), zc(x, b, W6, o), Uc(x, m, P6, "top", "bottom", l, o), zc(x, y, V6, s), Uc(x, g, wm, "left", "right", n, s), zc(x, p, X6, r), Uc(x, d, _m, "bottom", "top", n, r), x;
}
function Uc(e, t, n, i, r, s, o) {
  if (!t)
    return;
  const a = dk(t);
  o = pk(a ? i : t, s, o);
  const { line: c } = o;
  (n === wm || n === _m) && c && !bo(c) && e.push(vm(mk(o))), e.push(n(o)), a && e.push(n({ ...o, anchor: r, label: null }));
}
function zc(e, t, n, i) {
  !t || bo(t) || e.push(n(yk(t, i)));
}
function dk(e) {
  return /^\s*both\s*$/i.test(e);
}
function pk(e, t, { line: n = t.line, ticks: i, tickSize: r, tickSpacing: s, tickPadding: o, tickFormat: a, tickRotate: c, fontVariant: u, ariaLabel: l, ariaDescription: f, label: h = t.label, labelAnchor: d, labelOffset: p }) {
  return {
    anchor: e,
    line: n,
    ticks: i,
    tickSize: r,
    tickSpacing: s,
    tickPadding: o,
    tickFormat: a,
    tickRotate: c,
    fontVariant: u,
    ariaLabel: l,
    ariaDescription: f,
    label: h,
    labelAnchor: d,
    labelOffset: p
  };
}
function mk(e) {
  const { anchor: t, line: n } = e;
  return { anchor: t, facetAnchor: t + "-empty", stroke: n === !0 ? void 0 : n };
}
function yk(e, { stroke: t = oc(e) ? e : void 0, ticks: n = gk(e) ? e : void 0, tickSpacing: i, ariaLabel: r, ariaDescription: s }) {
  return {
    stroke: t,
    ticks: n,
    tickSpacing: i,
    ariaLabel: r,
    ariaDescription: s
  };
}
function gk(e) {
  switch (typeof e) {
    case "number":
      return !0;
    case "string":
      return !oc(e);
  }
  return qi(e) || typeof (e == null ? void 0 : e.range) == "function";
}
function Pc(e, t) {
  const n = `${t}-axis `;
  return e.some((i) => {
    var r;
    return (r = i.ariaLabel) == null ? void 0 : r.startsWith(n);
  });
}
function k1(e, t) {
  for (const n of t)
    for (const i in n.channels)
      if (n.channels[i].scale === e)
        return !0;
  return !1;
}
function bk(e, t) {
  for (const n in e) {
    const i = e[n], r = t[n];
    i.label === void 0 && r && (i.label = r.label);
  }
  return e;
}
function wk({ fx: e, fy: t }, n) {
  const { marginTop: i, marginRight: r, marginBottom: s, marginLeft: o, width: a, height: c } = um(n), u = e && R1(e), l = t && R1(t);
  return {
    marginTop: t ? l[0] : i,
    marginRight: e ? a - u[1] : r,
    marginBottom: t ? c - l[1] : s,
    marginLeft: e ? u[0] : o,
    // Some marks, namely the x- and y-axis labels, want to know what the
    // desired (rather than actual) margins are for positioning.
    inset: {
      marginTop: n.marginTop,
      marginRight: n.marginRight,
      marginBottom: n.marginBottom,
      marginLeft: n.marginLeft
    },
    width: a,
    height: c
  };
}
function R1(e) {
  const t = e.domain();
  let n = e(t[0]), i = e(t[t.length - 1]);
  return i < n && ([n, i] = [i, n]), [n, i + e.bandwidth()];
}
const _k = /* @__PURE__ */ new Map([
  ["basis", UD],
  ["basis-closed", zD],
  ["basis-open", PD],
  ["bundle", YD],
  ["bump-x", TD],
  ["bump-y", ED],
  ["cardinal", qD],
  ["cardinal-closed", VD],
  ["cardinal-open", jD],
  ["catmull-rom", XD],
  ["catmull-rom-closed", WD],
  ["catmull-rom-open", HD],
  ["linear", rc],
  ["linear-closed", GD],
  ["monotone-x", ZD],
  ["monotone-y", KD],
  ["natural", JD],
  ["step", QD],
  ["step-after", eB],
  ["step-before", tB]
]);
function Gf(e = rc, t) {
  if (typeof e == "function")
    return e;
  const n = _k.get(`${e}`.toLowerCase());
  if (!n)
    throw new Error(`unknown curve: ${e}`);
  if (t !== void 0) {
    if ("beta" in n)
      return n.beta(t);
    if ("tension" in n)
      return n.tension(t);
    if ("alpha" in n)
      return n.alpha(t);
  }
  return n;
}
function Ns(e = { y: "count" }, t = {}) {
  [e, t] = Im(e, t);
  const { x: n, y: i } = t;
  return $m(Cl(n, t, lt), null, null, i, e, uc(t));
}
function Os(e = { x: "count" }, t = {}) {
  [e, t] = Im(e, t);
  const { x: n, y: i } = t;
  return $m(null, Cl(i, t, lt), n, null, e, lc(t));
}
function nS(e = { fill: "count" }, t = {}) {
  [e, t] = Im(e, t);
  const { x: n, y: i } = vk(t);
  return $m(n, i, null, null, e, uc(lc(t)));
}
function iS(e, t, n = {}) {
  return (n == null ? void 0 : n.interval) == null ? n : e({ [t]: (n == null ? void 0 : n.reduce) === void 0 ? nm : n.reduce, filter: null }, n);
}
function Mm(e) {
  return iS(Ns, "y", e);
}
function Am(e) {
  return iS(Os, "x", e);
}
function $m(e, t, n, i, {
  data: r = B3,
  // TODO avoid materializing when unused?
  filter: s = Ol,
  // return only non-empty bins by default
  sort: o,
  reverse: a,
  ...c
  // output channel definitions
} = {}, u = {}) {
  e = U1(e), t = U1(t), c = Jp(c, u), r = Rf(r, lt), o = o == null ? void 0 : Qp("sort", o, u), s = s == null ? void 0 : tm("filter", s, u), n != null && Ki(c, "x", "x1", "x2") && (n = null), i != null && Ki(c, "y", "y1", "y2") && (i = null);
  const [l, f] = De(e), [h, d] = De(e), [p, g] = De(t), [y, m] = De(t), [b, w] = n != null ? [n, "x"] : i != null ? [i, "y"] : [], [_, x] = De(b), {
    x: S,
    y: I,
    z: N,
    fill: F,
    stroke: $,
    x1: T,
    x2: D,
    // consumed if x is an output
    y1: E,
    y2: v,
    // consumed if y is an output
    domain: M,
    cumulative: A,
    thresholds: O,
    interval: L,
    ...C
  } = u, [k, R] = De(N), [z] = Ge(F), [G] = Ge($), [Z, pt] = De(z), [Ot, gt] = De(G);
  return {
    ..."z" in u && { z: k || N },
    ..."fill" in u && { fill: Z || F },
    ..."stroke" in u && { stroke: Ot || $ },
    ...ci(C, (bt, P) => {
      const V = dt(bt, b), it = dt(bt, N), U = dt(bt, z), It = dt(bt, G), wt = em(c, { z: it, fill: U, stroke: It }), Lt = [], ne = [], X = V && x([]), Vt = it && R([]), Sr = U && pt([]), Dn = It && gt([]), ty = e && f([]), D4 = e && d([]), ey = t && g([]), B4 = t && m([]), L4 = Ak(e == null ? void 0 : e(bt), t == null ? void 0 : t(bt));
      let C4 = 0;
      for (const us of c)
        us.initialize(bt);
      o && o.initialize(bt), s && s.initialize(bt);
      for (const us of P) {
        const ny = [];
        for (const Uo of c)
          Uo.scope("facet", us);
        o && o.scope("facet", us), s && s.scope("facet", us);
        for (const [Uo, k4] of js(us, wt))
          for (const [R4, U4] of js(k4, V))
            for (const [Mr, Ar] of L4(U4))
              if (!(s && !s.reduce(Mr, Ar))) {
                ny.push(C4++), ne.push(r.reduce(Mr, bt, Ar)), V && X.push(R4), it && Vt.push(wt === it ? Uo : it[Mr[0]]), U && Sr.push(wt === U ? Uo : U[Mr[0]]), It && Dn.push(wt === It ? Uo : It[Mr[0]]), ty && (ty.push(Ar.x1), D4.push(Ar.x2)), ey && (ey.push(Ar.y1), B4.push(Ar.y2));
                for (const z4 of c)
                  z4.reduce(Mr, Ar);
                o && o.reduce(Mr);
              }
        Lt.push(ny);
      }
      return D3(Lt, o, a), { data: ne, facets: Lt };
    }),
    ...!Ki(c, "x") && (l ? { x1: l, x2: h, x: Il(l, h) } : { x: S, x1: T, x2: D }),
    ...!Ki(c, "y") && (p ? { y1: p, y2: y, y: Il(p, y) } : { y: I, y1: E, y2: v }),
    ..._ && { [w]: _ },
    ...Object.fromEntries(c.map(({ name: bt, output: P }) => [bt, P]))
  };
}
function Im({ cumulative: e, domain: t, thresholds: n, interval: i, ...r }, s) {
  return [r, { cumulative: e, domain: t, thresholds: n, interval: i, ...s }];
}
function Cl(e, { cumulative: t, domain: n, thresholds: i, interval: r }, s) {
  return e = { ...Nf(e) }, e.domain === void 0 && (e.domain = n), e.cumulative === void 0 && (e.cumulative = t), e.thresholds === void 0 && (e.thresholds = i), e.interval === void 0 && (e.interval = r), e.value === void 0 && (e.value = s), e.thresholds = rS(e.thresholds, e.interval), e;
}
function vk(e) {
  let { x: t, y: n } = e;
  return t = Cl(t, e), n = Cl(n, e), [t.value, n.value] = ai(t.value, n.value), { x: t, y: n };
}
function U1(e) {
  if (e == null)
    return;
  const { value: t, cumulative: n, domain: i = Ne, thresholds: r } = e, s = (o) => {
    let a = dt(o, t), c;
    if (Ue(a) || Sk(r)) {
      a = ie(a, n6, Float64Array);
      let [l, f] = typeof i == "function" ? i(a) : i, h = typeof r == "function" && !Fs(r) ? r(a, l, f) : r;
      typeof h == "number" && (h = bv(l, f, h)), Fs(h) && (i === Ne && (l = h.floor(l), f = h.offset(h.floor(f))), h = h.range(l, h.offset(f))), c = h;
    } else {
      a = ie(a, lm, Float64Array);
      let [l, f] = typeof i == "function" ? i(a) : i, h = typeof r == "function" && !Fs(r) ? r(a, l, f) : r;
      if (typeof h == "number")
        if (i === Ne) {
          let d = Sa(l, f, h);
          if (isFinite(d))
            if (d > 0) {
              let p = Math.round(l / d), g = Math.round(f / d);
              p * d <= l || --p, g * d > f || ++g;
              let y = g - p + 1;
              h = new Float64Array(y);
              for (let m = 0; m < y; ++m)
                h[m] = (p + m) * d;
            } else if (d < 0) {
              d = -d;
              let p = Math.round(l * d), g = Math.round(f * d);
              p / d <= l || --p, g / d > f || ++g;
              let y = g - p + 1;
              h = new Float64Array(y);
              for (let m = 0; m < y; ++m)
                h[m] = (p + m) / d;
            } else
              h = [l];
          else
            h = [l];
        } else
          h = or(l, f, h);
      else
        Fs(h) && (i === Ne && (l = h.floor(l), f = h.offset(h.floor(f))), h = h.range(l, h.offset(f)));
      c = h;
    }
    const u = [];
    if (c.length === 1)
      u.push([c[0], c[0]]);
    else
      for (let l = 1; l < c.length; ++l)
        u.push([c[l - 1], c[l]]);
    return u.bin = (n < 0 ? Ik : n > 0 ? $k : Tm)(u, c, a), u;
  };
  return s.label = ln(t), s;
}
function rS(e, t, n = z1) {
  if (e === void 0)
    return t === void 0 ? n : xk(t);
  if (typeof e == "string") {
    switch (e.toLowerCase()) {
      case "freedman-diaconis":
        return d7;
      case "scott":
        return _w;
      case "sturges":
        return hp;
      case "auto":
        return z1;
    }
    const i = wr(e);
    if (i !== void 0)
      return i;
    throw new Error(`invalid thresholds: ${e}`);
  }
  return e;
}
function xk(e) {
  if (e = wr(e), !Fs(e))
    throw new Error(`invalid interval: ${e}`);
  return e;
}
function z1(e, t, n) {
  return Math.min(200, _w(e, t, n));
}
function Sk(e) {
  return Mk(e) || qi(e) && Ue(e);
}
function Mk(e) {
  return Fs(e) && typeof e == "function" && e() instanceof Date;
}
function Fs(e) {
  return e ? typeof e.range == "function" : !1;
}
function Ak(e, t) {
  return e && t ? function* (n) {
    const i = e.bin(n);
    for (const [r, [s, o]] of e.entries()) {
      const a = t.bin(i[r]);
      for (const [c, [u, l]] of t.entries())
        yield [a[c], { x1: s, y1: u, x2: o, y2: l }];
    }
  } : e ? function* (n) {
    const i = e.bin(n);
    for (const [r, [s, o]] of e.entries())
      yield [i[r], { x1: s, x2: o }];
  } : function* (n) {
    const i = t.bin(n);
    for (const [r, [s, o]] of t.entries())
      yield [i[r], { y1: s, y2: o }];
  };
}
function Tm(e, t, n) {
  return t = t.map(lm), (i) => {
    var s;
    const r = e.map(() => []);
    for (const o of i)
      (s = r[Jl(t, n[o]) - 1]) == null || s.push(o);
    return r;
  };
}
function $k(e, t, n) {
  const i = Tm(e, t, n);
  return (r) => {
    const s = i(r);
    for (let o = 1, a = s.length; o < a; ++o) {
      const c = s[o - 1], u = s[o];
      for (const l of c)
        u.push(l);
    }
    return s;
  };
}
function Ik(e, t, n) {
  const i = Tm(e, t, n);
  return (r) => {
    const s = i(r);
    for (let o = s.length - 2; o >= 0; --o) {
      const a = s[o + 1], c = s[o];
      for (const u of a)
        c.push(u);
    }
    return s;
  };
}
function Em(e = {}) {
  const { x: t, x1: n, x2: i } = e;
  return n === void 0 && i === void 0 && t === void 0 ? { ...e, x: lt } : e;
}
function Nm(e = {}) {
  const { y: t, y1: n, y2: i } = e;
  return n === void 0 && i === void 0 && t === void 0 ? { ...e, y: lt } : e;
}
function sS(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Bo(e));
  const { y1: n, y: i = n, x: r, ...s } = t, [o, a, c, u] = Lo(i, r, "x", e, s);
  return { ...o, y1: n, y: a, x1: c, x2: u, x: Il(c, u) };
}
function Tk(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Bo(e));
  const { y1: n, y: i = n, x: r } = t, [s, o, a] = Lo(i, r, "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function Ek(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Bo(e));
  const { y1: n, y: i = n, x: r } = t, [s, o, , a] = Lo(i, r, "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function oS(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Bo(e));
  const { x1: n, x: i = n, y: r, ...s } = t, [o, a, c, u] = Lo(i, r, "y", e, s);
  return { ...o, x1: n, x: a, y1: c, y2: u, y: Il(c, u) };
}
function Nk(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Bo(e));
  const { x1: n, x: i = n, y: r } = t, [s, o, a] = Lo(i, r, "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function Ok(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Bo(e));
  const { x1: n, x: i = n, y: r } = t, [s, o, , a] = Lo(i, r, "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function Om({ x: e, x1: t, x2: n, ...i } = {}) {
  return t === void 0 && n === void 0 ? sS({ x: e, ...i }) : ([t, n] = I3(e, t, n), { ...i, x1: t, x2: n });
}
function Fm({ y: e, y1: t, y2: n, ...i } = {}) {
  return t === void 0 && n === void 0 ? oS({ y: e, ...i }) : ([t, n] = I3(e, t, n), { ...i, y1: t, y2: n });
}
function Bo(e) {
  const { offset: t, order: n, reverse: i, ...r } = e;
  return [{ offset: t, order: n, reverse: i }, r];
}
function Fk(e, t = jp, n, { offset: i, order: r, reverse: s }, o) {
  const a = gr(o), [c, u] = De(e), [l, f] = Ve(t), [h, d] = Ve(t);
  return i = Dk(i), r = Ck(r, i, n), [
    ci(o, (p, g) => {
      const y = e == null ? void 0 : u(dt(p, e)), m = dt(p, t, Float64Array), b = dt(p, a), w = r && r(p, y, m, b), _ = p.length, x = f(new Float64Array(_)), S = d(new Float64Array(_)), I = [];
      for (const N of g) {
        const F = y ? Array.from(Yi(N, ($) => y[$]).values()) : [N];
        w && Yk(F, w);
        for (const $ of F) {
          let T = 0, D = 0;
          s && $.reverse();
          for (const E of $) {
            const v = m[E];
            v < 0 ? T = S[E] = (x[E] = T) + v : v > 0 ? D = S[E] = (x[E] = D) + v : S[E] = x[E] = D;
          }
        }
        I.push(F);
      }
      return i && i(I, x, S, b), { data: p, facets: g };
    }),
    c,
    l,
    h
  ];
}
const Lo = Fk;
function Dk(e) {
  if (e != null) {
    if (typeof e == "function")
      return e;
    switch (`${e}`.toLowerCase()) {
      case "expand":
      case "normalize":
        return Bk;
      case "center":
      case "silhouette":
        return Lk;
      case "wiggle":
        return cS;
    }
    throw new Error(`unknown offset: ${e}`);
  }
}
function aS(e, t) {
  let n = 0, i = 0;
  for (const r of e) {
    const s = t[r];
    s < n && (n = s), s > i && (i = s);
  }
  return [n, i];
}
function Bk(e, t, n) {
  for (const i of e)
    for (const r of i) {
      const [s, o] = aS(r, n);
      for (const a of r) {
        const c = 1 / (o - s || 1);
        t[a] = c * (t[a] - s), n[a] = c * (n[a] - s);
      }
    }
}
function Lk(e, t, n) {
  for (const i of e) {
    for (const r of i) {
      const [s, o] = aS(r, n);
      for (const a of r) {
        const c = (o + s) / 2;
        t[a] -= c, n[a] -= c;
      }
    }
    uS(i, t, n);
  }
  lS(e, t, n);
}
function cS(e, t, n, i) {
  for (const r of e) {
    const s = new so();
    let o = 0;
    for (const a of r) {
      let c = -1;
      const u = a.map((d) => Math.abs(n[d] - t[d])), l = a.map((d) => {
        c = i ? i[d] : ++c;
        const p = n[d] - t[d], g = s.has(c) ? p - s.get(c) : 0;
        return s.set(c, p), g;
      }), f = [0, ...s7(l)];
      for (const d of a)
        t[d] += o, n[d] += o;
      const h = ti(u);
      h && (o -= ti(u, (d, p) => (l[p] / 2 + f[p]) * d) / h);
    }
    uS(r, t, n);
  }
  lS(e, t, n);
}
function uS(e, t, n) {
  const i = he(e, (r) => he(r, (s) => t[s]));
  for (const r of e)
    for (const s of r)
      t[s] -= i, n[s] -= i;
}
function lS(e, t, n) {
  const i = e.length;
  if (i === 1)
    return;
  const r = e.map((a) => a.flat()), s = r.map((a) => (he(a, (c) => t[c]) + Gt(a, (c) => n[c])) / 2), o = he(s);
  for (let a = 0; a < i; a++) {
    const c = o - s[a];
    for (const u of r[a])
      t[u] += c, n[u] += c;
  }
}
function Ck(e, t, n) {
  if (e === void 0 && t === cS)
    return P1;
  if (e != null) {
    if (typeof e == "string") {
      switch (e.toLowerCase()) {
        case "value":
        case n:
          return kk;
        case "z":
          return Rk;
        case "sum":
          return Uk;
        case "appearance":
          return zk;
        case "inside-out":
          return P1;
      }
      return Y1(M3(e));
    }
    if (typeof e == "function")
      return Y1(e);
    if (Array.isArray(e))
      return Pk(e);
    throw new Error(`invalid order: ${e}`);
  }
}
function kk(e, t, n) {
  return n;
}
function Rk(e, t, n, i) {
  return i;
}
function Uk(e, t, n, i) {
  return Zf(i, fp(br(e), (r) => ti(r, (s) => n[s]), (r) => i[r]));
}
function zk(e, t, n, i) {
  return Zf(i, fp(br(e), (r) => t[dp(r, (s) => n[s])], (r) => i[r]));
}
function P1(e, t, n, i) {
  const r = br(e), s = fp(r, (l) => t[dp(l, (f) => n[f])], (l) => i[l]), o = qr(r, (l) => ti(l, (f) => n[f]), (l) => i[l]), a = [], c = [];
  let u = 0;
  for (const l of s)
    u < 0 ? (u += o.get(l), a.push(l)) : (u -= o.get(l), c.push(l));
  return Zf(i, c.reverse().concat(a));
}
function Y1(e) {
  return (t) => dt(t, e);
}
function Pk(e) {
  return (t, n, i, r) => Zf(r, e);
}
function Zf(e, t) {
  if (!e)
    throw new Error("missing channel: z");
  return t = new so(t.map((n, i) => [n, i])), e.map((n) => t.get(n));
}
function Yk(e, t) {
  for (const n of e)
    n.sort((i, r) => wo(t[i], t[r]));
}
const qk = {
  ariaLabel: "area",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class Kf extends Yt {
  constructor(t, n = {}) {
    const { x1: i, y1: r, x2: s, y2: o, z: a, curve: c, tension: u } = n;
    super(t, {
      x1: { value: i, scale: "x" },
      y1: { value: r, scale: "y" },
      x2: { value: s, scale: "x", optional: !0 },
      y2: { value: o, scale: "y", optional: !0 },
      z: { value: gr(n), optional: !0 }
    }, n, qk), this.z = a, this.curve = Gf(c, u);
  }
  filter(t) {
    return t;
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a } = i;
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, n, 0, 0).call((l) => l.selectAll().data(c6(t, [o, a, c, u], this, i)).enter().append("path").call(Xt, this).call(Dl, this, i).attr("d", Up().curve(this.curve).defined((f) => f >= 0).x0((f) => o[f]).y0((f) => a[f]).x1((f) => c[f]).y1((f) => u[f]))).node();
  }
}
function fS(e, t) {
  return t === void 0 ? ha(e, { x: sc, y: Ba }) : new Kf(e, t);
}
function cu(e, t) {
  const { y: n = Ze, ...i } = Am(t);
  return new Kf(e, Om(Em({ ...i, y1: n, y2: void 0 })));
}
function ha(e, t) {
  const { x: n = Ze, ...i } = Mm(t);
  return new Kf(e, Fm(Nm({ ...i, x1: n, x2: void 0 })));
}
function Dm(e, { marker: t, markerStart: n = t, markerMid: i = t, markerEnd: r = t } = {}) {
  e.markerStart = rd(n), e.markerMid = rd(i), e.markerEnd = rd(r);
}
function rd(e) {
  if (e == null || e === !1)
    return null;
  if (e === !0)
    return q1;
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return null;
    case "arrow":
      return Vk;
    case "dot":
      return jk;
    case "circle":
    case "circle-fill":
      return q1;
    case "circle-stroke":
      return Xk;
  }
  throw new Error(`invalid marker: ${e}`);
}
function Vk(e, t) {
  return Nt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("orient", "auto").attr("fill", "none").attr("stroke", e).attr("stroke-width", 1.5).attr("stroke-linecap", "round").attr("stroke-linejoin", "round").call((n) => n.append("path").attr("d", "M-1.5,-3l3,3l-3,3")).node();
}
function jk(e, t) {
  return Nt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", e).attr("stroke", "none").call((n) => n.append("circle").attr("r", 2.5)).node();
}
function q1(e, t) {
  return Nt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", e).attr("stroke", "white").attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
function Xk(e, t) {
  return Nt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", "white").attr("stroke", e).attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
let Wk = 0;
function hS(e, t, { stroke: n } = {}) {
  return dS(e, t, n && ((i) => n[i]));
}
function Hk(e, t, { stroke: n } = {}) {
  return dS(e, t, n && (([i]) => n[i]));
}
function dS(e, { markerStart: t, markerMid: n, markerEnd: i, stroke: r }, s = () => r) {
  const o = /* @__PURE__ */ new Map();
  function a(c) {
    return function(u) {
      const l = s(u);
      let f = o.get(c);
      f || o.set(c, f = /* @__PURE__ */ new Map());
      let h = f.get(l);
      if (!h) {
        const d = { document: this.ownerDocument }, p = this.parentNode.insertBefore(c(l, d), this), g = `plot-marker-${++Wk}`;
        p.setAttribute("id", g), f.set(l, h = `url(#${g})`);
      }
      return h;
    };
  }
  t && e.attr("marker-start", a(t)), n && e.attr("marker-mid", a(n)), i && e.attr("marker-end", a(i));
}
const Gk = {
  ariaLabel: "link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class pS extends Yt {
  constructor(t, n = {}) {
    const { x1: i, y1: r, x2: s, y2: o, curve: a, tension: c } = n;
    super(t, {
      x1: { value: i, scale: "x" },
      y1: { value: r, scale: "y" },
      x2: { value: s, scale: "x", optional: !0 },
      y2: { value: o, scale: "y", optional: !0 }
    }, n, Gk), this.curve = Gf(a, c), Dm(this, n);
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a } = i, { curve: l } = this;
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, n).call((f) => f.selectAll().data(t).enter().append("path").call(Xt, this).attr("d", (h) => {
      const d = $i(), p = l(d);
      return p.lineStart(), p.point(o[h], a[h]), p.point(c[h], u[h]), p.lineEnd(), d;
    }).call(ge, this, i).call(hS, this, i)).node();
  }
}
function mS(e, t = {}) {
  let { x: n, x1: i, x2: r, y: s, y1: o, y2: a, ...c } = t;
  return [i, r] = kl(n, i, r), [o, a] = kl(s, o, a), new pS(e, { ...c, x1: i, x2: r, y1: o, y2: a });
}
function kl(e, t, n) {
  if (e === void 0) {
    if (t === void 0) {
      if (n !== void 0)
        return [n];
    } else if (n === void 0)
      return [t];
  } else {
    if (t === void 0)
      return n === void 0 ? [e] : [e, n];
    if (n === void 0)
      return [e, t];
  }
  return [t, n];
}
const Zk = {
  ariaLabel: "arrow",
  fill: "none",
  stroke: "currentColor",
  strokeLinecap: "round",
  strokeMiterlimit: 1,
  strokeWidth: 1.5
};
class yS extends Yt {
  constructor(t, n = {}) {
    const {
      x1: i,
      y1: r,
      x2: s,
      y2: o,
      bend: a = 0,
      headAngle: c = 60,
      headLength: u = 8,
      // Disable the arrow with headLength = 0; or, use Plot.link.
      inset: l = 0,
      insetStart: f = l,
      insetEnd: h = l
    } = n;
    super(t, {
      x1: { value: i, scale: "x" },
      y1: { value: r, scale: "y" },
      x2: { value: s, scale: "x", optional: !0 },
      y2: { value: o, scale: "y", optional: !0 }
    }, n, Zk), this.bend = a === !0 ? 22.5 : Math.max(-90, Math.min(90, a)), this.headAngle = +c, this.headLength = +u, this.insetStart = +f, this.insetEnd = +h;
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a, SW: l } = i, { strokeWidth: f, bend: h, headAngle: d, headLength: p, insetStart: g, insetEnd: y } = this, m = l ? (x) => l[x] : He(f === void 0 ? 1 : f), b = h * Ll, w = d * Ll / 2, _ = p / 1.5;
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, n).call((x) => x.selectAll().data(t).enter().append("path").call(Xt, this).attr("d", (S) => {
      let I = o[S], N = a[S], F = c[S], $ = u[S];
      const T = Math.hypot(F - I, $ - N);
      if (T <= g + y)
        return null;
      let D = Math.atan2($ - N, F - I);
      const E = Math.min(_ * m(S), T / 3), v = Math.hypot(T / Math.tan(b), T) / 2;
      if (g || y)
        if (v < 1e5) {
          const z = Math.sign(b), [G, Z] = Kk([I, N], [F, $], v, z);
          if (g && ([I, N] = V1([G, Z, v], [I, N, g], -z * Math.sign(g))), y) {
            const [pt, Ot] = V1([G, Z, v], [F, $, y], z * Math.sign(y));
            D += Math.atan2(Ot - Z, pt - G) - Math.atan2($ - Z, F - G), F = pt, $ = Ot;
          }
        } else {
          const z = F - I, G = $ - N, Z = Math.hypot(z, G);
          g && (I += z / Z * g, N += G / Z * g), y && (F -= z / Z * y, $ -= G / Z * y);
        }
      const M = D + b, A = M + w, O = M - w, L = F - E * Math.cos(A), C = $ - E * Math.sin(A), k = F - E * Math.cos(O), R = $ - E * Math.sin(O);
      return `M${I},${N}${v < 1e5 ? `A${v},${v} 0,0,${b > 0 ? 1 : 0} ` : "L"}${F},${$}M${L},${C}L${F},${$}L${k},${R}`;
    }).call(ge, this, i)).node();
  }
}
function Kk([e, t], [n, i], r, s) {
  const o = n - e, a = i - t, c = Math.hypot(o, a), u = s * Math.sqrt(r * r - c * c / 4) / c;
  return [(e + n) / 2 - a * u, (t + i) / 2 + o * u];
}
function V1([e, t, n], [i, r, s], o) {
  const a = i - e, c = r - t, u = Math.hypot(a, c), l = (a * a + c * c - s * s + n * n) / (2 * u), f = o * Math.sqrt(n * n - l * l);
  return [e + (a * l + c * f) / u, t + (c * l - a * f) / u];
}
function Jk(e, t = {}) {
  let { x: n, x1: i, x2: r, y: s, y1: o, y2: a, ...c } = t;
  return [i, r] = kl(n, i, r), [o, a] = kl(s, o, a), new yS(e, { ...c, x1: i, x2: r, y1: o, y2: a });
}
const Qk = {
  ariaLabel: "dot",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5
};
function gS(e) {
  return e.sort === void 0 && e.reverse === void 0 ? N3({ channel: "r", order: "descending" }, e) : e;
}
class Jf extends Yt {
  constructor(t, n = {}) {
    const { x: i, y: r, r: s, rotate: o, symbol: a = Da, frameAnchor: c } = n, [u, l] = Se(o, 0), [f, h] = OL(a), [d, p] = Se(s, f == null ? 3 : 4.5);
    super(t, {
      x: { value: i, scale: "x", optional: !0 },
      y: { value: r, scale: "y", optional: !0 },
      r: { value: d, scale: "r", filter: ur, optional: !0 },
      rotate: { value: u, optional: !0 },
      symbol: { value: f, scale: "symbol", optional: !0 }
    }, gS(n), Qk), this.r = p, this.rotate = l, this.symbol = h, this.frameAnchor = Of(c);
    const { channels: g } = this, { symbol: y } = g;
    if (y) {
      const { fill: m, stroke: b } = g;
      y.hint = {
        fill: m ? m.value === y.value ? "color" : "currentColor" : this.fill,
        stroke: b ? b.value === y.value ? "color" : "currentColor" : this.stroke
      };
    }
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: u, r: l, rotate: f, symbol: h } = i, { r: d, rotate: p, symbol: g } = this, [y, m] = _r(this, r), b = this.symbol === Da, w = l ? void 0 : d * d * Math.PI;
    return Lf(d) && (t = []), Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, { x: c && o, y: u && a }).call((_) => _.selectAll().data(t).enter().append(b ? "circle" : "path").call(Xt, this).call(b ? (x) => {
      x.attr("cx", c ? (S) => c[S] : y).attr("cy", u ? (S) => u[S] : m).attr("r", l ? (S) => l[S] : d);
    } : (x) => {
      x.attr("transform", bm`translate(${c ? (S) => c[S] : y},${u ? (S) => u[S] : m})${f ? (S) => ` rotate(${f[S]})` : p ? ` rotate(${p})` : ""}`).attr("d", l && h ? (S) => {
        const I = $i();
        return h[S].draw(I, l[S] * l[S] * Math.PI), I;
      } : l ? (S) => {
        const I = $i();
        return g.draw(I, l[S] * l[S] * Math.PI), I;
      } : h ? (S) => {
        const I = $i();
        return h[S].draw(I, w), I;
      } : (() => {
        const S = $i();
        return g.draw(S, w), S;
      })());
    }).call(ge, this, i)).node();
  }
}
function cs(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return t.frameAnchor === void 0 && ([n, i] = ai(n, i)), new Jf(e, { ...r, x: n, y: i });
}
function tR(e, t = {}) {
  const { x: n = lt, ...i } = t;
  return new Jf(e, v6({ ...i, x: n }));
}
function eR(e, t = {}) {
  const { y: n = lt, ...i } = t;
  return new Jf(e, _6({ ...i, y: n }));
}
function nR(e, t) {
  return cs(e, { ...t, symbol: "circle" });
}
function iR(e, t) {
  return cs(e, { ...t, symbol: "hexagon" });
}
const rR = {
  ariaLabel: "line",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
function Rl(e) {
  return rc(e);
}
function sR({ curve: e = Rl, tension: t }) {
  return typeof e != "function" && `${e}`.toLowerCase() === "auto" ? Rl : Gf(e, t);
}
class Qf extends Yt {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s } = n;
    super(t, {
      x: { value: i, scale: "x" },
      y: { value: r, scale: "y" },
      z: { value: gr(n), optional: !0 }
    }, n, rR), this.z = s, this.curve = sR(n), Dm(this, n);
  }
  filter(t) {
    return t;
  }
  project(t, n, i) {
    this.curve !== Rl && super.project(t, n, i);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = i, { curve: c } = this;
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, n).call((u) => u.selectAll().data(c6(t, [o, a], this, i)).enter().append("path").call(Xt, this).call(Dl, this, i).call(Hk, this, i).attr("d", c === Rl && s.projection ? oR(s.projection, o, a) : Px().curve(c).defined((l) => l >= 0).x((l) => o[l]).y((l) => a[l]))).node();
  }
}
function oR(e, t, n) {
  const i = rs(e);
  return t = Ui(t), n = Ui(n), (r) => {
    let s = [];
    const o = [s];
    for (const a of r)
      a === -1 ? (s = [], o.push(s)) : s.push([t[a], n[a]]);
    return i({ type: "MultiLineString", coordinates: o });
  };
}
function bS(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return [n, i] = ai(n, i), new Qf(e, { ...r, x: n, y: i });
}
function wS(e, t = {}) {
  const { x: n = lt, y: i = Ze, ...r } = t;
  return new Qf(e, Am({ ...r, x: n, y: i }));
}
function _S(e, t = {}) {
  const { x: n = Ze, y: i = lt, ...r } = t;
  return new Qf(e, Mm({ ...r, x: n, y: i }));
}
class Bm extends Yt {
  constructor(t, n, i = {}, r) {
    super(t, n, i, r);
    const { inset: s = 0, insetTop: o = s, insetRight: a = s, insetBottom: c = s, insetLeft: u = s, rx: l, ry: f } = i;
    this.insetTop = vt(o), this.insetRight = vt(a), this.insetBottom = vt(c), this.insetLeft = vt(u), this.rx = re(l, "auto"), this.ry = re(f, "auto");
  }
  render(t, n, i, r, s) {
    const { rx: o, ry: a } = this;
    return Nt("svg:g", s).call(Zt, this, r, s).call(this._transform, this, n).call((c) => c.selectAll().data(t).enter().append("rect").call(Xt, this).attr("x", this._x(n, i, r)).attr("width", this._width(n, i, r)).attr("y", this._y(n, i, r)).attr("height", this._height(n, i, r)).call(K, "rx", o).call(K, "ry", a).call(ge, this, i)).node();
  }
  _x(t, { x: n }, { marginLeft: i }) {
    const { insetLeft: r } = this;
    return n ? (s) => n[s] + r : i + r;
  }
  _y(t, { y: n }, { marginTop: i }) {
    const { insetTop: r } = this;
    return n ? (s) => n[s] + r : i + r;
  }
  _width({ x: t }, { x: n }, { marginRight: i, marginLeft: r, width: s }) {
    const { insetLeft: o, insetRight: a } = this, c = n && t ? t.bandwidth() : s - i - r;
    return Math.max(0, c - o - a);
  }
  _height({ y: t }, { y: n }, { marginTop: i, marginBottom: r, height: s }) {
    const { insetTop: o, insetBottom: a } = this, c = n && t ? t.bandwidth() : s - i - r;
    return Math.max(0, c - o - a);
  }
}
const vS = {
  ariaLabel: "bar"
};
class xS extends Bm {
  constructor(t, n = {}) {
    const { x1: i, x2: r, y: s } = n;
    super(t, {
      x1: { value: i, scale: "x" },
      x2: { value: r, scale: "x" },
      y: { value: s, scale: "y", type: "band", optional: !0 }
    }, n, vS);
  }
  _transform(t, n, { x: i }) {
    t.call(Pt, n, { x: i }, 0, 0);
  }
  _x({ x: t }, { x1: n, x2: i }, { marginLeft: r }) {
    const { insetLeft: s } = this;
    return fn(t) ? r + s : (o) => Math.min(n[o], i[o]) + s;
  }
  _width({ x: t }, { x1: n, x2: i }, { marginRight: r, marginLeft: s, width: o }) {
    const { insetLeft: a, insetRight: c } = this;
    return fn(t) ? o - r - s - a - c : (u) => Math.max(0, Math.abs(i[u] - n[u]) - a - c);
  }
}
class SS extends Bm {
  constructor(t, n = {}) {
    const { x: i, y1: r, y2: s } = n;
    super(t, {
      y1: { value: r, scale: "y" },
      y2: { value: s, scale: "y" },
      x: { value: i, scale: "x", type: "band", optional: !0 }
    }, n, vS);
  }
  _transform(t, n, { y: i }) {
    t.call(Pt, n, { y: i }, 0, 0);
  }
  _y({ y: t }, { y1: n, y2: i }, { marginTop: r }) {
    const { insetTop: s } = this;
    return fn(t) ? r + s : (o) => Math.min(n[o], i[o]) + s;
  }
  _height({ y: t }, { y1: n, y2: i }, { marginTop: r, marginBottom: s, height: o }) {
    const { insetTop: a, insetBottom: c } = this;
    return fn(t) ? o - r - s - a - c : (u) => Math.max(0, Math.abs(i[u] - n[u]) - a - c);
  }
}
function Ds(e, t = { y: Ze, x2: lt }) {
  return new xS(e, Om(b6(Em(t))));
}
function Bs(e, t = { x: Ze, y2: lt }) {
  return new SS(e, Fm(w6(Nm(t))));
}
const aR = {
  ariaLabel: "rect"
};
class th extends Yt {
  constructor(t, n = {}) {
    const { x1: i, y1: r, x2: s, y2: o, inset: a = 0, insetTop: c = a, insetRight: u = a, insetBottom: l = a, insetLeft: f = a, rx: h, ry: d } = n;
    super(t, {
      x1: { value: i, scale: "x", optional: !0 },
      y1: { value: r, scale: "y", optional: !0 },
      x2: { value: s, scale: "x", optional: !0 },
      y2: { value: o, scale: "y", optional: !0 }
    }, n, aR), this.insetTop = vt(c), this.insetRight = vt(u), this.insetBottom = vt(l), this.insetLeft = vt(f), this.rx = re(h, "auto"), this.ry = re(d, "auto");
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x1: c, y1: u, x2: l, y2: f } = i, { marginTop: h, marginRight: d, marginBottom: p, marginLeft: g, width: y, height: m } = r, { projection: b } = s, { insetTop: w, insetRight: _, insetBottom: x, insetLeft: S, rx: I, ry: N } = this;
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, { x: c && l && o, y: u && f && a }, 0, 0).call((F) => F.selectAll().data(t).enter().append("rect").call(Xt, this).attr("x", c && l && (b || !fn(o)) ? ($) => Math.min(c[$], l[$]) + S : g + S).attr("y", u && f && (b || !fn(a)) ? ($) => Math.min(u[$], f[$]) + w : h + w).attr("width", c && l && (b || !fn(o)) ? ($) => Math.max(0, Math.abs(l[$] - c[$]) - S - _) : y - d - g - _ - S).attr("height", u && f && (b || !fn(a)) ? ($) => Math.max(0, Math.abs(u[$] - f[$]) - w - x) : m - h - p - w - x).call(K, "rx", I).call(K, "ry", N).call(ge, this, i)).node();
  }
}
function MS(e, t) {
  return new th(e, y6(g6(t)));
}
function S0(e, t = { y: Ze, interval: 1, x2: lt }) {
  return new th(e, Om(g6(Em(t))));
}
function M0(e, t = { x: Ze, interval: 1, y2: lt }) {
  return new th(e, Fm(y6(Nm(t))));
}
const cR = {
  ariaLabel: "cell"
};
class eh extends Bm {
  constructor(t, { x: n, y: i, ...r } = {}) {
    super(t, {
      x: { value: n, scale: "x", type: "band", optional: !0 },
      y: { value: i, scale: "y", type: "band", optional: !0 }
    }, r, cR);
  }
  _transform(t, n) {
    t.call(Pt, n, {}, 0, 0);
  }
}
function A0(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return [n, i] = ai(n, i), new eh(e, { ...r, x: n, y: i });
}
function uR(e, t = {}) {
  let { x: n = Ze, fill: i, stroke: r, ...s } = t;
  return i === void 0 && Ge(r)[0] === void 0 && (i = lt), new eh(e, { ...s, x: n, fill: i, stroke: r });
}
function lR(e, t = {}) {
  let { y: n = Ze, fill: i, stroke: r, ...s } = t;
  return i === void 0 && Ge(r)[0] === void 0 && (i = lt), new eh(e, { ...s, y: n, fill: i, stroke: r });
}
function fR(e, { x: t, y: n, color: i, size: r, fx: s, fy: o, mark: a } = {}) {
  vi(t) || (t = _s(t)), vi(n) || (n = _s(n)), vi(i) || (i = oc(i) ? { color: i } : _s(i)), vi(r) || (r = _s(r)), vi(s) && ({ value: s } = _s(s)), vi(o) && ({ value: o } = _s(o));
  const { value: c } = t, { value: u } = n, { value: l } = r, { value: f, color: h } = i;
  let { reduce: d } = t, { reduce: p } = n, { reduce: g } = r, { reduce: y } = i;
  d === void 0 && (d = p == null && c == null && l == null && u != null ? "count" : null), p === void 0 && (p = d == null && u == null && l == null && c != null ? "count" : null);
  let { zero: m } = t, { zero: b } = n;
  if (t = dt(e, c), n = dt(e, u), i = dt(e, f), r = dt(e, l), !t && !n)
    throw new Error("must specify x or y");
  if (d != null && !n)
    throw new Error("reducing x requires y");
  if (p != null && !t)
    throw new Error("reducing y requires x");
  let w, _;
  t && (t.label = ln(c)), n && (n.label = ln(u)), i && (i.label = ln(f)), r && (r.label = ln(l)), g === void 0 && l == null && y == null && d == null && p == null && (!t || Kt(t)) && (!n || Kt(n)) && (g = "count"), a === void 0 && (a = l != null || g != null ? "dot" : d != null || p != null || y != null ? "bar" : t && n ? ws(t) && ws(n) && (Yc(t) || Yc(n)) ? "line" : ws(t) && m || ws(n) && b ? "bar" : "dot" : t || n ? "rule" : null);
  let x;
  if (a != null)
    switch (`${a}`.toLowerCase()) {
      case "dot":
        a = cs, x = "stroke";
        break;
      case "line":
        a = t && n ? bS : t ? wS : _S, x = "stroke", j1(i) && (w = null);
        break;
      case "area":
        a = t && n ? ws(t) && Yc(t) ? ha : ws(n) && Yc(n) ? cu : fS : t ? cu : ha, x = "fill", j1(i) && (w = null);
        break;
      case "rule":
        a = t ? za : Pa, x = "stroke";
        break;
      case "bar":
        a = p != null ? Kt(t) ? Bs : M0 : d != null ? Kt(n) ? Ds : S0 : y != null ? t && n && Kt(t) && Kt(n) ? A0 : t && Kt(t) ? Bs : n && Kt(n) ? Ds : MS : t && n && Kt(t) && Kt(n) ? A0 : n && Kt(n) ? Ds : Bs, x = "fill";
        break;
      default:
        throw new Error(`invalid mark: ${a}`);
    }
  let S = { x: t, y: n, [x]: i ?? h, z: w, r, fx: s, fy: o }, I, N = { [x]: y, z: _, r: g };
  if (d != null && p != null)
    throw new Error("cannot reduce both x and y");
  p != null ? (N.y = p, I = Kt(t) ? El : Ns) : d != null ? (N.x = d, I = Kt(n) ? Nl : Os) : (y != null || g != null) && (t && n ? I = Kt(t) && Kt(n) ? F3 : Kt(t) ? Os : Kt(n) ? Ns : nS : t ? I = Kt(t) ? El : Ns : n && (I = Kt(n) ? Nl : Os)), I && (S = I(N, S)), m === void 0 && (m = I !== Ns && (a === Ds || a === cu || a === S0)), b === void 0 && (b = I !== Os && (a === Bs || a === ha || a === M0));
  const F = s != null || o != null ? vm({ strokeOpacity: 0.1 }) : null, $ = [m ? za([0]) : null, b ? Pa([0]) : null];
  return a = a(e, S), x === "stroke" ? lr(F, $, a) : lr(F, a, $);
}
function ws(e) {
  return !Kt(e);
}
function Yc(e) {
  let t, n;
  for (const i of e) {
    if (i == null)
      continue;
    if (t === void 0) {
      t = i;
      continue;
    }
    const r = Math.sign(jt(t, i));
    if (r) {
      if (n !== void 0 && r !== n)
        return !1;
      t = i, n = r;
    }
  }
  return !0;
}
function _s(e) {
  return hR(e) ? { reduce: e } : { value: e };
}
function hR(e) {
  if (typeof (e == null ? void 0 : e.reduce) == "function" || /^p\d{2}$/i.test(e))
    return !0;
  switch (`${e}`.toLowerCase()) {
    case "first":
    case "last":
    case "count":
    case "distinct":
    case "sum":
    case "proportion":
    case "proportion-facet":
    case "deviation":
    case "min":
    case "min-index":
    case "max":
    case "max-index":
    case "mean":
    case "median":
    case "variance":
    case "mode":
      return !0;
  }
  return !1;
}
function j1(e) {
  return e ? new up(e).size > e.length >> 1 : !1;
}
function Lm(e, t = {}) {
  return AS(Object.fromEntries(["x", "x1", "x2"].filter((n) => t[n] != null).map((n) => [n, e])), t);
}
function Cm(e, t = {}) {
  return AS(Object.fromEntries(["y", "y1", "y2"].filter((n) => t[n] != null).map((n) => [n, e])), t);
}
function nh(e = {}, t = {}) {
  const n = gr(t), i = Object.entries(e).map(([r, s]) => {
    const o = T3(r, t);
    if (o == null)
      throw new Error(`missing channel: ${r}`);
    const [a, c] = Ve(o);
    return { key: r, input: o, output: a, setOutput: c, map: dR(s) };
  });
  return {
    ...ci(t, (r, s) => {
      const o = dt(r, n), a = i.map(({ input: u }) => dt(r, u)), c = i.map(({ setOutput: u }) => u(new Array(r.length)));
      for (const u of s)
        for (const l of o ? Yi(u, (f) => o[f]).values() : [u])
          i.forEach(({ map: f }, h) => f.map(l, a[h], c[h]));
      return { data: r, facets: s };
    }),
    ...Object.fromEntries(i.map(({ key: r, output: s }) => [r, s]))
  };
}
const AS = nh;
function dR(e) {
  if (e && typeof e.map == "function")
    return e;
  if (typeof e == "function")
    return sd(e);
  switch (`${e}`.toLowerCase()) {
    case "cumsum":
      return mR;
    case "rank":
      return sd(Sw);
    case "quantile":
      return sd(pR);
  }
  throw new Error(`invalid map: ${e}`);
}
function pR(e) {
  const t = Ql(e) - 1;
  return Sw(e).map((n) => n / t);
}
function sd(e) {
  return {
    map(t, n, i) {
      const r = e(Ji(n, t));
      if (r.length !== t.length)
        throw new Error("map function returned a mismatched length");
      for (let s = 0, o = t.length; s < o; ++s)
        i[t[s]] = r[s];
    }
  };
}
const mR = {
  map(e, t, n) {
    let i = 0;
    for (const r of e)
      n[r] = i += t[r];
  }
}, yR = {
  ariaLabel: "tick",
  fill: null,
  stroke: "currentColor"
};
class $S extends Yt {
  constructor(t, n, i) {
    super(t, n, i, yR);
  }
  render(t, n, i, r, s) {
    return Nt("svg:g", s).call(Zt, this, r, s).call(this._transform, this, n).call((o) => o.selectAll().data(t).enter().append("line").call(Xt, this).attr("x1", this._x1(n, i, r)).attr("x2", this._x2(n, i, r)).attr("y1", this._y1(n, i, r)).attr("y2", this._y2(n, i, r)).call(ge, this, i)).node();
  }
}
class IS extends $S {
  constructor(t, n = {}) {
    const { x: i, y: r, inset: s = 0, insetTop: o = s, insetBottom: a = s } = n;
    super(t, {
      x: { value: i, scale: "x" },
      y: { value: r, scale: "y", type: "band", optional: !0 }
    }, n), this.insetTop = vt(o), this.insetBottom = vt(a);
  }
  _transform(t, n, { x: i }) {
    t.call(Pt, n, { x: i }, me, 0);
  }
  _x1(t, { x: n }) {
    return (i) => n[i];
  }
  _x2(t, { x: n }) {
    return (i) => n[i];
  }
  _y1({ y: t }, { y: n }, { marginTop: i }) {
    const { insetTop: r } = this;
    return n && t ? (s) => n[s] + r : i + r;
  }
  _y2({ y: t }, { y: n }, { height: i, marginBottom: r }) {
    const { insetBottom: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : i - r - s;
  }
}
class TS extends $S {
  constructor(t, n = {}) {
    const { x: i, y: r, inset: s = 0, insetRight: o = s, insetLeft: a = s } = n;
    super(t, {
      y: { value: r, scale: "y" },
      x: { value: i, scale: "x", type: "band", optional: !0 }
    }, n), this.insetRight = vt(o), this.insetLeft = vt(a);
  }
  _transform(t, n, { y: i }) {
    t.call(Pt, n, { y: i }, 0, me);
  }
  _x1({ x: t }, { x: n }, { marginLeft: i }) {
    const { insetLeft: r } = this;
    return n && t ? (s) => n[s] + r : i + r;
  }
  _x2({ x: t }, { x: n }, { width: i, marginRight: r }) {
    const { insetRight: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : i - r - s;
  }
  _y1(t, { y: n }) {
    return (i) => n[i];
  }
  _y2(t, { y: n }) {
    return (i) => n[i];
  }
}
function ES(e, t = {}) {
  const { x: n = lt, ...i } = t;
  return new IS(e, { ...i, x: n });
}
function NS(e, t = {}) {
  const { y: n = lt, ...i } = t;
  return new TS(e, { ...i, y: n });
}
function gR(e, t = {}) {
  const { x: n = { transform: (h) => h }, y: i = null, fill: r = "#ccc", fillOpacity: s, stroke: o = "currentColor", strokeOpacity: a, strokeWidth: c = 2, sort: u, ...l } = t, f = i != null ? Nl : Kp;
  return lr(Pa(e, f({ x1: km, x2: Rm }, { x: n, y: i, stroke: o, strokeOpacity: a, ...l })), Ds(e, f({ x1: "p25", x2: "p75" }, { x: n, y: i, fill: r, fillOpacity: s, ...l })), ES(e, f({ x: "p50" }, { x: n, y: i, stroke: o, strokeOpacity: a, strokeWidth: c, sort: u, ...l })), cs(e, nh({ x: OS }, { x: n, y: i, z: i, stroke: o, strokeOpacity: a, ...l })));
}
function bR(e, t = {}) {
  const { y: n = { transform: (h) => h }, x: i = null, fill: r = "#ccc", fillOpacity: s, stroke: o = "currentColor", strokeOpacity: a, strokeWidth: c = 2, sort: u, ...l } = t, f = i != null ? El : Kp;
  return lr(za(e, f({ y1: km, y2: Rm }, { x: i, y: n, stroke: o, strokeOpacity: a, ...l })), Bs(e, f({ y1: "p25", y2: "p75" }, { x: i, y: n, fill: r, fillOpacity: s, ...l })), NS(e, f({ y: "p50" }, { x: i, y: n, stroke: o, strokeOpacity: a, strokeWidth: c, sort: u, ...l })), cs(e, nh({ y: OS }, { x: i, y: n, z: i, stroke: o, strokeOpacity: a, ...l })));
}
function OS(e) {
  const t = km(e), n = Rm(e);
  return e.map((i) => i < t || i > n ? i : NaN);
}
function km(e, t) {
  const n = FS(e, t) * 2.5 - DS(e, t) * 1.5;
  return he(e, (i) => i >= n ? i : NaN);
}
function Rm(e, t) {
  const n = DS(e, t) * 2.5 - FS(e, t) * 1.5;
  return Gt(e, (i) => i <= n ? i : NaN);
}
function FS(e, t) {
  return ar(e, 0.25, t);
}
function DS(e, t) {
  return ar(e, 0.75, t);
}
const wR = {
  ariaLabel: "raster",
  stroke: null,
  pixelSize: 1
};
function vs(e, t) {
  const n = +e;
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
function X1(e, t) {
  const n = Math.floor(e);
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
class BS extends Yt {
  constructor(t, n, i = {}, r) {
    let { width: s, height: o, x: a, y: c, x1: u = a == null ? 0 : void 0, y1: l = c == null ? 0 : void 0, x2: f = a == null ? s : void 0, y2: h = c == null ? o : void 0, pixelSize: d = r.pixelSize, blur: p = 0, interpolate: g } = i;
    if (s != null && (s = X1(s, "width")), o != null && (o = X1(o, "height")), u != null && (u = vs(u, "x1")), l != null && (l = vs(l, "y1")), f != null && (f = vs(f, "x2")), h != null && (h = vs(h, "y2")), a == null && (u == null || f == null))
      throw new Error("missing x");
    if (c == null && (l == null || h == null))
      throw new Error("missing y");
    t != null && s != null && o != null && (a === void 0 && u != null && f != null && (a = AR(u, f, s)), c === void 0 && l != null && h != null && (c = $R(l, h, s, o))), super(t, {
      x: { value: a, scale: "x", optional: !0 },
      y: { value: c, scale: "y", optional: !0 },
      x1: { value: u == null ? null : [u], scale: "x", optional: !0, filter: null },
      y1: { value: l == null ? null : [l], scale: "y", optional: !0, filter: null },
      x2: { value: f == null ? null : [f], scale: "x", optional: !0, filter: null },
      y2: { value: h == null ? null : [h], scale: "y", optional: !0, filter: null },
      ...n
    }, i, r), this.width = s, this.height = o, this.pixelSize = vs(d, "pixelSize"), this.blur = vs(p, "blur"), this.interpolate = a == null || c == null ? null : vR(g);
  }
}
class LS extends BS {
  constructor(t, n = {}) {
    const { imageRendering: i } = n;
    if (t == null) {
      const { fill: r, fillOpacity: s } = n;
      Se(s)[0] !== void 0 && (n = $0("fillOpacity", n)), Ge(r)[0] !== void 0 && (n = $0("fill", n));
    }
    super(t, void 0, n, wR), this.imageRendering = re(i, "auto");
  }
  // Ignore the color scale, so the fill channel is returned unscaled.
  scale(t, { color: n, ...i }, r) {
    return super.scale(t, i, r);
  }
  render(t, n, i, r, s) {
    const o = n.color ?? ((M) => M), { x: a, y: c } = i, { document: u } = s, [l, f, h, d] = kS(i, r, s), p = h - l, g = d - f, { pixelSize: y, width: m = Math.round(Math.abs(p) / y), height: b = Math.round(Math.abs(g) / y) } = this, w = m * b;
    let { fill: _, fillOpacity: x } = i, S = 0;
    if (this.interpolate) {
      const M = m / p, A = b / g, O = ie(a, (C) => (C - l) * M, Float64Array), L = ie(c, (C) => (C - f) * A, Float64Array);
      _ && (_ = this.interpolate(t, m, b, O, L, _)), x && (x = this.interpolate(t, m, b, O, L, x));
    } else
      this.data == null && t && (S = t.fi * w);
    const I = u.createElement("canvas");
    I.width = m, I.height = b;
    const N = I.getContext("2d"), F = N.createImageData(m, b), $ = F.data;
    let { r: T, g: D, b: E } = pn(this.fill) ?? { r: 0, g: 0, b: 0 }, v = (this.fillOpacity ?? 1) * 255;
    for (let M = 0; M < w; ++M) {
      const A = M << 2;
      if (_) {
        const O = o(_[M + S]);
        if (O == null) {
          $[A + 3] = 0;
          continue;
        }
        ({ r: T, g: D, b: E } = pn(O));
      }
      x && (v = x[M + S] * 255), $[A + 0] = T, $[A + 1] = D, $[A + 2] = E, $[A + 3] = v;
    }
    return this.blur > 0 && K$(F, this.blur), N.putImageData(F, 0, 0), Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, n).call((M) => M.append("image").attr("transform", `translate(${l},${f}) scale(${Math.sign(h - l)},${Math.sign(d - f)})`).attr("width", Math.abs(p)).attr("height", Math.abs(g)).attr("preserveAspectRatio", "none").call(K, "image-rendering", this.imageRendering).call(Xt, this).attr("xlink:href", I.toDataURL())).node();
  }
}
function CS(e, t, n) {
  arguments.length < 3 && (n = t, t = null);
  let { x: i, y: r, [e]: s, ...o } = n;
  return i === void 0 && r === void 0 && OB(t) && (i = sc, r = Ba, s === void 0 && (s = EB)), [t, { ...o, x: i, y: r, [e]: s }];
}
function _R() {
  const [e, t] = CS("fill", ...arguments);
  return new LS(e, e == null || t.fill !== void 0 || t.fillOpacity !== void 0 ? t : { ...t, fill: lt });
}
function kS({ x1: e, y1: t, x2: n, y2: i }, r, { projection: s }) {
  const { width: o, height: a, marginTop: c, marginRight: u, marginBottom: l, marginLeft: f } = r;
  return [
    e && s == null ? e[0] : f,
    t && s == null ? t[0] : c,
    n && s == null ? n[0] : o - u,
    i && s == null ? i[0] : a - l
  ];
}
function RS({ x1: e, y1: t, x2: n, y2: i }, r, s, o) {
  const a = {};
  return e && (a.x1 = e), t && (a.y1 = t), n && (a.x2 = n), i && (a.y2 = i), kS(im(a, r), s, o);
}
function $0(e, t = {}) {
  const { [e]: n } = t;
  if (typeof n != "function")
    throw new Error(`invalid ${e}: not a function`);
  return Fn({ ...t, [e]: void 0 }, function(i, r, s, o, a, c) {
    const { x: u, y: l } = o;
    if (!u)
      throw new Error("missing scale: x");
    if (!l)
      throw new Error("missing scale: y");
    const [f, h, d, p] = RS(s, o, a, c), g = d - f, y = p - h, { pixelSize: m } = this, { width: b = Math.round(Math.abs(g) / m), height: w = Math.round(Math.abs(y) / m) } = t, _ = new Array(b * w * (r ? r.length : 1)), x = g / b, S = y / w;
    let I = 0;
    for (const N of r ?? [void 0])
      for (let F = 0.5; F < w; ++F)
        for (let $ = 0.5; $ < b; ++$, ++I)
          _[I] = n(u.invert(f + $ * x), l.invert(h + F * S), N);
    return { data: _, facets: r, channels: { [e]: { value: _, scale: !0 } } };
  });
}
function vR(e) {
  if (typeof e == "function")
    return e;
  if (e == null)
    return I0;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return I0;
    case "nearest":
      return zS;
    case "barycentric":
      return US();
    case "random-walk":
      return PS();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function I0(e, t, n, i, r, s) {
  const o = new Array(t * n);
  for (const a of e)
    i[a] < 0 || i[a] >= t || r[a] < 0 || r[a] >= n || (o[Math.floor(r[a]) * t + Math.floor(i[a])] = s[a]);
  return o;
}
function US({ random: e = Bp(42) } = {}) {
  return (t, n, i, r, s, o) => {
    const a = t.length, c = n >> 2, u = (i >> 2) - 1, l = a + c * 2 + u * 2, f = new Float64Array(l * 2);
    for (let w = 0; w < a; ++w)
      f[w * 2] = r[t[w]], f[w * 2 + 1] = s[t[w]];
    let h = a;
    const d = (w, _) => (f[h * 2] = w, f[h * 2 + 1] = _, h++);
    for (let w = 0; w <= c; ++w)
      d(w / c * n, 0), d(w / c * n, i);
    for (let w = 0; w < u; ++w)
      d(n, w / u * i), d(0, w / u * i);
    o = Ji(o, t);
    const p = new ki(f.subarray(0, a * 2));
    for (let w = a, _; w < l; ++w)
      o[w] = o[_ = p.find(f[w * 2], f[w * 2 + 1], _)];
    const { points: g, triangles: y } = new ki(f), m = new o.constructor(n * i), b = MR(o, e);
    for (let w = 0; w < y.length; w += 3) {
      const _ = y[w], x = y[w + 1], S = y[w + 2], I = g[2 * _], N = g[2 * x], F = g[2 * S], $ = g[2 * _ + 1], T = g[2 * x + 1], D = g[2 * S + 1], E = Math.min(I, N, F), v = Math.max(I, N, F), M = Math.min($, T, D), A = Math.max($, T, D), O = (T - D) * (I - F) + ($ - D) * (F - N);
      if (!O)
        continue;
      const L = o[_], C = o[x], k = o[S];
      for (let R = Math.floor(E); R < v; ++R)
        for (let z = Math.floor(M); z < A; ++z) {
          if (R < 0 || R >= n || z < 0 || z >= i)
            continue;
          const G = R + 0.5, Z = z + 0.5, pt = ((T - D) * (G - F) + (Z - D) * (F - N)) / O;
          if (pt < 0)
            continue;
          const Ot = ((D - $) * (G - F) + (Z - D) * (I - F)) / O;
          if (Ot < 0)
            continue;
          const gt = 1 - pt - Ot;
          gt < 0 || (m[R + n * z] = b(L, pt, C, Ot, k, gt, R, z));
        }
    }
    return m;
  };
}
function zS(e, t, n, i, r, s) {
  const o = new s.constructor(t * n), a = ki.from(e, (l) => i[l], (l) => r[l]);
  let c, u;
  for (let l = 0.5, f = 0; l < n; ++l) {
    u = c;
    for (let h = 0.5; h < t; ++h, ++f)
      u = a.find(h, l, u), h === 0.5 && (c = u), o[f] = s[e[u]];
  }
  return o;
}
function PS({ random: e = Bp(42), minDistance: t = 0.5, maxSteps: n = 2 } = {}) {
  return (i, r, s, o, a, c) => {
    const u = new c.constructor(r * s), l = ki.from(i, (p) => o[p], (p) => a[p]);
    let f, h, d;
    for (let p = 0.5, g = 0; p < s; ++p) {
      h = f;
      for (let y = 0.5; y < r; ++y, ++g) {
        let m = y, b = p;
        d = h = l.find(m, b, h), y === 0.5 && (f = h);
        let w, _ = 0;
        for (; (w = Math.hypot(o[i[d]] - m, a[i[d]] - b)) > t && _ < n; ) {
          const x = e(y, p, _) * 2 * Math.PI;
          m += Math.cos(x) * w, b += Math.sin(x) * w, d = l.find(m, b, d), ++_;
        }
        u[g] = c[i[d]];
      }
    }
    return u;
  };
}
function xR(e, t, n, i, r, s) {
  return t * e + i * n + s * r;
}
function SR(e) {
  return (t, n, i, r, s, o, a, c) => {
    const u = e(a, c);
    return u < n ? t : u < n + r ? i : s;
  };
}
function MR(e, t) {
  return E3(e) || Ue(e) ? xR : SR(t);
}
function AR(e, t, n) {
  return {
    transform(i) {
      const r = i.length, s = new Float64Array(r), o = (t - e) / n, a = e + o / 2;
      for (let c = 0; c < r; ++c)
        s[c] = c % n * o + a;
      return s;
    }
  };
}
function $R(e, t, n, i) {
  return {
    transform(r) {
      const s = r.length, o = new Float64Array(s), a = (t - e) / i, c = e + a / 2;
      for (let u = 0; u < s; ++u)
        o[u] = Math.floor(u / n) % i * a + c;
      return o;
    }
  };
}
const W1 = {
  ariaLabel: "contour",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1,
  pixelSize: 2
};
class YS extends BS {
  constructor(t, { smooth: n = !0, value: i, ...r } = {}) {
    const s = a6({}, r, W1);
    if (i === void 0) {
      for (const a in s)
        if (s[a].value != null) {
          if (i !== void 0)
            throw new Error("ambiguous contour value");
          i = r[a], r[a] = "value";
        }
    }
    if (i != null) {
      const a = { transform: (c) => c.map((u) => u.value), label: ln(i) };
      for (const c in s)
        r[c] === "value" && (r[c] = a);
    }
    if (t == null) {
      if (i == null)
        throw new Error("missing contour value");
      r = $0("value", { value: i, ...r }), i = null;
    } else {
      let { interpolate: a } = r;
      i === void 0 && (i = lt), a === void 0 && (r.interpolate = "nearest");
    }
    super(t, { value: { value: i, optional: !0 } }, IR(r), W1);
    const o = { geometry: { value: lt } };
    for (const a in this.channels) {
      const c = this.channels[a], { scale: u } = c;
      u === "x" || u === "y" || a === "value" || (o[a] = c, delete this.channels[a]);
    }
    this.contourChannels = o, this.smooth = !!n;
  }
  filter(t, { x: n, y: i, value: r, ...s }, o) {
    return super.filter(t, s, o);
  }
  render(t, n, i, r, s) {
    const { geometry: o } = i, a = rs();
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, n).call((c) => {
      c.selectAll().data(t).enter().append("path").call(Xt, this).attr("d", (u) => a(o[u])).call(ge, this, i);
    }).node();
  }
}
function IR({ thresholds: e, interval: t, ...n }) {
  return e = rS(e, t, hp), Fn(n, function(i, r, s, o, a, c) {
    const [u, l, f, h] = RS(s, o, a, c), d = f - u, p = h - l, { pixelSize: g, width: y = Math.round(Math.abs(d) / g), height: m = Math.round(Math.abs(p) / g) } = this, b = y / d, w = m / p, _ = s.value.value, x = [];
    if (this.interpolate) {
      const { x: $, y: T } = Pf(s, o, c), D = Fy($, (A) => (A - u) * b), E = Fy(T, (A) => (A - l) * w), v = [s.x, s.y, s.value], M = [D, E, _];
      for (const A of r) {
        const O = this.filter(A, v, M);
        x.push(this.interpolate(O, y, m, D, E, _));
      }
    } else if (r) {
      const $ = y * m, T = r.length;
      for (let D = 0; D < T; ++D)
        x.push(_.slice(D * $, D * $ + $));
    } else
      x.push(_);
    if (this.blur > 0)
      for (const $ of x)
        fw({ data: $, width: y, height: m }, this.blur);
    const S = TR(e, _, ...NR(x));
    if (S === null)
      throw new Error(`unsupported thresholds: ${e}`);
    const { contour: I } = Hu().size([y, m]).smooth(this.smooth), N = [], F = [];
    for (const $ of x)
      F.push(sn(N.length, N.push(...S.map((T) => I($, T)))));
    for (const { coordinates: $ } of N)
      for (const T of $)
        for (const D of T)
          for (const E of D)
            E[0] = E[0] / b + u, E[1] = E[1] / w + l;
    return {
      data: N,
      facets: F,
      channels: C3(this.contourChannels, N)
    };
  });
}
function TR(e, t, n, i) {
  if (typeof (e == null ? void 0 : e.range) == "function")
    return e.range(e.floor(n), i);
  if (typeof e == "function" && (e = e(t, n, i)), typeof e != "number")
    return mn(e, Array);
  const r = or(...bw(n, i, e), e);
  for (; r[r.length - 1] >= i; )
    r.pop();
  for (; r[1] < n; )
    r.shift();
  return r;
}
function ER() {
  return new YS(...CS("value", ...arguments));
}
function NR(e) {
  return [he(e, (t) => he(t, H1)), Gt(e, (t) => Gt(t, H1))];
}
function H1(e) {
  return isFinite(e) ? e : NaN;
}
const OR = {
  ariaLabel: "delaunay link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, FR = {
  ariaLabel: "delaunay mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
}, DR = {
  ariaLabel: "hull",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeMiterlimit: 1
}, BR = {
  ariaLabel: "voronoi",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, LR = {
  ariaLabel: "voronoi mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
};
class CR extends Yt {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s, curve: o, tension: a } = n;
    super(t, {
      x: { value: i, scale: "x", optional: !0 },
      y: { value: r, scale: "y", optional: !0 },
      z: { value: s, optional: !0 }
    }, n, OR), this.curve = Gf(o, a), Dm(this, n);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = i, { curve: f } = this, [h, d] = _r(this, r), p = c ? (b) => c[b] : He(h), g = u ? (b) => u[b] : He(d), y = this;
    function m(b) {
      let w = -1;
      const _ = [], x = {};
      for (const v in i)
        x[v] = [];
      const S = [], I = [], N = [], F = [];
      function $(v, M) {
        v = b[v], M = b[M], _.push(++w), S[w] = p(v), N[w] = g(v), I[w] = p(M), F[w] = g(M);
        for (const A in i)
          x[A].push(i[A][M]);
      }
      const { halfedges: T, hull: D, triangles: E } = ki.from(b, p, g);
      for (let v = 0; v < T.length; ++v) {
        const M = T[v];
        M > v && $(E[v], E[M]);
      }
      for (let v = 0; v < D.length; ++v)
        $(D[v], D[(v + 1) % D.length]);
      zt(this).selectAll().data(_).join("path").call(Xt, y).attr("d", (v) => {
        const M = $i(), A = f(M);
        return A.lineStart(), A.point(S[v], N[v]), A.point(I[v], F[v]), A.lineEnd(), M;
      }).call(ge, y, x).call(hS, y, x);
    }
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, { x: c && o, y: u && a }).call(l ? (b) => b.selectAll().data(Yi(t, (w) => l[w]).values()).enter().append("g").each(m) : (b) => b.datum(t).each(m)).node();
  }
}
class Um extends Yt {
  constructor(t, n = {}, i, r = ({ z: s }) => s) {
    const { x: s, y: o } = n;
    super(t, {
      x: { value: s, scale: "x", optional: !0 },
      y: { value: o, scale: "y", optional: !0 },
      z: { value: r(n), optional: !0 }
    }, n, i);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = i, [f, h] = _r(this, r), d = c ? (m) => c[m] : He(f), p = u ? (m) => u[m] : He(h), g = this;
    function y(m) {
      const b = ki.from(m, d, p);
      zt(this).append("path").datum(m[0]).call(Xt, g).attr("d", g._render(b, r)).call(ge, g, i);
    }
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, { x: c && o, y: u && a }).call(l ? (m) => m.selectAll().data(Yi(t, (b) => l[b]).values()).enter().append("g").each(y) : (m) => m.datum(t).each(y)).node();
  }
}
class kR extends Um {
  constructor(t, n = {}) {
    super(t, n, FR), this.fill = "none";
  }
  _render(t) {
    return t.render();
  }
}
class RR extends Um {
  constructor(t, n = {}) {
    super(t, n, DR, gr);
  }
  _render(t) {
    return t.renderHull();
  }
}
class UR extends Yt {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s } = n;
    super(t, {
      x: { value: i, scale: "x", optional: !0 },
      y: { value: r, scale: "y", optional: !0 },
      z: { value: s, optional: !0 }
    }, n, BR);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = i, [f, h] = _r(this, r), d = c ? (m) => c[m] : He(f), p = u ? (m) => u[m] : He(h), g = this;
    function y(m) {
      const b = ki.from(m, d, p), w = qS(b, r);
      zt(this).selectAll().data(m).enter().append("path").call(Xt, g).attr("d", (_, x) => w.renderCell(x)).call(ge, g, i);
    }
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, { x: c && o, y: u && a }).call(l ? (m) => m.selectAll().data(Yi(t, (b) => l[b]).values()).enter().append("g").each(y) : (m) => m.datum(t).each(y)).node();
  }
}
class zR extends Um {
  constructor(t, n) {
    super(t, n, LR), this.fill = "none";
  }
  _render(t, n) {
    return qS(t, n).render();
  }
}
function qS(e, t) {
  const { width: n, height: i, marginTop: r, marginRight: s, marginBottom: o, marginLeft: a } = t;
  return e.voronoi([a, r, n - s, i - o]);
}
function fc(e, t, { x: n, y: i, ...r } = {}) {
  return [n, i] = ai(n, i), new e(t, { ...r, x: n, y: i });
}
function PR(e, t) {
  return fc(CR, e, t);
}
function YR(e, t) {
  return fc(kR, e, t);
}
function qR(e, t) {
  return fc(RR, e, t);
}
function VR(e, t) {
  return fc(UR, e, t);
}
function jR(e, t) {
  return fc(zR, e, t);
}
const XR = {
  ariaLabel: "density",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class VS extends Yt {
  constructor(t, { x: n, y: i, z: r, weight: s, fill: o, stroke: a, ...c } = {}) {
    const u = G1(o) && (o = "currentColor", !0), l = G1(a) && (a = "currentColor", !0);
    super(t, {
      x: { value: n, scale: "x", optional: !0 },
      y: { value: i, scale: "y", optional: !0 },
      z: { value: gr({ z: r, fill: o, stroke: a }), optional: !0 },
      weight: { value: s, optional: !0 }
    }, GR({ ...c, fill: o, stroke: a }, u, l), XR), u && (this.fill = void 0), l && (this.stroke = void 0), this.z = r;
  }
  filter(t) {
    return t;
  }
  render(t, n, i, r, s) {
    const { contours: o } = i, a = rs();
    return aT("svg:g").call(Zt, this, r, s).call(Pt, this, {}).call((c) => c.selectAll().data(t).enter().append("path").call(Xt, this).call(ge, this, i).attr("d", (u) => a(o[u]))).node();
  }
}
function WR(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return [n, i] = ai(n, i), new VS(e, { ...r, x: n, y: i });
}
const HR = /* @__PURE__ */ new Set(["x", "y", "z", "weight"]);
function GR(e, t, n) {
  let { bandwidth: r, thresholds: s } = e;
  return r = r === void 0 ? 20 : +r, s = s === void 0 ? 20 : typeof (s == null ? void 0 : s[Symbol.iterator]) == "function" ? Ui(s) : +s, Fn(e, function(o, a, c, u, l, f) {
    var E;
    const h = c.weight ? Ui(c.weight.value) : null, d = (E = c.z) == null ? void 0 : E.value, { z: p } = this, [g, y] = _r(this, l), { width: m, height: b } = l, { x: w, y: _ } = Pf(c, u, f), x = Object.fromEntries(Object.entries(c).filter(([v]) => !HR.has(v)).map(([v, M]) => [v, { ...M, value: [] }])), S = t && [], I = n && [], N = FE().x(w ? (v) => w[v] : g).y(_ ? (v) => _[v] : y).weight(h ? (v) => h[v] : 1).size([m, b]).bandwidth(r), F = [];
    for (const v of a) {
      const M = [];
      F.push(M);
      for (const A of d ? dm(v, d, p) : [v]) {
        const O = N.contours(A);
        M.push([A, O]);
      }
    }
    let $ = s;
    if (!$3($)) {
      let v = 0;
      for (const M of F)
        for (const [, A] of M) {
          const O = A.max;
          O > v && (v = O);
        }
      $ = Float64Array.from({ length: s - 1 }, (M, A) => v * 100 * (A + 1) / s);
    }
    const T = [], D = [];
    for (const v of F) {
      const M = [];
      T.push(M);
      for (const [A, O] of v)
        for (const L of $) {
          M.push(D.length), D.push(O(L / 100)), S && S.push(L), I && I.push(L);
          for (const C in x)
            x[C].value.push(c[C].value[A[0]]);
        }
    }
    return S && S.push(0), I && I.push(0), {
      data: o,
      facets: T,
      channels: {
        ...x,
        ...S && { fill: { value: S, scale: "color" } },
        ...I && { stroke: { value: I, scale: "color" } },
        contours: { value: D }
      }
    };
  });
}
function G1(e) {
  return /^density$/i.test(e);
}
const ZR = {
  ariaLabel: "geo",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class jS extends Yt {
  constructor(t, n = {}) {
    const [i, r] = Se(n.r, 3);
    super(t, {
      geometry: { value: n.geometry },
      r: { value: i, scale: "r", filter: ur, optional: !0 }
    }, gS(n), ZR), this.r = r;
  }
  render(t, n, i, r, s) {
    const { geometry: o, r: a } = i, c = rs(s.projection ?? KR(n)), { r: u } = this;
    return Lf(u) ? t = [] : u !== void 0 && c.pointRadius(u), Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, n).call((l) => {
      l.selectAll().data(t).enter().append("path").call(Xt, this).attr("d", a ? (f) => c.pointRadius(a[f])(o[f]) : (f) => c(o[f])).call(ge, this, i);
    }).node();
  }
}
function KR({ x: e, y: t }) {
  if (e || t)
    return e ?? (e = (n) => n), t ?? (t = (n) => n), ml({
      point(n, i) {
        this.stream.point(e(n), t(i));
      }
    });
}
function zm(e, { geometry: t = lt, ...n } = {}) {
  switch (e == null ? void 0 : e.type) {
    case "FeatureCollection":
      e = e.features;
      break;
    case "GeometryCollection":
      e = e.geometries;
      break;
    case "Feature":
    case "LineString":
    case "MultiLineString":
    case "MultiPoint":
    case "MultiPolygon":
    case "Point":
    case "Polygon":
    case "Sphere":
      e = [e];
      break;
  }
  return new jS(e, { geometry: t, ...n });
}
function JR({ strokeWidth: e = 1.5, ...t } = {}) {
  return zm({ type: "Sphere" }, { strokeWidth: e, ...t });
}
function QR({ strokeOpacity: e = 0.1, ...t } = {}) {
  return zm(IN(), { strokeOpacity: e, ...t });
}
const da = 0.5, pa = 0;
function tU(e = { fill: "count" }, { binWidth: t, ...n } = {}) {
  t = t === void 0 ? 20 : vt(t), e = Jp(e, n);
  const { z: i, fill: r, stroke: s } = n;
  return s === void 0 && le(r) && Ki(e, "fill") && (n.stroke = "none"), n.symbol === void 0 && (n.symbol = "hexagon"), n.r === void 0 && !Ki(e, "r") && (n.r = t / 2), Fn(n, (o, a, c, u, l, f) => {
    let { x: h, y: d, z: p, fill: g, stroke: y, symbol: m } = c;
    if (h === void 0)
      throw new Error("missing channel: x");
    if (d === void 0)
      throw new Error("missing channel: y");
    ({ x: h, y: d } = Pf(c, u, f)), p = p ? p.value : dt(o, i), g = g == null ? void 0 : g.value, y = y == null ? void 0 : y.value, m = m == null ? void 0 : m.value;
    const b = em(e, { z: p, fill: g, stroke: y, symbol: m }), w = p && [], _ = g && [], x = y && [], S = m && [], I = [], N = [], F = [];
    let $ = -1;
    for (const D of e)
      D.initialize(o);
    for (const D of a) {
      const E = [];
      for (const v of e)
        v.scope("facet", D);
      for (const [v, M] of js(D, b))
        for (const A of eU(M, h, d, t)) {
          E.push(++$), N.push(A.x), F.push(A.y), p && w.push(b === p ? v : p[A[0]]), g && _.push(b === g ? v : g[A[0]]), y && x.push(b === y ? v : y[A[0]]), m && S.push(b === m ? v : m[A[0]]);
          for (const O of e)
            O.reduce(A);
        }
      I.push(E);
    }
    const T = {
      x: { value: N },
      y: { value: F },
      ...p && { z: { value: w } },
      ...g && { fill: { value: _, scale: !0 } },
      ...y && { stroke: { value: x, scale: !0 } },
      ...m && { symbol: { value: S, scale: !0 } },
      ...Object.fromEntries(e.map(({ name: D, output: E }) => [
        D,
        { scale: !0, radius: D === "r" ? t / 2 : void 0, value: E.transform() }
      ]))
    };
    return { data: o, facets: I, channels: T };
  });
}
function eU(e, t, n, i) {
  const r = i * (1.5 / V3), s = /* @__PURE__ */ new Map();
  for (const o of e) {
    let a = t[o], c = n[o];
    if (isNaN(a) || isNaN(c))
      continue;
    let u = Math.round(c = (c - pa) / r), l = Math.round(a = (a - da) / i - (u & 1) / 2), f = c - u;
    if (Math.abs(f) * 3 > 1) {
      let p = a - l, g = l + (a < l ? -1 : 1) / 2, y = u + (c < u ? -1 : 1), m = a - g, b = c - y;
      p * p + f * f > m * m + b * b && (l = g + (u & 1 ? 1 : -1) / 2, u = y);
    }
    const h = `${l},${u}`;
    let d = s.get(h);
    d === void 0 && (s.set(h, d = []), d.x = (l + (u & 1) / 2) * i + da, d.y = u * r + pa), d.push(o);
  }
  return s.values();
}
const nU = {
  ariaLabel: "hexgrid",
  fill: "none",
  stroke: "currentColor",
  strokeOpacity: 0.1
};
function iU(e) {
  return new XS(e);
}
class XS extends Yt {
  constructor({ binWidth: t = 20, clip: n = !0, ...i } = {}) {
    super(void 0, void 0, { clip: n, ...i }, nU), this.binWidth = vt(t);
  }
  render(t, n, i, r, s) {
    const { binWidth: o } = this, { marginTop: a, marginRight: c, marginBottom: u, marginLeft: l, width: f, height: h } = r, d = l - da, p = f - c - da, g = a - pa, y = h - u - pa, m = o / 2, b = m * j3, w = b / 2, _ = m * 2, x = b * 1.5, S = Math.floor(d / _), I = Math.ceil(p / _), N = Math.floor((g + w) / x), F = Math.ceil((y - w) / x) + 1, $ = `m0,${ji(-b)}l${ji(m)},${ji(w)}v${ji(b)}l${ji(-m)},${ji(w)}`;
    let T = $;
    for (let D = N; D < F; ++D)
      for (let E = S; E < I; ++E)
        T += `M${ji(E * _ + (D & 1) * m)},${ji(D * x)}${$}`;
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, {}, me + da, me + pa).call((D) => D.append("path").call(Xt, this).attr("d", T)).node();
  }
}
function ji(e) {
  return Math.round(e * 1e3) / 1e3;
}
const rU = {
  ariaLabel: "image",
  fill: null,
  stroke: null
};
function sU(e) {
  return /^\.*\//.test(e);
}
function oU(e) {
  return /^(blob|data|file|http|https):/i.test(e);
}
function aU(e) {
  return typeof e == "string" && (sU(e) || oU(e)) ? [void 0, e] : [e, void 0];
}
class WS extends Yt {
  constructor(t, n = {}) {
    let { x: i, y: r, width: s, height: o, src: a, preserveAspectRatio: c, crossOrigin: u, frameAnchor: l } = n;
    s === void 0 && o !== void 0 ? s = o : o === void 0 && s !== void 0 && (o = s);
    const [f, h] = aU(a), [d, p] = Se(s, 16), [g, y] = Se(o, 16);
    super(t, {
      x: { value: i, scale: "x", optional: !0 },
      y: { value: r, scale: "y", optional: !0 },
      width: { value: d, filter: ur, optional: !0 },
      height: { value: g, filter: ur, optional: !0 },
      src: { value: f, optional: !0 }
    }, n, rU), this.src = h, this.width = p, this.height = y, this.preserveAspectRatio = re(c, "xMidYMid"), this.crossOrigin = un(u), this.frameAnchor = Of(l);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: u, width: l, height: f, src: h } = i, [d, p] = _r(this, r);
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, { x: c && o, y: u && a }).call((g) => g.selectAll().data(t).enter().append("image").call(Xt, this).attr("x", l && c ? (y) => c[y] - l[y] / 2 : l ? (y) => d - l[y] / 2 : c ? (y) => c[y] - this.width / 2 : d - this.width / 2).attr("y", f && u ? (y) => u[y] - f[y] / 2 : f ? (y) => p - f[y] / 2 : u ? (y) => u[y] - this.height / 2 : p - this.height / 2).attr("width", l ? (y) => l[y] : this.width).attr("height", f ? (y) => f[y] : this.height).call(K, "href", h ? (y) => h[y] : this.src).call(K, "preserveAspectRatio", this.preserveAspectRatio).call(K, "crossorigin", this.crossOrigin).call(ge, this, i)).node();
  }
}
function cU(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return t.frameAnchor === void 0 && ([n, i] = ai(n, i)), new WS(e, { ...r, x: n, y: i });
}
function uU(e, t, n) {
  var i = 1e-8, r = t - 1, s = n - 1, o = 0, a, c, u, l, f, h, d, p, g, y, m;
  if (e <= 0)
    return 0;
  if (e >= 1)
    return 1;
  for (t >= 1 && n >= 1 ? (u = e < 0.5 ? e : 1 - e, l = Math.sqrt(-2 * Math.log(u)), d = (2.30753 + l * 0.27061) / (1 + l * (0.99229 + l * 0.04481)) - l, e < 0.5 && (d = -d), p = (d * d - 3) / 6, g = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), y = d * Math.sqrt(p + g) / g - (1 / (2 * n - 1) - 1 / (2 * t - 1)) * (p + 5 / 6 - 2 / (3 * g)), d = t / (t + n * Math.exp(2 * y))) : (a = Math.log(t / (t + n)), c = Math.log(n / (t + n)), l = Math.exp(t * a) / t, f = Math.exp(n * c) / n, y = l + f, e < l / y ? d = Math.pow(t * y * e, 1 / t) : d = 1 - Math.pow(n * y * (1 - e), 1 / n)), m = -Xs(t) - Xs(n) + Xs(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = lU(d, t, n) - e, l = Math.exp(r * Math.log(d) + s * Math.log(1 - d) + m), f = h / l, d -= l = f / (1 - 0.5 * Math.min(1, f * (r / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + l)), d >= 1 && (d = 0.5 * (d + l + 1)), Math.abs(l) < i * d && o > 0)
      break;
  }
  return d;
}
function lU(e, t, n) {
  var i = e === 0 || e === 1 ? 0 : Math.exp(Xs(t + n) - Xs(t) - Xs(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? i * Z1(e, t, n) / t : 1 - i * Z1(1 - e, n, t) / n;
}
function Z1(e, t, n) {
  var i = 1e-30, r = 1, s = t + n, o = t + 1, a = t - 1, c = 1, u = 1 - s * e / o, l, f, h, d;
  for (Math.abs(u) < i && (u = i), u = 1 / u, d = u; r <= 100 && (l = 2 * r, f = r * (n - r) * e / ((a + l) * (t + l)), u = 1 + f * u, Math.abs(u) < i && (u = i), c = 1 + f / c, Math.abs(c) < i && (c = i), u = 1 / u, d *= u * c, f = -(t + r) * (s + r) * e / ((t + l) * (o + l)), u = 1 + f * u, Math.abs(u) < i && (u = i), c = 1 + f / c, Math.abs(c) < i && (c = i), u = 1 / u, h = u * c, d *= h, !(Math.abs(h - 1) < 3e-7)); r++)
    ;
  return d;
}
function Xs(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], i = 1.000000000190015, r, s, o;
  for (o = (s = r = e) + 5.5, o -= (r + 0.5) * Math.log(o); t < 6; t++)
    i += n[t] / ++s;
  return Math.log(2.506628274631 * i / r) - o;
}
function fU(e, t) {
  var n = uU(2 * Math.min(e, 1 - e), 0.5 * t, 0.5);
  return n = Math.sqrt(t * (1 - n) / n), e > 0.5 ? n : -n;
}
const hU = {
  ariaLabel: "linear-regression",
  fill: "currentColor",
  fillOpacity: 0.1,
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class HS extends Yt {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s, ci: o = 0.95, precision: a = 4 } = n;
    if (super(t, {
      x: { value: i, scale: "x" },
      y: { value: r, scale: "y" },
      z: { value: gr(n), optional: !0 }
    }, n, hU), this.z = s, this.ci = +o, this.precision = +a, !(0 <= this.ci && this.ci < 1))
      throw new Error(`invalid ci; not in [0, 1): ${o}`);
    if (!(this.precision > 0))
      throw new Error(`invalid precision: ${a}`);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a, z: c } = i, { ci: u } = this;
    return Nt("svg:g", s).call(Zt, this, r, s).call(Pt, this, n).call((l) => l.selectAll().data(c ? dm(t, c, this.z) : [t]).enter().call((f) => f.append("path").attr("fill", "none").call(Xt, this).call(Dl, this, { ...i, fill: null, fillOpacity: null }).attr("d", (h) => this._renderLine(h, o, a)).call(u && !bo(this.fill) ? (h) => h.select(dU).attr("stroke", "none").call(Xt, this).call(Dl, this, {
      ...i,
      stroke: null,
      strokeOpacity: null,
      strokeWidth: null
    }).attr("d", (d) => this._renderBand(d, o, a)) : () => {
    }))).node();
  }
}
function dU() {
  return this.parentNode.insertBefore(this.ownerDocument.createElementNS(ao.svg, "path"), this);
}
class pU extends HS {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, i) {
    const { ci: r, precision: s } = this, [o, a] = Ne(t, (l) => i[l]), c = Ul(t, i, n), u = GS(t, i, n, (1 - r) / 2, c);
    return Up().y((l) => l).x0((l) => u(l, -1)).x1((l) => u(l, 1))(sn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, i) {
    const [r, s] = Ne(t, (a) => i[a]), o = Ul(t, i, n);
    return `M${o(r)},${r}L${o(s)},${s}`;
  }
}
class mU extends HS {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, i) {
    const { ci: r, precision: s } = this, [o, a] = Ne(t, (l) => n[l]), c = Ul(t, n, i), u = GS(t, n, i, (1 - r) / 2, c);
    return Up().x((l) => l).y0((l) => u(l, -1)).y1((l) => u(l, 1))(sn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, i) {
    const [r, s] = Ne(t, (a) => n[a]), o = Ul(t, n, i);
    return `M${r},${o(r)}L${s},${o(s)}`;
  }
}
function yU(e, t = {}) {
  const { y: n = Ze, x: i = lt, stroke: r, fill: s = le(r) ? "currentColor" : r, ...o } = t;
  return new pU(e, Am({ ...o, x: i, y: n, fill: s, stroke: r }));
}
function gU(e, t = {}) {
  const { x: n = Ze, y: i = lt, stroke: r, fill: s = le(r) ? "currentColor" : r, ...o } = t;
  return new mU(e, Mm({ ...o, x: n, y: i, fill: s, stroke: r }));
}
function Ul(e, t, n) {
  let i = 0, r = 0, s = 0, o = 0;
  for (const l of e) {
    const f = t[l], h = n[l];
    i += f, r += h, s += f * h, o += f * f;
  }
  const a = e.length, c = (a * s - i * r) / (a * o - i * i), u = (r - c * i) / a;
  return (l) => c * l + u;
}
function GS(e, t, n, i, r) {
  const s = ti(e, (l) => t[l]) / e.length;
  let o = 0, a = 0;
  for (const l of e)
    o += (t[l] - s) ** 2, a += (n[l] - r(t[l])) ** 2;
  const c = Math.sqrt(a / (e.length - 2)), u = fU(i, e.length - 2);
  return (l, f) => {
    const h = r(l), d = c * Math.sqrt(1 / e.length + (l - s) ** 2 / o);
    return h + f * u * d;
  };
}
function T0(e = {}) {
  let {
    path: t = lt,
    // the delimited path
    delimiter: n,
    // how the path is separated
    frameAnchor: i,
    treeLayout: r = G_,
    treeSort: s,
    treeSeparation: o,
    treeAnchor: a,
    ...c
  } = e;
  a = Pm(a), s = KS(s), i === void 0 && (i = a.frameAnchor);
  const u = JS(n), l = r4(c, t4), [f, h] = Ve(), [d, p] = Ve();
  return {
    x: f,
    y: d,
    frameAnchor: i,
    ...ci(c, (g, y) => {
      const m = u(dt(g, t)), b = h([]), w = p([]);
      let _ = -1;
      const x = [], S = [], I = H_().path((F) => m[F]), N = r();
      N.nodeSize && N.nodeSize([1, 1]), N.separation && o !== void 0 && N.separation(o ?? jp);
      for (const F of l)
        F[zl] = F[n4]([]);
      for (const F of y) {
        const $ = [], T = I(F.filter((D) => m[D] != null)).each((D) => D.data = g[D.data]);
        s != null && T.sort(s), N(T);
        for (const D of T.descendants()) {
          $.push(++_), x[_] = D.data, a.position(D, _, b, w);
          for (const E of l)
            E[zl][_] = E[i4](D);
        }
        S.push($);
      }
      return { data: x, facets: S };
    }),
    ...Object.fromEntries(l)
  };
}
function ZS(e = {}) {
  let {
    path: t = lt,
    // the delimited path
    delimiter: n,
    // how the path is separated
    curve: i = "bump-x",
    stroke: r = "#555",
    strokeWidth: s = 1.5,
    strokeOpacity: o = 0.5,
    treeLayout: a = G_,
    treeSort: c,
    treeSeparation: u,
    treeAnchor: l,
    ...f
  } = e;
  l = Pm(l), c = KS(c), f = { curve: i, stroke: r, strokeWidth: s, strokeOpacity: o, ...f };
  const h = JS(n), d = r4(f, MU), [p, g] = Ve(), [y, m] = Ve(), [b, w] = Ve(), [_, x] = Ve();
  return {
    x1: p,
    x2: y,
    y1: b,
    y2: _,
    ...ci(f, (S, I) => {
      const N = h(dt(S, t)), F = g([]), $ = m([]), T = w([]), D = x([]);
      let E = -1;
      const v = [], M = [], A = H_().path((L) => N[L]), O = a();
      O.nodeSize && O.nodeSize([1, 1]), O.separation && u !== void 0 && O.separation(u ?? jp);
      for (const L of d)
        L[zl] = L[n4]([]);
      for (const L of I) {
        const C = [], k = A(L.filter((R) => N[R] != null)).each((R) => R.data = S[R.data]);
        c != null && k.sort(c), O(k);
        for (const { source: R, target: z } of k.links()) {
          C.push(++E), v[E] = z.data, l.position(R, E, F, T), l.position(z, E, $, D);
          for (const G of d)
            G[zl][E] = G[i4](z, R);
        }
        M.push(C);
      }
      return { data: v, facets: M };
    }),
    ...Object.fromEntries(d)
  };
}
function Pm(e = "left") {
  switch (`${e}`.trim().toLowerCase()) {
    case "left":
      return bU;
    case "right":
      return wU;
  }
  throw new Error(`invalid tree anchor: ${e}`);
}
const bU = {
  frameAnchor: "left",
  dx: 6,
  position({ x: e, y: t }, n, i, r) {
    i[n] = t, r[n] = -e;
  }
}, wU = {
  frameAnchor: "right",
  dx: -6,
  position({ x: e, y: t }, n, i, r) {
    i[n] = -t, r[n] = -e;
  }
};
function KS(e) {
  return e == null || typeof e == "function" ? e : `${e}`.trim().toLowerCase().startsWith("node:") ? K1(t4(e)) : K1(_U(e));
}
function K1(e) {
  return (t, n) => wo(e(t), e(n));
}
function _U(e) {
  return (t) => {
    var n;
    return (n = t.data) == null ? void 0 : n[e];
  };
}
function JS(e = "/") {
  return `${e}` == "/" ? (t) => t : (t) => t.map(vU(e, "/"));
}
function vU(e, t) {
  return e = new RegExp(xU(e), "g"), (n) => n == null ? null : `${n}`.replace(e, t);
}
function xU(e) {
  return `${e}`.replace(/[\\^$*+?.()|[\]{}]/g, "\\$&");
}
function QS(e) {
  return Fo(e) && typeof e.node == "function";
}
function SU(e) {
  return Fo(e) && typeof e.link == "function";
}
function t4(e) {
  if (QS(e))
    return e.node;
  if (e = `${e}`.trim().toLowerCase(), !!e.startsWith("node:")) {
    switch (e) {
      case "node:name":
        return N0;
      case "node:path":
        return E0;
      case "node:internal":
        return e4;
      case "node:depth":
        return O0;
      case "node:height":
        return F0;
    }
    throw new Error(`invalid node value: ${e}`);
  }
}
function MU(e) {
  if (QS(e))
    return e.node;
  if (SU(e))
    return e.link;
  if (e = `${e}`.trim().toLowerCase(), !(!e.startsWith("node:") && !e.startsWith("parent:"))) {
    switch (e) {
      case "parent:name":
        return qc(N0);
      case "parent:path":
        return qc(E0);
      case "parent:depth":
        return qc(O0);
      case "parent:height":
        return qc(F0);
      case "node:name":
        return N0;
      case "node:path":
        return E0;
      case "node:internal":
        return e4;
      case "node:depth":
        return O0;
      case "node:height":
        return F0;
    }
    throw new Error(`invalid link value: ${e}`);
  }
}
function E0(e) {
  return e.id;
}
function N0(e) {
  return AU(e.id);
}
function O0(e) {
  return e.depth;
}
function F0(e) {
  return e.height;
}
function e4(e) {
  return !!e.children;
}
function qc(e) {
  return (t, n) => n == null ? void 0 : e(n);
}
function AU(e) {
  let t = e.length;
  for (; --t > 0 && !$U(e, t); )
    ;
  return e.slice(t + 1);
}
function $U(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
const n4 = 2, i4 = 3, zl = 4;
function r4(e, t) {
  const n = [];
  for (const i in e) {
    const r = e[i], s = t(r);
    s !== void 0 && n.push([i, ...Ve(r), s]);
  }
  return n;
}
function s4(e, t = {}) {
  let { fill: n, stroke: i, strokeWidth: r, strokeOpacity: s, strokeLinejoin: o, strokeLinecap: a, strokeMiterlimit: c, strokeDasharray: u, strokeDashoffset: l, marker: f, markerStart: h = f, markerEnd: d = f, dot: p = le(h) && le(d), text: g = "node:name", textStroke: y = "white", title: m = "node:path", dx: b, dy: w, ..._ } = t;
  return b === void 0 && (b = Pm(_.treeAnchor).dx), lr(mS(e, ZS({
    markerStart: h,
    markerEnd: d,
    stroke: i !== void 0 ? i : n === void 0 ? "node:internal" : n,
    strokeWidth: r,
    strokeOpacity: s,
    strokeLinejoin: o,
    strokeLinecap: a,
    strokeMiterlimit: c,
    strokeDasharray: u,
    strokeDashoffset: l,
    ..._
  })), p ? cs(e, T0({ fill: n === void 0 ? "node:internal" : n, title: m, ..._ })) : null, g != null ? Xf(e, T0({
    text: g,
    fill: n === void 0 ? "currentColor" : n,
    stroke: y,
    dx: b,
    dy: w,
    title: m,
    ..._
  })) : null);
}
function IU(e, t) {
  return s4(e, { ...t, treeLayout: gO });
}
function TU({ geometry: e = lt, ...t } = {}) {
  return Fn({ ...t, x: null, y: null }, (n, i, r, s, o, { projection: a }) => {
    const c = dt(n, e), u = c.length, l = new Float64Array(u), f = new Float64Array(u), h = rs(a);
    for (let d = 0; d < u; ++d)
      [l[d], f[d]] = h.centroid(c[d]);
    return { data: n, facets: i, channels: { x: { value: l }, y: { value: f } } };
  });
}
function EU({ geometry: e = lt, ...t } = {}) {
  let n;
  return {
    ...t,
    x: { transform: (i) => Float64Array.from(n = dt(dt(i, e), mN), ([r]) => r) },
    y: { transform: () => Float64Array.from(n, ([, i]) => i) }
  };
}
function NU(e, t, n, i, r) {
  for (var s = r + 1; i <= r; ) {
    var o = i + r >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c >= 0 ? (s = o, r = o - 1) : i = o + 1;
  }
  return s;
}
function OU(e, t, n, i, r) {
  for (var s = r + 1; i <= r; ) {
    var o = i + r >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c > 0 ? (s = o, r = o - 1) : i = o + 1;
  }
  return s;
}
function FU(e, t, n, i, r) {
  for (var s = i - 1; i <= r; ) {
    var o = i + r >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c < 0 ? (s = o, i = o + 1) : r = o - 1;
  }
  return s;
}
function DU(e, t, n, i, r) {
  for (var s = i - 1; i <= r; ) {
    var o = i + r >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c <= 0 ? (s = o, i = o + 1) : r = o - 1;
  }
  return s;
}
function BU(e, t, n, i, r) {
  for (; i <= r; ) {
    var s = i + r >>> 1, o = e[s], a = n !== void 0 ? n(o, t) : o - t;
    if (a === 0)
      return s;
    a <= 0 ? i = s + 1 : r = s - 1;
  }
  return -1;
}
function Zo(e, t, n, i, r, s) {
  return typeof n == "function" ? s(e, t, n, i === void 0 ? 0 : i | 0, r === void 0 ? e.length - 1 : r | 0) : s(e, t, void 0, n === void 0 ? 0 : n | 0, i === void 0 ? e.length - 1 : i | 0);
}
var LU = {
  ge: function(e, t, n, i, r) {
    return Zo(e, t, n, i, r, NU);
  },
  gt: function(e, t, n, i, r) {
    return Zo(e, t, n, i, r, OU);
  },
  lt: function(e, t, n, i, r) {
    return Zo(e, t, n, i, r, FU);
  },
  le: function(e, t, n, i, r) {
    return Zo(e, t, n, i, r, DU);
  },
  eq: function(e, t, n, i, r) {
    return Zo(e, t, n, i, r, BU);
  }
}, Pl = LU, Ls = 0, Or = 1, uu = 2, CU = RU;
function Ym(e, t, n, i, r) {
  this.mid = e, this.left = t, this.right = n, this.leftPoints = i, this.rightPoints = r, this.count = (t ? t.count : 0) + (n ? n.count : 0) + i.length;
}
var hc = Ym.prototype;
function od(e, t) {
  e.mid = t.mid, e.left = t.left, e.right = t.right, e.leftPoints = t.leftPoints, e.rightPoints = t.rightPoints, e.count = t.count;
}
function o4(e, t) {
  var n = _o(t);
  e.mid = n.mid, e.left = n.left, e.right = n.right, e.leftPoints = n.leftPoints, e.rightPoints = n.rightPoints, e.count = n.count;
}
function J1(e, t) {
  var n = e.intervals([]);
  n.push(t), o4(e, n);
}
function Q1(e, t) {
  var n = e.intervals([]), i = n.indexOf(t);
  return i < 0 ? Ls : (n.splice(i, 1), o4(e, n), Or);
}
hc.intervals = function(e) {
  return e.push.apply(e, this.leftPoints), this.left && this.left.intervals(e), this.right && this.right.intervals(e), e;
};
hc.insert = function(e) {
  var t = this.count - this.leftPoints.length;
  if (this.count += 1, e[1] < this.mid)
    this.left ? 4 * (this.left.count + 1) > 3 * (t + 1) ? J1(this, e) : this.left.insert(e) : this.left = _o([e]);
  else if (e[0] > this.mid)
    this.right ? 4 * (this.right.count + 1) > 3 * (t + 1) ? J1(this, e) : this.right.insert(e) : this.right = _o([e]);
  else {
    var n = Pl.ge(this.leftPoints, e, qm), i = Pl.ge(this.rightPoints, e, Vm);
    this.leftPoints.splice(n, 0, e), this.rightPoints.splice(i, 0, e);
  }
};
hc.remove = function(e) {
  var t = this.count - this.leftPoints;
  if (e[1] < this.mid) {
    if (!this.left)
      return Ls;
    var n = this.right ? this.right.count : 0;
    if (4 * n > 3 * (t - 1))
      return Q1(this, e);
    var i = this.left.remove(e);
    return i === uu ? (this.left = null, this.count -= 1, Or) : (i === Or && (this.count -= 1), i);
  } else if (e[0] > this.mid) {
    if (!this.right)
      return Ls;
    var r = this.left ? this.left.count : 0;
    if (4 * r > 3 * (t - 1))
      return Q1(this, e);
    var i = this.right.remove(e);
    return i === uu ? (this.right = null, this.count -= 1, Or) : (i === Or && (this.count -= 1), i);
  } else {
    if (this.count === 1)
      return this.leftPoints[0] === e ? uu : Ls;
    if (this.leftPoints.length === 1 && this.leftPoints[0] === e) {
      if (this.left && this.right) {
        for (var s = this, o = this.left; o.right; )
          s = o, o = o.right;
        if (s === this)
          o.right = this.right;
        else {
          var a = this.left, i = this.right;
          s.count -= o.count, s.right = o.left, o.left = a, o.right = i;
        }
        od(this, o), this.count = (this.left ? this.left.count : 0) + (this.right ? this.right.count : 0) + this.leftPoints.length;
      } else
        this.left ? od(this, this.left) : od(this, this.right);
      return Or;
    }
    for (var a = Pl.ge(this.leftPoints, e, qm); a < this.leftPoints.length && this.leftPoints[a][0] === e[0]; ++a)
      if (this.leftPoints[a] === e) {
        this.count -= 1, this.leftPoints.splice(a, 1);
        for (var i = Pl.ge(this.rightPoints, e, Vm); i < this.rightPoints.length && this.rightPoints[i][1] === e[1]; ++i)
          if (this.rightPoints[i] === e)
            return this.rightPoints.splice(i, 1), Or;
      }
    return Ls;
  }
};
function a4(e, t, n) {
  for (var i = 0; i < e.length && e[i][0] <= t; ++i) {
    var r = n(e[i]);
    if (r)
      return r;
  }
}
function c4(e, t, n) {
  for (var i = e.length - 1; i >= 0 && e[i][1] >= t; --i) {
    var r = n(e[i]);
    if (r)
      return r;
  }
}
function u4(e, t) {
  for (var n = 0; n < e.length; ++n) {
    var i = t(e[n]);
    if (i)
      return i;
  }
}
hc.queryPoint = function(e, t) {
  if (e < this.mid) {
    if (this.left) {
      var n = this.left.queryPoint(e, t);
      if (n)
        return n;
    }
    return a4(this.leftPoints, e, t);
  } else if (e > this.mid) {
    if (this.right) {
      var n = this.right.queryPoint(e, t);
      if (n)
        return n;
    }
    return c4(this.rightPoints, e, t);
  } else
    return u4(this.leftPoints, t);
};
hc.queryInterval = function(e, t, n) {
  if (e < this.mid && this.left) {
    var i = this.left.queryInterval(e, t, n);
    if (i)
      return i;
  }
  if (t > this.mid && this.right) {
    var i = this.right.queryInterval(e, t, n);
    if (i)
      return i;
  }
  return t < this.mid ? a4(this.leftPoints, t, n) : e > this.mid ? c4(this.rightPoints, e, n) : u4(this.leftPoints, n);
};
function kU(e, t) {
  return e - t;
}
function qm(e, t) {
  var n = e[0] - t[0];
  return n || e[1] - t[1];
}
function Vm(e, t) {
  var n = e[1] - t[1];
  return n || e[0] - t[0];
}
function _o(e) {
  if (e.length === 0)
    return null;
  for (var t = [], n = 0; n < e.length; ++n)
    t.push(e[n][0], e[n][1]);
  t.sort(kU);
  for (var i = t[t.length >> 1], r = [], s = [], o = [], n = 0; n < e.length; ++n) {
    var a = e[n];
    a[1] < i ? r.push(a) : i < a[0] ? s.push(a) : o.push(a);
  }
  var c = o, u = o.slice();
  return c.sort(qm), u.sort(Vm), new Ym(
    i,
    _o(r),
    _o(s),
    c,
    u
  );
}
function D0(e) {
  this.root = e;
}
var Co = D0.prototype;
Co.insert = function(e) {
  this.root ? this.root.insert(e) : this.root = new Ym(e[0], null, null, [e], [e]);
};
Co.remove = function(e) {
  if (this.root) {
    var t = this.root.remove(e);
    return t === uu && (this.root = null), t !== Ls;
  }
  return !1;
};
Co.queryPoint = function(e, t) {
  if (this.root)
    return this.root.queryPoint(e, t);
};
Co.queryInterval = function(e, t, n) {
  if (e <= t && this.root)
    return this.root.queryInterval(e, t, n);
};
Object.defineProperty(Co, "count", {
  get: function() {
    return this.root ? this.root.count : 0;
  }
});
Object.defineProperty(Co, "intervals", {
  get: function() {
    return this.root ? this.root.intervals([]) : [];
  }
});
function RU(e) {
  return !e || e.length === 0 ? new D0(null) : new D0(_o(e));
}
const UU = ({ marginLeft: e }) => [1, e], zU = ({ width: e, marginRight: t }) => [-1, e - t], PU = ({ width: e, marginLeft: t, marginRight: n }) => [0, (t + e - n) / 2], YU = ({ marginTop: e }) => [1, e], qU = ({ height: e, marginBottom: t }) => [-1, e - t], VU = ({ height: e, marginTop: t, marginBottom: n }) => [0, (t + e - n) / 2];
function l4(e) {
  return typeof e == "string" ? { anchor: e } : e;
}
function jU(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = f4(e));
  let { anchor: n = "left", padding: i = 1 } = l4(e);
  switch (`${n}`.toLowerCase()) {
    case "left":
      n = UU;
      break;
    case "right":
      n = zU;
      break;
    case "middle":
      n = PU;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return h4("x", "y", n, vt(i), t);
}
function XU(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = f4(e));
  let { anchor: n = "bottom", padding: i = 1 } = l4(e);
  switch (`${n}`.toLowerCase()) {
    case "top":
      n = YU;
      break;
    case "bottom":
      n = qU;
      break;
    case "middle":
      n = VU;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return h4("y", "x", n, vt(i), t);
}
function f4(e) {
  const { anchor: t, padding: n, ...i } = e;
  return [{ anchor: t, padding: n }, i];
}
function h4(e, t, n, i, r) {
  const { r: s } = r;
  if (s != null && typeof s != "number") {
    const { channels: o, sort: a, reverse: c } = r;
    r = { ...r, channels: { r: { value: s, scale: "r" }, ...b0(o) } }, a === void 0 && c === void 0 && (r.sort = { channel: "r", order: "descending" });
  }
  return Fn(r, function(o, a, c, u, l, f) {
    let { [t]: h, r: d } = c;
    if (!c[t])
      throw new Error(`missing channel: ${t}`);
    ({ [t]: h } = Pf(c, u, f));
    const p = d ? void 0 : this.r !== void 0 ? this.r : r.r !== void 0 ? vt(r.r) : 3;
    d && (d = Ui(dt(d.value, u[d.scale] || lt)));
    let [g, y] = n(l);
    const m = g ? HU : WU, b = new Float64Array(h.length), w = d ? (_) => d[_] : () => p;
    for (let _ of a) {
      const x = CU();
      _ = _.filter(d ? (I) => Tl(h[I]) && ur(d[I]) : (I) => Tl(h[I]));
      const S = new Float64Array(2 * _.length + 2);
      for (const I of _) {
        const N = w(I), F = g ? N + i : 0, $ = h[I] - N, T = h[I] + N;
        let D = 2;
        x.queryInterval($ - i, T + i, ([, , v]) => {
          const M = b[v] - F, A = h[I] - h[v], O = i + (d ? d[I] + d[v] : 2 * p), L = Math.sqrt(O * O - A * A);
          S[D++] = M - L, S[D++] = M + L;
        });
        let E = S.slice(0, D);
        g && (E = E.filter((v) => v >= 0));
        t:
          for (const v of E.sort(m)) {
            for (let M = 0; M < D; M += 2)
              if (S[M] + 1e-6 < v && v < S[M + 1] - 1e-6)
                continue t;
            b[I] = v + F;
            break;
          }
        x.insert([$, T, I]);
      }
    }
    g || (g = 1);
    for (const _ of a)
      for (const x of _)
        b[x] = b[x] * g + y;
    return {
      data: o,
      facets: a,
      channels: {
        [t]: { value: h },
        [e]: { value: b },
        ...d && { r: { value: d } }
      }
    };
  });
}
function WU(e, t) {
  return Math.abs(e) - Math.abs(t);
}
function HU(e, t) {
  return e - t;
}
function GU(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), Lm(jm(e), t);
}
function ZU(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), Cm(jm(e), t);
}
function jm(e) {
  if (e === void 0)
    return tb;
  if (typeof e == "function")
    return ih((t, n) => e(Ji(n, t)));
  if (/^p\d{2}$/i.test(e))
    return ko(Xp(e));
  switch (`${e}`.toLowerCase()) {
    case "deviation":
      return QU;
    case "first":
      return tb;
    case "last":
      return JU;
    case "max":
      return tz;
    case "mean":
      return ez;
    case "median":
      return nz;
    case "min":
      return iz;
    case "sum":
      return rz;
    case "extent":
      return KU;
  }
  throw new Error(`invalid basis: ${e}`);
}
function ih(e) {
  return {
    map(t, n, i) {
      const r = +e(t, n);
      for (const s of t)
        i[s] = n[s] === null ? NaN : n[s] / r;
    }
  };
}
function ko(e) {
  return ih((t, n) => e(t, (i) => n[i]));
}
const KU = {
  map(e, t, n) {
    const [i, r] = Ne(e, (o) => t[o]), s = r - i;
    for (const o of e)
      n[o] = t[o] === null ? NaN : (t[o] - i) / s;
  }
}, tb = ih((e, t) => {
  for (let n = 0; n < e.length; ++n) {
    const i = t[e[n]];
    if (je(i))
      return i;
  }
}), JU = ih((e, t) => {
  for (let n = e.length - 1; n >= 0; --n) {
    const i = t[e[n]];
    if (je(i))
      return i;
  }
}), QU = {
  map(e, t, n) {
    const i = pp(e, (s) => t[s]), r = tf(e, (s) => t[s]);
    for (const s of e)
      n[s] = t[s] === null ? NaN : r ? (t[s] - i) / r : 0;
  }
}, tz = ko(Gt), ez = ko(pp), nz = ko(Ma), iz = ko(he), rz = ko(ti);
function sz(e = {}, t) {
  return arguments.length === 1 && (t = e), Lm(Xm(e), t);
}
function oz(e = {}, t) {
  return arguments.length === 1 && (t = e), Cm(Xm(e), t);
}
function Xm(e = {}) {
  typeof e == "number" && (e = { k: e });
  let { k: t, reduce: n, shift: i, anchor: r, strict: s } = e;
  if (r === void 0 && i !== void 0 && (r = cz(i), Wr(`Warning: the shift option is deprecated; please use anchor "${r}" instead.`)), !((t = Math.floor(t)) > 0))
    throw new Error(`invalid k: ${t}`);
  return uz(n)(t, az(r, t), s);
}
function az(e = "middle", t) {
  switch (`${e}`.toLowerCase()) {
    case "middle":
      return t - 1 >> 1;
    case "start":
      return 0;
    case "end":
      return t - 1;
  }
  throw new Error(`invalid anchor: ${e}`);
}
function cz(e) {
  switch (`${e}`.toLowerCase()) {
    case "centered":
      return "middle";
    case "leading":
      return "start";
    case "trailing":
      return "end";
  }
  throw new Error(`invalid shift: ${e}`);
}
function uz(e = "mean") {
  if (typeof e == "string") {
    if (/^p\d{2}$/i.test(e))
      return Vc(Xp(e));
    switch (e.toLowerCase()) {
      case "deviation":
        return Vc(tf);
      case "max":
        return jc(Gt);
      case "mean":
        return lz;
      case "median":
        return Vc(Ma);
      case "min":
        return jc(he);
      case "mode":
        return jc(xw);
      case "sum":
        return d4;
      case "variance":
        return Vc(cp);
      case "difference":
        return dz;
      case "ratio":
        return pz;
      case "first":
        return mz;
      case "last":
        return yz;
    }
  }
  if (typeof e != "function")
    throw new Error(`invalid reduce: ${e}`);
  return jc(e);
}
function ad(e, t, n) {
  return e.subarray ? e.subarray(t, n) : e.slice(t, n);
}
function Vc(e) {
  return (t, n, i) => i ? {
    map(r, s, o) {
      const a = Float64Array.from(r, (u) => s[u] === null ? NaN : s[u]);
      let c = 0;
      for (let u = 0; u < t - 1; ++u)
        isNaN(a[u]) && ++c;
      for (let u = 0, l = r.length - t + 1; u < l; ++u)
        isNaN(a[u + t - 1]) && ++c, o[r[u + n]] = c === 0 ? e(a.subarray(u, u + t)) : NaN, isNaN(a[u]) && --c;
    }
  } : {
    map(r, s, o) {
      const a = Float64Array.from(r, (c) => s[c] === null ? NaN : s[c]);
      for (let c = -n; c < 0; ++c)
        o[r[c + n]] = e(a.subarray(0, c + t));
      for (let c = 0, u = r.length - n; c < u; ++c)
        o[r[c + n]] = e(a.subarray(c, c + t));
    }
  };
}
function jc(e) {
  return (t, n, i) => i ? {
    map(r, s, o) {
      let a = 0;
      for (let c = 0; c < t - 1; ++c)
        a += je(s[r[c]]);
      for (let c = 0, u = r.length - t + 1; c < u; ++c)
        a += je(s[r[c + t - 1]]), a === t && (o[r[c + n]] = e(Ji(s, ad(r, c, c + t)))), a -= je(s[r[c]]);
    }
  } : {
    map(r, s, o) {
      for (let a = -n; a < 0; ++a)
        o[r[a + n]] = e(Ji(s, ad(r, 0, a + t)));
      for (let a = 0, c = r.length - n; a < c; ++a)
        o[r[a + n]] = e(Ji(s, ad(r, a, a + t)));
    }
  };
}
function d4(e, t, n) {
  return n ? {
    map(i, r, s) {
      let o = 0, a = 0;
      for (let c = 0; c < e - 1; ++c) {
        const u = r[i[c]];
        u === null || isNaN(u) ? ++o : a += +u;
      }
      for (let c = 0, u = i.length - e + 1; c < u; ++c) {
        const l = r[i[c]], f = r[i[c + e - 1]];
        f === null || isNaN(f) ? ++o : a += +f, s[i[c + t]] = o === 0 ? a : NaN, l === null || isNaN(l) ? --o : a -= +l;
      }
    }
  } : {
    map(i, r, s) {
      let o = 0;
      const a = i.length;
      for (let c = 0, u = Math.min(a, e - t - 1); c < u; ++c)
        o += +r[i[c]] || 0;
      for (let c = -t, u = a - t; c < u; ++c)
        o += +r[i[c + e - 1]] || 0, s[i[c + t]] = o, o -= +r[i[c]] || 0;
    }
  };
}
function lz(e, t, n) {
  if (n) {
    const i = d4(e, t, n);
    return {
      map(r, s, o) {
        i.map(r, s, o);
        for (let a = 0, c = r.length - e + 1; a < c; ++a)
          o[r[a + t]] /= e;
      }
    };
  } else
    return {
      map(i, r, s) {
        let o = 0, a = 0;
        const c = i.length;
        for (let u = 0, l = Math.min(c, e - t - 1); u < l; ++u) {
          let f = r[i[u]];
          f !== null && !isNaN(f = +f) && (o += f, ++a);
        }
        for (let u = -t, l = c - t; u < l; ++u) {
          let f = r[i[u + e - 1]], h = r[i[u]];
          f !== null && !isNaN(f = +f) && (o += f, ++a), s[i[u + t]] = o / a, h !== null && !isNaN(h = +h) && (o -= h, --a);
        }
      }
    };
}
function fz(e, t, n, i) {
  for (let r = n + i; n < r; ++n) {
    const s = e[t[n]];
    if (je(s))
      return s;
  }
}
function hz(e, t, n, i) {
  for (let r = n + i - 1; r >= n; --r) {
    const s = e[t[r]];
    if (je(s))
      return s;
  }
}
function p4(e, t, n, i) {
  for (let r = n + i; n < r; ++n) {
    let s = e[t[n]];
    if (s !== null && !isNaN(s = +s))
      return s;
  }
}
function m4(e, t, n, i) {
  for (let r = n + i - 1; r >= n; --r) {
    let s = e[t[r]];
    if (s !== null && !isNaN(s = +s))
      return s;
  }
}
function dz(e, t, n) {
  return n ? {
    map(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o) {
        const c = r[i[o]], u = r[i[o + e - 1]];
        s[i[o + t]] = c === null || u === null ? NaN : u - c;
      }
    }
  } : {
    map(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = m4(r, i, o, e) - p4(r, i, o, e);
    }
  };
}
function pz(e, t, n) {
  return n ? {
    map(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o) {
        const c = r[i[o]], u = r[i[o + e - 1]];
        s[i[o + t]] = c === null || u === null ? NaN : u / c;
      }
    }
  } : {
    map(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = m4(r, i, o, e) / p4(r, i, o, e);
    }
  };
}
function mz(e, t, n) {
  return n ? {
    map(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o)
        s[i[o + t]] = r[i[o]];
    }
  } : {
    map(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = fz(r, i, o, e);
    }
  };
}
function yz(e, t, n) {
  return n ? {
    map(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o)
        s[i[o + t]] = r[i[o + e - 1]];
    }
  } : {
    map(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = hz(r, i, o, e);
    }
  };
}
function gz(e, t = {}) {
  if (typeof e == "string")
    switch (e.toLowerCase()) {
      case "first":
        return y4(t);
      case "last":
        return g4(t);
    }
  if (typeof e == "function")
    return fr(null, e, t);
  let n, i;
  for (n in e) {
    if (i !== void 0)
      throw new Error("ambiguous selector; multiple inputs");
    i = bz(e[n]);
  }
  if (i === void 0)
    throw new Error(`invalid selector: ${e}`);
  return fr(n, i, t);
}
function bz(e) {
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "min":
      return Wm;
    case "max":
      return Hm;
  }
  throw new Error(`unknown selector: ${e}`);
}
function y4(e) {
  return fr(null, Sz, e);
}
function g4(e) {
  return fr(null, Mz, e);
}
function wz(e) {
  return fr("x", Wm, e);
}
function _z(e) {
  return fr("y", Wm, e);
}
function vz(e) {
  return fr("x", Hm, e);
}
function xz(e) {
  return fr("y", Hm, e);
}
function* Sz(e) {
  yield e[0];
}
function* Mz(e) {
  yield e[e.length - 1];
}
function* Wm(e, t) {
  yield g7(e, (n) => t[n]);
}
function* Hm(e, t) {
  yield dp(e, (n) => t[n]);
}
function fr(e, t, n) {
  if (e != null) {
    if (n[e] == null)
      throw new Error(`missing channel: ${e}`);
    e = n[e];
  }
  const i = gr(n);
  return ci(n, (r, s) => {
    const o = dt(r, i), a = dt(r, e), c = [];
    for (const u of s) {
      const l = [];
      for (const f of o ? Yi(u, (h) => o[h]).values() : [u])
        for (const h of t(f, a))
          l.push(h);
      c.push(l);
    }
    return { data: r, facets: c };
  });
}
const eb = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Area: Kf,
  Arrow: yS,
  BarX: xS,
  BarY: SS,
  Cell: eh,
  Contour: YS,
  Density: VS,
  Dot: Jf,
  Frame: tS,
  Geo: jS,
  Hexgrid: XS,
  Image: WS,
  Line: Qf,
  Link: pS,
  Mark: Yt,
  Raster: LS,
  Rect: th,
  RuleX: S6,
  RuleY: M6,
  Text: jf,
  TickX: IS,
  TickY: TS,
  Vector: Wf,
  area: fS,
  areaX: cu,
  areaY: ha,
  arrow: Jk,
  auto: fR,
  axisFx: P6,
  axisFy: z6,
  axisX: _m,
  axisY: wm,
  barX: Ds,
  barY: Bs,
  bin: nS,
  binX: Ns,
  binY: Os,
  boxX: gR,
  boxY: bR,
  cell: A0,
  cellX: uR,
  cellY: lR,
  centroid: TU,
  circle: nR,
  cluster: IU,
  column: Ve,
  contour: ER,
  delaunayLink: PR,
  delaunayMesh: YR,
  density: WR,
  dodgeX: jU,
  dodgeY: XU,
  dot: cs,
  dotX: tR,
  dotY: eR,
  filter: UB,
  formatIsoDate: hm,
  formatMonth: nC,
  formatWeekday: iC,
  frame: vm,
  geo: zm,
  geoCentroid: EU,
  graticule: QR,
  gridFx: W6,
  gridFy: j6,
  gridX: X6,
  gridY: V6,
  group: F3,
  groupX: El,
  groupY: Nl,
  groupZ: Kp,
  hexagon: iR,
  hexbin: tU,
  hexgrid: iU,
  hull: qR,
  identity: lt,
  image: cU,
  initializer: Fn,
  interpolateNearest: zS,
  interpolateNone: I0,
  interpolatorBarycentric: US,
  interpolatorRandomWalk: PS,
  legend: OC,
  line: bS,
  lineX: wS,
  lineY: _S,
  linearRegressionX: yU,
  linearRegressionY: gU,
  link: mS,
  map: nh,
  mapX: Lm,
  mapY: Cm,
  marks: lr,
  normalize: jm,
  normalizeX: GU,
  normalizeY: ZU,
  plot: xm,
  raster: _R,
  rect: MS,
  rectX: S0,
  rectY: M0,
  reverse: zB,
  ruleX: za,
  ruleY: Pa,
  scale: Fl,
  select: gz,
  selectFirst: y4,
  selectLast: g4,
  selectMaxX: vz,
  selectMaxY: xz,
  selectMinX: wz,
  selectMinY: _z,
  shuffle: PB,
  sort: N3,
  sphere: JR,
  spike: HC,
  stackX: sS,
  stackX1: Tk,
  stackX2: Ek,
  stackY: oS,
  stackY1: Nk,
  stackY2: Ok,
  text: Xf,
  textX: I6,
  textY: T6,
  tickX: ES,
  tickY: NS,
  transform: ci,
  tree: s4,
  treeLink: ZS,
  treeNode: T0,
  valueof: dt,
  vector: D6,
  vectorX: B6,
  vectorY: L6,
  voronoi: VR,
  voronoiMesh: jR,
  window: Xm,
  windowX: sz,
  windowY: oz
}, Symbol.toStringTag, { value: "Module" }));
function Az(e, t, n, i, r, s) {
  const o = (s.length >> 2) - 1;
  for (let a = 0, c = 0; a < i; ++a)
    for (let u = 0, l = (i - a - 1) * n; u < n; ++u, c += 4) {
      const f = o * r(e[u + l]) << 2;
      t[c + 0] = s[f + 0], t[c + 1] = s[f + 1], t[c + 2] = s[f + 2], t[c + 3] = s[f + 3];
    }
}
function nb(e, t) {
  const n = new Uint8ClampedArray(4 * e), i = e - 1;
  for (let r = 0; r <= i; ++r) {
    const s = t(r / i), { r: o, g: a, b: c, opacity: u = 1 } = typeof s == "string" ? pn(s) : s, l = r << 2;
    n[l + 0] = o, n[l + 1] = a, n[l + 2] = c, n[l + 3] = 255 * u | 0;
  }
  return n;
}
function $z(e, t) {
  if (typeof document < "u") {
    const n = document.createElement("canvas");
    return n.setAttribute("width", e), n.setAttribute("height", t), n;
  }
  throw new Error("Can not create a canvas instance.");
}
function Iz(e = "black") {
  const { r: t, g: n, b: i } = pn(e);
  return (r) => ({ r: t, g: n, b: i, opacity: r });
}
class b4 extends Oo {
  constructor(t, n, i) {
    const { bandwidth: r = 20, binWidth: s = 2, ...o } = i, a = o.fill === "density", c = o.stroke === "density";
    a && delete o.fill, c && delete o.stroke, super(t, n, o, g3), this.densityFill = a, this.densityStroke = c, this.bandwidth = r, this.binWidth = s, sr(r) && (r.addEventListener("value", (u) => {
      this.bandwidth = u, this.grids && this.convolve().update();
    }), this.bandwidth = r.value), sr(s) && (s.addEventListener("value", (u) => {
      this.binWidth = u, this.requestUpdate();
    }), this.binWidth = s.value);
  }
  setPlot(t, n) {
    const i = () => {
      this.stats && this.requestUpdate();
    };
    return t.addAttributeListener("domainX", i), t.addAttributeListener("domainY", i), super.setPlot(t, n);
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("domainX"), n = this.plot.getAttribute("domainY");
    return t && n && !t[is] && !n[is];
  }
  query(t = []) {
    var m;
    const { plot: n, channels: i, source: r, stats: s } = this, o = mt.from(r.table).where(t), a = this.groupby = [];
    let c = 1;
    for (const b of i)
      if (Object.hasOwn(b, "field")) {
        const { channel: w, field: _ } = b, x = ((m = _.transform) == null ? void 0 : m.call(_, s)) || _;
        o.select({ [w]: x }), w === "weight" ? c = w : w !== "x" && w !== "y" && a.push(w);
      }
    const [u, l] = Tf(this, t), [f, h] = Ef(this, t), [d, p] = this.bins = [
      Math.round(n.innerWidth() / this.binWidth),
      Math.round(n.innerHeight() / this.binWidth)
    ], g = !!n.getAttribute("reverseX"), y = !!n.getAttribute("reverseY");
    return Tz(o, "x", "y", c, u, l, f, h, d, p, g, y, a);
  }
  queryResult(t) {
    const [n, i] = this.bins;
    return this.grids = yB(n, i, t, this.groupby), this.convolve();
  }
  convolve() {
    const { bandwidth: t, bins: n, grids: i, plot: r } = this;
    if (t <= 0)
      this.kde = this.grids.map(({ key: s, grid: o }) => (o.key = s, o));
    else {
      const s = r.innerWidth(), o = r.innerHeight(), [a, c] = n, u = i.some(({ grid: h }) => h.some((d) => d < 0)), l = m0(t * (a - 1) / s, u), f = m0(t * (c - 1) / o, u);
      this.kde = this.grids.map(({ key: h, grid: d }) => {
        const p = bB(l, f, d, n);
        return p.key = h, p;
      });
    }
    return this;
  }
  plotSpecs() {
    throw new Error("Unimplemented. Use a Density2D mark subclass.");
  }
}
function Tz(e, t, n, i, r, s, o, a, c, u, l, f, h = []) {
  const d = i && i !== 1 ? `* ${i}` : "", p = q(l ? `(${s} - ${t}::DOUBLE) * ${(c - 1) / (s - r)}::DOUBLE` : `(${t}::DOUBLE - ${r}) * ${(c - 1) / (s - r)}::DOUBLE`), g = q(f ? `(${a} - ${n}::DOUBLE) * ${(u - 1) / (a - o)}::DOUBLE` : `(${n}::DOUBLE - ${o}) * ${(u - 1) / (a - o)}::DOUBLE`), y = (x, S) => mt.select({ xp: p, yp: g, i: x, w: S }, h).from(e).where(rr(
    dn(t, [r, s]),
    dn(n, [o, a])
  )), m = y(
    q(`FLOOR(xp) + FLOOR(yp) * ${c}`),
    q(`(FLOOR(xp) + 1 - xp) * (FLOOR(yp) + 1 - yp)${d}`)
  ), b = y(
    q(`FLOOR(xp) + (FLOOR(yp) + 1) * ${c}`),
    q(`(FLOOR(xp) + 1 - xp) * (yp - FLOOR(yp))${d}`)
  ), w = y(
    q(`FLOOR(xp) + 1 + FLOOR(yp) * ${c}`),
    q(`(xp - FLOOR(xp)) * (FLOOR(yp) + 1 - yp)${d}`)
  ), _ = y(
    q(`FLOOR(xp) + 1 + (FLOOR(yp) + 1) * ${c}`),
    q(`(xp - FLOOR(xp)) * (yp - FLOOR(yp))${d}`)
  );
  return mt.from(mt.unionAll(m, b, w, _)).select({ index: "i", weight: Zl("w") }, h).groupby("index", h).having(nw("weight", 0));
}
class w4 extends b4 {
  constructor(t, n) {
    super("image", t, n);
  }
  convolve() {
    super.convolve();
    const { bins: t, kde: n, groupby: i } = this, [r, s] = t, { canvas: o, ctx: a, img: c } = Ez(this, r, s), u = Nz(this), l = i.indexOf("fill"), f = l < 0 ? [] : n.map(({ key: h }) => h[l]);
    return this.data = n.map((h) => {
      var p;
      const d = Oz(this, f, (p = h.key) == null ? void 0 : p[l]);
      return Az(h, c.data, r, s, u, d), a.putImageData(c, 0, 0), { src: o.toDataURL() };
    }), this;
  }
  plotSpecs() {
    const { type: t, plot: n, data: i } = this, r = {
      src: "src",
      width: n.innerWidth(),
      height: n.innerHeight(),
      preserveAspectRatio: "none",
      frameAnchor: "middle"
    };
    return [{ type: t, data: i, options: r }];
  }
}
function Ez(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const i = $z(t, n), r = i.getContext("2d", { willReadFrequently: !0 }), s = r.getImageData(0, 0, t, n);
    e.image = { canvas: i, ctx: r, img: s, w: t, h: n };
  }
  return e.image;
}
function Nz(e) {
  const { densityFill: t, kde: n, plot: i } = e;
  let r = t && i.getAttribute("domainColor");
  if (!r) {
    let o = 0, a = 0;
    n.forEach((c) => {
      const u = c.length;
      for (let l = 0; l < u; ++l) {
        const f = c[l];
        f < o && (o = f), f > a && (a = f);
      }
    }), r = o === 0 && a === 0 ? [0, 1] : [o, a];
  }
  const s = i.getAttribute("scaleColor");
  return Fl({ x: { type: s, domain: r, range: [0, 1] } }).apply;
}
function Oz(e, t, n, i = 512) {
  const { densityFill: r, plot: s } = e, o = s.getAttribute("schemeColor");
  let a;
  if (r) {
    if (o)
      try {
        return nb(
          i,
          Fl({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (c) {
        console.warn(c);
      }
  } else if (t.length)
    a = Fl({ color: { scheme: o || "tableau10", domain: t } }).apply(n);
  else {
    const c = e.channels.find((u) => u.channel === "fill");
    a = p3(c == null ? void 0 : c.value) ? c.value : void 0;
  }
  return nb(i, Iz(a));
}
class Fz extends w4 {
  constructor(t, n) {
    const { normalize: i = !0, ...r } = n;
    super(t, { bandwidth: 0, ...r }), this.normalize = i;
  }
  query(t = []) {
    var b;
    const { plot: n, channels: i, normalize: r, source: s, stats: o } = this, [a, c] = Tf(this, t), [u, l] = Ef(this, t), f = mt.from(s.table).where(Dz(this, t)), h = this.groupby = [], d = [];
    for (const w of i)
      if (Object.hasOwn(w, "field")) {
        const { channel: _, field: x } = w, S = ((b = x.transform) == null ? void 0 : b.call(x, o)) || x;
        f.select({ [_]: S }), _ === "z" ? d.push("z") : _ !== "x" && _ !== "y" && h.push(_);
      }
    const [p, g] = this.bins = [
      Math.round(n.innerWidth() / this.binWidth),
      Math.round(n.innerHeight() / this.binWidth)
    ], y = !!n.getAttribute("reverseX"), m = !!n.getAttribute("reverseY");
    return Bz(f, "x", "y", d, a, c, u, l, p, g, y, m, h, r);
  }
}
function Dz(e, t) {
  if (Array.isArray(t) && !t.length)
    return t;
  const n = e.channelField("x").column, i = e.channelField("y").column, r = (o) => o.op !== "BETWEEN" || o.expr.column !== n && o.expr.column !== i, s = (o) => o.op === "AND" ? rr(o.value.filter((a) => r(a))) : o;
  return Array.isArray(t) ? t.filter((o) => r(o)).map((o) => s(o)) : s(t);
}
function Bz(e, t, n, i, r, s, o, a, c, u, l, f, h = [], d = !0) {
  const p = h.concat(i), g = l ? `(${s} - ${t}::DOUBLE)` : `(${t}::DOUBLE - ${r})`, y = q(`FLOOR(${g} * ${(c - 1) / (s - r)}::DOUBLE)::INTEGER`), m = f ? `(${a} - ${n}::DOUBLE)` : `(${n}::DOUBLE - ${o})`, b = q(`FLOOR(${m} * ${(u - 1) / (a - o)}::DOUBLE)::INTEGER`), w = mt.from(e).select(p, { x: y, y: b }), _ = p.length ? `PARTITION BY ${p.join(", ")} ` : "", x = mt.from(w).select(p, {
    x0: "x",
    y0: "y",
    dx: q("(lead(x) OVER sw - x)"),
    dy: q("(lead(y) OVER sw - y)")
  }).window({ sw: q(`${_}ORDER BY x ASC`) }).qualify(rr(
    q(`(x0 < ${c} OR x0 + dx < ${c})`),
    q(`(y0 < ${u} OR y0 + dy < ${u})`),
    q("(x0 > 0 OR x0 + dx > 0)"),
    q("(y0 > 0 OR y0 + dy > 0)")
  )), S = mt.select({ x: q("GREATEST(MAX(ABS(dx)), MAX(ABS(dy)))") }).from("pairs"), I = mt.select({ i: q(`UNNEST(range((${S})))::INTEGER`) }), N = mt.unionAll(
    mt.select(p, {
      x: q("x0 + i"),
      y: q("y0 + ROUND(i * dy / dx::FLOAT)::INTEGER")
    }).from("pairs", "indices").where(q("ABS(dy) <= ABS(dx) AND i < ABS(dx)")),
    mt.select(p, {
      x: q("x0 + ROUND(SIGN(dy) * i * dx / dy::FLOAT)::INTEGER"),
      y: q("y0 + SIGN(dy) * i")
    }).from("pairs", "indices").where(q("ABS(dy) > ABS(dx) AND i < ABS(dy)")),
    mt.select(p, { x: "x0", y: "y0" }).from("pairs").where(tw("dx"))
  ), F = ["x"].concat(p).join(", "), $ = mt.from("raster").select(
    p,
    "x",
    "y",
    d ? { w: q(`1.0 / COUNT(*) OVER (PARTITION BY ${F})`) } : null
  ).where(rr(dn("x", [0, c]), dn("y", [0, u])));
  return mt.with({ pairs: x, indices: I, raster: N, points: $ }).from("points").select(h, {
    index: q(`x + y * ${c}::INTEGER`),
    weight: d ? Zl("w") : aa()
  }).groupby("index", h);
}
class Lz extends b4 {
  constructor(t, n) {
    const { thresholds: i = 10, ...r } = n;
    super("geo", t, r), this.thresholds = i, sr(i) && (i.addEventListener("value", (s) => {
      this.thresholds = s, this.grids && this.contours().update();
    }), this.thresholds = i.value);
  }
  convolve() {
    return super.convolve().contours();
  }
  contours() {
    const { bins: t, kde: n, thresholds: i, groupby: r, plot: s } = this;
    let o = i;
    if (!Array.isArray(o)) {
      const b = Gt(n.map((w) => Gt(w)));
      o = Array.from({ length: o - 1 }, (w, _) => b * (_ + 1) / o);
    }
    (this.densityFill || this.densityStroke) && this.plot.getAttribute("scaleColor") !== "log" && this.plot.setAttribute("zeroColor", !0);
    const [a, c] = t, [u, l] = s.getAttribute("domainX"), [f, h] = s.getAttribute("domainY"), d = (l - u) / a, p = (h - f) / c, g = (b) => u + b * d, y = (b) => f + b * p, m = Hu().size(t);
    return this.data = n.flatMap((b) => o.map((w) => {
      const _ = Cz(m.contour(b, w), g, y);
      return r.forEach((x, S) => _[x] = b.key[S]), _.density = w, _;
    })), this;
  }
  plotSpecs() {
    const { type: t, channels: n, densityFill: i, densityStroke: r, data: s } = this, o = {};
    for (const a of n)
      o[a.channel] = Object.hasOwn(a, "value") ? a.value : a.channel;
    return i && (o.fill = "density"), r && (o.stroke = "density"), [{ type: t, data: s, options: o }];
  }
}
function Cz(e, t, n) {
  function i(o) {
    o.forEach(r);
  }
  function r(o) {
    o.forEach(s);
  }
  function s(o) {
    o[0] = t(o[0]), o[1] = n(o[1]);
  }
  return e.coordinates.forEach(i), e;
}
class kz extends Oo {
  constructor(t, n) {
    const { type: i = "hexagon", binWidth: r = 20, ...s } = n;
    super(i, t, { r: r / 2, clip: !0, ...s }, g3), this.binWidth = r;
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("domainX"), n = this.plot.getAttribute("domainY");
    return t && n && !t[is] && !n[is];
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { plot: n, binWidth: i, channels: r, source: s } = this, [o, a] = Tf(this, t), [c, u] = Ef(this, t), l = 0.5 - n.getAttribute("marginLeft"), f = 0 - n.getAttribute("marginTop"), h = `${i}::DOUBLE`, d = `${i * (1.5 / Math.sqrt(3))}::DOUBLE`, p = `${n.innerWidth() / (a - o)}::DOUBLE`, g = `${n.innerHeight() / (u - c)}::DOUBLE`, y = mt.select({
      x: q(`${o}::DOUBLE + ((x + 0.5 * (y & 1)) * ${h} + ${l})::DOUBLE / ${p}`),
      y: q(`${u}::DOUBLE - (y * ${d} + ${f})::DOUBLE / ${g}`)
    }).groupby("x", "y");
    let m, b;
    const w = /* @__PURE__ */ new Set();
    for (const I of r)
      I.channel === "order" ? y.orderby(I.value) : I.channel === "x" ? m = I.field : I.channel === "y" ? b = I.field : Object.hasOwn(I, "field") && (y.select({ [I.channel]: I.field }), I.field.aggregate && I.field.columns.forEach((N) => w.add(N)));
    const _ = `${p} * (${m} - ${o}::DOUBLE)`, x = `${g} * (${u}::DOUBLE - ${b})`, S = mt.select({
      py: q(`(${x} - ${f}) / ${d}`),
      pj: q("ROUND(py)::INTEGER"),
      px: q(`(${_} - ${l}) / ${h} - 0.5 * (pj & 1)`),
      pi: q("ROUND(px)::INTEGER"),
      tt: q("ABS(py-pj) * 3 > 1 AND (px-pi)**2 + (py-pj)**2 > (px - pi - 0.5 * CASE WHEN px < pi THEN -1 ELSE 1 END)**2 + (py - pj - CASE WHEN py < pj THEN -1 ELSE 1 END)**2"),
      x: q("CASE WHEN tt THEN (pi + (CASE WHEN px < pi THEN -0.5 ELSE 0.5 END) + (CASE WHEN pj & 1 <> 0 THEN 0.5 ELSE -0.5 END))::INTEGER ELSE pi END"),
      y: q("CASE WHEN tt THEN (pj + CASE WHEN py < pj THEN -1 ELSE 1 END)::INTEGER ELSE pj END")
    }).select(Array.from(w)).from(s.table).where(Uu(m), Uu(b), t);
    return y.from(S);
  }
}
function Rz(e, t, n) {
  var i = 1e-8, r = t - 1, s = n - 1, o = 0, a, c, u, l, f, h, d, p, g, y, m;
  if (e <= 0)
    return 0;
  if (e >= 1)
    return 1;
  for (t >= 1 && n >= 1 ? (u = e < 0.5 ? e : 1 - e, l = Math.sqrt(-2 * Math.log(u)), d = (2.30753 + l * 0.27061) / (1 + l * (0.99229 + l * 0.04481)) - l, e < 0.5 && (d = -d), p = (d * d - 3) / 6, g = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), y = d * Math.sqrt(p + g) / g - (1 / (2 * n - 1) - 1 / (2 * t - 1)) * (p + 5 / 6 - 2 / (3 * g)), d = t / (t + n * Math.exp(2 * y))) : (a = Math.log(t / (t + n)), c = Math.log(n / (t + n)), l = Math.exp(t * a) / t, f = Math.exp(n * c) / n, y = l + f, e < l / y ? d = Math.pow(t * y * e, 1 / t) : d = 1 - Math.pow(n * y * (1 - e), 1 / n)), m = -Ws(t) - Ws(n) + Ws(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = Uz(d, t, n) - e, l = Math.exp(r * Math.log(d) + s * Math.log(1 - d) + m), f = h / l, d -= l = f / (1 - 0.5 * Math.min(1, f * (r / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + l)), d >= 1 && (d = 0.5 * (d + l + 1)), Math.abs(l) < i * d && o > 0)
      break;
  }
  return d;
}
function Uz(e, t, n) {
  var i = e === 0 || e === 1 ? 0 : Math.exp(Ws(t + n) - Ws(t) - Ws(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? i * ib(e, t, n) / t : 1 - i * ib(1 - e, n, t) / n;
}
function ib(e, t, n) {
  var i = 1e-30, r = 1, s = t + n, o = t + 1, a = t - 1, c = 1, u = 1 - s * e / o, l, f, h, d;
  for (Math.abs(u) < i && (u = i), u = 1 / u, d = u; r <= 100 && (l = 2 * r, f = r * (n - r) * e / ((a + l) * (t + l)), u = 1 + f * u, Math.abs(u) < i && (u = i), c = 1 + f / c, Math.abs(c) < i && (c = i), u = 1 / u, d *= u * c, f = -(t + r) * (s + r) * e / ((t + l) * (o + l)), u = 1 + f * u, Math.abs(u) < i && (u = i), c = 1 + f / c, Math.abs(c) < i && (c = i), u = 1 / u, h = u * c, d *= h, !(Math.abs(h - 1) < 3e-7)); r++)
    ;
  return d;
}
function Ws(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], i = 1.000000000190015, r, s, o;
  for (o = (s = r = e) + 5.5, o -= (r + 0.5) * Math.log(o); t < 6; t++)
    i += n[t] / ++s;
  return Math.log(2.506628274631 * i / r) - o;
}
function zz(e, t) {
  var n = Rz(2 * Math.min(e, 1 - e), 0.5 * t, 0.5);
  return n = Math.sqrt(t * (1 - n) / n), e > 0.5 ? n : -n;
}
class Pz extends Oo {
  constructor(t, n) {
    const { ci: i = 0.95, precision: r = 4, ...s } = n;
    super("line", t, s), this.ci = i, this.precision = r;
  }
  query(t = []) {
    const n = "x", i = "y", r = ["stroke", "z", "fx", "fy"].flatMap((s) => this.channelField(s) ? s : []);
    return mt.from(super.query(t)).select({
      intercept: X5(i, n),
      slope: W5(i, n),
      n: H5(i, n),
      r2: G5(i, n),
      ssy: Z5(i, n),
      ssx: K5(i, n),
      xm: J5(i, n),
      x0: ro(n).where(Uu(i)),
      x1: io(n).where(Uu(i))
    }).select(r).groupby(r);
  }
  queryResult(t) {
    t = Array.from(t), this.data = t.flatMap((o) => Yz(o));
    const { ci: n, precision: i, plot: r } = this, s = r.innerWidth();
    return this.areaData = n ? t.flatMap((o) => qz(n, i, o, s)) : null, this;
  }
  plotSpecs() {
    const { data: t, areaData: n, channels: i, ci: r } = this, s = { x: "x", y: "y" }, o = { x: "x", y1: "y1", y2: "y2", fillOpacity: 0.1 };
    for (const a of i)
      switch (a.channel) {
        case "x":
        case "y":
        case "fill":
          break;
        case "stroke":
          s.stroke = Object.hasOwn(a, "value") ? a.value : "stroke", o.fill = Object.hasOwn(a, "value") ? a.value : "fill";
          break;
        case "strokeOpacity":
          s.strokeOpacity = Object.hasOwn(a, "value") ? a.value : a.channel;
          break;
        case "fillOpacity":
          o.fillOpacity = Object.hasOwn(a, "value") ? a.value : a.channel;
          break;
        default:
          s[a.channel] = Object.hasOwn(a, "value") ? a.value : a.channel, o[a.channel] = s[a.channel];
          break;
      }
    return [
      ...r ? [{ type: "areaY", data: n, options: o }] : [],
      { type: "line", data: t, options: s }
    ];
  }
}
function Yz(e) {
  const { x0: t, x1: n, intercept: i, slope: r, stroke: s } = e;
  return [
    { x: t, y: i + t * r, stroke: s },
    { x: n, y: i + n * r, stroke: s }
  ];
}
function qz(e, t, n, i) {
  const {
    x0: r,
    x1: s,
    xm: o,
    intercept: a,
    slope: c,
    n: u,
    ssx: l,
    ssy: f,
    stroke: h
  } = n, d = t * (s - r) / i, p = zz((1 - e) / 2, u - 2) * Math.sqrt(f / (u - 2));
  return sn(r, s - d / 2, d).concat(s).map((g) => {
    const y = a + g * c, m = p * Math.sqrt(1 / u + (g - o) ** 2 / l);
    return { x: g, y1: y - m, y2: y + m, fill: h };
  });
}
const Vz = /* @__PURE__ */ new Set(["frame", "hexgrid", "graticule", "sphere"]);
function Dt(e, t, n) {
  arguments.length === 2 && (n = t, t = Vz.has(e) ? null : [{}]);
  const i = e.startsWith("area") || e.startsWith("line") ? dB : Oo;
  return Gm(i, e, t, n);
}
function Gm(e, t, n, i) {
  return (r) => {
    r.addMark(new e(t, n, i));
  };
}
function dc(e, t, n) {
  return (i) => {
    i.addMark(new e(t, n));
  };
}
const jz = (...e) => Dt("area", ...e), Xz = (...e) => Dt("areaX", ...e), Wz = (...e) => Dt("areaY", ...e), Hz = (...e) => Dt("line", ...e), Gz = (...e) => Dt("lineX", ...e), Zz = (...e) => Dt("lineY", ...e), Kz = (...e) => Dt("bar", ...e), Jz = (...e) => Dt("barX", ...e), Qz = (...e) => Dt("barY", ...e), tP = (...e) => Dt("cell", ...e), eP = (...e) => Dt("cellX", ...e), nP = (...e) => Dt("cellY", ...e), iP = (...e) => Dt("rect", ...e), rP = (...e) => Dt("rectX", ...e), sP = (...e) => Dt("rectY", ...e), oP = (...e) => Dt("dot", ...e), aP = (...e) => Dt("dotX", ...e), cP = (...e) => Dt("dotY", ...e), uP = (...e) => Dt("circle", ...e), lP = (...e) => Dt("hexagon", ...e), fP = (...e) => Dt("text", ...e), hP = (...e) => Dt("textX", ...e), dP = (...e) => Dt("textY", ...e), pP = (...e) => Dt("ruleX", ...e), mP = (...e) => Dt("ruleY", ...e), yP = (...e) => Dt("tickX", ...e), gP = (...e) => Dt("tickY", ...e), bP = (...e) => Dt("frame", ...e), wP = (...e) => Gm(_3, "areaX", ...e), _P = (...e) => Gm(_3, "areaY", ...e), vP = (...e) => dc(Fz, ...e), xP = (...e) => dc(Lz, ...e), SP = (...e) => dc(w4, ...e), MP = (...e) => dc(kz, ...e), AP = (...e) => Dt("hexgrid", ...e), $P = (...e) => dc(Pz, ...e), IP = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  area: jz,
  areaX: Xz,
  areaY: Wz,
  bar: Kz,
  barX: Jz,
  barY: Qz,
  cell: tP,
  cellX: eP,
  cellY: nP,
  circle: uP,
  contour: xP,
  denseLine: vP,
  densityX: wP,
  densityY: _P,
  dot: oP,
  dotX: aP,
  dotY: cP,
  frame: bP,
  hexagon: lP,
  hexbin: MP,
  hexgrid: AP,
  line: Hz,
  lineX: Gz,
  lineY: Zz,
  raster: SP,
  rect: iP,
  rectX: rP,
  rectY: sP,
  regressionY: $P,
  ruleX: pP,
  ruleY: mP,
  text: fP,
  textX: hP,
  textY: dP,
  tickX: yP,
  tickY: gP
}, Symbol.toStringTag, { value: "Module" }));
function TP(e) {
  const t = e.toLowerCase(), n = e.length;
  let i = "";
  for (let r = 0; r < n; ++r)
    i += (e[r] !== t[r] ? "-" : "") + t[r];
  return i;
}
function Zm(e) {
  const t = {};
  for (const n in e)
    t[TP(n)] = e[n];
  return t;
}
class EP {
  constructor(t, {
    selection: n,
    channels: i = {}
  }) {
    this.mark = t, this.selection = n;
    const r = Object.entries(Zm(i));
    this.channels = r.length ? r : [["opacity", 0.2]], this.selection.addEventListener("value", Kl(() => this.update()));
  }
  init(t) {
    this.svg = t;
    const n = this.values = [], i = this.mark.index, r = this.nodes = t.querySelectorAll(`[data-index="${i}"] > *`), { channels: s } = this;
    for (let o = 0; o < r.length; ++o) {
      const a = r[o];
      n.push(s.map((c) => a.getAttribute(c[0])));
    }
    return this.update();
  }
  async update() {
    const { svg: t, nodes: n, channels: i, values: r, mark: s, selection: o } = this;
    if (!t)
      return;
    const a = await NP(s, o);
    for (let c = 0; c < n.length; ++c) {
      const u = n[c], l = r[c], f = a(u.__data__);
      for (let h = 0; h < i.length; ++h) {
        const [d, p] = i[h];
        u.setAttribute(d, f ? l[h] : p);
      }
    }
  }
}
async function NP(e, t) {
  var c, u;
  const n = t == null ? void 0 : t.predicate(e);
  if (!n || n.length === 0)
    return () => !0;
  const i = { __: rr(n) }, r = e.query((c = e.filterBy) == null ? void 0 : c.predicate(e)), s = r.groupby().length ? r.select(i) : r.$select(i), o = await So().query(s), a = (u = o.getChild) == null ? void 0 : u.call(o, "__");
  return a ? (l) => a.get(l) : (l) => o[l].__;
}
class _4 {
  constructor(t, {
    selection: n,
    channels: i
  }) {
    this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.channels = i.map((r) => {
      const s = r === "color" ? ["fill", "stroke"] : r === "x" ? ["x", "x1", "x2"] : r === "y" ? ["y", "y1", "y2"] : [r];
      for (let o = 0; o < s.length; ++o) {
        const a = t.channelField(s[o]);
        if (a)
          return [s[o], a];
      }
      throw new Error(`Missing channel: ${r}`);
    });
  }
  clause(t) {
    const { channels: n, clients: i } = this;
    let r = null;
    if (t) {
      const s = t.map((o) => {
        const a = o.map((c, u) => Hl(n[u][1], Ha(c)));
        return a.length > 1 ? rr(a) : a[0];
      });
      r = s.length > 1 ? rw(s) : s[0];
    }
    return {
      source: this,
      schema: { type: "point" },
      clients: i,
      value: t,
      predicate: r
    };
  }
  init(t, n, i) {
    const { mark: r, channels: s, selection: o } = this, { data: a } = r;
    i = i || ((u) => {
      const l = a[u.__data__];
      return s.map(([f]) => l[f]);
    }), n = n || `[data-index="${r.index}"]`;
    const c = new Set(t.querySelectorAll(n));
    t.addEventListener("click", (u) => {
      const l = u.target;
      let f = null;
      if (OP(c, l)) {
        const h = o.single ? o.value : this.value, d = i(l);
        u.shiftKey && (h != null && h.length) ? (f = h.filter((p) => FP(p, d)), f.length === h.length && f.push(d)) : f = [d];
      }
      this.value = f, o.update(this.clause(f));
    }), t.addEventListener("mouseenter", () => {
      this.selection.activate(this.clause([this.channels.map(() => 0)]));
    });
  }
}
function OP(e, t) {
  var n;
  return e.has(t) || e.has(t.parentNode) || e.has((n = t.parentNode) == null ? void 0 : n.parentNode);
}
function FP(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !0;
  for (let i = 0; i < n; ++i)
    if (e[i] !== t[i])
      return !0;
  return !1;
}
const rb = 1e-12;
function B0(e, t) {
  return e === t || e && t && Math.abs(e[0] - t[0]) < rb && Math.abs(e[1] - t[1]) < rb || !1;
}
function v4() {
  const e = this, t = e.getScreenCTM;
  let n;
  e.getScreenCTM = () => e.isConnected ? n = t.call(e) : n;
}
class x4 {
  constructor(t, {
    channel: n,
    selection: i,
    field: r,
    peers: s = !0,
    brush: o
  }) {
    var a;
    this.mark = t, this.channel = n, this.selection = i, this.peers = s, this.field = r || t.channelField(n, n + "1", n + "2"), this.field = ((a = this.field) == null ? void 0 : a.column) || this.field, this.style = o && Zm(o), this.brush = n === "y" ? mE() : pE(), this.brush.on("brush end", ({ selection: c }) => this.publish(c));
  }
  activate() {
    this.selection.activate(this.clause(this.value || [0, 1]));
  }
  publish(t) {
    let n;
    t && (n = t.map(this.scale.invert).sort((i, r) => i - r)), B0(n, this.value) || (this.value = n, this.g.call(this.brush.move, t), this.selection.update(this.clause(n)));
  }
  clause(t) {
    return {
      source: this,
      schema: { type: "interval", scales: [this.scale] },
      clients: this.peers ? this.mark.plot.markSet : (/* @__PURE__ */ new Set()).add(this.mark),
      value: t,
      predicate: t ? dn(this.field, t) : null
    };
  }
  init(t) {
    var u;
    const { brush: n, channel: i, style: r } = this;
    this.scale = t.scale(i);
    const s = t.scale("x").range, o = t.scale("y").range;
    n.extent([[he(s), he(o)], [Gt(s), Gt(o)]]);
    const a = zt(t).selectAll('g[aria-label="facet"]'), c = a.size() ? a : zt(t);
    if (this.g = c.append("g").attr("class", `interval-${i}`).each(v4).call(n).call(n.move, (u = this.value) == null ? void 0 : u.map(this.scale.apply)), r) {
      const l = this.g.selectAll("rect.selection");
      for (const f in r)
        l.attr(f, r[f]);
    }
    t.addEventListener("mouseenter", () => this.activate());
  }
}
const Xc = (e, t) => e - t;
class DP {
  constructor(t, {
    selection: n,
    xfield: i,
    yfield: r,
    peers: s = !0,
    brush: o
  }) {
    this.mark = t, this.selection = n, this.peers = s, this.xfield = i || t.channelField("x", "x1", "x2"), this.yfield = r || t.channelField("y", "y1", "y2"), this.style = o && Zm(o), this.brush = yE(), this.brush.on("brush end", ({ selection: a }) => this.publish(a));
  }
  activate() {
    this.selection.activate(this.clause(this.value || [[0, 1], [0, 1]]));
  }
  publish(t) {
    const { value: n } = this;
    let i, r;
    if (t) {
      const [s, o] = t;
      i = [s[0], o[0]].map(this.xscale.invert).sort(Xc), r = [s[1], o[1]].map(this.yscale.invert).sort(Xc);
    }
    (!B0(i, n == null ? void 0 : n[0]) || !B0(r, n == null ? void 0 : n[1])) && (this.value = t ? [i, r] : null, this.g.call(this.brush.move, t), this.selection.update(this.clause(this.value)));
  }
  clause(t) {
    return {
      source: this,
      schema: { type: "interval", scales: [this.xscale, this.yscale] },
      clients: this.peers ? this.mark.plot.markSet : (/* @__PURE__ */ new Set()).add(this.mark),
      value: t,
      predicate: t ? rr(
        dn(this.xfield, t[0]),
        dn(this.yfield, t[1])
      ) : null
    };
  }
  init(t) {
    const { brush: n, style: i } = this, r = this.xscale = t.scale("x"), s = this.yscale = t.scale("y"), o = r.range, a = s.range;
    n.extent([[he(o), he(a)], [Gt(o), Gt(a)]]);
    const c = zt(t).selectAll('g[aria-label="facet"]'), u = c.size() ? c : zt(t);
    if (this.g = u.append("g").attr("class", "interval-xy").each(v4).call(n), i) {
      const l = this.g.selectAll("rect.selection");
      for (const f in i)
        l.attr(f, i[f]);
    }
    if (this.value) {
      const [l, f] = this.value[0].map(r.apply).sort(Xc), [h, d] = this.value[1].map(s.apply).sort(Xc);
      this.g.call(n.move, [[l, h], [f, d]]);
    }
    t.addEventListener("mouseenter", () => this.activate());
  }
}
const sb = (e, t) => e - t;
class BP {
  constructor(t, {
    x: n = new Zi(),
    y: i = new Zi(),
    xfield: r,
    yfield: s,
    zoom: o = !0,
    panx: a = !0,
    pany: c = !0
  }) {
    this.mark = t, this.xsel = n, this.ysel = i, this.xfield = r || t.channelField("x", "x1", "x2"), this.yfield = s || t.channelField("y", "y1", "y2"), this.zoom = cd(o, [0, 1 / 0], [1, 1]), this.panx = this.xsel && a, this.pany = this.ysel && c;
    const { plot: u } = t;
    a && this.xsel.addEventListener("value", (l) => {
      u.setAttribute("domainX", l) && u.update();
    }), c && this.ysel.addEventListener("value", (l) => {
      u.setAttribute("domainY", l) && u.update();
    });
  }
  publish(t) {
    if (this.panx) {
      const n = LP(t, this.xscale);
      this.xsel.update(this.clause(n, this.xfield, this.xscale));
    }
    if (this.pany) {
      const n = CP(t, this.yscale);
      this.ysel.update(this.clause(n, this.yfield, this.yscale));
    }
  }
  clause(t, n, i) {
    return {
      source: this,
      schema: { type: "interval", scales: [i] },
      clients: this.mark.plot.markSet,
      value: t,
      predicate: t ? dn(n, t) : null
    };
  }
  init(t) {
    if (this.svg = t, this.initialized)
      return;
    this.initialized = !0;
    const { panx: n, pany: i, mark: { plot: { element: r } }, xsel: s, ysel: o } = this;
    this.xscale = t.scale("x"), this.yscale = t.scale("y");
    const a = this.xscale.range.slice().sort(sb), c = this.yscale.range.slice().sort(sb), u = cd(n, [-1 / 0, 1 / 0], a), l = cd(i, [-1 / 0, 1 / 0], c), f = cB().extent([[a[0], c[0]], [a[1], c[1]]]).scaleExtent(this.zoom).translateExtent([[u[0], l[0]], [u[1], l[1]]]).on("start", () => {
      this.xscale = this.svg.scale("x"), this.yscale = this.svg.scale("y");
    }).on("end", () => r.__zoom = new Wn(1, 0, 0)).on("zoom", ({ transform: h }) => this.publish(h));
    if (zt(r).call(f), n || i) {
      let h = !1;
      r.addEventListener("mouseenter", () => {
        if (!h) {
          if (h = !0, n) {
            const { xscale: d, xfield: p } = this;
            s.activate(this.clause(d.domain, p, d));
          }
          if (i) {
            const { yscale: d, yfield: p } = this;
            o.activate(this.clause(d.domain, p, d));
          }
        }
      }), r.addEventListener("mouseleave", () => h = !1);
    }
  }
}
function cd(e, t, n) {
  return e ? Array.isArray(e) ? e : t : n;
}
function LP(e, t) {
  return t.range.map(e.invertX, e).map(t.invert, t);
}
function CP(e, t) {
  return t.range.map(e.invertY, e).map(t.invert, t);
}
class S4 {
  constructor(t, {
    selection: n,
    channel: i,
    field: r
  }) {
    var s;
    this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.channel = i, this.field = r || t.channelField(i), this.field = ((s = this.field) == null ? void 0 : s.column) || this.field;
  }
  clause(t) {
    const { clients: n, field: i } = this, r = t ? Hl(i, Ha(t)) : null;
    return {
      source: this,
      schema: { type: "point" },
      clients: n,
      value: t,
      predicate: r
    };
  }
  init(t) {
    const n = this, { mark: i, channel: r, selection: s } = this, { data: o } = i, a = zt(t).selectAll('g[aria-label="facet"]'), c = a.size() ? a : zt(t), u = t.scale(r), l = !Zr(s);
    c.on("mousemove", function(f) {
      const [h, d] = kn(f, this), p = kP(o, r, u.invert(r === "x" ? h : d));
      s.update(l ? p : n.clause(p));
    }), !l && t.addEventListener("mouseenter", () => {
      this.selection.activate(this.clause(0));
    });
  }
}
function kP(e, t, n) {
  let i = 1 / 0, r;
  return e.forEach((s) => {
    const o = Math.abs(s[t] - n);
    o < i && (i = o, r = s[t]);
  }), r;
}
function xr(e, t) {
  return (n) => {
    const i = n.marks[n.marks.length - 1];
    n.addInteractor(new e(i, t));
  };
}
function RP({ by: e, ...t }) {
  return xr(EP, { selection: e, channels: t });
}
function rh({ as: e, ...t }) {
  return xr(_4, { ...t, selection: e });
}
function UP({ as: e }) {
  return rh({ as: e, channels: ["x"] });
}
function zP({ as: e }) {
  return rh({ as: e, channels: ["y"] });
}
function PP({ as: e }) {
  return rh({ as: e, channels: ["color"] });
}
function YP({ as: e, ...t }) {
  return xr(S4, { ...t, selection: e, channel: "x" });
}
function qP({ as: e, ...t }) {
  return xr(S4, { ...t, selection: e, channel: "y" });
}
function VP({ as: e, ...t }) {
  return xr(x4, { ...t, selection: e, channel: "x" });
}
function jP({ as: e, ...t }) {
  return xr(x4, { ...t, selection: e, channel: "y" });
}
function XP({ as: e, ...t }) {
  return xr(DP, { ...t, selection: e });
}
function Ro(e) {
  return xr(BP, e);
}
function WP(e = {}) {
  return Ro({ ...e, zoom: !1 });
}
function HP(e = {}) {
  return Ro({ ...e, zoom: !1, pany: !1 });
}
function GP(e = {}) {
  return Ro({ ...e, zoom: !1, panx: !1 });
}
function ZP(e = {}) {
  return Ro(e);
}
function KP(e = {}) {
  return Ro({ ...e, pany: !1 });
}
function JP(e = {}) {
  return Ro({ ...e, panx: !1 });
}
const QP = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  highlight: RP,
  intervalX: VP,
  intervalXY: XP,
  intervalY: jP,
  nearestX: YP,
  nearestY: qP,
  pan: WP,
  panX: HP,
  panY: GP,
  panZoom: ZP,
  panZoomX: KP,
  panZoomY: JP,
  toggle: rh,
  toggleColor: PP,
  toggleX: UP,
  toggleY: zP
}, Symbol.toStringTag, { value: "Module" }));
class ob {
  constructor(t, n) {
    const { as: i, ...r } = n;
    this.channel = t, this.options = { label: null, ...r }, this.selection = i, this.element = document.createElement("div"), this.element.setAttribute("class", "legend"), this.element.value = this;
  }
  setPlot(t) {
    const { channel: n, selection: i } = this, r = this.mark = tY(t, n);
    this.selection && r && (this.handler = new _4(r, { selection: i, channels: [n] }), this.selection.addEventListener("value", () => this.update()));
  }
  init(t) {
    const { channel: n, options: i, handler: r } = this, o = t.scale(n).type === "ordinal" ? i : { marginTop: 1, tickSize: 2, height: 28, ...i };
    return this.legend = t.legend(n, o), r && (r.init(this.legend, ":scope > div", (a) => [a.__data__]), this.update()), this.element.replaceChildren(this.legend), this.element;
  }
  update() {
    if (!this.legend)
      return;
    const { value: t } = this.selection, n = t ? new Set(t.map((r) => r[0])) : null, i = this.legend.querySelectorAll(":scope > div");
    for (const r of i) {
      const s = n == null || n.has(r.__data__);
      r.style.opacity = s ? 1 : 0.2;
    }
  }
}
function tY({ marks: e }, t) {
  const n = t === "color" ? ["fill", "stroke"] : t === "opacity" ? ["opacity", "fillOpacity", "strokeOpacity"] : null;
  if (n == null)
    return null;
  for (let i = e.length - 1; i > -1; --i)
    if (e[i].channelField(n))
      return e[i];
  return null;
}
function M4(e, t = {}) {
  if (t.for) {
    const { for: n, ...i } = t, r = new ob(e, i), s = typeof n, o = (a) => a.addLegend(r, !1);
    return s === "string" ? cw.request(n, o) : n.value && o(n.value), r.element;
  } else
    return (n) => n.addLegend(new ob(e, t));
}
const eY = (e) => M4("color", e), nY = (e) => M4("opacity", e), iY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  legendColor: eY,
  legendOpacity: nY
}, Symbol.toStringTag, { value: "Module" }));
class A4 {
  constructor(t, { type: n = "vertical" }) {
    this.elements = t, this.element = document.createElement("div"), this.element.setAttribute("class", `concat-${n}`), this.element.value = this, t.forEach((i) => this.element.appendChild(i));
  }
}
const rY = /* @__PURE__ */ new Map([
  ["width", "width"],
  ["height", "height"],
  ["margin", "margin"],
  ["marginTop", "marginTop"],
  ["marginBottom", "marginBottom"],
  ["marginLeft", "marginLeft"],
  ["marginRight", "marginRight"],
  ["scaleX", "x.type"],
  ["scaleY", "y.type"],
  ["domainX", "x.domain"],
  ["domainY", "y.domain"],
  ["domainFX", "fx.domain"],
  ["domainFY", "fy.domain"],
  ["axisX", "x.axis"],
  ["axisY", "y.axis"],
  ["axisLineX", "x.line"],
  ["axisLineY", "y.line"],
  ["insetX", "x.inset"],
  ["insetY", "y.inset"],
  ["grid", "grid"],
  ["gridX", "x.grid"],
  ["gridY", "y.grid"],
  ["niceX", "x.nice"],
  ["niceY", "y.nice"],
  ["zeroX", "x.zero"],
  ["zeroY", "y.zero"],
  ["reverseX", "x.reverse"],
  ["reverseY", "y.reverse"],
  ["ticksX", "x.ticks"],
  ["ticksY", "y.ticks"],
  ["tickFormatX", "x.tickFormat"],
  ["tickFormatY", "y.tickFormat"],
  ["tickFormatFX", "fx.tickFormat"],
  ["tickFormatFY", "fy.tickFormat"],
  ["tickFormatColor", "color.tickFormat"],
  ["tickRotateX", "x.tickRotate"],
  ["tickRotateY", "y.tickRotate"],
  ["tickSizeX", "x.tickSize"],
  ["tickSizeY", "y.tickSize"],
  ["labelX", "x.label"],
  ["labelY", "y.label"],
  ["labelAnchorX", "x.labelAnchor"],
  ["labelAnchorY", "y.labelAnchor"],
  ["labelOffsetX", "x.labelOffset"],
  ["labelOffsetY", "y.labelOffset"],
  ["scaleColor", "color.type"],
  ["domainColor", "color.domain"],
  ["rangeColor", "color.range"],
  ["schemeColor", "color.scheme"],
  ["interpolateColor", "color.interpolate"],
  ["zeroColor", "color.zero"],
  ["domainR", "r.domain"],
  ["rangeR", "r.range"],
  ["labelFX", "fx.label"],
  ["labelFY", "fy.label"],
  ["reverseFX", "fx.reverse"],
  ["reverseFY", "fy.reverse"],
  ["marginTopFacet", "facet.marginTop"],
  ["marginRightFacet", "facet.marginRight"],
  ["marginBottomFacet", "facet.marginBottom"],
  ["marginLeftFacet", "facet.marginLeft"],
  ["gridFacet", "facet.grid"],
  ["labelFacet", "facet.label"]
]);
function sY(e, t, n) {
  for (let i = 0; i < t.length; ++i) {
    const r = t[i];
    i === t.length - 1 ? e[r] = n : e = e[r] || (e[r] = {});
  }
}
async function oY(e) {
  const t = { marks: [] }, n = [], { attributes: i, marks: r } = e;
  for (const a in i) {
    const c = rY.get(a);
    if (c == null)
      throw new Error(`Unrecognized plot attribute: ${a}`);
    const u = i[a];
    typeof u == "symbol" ? n.push(a) : u !== void 0 && sY(t, c.split("."), u);
  }
  const s = [];
  for (const a of r)
    for (const { type: c, data: u, options: l } of a.plotSpecs())
      c === "frame" || c === "hexgrid" ? t.marks.push(eb[c](l)) : t.marks.push(eb[c](u, l)), s.push(a.index);
  aY(t, e);
  const o = xm(t);
  cY(o, s), n.forEach((a) => {
    var u;
    const c = i[a];
    if (c === Vp) {
      let l;
      switch (a) {
        case "domainX":
          l = "x";
          break;
        case "domainY":
          l = "y";
          break;
        case "domainFX":
          l = "fx";
          break;
        case "domainFY":
          l = "fy";
          break;
        case "domainColor":
          l = "color";
          break;
        case "domainR":
          l = "r";
          break;
        default:
          throw new Error(`Unsupported fixed attribute: ${a}`);
      }
      const f = (u = o.scale(l)) == null ? void 0 : u.domain;
      f && e.setAttribute(a, f);
    } else
      throw new Error(`Unrecognized symbol: ${c}`);
  });
  for (const a of e.interactors)
    await a.init(o);
  return o;
}
function aY(e, t) {
  const { marks: n } = t;
  Wc("x", e, n, ["x", "x1", "x2"]), Wc("y", e, n, ["y", "y1", "y2"]), Wc("fx", e, n), Wc("fy", e, n);
}
function Wc(e, t, n, i = [e]) {
  const r = t[e] || {};
  if (r.axis === null || r.label !== void 0)
    return;
  const s = n.map((l) => l.channelField(i));
  if (s.every((l) => l == null))
    return;
  let o, a, c;
  for (let l = 0; l < s.length; ++l) {
    const { column: f, label: h } = s[l] || {};
    f === void 0 && h === void 0 || (o === void 0 && a === void 0 ? (o = f, a = h, c = uY(n[l].data, i) || "number") : a !== h ? a = void 0 : o !== f && (o = void 0));
  }
  let u = a || o;
  if (u !== void 0) {
    if ((c === "number" || c === "date") && (e === "x" || e === "y")) {
      r.percent && (u = `${u} (%)`);
      const l = (e === "x" ? 1 : -1) * (r.reverse ? -1 : 1);
      e === "x" || r.labelAnchor === "center" ? u = e === "x" == l < 0 ? `← ${u}` : `${u} →` : u = `${l < 0 ? "↑ " : "↓ "}${u}`;
    }
    t[e] = { ...r, label: u };
  }
}
function cY(e, t) {
  const n = e.querySelectorAll('g[aria-label="facet"]');
  if (n.length)
    for (const i of n)
      ab(i, t);
  else
    ab(e, t);
}
function ab(e, t) {
  let n = -1;
  for (const i of e.children) {
    const r = i.getAttribute("aria-label") || "";
    i.nodeName === "style" || r.includes("-axis") || r.includes("-grid") || i.setAttribute("data-index", t[++n]);
  }
}
function uY(e, t) {
  for (const n of e)
    for (let i = 0; i < t.length; ++i) {
      const r = n[t[i]];
      if (r != null)
        return r instanceof Date ? "date" : typeof r;
    }
}
const lY = {
  width: 640,
  marginLeft: 50,
  marginRight: 20,
  marginTop: 30,
  marginBottom: 30
};
class fY {
  constructor(t) {
    this.attributes = { ...lY }, this.listeners = null, this.interactors = [], this.legends = [], this.marks = [], this.markset = null, this.element = t || document.createElement("div"), this.element.setAttribute("class", "plot"), this.element.value = this, this.queue = /* @__PURE__ */ new Set(), this.params = /* @__PURE__ */ new Map();
  }
  margins() {
    return {
      left: this.getAttribute("marginLeft"),
      top: this.getAttribute("marginTop"),
      bottom: this.getAttribute("marginBottom"),
      right: this.getAttribute("marginRight")
    };
  }
  innerWidth() {
    const { left: t, right: n } = this.margins();
    return this.getAttribute("width") - t - n;
  }
  innerHeight() {
    const { top: t, bottom: n } = this.margins();
    return this.getAttribute("height") - t - n;
  }
  pending(t) {
    this.queue.add(t);
  }
  update(t) {
    return this.queue.delete(t), this.queue.size === 0 && !this.pendingRender && (this.pendingRender = !0, requestAnimationFrame(() => this.render())), this;
  }
  async render() {
    this.pendingRender = !1;
    const t = await oY(this), n = this.legends.flatMap(({ legend: i, include: r }) => {
      const s = i.init(t);
      return r ? s : [];
    });
    this.element.replaceChildren(t, ...n);
  }
  getAttribute(t) {
    return this.attributes[t];
  }
  setAttribute(t, n, i) {
    var r, s;
    return aw(this.attributes[t], n) ? (n === void 0 ? delete this.attributes[t] : this.attributes[t] = n, i != null && i.silent || (s = (r = this.listeners) == null ? void 0 : r.get(t)) == null || s.forEach((o) => o(t, n)), !0) : !1;
  }
  addAttributeListener(t, n) {
    const i = this.listeners || (this.listeners = /* @__PURE__ */ new Map());
    return i.has(t) || i.set(t, /* @__PURE__ */ new Set()), i.get(t).add(n), this;
  }
  removeAttributeListener(t, n) {
    var i, r;
    return (r = (i = this.listeners) == null ? void 0 : i.get(t)) == null ? void 0 : r.delete(n);
  }
  addParams(t, n) {
    const { params: i } = this;
    for (const r of n)
      i.has(r) ? i.get(r).push(t) : (i.set(r, [t]), r.addEventListener("value", Kl(() => Promise.allSettled(
        i.get(r).map((s) => s.requestQuery())
      ))));
  }
  addMark(t) {
    return t.setPlot(this, this.marks.length), this.marks.push(t), this.markset = null, this;
  }
  get markSet() {
    return this.markset || (this.markset = new Set(this.marks));
  }
  addInteractor(t) {
    return this.interactors.push(t), this;
  }
  addLegend(t, n = !0) {
    t.setPlot(this), this.legends.push({ legend: t, include: n });
  }
}
function hY(...e) {
  const t = new fY();
  return e.flat().forEach((n) => n(t)), t.marks.forEach((n) => So().connect(n)), t.element;
}
function dY(...e) {
  return new A4(e.flat(), { type: "vertical" }).element;
}
function pY(...e) {
  return new A4(e.flat(), { type: "horizontal" }).element;
}
function $4(e = "width", t = 10) {
  const n = document.createElement("span");
  n.style.display = "inline-block", n.style[e] = Number.isNaN(+t) ? t : `${t}px`;
  const i = { element: n };
  return n.value = i, n;
}
function mY(e) {
  return $4("height", e);
}
function yY(e) {
  return $4("width", e);
}
const gY = (e) => e && typeof e == "object" && !Array.isArray(e);
class bY extends Ga {
  constructor({
    filterBy: t,
    from: n,
    column: i,
    label: r = i,
    format: s = (u) => u,
    // TODO
    options: o,
    value: a,
    as: c
  } = {}) {
    var l, f, h, d;
    super(t), this.from = n, this.column = i, this.selection = c, this.format = s, this.element = document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this;
    const u = document.createElement("label");
    u.innerText = r || i, this.element.appendChild(u), this.select = document.createElement("select"), o && (this.data = o.map((p) => gY(p) ? p : { value: p }), this.update()), a = a ?? ((l = this.selection) == null ? void 0 : l.value) ?? ((h = (f = this.data) == null ? void 0 : f[0]) == null ? void 0 : h.value), this.select.value = a, ((d = this.selection) == null ? void 0 : d.value) === void 0 && this.publish(a), this.element.appendChild(this.select), this.selection && (this.select.addEventListener("input", () => {
      this.publish(this.selectedValue() || null);
    }), Zr(this.selection) || this.selection.addEventListener("value", (p) => {
      p !== this.select.value && this.selectedValue(p);
    }));
  }
  selectedValue(t) {
    if (arguments.length === 0) {
      const n = this.select.selectedIndex;
      return this.data[n].value;
    } else
      this.select.value = String(t);
  }
  publish(t) {
    const { selection: n, column: i } = this;
    Zr(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: t ? Hl(i, Ha(t)) : null
    }) : sr(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return n ? mt.from(n).select({ value: i }).distinct().where(t).orderby(i) : null;
  }
  queryResult(t) {
    return this.data = [{ value: "", label: "All" }, ...t], this;
  }
  update() {
    var r;
    const { data: t, format: n, select: i } = this;
    i.replaceChildren();
    for (const { value: s, label: o } of t) {
      const a = document.createElement("option");
      a.setAttribute("value", s), a.innerText = o ?? n(s), this.select.appendChild(a);
    }
    return this.selection && (this.select.value = ((r = this.selection) == null ? void 0 : r.value) || ""), this;
  }
}
const wY = { contains: R5, prefix: U5, suffix: z5, regexp: k5 };
let _Y = 0;
class vY extends Ga {
  constructor({
    filterBy: t,
    from: n,
    column: i,
    label: r,
    type: s,
    as: o
  } = {}) {
    if (super(t), this.id = "search_" + ++_Y, this.type = s, this.from = n, this.column = i, this.selection = o, this.element = document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this, r) {
      const a = document.createElement("label");
      a.setAttribute("for", this.id), a.innerText = r, this.element.appendChild(a);
    }
    this.searchbox = document.createElement("input"), this.searchbox.setAttribute("id", this.id), this.searchbox.setAttribute("type", "text"), this.searchbox.setAttribute("placeholder", "Query"), this.element.appendChild(this.searchbox), this.selection && (this.searchbox.addEventListener("input", () => {
      this.publish(this.searchbox.value || null);
    }), Zr(this.selection) || this.selection.addEventListener("value", (a) => {
      a !== this.searchbox.value && (this.searchbox.value = a);
    }));
  }
  publish(t) {
    const { selection: n, column: i, type: r } = this;
    Zr(n) ? n.update({
      source: this,
      schema: { type: r },
      value: t,
      predicate: t ? wY[r](i, Ha(t)) : null
    }) : sr(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return n ? mt.from(n).select({ list: i }).distinct().where(t) : null;
  }
  queryResult(t) {
    return this.data = t, this;
  }
  update() {
    const t = document.createElement("datalist"), n = `${this.id}_list`;
    t.setAttribute("id", n);
    for (const i of this.data) {
      const r = document.createElement("option");
      r.setAttribute("value", i.list), t.append(r);
    }
    return this.datalist && this.datalist.remove(), this.element.appendChild(this.datalist = t), this.searchbox.setAttribute("list", n), this;
  }
}
let xY = 0;
class SY extends Ga {
  constructor({
    filterBy: t,
    as: n,
    min: i,
    max: r,
    step: s,
    from: o,
    column: a,
    label: c = a,
    value: u = n == null ? void 0 : n.value
  } = {}) {
    var l;
    if (super(t), this.id = "slider_" + ++xY, this.from = o, this.column = a || "value", this.selection = n, this.min = i, this.max = r, this.step = s, this.element = document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this, c) {
      const f = document.createElement("label");
      f.setAttribute("for", this.id), f.innerText = c, this.element.appendChild(f);
    }
    this.slider = document.createElement("input"), this.slider.setAttribute("id", this.id), this.slider.setAttribute("type", "range"), i != null && this.slider.setAttribute("min", i), r != null && this.slider.setAttribute("max", r), s != null && this.slider.setAttribute("step", s), u != null && (this.slider.setAttribute("value", u), ((l = this.selection) == null ? void 0 : l.value) === void 0 && this.publish(u)), this.element.appendChild(this.slider), this.selection && (this.slider.addEventListener("input", () => {
      this.publish(+this.slider.value);
    }), Zr(this.selection) || this.selection.addEventListener("value", (f) => {
      f !== +this.slider.value && (this.slider.value = f);
    }));
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return !n || this.min != null && this.max != null ? null : mt.select({ min: ro(i), max: io(i) }).from(n).where(t);
  }
  queryResult(t) {
    const { min: n, max: i } = Array.from(t)[0];
    return this.min == null && this.slider.setAttribute("min", n), this.max == null && this.slider.setAttribute("max", i), this.step == null && this.slider.setAttribute("step", (i - n) / 500), this;
  }
  publish(t) {
    const { selection: n, column: i } = this;
    Zr(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: Hl(i, Ha(t))
    }) : sr(this.selection) && n.update(t);
  }
}
const I4 = Jm((e) => {
  const t = Km(e);
  return (n) => n == null ? "" : typeof n == "number" ? t(n) : n instanceof Date ? T4(n) : `${n}`;
}), Km = Jm((e) => (t) => t === 0 ? "0" : t.toLocaleString(e));
I4();
Km();
function T4(e) {
  return v3(e, "Invalid Date");
}
function Jm(e) {
  let t = Jm, n;
  return (i = "en") => i === t ? n : n = e(t = i);
}
let MY = -1;
class AY extends Ga {
  constructor({
    filterBy: t,
    from: n,
    columns: i = ["*"],
    format: r,
    rowBatch: s = 100,
    width: o,
    height: a = 500
  } = {}) {
    super(t), this.id = `table-${++MY}`, this.from = n, this.columns = i, this.format = r, this.offset = 0, this.limit = +s, this.pending = !1, this.sortHeader = null, this.sortColumn = null, this.sortDesc = !1, this.element = document.createElement("div"), this.element.setAttribute("id", this.id), this.element.value = this, o && (this.element.style.maxWidth = `${o}px`), this.element.style.maxHeight = `${a}px`, this.element.style.overflow = "auto";
    let c = -1;
    this.element.addEventListener("scroll", (u) => {
      var y;
      const { pending: l, loaded: f } = this, { scrollHeight: h, scrollTop: d, clientHeight: p } = u.target, g = d < c;
      if (c = d, !(g || l || f) && h - d < 2 * p) {
        this.pending = !0, this.offset += this.limit;
        const m = this.queryInternal((y = this.filterBy) == null ? void 0 : y.predicate(this));
        this.requestQuery(m);
      }
    }), this.tbl = document.createElement("table"), this.element.appendChild(this.tbl), this.head = document.createElement("thead"), this.tbl.appendChild(this.head), this.body = document.createElement("tbody"), this.tbl.appendChild(this.body), this.style = document.createElement("style"), this.element.appendChild(this.style);
  }
  fields() {
    return this.columns.map((t) => rp(this.from, t));
  }
  fieldStats(t) {
    this.stats = t;
    const n = this.head;
    n.innerHTML = "";
    const i = document.createElement("tr");
    for (const { column: r } of t) {
      const s = document.createElement("th");
      s.addEventListener("click", (o) => this.sort(o, r)), s.appendChild(document.createElement("span")), s.appendChild(document.createTextNode(r)), i.appendChild(s);
    }
    return n.appendChild(i), this.formats = $Y(this.format, t), this.style.innerText = TY(this.id, IY({}, t)), this;
  }
  query(t) {
    return this.offset = 0, this.queryInternal(t);
  }
  queryInternal(t = []) {
    const { from: n, limit: i, offset: r, stats: s, sortColumn: o, sortDesc: a } = this;
    return mt.from(n).select(s.map((c) => c.column)).where(t).orderby(o ? a ? N5(o) : o : []).limit(i).offset(r);
  }
  queryResult(t) {
    return this.pending || (this.loaded = !1, this.body.replaceChildren()), this.data = t, this;
  }
  update() {
    const { body: t, formats: n, data: i, stats: r, limit: s } = this, o = r.length;
    let a = 0;
    for (const c of i) {
      ++a;
      const u = document.createElement("tr");
      for (let l = 0; l < o; ++l) {
        const f = c[r[l].column], h = document.createElement("td");
        h.innerText = f == null ? "" : n[l](f), u.appendChild(h);
      }
      t.appendChild(u);
    }
    return a < s && (this.loaded = !0), this.pending = !1, this;
  }
  sort(t, n) {
    var o;
    n === this.sortColumn ? this.sortDesc = !this.sortDesc : (this.sortColumn = n, this.sortDesc = !1);
    const i = t.currentTarget, r = this.sortHeader;
    r === i && t.metaKey ? (r.firstChild.textContent = "", this.sortHeader = null, this.sortColumn = null) : (r && (r.firstChild.textContent = ""), this.sortHeader = i, i.firstChild.textContent = this.sortDesc ? "▾" : "▴");
    const s = this.query((o = this.filterBy) == null ? void 0 : o.predicate(this));
    this.requestQuery(s);
  }
}
function $Y(e = {}, t, n) {
  return t.map(({ column: i, type: r }) => {
    if (i in e)
      return e[i];
    switch (r) {
      case "number":
        return Km(n);
      case "date":
        return T4;
      default:
        return I4(n);
    }
  });
}
function IY(e = {}, t) {
  return t.map(({ column: n, type: i }) => n in e ? e[n] : i === "number" ? "right" : "left");
}
function TY(e, t) {
  const n = [];
  return t.forEach((i, r) => {
    i !== "left" && n.push(`#${e} tr>:nth-child(${r + 1}) {text-align:${i}}`);
  }), n.join(" ");
}
function sh(e, t) {
  const n = new e(t);
  return So().connect(n), n.element;
}
const EY = (e) => sh(bY, e), NY = (e) => sh(vY, e), OY = (e) => sh(SY, e), FY = (e) => sh(AY, e), DY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  menu: EY,
  search: NY,
  slider: OY,
  table: FY
}, Symbol.toStringTag, { value: "Module" })), BY = /* @__PURE__ */ new Map([
  ["intersect", () => Zi.intersect()],
  ["crossfilter", () => Zi.crossfilter()],
  ["union", () => Zi.union()],
  ["single", () => Zi.single()],
  ["value", (e) => Mo.value(e)]
]), LY = /* @__PURE__ */ new Map([
  ["plot", { type: Hs, parse: E4 }],
  ["mark", { type: Qi, parse: iq }],
  ["legend", { type: Qi, parse: N4 }],
  ["hconcat", { type: Hs, parse: nq }],
  ["vconcat", { type: Hs, parse: eq }],
  ["hspace", { type: cb, parse: JY }],
  ["vspace", { type: cb, parse: QY }],
  ["input", { type: Qi, parse: tq }]
]), CY = /* @__PURE__ */ new Map([
  ["table", WY],
  ["parquet", HY],
  ["csv", GY],
  ["json", ZY]
]), kY = /* @__PURE__ */ new Map([
  ["avg", Y5],
  ["bin", Oy],
  ["count", aa],
  ["dateMonth", NA],
  ["dateMonthDay", OA],
  ["dateDay", FA],
  ["bin", Oy],
  ["max", io],
  ["median", q5],
  ["min", ro],
  ["mode", j5],
  ["quantile", V5],
  ["sum", Zl]
]), RY = new Map(Object.entries(DY)), UY = new Map(Object.entries(iY)), zY = new Map(Object.entries(j$)), PY = new Map(Object.entries(QP));
function YY(e, t) {
  return e = Qi(e) ? JSON.parse(e) : e, new qY(t).parse(e);
}
class qY {
  constructor({
    specParsers: t = LY,
    paramParsers: n = BY,
    formats: i = CY,
    transforms: r = kY,
    attributes: s = zY,
    interactors: o = PY,
    legends: a = UY,
    inputs: c = RY,
    params: u = []
  } = {}) {
    this.specParsers = t, this.paramParsers = n, this.formats = i, this.transforms = r, this.attributes = s, this.interactors = o, this.legends = a, this.inputs = c, this.params = new Map(u), this.postQueue = [];
  }
  after(t) {
    this.postQueue.push(t);
  }
  maybeParam(t, n = () => Mo.value()) {
    const { params: i } = this, r = uq(t);
    if (r) {
      if (i.has(r))
        return i.get(r);
      {
        const s = n();
        return i.set(r, s), s;
      }
    }
    return t;
  }
  maybeSelection(t) {
    return this.maybeParam(t, () => Zi.intersect());
  }
  maybeTransform(t) {
    if (F4(t)) {
      if (t.expr)
        return q(t.expr, [], t.label);
      {
        const { transforms: n } = this, [i] = Object.keys(t), r = n.get(i);
        if (r) {
          const s = i === "count" ? [] : [t[i]].flat();
          return r(...s);
        }
      }
    }
  }
  async parse(t) {
    const { data: n = {}, defaults: i = {}, params: r, ...s } = t;
    await Promise.allSettled(
      Object.keys(n).map(async (a) => {
        const c = await VY(a, n[a], this);
        return c ? So().exec(c) : null;
      })
    ), this.defaults = Object.keys(i).map((a) => O4(i, a, this));
    for (const a in r)
      this.params.set(a, KY(r[a], this));
    const o = Qm(s, this);
    return this.postQueue.forEach((a) => a()), this.postQueue = [], this.defaults = {}, o;
  }
  createFrom(t, n, i, r) {
    const s = mt.select(i).from(n).where(r);
    return this.create(t, s);
  }
  create(t, n) {
    return `CREATE TEMP TABLE IF NOT EXISTS "${t}" AS ${n}`;
  }
}
function VY(e, t, n) {
  Hs(t) && (t = { format: "json", data: t }), Qi(t) && (t = { format: "table", query: t });
  const i = jY(t), r = n.formats.get(i);
  if (r)
    return r(e, t, n);
  ri("Unrecognized data format.", t);
}
function jY(e) {
  return e.format || XY(e.file) || "table";
}
function XY(e) {
  const t = e == null ? void 0 : e.lastIndexOf(".");
  return t > 0 ? e.slice(t + 1) : null;
}
function WY(e, t, n) {
  if (t.query)
    return n.create(e, t.query);
}
function HY(e, t, n) {
  const { file: i, select: r = "*" } = t;
  return n.createFrom(
    e,
    q(`read_parquet('${i}')`),
    r
  );
}
function GY(e, t, n) {
  const { file: i, format: r, select: s = "*", ...o } = t, a = Object.entries({ sample_size: -1, ...o }).map(([c, u]) => {
    const l = typeof u, f = l === "boolean" ? String(u).toUpperCase() : l === "string" ? `'${u}'` : u;
    return `${c.toUpperCase()}=${f}`;
  }).join(", ");
  return n.createFrom(
    e,
    q(`read_csv_auto('${i}', ${a})`),
    s
  );
}
async function ZY(e, t, n) {
  const { data: i, file: r, select: s = "*" } = t, o = i || await fetch(r).then((a) => a.json());
  return n.createFrom(e, q(AA(o)), s);
}
function KY(e, t) {
  e = F4(e) ? e : { value: e };
  const { select: n = "value", value: i } = e, r = t.paramParsers.get(n);
  return r || ri(`Unrecognized param type: ${n}`, e), r(i);
}
function Qm(e, t) {
  for (const [n, { type: i, parse: r }] of t.specParsers) {
    const s = e[n];
    if (s != null) {
      if (i(s))
        return r(e, t);
      ri(`Invalid property type: ${n}`, e);
    }
  }
  ri("Invalid specification.", e);
}
function JY(e) {
  return yY(+e.hspace);
}
function QY(e) {
  return mY(+e.vspace);
}
function tq(e, t) {
  const { input: n, ...i } = e, r = t.inputs.get(n);
  pc(r) || ri(`Unrecognized input: ${n}`, e);
  for (const s in i)
    i[s] = t.maybeSelection(i[s]);
  return r(i);
}
function eq(e, t) {
  return dY(e.vconcat.map((n) => Qm(n, t)));
}
function nq(e, t) {
  return pY(e.hconcat.map((n) => Qm(n, t)));
}
function E4(e, t) {
  const { plot: n, ...i } = e, r = t.defaults.concat(
    Object.keys(i).map((o) => O4(e, o, t))
  ), s = n.map((o) => rq(o, t));
  return hY(r, s);
}
function iq(e, t) {
  return E4({ plot: [e] }, t);
}
function N4(e, t) {
  const { legend: n, ...i } = e, r = `legend${n[0].toUpperCase()}${n.slice(1)}`, s = t.legends.get(r);
  pc(s) || ri(`Unrecognized legend type: ${n}`, e);
  for (const o in i)
    i[o] = t.maybeSelection(i[o]);
  return s(i);
}
function O4(e, t, n) {
  const i = n.attributes.get(t);
  pc(i) || ri(`Unrecognized attribute: ${t}`, e);
  const r = e[t], s = r === "Fixed" ? Vp : n.maybeParam(r);
  return i(s);
}
function rq(e, t) {
  return Qi(e.mark) ? sq(e, t) : Qi(e.legend) ? N4(e, t) : Qi(e.select) ? cq(e, t) : ri("Invalid plot entry.", e);
}
function sq(e, t) {
  const { mark: n, data: i, ...r } = e, s = IP[n];
  pc(s) || ri(`Unrecognized mark type: ${n}`, e);
  const o = oq(i, t);
  for (const a in r)
    r[a] = aq(r[a], t);
  return o ? s(o, r) : s(r);
}
function oq(e, t) {
  if (!e)
    return null;
  if (Hs(e))
    return e;
  const { from: n, ...i } = e;
  for (const r in i)
    i[r] = t.maybeSelection(i[r]);
  return X$(n, i);
}
function aq(e, t) {
  return t.maybeTransform(e) || t.maybeParam(e);
}
function cq(e, t) {
  const { select: n, ...i } = e, r = t.interactors.get(n);
  pc(r) || ri(`Unrecognized interactor type: ${n}`, e);
  for (const s in i)
    i[s] = t.maybeSelection(i[s]);
  return r(i);
}
function uq(e) {
  const t = typeof e;
  return t === "object" ? e == null ? void 0 : e.param : t === "string" ? lq(e) : null;
}
function lq(e) {
  return (e == null ? void 0 : e[0]) === "$" ? e.slice(1) : null;
}
function Hs(e) {
  return Array.isArray(e);
}
function F4(e) {
  return e !== null && typeof e == "object" && !Hs(e);
}
function cb(e) {
  return typeof e == "number";
}
function Qi(e) {
  return typeof e == "string";
}
function pc(e) {
  return typeof e == "function";
}
function ri(e, t) {
  throw Object.assign(Error(e), { data: t });
}
let fq = 0;
async function Iq(e) {
  e.el.classList.add("mosaic-widget");
  const t = () => e.model.get("spec"), n = {};
  function i(o, a, c) {
    const u = fq++;
    n[u] = { query: o, resolve: a, reject: c }, e.model.send({ ...o, queryId: u });
  }
  const r = {
    query(o) {
      return new Promise((a, c) => i(o, a, c));
    }
  };
  async function s() {
    const o = t();
    console.log("Setting spec:", o), e.el.replaceChildren(await YY(o));
  }
  e.model.on("change:spec", () => s()), e.model.on("msg:custom", (o, a) => {
    console.group(`query ${o.queryId}`), console.log("received message", o, a);
    const c = n[o.queryId];
    switch (delete n[o.queryId], console.log("resolving query", c.query.sql), o.type) {
      case "arrow": {
        const u = ip(a[0].buffer);
        console.log("table", u), c.resolve(u);
        break;
      }
      case "json": {
        console.log("json", o.result), c.resolve(o.result);
        break;
      }
      default: {
        c.resolve({});
        break;
      }
    }
    console.groupEnd("query");
  }), So().databaseClient(r), s();
}
export {
  Iq as render
};
