const x1 = {};
function J2(e, t = !1) {
  let n, r, i = x1;
  function s(u) {
    n = e(u).then(() => {
      if (r) {
        const { value: l } = r;
        r = null, s(l);
      } else
        n = null;
    });
  }
  function o(u) {
    r = { event: u };
  }
  function a(u) {
    n ? o(u) : s(u);
  }
  function c(u) {
    i !== u && requestAnimationFrame(() => {
      const l = i;
      i = x1, a(l);
    }), i = u;
  }
  return t ? c : a;
}
class Yc {
  /**
   * 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 = J2(() => this.requestQuery(), !0), this._coordinator = null;
  }
  /**
   * Return this client's connected coordinator.
   */
  get coordinator() {
    return this._coordinator;
  }
  /**
   * Set this client's connected coordinator.
   */
  set coordinator(t) {
    this._coordinator = t;
  }
  /**
   * 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 info for this client.
   * @returns {this}
   */
  fieldInfo() {
    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.
   *
   * @param {*} data the query result
   * @returns {this}
   */
  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 r;
    const n = t || this.query((r = this.filterBy) == null ? void 0 : r.predicate(this));
    return this._coordinator.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 gt(e, t, n, r) {
  function i(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(r.next(l));
      } catch (f) {
        o(f);
      }
    }
    function c(l) {
      try {
        u(r.throw(l));
      } catch (f) {
        o(f);
      }
    }
    function u(l) {
      l.done ? s(l.value) : i(l.value).then(a, c);
    }
    u((r = r.apply(e, t || [])).next());
  });
}
function S1(e) {
  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
  if (n)
    return n.call(e);
  if (e && typeof e.length == "number")
    return {
      next: function() {
        return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e };
      }
    };
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function vt(e) {
  return this instanceof vt ? (this.v = e, this) : new vt(e);
}
function ur(e, t, n) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var r = n.apply(e, t || []), i, s = [];
  return i = {}, o("next"), o("throw"), o("return"), i[Symbol.asyncIterator] = function() {
    return this;
  }, i;
  function o(h) {
    r[h] && (i[h] = function(d) {
      return new Promise(function(p, y) {
        s.push([h, d, p, y]) > 1 || a(h, d);
      });
    });
  }
  function a(h, d) {
    try {
      c(r[h](d));
    } catch (p) {
      f(s[0][3], p);
    }
  }
  function c(h) {
    h.value instanceof vt ? 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 ml(e) {
  var t, n;
  return t = {}, r("next"), r("throw", function(i) {
    throw i;
  }), r("return"), t[Symbol.iterator] = function() {
    return this;
  }, t;
  function r(i, s) {
    t[i] = e[i] ? function(o) {
      return (n = !n) ? { value: vt(e[i](o)), done: !1 } : s ? s(o) : o;
    } : s;
  }
}
function Ao(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 S1 == "function" ? S1(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
    return this;
  }, n);
  function r(s) {
    n[s] = e[s] && function(o) {
      return new Promise(function(a, c) {
        o = e[s](o), i(a, c, o.done, o.value);
      });
    };
  }
  function i(s, o, a, c) {
    Promise.resolve(c).then(function(u) {
      s({ value: u, done: a });
    }, o);
  }
}
const vN = new TextDecoder("utf-8"), Yp = (e) => vN.decode(e), _N = new TextEncoder(), Ey = (e) => _N.encode(e), xN = (e) => typeof e == "number", SN = (e) => typeof e == "boolean", De = (e) => typeof e == "function", Rn = (e) => e != null && Object(e) === e, hc = (e) => Rn(e) && De(e.then), Mh = (e) => Rn(e) && De(e[Symbol.iterator]), Ny = (e) => Rn(e) && De(e[Symbol.asyncIterator]), Wp = (e) => Rn(e) && Rn(e.schema), Z2 = (e) => Rn(e) && "done" in e && "value" in e, K2 = (e) => Rn(e) && De(e.stat) && xN(e.fd), Q2 = (e) => Rn(e) && Dy(e.body), tv = (e) => "_getDOMStream" in e && "_getNodeStream" in e, Dy = (e) => Rn(e) && De(e.cancel) && De(e.getReader) && !tv(e), ev = (e) => Rn(e) && De(e.read) && De(e.pipe) && SN(e.readable) && !tv(e), MN = (e) => Rn(e) && De(e.clear) && De(e.bytes) && De(e.position) && De(e.setPosition) && De(e.capacity) && De(e.getBufferIdentifier) && De(e.createLong), Oy = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function AN(e) {
  const t = e[0] ? [e[0]] : [];
  let n, r, i, 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: i } = o, { byteOffset: r, byteLength: s } = a, n + i < r || r + s < n) {
      a && (t[++u] = a);
      continue;
    }
    t[u] = new Uint8Array(o.buffer, n, r - n + s);
  }
  return t;
}
function M1(e, t, n = 0, r = t.byteLength) {
  const i = e.byteLength, s = new Uint8Array(e.buffer, e.byteOffset, i), o = new Uint8Array(t.buffer, t.byteOffset, Math.min(r, i));
  return s.set(o, n), e;
}
function yr(e, t) {
  const n = AN(e), r = n.reduce((l, f) => l + f.byteLength, 0);
  let i, s, o, a = 0, c = -1;
  const u = Math.min(t || Number.POSITIVE_INFINITY, r);
  for (const l = n.length; ++c < l; ) {
    if (i = n[c], s = i.subarray(0, Math.min(i.length, u - a)), u <= a + s.length) {
      s.length < i.length ? n[c] = i.subarray(s.length) : s.length === i.length && c++, o ? M1(o, s, a) : o = s;
      break;
    }
    M1(o || (o = new Uint8Array(u)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), r - (o ? o.byteLength : 0)];
}
function Pt(e, t) {
  let n = Z2(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = Ey(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof Oy ? new e(n) : MN(n) ? Pt(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 Oa = (e) => Pt(Int32Array, e), Ft = (e) => Pt(Uint8Array, e), Xp = (e) => (e.next(), e);
function* $N(e, t) {
  const n = function* (i) {
    yield i;
  }, r = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof Oy ? n(t) : Mh(t) ? t : n(t);
  return yield* Xp(function* (i) {
    let s = null;
    do
      s = i.next(yield Pt(e, s));
    while (!s.done);
  }(r[Symbol.iterator]())), new e();
}
const IN = (e) => $N(Uint8Array, e);
function nv(e, t) {
  return ur(this, arguments, function* () {
    if (hc(t))
      return yield vt(yield vt(yield* ml(Ao(nv(e, yield vt(t))))));
    const r = function(o) {
      return ur(this, arguments, function* () {
        yield yield vt(yield vt(o));
      });
    }, i = function(o) {
      return ur(this, arguments, function* () {
        yield vt(yield* ml(Ao(Xp(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 Oy ? r(t) : Mh(t) ? i(t) : Ny(t) ? t : r(t);
    return yield vt(
      // otherwise if AsyncIterable, use it
      yield* ml(Ao(Xp(function(o) {
        return ur(this, arguments, function* () {
          let a = null;
          do
            a = yield vt(o.next(yield yield vt(Pt(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield vt(new e());
  });
}
const TN = (e) => nv(Uint8Array, e);
function EN(e, t) {
  let n = 0;
  const r = e.length;
  if (r !== t.length)
    return !1;
  if (r > 0)
    do
      if (e[n] !== t[n])
        return !1;
    while (++n < r);
  return !0;
}
const pn = {
  fromIterable(e) {
    return Fu(NN(e));
  },
  fromAsyncIterable(e) {
    return Fu(DN(e));
  },
  fromDOMStream(e) {
    return Fu(ON(e));
  },
  fromNodeStream(e) {
    return Fu(kN(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');
  }
}, Fu = (e) => (e.next(), e);
function* NN(e) {
  let t, n = !1, r = [], i, s, o, a = 0;
  function c() {
    return s === "peek" ? yr(r, o)[0] : ([i, r, a] = yr(r, o), i);
  }
  ({ cmd: s, size: o } = yield null);
  const u = IN(e)[Symbol.iterator]();
  try {
    do
      if ({ done: t, value: i } = Number.isNaN(o - a) ? u.next() : u.next(o - a), !t && i.byteLength > 0 && (r.push(i), a += i.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 DN(e) {
  return ur(this, arguments, function* () {
    let n, r = !1, i = [], s, o, a, c = 0;
    function u() {
      return o === "peek" ? yr(i, a)[0] : ([s, i, c] = yr(i, a), s);
    }
    ({ cmd: o, size: a } = yield yield vt(null));
    const l = TN(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield vt(l.next()) : yield vt(l.next(a - c)), !n && s.byteLength > 0 && (i.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield vt(u()));
          while (a < c);
      while (!n);
    } catch (f) {
      (r = !0) && typeof l.throw == "function" && (yield vt(l.throw(f)));
    } finally {
      r === !1 && typeof l.return == "function" && (yield vt(l.return(new Uint8Array(0))));
    }
    return yield vt(null);
  });
}
function ON(e) {
  return ur(this, arguments, function* () {
    let n = !1, r = !1, i = [], s, o, a, c = 0;
    function u() {
      return o === "peek" ? yr(i, a)[0] : ([s, i, c] = yr(i, a), s);
    }
    ({ cmd: o, size: a } = yield yield vt(null));
    const l = new LN(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield vt(l.read()) : yield vt(l.read(a - c)), !n && s.byteLength > 0 && (i.push(Ft(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield vt(u()));
          while (a < c);
      while (!n);
    } catch (f) {
      (r = !0) && (yield vt(l.cancel(f)));
    } finally {
      r === !1 ? yield vt(l.cancel()) : e.locked && l.releaseLock();
    }
    return yield vt(null);
  });
}
class LN {
  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 gt(this, void 0, void 0, function* () {
      const { reader: n, source: r } = this;
      n && (yield n.cancel(t).catch(() => {
      })), r && r.locked && this.releaseLock();
    });
  }
  read(t) {
    return gt(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 = Ft(n)), n;
    });
  }
}
const Rd = (e, t) => {
  const n = (i) => r([t, i]);
  let r;
  return [t, n, new Promise((i) => (r = i) && e.once(t, n))];
};
function kN(e) {
  return ur(this, arguments, function* () {
    const n = [];
    let r = "error", i = !1, s = null, o, a, c = 0, u = [], l;
    function f() {
      return o === "peek" ? yr(u, a)[0] : ([l, u, c] = yr(u, a), l);
    }
    if ({ cmd: o, size: a } = yield yield vt(null), e.isTTY)
      return yield yield vt(new Uint8Array(0)), yield vt(null);
    try {
      n[0] = Rd(e, "end"), n[1] = Rd(e, "error");
      do {
        if (n[2] = Rd(e, "readable"), [r, s] = yield vt(Promise.race(n.map((d) => d[2]))), r === "error")
          break;
        if ((i = r === "end") || (Number.isFinite(a - c) ? (l = Ft(e.read(a - c)), l.byteLength < a - c && (l = Ft(e.read()))) : l = Ft(e.read()), l.byteLength > 0 && (u.push(l), c += l.byteLength)), i || a <= c)
          do
            ({ cmd: o, size: a } = yield yield vt(f()));
          while (a < c);
      } while (!i);
    } finally {
      yield vt(h(n, r === "error" ? s : null));
    }
    return yield vt(null);
    function h(d, p) {
      return l = u = null, new Promise((y, g) => {
        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 ? g(p) : y();
        }
      });
    }
  });
}
var Ie;
(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";
})(Ie || (Ie = {}));
var on;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(on || (on = {}));
var Xe;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(Xe || (Xe = {}));
var Zr;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Zr || (Zr = {}));
var mt;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(mt || (mt = {}));
var Ii;
(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";
})(Ii || (Ii = {}));
var Ut;
(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";
})(Ut || (Ut = {}));
var L;
(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.Duration = 18] = "Duration", 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", e[e.DurationSecond = -27] = "DurationSecond", e[e.DurationMillisecond = -28] = "DurationMillisecond", e[e.DurationMicrosecond = -29] = "DurationMicrosecond", e[e.DurationNanosecond = -30] = "DurationNanosecond";
})(L || (L = {}));
var kr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(kr || (kr = {}));
const FN = void 0;
function dc(e) {
  if (e === null)
    return "null";
  if (e === FN)
    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 BigInt64Array || e instanceof BigUint64Array ? `[${[...e].map((t) => dc(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const RN = Symbol.for("isArrowBigNum");
function qn(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(Pt(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
qn.prototype[RN] = !0;
qn.prototype.toJSON = function() {
  return `"${yc(this)}"`;
};
qn.prototype.valueOf = function() {
  return rv(this);
};
qn.prototype.toString = function() {
  return yc(this);
};
qn.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return rv(this);
    case "string":
      return yc(this);
    case "default":
      return CN(this);
  }
  return yc(this);
};
function $o(...e) {
  return qn.apply(this, e);
}
function Io(...e) {
  return qn.apply(this, e);
}
function pc(...e) {
  return qn.apply(this, e);
}
Object.setPrototypeOf($o.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(Io.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(pc.prototype, Object.create(Uint32Array.prototype));
Object.assign($o.prototype, qn.prototype, { constructor: $o, signed: !0, TypedArray: Int32Array, BigIntArray: BigInt64Array });
Object.assign(Io.prototype, qn.prototype, { constructor: Io, signed: !1, TypedArray: Uint32Array, BigIntArray: BigUint64Array });
Object.assign(pc.prototype, qn.prototype, { constructor: pc, signed: !0, TypedArray: Uint32Array, BigIntArray: BigUint64Array });
function rv(e) {
  const { buffer: t, byteOffset: n, length: r, signed: i } = e, s = new BigUint64Array(t, n, r), o = i && s.at(-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;
}
const yc = (e) => {
  if (e.byteLength === 8)
    return `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}`;
  if (!e.signed)
    return Cd(e);
  let t = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  if (new Int16Array([t.at(-1)])[0] >= 0)
    return Cd(e);
  t = t.slice();
  let r = 1;
  for (let s = 0; s < t.length; s++) {
    const o = t[s], a = ~o + r;
    t[s] = a, r &= o === 0 ? 1 : 0;
  }
  return `-${Cd(t)}`;
}, CN = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : yc(e);
function Cd(e) {
  let t = "";
  const n = new Uint32Array(2);
  let r = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  const i = new Uint32Array((r = new Uint16Array(r).reverse()).buffer);
  let s = -1;
  const o = r.length - 1;
  do {
    for (n[0] = r[s = 0]; s < o; )
      r[s++] = n[1] = n[0] / 10, n[0] = (n[0] - n[1] * 10 << 16) + r[s];
    r[s] = n[1] = n[0] / 10, n[0] = n[0] - n[1] * 10, t = `${n[0]}${t}`;
  } while (i[0] || i[1] || i[2] || i[3]);
  return t ?? "0";
}
class Ly {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new $o(t);
      case !1:
        return new Io(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case BigInt64Array:
        return new $o(t);
    }
    return t.byteLength === 16 ? new pc(t) : new Io(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new $o(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new Io(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new pc(t);
  }
  constructor(t, n) {
    return Ly.new(t, n);
  }
}
function Cn(e) {
  if (typeof e == "bigint" && (e < Number.MIN_SAFE_INTEGER || e > Number.MAX_SAFE_INTEGER))
    throw new TypeError(`${e} is not safe to convert to a number.`);
  return Number(e);
}
var iv, sv, ov, av, cv, uv, lv, fv, hv, dv, pv, yv, mv, gv, bv, wv, vv, _v, xv, Sv;
class st {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === L.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === L.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === L.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === L.Binary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === L.Utf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === L.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === L.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === L.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === L.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === L.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === L.Interval;
  }
  /** @nocollapse */
  static isDuration(t) {
    return (t == null ? void 0 : t.typeId) === L.Duration;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === L.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === L.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === L.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === L.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === L.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === L.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === L.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return st.isUnion(t) && t.mode === on.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return st.isUnion(t) && t.mode === on.Sparse;
  }
  get typeId() {
    return L.NONE;
  }
}
iv = Symbol.toStringTag;
st[iv] = ((e) => (e.children = null, e.ArrayType = Array, e[Symbol.toStringTag] = "DataType"))(st.prototype);
let Ti = class extends st {
  toString() {
    return "Null";
  }
  get typeId() {
    return L.Null;
  }
};
sv = Symbol.toStringTag;
Ti[sv] = ((e) => e[Symbol.toStringTag] = "Null")(Ti.prototype);
class Ei extends st {
  constructor(t, n) {
    super(), this.isSigned = t, this.bitWidth = n;
  }
  get typeId() {
    return L.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 ? BigInt64Array : BigUint64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
}
ov = Symbol.toStringTag;
Ei[ov] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(Ei.prototype);
class mc extends Ei {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
}
Object.defineProperty(mc.prototype, "ArrayType", { value: Int32Array });
class gc extends st {
  constructor(t) {
    super(), this.precision = t;
  }
  get typeId() {
    return L.Float;
  }
  get ArrayType() {
    switch (this.precision) {
      case Xe.HALF:
        return Uint16Array;
      case Xe.SINGLE:
        return Float32Array;
      case Xe.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
}
av = Symbol.toStringTag;
gc[av] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(gc.prototype);
let Ll = class extends st {
  constructor() {
    super();
  }
  get typeId() {
    return L.Binary;
  }
  toString() {
    return "Binary";
  }
};
cv = Symbol.toStringTag;
Ll[cv] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(Ll.prototype);
let kl = class extends st {
  constructor() {
    super();
  }
  get typeId() {
    return L.Utf8;
  }
  toString() {
    return "Utf8";
  }
};
uv = Symbol.toStringTag;
kl[uv] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(kl.prototype);
let Fl = class extends st {
  constructor() {
    super();
  }
  get typeId() {
    return L.Bool;
  }
  toString() {
    return "Bool";
  }
};
lv = Symbol.toStringTag;
Fl[lv] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(Fl.prototype);
let Rl = class extends st {
  constructor(t, n, r = 128) {
    super(), this.scale = t, this.precision = n, this.bitWidth = r;
  }
  get typeId() {
    return L.Decimal;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
};
fv = Symbol.toStringTag;
Rl[fv] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(Rl.prototype);
class Cl extends st {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return L.Date;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${Zr[this.unit]}>`;
  }
}
hv = Symbol.toStringTag;
Cl[hv] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(Cl.prototype);
class bc extends st {
  constructor(t, n) {
    super(), this.unit = t, this.bitWidth = n;
  }
  get typeId() {
    return L.Time;
  }
  toString() {
    return `Time${this.bitWidth}<${mt[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return BigInt64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
}
dv = Symbol.toStringTag;
bc[dv] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(bc.prototype);
class Bl extends st {
  constructor(t, n) {
    super(), this.unit = t, this.timezone = n;
  }
  get typeId() {
    return L.Timestamp;
  }
  toString() {
    return `Timestamp<${mt[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
}
pv = Symbol.toStringTag;
Bl[pv] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(Bl.prototype);
class Pl extends st {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return L.Interval;
  }
  toString() {
    return `Interval<${Ii[this.unit]}>`;
  }
}
yv = Symbol.toStringTag;
Pl[yv] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(Pl.prototype);
let Ul = class extends st {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return L.Duration;
  }
  toString() {
    return `Duration<${mt[this.unit]}>`;
  }
};
mv = Symbol.toStringTag;
Ul[mv] = ((e) => (e.unit = null, e.ArrayType = BigInt64Array, e[Symbol.toStringTag] = "Duration"))(Ul.prototype);
let zl = class extends st {
  constructor(t) {
    super(), this.children = [t];
  }
  get typeId() {
    return L.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;
  }
};
gv = Symbol.toStringTag;
zl[gv] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(zl.prototype);
class Fe extends st {
  constructor(t) {
    super(), this.children = t;
  }
  get typeId() {
    return L.Struct;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
bv = Symbol.toStringTag;
Fe[bv] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(Fe.prototype);
class jl extends st {
  constructor(t, n, r) {
    super(), this.mode = t, this.children = r, this.typeIds = n = Int32Array.from(n), this.typeIdToChildIndex = n.reduce((i, s, o) => (i[s] = o) && i || i, /* @__PURE__ */ Object.create(null));
  }
  get typeId() {
    return L.Union;
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
}
wv = Symbol.toStringTag;
jl[wv] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(jl.prototype);
let ql = class extends st {
  constructor(t) {
    super(), this.byteWidth = t;
  }
  get typeId() {
    return L.FixedSizeBinary;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
};
vv = Symbol.toStringTag;
ql[vv] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(ql.prototype);
let Vl = class extends st {
  constructor(t, n) {
    super(), this.listSize = t, this.children = [n];
  }
  get typeId() {
    return L.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}>`;
  }
};
_v = Symbol.toStringTag;
Vl[_v] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(Vl.prototype);
class Yl extends st {
  constructor(t, n = !1) {
    var r, i, s;
    if (super(), this.children = [t], this.keysSorted = n, t && (t.name = "entries", !((r = t == null ? void 0 : t.type) === null || r === void 0) && r.children)) {
      const o = (i = t == null ? void 0 : t.type) === null || i === void 0 ? void 0 : i.children[0];
      o && (o.name = "key");
      const a = (s = t == null ? void 0 : t.type) === null || s === void 0 ? void 0 : s.children[1];
      a && (a.name = "value");
    }
  }
  get typeId() {
    return L.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(", ")}}>`;
  }
}
xv = Symbol.toStringTag;
Yl[xv] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(Yl.prototype);
const BN = /* @__PURE__ */ ((e) => () => ++e)(-1);
class Uo extends st {
  constructor(t, n, r, i) {
    super(), this.indices = n, this.dictionary = t, this.isOrdered = i || !1, this.id = r == null ? BN() : Cn(r);
  }
  get typeId() {
    return L.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}>`;
  }
}
Sv = Symbol.toStringTag;
Uo[Sv] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(Uo.prototype);
function Fr(e) {
  const t = e;
  switch (e.typeId) {
    case L.Decimal:
      return e.bitWidth / 32;
    case L.Timestamp:
      return 2;
    case L.Date:
      return 1 + t.unit;
    case L.Interval:
      return 1 + t.unit;
    case L.FixedSizeList:
      return t.listSize;
    case L.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
class xt {
  visitMany(t, ...n) {
    return t.map((r, i) => this.visit(r, ...n.map((s) => s[i])));
  }
  visit(...t) {
    return this.getVisitFn(t[0], !1).apply(this, t);
  }
  getVisitFn(t, n = !0) {
    return PN(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return fo(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;
  }
  visitDuration(t, ...n) {
    return null;
  }
  visitFixedSizeList(t, ...n) {
    return null;
  }
  visitMap(t, ...n) {
    return null;
  }
}
function PN(e, t, n = !0) {
  return typeof t == "number" ? fo(e, t, n) : typeof t == "string" && t in L ? fo(e, L[t], n) : t && t instanceof st ? fo(e, A1(t), n) : t != null && t.type && t.type instanceof st ? fo(e, A1(t.type), n) : fo(e, L.NONE, n);
}
function fo(e, t, n = !0) {
  let r = null;
  switch (t) {
    case L.Null:
      r = e.visitNull;
      break;
    case L.Bool:
      r = e.visitBool;
      break;
    case L.Int:
      r = e.visitInt;
      break;
    case L.Int8:
      r = e.visitInt8 || e.visitInt;
      break;
    case L.Int16:
      r = e.visitInt16 || e.visitInt;
      break;
    case L.Int32:
      r = e.visitInt32 || e.visitInt;
      break;
    case L.Int64:
      r = e.visitInt64 || e.visitInt;
      break;
    case L.Uint8:
      r = e.visitUint8 || e.visitInt;
      break;
    case L.Uint16:
      r = e.visitUint16 || e.visitInt;
      break;
    case L.Uint32:
      r = e.visitUint32 || e.visitInt;
      break;
    case L.Uint64:
      r = e.visitUint64 || e.visitInt;
      break;
    case L.Float:
      r = e.visitFloat;
      break;
    case L.Float16:
      r = e.visitFloat16 || e.visitFloat;
      break;
    case L.Float32:
      r = e.visitFloat32 || e.visitFloat;
      break;
    case L.Float64:
      r = e.visitFloat64 || e.visitFloat;
      break;
    case L.Utf8:
      r = e.visitUtf8;
      break;
    case L.Binary:
      r = e.visitBinary;
      break;
    case L.FixedSizeBinary:
      r = e.visitFixedSizeBinary;
      break;
    case L.Date:
      r = e.visitDate;
      break;
    case L.DateDay:
      r = e.visitDateDay || e.visitDate;
      break;
    case L.DateMillisecond:
      r = e.visitDateMillisecond || e.visitDate;
      break;
    case L.Timestamp:
      r = e.visitTimestamp;
      break;
    case L.TimestampSecond:
      r = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case L.TimestampMillisecond:
      r = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case L.TimestampMicrosecond:
      r = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case L.TimestampNanosecond:
      r = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case L.Time:
      r = e.visitTime;
      break;
    case L.TimeSecond:
      r = e.visitTimeSecond || e.visitTime;
      break;
    case L.TimeMillisecond:
      r = e.visitTimeMillisecond || e.visitTime;
      break;
    case L.TimeMicrosecond:
      r = e.visitTimeMicrosecond || e.visitTime;
      break;
    case L.TimeNanosecond:
      r = e.visitTimeNanosecond || e.visitTime;
      break;
    case L.Decimal:
      r = e.visitDecimal;
      break;
    case L.List:
      r = e.visitList;
      break;
    case L.Struct:
      r = e.visitStruct;
      break;
    case L.Union:
      r = e.visitUnion;
      break;
    case L.DenseUnion:
      r = e.visitDenseUnion || e.visitUnion;
      break;
    case L.SparseUnion:
      r = e.visitSparseUnion || e.visitUnion;
      break;
    case L.Dictionary:
      r = e.visitDictionary;
      break;
    case L.Interval:
      r = e.visitInterval;
      break;
    case L.IntervalDayTime:
      r = e.visitIntervalDayTime || e.visitInterval;
      break;
    case L.IntervalYearMonth:
      r = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case L.Duration:
      r = e.visitDuration;
      break;
    case L.DurationSecond:
      r = e.visitDurationSecond || e.visitDuration;
      break;
    case L.DurationMillisecond:
      r = e.visitDurationMillisecond || e.visitDuration;
      break;
    case L.DurationMicrosecond:
      r = e.visitDurationMicrosecond || e.visitDuration;
      break;
    case L.DurationNanosecond:
      r = e.visitDurationNanosecond || e.visitDuration;
      break;
    case L.FixedSizeList:
      r = e.visitFixedSizeList;
      break;
    case L.Map:
      r = e.visitMap;
      break;
  }
  if (typeof r == "function")
    return r;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${L[t]}'`);
}
function A1(e) {
  switch (e.typeId) {
    case L.Null:
      return L.Null;
    case L.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? L.Int8 : L.Uint8;
        case 16:
          return n ? L.Int16 : L.Uint16;
        case 32:
          return n ? L.Int32 : L.Uint32;
        case 64:
          return n ? L.Int64 : L.Uint64;
      }
      return L.Int;
    }
    case L.Float:
      switch (e.precision) {
        case Xe.HALF:
          return L.Float16;
        case Xe.SINGLE:
          return L.Float32;
        case Xe.DOUBLE:
          return L.Float64;
      }
      return L.Float;
    case L.Binary:
      return L.Binary;
    case L.Utf8:
      return L.Utf8;
    case L.Bool:
      return L.Bool;
    case L.Decimal:
      return L.Decimal;
    case L.Time:
      switch (e.unit) {
        case mt.SECOND:
          return L.TimeSecond;
        case mt.MILLISECOND:
          return L.TimeMillisecond;
        case mt.MICROSECOND:
          return L.TimeMicrosecond;
        case mt.NANOSECOND:
          return L.TimeNanosecond;
      }
      return L.Time;
    case L.Timestamp:
      switch (e.unit) {
        case mt.SECOND:
          return L.TimestampSecond;
        case mt.MILLISECOND:
          return L.TimestampMillisecond;
        case mt.MICROSECOND:
          return L.TimestampMicrosecond;
        case mt.NANOSECOND:
          return L.TimestampNanosecond;
      }
      return L.Timestamp;
    case L.Date:
      switch (e.unit) {
        case Zr.DAY:
          return L.DateDay;
        case Zr.MILLISECOND:
          return L.DateMillisecond;
      }
      return L.Date;
    case L.Interval:
      switch (e.unit) {
        case Ii.DAY_TIME:
          return L.IntervalDayTime;
        case Ii.YEAR_MONTH:
          return L.IntervalYearMonth;
      }
      return L.Interval;
    case L.Duration:
      switch (e.unit) {
        case mt.SECOND:
          return L.DurationSecond;
        case mt.MILLISECOND:
          return L.DurationMillisecond;
        case mt.MICROSECOND:
          return L.DurationMicrosecond;
        case mt.NANOSECOND:
          return L.DurationNanosecond;
      }
      return L.Duration;
    case L.Map:
      return L.Map;
    case L.List:
      return L.List;
    case L.Struct:
      return L.Struct;
    case L.Union:
      switch (e.mode) {
        case on.Dense:
          return L.DenseUnion;
        case on.Sparse:
          return L.SparseUnion;
      }
      return L.Union;
    case L.FixedSizeBinary:
      return L.FixedSizeBinary;
    case L.FixedSizeList:
      return L.FixedSizeList;
    case L.Dictionary:
      return L.Dictionary;
  }
  throw new Error(`Unrecognized type '${L[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;
xt.prototype.visitDuration = null;
xt.prototype.visitDurationSecond = null;
xt.prototype.visitDurationMillisecond = null;
xt.prototype.visitDurationMicrosecond = null;
xt.prototype.visitDurationNanosecond = null;
const Mv = new Float64Array(1), Qs = new Uint32Array(Mv.buffer);
function Av(e) {
  const t = (e & 31744) >> 10, n = (e & 1023) / 1024, r = Math.pow(-1, (e & 32768) >> 15);
  switch (t) {
    case 31:
      return r * (n ? Number.NaN : 1 / 0);
    case 0:
      return r * (n ? 6103515625e-14 * n : 0);
  }
  return r * Math.pow(2, t - 15) * (1 + n);
}
function UN(e) {
  if (e !== e)
    return 32256;
  Mv[0] = e;
  const t = (Qs[1] & 2147483648) >> 16 & 65535;
  let n = Qs[1] & 2146435072, r = 0;
  return n >= 1089470464 ? Qs[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, r = (Qs[1] & 1048575) >> 10) : n <= 1056964608 ? (r = 1048576 + (Qs[1] & 1048575), r = 1048576 + (r << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, r = (Qs[1] & 1048575) + 512 >> 10), t | n | r & 65535;
}
class ht extends xt {
}
function yt(e) {
  return (t, n, r) => {
    if (t.setValid(n, r != null))
      return e(t, n, r);
  };
}
const zN = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, ky = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, jN = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, qN = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, $v = (e, t, n, r) => {
  if (n + 1 < t.length) {
    const { [n]: i, [n + 1]: s } = t;
    e.set(r.subarray(0, s - i), i);
  }
}, VN = ({ offset: e, values: t }, n, r) => {
  const i = e + n;
  r ? t[i >> 3] |= 1 << i % 8 : t[i >> 3] &= ~(1 << i % 8);
}, ei = ({ values: e }, t, n) => {
  e[t] = n;
}, Fy = ({ values: e }, t, n) => {
  e[t] = n;
}, Iv = ({ values: e }, t, n) => {
  e[t] = UN(n);
}, YN = (e, t, n) => {
  switch (e.type.precision) {
    case Xe.HALF:
      return Iv(e, t, n);
    case Xe.SINGLE:
    case Xe.DOUBLE:
      return Fy(e, t, n);
  }
}, Tv = ({ values: e }, t, n) => {
  zN(e, t, n.valueOf());
}, Ev = ({ values: e }, t, n) => {
  ky(e, t * 2, n.valueOf());
}, WN = ({ stride: e, values: t }, n, r) => {
  t.set(r.subarray(0, e), e * n);
}, XN = ({ values: e, valueOffsets: t }, n, r) => $v(e, t, n, r), GN = ({ values: e, valueOffsets: t }, n, r) => {
  $v(e, t, n, Ey(r));
}, HN = (e, t, n) => {
  e.type.unit === Zr.DAY ? Tv(e, t, n) : Ev(e, t, n);
}, Nv = ({ values: e }, t, n) => ky(e, t * 2, n / 1e3), Dv = ({ values: e }, t, n) => ky(e, t * 2, n), Ov = ({ values: e }, t, n) => jN(e, t * 2, n), Lv = ({ values: e }, t, n) => qN(e, t * 2, n), JN = (e, t, n) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return Nv(e, t, n);
    case mt.MILLISECOND:
      return Dv(e, t, n);
    case mt.MICROSECOND:
      return Ov(e, t, n);
    case mt.NANOSECOND:
      return Lv(e, t, n);
  }
}, kv = ({ values: e }, t, n) => {
  e[t] = n;
}, Fv = ({ values: e }, t, n) => {
  e[t] = n;
}, Rv = ({ values: e }, t, n) => {
  e[t] = n;
}, Cv = ({ values: e }, t, n) => {
  e[t] = n;
}, ZN = (e, t, n) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return kv(e, t, n);
    case mt.MILLISECOND:
      return Fv(e, t, n);
    case mt.MICROSECOND:
      return Rv(e, t, n);
    case mt.NANOSECOND:
      return Cv(e, t, n);
  }
}, KN = ({ values: e, stride: t }, n, r) => {
  e.set(r.subarray(0, t), t * n);
}, QN = (e, t, n) => {
  const r = e.children[0], i = e.valueOffsets, s = xn.getVisitFn(r);
  if (Array.isArray(n))
    for (let o = -1, a = i[t], c = i[t + 1]; a < c; )
      s(r, a++, n[++o]);
  else
    for (let o = -1, a = i[t], c = i[t + 1]; a < c; )
      s(r, a++, n.get(++o));
}, tD = (e, t, n) => {
  const r = e.children[0], { valueOffsets: i } = e, s = xn.getVisitFn(r);
  let { [t]: o, [t + 1]: a } = i;
  const c = n instanceof Map ? n.entries() : Object.entries(n);
  for (const u of c)
    if (s(r, o, u), ++o >= a)
      break;
}, eD = (e, t) => (n, r, i, s) => r && n(r, e, t[s]), nD = (e, t) => (n, r, i, s) => r && n(r, e, t.get(s)), rD = (e, t) => (n, r, i, s) => r && n(r, e, t.get(i.name)), iD = (e, t) => (n, r, i, s) => r && n(r, e, t[i.name]), sD = (e, t, n) => {
  const r = e.type.children.map((s) => xn.getVisitFn(s.type)), i = n instanceof Map ? rD(t, n) : n instanceof ae ? nD(t, n) : Array.isArray(n) ? eD(t, n) : iD(t, n);
  e.type.children.forEach((s, o) => i(r[o], e.children[o], s, o));
}, oD = (e, t, n) => {
  e.type.mode === on.Dense ? Bv(e, t, n) : Pv(e, t, n);
}, Bv = (e, t, n) => {
  const r = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[r];
  xn.visit(i, e.valueOffsets[t], n);
}, Pv = (e, t, n) => {
  const r = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[r];
  xn.visit(i, t, n);
}, aD = (e, t, n) => {
  var r;
  (r = e.dictionary) === null || r === void 0 || r.set(e.values[t], n);
}, cD = (e, t, n) => {
  e.type.unit === Ii.DAY_TIME ? Uv(e, t, n) : zv(e, t, n);
}, Uv = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, zv = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, jv = ({ values: e }, t, n) => {
  e[t] = n;
}, qv = ({ values: e }, t, n) => {
  e[t] = n;
}, Vv = ({ values: e }, t, n) => {
  e[t] = n;
}, Yv = ({ values: e }, t, n) => {
  e[t] = n;
}, uD = (e, t, n) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return jv(e, t, n);
    case mt.MILLISECOND:
      return qv(e, t, n);
    case mt.MICROSECOND:
      return Vv(e, t, n);
    case mt.NANOSECOND:
      return Yv(e, t, n);
  }
}, lD = (e, t, n) => {
  const { stride: r } = e, i = e.children[0], s = xn.getVisitFn(i);
  if (Array.isArray(n))
    for (let o = -1, a = t * r; ++o < r; )
      s(i, a + o, n[o]);
  else
    for (let o = -1, a = t * r; ++o < r; )
      s(i, a + o, n.get(o));
};
ht.prototype.visitBool = yt(VN);
ht.prototype.visitInt = yt(ei);
ht.prototype.visitInt8 = yt(ei);
ht.prototype.visitInt16 = yt(ei);
ht.prototype.visitInt32 = yt(ei);
ht.prototype.visitInt64 = yt(ei);
ht.prototype.visitUint8 = yt(ei);
ht.prototype.visitUint16 = yt(ei);
ht.prototype.visitUint32 = yt(ei);
ht.prototype.visitUint64 = yt(ei);
ht.prototype.visitFloat = yt(YN);
ht.prototype.visitFloat16 = yt(Iv);
ht.prototype.visitFloat32 = yt(Fy);
ht.prototype.visitFloat64 = yt(Fy);
ht.prototype.visitUtf8 = yt(GN);
ht.prototype.visitBinary = yt(XN);
ht.prototype.visitFixedSizeBinary = yt(WN);
ht.prototype.visitDate = yt(HN);
ht.prototype.visitDateDay = yt(Tv);
ht.prototype.visitDateMillisecond = yt(Ev);
ht.prototype.visitTimestamp = yt(JN);
ht.prototype.visitTimestampSecond = yt(Nv);
ht.prototype.visitTimestampMillisecond = yt(Dv);
ht.prototype.visitTimestampMicrosecond = yt(Ov);
ht.prototype.visitTimestampNanosecond = yt(Lv);
ht.prototype.visitTime = yt(ZN);
ht.prototype.visitTimeSecond = yt(kv);
ht.prototype.visitTimeMillisecond = yt(Fv);
ht.prototype.visitTimeMicrosecond = yt(Rv);
ht.prototype.visitTimeNanosecond = yt(Cv);
ht.prototype.visitDecimal = yt(KN);
ht.prototype.visitList = yt(QN);
ht.prototype.visitStruct = yt(sD);
ht.prototype.visitUnion = yt(oD);
ht.prototype.visitDenseUnion = yt(Bv);
ht.prototype.visitSparseUnion = yt(Pv);
ht.prototype.visitDictionary = yt(aD);
ht.prototype.visitInterval = yt(cD);
ht.prototype.visitIntervalDayTime = yt(Uv);
ht.prototype.visitIntervalYearMonth = yt(zv);
ht.prototype.visitDuration = yt(uD);
ht.prototype.visitDurationSecond = yt(jv);
ht.prototype.visitDurationMillisecond = yt(qv);
ht.prototype.visitDurationMicrosecond = yt(Vv);
ht.prototype.visitDurationNanosecond = yt(Yv);
ht.prototype.visitFixedSizeList = yt(lD);
ht.prototype.visitMap = yt(tD);
const xn = new ht(), Tn = Symbol.for("parent"), To = Symbol.for("rowIndex");
class Ry {
  constructor(t, n) {
    return this[Tn] = t, this[To] = n, new Proxy(this, new hD());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[To], n = this[Tn], r = n.type.children, i = {};
    for (let s = -1, o = r.length; ++s < o; )
      i[r[s].name] = Ge.visit(n.children[s], t);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${dc(t)}: ${dc(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new fD(this[Tn], this[To]);
  }
}
class fD {
  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,
        Ge.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
}
Object.defineProperties(Ry.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [Tn]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [To]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
class hD {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[Tn].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[Tn].type.children.findIndex((r) => r.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[Tn].type.children.findIndex((r) => r.name === n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const r = t[Tn].type.children.findIndex((i) => i.name === n);
    if (r !== -1) {
      const i = Ge.visit(t[Tn].children[r], t[To]);
      return Reflect.set(t, n, i), i;
    }
  }
  set(t, n, r) {
    const i = t[Tn].type.children.findIndex((s) => s.name === n);
    return i !== -1 ? (xn.visit(t[Tn].children[i], t[To], r), Reflect.set(t, n, r)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, r) : !1;
  }
}
class ct extends xt {
}
function dt(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const dD = (e, t) => 864e5 * e[t], Cy = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), pD = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, yD = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, Wv = (e) => new Date(e), mD = (e, t) => Wv(dD(e, t)), gD = (e, t) => Wv(Cy(e, t)), bD = (e, t) => null, Xv = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const r = t[n], i = t[n + 1];
  return e.subarray(r, i);
}, wD = ({ offset: e, values: t }, n) => {
  const r = e + n;
  return (t[r >> 3] & 1 << r % 8) !== 0;
}, Gv = ({ values: e }, t) => mD(e, t), Hv = ({ values: e }, t) => gD(e, t * 2), qi = ({ stride: e, values: t }, n) => t[e * n], vD = ({ stride: e, values: t }, n) => Av(t[e * n]), Jv = ({ values: e }, t) => e[t], _D = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), xD = ({ values: e, valueOffsets: t }, n) => Xv(e, t, n), SD = ({ values: e, valueOffsets: t }, n) => {
  const r = Xv(e, t, n);
  return r !== null ? Yp(r) : null;
}, MD = ({ values: e }, t) => e[t], AD = ({ type: e, values: t }, n) => e.precision !== Xe.HALF ? t[n] : Av(t[n]), $D = (e, t) => e.type.unit === Zr.DAY ? Gv(e, t) : Hv(e, t), Zv = ({ values: e }, t) => 1e3 * Cy(e, t * 2), Kv = ({ values: e }, t) => Cy(e, t * 2), Qv = ({ values: e }, t) => pD(e, t * 2), t_ = ({ values: e }, t) => yD(e, t * 2), ID = (e, t) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return Zv(e, t);
    case mt.MILLISECOND:
      return Kv(e, t);
    case mt.MICROSECOND:
      return Qv(e, t);
    case mt.NANOSECOND:
      return t_(e, t);
  }
}, e_ = ({ values: e }, t) => e[t], n_ = ({ values: e }, t) => e[t], r_ = ({ values: e }, t) => e[t], i_ = ({ values: e }, t) => e[t], TD = (e, t) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return e_(e, t);
    case mt.MILLISECOND:
      return n_(e, t);
    case mt.MICROSECOND:
      return r_(e, t);
    case mt.NANOSECOND:
      return i_(e, t);
  }
}, ED = ({ values: e, stride: t }, n) => Ly.decimal(e.subarray(t * n, t * (n + 1))), ND = (e, t) => {
  const { valueOffsets: n, stride: r, children: i } = e, { [t * r]: s, [t * r + 1]: o } = n, c = i[0].slice(s, o - s);
  return new ae([c]);
}, DD = (e, t) => {
  const { valueOffsets: n, children: r } = e, { [t]: i, [t + 1]: s } = n, o = r[0];
  return new By(o.slice(i, s - i));
}, OD = (e, t) => new Ry(e, t), LD = (e, t) => e.type.mode === on.Dense ? s_(e, t) : o_(e, t), s_ = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[n];
  return Ge.visit(r, e.valueOffsets[t]);
}, o_ = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[n];
  return Ge.visit(r, t);
}, kD = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, FD = (e, t) => e.type.unit === Ii.DAY_TIME ? a_(e, t) : c_(e, t), a_ = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), c_ = ({ values: e }, t) => {
  const n = e[t], r = new Int32Array(2);
  return r[0] = Math.trunc(n / 12), r[1] = Math.trunc(n % 12), r;
}, u_ = ({ values: e }, t) => e[t], l_ = ({ values: e }, t) => e[t], f_ = ({ values: e }, t) => e[t], h_ = ({ values: e }, t) => e[t], RD = (e, t) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return u_(e, t);
    case mt.MILLISECOND:
      return l_(e, t);
    case mt.MICROSECOND:
      return f_(e, t);
    case mt.NANOSECOND:
      return h_(e, t);
  }
}, CD = (e, t) => {
  const { stride: n, children: r } = e, s = r[0].slice(t * n, n);
  return new ae([s]);
};
ct.prototype.visitNull = dt(bD);
ct.prototype.visitBool = dt(wD);
ct.prototype.visitInt = dt(MD);
ct.prototype.visitInt8 = dt(qi);
ct.prototype.visitInt16 = dt(qi);
ct.prototype.visitInt32 = dt(qi);
ct.prototype.visitInt64 = dt(Jv);
ct.prototype.visitUint8 = dt(qi);
ct.prototype.visitUint16 = dt(qi);
ct.prototype.visitUint32 = dt(qi);
ct.prototype.visitUint64 = dt(Jv);
ct.prototype.visitFloat = dt(AD);
ct.prototype.visitFloat16 = dt(vD);
ct.prototype.visitFloat32 = dt(qi);
ct.prototype.visitFloat64 = dt(qi);
ct.prototype.visitUtf8 = dt(SD);
ct.prototype.visitBinary = dt(xD);
ct.prototype.visitFixedSizeBinary = dt(_D);
ct.prototype.visitDate = dt($D);
ct.prototype.visitDateDay = dt(Gv);
ct.prototype.visitDateMillisecond = dt(Hv);
ct.prototype.visitTimestamp = dt(ID);
ct.prototype.visitTimestampSecond = dt(Zv);
ct.prototype.visitTimestampMillisecond = dt(Kv);
ct.prototype.visitTimestampMicrosecond = dt(Qv);
ct.prototype.visitTimestampNanosecond = dt(t_);
ct.prototype.visitTime = dt(TD);
ct.prototype.visitTimeSecond = dt(e_);
ct.prototype.visitTimeMillisecond = dt(n_);
ct.prototype.visitTimeMicrosecond = dt(r_);
ct.prototype.visitTimeNanosecond = dt(i_);
ct.prototype.visitDecimal = dt(ED);
ct.prototype.visitList = dt(ND);
ct.prototype.visitStruct = dt(OD);
ct.prototype.visitUnion = dt(LD);
ct.prototype.visitDenseUnion = dt(s_);
ct.prototype.visitSparseUnion = dt(o_);
ct.prototype.visitDictionary = dt(kD);
ct.prototype.visitInterval = dt(FD);
ct.prototype.visitIntervalDayTime = dt(a_);
ct.prototype.visitIntervalYearMonth = dt(c_);
ct.prototype.visitDuration = dt(RD);
ct.prototype.visitDurationSecond = dt(u_);
ct.prototype.visitDurationMillisecond = dt(l_);
ct.prototype.visitDurationMicrosecond = dt(f_);
ct.prototype.visitDurationNanosecond = dt(h_);
ct.prototype.visitFixedSizeList = dt(CD);
ct.prototype.visitMap = dt(DD);
const Ge = new ct(), tr = Symbol.for("keys"), Eo = Symbol.for("vals");
class By {
  constructor(t) {
    return this[tr] = new ae([t.children[0]]).memoize(), this[Eo] = t.children[1], new Proxy(this, new PD());
  }
  [Symbol.iterator]() {
    return new BD(this[tr], this[Eo]);
  }
  get size() {
    return this[tr].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[tr], n = this[Eo], r = {};
    for (let i = -1, s = t.length; ++i < s; )
      r[t.get(i)] = Ge.visit(n, i);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${dc(t)}: ${dc(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}
class BD {
  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),
        Ge.visit(this.vals, t)
      ]
    });
  }
}
class PD {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[tr].toArray().map(String);
  }
  has(t, n) {
    return t[tr].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[tr].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const r = t[tr].indexOf(n);
    if (r !== -1) {
      const i = Ge.visit(Reflect.get(t, Eo), r);
      return Reflect.set(t, n, i), i;
    }
  }
  set(t, n, r) {
    const i = t[tr].indexOf(n);
    return i !== -1 ? (xn.visit(Reflect.get(t, Eo), i, r), Reflect.set(t, n, r)) : Reflect.has(t, n) ? Reflect.set(t, n, r) : !1;
  }
}
Object.defineProperties(By.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [tr]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [Eo]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let $1;
function d_(e, t, n, r) {
  const { length: i = 0 } = e;
  let s = typeof t != "number" ? 0 : t, o = typeof n != "number" ? i : n;
  return s < 0 && (s = (s % i + i) % i), o < 0 && (o = (o % i + i) % i), o < s && ($1 = s, s = o, o = $1), o > i && (o = i), r ? r(e, s, o) : [s, o];
}
const I1 = (e) => e !== e;
function pa(e) {
  if (typeof e !== "object" || e === null)
    return I1(e) ? I1 : (n) => n === e;
  if (e instanceof Date) {
    const n = e.valueOf();
    return (r) => r instanceof Date ? r.valueOf() === n : !1;
  }
  return ArrayBuffer.isView(e) ? (n) => n ? EN(e, n) : !1 : e instanceof Map ? zD(e) : Array.isArray(e) ? UD(e) : e instanceof ae ? jD(e) : qD(e, !0);
}
function UD(e) {
  const t = [];
  for (let n = -1, r = e.length; ++n < r; )
    t[n] = pa(e[n]);
  return Ah(t);
}
function zD(e) {
  let t = -1;
  const n = [];
  for (const r of e.values())
    n[++t] = pa(r);
  return Ah(n);
}
function jD(e) {
  const t = [];
  for (let n = -1, r = e.length; ++n < r; )
    t[n] = pa(e.get(n));
  return Ah(t);
}
function qD(e, t = !1) {
  const n = Object.keys(e);
  if (!t && n.length === 0)
    return () => !1;
  const r = [];
  for (let i = -1, s = n.length; ++i < s; )
    r[i] = pa(e[n[i]]);
  return Ah(r, n);
}
function Ah(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return VD(e, n);
      case Map:
        return T1(e, n, n.keys());
      case By:
      case Ry:
      case Object:
      case void 0:
        return T1(e, n, t || Object.keys(n));
    }
    return n instanceof ae ? YD(e, n) : !1;
  };
}
function VD(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let r = -1; ++r < n; )
    if (!e[r](t[r]))
      return !1;
  return !0;
}
function YD(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let r = -1; ++r < n; )
    if (!e[r](t.get(r)))
      return !1;
  return !0;
}
function T1(e, t, n) {
  const r = n[Symbol.iterator](), i = 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 = r.next(), l = i.next();
  for (; o < a && !u.done && !l.done && !c.done && !(u.value !== l.value || !e[o](c.value)); ++o, u = r.next(), l = i.next(), c = s.next())
    ;
  return o === a && u.done && l.done && c.done ? !0 : (r.return && r.return(), i.return && i.return(), s.return && s.return(), !1);
}
function p_(e, t, n, r) {
  return (n & 1 << r) !== 0;
}
function WD(e, t, n, r) {
  return (n & 1 << r) >> r;
}
function E1(e, t, n) {
  const r = n.byteLength + 7 & -8;
  if (e > 0 || n.byteLength < r) {
    const i = new Uint8Array(r);
    return i.set(e % 8 === 0 ? n.subarray(e >> 3) : (
      // Otherwise iterate each bit from the offset and return a new one
      Gp(new Py(n, e, t, null, p_)).subarray(0, r)
    )), i;
  }
  return n;
}
function Gp(e) {
  const t = [];
  let n = 0, r = 0, i = 0;
  for (const o of e)
    o && (i |= 1 << r), ++r === 8 && (t[n++] = i, i = r = 0);
  (n === 0 || r > 0) && (t[n++] = i);
  const s = new Uint8Array(t.length + 7 & -8);
  return s.set(t), s;
}
class Py {
  constructor(t, n, r, i, s) {
    this.bytes = t, this.length = r, this.context = i, 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 Hp(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new Py(e, t, n - t, e, WD))
      s += o;
    return s;
  }
  const r = n >> 3 << 3, i = 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
    Hp(e, t, i) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    Hp(e, r, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    XD(e, i >> 3, r - i >> 3)
  );
}
function XD(e, t, n) {
  let r = 0, i = Math.trunc(t);
  const s = new DataView(e.buffer, e.byteOffset, e.byteLength), o = n === void 0 ? e.byteLength : i + n;
  for (; o - i >= 4; )
    r += Bd(s.getUint32(i)), i += 4;
  for (; o - i >= 2; )
    r += Bd(s.getUint16(i)), i += 2;
  for (; o - i >= 1; )
    r += Bd(s.getUint8(i)), i += 1;
  return r;
}
function Bd(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 GD = -1;
class jt {
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  get nullable() {
    if (this._nullCount !== 0) {
      const { type: t } = this;
      return st.isSparseUnion(t) ? this.children.some((n) => n.nullable) : st.isDenseUnion(t) ? this.children.some((n) => n.nullable) : this.nullBitmap && this.nullBitmap.byteLength > 0;
    }
    return !0;
  }
  get byteLength() {
    let t = 0;
    const { valueOffsets: n, values: r, nullBitmap: i, typeIds: s } = this;
    return n && (t += n.byteLength), r && (t += r.byteLength), i && (t += i.byteLength), s && (t += s.byteLength), this.children.reduce((o, a) => o + a.byteLength, t);
  }
  get nullCount() {
    if (st.isUnion(this.type))
      return this.children.reduce((r, i) => r + i.nullCount, 0);
    let t = this._nullCount, n;
    return t <= GD && (n = this.nullBitmap) && (this._nullCount = t = this.length - Hp(n, this.offset, this.offset + this.length)), t;
  }
  constructor(t, n, r, i, 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(r || 0, 0)), this._nullCount = Math.floor(Math.max(i || 0, -1));
    let c;
    s instanceof jt ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = Fr(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)));
  }
  getValid(t) {
    const { type: n } = this;
    if (st.isUnion(n)) {
      const r = n, i = this.children[r.typeIdToChildIndex[this.typeIds[t]]], s = r.mode === on.Dense ? this.valueOffsets[t] : t;
      return i.getValid(s);
    }
    if (this.nullable && this.nullCount > 0) {
      const r = this.offset + t;
      return (this.nullBitmap[r >> 3] & 1 << r % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    let r;
    const { type: i } = this;
    if (st.isUnion(i)) {
      const s = i, o = this.children[s.typeIdToChildIndex[this.typeIds[t]]], a = s.mode === on.Dense ? this.valueOffsets[t] : t;
      r = o.getValid(a), o.setValid(a, n);
    } else {
      let { nullBitmap: s } = this;
      const { offset: o, length: a } = this, c = o + t, u = 1 << c % 8, l = c >> 3;
      (!s || s.byteLength <= l) && (s = new Uint8Array((o + a + 63 & -64) >> 3).fill(255), this.nullCount > 0 && s.set(E1(o, a, this.nullBitmap), 0), Object.assign(this, { nullBitmap: s, _nullCount: -1 }));
      const f = s[l];
      r = (f & u) !== 0, n ? s[l] = f | u : s[l] = f & ~u;
    }
    return r !== !!n && (this._nullCount = this.nullCount + (n ? -1 : 1)), n;
  }
  clone(t = this.type, n = this.offset, r = this.length, i = this._nullCount, s = this, o = this.children) {
    return new jt(t, n, r, i, s, o, this.dictionary);
  }
  slice(t, n) {
    const { stride: r, typeId: i, children: s } = this, o = +(this._nullCount === 0) - 1, a = i === 16 ? r : 1, c = this._sliceBuffers(t, n, r, i);
    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 === L.Null)
      return this.clone(this.type, 0, t, 0);
    const { length: n, nullCount: r } = this, i = new Uint8Array((t + 63 & -64) >> 3).fill(255, 0, n >> 3);
    i[n >> 3] = (1 << n - (n & -8)) - 1, r > 0 && i.set(E1(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[kr.VALIDITY] = i, this.clone(this.type, 0, t, r + (t - n), s);
  }
  _sliceBuffers(t, n, r, i) {
    let s;
    const { buffers: o } = this;
    return (s = o[kr.TYPE]) && (o[kr.TYPE] = s.subarray(t, t + n)), (s = o[kr.OFFSET]) && (o[kr.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[kr.DATA]) && (o[kr.DATA] = i === 6 ? s : s.subarray(r * t, r * (t + n))), o;
  }
  _sliceChildren(t, n, r) {
    return t.map((i) => i.slice(n, r));
  }
}
jt.prototype.children = Object.freeze([]);
class nc extends xt {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["length"]: i = 0 } = t;
    return new jt(n, r, i, i);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.data), s = Ft(t.nullBitmap), o = Oa(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, i, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.data), s = Ft(t.nullBitmap), o = Oa(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, i, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length / Fr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length / Fr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length / Fr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length / Fr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length / Fr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i } = t, s = Ft(t.nullBitmap), o = Oa(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, void 0, s], [i]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["children"]: i = [] } = t, s = Ft(t.nullBitmap), { length: o = i.reduce((c, { length: u }) => Math.max(c, u), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, void 0, s], i);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["children"]: i = [] } = t, s = Pt(n.ArrayType, t.typeIds), { ["length"]: o = s.length, ["nullCount"]: a = -1 } = t;
    if (st.isSparseUnion(n))
      return new jt(n, r, o, a, [void 0, void 0, void 0, s], i);
    const c = Oa(t.valueOffsets);
    return new jt(n, r, o, a, [c, void 0, void 0, s], i);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.indices.ArrayType, t.data), { ["dictionary"]: o = new ae([new nc().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [void 0, s, i], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length / Fr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitDuration(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i = new nc().visit({ type: n.valueType }) } = t, s = Ft(t.nullBitmap), { ["length"]: o = i.length / Fr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, void 0, s], [i]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i = new nc().visit({ type: n.childType }) } = t, s = Ft(t.nullBitmap), o = Oa(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, void 0, s], [i]);
  }
}
const HD = new nc();
function $t(e) {
  return HD.visit(e);
}
class N1 {
  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 y_(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function m_(e) {
  return e.reduce((t, n, r) => (t[r + 1] = t[r] + n.length, t), new Uint32Array(e.length + 1));
}
function g_(e, t, n, r) {
  const i = [];
  for (let s = -1, o = e.length; ++s < o; ) {
    const a = e[s], c = t[s], { length: u } = a;
    if (c >= r)
      break;
    if (n >= c + u)
      continue;
    if (c >= n && c + u <= r) {
      i.push(a);
      continue;
    }
    const l = Math.max(0, n - c), f = Math.min(r - c, u);
    i.push(a.slice(l, f - l));
  }
  return i.length === 0 && i.push(e[0].slice(0, 0)), i;
}
function Uy(e, t, n, r) {
  let i = 0, s = 0, o = t.length - 1;
  do {
    if (i >= o - 1)
      return n < t[o] ? r(e, i, n - t[i]) : null;
    s = i + Math.trunc((o - i) * 0.5), n < t[s] ? o = s : i = s;
  } while (i < o);
}
function zy(e, t) {
  return e.getValid(t);
}
function No(e) {
  function t(n, r, i) {
    return e(n[r], i);
  }
  return function(n) {
    const r = this.data;
    return Uy(r, this._offsets, n, t);
  };
}
function b_(e) {
  let t;
  function n(r, i, s) {
    return e(r[i], s, t);
  }
  return function(r, i) {
    const s = this.data;
    t = i;
    const o = Uy(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
function w_(e) {
  let t;
  function n(r, i, s) {
    let o = s, a = 0, c = 0;
    for (let u = i - 1, l = r.length; ++u < l; ) {
      const f = r[u];
      if (~(a = e(f, t, o)))
        return c + a;
      o = 0, c += f.length;
    }
    return -1;
  }
  return function(r, i) {
    t = r;
    const s = this.data, o = typeof i != "number" ? n(s, 0, 0) : Uy(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
class ut extends xt {
}
function JD(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function ZD(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let r = 0;
  for (const i of new Py(n, e.offset + (t || 0), e.length, n, p_)) {
    if (!i)
      return r;
    ++r;
  }
  return -1;
}
function bt(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    switch (e.typeId) {
      case L.Union:
        break;
      case L.Dictionary:
        break;
      default:
        return ZD(e, n);
    }
  const r = Ge.getVisitFn(e), i = pa(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (i(r(e, s)))
      return s;
  return -1;
}
function v_(e, t, n) {
  const r = Ge.getVisitFn(e), i = pa(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (i(r(e, s)))
      return s;
  return -1;
}
ut.prototype.visitNull = JD;
ut.prototype.visitBool = bt;
ut.prototype.visitInt = bt;
ut.prototype.visitInt8 = bt;
ut.prototype.visitInt16 = bt;
ut.prototype.visitInt32 = bt;
ut.prototype.visitInt64 = bt;
ut.prototype.visitUint8 = bt;
ut.prototype.visitUint16 = bt;
ut.prototype.visitUint32 = bt;
ut.prototype.visitUint64 = bt;
ut.prototype.visitFloat = bt;
ut.prototype.visitFloat16 = bt;
ut.prototype.visitFloat32 = bt;
ut.prototype.visitFloat64 = bt;
ut.prototype.visitUtf8 = bt;
ut.prototype.visitBinary = bt;
ut.prototype.visitFixedSizeBinary = bt;
ut.prototype.visitDate = bt;
ut.prototype.visitDateDay = bt;
ut.prototype.visitDateMillisecond = bt;
ut.prototype.visitTimestamp = bt;
ut.prototype.visitTimestampSecond = bt;
ut.prototype.visitTimestampMillisecond = bt;
ut.prototype.visitTimestampMicrosecond = bt;
ut.prototype.visitTimestampNanosecond = bt;
ut.prototype.visitTime = bt;
ut.prototype.visitTimeSecond = bt;
ut.prototype.visitTimeMillisecond = bt;
ut.prototype.visitTimeMicrosecond = bt;
ut.prototype.visitTimeNanosecond = bt;
ut.prototype.visitDecimal = bt;
ut.prototype.visitList = bt;
ut.prototype.visitStruct = bt;
ut.prototype.visitUnion = bt;
ut.prototype.visitDenseUnion = v_;
ut.prototype.visitSparseUnion = v_;
ut.prototype.visitDictionary = bt;
ut.prototype.visitInterval = bt;
ut.prototype.visitIntervalDayTime = bt;
ut.prototype.visitIntervalYearMonth = bt;
ut.prototype.visitDuration = bt;
ut.prototype.visitDurationSecond = bt;
ut.prototype.visitDurationMillisecond = bt;
ut.prototype.visitDurationMicrosecond = bt;
ut.prototype.visitDurationNanosecond = bt;
ut.prototype.visitFixedSizeList = bt;
ut.prototype.visitMap = bt;
const Wl = new ut();
class lt extends xt {
}
function pt(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === L.Timestamp || t instanceof Ei && t.bitWidth !== 64 || t instanceof bc && t.bitWidth !== 64 || t instanceof gc && t.precision !== Xe.HALF))
    return new N1(e.data.length, (r) => {
      const i = e.data[r];
      return i.values.subarray(0, i.length)[Symbol.iterator]();
    });
  let n = 0;
  return new N1(e.data.length, (r) => {
    const s = e.data[r].length, o = e.slice(n, n + s);
    return n += s, new KD(o);
  });
}
class KD {
  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;
  }
}
lt.prototype.visitNull = pt;
lt.prototype.visitBool = pt;
lt.prototype.visitInt = pt;
lt.prototype.visitInt8 = pt;
lt.prototype.visitInt16 = pt;
lt.prototype.visitInt32 = pt;
lt.prototype.visitInt64 = pt;
lt.prototype.visitUint8 = pt;
lt.prototype.visitUint16 = pt;
lt.prototype.visitUint32 = pt;
lt.prototype.visitUint64 = pt;
lt.prototype.visitFloat = pt;
lt.prototype.visitFloat16 = pt;
lt.prototype.visitFloat32 = pt;
lt.prototype.visitFloat64 = pt;
lt.prototype.visitUtf8 = pt;
lt.prototype.visitBinary = pt;
lt.prototype.visitFixedSizeBinary = pt;
lt.prototype.visitDate = pt;
lt.prototype.visitDateDay = pt;
lt.prototype.visitDateMillisecond = pt;
lt.prototype.visitTimestamp = pt;
lt.prototype.visitTimestampSecond = pt;
lt.prototype.visitTimestampMillisecond = pt;
lt.prototype.visitTimestampMicrosecond = pt;
lt.prototype.visitTimestampNanosecond = pt;
lt.prototype.visitTime = pt;
lt.prototype.visitTimeSecond = pt;
lt.prototype.visitTimeMillisecond = pt;
lt.prototype.visitTimeMicrosecond = pt;
lt.prototype.visitTimeNanosecond = pt;
lt.prototype.visitDecimal = pt;
lt.prototype.visitList = pt;
lt.prototype.visitStruct = pt;
lt.prototype.visitUnion = pt;
lt.prototype.visitDenseUnion = pt;
lt.prototype.visitSparseUnion = pt;
lt.prototype.visitDictionary = pt;
lt.prototype.visitInterval = pt;
lt.prototype.visitIntervalDayTime = pt;
lt.prototype.visitIntervalYearMonth = pt;
lt.prototype.visitDuration = pt;
lt.prototype.visitDurationSecond = pt;
lt.prototype.visitDurationMillisecond = pt;
lt.prototype.visitDurationMicrosecond = pt;
lt.prototype.visitDurationNanosecond = pt;
lt.prototype.visitFixedSizeList = pt;
lt.prototype.visitMap = pt;
const jy = new lt(), QD = (e, t) => e + t;
class Vi 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 === mt.SECOND ? 4 : 8;
  }
  visitInterval(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitDuration(t, n) {
    return 8;
  }
  visitStruct(t, n) {
    return t.children.reduce((r, i) => r + mr.visit(i, n), 0);
  }
  visitFixedSizeBinary(t, n) {
    return t.type.byteWidth;
  }
  visitMap(t, n) {
    return 8 + t.children.reduce((r, i) => r + mr.visit(i, n), 0);
  }
  visitDictionary(t, n) {
    var r;
    return t.type.indices.bitWidth / 8 + (((r = t.dictionary) === null || r === void 0 ? void 0 : r.getByteLength(t.values[n])) || 0);
  }
}
const t7 = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), e7 = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), n7 = ({ valueOffsets: e, stride: t, children: n }, r) => {
  const i = n[0], { [r * t]: s } = e, { [r * t + 1]: o } = e, a = mr.getVisitFn(i.type), c = i.slice(s, o - s);
  let u = 8;
  for (let l = -1, f = o - s; ++l < f; )
    u += a(c, l);
  return u;
}, r7 = ({ stride: e, children: t }, n) => {
  const r = t[0], i = r.slice(n * e, e), s = mr.getVisitFn(r.type);
  let o = 0;
  for (let a = -1, c = i.length; ++a < c; )
    o += s(i, a);
  return o;
}, i7 = (e, t) => e.type.mode === on.Dense ? __(e, t) : x_(e, t), __ = ({ type: e, children: t, typeIds: n, valueOffsets: r }, i) => {
  const s = e.typeIdToChildIndex[n[i]];
  return 8 + mr.visit(t[s], r[i]);
}, x_ = ({ children: e }, t) => 4 + mr.visitMany(e, e.map(() => t)).reduce(QD, 0);
Vi.prototype.visitUtf8 = t7;
Vi.prototype.visitBinary = e7;
Vi.prototype.visitList = n7;
Vi.prototype.visitFixedSizeList = r7;
Vi.prototype.visitUnion = i7;
Vi.prototype.visitDenseUnion = __;
Vi.prototype.visitSparseUnion = x_;
const mr = new Vi();
var S_;
const M_ = {}, A_ = {};
let ae = class ss {
  constructor(t) {
    var n, r, i;
    const s = t[0] instanceof ss ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof jt)))
      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 } = M_[o.typeId], f = s[0];
        this.isValid = (h) => zy(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, A_[o.typeId]), this._offsets = m_(s);
        break;
    }
    this.data = s, this.type = o, this.stride = Fr(o), this.numChildren = (i = (r = o.children) === null || r === void 0 ? void 0 : r.length) !== null && i !== void 0 ? i : 0, this.length = this._offsets.at(-1);
  }
  /**
   * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
   */
  get byteLength() {
    return this.data.reduce((t, n) => t + n.byteLength, 0);
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return y_(this.data);
  }
  /**
   * The Array or TypedArray 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 `${L[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) > -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 the Vector's elements.
   */
  [Symbol.iterator]() {
    return jy.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 ss(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 ss(d_(this, t, n, ({ data: r, _offsets: i }, s, o) => g_(r, i, 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: r, stride: i, ArrayType: s } = this;
    switch (t.typeId) {
      case L.Int:
      case L.Float:
      case L.Decimal:
      case L.Time:
      case L.Timestamp:
        switch (n.length) {
          case 0:
            return new s();
          case 1:
            return n[0].values.subarray(0, r * i);
          default:
            return n.reduce((o, { values: a, length: c }) => (o.array.set(a.subarray(0, c * i), o.offset), o.offset += c * i, o), { array: new s(r * i), 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((r) => r.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 ss(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return st.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 (st.isDictionary(this.type)) {
      const t = new Xl(this.data[0].dictionary), n = this.data.map((r) => {
        const i = r.clone();
        return i.dictionary = t, i;
      });
      return new ss(n);
    }
    return new Xl(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 (st.isDictionary(this.type) && this.isMemoized) {
      const t = this.data[0].dictionary.unmemoize(), n = this.data.map((r) => {
        const i = r.clone();
        return i.dictionary = t, i;
      });
      return new ss(n);
    }
    return this;
  }
};
S_ = Symbol.toStringTag;
ae[S_] = ((e) => {
  e.type = st.prototype, e.data = [], e.length = 0, e.stride = 1, e.numChildren = 0, e._offsets = new Uint32Array([0]), e[Symbol.isConcatSpreadable] = !0;
  const t = Object.keys(L).map((n) => L[n]).filter((n) => typeof n == "number" && n !== L.NONE);
  for (const n of t) {
    const r = Ge.getVisitFnByTypeId(n), i = xn.getVisitFnByTypeId(n), s = Wl.getVisitFnByTypeId(n), o = mr.getVisitFnByTypeId(n);
    M_[n] = { get: r, set: i, indexOf: s, byteLength: o }, A_[n] = Object.create(e, {
      isValid: { value: No(zy) },
      get: { value: No(Ge.getVisitFnByTypeId(n)) },
      set: { value: b_(xn.getVisitFnByTypeId(n)) },
      indexOf: { value: w_(Wl.getVisitFnByTypeId(n)) },
      getByteLength: { value: No(mr.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(ae.prototype);
class Xl extends ae {
  constructor(t) {
    super(t.data);
    const n = this.get, r = this.set, i = 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) {
        r.call(this, o, a), s[o] = a;
      }
    }), Object.defineProperty(this, "slice", {
      value: (o, a) => new Xl(i.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new ae(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}
class Jp {
  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, r, i) {
    return t.prep(8, 24), t.writeInt64(BigInt(i ?? 0)), t.pad(4), t.writeInt32(r), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}
const Pd = 2, er = 4, Br = 4, zt = 4, di = new Int32Array(2), D1 = new Float32Array(di.buffer), O1 = new Float64Array(di.buffer), Ru = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
var Zp;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(Zp || (Zp = {}));
let zo = class $_ {
  /**
   * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
   */
  constructor(t) {
    this.bytes_ = t, this.position_ = 0, this.text_decoder_ = new TextDecoder();
  }
  /**
   * Create and allocate a new ByteBuffer with a given size.
   */
  static allocate(t) {
    return new $_(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 BigInt.asIntN(64, BigInt(this.readUint32(t)) + (BigInt(this.readUint32(t + 4)) << BigInt(32)));
  }
  readUint64(t) {
    return BigInt.asUintN(64, BigInt(this.readUint32(t)) + (BigInt(this.readUint32(t + 4)) << BigInt(32)));
  }
  readFloat32(t) {
    return di[0] = this.readInt32(t), D1[0];
  }
  readFloat64(t) {
    return di[Ru ? 0 : 1] = this.readInt32(t), di[Ru ? 1 : 0] = this.readInt32(t + 4), O1[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, Number(BigInt.asIntN(32, n))), this.writeInt32(t + 4, Number(BigInt.asIntN(32, n >> BigInt(32))));
  }
  writeUint64(t, n) {
    this.writeUint32(t, Number(BigInt.asUintN(32, n))), this.writeUint32(t + 4, Number(BigInt.asUintN(32, n >> BigInt(32))));
  }
  writeFloat32(t, n) {
    D1[0] = n, this.writeInt32(t, di[0]);
  }
  writeFloat64(t, n) {
    O1[0] = n, this.writeInt32(t, di[Ru ? 0 : 1]), this.writeInt32(t + 4, di[Ru ? 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_ + er + Br)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < Br; n++)
      t += String.fromCharCode(this.readInt8(this.position_ + er + 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 r = t - this.readInt32(t);
    return n < this.readInt16(r) ? this.readInt16(r + 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 string, pass Encoding.UTF8_BYTES as the
   * "optionalEncoding" argument. This is useful for avoiding conversion 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 r = this.readInt32(t);
    t += er;
    const i = this.bytes_.subarray(t, t + r);
    return n === Zp.UTF8_BYTES ? i : this.text_decoder_.decode(i);
  }
  /**
   * 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) + er;
  }
  /**
   * 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 != Br)
      throw new Error("FlatBuffers: file identifier must be length " + Br);
    for (let n = 0; n < Br; n++)
      if (t.charCodeAt(n) != this.readInt8(this.position() + er + n))
        return !1;
    return !0;
  }
  /**
   * A helper function for generating list for obj api
   */
  createScalarList(t, n) {
    const r = [];
    for (let i = 0; i < n; ++i) {
      const s = t(i);
      s !== null && r.push(s);
    }
    return r;
  }
  /**
   * 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 r = [];
    for (let i = 0; i < n; ++i) {
      const s = t(i);
      s !== null && r.push(s.unpack());
    }
    return r;
  }
}, I_ = class T_ {
  /**
   * 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, this.text_encoder = new TextEncoder();
    let n;
    t ? n = t : n = 1024, this.bb = zo.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 r = ~(this.bb.capacity() - this.space + n) + 1 & t - 1;
    for (; this.space < r + t + n; ) {
      const i = this.bb.capacity();
      this.bb = T_.growByteBuffer(this.bb), this.space += this.bb.capacity() - i;
    }
    this.pad(r);
  }
  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 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 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 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 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 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 buffer.
   */
  addFloat64(t) {
    this.prep(8, 0), this.writeFloat64(t);
  }
  addFieldInt8(t, n, r) {
    (this.force_defaults || n != r) && (this.addInt8(n), this.slot(t));
  }
  addFieldInt16(t, n, r) {
    (this.force_defaults || n != r) && (this.addInt16(n), this.slot(t));
  }
  addFieldInt32(t, n, r) {
    (this.force_defaults || n != r) && (this.addInt32(n), this.slot(t));
  }
  addFieldInt64(t, n, r) {
    (this.force_defaults || n !== r) && (this.addInt64(n), this.slot(t));
  }
  addFieldFloat32(t, n, r) {
    (this.force_defaults || n != r) && (this.addFloat32(n), this.slot(t));
  }
  addFieldFloat64(t, n, r) {
    (this.force_defaults || n != r) && (this.addFloat64(n), this.slot(t));
  }
  addFieldOffset(t, n, r) {
    (this.force_defaults || n != r) && (this.addOffset(n), this.slot(t));
  }
  /**
   * Structs are stored inline, so nothing additional is being added. `d` is always 0.
   */
  addFieldStruct(t, n, r) {
    n != r && (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 TypeError("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 TypeError("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 r = n << 1, i = zo.allocate(r);
    return i.setPosition(r - n), i.bytes().set(t.bytes(), r - n), i;
  }
  /**
   * Adds on offset, relative to where it will be written.
   *
   * @param offset The offset to add.
   */
  addOffset(t) {
    this.prep(er, 0), this.writeInt32(this.offset() - t + er);
  }
  /**
   * 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 r = n + 1;
    for (; n >= 0; n--)
      this.addInt16(this.vtable[n] != 0 ? t - this.vtable[n] : 0);
    const i = 2;
    this.addInt16(t - this.object_start);
    const s = (r + i) * Pd;
    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 = Pd; u < s; u += Pd)
            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, r) {
    const i = r ? zt : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, er + Br + i), s.length != Br)
        throw new TypeError("FlatBuffers: file identifier must be length " + Br);
      for (let o = Br - 1; o >= 0; o--)
        this.writeInt8(s.charCodeAt(o));
    }
    this.prep(this.minalign, er + i), this.addOffset(t), i && 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 r = this.bb.capacity() - t, i = r - this.bb.readInt32(r);
    if (!(n < this.bb.readInt16(i) && this.bb.readInt16(i + n) != 0))
      throw new TypeError("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, r) {
    this.notNested(), this.vector_num_elems = n, this.prep(er, t * n), this.prep(r, 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 == null)
      return 0;
    let n;
    t instanceof Uint8Array ? n = t : n = this.text_encoder.encode(t), this.addInt8(0), this.startVector(1, n.length, 1), this.bb.setPosition(this.space -= n.length);
    for (let r = 0, i = this.space, s = this.bb.bytes(); r < n.length; r++)
      s[i++] = n[r];
    return this.endVector();
  }
  /**
   * 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 r = 0; r < t.length; ++r) {
      const i = t[r];
      if (i !== null)
        n.push(this.createObjectOffset(i));
      else
        throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return n;
  }
  createStructOffsetList(t, n) {
    return n(this, t.length), this.createObjectOffsetList(t.slice().reverse()), this.endVector();
  }
};
class le {
  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 le()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + zt), (n || new le()).__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, r) {
    return le.startKeyValue(t), le.addKey(t, n), le.addValue(t, r), le.endKeyValue(t);
  }
}
var jo;
(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";
})(jo || (jo = {}));
var qo;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(qo || (qo = {}));
var Gl;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(Gl || (Gl = {}));
class en {
  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 en()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + zt), (n || new en()).__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, r) {
    return en.startInt(t), en.addBitWidth(t, n), en.addIsSigned(t, r), en.endInt(t);
  }
}
class Pr {
  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 Pr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + zt), (n || new Pr()).__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) : BigInt("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 en()).__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) : Gl.DenseArray;
  }
  static startDictionaryEncoding(t) {
    t.startObject(4);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, BigInt("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, Gl.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}
class ls {
  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 ls()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + zt), (n || new ls()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return ls.startBinary(t), ls.endBinary(t);
  }
}
class fs {
  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 fs()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + zt), (n || new fs()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return fs.startBool(t), fs.endBool(t);
  }
}
var Hl;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Hl || (Hl = {}));
let gl = class ho {
  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 ho()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + zt), (n || new ho()).__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) : Hl.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Hl.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return ho.startDate(t), ho.addUnit(t, n), ho.endDate(t);
  }
};
class Ve {
  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 Ve()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + zt), (n || new Ve()).__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, r, i) {
    return Ve.startDecimal(t), Ve.addPrecision(t, n), Ve.addScale(t, r), Ve.addBitWidth(t, i), Ve.endDecimal(t);
  }
}
var Ni;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(Ni || (Ni = {}));
class nr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDuration(t, n) {
    return (n || new nr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDuration(t, n) {
    return t.setPosition(t.position() + zt), (n || new nr()).__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) : Ni.MILLISECOND;
  }
  static startDuration(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Ni.MILLISECOND);
  }
  static endDuration(t) {
    return t.endObject();
  }
  static createDuration(t, n) {
    return nr.startDuration(t), nr.addUnit(t, n), nr.endDuration(t);
  }
}
class rr {
  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 rr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + zt), (n || new rr()).__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 rr.startFixedSizeBinary(t), rr.addByteWidth(t, n), rr.endFixedSizeBinary(t);
  }
}
class ir {
  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 ir()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + zt), (n || new ir()).__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 ir.startFixedSizeList(t), ir.addListSize(t, n), ir.endFixedSizeList(t);
  }
}
var Jl;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(Jl || (Jl = {}));
class sr {
  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 sr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + zt), (n || new sr()).__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) : Jl.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, Jl.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return sr.startFloatingPoint(t), sr.addPrecision(t, n), sr.endFloatingPoint(t);
  }
}
var Zl;
(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";
})(Zl || (Zl = {}));
class or {
  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 or()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + zt), (n || new or()).__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) : Zl.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Zl.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return or.startInterval(t), or.addUnit(t, n), or.endInterval(t);
  }
}
class hs {
  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 hs()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + zt), (n || new hs()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return hs.startList(t), hs.endList(t);
  }
}
let bl = class po {
  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 po()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + zt), (n || new po()).__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 po.startMap(t), po.addKeysSorted(t, n), po.endMap(t);
  }
};
class ds {
  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 ds()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + zt), (n || new ds()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return ds.startNull(t), ds.endNull(t);
  }
}
class ps {
  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 ps()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + zt), (n || new ps()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return ps.startStruct_(t), ps.endStruct_(t);
  }
}
class yn {
  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 yn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + zt), (n || new yn()).__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) : Ni.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, Ni.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, r) {
    return yn.startTime(t), yn.addUnit(t, n), yn.addBitWidth(t, r), yn.endTime(t);
  }
}
class mn {
  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 mn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + zt), (n || new mn()).__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) : Ni.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, Ni.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, r) {
    return mn.startTimestamp(t), mn.addUnit(t, n), mn.addTimezone(t, r), mn.endTimestamp(t);
  }
}
var Kl;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(Kl || (Kl = {}));
class Ye {
  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 Ye()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + zt), (n || new Ye()).__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) : Kl.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, Kl.Sparse);
  }
  static addTypeIds(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createTypeIdsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addInt32(n[r]);
    return t.endVector();
  }
  static startTypeIdsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endUnion(t) {
    return t.endObject();
  }
  static createUnion(t, n, r) {
    return Ye.startUnion(t), Ye.addMode(t, n), Ye.addTypeIds(t, r), Ye.endUnion(t);
  }
}
class ys {
  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 ys()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + zt), (n || new ys()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return ys.startUtf8(t), ys.endUtf8(t);
  }
}
var Zt;
(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", e[e.RunEndEncoded = 22] = "RunEndEncoded";
})(Zt || (Zt = {}));
let dn = class wl {
  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 wl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + zt), (n || new wl()).__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) : Zt.NONE;
  }
  /**
   * This is the type of the decoded value if the field is dictionary encoded.
   */
  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 Pr()).__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 r = this.bb.__offset(this.bb_pos, 14);
    return r ? (n || new wl()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + 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 r = this.bb.__offset(this.bb_pos, 16);
    return r ? (n || new le()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + 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, Zt.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 r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    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 r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endField(t) {
    return t.endObject();
  }
}, Jn = class Or {
  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 Or()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsSchema(t, n) {
    return t.setPosition(t.position() + zt), (n || new Or()).__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) : qo.Little;
  }
  fields(t, n) {
    const r = this.bb.__offset(this.bb_pos, 6);
    return r ? (n || new dn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + 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 r = this.bb.__offset(this.bb_pos, 8);
    return r ? (n || new le()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + 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) : BigInt(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, qo.Little);
  }
  static addFields(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createFieldsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    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 r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    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 r = n.length - 1; r >= 0; r--)
      t.addInt64(n[r]);
    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, r, i, s) {
    return Or.startSchema(t), Or.addEndianness(t, n), Or.addFields(t, r), Or.addCustomMetadata(t, i), Or.addFeatures(t, s), Or.endSchema(t);
  }
};
class tn {
  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 tn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + zt), (n || new tn()).__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) : jo.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Jn()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  dictionaries(t, n) {
    const r = this.bb.__offset(this.bb_pos, 8);
    return r ? (n || new Jp()).__init(this.bb.__vector(this.bb_pos + r) + 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 r = this.bb.__offset(this.bb_pos, 10);
    return r ? (n || new Jp()).__init(this.bb.__vector(this.bb_pos + r) + 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 r = this.bb.__offset(this.bb_pos, 12);
    return r ? (n || new le()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + 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, jo.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 r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    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 Rt {
  constructor(t = [], n, r, i = Ie.V5) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), r || (r = Kp(t)), this.dictionaries = r, this.metadataVersion = 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), r = this.fields.filter((i) => n.has(i.name));
    return new Rt(r, 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((r) => this.fields[r]).filter(Boolean);
    return new Rt(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof Rt ? t[0] : Array.isArray(t[0]) ? new Rt(t[0]) : new Rt(t), r = [...this.fields], i = Cu(Cu(/* @__PURE__ */ new Map(), this.metadata), n.metadata), s = n.fields.filter((a) => {
      const c = r.findIndex((u) => u.name === a.name);
      return ~c ? (r[c] = a.clone({
        metadata: Cu(Cu(/* @__PURE__ */ new Map(), r[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = Kp(s, /* @__PURE__ */ new Map());
    return new Rt([...r, ...s], i, new Map([...this.dictionaries, ...o]));
  }
}
Rt.prototype.fields = null;
Rt.prototype.metadata = null;
Rt.prototype.dictionaries = null;
class Ht {
  /** @nocollapse */
  static new(...t) {
    let [n, r, i, s] = t;
    return t[0] && typeof t[0] == "object" && ({ name: n } = t[0], r === void 0 && (r = t[0].type), i === void 0 && (i = t[0].nullable), s === void 0 && (s = t[0].metadata)), new Ht(`${n}`, r, i, s);
  }
  constructor(t, n, r = !1, i) {
    this.name = t, this.type = n, this.nullable = r, this.metadata = i || /* @__PURE__ */ new Map();
  }
  get typeId() {
    return this.type.typeId;
  }
  get [Symbol.toStringTag]() {
    return "Field";
  }
  toString() {
    return `${this.name}: ${this.type}`;
  }
  clone(...t) {
    let [n, r, i, s] = t;
    return !t[0] || typeof t[0] != "object" ? [n = this.name, r = this.type, i = this.nullable, s = this.metadata] = t : { name: n = this.name, type: r = this.type, nullable: i = this.nullable, metadata: s = this.metadata } = t[0], Ht.new(n, r, i, s);
  }
}
Ht.prototype.type = null;
Ht.prototype.name = null;
Ht.prototype.nullable = null;
Ht.prototype.metadata = null;
function Cu(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function Kp(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, r = e.length; ++n < r; ) {
    const s = e[n].type;
    if (st.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 && Kp(s.children, t);
  }
  return t;
}
var s7 = I_, o7 = zo;
class qy {
  /** @nocollapse */
  static decode(t) {
    t = new o7(Ft(t));
    const n = tn.getRootAsFooter(t), r = Rt.decode(n.schema(), /* @__PURE__ */ new Map(), n.version());
    return new a7(r, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new s7(), r = Rt.encode(n, t.schema);
    tn.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      Vo.encode(n, o);
    const i = n.endVector();
    tn.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      Vo.encode(n, o);
    const s = n.endVector();
    return tn.startFooter(n), tn.addSchema(n, r), tn.addVersion(n, Ie.V5), tn.addRecordBatches(n, i), tn.addDictionaries(n, s), tn.finishFooterBuffer(n, tn.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  constructor(t, n = Ie.V5, r, i) {
    this.schema = t, this.version = n, r && (this._recordBatches = r), i && (this._dictionaryBatches = i);
  }
  *recordBatches() {
    for (let t, n = -1, r = this.numRecordBatches; ++n < r; )
      (t = this.getRecordBatch(n)) && (yield t);
  }
  *dictionaryBatches() {
    for (let t, n = -1, r = this.numDictionaries; ++n < r; )
      (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 a7 extends qy {
  get numRecordBatches() {
    return this._footer.recordBatchesLength();
  }
  get numDictionaries() {
    return this._footer.dictionariesLength();
  }
  constructor(t, n) {
    super(t, n.version()), this._footer = n;
  }
  getRecordBatch(t) {
    if (t >= 0 && t < this.numRecordBatches) {
      const n = this._footer.recordBatches(t);
      if (n)
        return Vo.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return Vo.decode(n);
    }
    return null;
  }
}
class Vo {
  /** @nocollapse */
  static decode(t) {
    return new Vo(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: r } = n, i = BigInt(n.offset), s = BigInt(n.bodyLength);
    return Jp.createBlock(t, i, r, s);
  }
  constructor(t, n, r) {
    this.metaDataLength = t, this.offset = Cn(r), this.bodyLength = Cn(n);
  }
}
const ee = Object.freeze({ done: !0, value: void 0 });
class L1 {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}
class E_ {
  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 c7 extends E_ {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return gt(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(ee);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return pn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return pn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return gt(this, void 0, void 0, function* () {
      return yield this.abort(t), ee;
    });
  }
  return(t) {
    return gt(this, void 0, void 0, function* () {
      return yield this.close(), ee;
    });
  }
  read(t) {
    return gt(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return gt(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, r) => {
      this.resolvers.push({ resolve: n, reject: r });
    }) : Promise.resolve(ee);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}
class u7 extends c7 {
  write(t) {
    if ((t = Ft(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? Yp(this.toUint8Array(!0)) : this.toUint8Array(!1).then(Yp);
  }
  toUint8Array(t = !1) {
    return t ? yr(this._values)[0] : gt(this, void 0, void 0, function* () {
      var n, r, i, s;
      const o = [];
      let a = 0;
      try {
        for (var c = !0, u = Ao(this), l; l = yield u.next(), n = l.done, !n; c = !0) {
          s = l.value, c = !1;
          const f = s;
          o.push(f), a += f.byteLength;
        }
      } catch (f) {
        r = { error: f };
      } finally {
        try {
          !c && !n && (i = u.return) && (yield i.call(u));
        } finally {
          if (r)
            throw r.error;
        }
      }
      return yr(o, a)[0];
    });
  }
}
class Ql {
  constructor(t) {
    t && (this.source = new l7(pn.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 Yo {
  constructor(t) {
    t instanceof Yo ? this.source = t.source : t instanceof u7 ? this.source = new rs(pn.fromAsyncIterable(t)) : ev(t) ? this.source = new rs(pn.fromNodeStream(t)) : Dy(t) ? this.source = new rs(pn.fromDOMStream(t)) : Q2(t) ? this.source = new rs(pn.fromDOMStream(t.body)) : Mh(t) ? this.source = new rs(pn.fromIterable(t)) : hc(t) ? this.source = new rs(pn.fromAsyncIterable(t)) : Ny(t) && (this.source = new rs(pn.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 l7 {
  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) || ee);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || ee);
  }
}
class rs {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return gt(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return gt(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return gt(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return gt(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return gt(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || ee;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return gt(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || ee;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}
class k1 extends Ql {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Ft(t), this.size = n === void 0 ? this.buffer.byteLength : n;
  }
  readInt32(t) {
    const { buffer: n, byteOffset: r } = this.readAt(t, 4);
    return new DataView(n, r).getInt32(0, !0);
  }
  seek(t) {
    return this.position = Math.min(t, this.size), t < this.size;
  }
  read(t) {
    const { buffer: n, size: r, position: i } = this;
    return n && i < r ? (typeof t != "number" && (t = Number.POSITIVE_INFINITY), this.position = Math.min(r, i + Math.min(r - i, t)), n.subarray(i, this.position)) : null;
  }
  readAt(t, n) {
    const r = this.buffer, i = Math.min(this.size, t + n);
    return r ? r.subarray(t, i) : 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 tf extends Yo {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = gt(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    });
  }
  readInt32(t) {
    return gt(this, void 0, void 0, function* () {
      const { buffer: n, byteOffset: r } = yield this.readAt(t, 4);
      return new DataView(n, r).getInt32(0, !0);
    });
  }
  seek(t) {
    return gt(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 gt(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: n, size: r, position: i } = this;
      if (n && i < r) {
        typeof t != "number" && (t = Number.POSITIVE_INFINITY);
        let s = i, o = 0, a = 0;
        const c = Math.min(r, s + Math.min(r - 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 gt(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: r, size: i } = this;
      if (r && t + n < i) {
        const s = Math.min(i, t + n), o = new Uint8Array(s - t);
        return (yield r.read(o, 0, n, t)).buffer;
      }
      return new Uint8Array(n);
    });
  }
  close() {
    return gt(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return gt(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return gt(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
}
const f7 = 65536;
function go(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const Wo = 8, Vy = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
class N_ {
  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
    ]), r = new Uint32Array([
      t.buffer[1] >>> 16,
      t.buffer[1] & 65535,
      t.buffer[0] >>> 16,
      t.buffer[0] & 65535
    ]);
    let i = n[3] * r[3];
    this.buffer[0] = i & 65535;
    let s = i >>> 16;
    return i = n[2] * r[3], s += i, i = n[3] * r[2] >>> 0, s += i, this.buffer[0] += s << 16, this.buffer[1] = s >>> 0 < i ? f7 : 0, this.buffer[1] += s >>> 16, this.buffer[1] += n[1] * r[3] + n[2] * r[2] + n[3] * r[1], this.buffer[1] += n[0] * r[3] + n[1] * r[2] + n[2] * r[1] + n[3] * r[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 `${go(this.buffer[1])} ${go(this.buffer[0])}`;
  }
}
class Bt extends N_ {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Bt.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Bt.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const r = t.length, i = new Bt(n);
    for (let s = 0; s < r; ) {
      const o = Wo < r - s ? Wo : r - s, a = new Bt(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Bt(new Uint32Array([Vy[o], 0]));
      i.times(c), i.plus(a), s += o;
    }
    return i;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let r = -1, i = t.length; ++r < i; )
      Bt.from(t[r], new Uint32Array(n.buffer, n.byteOffset + 2 * r * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Bt(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Bt(new Uint32Array(t.buffer)).plus(n);
  }
}
class je extends N_ {
  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, r = t.buffer[1] << 0;
    return n < r || n === r && this.buffer[0] < t.buffer[0];
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return je.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return je.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const r = t.startsWith("-"), i = t.length, s = new je(n);
    for (let o = r ? 1 : 0; o < i; ) {
      const a = Wo < i - o ? Wo : i - o, c = new je(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), u = new je(new Uint32Array([Vy[a], 0]));
      s.times(u), s.plus(c), o += a;
    }
    return r ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let r = -1, i = t.length; ++r < i; )
      je.from(t[r], new Uint32Array(n.buffer, n.byteOffset + 2 * r * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new je(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new je(new Uint32Array(t.buffer)).plus(n);
  }
}
class Zn {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new je(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new je(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 Bt(new Uint32Array([this.buffer[3], 0])), r = new Bt(new Uint32Array([this.buffer[2], 0])), i = new Bt(new Uint32Array([this.buffer[1], 0])), s = new Bt(new Uint32Array([this.buffer[0], 0])), o = new Bt(new Uint32Array([t.buffer[3], 0])), a = new Bt(new Uint32Array([t.buffer[2], 0])), c = new Bt(new Uint32Array([t.buffer[1], 0])), u = new Bt(new Uint32Array([t.buffer[0], 0]));
    let l = Bt.multiply(s, u);
    this.buffer[0] = l.low();
    const f = new Bt(new Uint32Array([l.high(), 0]));
    return l = Bt.multiply(i, u), f.plus(l), l = Bt.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 Bt(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(Bt.multiply(r, u)).plus(Bt.multiply(i, c)).plus(Bt.multiply(s, a)), this.buffer[3] += Bt.multiply(n, u).plus(Bt.multiply(r, c)).plus(Bt.multiply(i, a)).plus(Bt.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 `${go(this.buffer[3])} ${go(this.buffer[2])} ${go(this.buffer[1])} ${go(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Zn(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Zn(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return Zn.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return Zn.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const r = t.startsWith("-"), i = t.length, s = new Zn(n);
    for (let o = r ? 1 : 0; o < i; ) {
      const a = Wo < i - o ? Wo : i - o, c = new Zn(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), u = new Zn(new Uint32Array([Vy[a], 0, 0, 0]));
      s.times(u), s.plus(c), o += a;
    }
    return r ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 4);
    for (let r = -1, i = t.length; ++r < i; )
      Zn.from(t[r], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * r, 4));
    return n;
  }
}
class D_ extends xt {
  constructor(t, n, r, i, s = Ie.V5) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = r, this.dictionaries = i, this.metadataVersion = s;
  }
  visit(t) {
    return super.visit(t instanceof Ht ? t.type : t);
  }
  visitNull(t, { length: n } = this.nextFieldNode()) {
    return $t({ type: t, length: n });
  }
  visitBool(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitInt(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitFloat(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitUtf8(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitBinary(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitFixedSizeBinary(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitDate(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitTimestamp(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitTime(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitDecimal(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitList(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  visitStruct(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), children: this.visitMany(t.children) });
  }
  visitUnion(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return this.metadataVersion < Ie.V5 && this.readNullBitmap(t, r), t.mode === on.Sparse ? this.visitSparseUnion(t, { length: n, nullCount: r }) : this.visitDenseUnion(t, { length: n, nullCount: r });
  }
  visitDenseUnion(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, typeIds: this.readTypeIds(t), valueOffsets: this.readOffsets(t), children: this.visitMany(t.children) });
  }
  visitSparseUnion(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, typeIds: this.readTypeIds(t), children: this.visitMany(t.children) });
  }
  visitDictionary(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t.indices), dictionary: this.readDictionary(t) });
  }
  visitInterval(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitDuration(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitFixedSizeList(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), child: this.visit(t.children[0]) });
  }
  visitMap(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), 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, r = this.nextBufferRange()) {
    return n > 0 && this.readData(t, r) || new Uint8Array(0);
  }
  readOffsets(t, n) {
    return this.readData(t, n);
  }
  readTypeIds(t, n) {
    return this.readData(t, n);
  }
  readData(t, { length: n, offset: r } = this.nextBufferRange()) {
    return this.bytes.subarray(r, r + n);
  }
  readDictionary(t) {
    return this.dictionaries.get(t.id);
  }
}
class h7 extends D_ {
  constructor(t, n, r, i, s) {
    super(new Uint8Array(0), n, r, i, s), this.sources = t;
  }
  readNullBitmap(t, n, { offset: r } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : Gp(this.sources[r]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return Pt(Uint8Array, Pt(Int32Array, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return Pt(Uint8Array, Pt(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: r } = this;
    return st.isTimestamp(t) || (st.isInt(t) || st.isTime(t)) && t.bitWidth === 64 || st.isDuration(t) || st.isDate(t) && t.unit === Zr.MILLISECOND ? Pt(Uint8Array, je.convertArray(r[n])) : st.isDecimal(t) ? Pt(Uint8Array, Zn.convertArray(r[n])) : st.isBinary(t) || st.isFixedSizeBinary(t) ? d7(r[n]) : st.isBool(t) ? Gp(r[n]) : st.isUtf8(t) ? Ey(r[n].join("")) : Pt(Uint8Array, Pt(t.ArrayType, r[n].map((i) => +i)));
  }
}
function d7(e) {
  const t = e.join(""), n = new Uint8Array(t.length / 2);
  for (let r = 0; r < t.length; r += 2)
    n[r >> 1] = Number.parseInt(t.slice(r, r + 2), 16);
  return n;
}
class ft 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((r, i) => this.compareFields(r, n[i]));
  }
  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 Ue(e, t) {
  return t instanceof e.constructor;
}
function Wc(e, t) {
  return e === t || Ue(e, t);
}
function ni(e, t) {
  return e === t || Ue(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function $h(e, t) {
  return e === t || Ue(e, t) && e.precision === t.precision;
}
function p7(e, t) {
  return e === t || Ue(e, t) && e.byteWidth === t.byteWidth;
}
function Yy(e, t) {
  return e === t || Ue(e, t) && e.unit === t.unit;
}
function Xc(e, t) {
  return e === t || Ue(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function Gc(e, t) {
  return e === t || Ue(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function y7(e, t) {
  return e === t || Ue(e, t) && e.children.length === t.children.length && Di.compareManyFields(e.children, t.children);
}
function m7(e, t) {
  return e === t || Ue(e, t) && e.children.length === t.children.length && Di.compareManyFields(e.children, t.children);
}
function Wy(e, t) {
  return e === t || Ue(e, t) && e.mode === t.mode && e.typeIds.every((n, r) => n === t.typeIds[r]) && Di.compareManyFields(e.children, t.children);
}
function g7(e, t) {
  return e === t || Ue(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && Di.visit(e.indices, t.indices) && Di.visit(e.dictionary, t.dictionary);
}
function Xy(e, t) {
  return e === t || Ue(e, t) && e.unit === t.unit;
}
function Hc(e, t) {
  return e === t || Ue(e, t) && e.unit === t.unit;
}
function b7(e, t) {
  return e === t || Ue(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && Di.compareManyFields(e.children, t.children);
}
function w7(e, t) {
  return e === t || Ue(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && Di.compareManyFields(e.children, t.children);
}
ft.prototype.visitNull = Wc;
ft.prototype.visitBool = Wc;
ft.prototype.visitInt = ni;
ft.prototype.visitInt8 = ni;
ft.prototype.visitInt16 = ni;
ft.prototype.visitInt32 = ni;
ft.prototype.visitInt64 = ni;
ft.prototype.visitUint8 = ni;
ft.prototype.visitUint16 = ni;
ft.prototype.visitUint32 = ni;
ft.prototype.visitUint64 = ni;
ft.prototype.visitFloat = $h;
ft.prototype.visitFloat16 = $h;
ft.prototype.visitFloat32 = $h;
ft.prototype.visitFloat64 = $h;
ft.prototype.visitUtf8 = Wc;
ft.prototype.visitBinary = Wc;
ft.prototype.visitFixedSizeBinary = p7;
ft.prototype.visitDate = Yy;
ft.prototype.visitDateDay = Yy;
ft.prototype.visitDateMillisecond = Yy;
ft.prototype.visitTimestamp = Xc;
ft.prototype.visitTimestampSecond = Xc;
ft.prototype.visitTimestampMillisecond = Xc;
ft.prototype.visitTimestampMicrosecond = Xc;
ft.prototype.visitTimestampNanosecond = Xc;
ft.prototype.visitTime = Gc;
ft.prototype.visitTimeSecond = Gc;
ft.prototype.visitTimeMillisecond = Gc;
ft.prototype.visitTimeMicrosecond = Gc;
ft.prototype.visitTimeNanosecond = Gc;
ft.prototype.visitDecimal = Wc;
ft.prototype.visitList = y7;
ft.prototype.visitStruct = m7;
ft.prototype.visitUnion = Wy;
ft.prototype.visitDenseUnion = Wy;
ft.prototype.visitSparseUnion = Wy;
ft.prototype.visitDictionary = g7;
ft.prototype.visitInterval = Xy;
ft.prototype.visitIntervalDayTime = Xy;
ft.prototype.visitIntervalYearMonth = Xy;
ft.prototype.visitDuration = Hc;
ft.prototype.visitDurationSecond = Hc;
ft.prototype.visitDurationMillisecond = Hc;
ft.prototype.visitDurationMicrosecond = Hc;
ft.prototype.visitDurationNanosecond = Hc;
ft.prototype.visitFixedSizeList = b7;
ft.prototype.visitMap = w7;
const Di = new ft();
function v7(e, t) {
  return Di.compareSchemas(e, t);
}
function Ud(e, t) {
  return _7(e, t.map((n) => n.data.concat()));
}
function _7(e, t) {
  const n = [...e.fields], r = [], i = { 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 (; i.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 = x7(n, o, l, t, i), o > 0 && (r[s++] = $t({
      type: new Fe(n),
      length: o,
      nullCount: 0,
      children: l.slice()
    })));
  }
  return [
    e = e.assign(n),
    r.map((f) => new Nn(e, f))
  ];
}
function x7(e, t, n, r, i) {
  var s;
  const o = (t + 63 & -64) >> 3;
  for (let a = -1, c = r.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), i.numBatches = Math.max(i.numBatches, r[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 O_;
let wc = class os {
  constructor(...t) {
    var n, r;
    if (t.length === 0)
      return this.batches = [], this.schema = new Rt([]), this._offsets = [0], this;
    let i, s;
    t[0] instanceof Rt && (i = t.shift()), t.at(-1) instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof Nn)
          return [c];
        if (c instanceof os)
          return c.batches;
        if (c instanceof jt) {
          if (c.type instanceof Fe)
            return [new Nn(new Rt(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 ae([c[d]])), f = new Rt(u.map((d, p) => new Ht(String(d), l[p].type))), [, h] = Ud(f, l);
            return h.length === 0 ? [new Nn(c)] : h;
          }
        }
      }
      return [];
    }, a = t.flatMap((c) => o(c));
    if (i = (r = i ?? ((n = a[0]) === null || n === void 0 ? void 0 : n.schema)) !== null && r !== void 0 ? r : new Rt([]), !(i instanceof Rt))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof Nn))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!v7(i, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = i, this.batches = a, this._offsets = s ?? m_(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 = y_(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 ? jy.visit(new ae(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, r = this.data.concat(t.flatMap(({ data: i }) => i));
    return new os(n, r.map((i) => new Nn(n, i)));
  }
  /**
   * 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 r = this.schema;
    [t, n] = d_({ length: this.numRows }, t, n);
    const i = g_(this.data, this._offsets, t, n);
    return new os(r, i.map((s) => new Nn(r, 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((r) => r.children[t]);
      if (n.length === 0) {
        const { type: r } = this.schema.fields[t], i = $t({ type: r, length: 0, nullCount: 0 });
        n.push(i._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new ae(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 r;
    return this.setChildAt((r = this.schema.fields) === null || r === void 0 ? void 0 : r.findIndex((i) => i.name === t), n);
  }
  setChildAt(t, n) {
    let r = this.schema, i = [...this.batches];
    if (t > -1 && t < this.numCols) {
      n || (n = new ae([$t({ type: new Ti(), length: this.numRows })]));
      const s = r.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], [r, i] = Ud(r, a);
    }
    return new os(r, i);
  }
  /**
   * 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((r, i, s) => r.set(i.name, s), /* @__PURE__ */ new Map());
    return this.selectAt(t.map((r) => n.get(r)).filter((r) => r > -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), r = this.batches.map((i) => i.selectAt(t));
    return new os(n, r);
  }
  assign(t) {
    const n = this.schema.fields, [r, i] = 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, i[c]]).map(([a, c]) => c === void 0 ? this.getChildAt(a) : t.getChildAt(c)),
      ...r.map((a) => t.getChildAt(a))
    ].filter(Boolean);
    return new os(...Ud(s, o));
  }
};
O_ = Symbol.toStringTag;
wc[O_] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = No(zy), e.get = No(Ge.getVisitFn(L.Struct)), e.set = b_(xn.getVisitFn(L.Struct)), e.indexOf = w_(Wl.getVisitFn(L.Struct)), e.getByteLength = No(mr.getVisitFn(L.Struct)), "Table"))(wc.prototype);
var L_;
let Nn = class Wa {
  constructor(...t) {
    switch (t.length) {
      case 2: {
        if ([this.schema] = t, !(this.schema instanceof Rt))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = $t({
            nullCount: 0,
            type: new Fe(this.schema.fields),
            children: this.schema.fields.map((n) => $t({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof jt))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = F1(this.schema, this.data.children);
        break;
      }
      case 1: {
        const [n] = t, { fields: r, children: i, 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] = Ht.new({ name: u, type: n[u].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new Rt(r), a = $t({ type: new Fe(r), length: s, children: i, nullCount: 0 });
        [this.schema, this.data] = F1(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 = k_(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 Ge.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 xn.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 Wl.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 mr.visit(this.data, t);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return jy.visit(new ae([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 wc(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 [r] = new ae([this.data]).slice(t, n).data;
    return new Wa(this.schema, r);
  }
  /**
   * 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((r) => r.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 ae([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 r;
    return this.setChildAt((r = this.schema.fields) === null || r === void 0 ? void 0 : r.findIndex((i) => i.name === t), n);
  }
  setChildAt(t, n) {
    let r = this.schema, i = this.data;
    if (t > -1 && t < this.numCols) {
      n || (n = new ae([$t({ type: new Ti(), length: this.numRows })]));
      const s = r.fields.slice(), o = i.children.slice(), a = s[t].clone({ type: n.type });
      [s[t], o[t]] = [a, n.data[0]], r = new Rt(s, new Map(this.schema.metadata)), i = $t({ type: new Fe(s), children: o });
    }
    return new Wa(r, i);
  }
  /**
   * 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), r = new Fe(n.fields), i = [];
    for (const s of t) {
      const o = this.schema.fields.findIndex((a) => a.name === s);
      ~o && (i[o] = this.data.children[o]);
    }
    return new Wa(n, $t({ type: r, length: this.numRows, children: i }));
  }
  /**
   * 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), r = t.map((s) => this.data.children[s]).filter(Boolean), i = $t({ type: new Fe(n.fields), length: this.numRows, children: r });
    return new Wa(n, i);
  }
};
L_ = Symbol.toStringTag;
Nn[L_] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(Nn.prototype);
function F1(e, t, n = t.reduce((r, i) => Math.max(r, i.length), 0)) {
  var r;
  const i = [...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) && (i[a] = c.clone({ nullable: !0 }), s[a] = (r = u == null ? void 0 : u._changeLengthAndBackfillNullBitmap(n)) !== null && r !== void 0 ? r : $t({
      type: c.type,
      length: n,
      nullCount: n,
      nullBitmap: new Uint8Array(o)
    }));
  }
  return [
    e.assign(i),
    $t({ type: new Fe(i), length: n, children: s })
  ];
}
function k_(e, t, n = /* @__PURE__ */ new Map()) {
  var r, i;
  if (((r = e == null ? void 0 : e.length) !== null && r !== void 0 ? r : 0) > 0 && (e == null ? void 0 : e.length) === (t == null ? void 0 : t.length))
    for (let s = -1, o = e.length; ++s < o; ) {
      const { type: a } = e[s], c = t[s];
      for (const u of [c, ...((i = c == null ? void 0 : c.dictionary) === null || i === void 0 ? void 0 : i.data) || []])
        k_(a.children, u == null ? void 0 : u.children, n);
      if (st.isDictionary(a)) {
        const { id: u } = a;
        if (!n.has(u))
          c != null && c.dictionary && n.set(u, c.dictionary);
        else if (n.get(u) !== c.dictionary)
          throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
      }
    }
  return n;
}
class F_ extends Nn {
  constructor(t) {
    const n = t.fields.map((i) => $t({ type: i.type })), r = $t({ type: new Fe(t.fields), nullCount: 0, children: n });
    super(t, r);
  }
}
var ef;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(ef || (ef = {}));
var nf;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(nf || (nf = {}));
class pi {
  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 pi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + zt), (n || new pi()).__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) : nf.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) : ef.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, nf.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, ef.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, r) {
    return pi.startBodyCompression(t), pi.addCodec(t, n), pi.addMethod(t, r), pi.endBodyCompression(t);
  }
}
class R_ {
  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, r) {
    return t.prep(8, 16), t.writeInt64(BigInt(r ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}
let C_ = 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, r) {
    return t.prep(8, 16), t.writeInt64(BigInt(r ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, Rr = class Qp {
  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 Qp()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + zt), (n || new Qp()).__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) : BigInt("0");
  }
  /**
   * Nodes correspond to the pre-ordered flattened logical schema
   */
  nodes(t, n) {
    const r = this.bb.__offset(this.bb_pos, 6);
    return r ? (n || new C_()).__init(this.bb.__vector(this.bb_pos + r) + 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 r = this.bb.__offset(this.bb_pos, 8);
    return r ? (n || new R_()).__init(this.bb.__vector(this.bb_pos + r) + 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 pi()).__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, BigInt("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();
  }
}, yo = class t0 {
  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 t0()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + zt), (n || new t0()).__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) : BigInt("0");
  }
  data(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Rr()).__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, BigInt("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 rf;
(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";
})(rf || (rf = {}));
let ui = class Hn {
  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 Hn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + zt), (n || new Hn()).__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) : jo.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : rf.NONE;
  }
  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) : BigInt("0");
  }
  customMetadata(t, n) {
    const r = this.bb.__offset(this.bb_pos, 12);
    return r ? (n || new le()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + 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, jo.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, rf.NONE);
  }
  static addHeader(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static addBodyLength(t, n) {
    t.addFieldInt64(3, n, BigInt("0"));
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    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, r, i, s, o) {
    return Hn.startMessage(t), Hn.addVersion(t, n), Hn.addHeaderType(t, r), Hn.addHeader(t, i), Hn.addBodyLength(t, s), Hn.addCustomMetadata(t, o), Hn.endMessage(t);
  }
};
class S7 extends xt {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return ds.startNull(n), ds.endNull(n);
  }
  visitInt(t, n) {
    return en.startInt(n), en.addBitWidth(n, t.bitWidth), en.addIsSigned(n, t.isSigned), en.endInt(n);
  }
  visitFloat(t, n) {
    return sr.startFloatingPoint(n), sr.addPrecision(n, t.precision), sr.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return ls.startBinary(n), ls.endBinary(n);
  }
  visitBool(t, n) {
    return fs.startBool(n), fs.endBool(n);
  }
  visitUtf8(t, n) {
    return ys.startUtf8(n), ys.endUtf8(n);
  }
  visitDecimal(t, n) {
    return Ve.startDecimal(n), Ve.addScale(n, t.scale), Ve.addPrecision(n, t.precision), Ve.addBitWidth(n, t.bitWidth), Ve.endDecimal(n);
  }
  visitDate(t, n) {
    return gl.startDate(n), gl.addUnit(n, t.unit), gl.endDate(n);
  }
  visitTime(t, n) {
    return yn.startTime(n), yn.addUnit(n, t.unit), yn.addBitWidth(n, t.bitWidth), yn.endTime(n);
  }
  visitTimestamp(t, n) {
    const r = t.timezone && n.createString(t.timezone) || void 0;
    return mn.startTimestamp(n), mn.addUnit(n, t.unit), r !== void 0 && mn.addTimezone(n, r), mn.endTimestamp(n);
  }
  visitInterval(t, n) {
    return or.startInterval(n), or.addUnit(n, t.unit), or.endInterval(n);
  }
  visitDuration(t, n) {
    return nr.startDuration(n), nr.addUnit(n, t.unit), nr.endDuration(n);
  }
  visitList(t, n) {
    return hs.startList(n), hs.endList(n);
  }
  visitStruct(t, n) {
    return ps.startStruct_(n), ps.endStruct_(n);
  }
  visitUnion(t, n) {
    Ye.startTypeIdsVector(n, t.typeIds.length);
    const r = Ye.createTypeIdsVector(n, t.typeIds);
    return Ye.startUnion(n), Ye.addMode(n, t.mode), Ye.addTypeIds(n, r), Ye.endUnion(n);
  }
  visitDictionary(t, n) {
    const r = this.visit(t.indices, n);
    return Pr.startDictionaryEncoding(n), Pr.addId(n, BigInt(t.id)), Pr.addIsOrdered(n, t.isOrdered), r !== void 0 && Pr.addIndexType(n, r), Pr.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return rr.startFixedSizeBinary(n), rr.addByteWidth(n, t.byteWidth), rr.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return ir.startFixedSizeList(n), ir.addListSize(n, t.listSize), ir.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return bl.startMap(n), bl.addKeysSorted(n, t.keysSorted), bl.endMap(n);
  }
}
const zd = new S7();
function M7(e, t = /* @__PURE__ */ new Map()) {
  return new Rt($7(e, t), vl(e.metadata), t);
}
function B_(e) {
  return new Bn(e.count, P_(e.columns), U_(e.columns));
}
function A7(e) {
  return new Kr(B_(e.data), e.id, e.isDelta);
}
function $7(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => Ht.fromJSON(n, t));
}
function R1(e, t) {
  return (e.children || []).filter(Boolean).map((n) => Ht.fromJSON(n, t));
}
function P_(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new ya(n.count, I7(n.VALIDITY)),
    ...P_(n.children)
  ], []);
}
function U_(e, t = []) {
  for (let n = -1, r = (e || []).length; ++n < r; ) {
    const i = e[n];
    i.VALIDITY && t.push(new Ur(t.length, i.VALIDITY.length)), i.TYPE_ID && t.push(new Ur(t.length, i.TYPE_ID.length)), i.OFFSET && t.push(new Ur(t.length, i.OFFSET.length)), i.DATA && t.push(new Ur(t.length, i.DATA.length)), t = U_(i.children, t);
  }
  return t;
}
function I7(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function T7(e, t) {
  let n, r, i, s, o, a;
  return !t || !(s = e.dictionary) ? (o = B1(e, R1(e, t)), i = new Ht(e.name, o, e.nullable, vl(e.metadata))) : t.has(n = s.id) ? (r = (r = s.indexType) ? C1(r) : new mc(), a = new Uo(t.get(n), r, n, s.isOrdered), i = new Ht(e.name, a, e.nullable, vl(e.metadata))) : (r = (r = s.indexType) ? C1(r) : new mc(), t.set(n, o = B1(e, R1(e, t))), a = new Uo(o, r, n, s.isOrdered), i = new Ht(e.name, a, e.nullable, vl(e.metadata))), i || null;
}
function vl(e = []) {
  return new Map(e.map(({ key: t, value: n }) => [t, n]));
}
function C1(e) {
  return new Ei(e.isSigned, e.bitWidth);
}
function B1(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new Ti();
    case "null":
      return new Ti();
    case "binary":
      return new Ll();
    case "utf8":
      return new kl();
    case "bool":
      return new Fl();
    case "list":
      return new zl((t || [])[0]);
    case "struct":
      return new Fe(t || []);
    case "struct_":
      return new Fe(t || []);
  }
  switch (n) {
    case "int": {
      const r = e.type;
      return new Ei(r.isSigned, r.bitWidth);
    }
    case "floatingpoint": {
      const r = e.type;
      return new gc(Xe[r.precision]);
    }
    case "decimal": {
      const r = e.type;
      return new Rl(r.scale, r.precision, r.bitWidth);
    }
    case "date": {
      const r = e.type;
      return new Cl(Zr[r.unit]);
    }
    case "time": {
      const r = e.type;
      return new bc(mt[r.unit], r.bitWidth);
    }
    case "timestamp": {
      const r = e.type;
      return new Bl(mt[r.unit], r.timezone);
    }
    case "interval": {
      const r = e.type;
      return new Pl(Ii[r.unit]);
    }
    case "duration": {
      const r = e.type;
      return new Ul(mt[r.unit]);
    }
    case "union": {
      const r = e.type, [i, ...s] = (r.mode + "").toLowerCase(), o = i.toUpperCase() + s.join("");
      return new jl(on[o], r.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const r = e.type;
      return new ql(r.byteWidth);
    }
    case "fixedsizelist": {
      const r = e.type;
      return new Vl(r.listSize, (t || [])[0]);
    }
    case "map": {
      const r = e.type;
      return new Yl((t || [])[0], r.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var E7 = I_, N7 = zo;
class Dn {
  /** @nocollapse */
  static fromJSON(t, n) {
    const r = new Dn(0, Ie.V5, n);
    return r._createHeader = D7(t, n), r;
  }
  /** @nocollapse */
  static decode(t) {
    t = new N7(Ft(t));
    const n = ui.getRootAsMessage(t), r = n.bodyLength(), i = n.version(), s = n.headerType(), o = new Dn(r, i, s);
    return o._createHeader = O7(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new E7();
    let r = -1;
    return t.isSchema() ? r = Rt.encode(n, t.header()) : t.isRecordBatch() ? r = Bn.encode(n, t.header()) : t.isDictionaryBatch() && (r = Kr.encode(n, t.header())), ui.startMessage(n), ui.addVersion(n, Ie.V5), ui.addHeader(n, r), ui.addHeaderType(n, t.headerType), ui.addBodyLength(n, BigInt(t.bodyLength)), ui.finishMessageBuffer(n, ui.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof Rt)
      return new Dn(0, Ie.V5, Ut.Schema, t);
    if (t instanceof Bn)
      return new Dn(n, Ie.V5, Ut.RecordBatch, t);
    if (t instanceof Kr)
      return new Dn(n, Ie.V5, Ut.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 === Ut.Schema;
  }
  isRecordBatch() {
    return this.headerType === Ut.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === Ut.DictionaryBatch;
  }
  constructor(t, n, r, i) {
    this._version = n, this._headerType = r, this.body = new Uint8Array(0), i && (this._createHeader = () => i), this._bodyLength = Cn(t);
  }
}
class Bn {
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
  constructor(t, n, r) {
    this._nodes = n, this._buffers = r, this._length = Cn(t);
  }
}
class Kr {
  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;
  }
  constructor(t, n, r = !1) {
    this._data = t, this._isDelta = r, this._id = Cn(n);
  }
}
class Ur {
  constructor(t, n) {
    this.offset = Cn(t), this.length = Cn(n);
  }
}
class ya {
  constructor(t, n) {
    this.length = Cn(t), this.nullCount = Cn(n);
  }
}
function D7(e, t) {
  return () => {
    switch (t) {
      case Ut.Schema:
        return Rt.fromJSON(e);
      case Ut.RecordBatch:
        return Bn.fromJSON(e);
      case Ut.DictionaryBatch:
        return Kr.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Ut[t]}, type: ${t} }`);
  };
}
function O7(e, t) {
  return () => {
    switch (t) {
      case Ut.Schema:
        return Rt.decode(e.header(new Jn()), /* @__PURE__ */ new Map(), e.version());
      case Ut.RecordBatch:
        return Bn.decode(e.header(new Rr()), e.version());
      case Ut.DictionaryBatch:
        return Kr.decode(e.header(new yo()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Ut[t]}, type: ${t} }`);
  };
}
Ht.encode = q7;
Ht.decode = z7;
Ht.fromJSON = T7;
Rt.encode = j7;
Rt.decode = L7;
Rt.fromJSON = M7;
Bn.encode = V7;
Bn.decode = k7;
Bn.fromJSON = B_;
Kr.encode = Y7;
Kr.decode = F7;
Kr.fromJSON = A7;
ya.encode = W7;
ya.decode = C7;
Ur.encode = X7;
Ur.decode = R7;
function L7(e, t = /* @__PURE__ */ new Map(), n = Ie.V5) {
  const r = U7(e, t);
  return new Rt(r, _l(e), t, n);
}
function k7(e, t = Ie.V5) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new Bn(e.length(), B7(e), P7(e, t));
}
function F7(e, t = Ie.V5) {
  return new Kr(Bn.decode(e.data(), t), e.id(), e.isDelta());
}
function R7(e) {
  return new Ur(e.offset(), e.length());
}
function C7(e) {
  return new ya(e.length(), e.nullCount());
}
function B7(e) {
  const t = [];
  for (let n, r = -1, i = -1, s = e.nodesLength(); ++r < s; )
    (n = e.nodes(r)) && (t[++i] = ya.decode(n));
  return t;
}
function P7(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.buffersLength(); ++i < o; )
    (r = e.buffers(i)) && (t < Ie.V4 && (r.bb_pos += 8 * (i + 1)), n[++s] = Ur.decode(r));
  return n;
}
function U7(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.fieldsLength(); ++i < o; )
    (r = e.fields(i)) && (n[++s] = Ht.decode(r, t));
  return n;
}
function P1(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.childrenLength(); ++i < o; )
    (r = e.children(i)) && (n[++s] = Ht.decode(r, t));
  return n;
}
function z7(e, t) {
  let n, r, i, s, o, a;
  return !t || !(a = e.dictionary()) ? (i = z1(e, P1(e, t)), r = new Ht(e.name(), i, e.nullable(), _l(e))) : t.has(n = Cn(a.id())) ? (s = (s = a.indexType()) ? U1(s) : new mc(), o = new Uo(t.get(n), s, n, a.isOrdered()), r = new Ht(e.name(), o, e.nullable(), _l(e))) : (s = (s = a.indexType()) ? U1(s) : new mc(), t.set(n, i = z1(e, P1(e, t))), o = new Uo(i, s, n, a.isOrdered()), r = new Ht(e.name(), o, e.nullable(), _l(e))), r || null;
}
function _l(e) {
  const t = /* @__PURE__ */ new Map();
  if (e)
    for (let n, r, i = -1, s = Math.trunc(e.customMetadataLength()); ++i < s; )
      (n = e.customMetadata(i)) && (r = n.key()) != null && t.set(r, n.value());
  return t;
}
function U1(e) {
  return new Ei(e.isSigned(), e.bitWidth());
}
function z1(e, t) {
  const n = e.typeType();
  switch (n) {
    case Zt.NONE:
      return new Ti();
    case Zt.Null:
      return new Ti();
    case Zt.Binary:
      return new Ll();
    case Zt.Utf8:
      return new kl();
    case Zt.Bool:
      return new Fl();
    case Zt.List:
      return new zl((t || [])[0]);
    case Zt.Struct_:
      return new Fe(t || []);
  }
  switch (n) {
    case Zt.Int: {
      const r = e.type(new en());
      return new Ei(r.isSigned(), r.bitWidth());
    }
    case Zt.FloatingPoint: {
      const r = e.type(new sr());
      return new gc(r.precision());
    }
    case Zt.Decimal: {
      const r = e.type(new Ve());
      return new Rl(r.scale(), r.precision(), r.bitWidth());
    }
    case Zt.Date: {
      const r = e.type(new gl());
      return new Cl(r.unit());
    }
    case Zt.Time: {
      const r = e.type(new yn());
      return new bc(r.unit(), r.bitWidth());
    }
    case Zt.Timestamp: {
      const r = e.type(new mn());
      return new Bl(r.unit(), r.timezone());
    }
    case Zt.Interval: {
      const r = e.type(new or());
      return new Pl(r.unit());
    }
    case Zt.Duration: {
      const r = e.type(new nr());
      return new Ul(r.unit());
    }
    case Zt.Union: {
      const r = e.type(new Ye());
      return new jl(r.mode(), r.typeIdsArray() || [], t || []);
    }
    case Zt.FixedSizeBinary: {
      const r = e.type(new rr());
      return new ql(r.byteWidth());
    }
    case Zt.FixedSizeList: {
      const r = e.type(new ir());
      return new Vl(r.listSize(), (t || [])[0]);
    }
    case Zt.Map: {
      const r = e.type(new bl());
      return new Yl((t || [])[0], r.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${Zt[n]}" (${n})`);
}
function j7(e, t) {
  const n = t.fields.map((s) => Ht.encode(e, s));
  Jn.startFieldsVector(e, n.length);
  const r = Jn.createFieldsVector(e, n), i = t.metadata && t.metadata.size > 0 ? Jn.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return le.startKeyValue(e), le.addKey(e, a), le.addValue(e, c), le.endKeyValue(e);
  })) : -1;
  return Jn.startSchema(e), Jn.addFields(e, r), Jn.addEndianness(e, G7 ? qo.Little : qo.Big), i !== -1 && Jn.addCustomMetadata(e, i), Jn.endSchema(e);
}
function q7(e, t) {
  let n = -1, r = -1, i = -1;
  const s = t.type;
  let o = t.typeId;
  st.isDictionary(s) ? (o = s.dictionary.typeId, i = zd.visit(s, e), r = zd.visit(s.dictionary, e)) : r = zd.visit(s, e);
  const a = (s.children || []).map((l) => Ht.encode(e, l)), c = dn.createChildrenVector(e, a), u = t.metadata && t.metadata.size > 0 ? dn.createCustomMetadataVector(e, [...t.metadata].map(([l, f]) => {
    const h = e.createString(`${l}`), d = e.createString(`${f}`);
    return le.startKeyValue(e), le.addKey(e, h), le.addValue(e, d), le.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), dn.startField(e), dn.addType(e, r), dn.addTypeType(e, o), dn.addChildren(e, c), dn.addNullable(e, !!t.nullable), n !== -1 && dn.addName(e, n), i !== -1 && dn.addDictionary(e, i), u !== -1 && dn.addCustomMetadata(e, u), dn.endField(e);
}
function V7(e, t) {
  const n = t.nodes || [], r = t.buffers || [];
  Rr.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    ya.encode(e, o);
  const i = e.endVector();
  Rr.startBuffersVector(e, r.length);
  for (const o of r.slice().reverse())
    Ur.encode(e, o);
  const s = e.endVector();
  return Rr.startRecordBatch(e), Rr.addLength(e, BigInt(t.length)), Rr.addNodes(e, i), Rr.addBuffers(e, s), Rr.endRecordBatch(e);
}
function Y7(e, t) {
  const n = Bn.encode(e, t.data);
  return yo.startDictionaryBatch(e), yo.addId(e, BigInt(t.id)), yo.addIsDelta(e, t.isDelta), yo.addData(e, n), yo.endDictionaryBatch(e);
}
function W7(e, t) {
  return C_.createFieldNode(e, BigInt(t.length), BigInt(t.nullCount));
}
function X7(e, t) {
  return R_.createBuffer(e, BigInt(t.offset), BigInt(t.length));
}
const G7 = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), Gy = (e) => `Expected ${Ut[e]} Message in stream, but was null or length 0.`, Hy = (e) => `Header pointer of flatbuffer-encoded ${Ut[e]} Message is null or length 0.`, z_ = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, j_ = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
class q_ {
  constructor(t) {
    this.source = t instanceof Ql ? t : new Ql(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 ? ee : 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(Gy(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Ft(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(j_(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 = Ut.Schema, r = this.readMessage(n), i = r == null ? void 0 : r.header();
    if (t && !i)
      throw new Error(Hy(n));
    return i;
  }
  readMetadataLength() {
    const t = this.source.read(Ih), n = t && new zo(t), r = (n == null ? void 0 : n.readInt32(0)) || 0;
    return { done: r === 0, value: r };
  }
  readMetadata(t) {
    const n = this.source.read(t);
    if (!n)
      return ee;
    if (n.byteLength < t)
      throw new Error(z_(t, n.byteLength));
    return { done: !1, value: Dn.decode(n) };
  }
}
class H7 {
  constructor(t, n) {
    this.source = t instanceof Yo ? t : K2(t) ? new tf(t, n) : new Yo(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return gt(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 ? ee : t;
    });
  }
  throw(t) {
    return gt(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return gt(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return gt(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(Gy(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return gt(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Ft(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(j_(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return gt(this, void 0, void 0, function* () {
      const n = Ut.Schema, r = yield this.readMessage(n), i = r == null ? void 0 : r.header();
      if (t && !i)
        throw new Error(Hy(n));
      return i;
    });
  }
  readMetadataLength() {
    return gt(this, void 0, void 0, function* () {
      const t = yield this.source.read(Ih), n = t && new zo(t), r = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: r === 0, value: r };
    });
  }
  readMetadata(t) {
    return gt(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return ee;
      if (n.byteLength < t)
        throw new Error(z_(t, n.byteLength));
      return { done: !1, value: Dn.decode(n) };
    });
  }
}
class J7 extends q_ {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof L1 ? t : new L1(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: Dn.fromJSON(t.schema, Ut.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: Dn.fromJSON(n, Ut.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: Dn.fromJSON(n, Ut.RecordBatch) };
    }
    return this._body = [], ee;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(r) {
      return (r || []).reduce((i, s) => [
        ...i,
        ...s.VALIDITY && [s.VALIDITY] || [],
        ...s.TYPE_ID && [s.TYPE_ID] || [],
        ...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(Gy(t));
    return n.value;
  }
  readSchema() {
    const t = Ut.Schema, n = this.readMessage(t), r = n == null ? void 0 : n.header();
    if (!n || !r)
      throw new Error(Hy(t));
    return r;
  }
}
const Ih = 4, e0 = "ARROW1", sf = new Uint8Array(e0.length);
for (let e = 0; e < e0.length; e += 1)
  sf[e] = e0.codePointAt(e);
function Jy(e, t = 0) {
  for (let n = -1, r = sf.length; ++n < r; )
    if (sf[n] !== e[t + n])
      return !1;
  return !0;
}
const Jc = sf.length, V_ = Jc + Ih, Z7 = Jc * 2 + Ih;
class Wr extends E_ {
  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 hc(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 pn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return pn.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 Wr ? t : Wp(t) ? eO(t) : K2(t) ? iO(t) : hc(t) ? gt(this, void 0, void 0, function* () {
      return yield Wr.from(yield t);
    }) : Q2(t) || Dy(t) || ev(t) || Ny(t) ? rO(new Yo(t)) : nO(new Ql(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof Wr ? t.isSync() ? j1(t) : q1(t) : Wp(t) || ArrayBuffer.isView(t) || Mh(t) || Z2(t) ? j1(t) : q1(t);
  }
}
class of extends Wr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return ur(this, arguments, function* () {
      yield vt(yield* ml(Ao(this[Symbol.iterator]())));
    });
  }
}
class af extends Wr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n, r, i;
    return gt(this, void 0, void 0, function* () {
      const s = new Array();
      try {
        for (var o = !0, a = Ao(this), c; c = yield a.next(), t = c.done, !t; o = !0) {
          i = c.value, o = !1;
          const u = i;
          s.push(u);
        }
      } catch (u) {
        n = { error: u };
      } finally {
        try {
          !o && !t && (r = a.return) && (yield r.call(a));
        } finally {
          if (n)
            throw n.error;
        }
      }
      return s;
    });
  }
  [Symbol.iterator]() {
    throw new Error("AsyncRecordBatchStreamReader is not Iterable");
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
}
class Y_ extends of {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class K7 extends af {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class W_ {
  get numDictionaries() {
    return this._dictionaryIndex;
  }
  get numRecordBatches() {
    return this._recordBatchIndex;
  }
  constructor(t = /* @__PURE__ */ new Map()) {
    this.closed = !1, this.autoDestroy = !0, this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.dictionaries = t;
  }
  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 r = this._loadVectors(t, n, this.schema.fields), i = $t({ type: new Fe(this.schema.fields), length: t.length, children: r });
    return new Nn(this.schema, i);
  }
  _loadDictionaryBatch(t, n) {
    const { id: r, isDelta: i } = t, { dictionaries: s, schema: o } = this, a = s.get(r);
    if (i || !a) {
      const c = o.dictionaries.get(r), u = this._loadVectors(t.data, n, [c]);
      return (a && i ? a.concat(new ae(u)) : new ae(u)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, r) {
    return new D_(n, t.nodes, t.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(r);
  }
}
class cf extends W_ {
  constructor(t, n) {
    super(n), this._reader = Wp(t) ? new J7(this._handle = t) : new q_(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 = G_(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) : ee;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : ee;
  }
  next() {
    if (this.closed)
      return ee;
    let t;
    const { _reader: n } = this;
    for (; t = this._readNextMessageAndValidate(); )
      if (t.isSchema())
        this.reset(t.header());
      else if (t.isRecordBatch()) {
        this._recordBatchIndex++;
        const r = t.header(), i = n.readMessageBody(t.bodyLength);
        return { done: !1, value: this._loadRecordBatch(r, i) };
      } else if (t.isDictionaryBatch()) {
        this._dictionaryIndex++;
        const r = t.header(), i = n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(r, i);
        this.dictionaries.set(r.id, s);
      }
    return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new F_(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}
class uf extends W_ {
  constructor(t, n) {
    super(n), this._reader = new H7(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return gt(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 gt(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = G_(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return gt(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : ee;
    });
  }
  return(t) {
    return gt(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : ee;
    });
  }
  next() {
    return gt(this, void 0, void 0, function* () {
      if (this.closed)
        return ee;
      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 r = t.header(), i = yield n.readMessageBody(t.bodyLength);
          return { done: !1, value: this._loadRecordBatch(r, i) };
        } else if (t.isDictionaryBatch()) {
          this._dictionaryIndex++;
          const r = t.header(), i = yield n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(r, i);
          this.dictionaries.set(r.id, s);
        }
      return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new F_(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return gt(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}
class X_ extends cf {
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  constructor(t, n) {
    super(t instanceof k1 ? t : new k1(t), n);
  }
  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 r = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
    if (r && this._handle.seek(r.offset)) {
      const i = this._reader.readMessage(Ut.RecordBatch);
      if (i != null && i.isRecordBatch()) {
        const s = i.header(), o = this._reader.readMessageBody(i.bodyLength);
        return this._loadRecordBatch(s, o);
      }
    }
    return null;
  }
  _readDictionaryBatch(t) {
    var n;
    const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
    if (r && this._handle.seek(r.offset)) {
      const i = this._reader.readMessage(Ut.DictionaryBatch);
      if (i != null && i.isDictionaryBatch()) {
        const s = i.header(), o = this._reader.readMessageBody(i.bodyLength), a = this._loadDictionaryBatch(s, o);
        this.dictionaries.set(s.id, a);
      }
    }
  }
  _readFooter() {
    const { _handle: t } = this, n = t.size - V_, r = t.readInt32(n), i = t.readAt(n - r, r);
    return qy.decode(i);
  }
  _readNextMessageAndValidate(t) {
    var n;
    if (this._footer || this.open(), this._footer && this._recordBatchIndex < this.numRecordBatches) {
      const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(this._recordBatchIndex);
      if (r && this._handle.seek(r.offset))
        return this._reader.readMessage(t);
    }
    return null;
  }
}
class Q7 extends uf {
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  constructor(t, ...n) {
    const r = typeof n[0] != "number" ? n.shift() : void 0, i = n[0] instanceof Map ? n.shift() : void 0;
    super(t instanceof tf ? t : new tf(t, r), i);
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return gt(this, void 0, void 0, function* () {
      if (!this.closed && !this._footer) {
        this.schema = (this._footer = yield this._readFooter()).schema;
        for (const r of this._footer.dictionaryBatches())
          r && (yield this._readDictionaryBatch(this._dictionaryIndex++));
      }
      return yield n.open.call(this, t);
    });
  }
  readRecordBatch(t) {
    var n;
    return gt(this, void 0, void 0, function* () {
      if (this.closed)
        return null;
      this._footer || (yield this.open());
      const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
      if (r && (yield this._handle.seek(r.offset))) {
        const i = yield this._reader.readMessage(Ut.RecordBatch);
        if (i != null && i.isRecordBatch()) {
          const s = i.header(), o = yield this._reader.readMessageBody(i.bodyLength);
          return this._loadRecordBatch(s, o);
        }
      }
      return null;
    });
  }
  _readDictionaryBatch(t) {
    var n;
    return gt(this, void 0, void 0, function* () {
      const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
      if (r && (yield this._handle.seek(r.offset))) {
        const i = yield this._reader.readMessage(Ut.DictionaryBatch);
        if (i != null && i.isDictionaryBatch()) {
          const s = i.header(), o = yield this._reader.readMessageBody(i.bodyLength), a = this._loadDictionaryBatch(s, o);
          this.dictionaries.set(s.id, a);
        }
      }
    });
  }
  _readFooter() {
    return gt(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - V_, r = yield t.readInt32(n), i = yield t.readAt(n - r, r);
      return qy.decode(i);
    });
  }
  _readNextMessageAndValidate(t) {
    return gt(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 tO extends cf {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, r) {
    return new h7(n, t.nodes, t.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(r);
  }
}
function G_(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* j1(e) {
  const t = Wr.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function q1(e) {
  return ur(this, arguments, function* () {
    const n = yield vt(Wr.from(e));
    try {
      if (!(yield vt(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield vt(n);
        while (!(yield vt(n.reset().open())).closed);
    } finally {
      yield vt(n.cancel());
    }
  });
}
function eO(e) {
  return new of(new tO(e));
}
function nO(e) {
  const t = e.peek(Jc + 7 & -8);
  return t && t.byteLength >= 4 ? Jy(t) ? new Y_(new X_(e.read())) : new of(new cf(e)) : new of(new cf(function* () {
  }()));
}
function rO(e) {
  return gt(this, void 0, void 0, function* () {
    const t = yield e.peek(Jc + 7 & -8);
    return t && t.byteLength >= 4 ? Jy(t) ? new Y_(new X_(yield e.read())) : new af(new uf(e)) : new af(new uf(function() {
      return ur(this, arguments, function* () {
      });
    }()));
  });
}
function iO(e) {
  return gt(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new tf(e, t);
    return t >= Z7 && Jy(yield n.readAt(0, Jc + 7 & -8)) ? new K7(new Q7(n)) : new af(new uf(n));
  });
}
function Zy(e) {
  const t = Wr.from(e);
  return hc(t) ? t.then((n) => Zy(n)) : t.isAsync() ? t.readAll().then((n) => new wc(n)) : new wc(t.readAll());
}
function sO(e = "ws://localhost:3000/") {
  const t = [];
  let n = !1, r = null, i;
  const s = {
    open() {
      n = !0, c();
    },
    close() {
      for (n = !1, r = null, i = null; t.length; )
        t.shift().reject("Socket closed");
    },
    error(u) {
      if (r) {
        const { reject: l } = r;
        r = null, c(), l(u);
      } else
        console.error("WebSocket error: ", u);
    },
    message({ data: u }) {
      if (r) {
        const { query: l, resolve: f, reject: h } = r;
        if (r = 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(Zy(u.arrayBuffer()));
        else
          throw new Error(`Unexpected socket data: ${u}`);
      } else
        console.log("WebSocket message: ", u);
    }
  };
  function o() {
    i = new WebSocket(e);
    for (const u in s)
      i.addEventListener(u, s[u]);
  }
  function a(u, l, f) {
    i == null && o(), t.push({ query: u, resolve: l, reject: f }), n && !r && c();
  }
  function c() {
    t.length && (r = t.shift(), i.send(JSON.stringify(r.query)));
  }
  return {
    get connected() {
      return n;
    },
    query(u) {
      return new Promise(
        (l, f) => a(u, l, f)
      );
    }
  };
}
class Oi {
  /**
   * Create a new Ref instance.
   * @param {string|Ref|null} table The table name.
   * @param {string|null} column The column name.
   */
  constructor(t, n) {
    t && (this.table = String(t)), n && (this.column = n);
  }
  /**
   * Get the list of referenced columns. Either a single element array
   * if column is non-null, otherwise an empty array.
   */
  get columns() {
    return this.column ? [this.column] : [];
  }
  /**
   * Generate a SQL string for this reference.
   * @returns {string} The SQL string.
   */
  toString() {
    const { table: t, column: n } = this;
    if (n) {
      const r = n.startsWith("*") ? n : `"${n}"`;
      return `${t ? `${V1(t)}.` : ""}${r}`;
    } else
      return t ? V1(t) : "NULL";
  }
}
function V1(e) {
  return e.split(".").map((n) => `"${n}"`).join(".");
}
function oO(e, t) {
  return e instanceof Oi && e.column === t;
}
function qt(e) {
  return typeof e == "string" ? Th(e) : e;
}
function xl(e) {
  return typeof e == "string" ? aO(e) : e;
}
function aO(e) {
  return new Oi(e);
}
function Th(e, t) {
  return arguments.length === 1 && (t = e, e = null), new Oi(e, t);
}
function Zc(e) {
  switch (typeof e) {
    case "boolean":
      return e ? "TRUE" : "FALSE";
    case "string":
      return `'${e}'`;
    case "number":
      return Number.isFinite(e) ? String(e) : "NULL";
    default:
      if (e == null)
        return "NULL";
      if (e instanceof Date) {
        const t = +e;
        if (Number.isNaN(t))
          return "NULL";
        const n = e.getUTCFullYear(), r = e.getUTCMonth(), i = e.getUTCDate();
        return t === Date.UTC(n, r, i) ? `MAKE_DATE(${n}, ${r + 1}, ${i})` : `EPOCH_MS(${t})`;
      } else
        return e instanceof RegExp ? `'${e.source}'` : String(e);
  }
}
const Xo = (e) => typeof (e == null ? void 0 : e.addEventListener) == "function";
function H_(e) {
  return e instanceof Eh;
}
class Eh {
  /**
   * Create a new SQL expression instance.
   * @param {(string|SQLExpression|Ref)[]} parts The parts of the expression.
   * @param {string[]} [columns=[]] The column dependencies
   * @param {object} [props] Additional properties for this expression.
   */
  constructor(t, n, r) {
    this._expr = Array.isArray(t) ? t : [t], this._deps = n || [], this.annotate(r);
    const i = this._expr.filter((s) => Xo(s));
    i.length > 0 ? (this._params = Array.from(new Set(i)), this._params.forEach((s) => {
      s.addEventListener("value", () => {
        var o;
        return cO(this, (o = this.map) == null ? void 0 : o.get("value"));
      });
    })) : this.addEventListener = void 0;
  }
  /**
   * A reference to this expression.
   * Provides compatibility with param-like objects.
   */
  get value() {
    return this;
  }
  /**
   * The column dependencies of this expression.
   * @returns {string[]} The columns dependencies.
   */
  get columns() {
    const { _params: t, _deps: n } = this;
    if (t) {
      const r = new Set(t.flatMap((i) => {
        var o;
        const s = (o = i.value) == null ? void 0 : o.columns;
        return Array.isArray(s) ? s : [];
      }));
      if (r.size) {
        const i = new Set(n);
        return r.forEach((s) => i.add(s)), Array.from(i);
      }
    }
    return n;
  }
  /**
   * The first column dependency in this expression, or undefined if none.
   * @returns {string} The first column dependency.
   */
  get column() {
    return this._deps.length ? this._deps[0] : this.columns[0];
  }
  /**
   * Annotate this expression instance with additional properties.
   * @param {object[]} [props] One or more objects with properties to add.
   * @returns {this} This SQL expression.
   */
  annotate(...t) {
    return Object.assign(this, ...t);
  }
  /**
   * Generate a SQL code string corresponding to this expression.
   * @returns {string} A SQL code string.
   */
  toString() {
    return this._expr.map((t) => Xo(t) && !H_(t) ? Zc(t.value) : t).join("");
  }
  /**
   * Add an event listener callback for the provided event type.
   * @param {string} type The event type to listen for (for example, "value").
   * @param {(a: SQLExpression) => Promise?} callback The callback function to
   *  invoke upon updates. A callback may optionally return a Promise that
   *  upstream listeners may await before proceeding.
   */
  addEventListener(t, n) {
    const r = this.map || (this.map = /* @__PURE__ */ new Map());
    (r.get(t) || (r.set(t, /* @__PURE__ */ new Set()), r.get(t))).add(n);
  }
}
function cO(e, t) {
  if (t != null && t.size)
    return Promise.allSettled(Array.from(t, (n) => n(e)));
}
function J_(e, t) {
  const n = [e[0]], r = /* @__PURE__ */ new Set(), i = t.length;
  for (let s = 0, o = 0; s < i; ) {
    const a = t[s];
    Xo(a) ? n[++o] = a : (Array.isArray(a == null ? void 0 : a.columns) && a.columns.forEach((u) => r.add(u)), n[o] += typeof a == "string" ? a : Zc(a));
    const c = e[++s];
    Xo(n[o]) ? n[++o] = c : n[o] += c;
  }
  return { spans: n, cols: Array.from(r) };
}
function V(e, ...t) {
  const { spans: n, cols: r } = J_(e, t);
  return new Eh(n, r);
}
function uO(e) {
  const t = qt(e);
  return V`${t} DESC NULLS LAST`.annotate({ label: t == null ? void 0 : t.label, desc: !0 });
}
const ma = (e) => ({
  value: e,
  toString: () => Zc(e)
});
function Kc(e) {
  var t;
  e(this.op, this), (t = this.children) == null || t.forEach((n) => n.visit(e));
}
function Z_(e, t) {
  const n = t.filter((i) => i != null).map(qt), r = n.map((i, s) => s ? ` ${e} ` : "");
  return n.length === 1 ? r.push("") : n.length > 1 && (r[0] = "(", r.push(")")), V(r, ...n).annotate({ op: e, children: n, visit: Kc });
}
const Li = (...e) => Z_("AND", e.flat()), Ky = (...e) => Z_("OR", e.flat()), lO = (e) => (t) => V`(${e} ${qt(t)})`.annotate({ op: e, a: t, visit: Kc }), fO = lO("NOT"), K_ = (e) => (t) => V`(${qt(t)} ${e})`.annotate({ op: e, a: t, visit: Kc }), Qy = K_("IS NULL"), vc = K_("IS NOT NULL"), Yi = (e) => (t, n) => V`(${qt(t)} ${e} ${qt(n)})`.annotate({ op: e, a: t, b: n, visit: Kc }), Nh = Yi("="), Q_ = Yi("<>"), _c = Yi("<"), tm = Yi(">"), xc = Yi("<="), hO = Yi(">="), dO = Yi("IS DISTINCT FROM"), tx = Yi("IS NOT DISTINCT FROM");
function ex(e, t, n, r) {
  t = qt(t);
  const i = e.startsWith("NOT ") ? "NOT " : "";
  return (n ? r ? V`${i}(${n[0]} <= ${t} AND ${t} < ${n[1]})` : V`(${t} ${e} ${n[0]} AND ${n[1]})` : V``).annotate({ op: e, visit: Kc, field: t, range: n });
}
const He = (e, t, n) => ex("BETWEEN", e, t, n), pO = (e, t, n) => ex("NOT BETWEEN", e, t, n);
function lf(e, t) {
  return Array.from({ length: e }, () => t);
}
function ri(e, t) {
  return (...n) => {
    const r = n.map(qt), i = t ? `::${t}` : "";
    return (r.length ? V([`${e}(`, ...lf(r.length - 1, ", "), `)${i}`], ...r) : V`${e}()${i}`).annotate({ func: e, args: r });
  };
}
const yO = ri("REGEXP_MATCHES"), mO = ri("CONTAINS"), gO = ri("PREFIX"), bO = ri("SUFFIX");
class gi extends Eh {
  constructor(t, n, r, i, s = "", o = "", a = "") {
    let c;
    if (i && !(s || o || a))
      c = i ? V`${n} OVER "${i}"` : V`${n} OVER ()`;
    else {
      const h = s && o ? " " : "", d = (s || o) && a ? " " : "";
      c = V`${n} OVER (${i ? `"${i}" ` : ""}${s}${h}${o}${d}${a})`;
    }
    r && (c = V`(${c})::${r}`);
    const { _expr: l, _deps: f } = c;
    super(l, f, { window: t, func: n, type: r, name: i, group: s, order: o, frame: a });
  }
  get basis() {
    return this.column;
  }
  get label() {
    const { func: t } = this;
    return t.label ?? t.toString();
  }
  over(t) {
    const { window: n, func: r, type: i, group: s, order: o, frame: a } = this;
    return new gi(n, r, i, t, s, o, a);
  }
  partitionby(...t) {
    const n = t.flat().filter((l) => l).map(qt), r = V(
      ["PARTITION BY ", lf(n.length - 1, ", "), ""],
      ...n
    ), { window: i, func: s, type: o, name: a, order: c, frame: u } = this;
    return new gi(i, s, o, a, r, c, u);
  }
  orderby(...t) {
    const n = t.flat().filter((l) => l).map(qt), r = V(
      ["ORDER BY ", lf(n.length - 1, ", "), ""],
      ...n
    ), { window: i, func: s, type: o, name: a, group: c, frame: u } = this;
    return new gi(i, s, o, a, c, r, u);
  }
  rows(t) {
    const n = Y1("ROWS", t), { window: r, func: i, type: s, name: o, group: a, order: c } = this;
    return new gi(r, i, s, o, a, c, n);
  }
  range(t) {
    const n = Y1("RANGE", t), { window: r, func: i, type: s, name: o, group: a, order: c } = this;
    return new gi(r, i, s, o, a, c, n);
  }
}
function Y1(e, t) {
  if (Xo(t)) {
    const n = V`${t}`;
    return n.toString = () => `${e} ${W1(t.value)}`, n;
  }
  return `${e} ${W1(t)}`;
}
function W1(e) {
  const [t, n] = e, r = t === 0 ? "CURRENT ROW" : Number.isFinite(t) ? `${Math.abs(t)} PRECEDING` : "UNBOUNDED PRECEDING", i = n === 0 ? "CURRENT ROW" : Number.isFinite(n) ? `${Math.abs(n)} FOLLOWING` : "UNBOUNDED FOLLOWING";
  return `BETWEEN ${r} AND ${i}`;
}
function Vn(e, t) {
  return (...n) => {
    const r = ri(e)(...n);
    return new gi(e, r, t);
  };
}
const wO = Vn("ROW_NUMBER", "INTEGER"), vO = Vn("RANK", "INTEGER"), _O = Vn("DENSE_RANK", "INTEGER"), xO = Vn("PERCENT_RANK"), SO = Vn("CUME_DIST"), MO = Vn("NTILE"), AO = Vn("LAG"), $O = Vn("LEAD"), IO = Vn("FIRST_VALUE"), TO = Vn("LAST_VALUE"), EO = Vn("NTH_VALUE");
function NO(e, ...t) {
  return V(e, ...t).annotate({ aggregate: !0 });
}
class rc extends Eh {
  constructor(t, n, r, i, s) {
    n = (n || []).map(qt);
    const { strings: o, exprs: a } = DO(t, n, r, i, s), { spans: c, cols: u } = J_(o, a);
    super(c, u, { aggregate: t, args: n, type: r, isDistinct: i, filter: s });
  }
  get basis() {
    return this.column;
  }
  get label() {
    const { aggregate: t, args: n, isDistinct: r } = this, i = r ? "DISTINCT" + (n.length ? " " : "") : "", s = n.length ? `(${i}${n.map(OO).join(", ")})` : "";
    return `${t.toLowerCase()}${s}`;
  }
  distinct() {
    const { aggregate: t, args: n, type: r, filter: i } = this;
    return new rc(t, n, r, !0, i);
  }
  where(t) {
    const { aggregate: n, args: r, type: i, isDistinct: s } = this;
    return new rc(n, r, i, s, t);
  }
  window() {
    const { aggregate: t, args: n, type: r, isDistinct: i } = this, s = new rc(t, n, null, i);
    return new gi(t, s, r);
  }
  partitionby(...t) {
    return this.window().partitionby(...t);
  }
  orderby(...t) {
    return this.window().orderby(...t);
  }
  rows(t, n) {
    return this.window().rows(t, n);
  }
  range(t, n) {
    return this.window().range(t, n);
  }
}
function DO(e, t, n, r, i) {
  const s = `)${n ? `::${n}` : ""}`;
  let o = [`${e}(${r ? "DISTINCT " : ""}`], a = [];
  return t.length ? (o = o.concat([
    ...lf(t.length - 1, ", "),
    `${s}${i ? " FILTER (WHERE " : ""}`,
    ...i ? [")"] : []
  ]), a = [...t, ...i ? [i] : []]) : o[0] += "*" + s, { exprs: a, strings: o };
}
function OO(e) {
  const t = Zc(e);
  return t && t.startsWith('"') && t.endsWith('"') ? t.slice(1, -1) : t;
}
function Ct(e, t) {
  return (...n) => new rc(e, n, t);
}
const xs = Ct("COUNT", "INTEGER"), LO = Ct("AVG"), kO = Ct("MAD"), Go = Ct("MAX"), Ho = Ct("MIN"), Ys = Ct("SUM", "DOUBLE"), FO = Ct("PRODUCT"), RO = Ct("MEDIAN"), CO = Ct("QUANTILE"), BO = Ct("MODE"), PO = Ct("VARIANCE"), UO = Ct("STDDEV"), zO = Ct("SKEWNESS"), jO = Ct("KURTOSIS"), qO = Ct("ENTROPY"), VO = Ct("VAR_POP"), YO = Ct("STDDEV_POP"), WO = Ct("CORR"), XO = Ct("COVAR_POP"), GO = Ct("REGR_INTERCEPT"), HO = Ct("REGR_SLOPE"), JO = Ct("REGR_COUNT"), ZO = Ct("REGR_SYY"), KO = Ct("REGR_SXX"), QO = Ct("REGR_AVGX"), t9 = Ct("LAST"), n0 = Ct("ARG_MIN"), r0 = Ct("ARG_MAX"), e9 = Ct("STRING_AGG"), n9 = Ct("ARRAY_AGG");
function em(e, t) {
  const n = qt(e), r = V`CAST(${n} AS ${t})`;
  return Object.defineProperty(r, "label", {
    enumerable: !0,
    get() {
      return e.label;
    }
  }), Object.defineProperty(r, "aggregate", {
    enumerable: !0,
    get() {
      return e.aggregate || !1;
    }
  }), r;
}
const i0 = (e) => em(e, "DOUBLE"), r9 = (e) => em(e, "INTEGER"), nx = (e) => {
  const t = qt(e);
  return V`(1000 * (epoch(${t}) - second(${t})) + millisecond(${t}))::DOUBLE`;
}, i9 = (e) => {
  const t = qt(e);
  return V`MAKE_DATE(2012, MONTH(${t}), 1)`.annotate({ label: "month" });
}, s9 = (e) => {
  const t = qt(e);
  return V`MAKE_DATE(2012, MONTH(${t}), DAY(${t}))`.annotate({ label: "date" });
}, o9 = (e) => {
  const t = qt(e);
  return V`MAKE_DATE(2012, 1, DAY(${t}))`.annotate({ label: "date" });
}, rx = ri("ST_AsGeoJSON"), a9 = ri("ST_X"), c9 = ri("ST_Y"), nm = ri("ST_CENTROID"), u9 = (e) => a9(nm(e)), l9 = (e) => c9(nm(e));
class St {
  static select(...t) {
    return new St().select(...t);
  }
  static from(...t) {
    return new St().from(...t);
  }
  static with(...t) {
    return new St().with(...t);
  }
  static union(...t) {
    return new ms("UNION", t.flat());
  }
  static unionAll(...t) {
    return new ms("UNION ALL", t.flat());
  }
  static intersect(...t) {
    return new ms("INTERSECT", t.flat());
  }
  static except(...t) {
    return new ms("EXCEPT", t.flat());
  }
  constructor() {
    this.query = {
      with: [],
      select: [],
      from: [],
      where: [],
      groupby: [],
      having: [],
      window: [],
      qualify: [],
      orderby: []
    };
  }
  clone() {
    const t = new St();
    return t.query = { ...this.query }, t;
  }
  with(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.with;
    {
      const r = [], i = (s, o) => {
        const a = o.clone();
        a.cteFor = this, r.push({ as: s, query: a });
      };
      return t.flat().forEach((s) => {
        if (s != null)
          if (s.as && s.query)
            i(s.as, s.query);
          else
            for (const o in s)
              i(o, s[o]);
      }), n.with = n.with.concat(r), this;
    }
  }
  select(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.select;
    {
      const r = [];
      for (const i of t.flat())
        if (i != null)
          if (typeof i == "string")
            r.push({ as: i, expr: qt(i) });
          else if (i instanceof Oi)
            r.push({ as: i.column, expr: i });
          else if (Array.isArray(i))
            r.push({ as: i[0], expr: i[1] });
          else
            for (const s in i)
              r.push({ as: Bu(s), expr: qt(i[s]) });
      return n.select = n.select.concat(r), 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 r = [];
      return t.flat().forEach((i) => {
        if (i != null)
          if (typeof i == "string")
            r.push({ as: i, from: xl(i) });
          else if (i instanceof Oi)
            r.push({ as: i.table, from: i });
          else if (jd(i) || H_(i))
            r.push({ from: i });
          else if (Array.isArray(i))
            r.push({ as: Bu(i[0]), from: xl(i[1]) });
          else
            for (const s in i)
              r.push({ as: Bu(s), from: xl(i[s]) });
      }), n.from = n.from.concat(r), this;
    }
  }
  $from(...t) {
    return this.query.from = [], this.from(...t);
  }
  sample(t, n) {
    const { query: r } = this;
    if (arguments.length === 0)
      return r.sample;
    {
      let i = t;
      return typeof t == "number" && (i = t > 0 && t < 1 ? { perc: 100 * t, method: n } : { rows: Math.round(t), method: n }), r.sample = i, this;
    }
  }
  where(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.where : (n.where = n.where.concat(
      t.flat().filter((r) => r)
    ), 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((r) => r).map(qt)
    ), this);
  }
  $groupby(...t) {
    return this.query.groupby = [], this.groupby(...t);
  }
  having(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.having : (n.having = n.having.concat(
      t.flat().filter((r) => r)
    ), this);
  }
  window(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.window;
    {
      const r = [];
      return t.flat().forEach((i) => {
        if (i != null)
          for (const s in i)
            r.push({ as: Bu(s), expr: i[s] });
      }), n.window = n.window.concat(r), this;
    }
  }
  qualify(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.qualify : (n.qualify = n.qualify.concat(
      t.flat().filter((r) => r)
    ), this);
  }
  orderby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.orderby : (n.orderby = n.orderby.concat(
      t.flat().filter((r) => r).map(qt)
    ), 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, r = ((n == null ? void 0 : n.query) || t).with, i = r == null ? void 0 : r.reduce((o, { as: a, query: c }) => (o[a] = c, o), {}), s = [];
    return t.from.forEach(({ from: o }) => {
      if (jd(o))
        s.push(o);
      else if (i[o.table]) {
        const a = i[o.table];
        s.push(a);
      }
    }), s;
  }
  toString() {
    const {
      select: t,
      distinct: n,
      from: r,
      sample: i,
      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 g = d.map(({ as: m, query: b }) => `"${m}" AS (${b})`);
      p.push(`WITH ${g.join(", ")}`);
    }
    const y = t.map(
      ({ as: g, expr: m }) => oO(m, g) && !m.table ? `${m}` : `${m} AS "${g}"`
    );
    if (p.push(`SELECT${n ? " DISTINCT" : ""} ${y.join(", ")}`), r.length) {
      const g = r.map(({ as: m, from: b }) => {
        const w = jd(b) ? `(${b})` : `${b}`;
        return !m || m === b.table ? w : `${w} AS "${m}"`;
      });
      p.push(`FROM ${g.join(", ")}`);
    }
    if (s.length) {
      const g = s.map(String).filter((m) => m).join(" AND ");
      g && p.push(`WHERE ${g}`);
    }
    if (i) {
      const { rows: g, perc: m, method: b, seed: w } = i, v = g ? `${g} ROWS` : `${m} PERCENT`, x = b ? ` (${b}${w != null ? `, ${w}` : ""})` : "";
      p.push(`USING SAMPLE ${v}${x}`);
    }
    if (o.length && p.push(`GROUP BY ${o.join(", ")}`), a.length) {
      const g = a.map(String).filter((m) => m).join(" AND ");
      g && p.push(`HAVING ${g}`);
    }
    if (c.length) {
      const g = c.map(({ as: m, expr: b }) => `"${m}" AS (${b})`);
      p.push(`WINDOW ${g.join(", ")}`);
    }
    if (u.length) {
      const g = u.map(String).filter((m) => m).join(" AND ");
      g && p.push(`QUALIFY ${g}`);
    }
    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 ms {
  constructor(t, n) {
    this.op = t, this.queries = n.map((r) => r.clone()), this.query = { orderby: [] };
  }
  clone() {
    const t = new ms(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((r) => r).map(qt)
    ), 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((r) => r.cteFor = n), t;
  }
  toString() {
    const { op: t, queries: n, query: { orderby: r, limit: i, offset: s } } = this, o = [n.join(` ${t} `)];
    return r.length && o.push(`ORDER BY ${r.join(", ")}`), Number.isFinite(i) && o.push(`LIMIT ${i}`), Number.isFinite(s) && o.push(`OFFSET ${s}`), o.join(" ");
  }
}
function jd(e) {
  return e instanceof St || e instanceof ms;
}
function Bu(e) {
  return f9(e) ? e.slice(1, -1) : e;
}
function f9(e) {
  return e[0] === '"' && e[e.length - 1] === '"';
}
function Qc(e, t, {
  replace: n = !1,
  temp: r = !0,
  view: i = !1
} = {}) {
  return "CREATE" + (n ? " OR REPLACE " : " ") + (r ? "TEMP " : "") + (i ? "VIEW" : "TABLE") + (n ? " " : " IF NOT EXISTS ") + e + " AS " + t;
}
function ix(e) {
  return `INSTALL ${e}; LOAD ${e}`;
}
function h9(e, {
  columns: t = Object.keys((e == null ? void 0 : e[0]) || {})
} = {}) {
  let n = [];
  if (Array.isArray(t) ? (n = t, t = n.reduce((i, s) => (i[s] = s, i), {})) : t && (n = Object.keys(t)), !n.length)
    throw new Error("Can not create table from empty column set.");
  const r = [];
  for (const i of e) {
    const s = n.map((o) => `${Zc(i[o])} AS "${t[o]}"`);
    r.push(`(SELECT ${s.join(", ")})`);
  }
  return r.join(" UNION ALL ");
}
function Dh(e, t, n, r = {}, i = {}) {
  const { select: s = ["*"], where: o, view: a, temp: c, replace: u, ...l } = r, f = b9({ ...i, ...l }), h = `${e}('${n}'${f ? ", " + f : ""})`, d = o ? ` WHERE ${o}` : "", p = `SELECT ${s.join(", ")} FROM ${h}${d}`;
  return Qc(t, p, { view: a, temp: c, replace: u });
}
function d9(e, t, n) {
  return Dh("read_csv", e, t, n, { auto_detect: !0, sample_size: -1 });
}
function p9(e, t, n) {
  return Dh("read_json", e, t, n, { auto_detect: !0, json_format: "auto" });
}
function y9(e, t, n) {
  return Dh("read_parquet", e, t, n);
}
function m9(e, t, n = {}) {
  const { options: r, ...i } = n;
  if (r) {
    const s = Array.isArray(r) ? r.join(", ") : typeof r == "string" ? r : Object.entries(r).map(([o, a]) => `${o}=${a}`).join(", ");
    i.open_options = s.toUpperCase();
  }
  return Dh("st_read", e, t, i);
}
function g9(e, t, n = {}) {
  const { select: r = ["*"], ...i } = n, s = h9(t), o = r.length === 1 && r[0] === "*" ? s : `SELECT ${r} FROM ${s}`;
  return Qc(e, o, i);
}
function b9(e) {
  return Object.entries(e).map(([t, n]) => `${t}=${s0(n)}`).join(", ");
}
function s0(e) {
  switch (typeof e) {
    case "boolean":
      return String(e);
    case "string":
      return `'${e}'`;
    case "undefined":
    case "object":
      return e == null ? "NULL" : Array.isArray(e) ? "[" + e.map((t) => s0(t)).join(", ") + "]" : "{" + Object.entries(e).map(([t, n]) => `'${t}': ${s0(n)}`).join(", ") + "}";
    default:
      return e;
  }
}
function w9(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 "TIMESTAMP WITH TIME ZONE":
    case "TIME":
    case "TIMESTAMP_NS":
      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}`);
  }
}
const v9 = "count", _9 = "nulls", x9 = "max", S9 = "min", M9 = "distinct", A9 = {
  [v9]: xs,
  [M9]: (e) => xs(e).distinct(),
  [x9]: Go,
  [S9]: Ho,
  [_9]: (e) => xs().where(Qy(e))
};
function $9({ table: e, column: t }, n) {
  return St.from(e).select(n.map((r) => [r, A9[r](t)]));
}
const sx = () => /* @__PURE__ */ Object.create(null);
class I9 {
  constructor(t) {
    this.mc = t, this.clear();
  }
  clear() {
    this.tables = sx();
  }
  tableInfo(t) {
    const n = this.tables;
    if (n[t])
      return n[t];
    const r = T9(this.mc, t).catch((i) => {
      throw n[t] = null, i;
    });
    return n[t] = r;
  }
  async fieldInfo({ table: t, column: n, stats: r }) {
    const s = (await this.tableInfo(t))[n];
    if (s == null)
      return;
    if (!(r != null && r.length))
      return s;
    const o = await this.mc.query(
      $9(s, r),
      { persist: !0 }
    ), a = { ...s, ...Array.from(o)[0] };
    for (const c in a) {
      const u = a[c];
      typeof u == "bigint" && (a[c] = Number(u));
    }
    return a;
  }
  async queryFields(t) {
    const n = await E9(this, t);
    return (await Promise.all(n.map((i) => this.fieldInfo(i)))).filter((i) => i);
  }
}
async function T9(e, t) {
  const n = await e.query(
    `DESCRIBE ${xl(t)}`,
    { type: "json", cache: !1 }
  ), r = sx();
  for (const i of n)
    r[i.column_name] = {
      table: t,
      column: i.column_name,
      sqlType: i.column_type,
      type: w9(i.column_type),
      nullable: i.null === "YES"
    };
  return r;
}
async function E9(e, t) {
  return t.length === 1 && t[0].column === "*" ? Object.values(await e.tableInfo(t[0].table)) : t;
}
function N9(e) {
  let t = 2166136261;
  for (let n = 0, r = e.length; n < r; ++n) {
    const i = e.charCodeAt(n), s = i & 65280;
    s && (t = X1(t ^ s >> 8)), t = X1(t ^ i & 255);
  }
  return D9(t);
}
function X1(e) {
  return e + (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
}
function D9(e) {
  return e += e << 13, e ^= e >>> 7, e += e << 3, e ^= e >>> 17, e += e << 5, e & 4294967295;
}
const ox = (e) => e;
class O9 {
  /**
   *
   * @param {import('./Coordinator.js').Coordinator} mc a Mosaic coordinator
   * @param {*} options Options hash to configure the data cube indexes and pass selections to the coordinator.
   */
  constructor(t, { selection: n, temp: r = !0 }) {
    this.mc = t, this.selection = n, this.temp = r, this.reset();
  }
  reset() {
    this.enabled = !1, this.clients = null, this.indices = null, this.activeView = null;
  }
  clear() {
    this.indices && (this.mc.cancel(Array.from(this.indices.values(), (t) => t.result)), this.indices = null);
  }
  index(t, n) {
    var u, l;
    if (this.clients !== t) {
      const f = Array.from(t, H1), h = (u = f[0]) == null ? void 0 : u.from;
      this.enabled = f.every((d) => d && d.from === h), this.clients = t, this.activeView = null, this.clear();
    }
    if (!this.enabled)
      return !1;
    n = n || this.selection.active;
    const { source: r } = n;
    if (r && r === ((l = this.activeView) == null ? void 0 : l.source))
      return !0;
    if (this.clear(), !r)
      return !1;
    const i = this.activeView = L9(n);
    if (!i)
      return !1;
    this.mc.logger().warn("DATA CUBE INDEX CONSTRUCTION");
    const s = this.selection.remove(r), o = this.indices = /* @__PURE__ */ new Map(), { mc: a, temp: c } = this;
    for (const f of t) {
      if (s.skip(f, n))
        continue;
      const h = H1(f), d = f.query(s.predicate(f)).select({ ...i.columns, ...h.count }).groupby(Object.keys(i.columns)), [p] = d.subqueries;
      if (p) {
        const v = Object.values(i.columns).map((x) => x.columns[0]);
        R9(p, v);
      }
      const y = d.orderby();
      d.query.orderby = [];
      const g = d.toString(), b = `cube_index_${(N9(g) >>> 0).toString(16)}`, w = a.exec(Qc(b, g, { temp: c }));
      o.set(f, { table: b, result: w, order: y, ...h });
    }
  }
  async update() {
    const { clients: t, selection: n, activeView: r } = this, i = r.predicate(n.active.predicate);
    return Promise.all(
      Array.from(t).map((s) => this.updateClient(s, i))
    );
  }
  async updateClient(t, n) {
    const r = this.indices.get(t);
    if (!r)
      return;
    n || (n = this.activeView.predicate(this.selection.active.predicate));
    const { table: i, dims: s, aggr: o, order: a = [] } = r, c = St.select(s, o).from(i).groupby(s).where(n).orderby(a);
    return this.mc.updateClient(t, c);
  }
}
function L9(e) {
  var c;
  const { source: t, schema: n } = e;
  let r = (c = e.predicate) == null ? void 0 : c.columns;
  if (!n || !r)
    return null;
  const { type: i, scales: s, pixelSize: o = 1 } = n;
  let a;
  if (i === "interval" && s) {
    const u = s.map((l) => k9(l, o));
    if (u.some((l) => l == null))
      return null;
    u.length === 1 ? (a = (l) => l ? He("active0", l.range.map(u[0])) : [], r = { active0: u[0](e.predicate.field) }) : (a = (l) => l ? Li(l.children.map(({ range: f }, h) => He(`active${h}`, f.map(u[h])))) : [], r = Object.fromEntries(
      e.predicate.children.map((l, f) => [`active${f}`, u[f](l.field)])
    ));
  } else if (i === "point")
    a = ox, r = Object.fromEntries(r.map((u) => [u.toString(), u]));
  else
    return null;
  return { source: t, columns: r, predicate: a };
}
function k9(e, t) {
  const { type: n, domain: r, range: i } = e;
  let s, o;
  switch (n) {
    case "linear":
      s = ox, o = qt;
      break;
    case "log":
      s = Math.log, o = (a) => V`LN(${qt(a)})`;
      break;
    case "symlog":
      s = (a) => Math.sign(a) * Math.log1p(Math.abs(a)), o = (a) => (a = qt(a), V`SIGN(${a}) * LN(1 + ABS(${a}))`);
      break;
    case "sqrt":
      s = Math.sqrt, o = (a) => V`SQRT(${qt(a)})`;
      break;
    case "utc":
    case "time":
      s = (a) => +a, o = (a) => a instanceof Date ? +a : nx(qt(a));
      break;
  }
  return s ? F9(r, i, t, s, o) : null;
}
function F9(e, t, n, r, i) {
  const s = r(Math.min(e[0], e[1])), o = r(Math.max(e[0], e[1])), a = Math.abs(r(t[1]) - r(t[0])) / (o - s) / n, c = n === 1 ? "" : `${n}::INTEGER * `;
  return (u) => V`${c}FLOOR(${a}::DOUBLE * (${i(u)} - ${s}::DOUBLE))::INTEGER`;
}
const G1 = { from: NaN };
function H1(e) {
  var a;
  if (!e.filterIndexable)
    return G1;
  const t = e.query(), n = o0(t);
  if (!n || !t.groupby)
    return G1;
  const r = new Set(t.groupby().map((c) => c.column)), i = [], s = [];
  let o;
  for (const { as: c, expr: { aggregate: u } } of t.select())
    switch ((a = u == null ? void 0 : u.toUpperCase) == null ? void 0 : a.call(u)) {
      case "COUNT":
      case "SUM":
        i.push({ [c]: V`SUM("${c}")::DOUBLE` });
        break;
      case "AVG":
        o = "_count_", i.push({ [c]: V`(SUM("${c}" * ${o}) / SUM(${o}))::DOUBLE` });
        break;
      case "MAX":
        i.push({ [c]: V`MAX("${c}")` });
        break;
      case "MIN":
        i.push({ [c]: V`MIN("${c}")` });
        break;
      default:
        if (r.has(c))
          s.push(c);
        else
          return null;
    }
  return {
    aggr: i,
    dims: s,
    count: o ? { [o]: V`COUNT(*)` } : {},
    from: n
  };
}
function o0(e) {
  const t = e.subqueries;
  if (e.select) {
    const r = e.from();
    if (!r.length)
      return;
    if (t.length === 0)
      return r[0].from.table;
  }
  const n = o0(t[0]);
  for (let r = 1; r < t.length; ++r) {
    const i = o0(t[r]);
    if (i !== void 0 && i !== n)
      return NaN;
  }
  return n;
}
function R9(e, t) {
  const n = /* @__PURE__ */ new Set(), r = (i) => {
    n.has(i) || (n.add(i), i.select && i.from().length && i.select(t), i.subqueries.forEach(r));
  };
  r(e);
}
class C9 {
  /**
   * @param {import('./Coordinator.js').Coordinator} coordinator The Mosaic coordinator.
   * @param {*} selection The shared filter selection.
   * @param {*} index Boolean flag or options hash for data cube indexer.
   *  Falsy values disable indexing.
   */
  constructor(t, n, r = !0) {
    this.mc = t, this.selection = n, this.clients = /* @__PURE__ */ new Set(), this.indexer = r ? new O9(this.mc, { ...r, selection: n }) : null;
    const { value: i, activate: s } = this.handlers = {
      value: () => this.update(),
      activate: (o) => {
        var a;
        return (a = this.indexer) == null ? void 0 : a.index(this.clients, o);
      }
    };
    n.addEventListener("value", i), 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;
  }
  update() {
    const { mc: t, indexer: n, clients: r, selection: i } = this;
    return n != null && n.index(r) ? n.update() : B9(t, r, i);
  }
}
function B9(e, t, n) {
  return Promise.all(Array.from(t).map((r) => {
    const i = n.predicate(r);
    if (i != null)
      return e.updateClient(r, r.query(i));
  }));
}
function ax() {
  let e, t;
  const n = new Promise((r, i) => {
    e = r, t = i;
  });
  return n.fulfill = (r) => (e(r), n), n.reject = (r) => (t(r), n), n;
}
function P9(e) {
  return (typeof requestAnimationFrame < "u" ? requestAnimationFrame : typeof setImmediate < "u" ? setImmediate : setTimeout)(e);
}
function U9(e, t, n) {
  let r = [], i = 0;
  function s() {
    const o = z9(r, t);
    r = [], i = 0;
    for (const a of o)
      q9(a, e, n), W9(a, t);
  }
  return {
    add(o, a) {
      o.request.type === "arrow" ? (i = i || P9(() => s()), r.push({ entry: o, priority: a, index: r.length })) : e(o, a);
    }
  };
}
function z9(e, t) {
  const n = [], r = /* @__PURE__ */ new Map();
  for (const i of e) {
    const { entry: { request: s } } = i, o = j9(s.query, t);
    if (!r.has(o)) {
      const a = [];
      n.push(a), r.set(o, a);
    }
    r.get(o).push(i);
  }
  return n;
}
function j9(e, t) {
  const n = `${e}`;
  if (e instanceof St && !t.get(n)) {
    if (e.orderby().length || e.where().length || e.qualify().length || e.having().length)
      return n;
    const r = e.clone().$select("*"), i = e.groupby();
    if (i.length) {
      const s = {};
      e.select().forEach(({ as: o, expr: a }) => s[o] = a), r.$groupby(i.map((o) => o instanceof Oi && s[o.column] || o));
    }
    return `${r}`;
  } else
    return n;
}
function q9(e, t, n) {
  if (V9(e))
    t({
      request: {
        type: "arrow",
        cache: !1,
        record: !1,
        query: Y9(e, n)
      },
      result: e.result = ax()
    });
  else
    for (const { entry: r, priority: i } of e)
      t(r, i);
}
function V9(e) {
  if (e.length > 1) {
    const t = `${e[0].entry.request.query}`;
    for (let n = 1; n < e.length; ++n)
      if (t !== `${e[n].entry.request.query}`)
        return !0;
  }
  return !1;
}
function Y9(e, t) {
  const n = e.maps = [], r = /* @__PURE__ */ new Map();
  for (const o of e) {
    const { query: a } = o.entry.request, c = [];
    n.push(c);
    for (const { as: u, expr: l } of a.select()) {
      const f = `${l}`;
      r.has(f) || r.set(f, [`col${r.size}`, l]);
      const [h] = r.get(f);
      c.push([h, u]);
    }
    t(`${a}`);
  }
  const i = e[0].entry.request.query.clone(), s = i.groupby();
  if (s.length) {
    const o = {};
    e.maps[0].forEach(([a, c]) => o[c] = a), i.$groupby(s.map((a) => a instanceof Oi && o[a.column] || a));
  }
  return i.$select(Array.from(r.values()));
}
async function W9(e, t) {
  const { maps: n, result: r } = e;
  if (!n)
    return;
  let i;
  try {
    i = await r;
  } catch (s) {
    for (const { entry: o } of e)
      o.result.reject(s);
    return;
  }
  e.forEach(({ entry: s }, o) => {
    const { request: a, result: c } = s, u = X9(i, n[o]);
    a.cache && t.set(String(a.query), u), c.fulfill(u);
  });
}
function X9(e, t) {
  if (t) {
    const n = {};
    for (const [r, i] of t)
      n[i] = e.getChild(r);
    return new e.constructor(n);
  } else
    return e;
}
const G9 = typeof requestIdleCallback < "u" ? requestIdleCallback : setTimeout, H9 = () => ({
  get: () => {
  },
  set: (e, t) => t,
  clear: () => {
  }
});
function J9({
  max: e = 1e3,
  // max entries
  ttl: t = 3 * 60 * 60 * 1e3
  // time-to-live, default 3 hours
} = {}) {
  let n = /* @__PURE__ */ new Map();
  function r() {
    const i = performance.now() - t;
    let s = null, o = 1 / 0;
    for (const [a, c] of n) {
      const { last: u } = c;
      u < o && (s = a, o = u), i > u && n.delete(a);
    }
    s && n.delete(s);
  }
  return {
    get(i) {
      const s = n.get(i);
      if (s)
        return s.last = performance.now(), s.value;
    },
    set(i, s) {
      return n.set(i, { last: performance.now(), value: s }), n.size > e && G9(r), s;
    },
    clear() {
      n = /* @__PURE__ */ new Map();
    }
  };
}
function Z9(e) {
  const t = Array.from(
    { length: e },
    () => ({ head: null, tail: null })
  );
  return {
    /**
     * Indicate if the queue is empty.
     * @returns [boolean] true if empty, false otherwise.
     */
    isEmpty() {
      return t.every((n) => !n.head);
    },
    /**
     * Insert an item into the queue with a given priority rank.
     * @param {*} item The item to add.
     * @param {number} rank The integer priority rank.
     *  Priority ranks are integers starting at zero.
     *  Lower ranks indicate higher priority.
     */
    insert(n, r) {
      const i = t[r];
      if (!i)
        throw new Error(`Invalid queue priority rank: ${r}`);
      const s = { item: n, next: null };
      i.head === null ? i.head = i.tail = s : i.tail = i.tail.next = s;
    },
    /**
     * Remove a set of items from the queue, regardless of priority rank.
     * If a provided item is not in the queue it will be ignored.
     * @param {(item: *) => boolean} test A predicate function to test
     * 	if an item should be removed (true to drop, false to keep).
     */
    remove(n) {
      for (const r of t) {
        let { head: i, tail: s } = r;
        for (let o = null, a = i; a; o = a, a = a.next)
          n(a.item) && (a === i ? i = a.next : o.next = a.next, a === s && (s = o || i));
        r.head = i, r.tail = s;
      }
    },
    /**
     * Remove and return the next highest priority item.
     * @returns {*} The next item in the queue,
     *  or undefined if this queue is empty.
     */
    next() {
      for (const n of t) {
        const { head: r } = n;
        if (r !== null)
          return n.head = r.next, n.tail === r && (n.tail = null), r.item;
      }
    }
  };
}
const yi = { High: 0, Normal: 1, Low: 2 };
function K9() {
  const e = Z9(3);
  let t, n, r, i = [], s = null, o;
  function a() {
    if (s || e.isEmpty())
      return;
    const { request: f, result: h } = e.next();
    s = l(f, h), s.finally(() => {
      s = null, a();
    });
  }
  function c(f, h = yi.Normal) {
    e.insert(f, h), a();
  }
  function u(f) {
    i.length && f && i.forEach((h) => h.add(f));
  }
  async function l(f, h) {
    try {
      const { query: d, type: p, cache: y = !1, record: g = !0, options: m } = f, b = d ? `${d}` : null;
      if (g && u(b), y) {
        const x = n.get(b);
        if (x) {
          r.debug("Cache"), h.fulfill(x);
          return;
        }
      }
      const w = performance.now(), v = await t.query({ type: p, sql: b, ...m });
      y && n.set(b, v), r.debug(`Request: ${(performance.now() - w).toFixed(1)}`), h.fulfill(v);
    } catch (d) {
      h.reject(d);
    }
  }
  return {
    cache(f) {
      return f !== void 0 ? n = f === !0 ? J9() : f || H9() : n;
    },
    logger(f) {
      return f ? r = f : r;
    },
    connector(f) {
      return f ? t = f : t;
    },
    consolidate(f) {
      f && !o ? o = U9(c, n, u) : !f && o && (o = null);
    },
    request(f, h = yi.Normal) {
      const d = ax(), p = { request: f, result: d };
      return o ? o.add(p, h) : c(p, h), d;
    },
    cancel(f) {
      const h = new Set(f);
      e.remove(({ result: d }) => h.has(d));
    },
    clear() {
      e.remove(({ result: f }) => (f.reject("Cleared"), !0));
    },
    record() {
      let f = [];
      const h = {
        add(d) {
          f.push(d);
        },
        reset() {
          f = [];
        },
        snapshot() {
          return f.slice();
        },
        stop() {
          return i = i.filter((d) => d !== h), f;
        }
      };
      return i.push(h), h;
    }
  };
}
function Q9() {
  return {
    debug() {
    },
    info() {
    },
    log() {
    },
    warn() {
    },
    error() {
    }
  };
}
let Pu;
function zr(e) {
  return e ? Pu = e : Pu == null && (Pu = new tL()), Pu;
}
class tL {
  constructor(t = sO(), n = {}) {
    const {
      logger: r = console,
      manager: i = K9()
    } = n;
    this.catalog = new I9(this), this.manager = i, this.logger(r), this.configure(n), this.databaseConnector(t), this.clear();
  }
  logger(t) {
    return arguments.length && (this._logger = t || Q9(), this.manager.logger(this._logger)), this._logger;
  }
  configure({ cache: t = !0, consolidate: n = !0, indexes: r = !0 }) {
    this.manager.cache(t), this.manager.consolidate(n), this.indexes = r;
  }
  clear({ clients: t = !0, cache: n = !0, catalog: r = !1 } = {}) {
    var i, s;
    this.manager.clear(), t && ((i = this.clients) == null || i.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.manager.cache().clear(), r && this.catalog.clear();
  }
  databaseConnector(t) {
    return this.manager.connector(t);
  }
  // -- Query Management ----
  cancel(t) {
    this.manager.cancel(t);
  }
  exec(t, { priority: n = yi.Normal } = {}) {
    return t = Array.isArray(t) ? t.join(`;
`) : t, this.manager.request({ type: "exec", query: t }, n);
  }
  query(t, {
    type: n = "arrow",
    cache: r = !0,
    priority: i = yi.Normal,
    ...s
  } = {}) {
    return this.manager.request({ type: n, query: t, cache: r, options: s }, i);
  }
  prefetch(t, n = {}) {
    return this.query(t, { ...n, cache: !0, priority: yi.Low });
  }
  createBundle(t, n, r = yi.Low) {
    const i = { name: t, queries: n };
    return this.manager.request({ type: "create-bundle", options: i }, r);
  }
  loadBundle(t, n = yi.High) {
    const r = { name: t };
    return this.manager.request({ type: "load-bundle", options: r }, n);
  }
  // -- Client Management ----
  updateClient(t, n, r = yi.Normal) {
    return t.queryPending(), this.query(n, { priority: r }).then(
      (i) => t.queryResult(i).update(),
      (i) => {
        t.queryError(i), this._logger.error(i);
      }
    );
  }
  requestQuery(t, n) {
    var r;
    return (r = this.filterGroups.get(t.filterBy)) == null || r.reset(), n ? this.updateClient(t, n) : t.update();
  }
  /**
   * Connect a client to the coordinator.
   *
   * @param {import('./MosaicClient.js').MosaicClient} client the client to disconnect
   */
  async connect(t) {
    const { catalog: n, clients: r, filterGroups: i, indexes: s } = this;
    if (r.has(t))
      throw new Error("Client already connected.");
    r.add(t), t.coordinator = this;
    const o = t.fields();
    o != null && o.length && t.fieldInfo(await n.queryFields(o));
    const a = t.filterBy;
    if (a)
      if (i.has(a))
        i.get(a).add(t);
      else {
        const c = new C9(this, a, s);
        i.set(a, c.add(t));
      }
    t.requestQuery();
  }
  /**
   * Disconnect a client from the coordinator.
   *
   * @param {import('./MosaicClient.js').MosaicClient} client the client to disconnect
   */
  disconnect(t) {
    var i;
    const { clients: n, filterGroups: r } = this;
    n.has(t) && (n.delete(t), (i = r.get(t.filterBy)) == null || i.remove(t), t.coordinator = null);
  }
}
class eL {
  /**
   * Create a new asynchronous dispatcher instance.
   */
  constructor() {
    this._callbacks = /* @__PURE__ */ new Map();
  }
  /**
   * Add an event listener callback for the provided event type.
   * @param {string} type The event type.
   * @param {(value: *) => Promise?} callback The event handler
   *  callback function to add. If the callback has already been
   *  added for the event type, this method has no effect.
   */
  addEventListener(t, n) {
    this._callbacks.has(t) || this._callbacks.set(t, {
      callbacks: /* @__PURE__ */ new Set(),
      pending: null,
      queue: new nL()
    }), this._callbacks.get(t).callbacks.add(n);
  }
  /**
   * Remove an event listener callback for the provided event type.
   * @param {string} type The event type.
   * @param {(value: *) => Promise?} callback The event handler
   *  callback function to remove.
   */
  removeEventListener(t, n) {
    const r = this._callbacks.get(t);
    r && r.callbacks.delete(n);
  }
  /**
   * Lifecycle method that returns the event value to emit.
   * This default implementation simply returns the input value as-is.
   * Subclasses may override this method to implement custom transformations
   * prior to emitting an event value to all listeners.
   * @param {string} type The event type.
   * @param {*} value The event value.
   * @returns The (possibly transformed) event value to emit.
   */
  willEmit(t, n) {
    return n;
  }
  /**
   * Lifecycle method that returns a filter function for updating the
   * queue of unemitted event values prior to enqueueing a new value.
   * This default implementation simply returns null, indicating that
   * any other unemitted event values should be dropped (that is, all
   * queued events are filtered)
   * @param {*} value The new event value that will be enqueued.
   * @returns {(value: *) => boolean|null} A dispatch queue filter
   *  function, or null if all unemitted event values should be filtered.
   */
  emitQueueFilter() {
    return null;
  }
  /**
   * Cancel all unemitted event values for the given event type.
   * @param {string} type The event type.
   */
  cancel(t) {
    const n = this._callbacks.get(t);
    n == null || n.queue.clear();
  }
  /**
   * Emit an event value to listeners for the given event type.
   * If a previous emit has not yet resolved, the event value
   * will be queued to be emitted later.
   * The actual event value given to listeners will be the result
   * of passing the input value through the emitValue() method.
   * @param {string} type The event type.
   * @param {*} value The event value.
   */
  emit(t, n) {
    const r = this._callbacks.get(t) || {};
    if (r.pending)
      r.queue.enqueue(n, this.emitQueueFilter(t, n));
    else {
      const i = this.willEmit(t, n), { callbacks: s, queue: o } = r;
      if (s != null && s.size) {
        const a = Promise.allSettled(Array.from(s, (c) => c(i))).then(() => {
          r.pending = null, o.isEmpty() || this.emit(t, o.dequeue());
        });
        r.pending = a;
      }
    }
  }
}
class nL {
  /**
   * Create a new dispatch queue instance.
   */
  constructor() {
    this.clear();
  }
  /**
   * Clear the queue state of all event values.
   */
  clear() {
    this.next = null;
  }
  /**
   * Indicate if the queue is empty.
   * @returns {boolean} True if queue is empty, false otherwise.
   */
  isEmpty() {
    return !this.next;
  }
  /**
   * Add a new value to the queue, and optionally filter the
   * current queue content in response.
   * @param {*} value The value to add.
   * @param {(value: *) => boolean} [filter] An optional filter
   *  function to apply to existing queue content. If unspecified
   *  or falsy, all previously queued values are removed. Otherwise,
   *  the provided function is applied to all queue entries. The
   *  entry is retained if the filter function returns a truthy value,
   *  otherwise the entry is removed.
   */
  enqueue(t, n) {
    const r = { value: t };
    if (n && this.next) {
      let i = this;
      for (; i.next; )
        n(i.next.value) ? i = i.next : i.next = i.next.next;
      i.next = r;
    } else
      this.next = r;
  }
  /**
   * Remove and return the next queued event value.
   * @returns {*} The next event value in the queue.
   */
  dequeue() {
    const { next: t } = this;
    return this.next = t == null ? void 0 : t.next, t == null ? void 0 : t.value;
  }
}
function cx(e, t) {
  return e === t ? !1 : e instanceof Date && t instanceof Date ? +e != +t : Array.isArray(e) && Array.isArray(t) ? rL(e, t) : !0;
}
function rL(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 $i(e) {
  return e instanceof Ss;
}
class Ss extends eL {
  /**
   * Create a new Param instance.
   * @param {*} value The initial value of the Param.
   */
  constructor(t) {
    super(), this._value = t;
  }
  /**
   * Create a new Param instance with the given initial value.
   * @param {*} value The initial value of the Param.
   * @returns {Param} The new Param instance.
   */
  static value(t) {
    return new Ss(t);
  }
  /**
   * Create a new Param instance over an array of initial values,
   * which may contain nested Params.
   * @param {*} values The initial values of the Param.
   * @returns {Param} The new Param instance.
   */
  static array(t) {
    if (t.some((n) => $i(n))) {
      const n = new Ss(), r = () => n.update(t.map((i) => $i(i) ? i.value : i));
      return r(), t.forEach((i) => $i(i) ? i.addEventListener("value", r) : 0), n;
    }
    return new Ss(t);
  }
  /**
   * The current value of the Param.
   */
  get value() {
    return this._value;
  }
  /**
   * Update the Param value
   * @param {*} value The new value of the Param.
   * @param {object} [options] The update options.
   * @param {boolean} [options.force] A boolean flag indicating if the Param
   *  should emit a 'value' event even if the internal value is unchanged.
   * @returns {this} This Param instance.
   */
  update(t, { force: n } = {}) {
    return cx(this._value, t) || n ? this.emit("value", t) : this.cancel("value"), this;
  }
  /**
   * Upon value-typed updates, sets the current value to the input value
   * immediately prior to the event value being emitted to listeners.
   * @param {string} type The event type.
   * @param {*} value The input event value.
   * @returns {*} The input event value.
   */
  willEmit(t, n) {
    return t === "value" && (this._value = n), n;
  }
}
function Os(e) {
  return e instanceof ff;
}
let ff = class mo extends Ss {
  /**
   * Create a new Selection instance with an
   * intersect (conjunction) resolution strategy.
   * @param {object} [options] The selection options.
   * @param {boolean} [options.cross=false] Boolean flag indicating
   *  cross-filtered resolution. If true, selection clauses will not
   *  be applied to the clients they are associated with.
   * @returns {Selection} The new Selection instance.
   */
  static intersect({ cross: t = !1 } = {}) {
    return new mo(new La({ cross: t }));
  }
  /**
   * Create a new Selection instance with a
   * union (disjunction) resolution strategy.
   * @param {object} [options] The selection options.
   * @param {boolean} [options.cross=false] Boolean flag indicating
   *  cross-filtered resolution. If true, selection clauses will not
   *  be applied to the clients they are associated with.
   * @returns {Selection} The new Selection instance.
   */
  static union({ cross: t = !1 } = {}) {
    return new mo(new La({ cross: t, union: !0 }));
  }
  /**
   * Create a new Selection instance with a singular resolution strategy
   * that keeps only the most recent selection clause.
   * @param {object} [options] The selection options.
   * @param {boolean} [options.cross=false] Boolean flag indicating
   *  cross-filtered resolution. If true, selection clauses will not
   *  be applied to the clients they are associated with.
   * @returns {Selection} The new Selection instance.
   */
  static single({ cross: t = !1 } = {}) {
    return new mo(new La({ cross: t, single: !0 }));
  }
  /**
   * Create a new Selection instance with a
   * cross-filtered intersect resolution strategy.
   * @returns {Selection} The new Selection instance.
   */
  static crossfilter() {
    return new mo(new La({ cross: !0 }));
  }
  /**
   * Create a new Selection instance.
   * @param {SelectionResolver} resolver The selection resolution
   *  strategy to apply.
   */
  constructor(t = new La()) {
    super([]), this._resolved = this._value, this._resolver = t;
  }
  /**
   * Create a cloned copy of this Selection instance.
   * @returns {this} A clone of this selection.
   */
  clone() {
    const t = new mo(this._resolver);
    return t._value = t._resolved = this._value, t;
  }
  /**
   * Create a clone of this Selection with clauses corresponding
   * to the provided source removed.
   * @param {*} source The clause source to remove.
   * @returns {this} A cloned and updated Selection.
   */
  remove(t) {
    const n = this.clone();
    return n._value = n._resolved = n._resolver.resolve(this._resolved, { source: t }), n._value.active = { source: t }, n;
  }
  /**
   * The current active (most recently updated) selection clause.
   */
  get active() {
    return this.clauses.active;
  }
  /**
   * The value corresponding to the current active selection clause.
   * This method ensures compatibility where a normal Param is expected.
   */
  get value() {
    var t;
    return (t = this.active) == null ? void 0 : t.value;
  }
  /**
   * The current array of selection clauses.
   */
  get clauses() {
    return super.value;
  }
  /**
   * Indicate if this selection has a single resolution strategy.
   */
  get single() {
    return this._resolver.single;
  }
  /**
   * Emit an activate event with the given selection clause.
   * @param {*} clause The clause repesenting the potential activation.
   */
  activate(t) {
    this.emit("activate", t);
  }
  /**
   * Update the selection with a new selection clause.
   * @param {*} clause The selection clause to add.
   * @returns {this} This Selection instance.
   */
  update(t) {
    return this._resolved = this._resolver.resolve(this._resolved, t, !0), this._resolved.active = t, super.update(this._resolved);
  }
  /**
   * Upon value-typed updates, sets the current clause list to the
   * input value and returns the active clause value.
   * @param {string} type The event type.
   * @param {*} value The input event value.
   * @returns {*} For value-typed events, returns the active clause
   *  values. Otherwise returns the input event value as-is.
   */
  willEmit(t, n) {
    return t === "value" ? (this._value = n, this.value) : n;
  }
  /**
   * Upon value-typed updates, returns a dispatch queue filter function.
   * The return value depends on the selection resolution strategy.
   * @param {string} type The event type.
   * @param {*} value The input event value.
   * @returns {*} For value-typed events, returns a dispatch queue filter
   *  function. Otherwise returns null.
   */
  emitQueueFilter(t, n) {
    return t === "value" ? this._resolver.queueFilter(n) : null;
  }
  /**
   * Indicates if a selection clause should not be applied to a given client.
   * The return value depends on the selection resolution strategy.
   * @param {*} client The selection clause.
   * @param {*} clause The client to test.
   * @returns True if the client should be skipped, false otherwise.
   */
  skip(t, n) {
    return this._resolver.skip(t, n);
  }
  /**
   * Return a selection query predicate for the given client.
   * @param {*} client The client whose data may be filtered.
   * @param {boolean} [noSkip=false] Disable skipping of active
   *  cross-filtered sources. If set true, the source of the active
   *  clause in a cross-filtered selection will not be skipped.
   * @returns {*} The query predicate for filtering client data,
   *  based on the current state of this selection.
   */
  predicate(t, n = !1) {
    const { clauses: r } = this, i = n ? null : r.active;
    return this._resolver.predicate(r, i, t);
  }
};
class La {
  /**
   * Create a new selection resolved instance.
   * @param {object} [options] The resolution strategy options.
   * @param {boolean} [options.union=false] Boolean flag to indicate a union strategy.
   *  If false, an intersection strategy is used.
   * @param {boolean} [options.cross=false] Boolean flag to indicate cross-filtering.
   * @param {boolean} [options.single=false] Boolean flag to indicate single clauses only.
   */
  constructor({ union: t, cross: n, single: r } = {}) {
    this.union = !!t, this.cross = !!n, this.single = !!r;
  }
  /**
   * Resolve a list of selection clauses according to the resolution strategy.
   * @param {*[]} clauseList An array of selection clauses.
   * @param {*} clause A new selection clause to add.
   * @returns {*[]} An updated array of selection clauses.
   */
  resolve(t, n, r = !1) {
    const { source: i, predicate: s } = n, o = t.filter((c) => i !== c.source), a = this.single ? [] : o;
    return this.single && r && o.forEach((c) => {
      var u, l;
      return (l = (u = c.source) == null ? void 0 : u.reset) == null ? void 0 : l.call(u);
    }), s && a.push(n), a;
  }
  /**
   * Indicates if a selection clause should not be applied to a given client.
   * The return value depends on the resolution strategy.
   * @param {*} client The selection clause.
   * @param {*} clause The client to test.
   * @returns True if the client should be skipped, false otherwise.
   */
  skip(t, n) {
    var r;
    return this.cross && ((r = n == null ? void 0 : n.clients) == null ? void 0 : r.has(t));
  }
  /**
   * Return a selection query predicate for the given client.
   * @param {*[]} clauseList An array of selection clauses.
   * @param {*} active The current active selection clause.
   * @param {*} client The client whose data may be filtered.
   * @returns {*} The query predicate for filtering client data,
   *  based on the current state of this selection.
   */
  predicate(t, n, r) {
    const { union: i } = this;
    if (this.skip(r, n))
      return;
    const s = t.filter((o) => !this.skip(r, o)).map((o) => o.predicate);
    return i && s.length > 1 ? Ky(s) : s;
  }
  /**
   * Returns a filter function for queued selection updates.
   * @param {*} value The new event value that will be enqueued.
   * @returns {(value: *) => boolean|null} A dispatch queue filter
   *  function, or null if all unemitted event values should be filtered.
   */
  queueFilter(t) {
    var n;
    if (this.cross) {
      const r = (n = t.active) == null ? void 0 : n.source;
      return (i) => {
        var s;
        return ((s = i.active) == null ? void 0 : s.source) !== r;
      };
    }
  }
}
function iL() {
  const e = /* @__PURE__ */ new Set();
  let t, n = new Promise((r) => t = r);
  return {
    /**
     * Mark an item as pending.
     * @param {*} item An item to synchronize on.
     */
    pending(r) {
      e.add(r);
    },
    /**
     * Mark a pending item as ready, indicating it is
     * ready for a synchronized update.
     * @param {*} item An item to synchronize on.
     * @returns {boolean} True if the synchronizer is ready to
     *  resolve, false otherwise.
     */
    ready(r) {
      return e.delete(r), e.size === 0;
    },
    /**
     * Resolve the current synchronization cycle, causing the synchronize
     * promise to resolve and thereby trigger downstream updates.
     */
    resolve() {
      n = new Promise((r) => {
        t(), t = r;
      });
    },
    /**
     * The promise for the current synchronization cycle.
     * @return {Promise} The synchronization promise.
     */
    get promise() {
      return n;
    }
  };
}
const rm = Symbol("Fixed"), Ls = Symbol("Transient"), ux = Symbol("Transform");
function re(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function ks(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function Oh(e) {
  let t, n, r;
  e.length !== 2 ? (t = re, n = (a, c) => re(e(a), c), r = (a, c) => e(a) - c) : (t = e === re || e === ks ? e : sL, n = e, r = e);
  function i(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 = i(a, c, u, l - 1);
    return f > u && r(a[f - 1], c) > -r(a[f], c) ? f - 1 : f;
  }
  return { left: i, center: o, right: s };
}
function sL() {
  return 0;
}
function lx(e) {
  return e === null ? NaN : +e;
}
function* oL(e, t) {
  if (t === void 0)
    for (let n of e)
      n != null && (n = +n) >= n && (yield n);
  else {
    let n = -1;
    for (let r of e)
      (r = t(r, ++n, e)) != null && (r = +r) >= r && (yield r);
  }
}
const aL = Oh(re), cL = aL.right;
Oh(lx).center;
const Lh = cL, fx = hx(dx), uL = hx(lL);
function hx(e) {
  return function(t, n, r = n) {
    if (!((n = +n) >= 0))
      throw new RangeError("invalid rx");
    if (!((r = +r) >= 0))
      throw new RangeError("invalid ry");
    let { data: i, width: s, height: o } = t;
    if (!((s = Math.floor(s)) >= 0))
      throw new RangeError("invalid width");
    if (!((o = Math.floor(o !== void 0 ? o : i.length / s)) >= 0))
      throw new RangeError("invalid height");
    if (!s || !o || !n && !r)
      return t;
    const a = n && e(n), c = r && e(r), u = i.slice();
    return a && c ? (to(a, u, i, s, o), to(a, i, u, s, o), to(a, u, i, s, o), eo(c, i, u, s, o), eo(c, u, i, s, o), eo(c, i, u, s, o)) : a ? (to(a, i, u, s, o), to(a, u, i, s, o), to(a, i, u, s, o)) : c && (eo(c, i, u, s, o), eo(c, u, i, s, o), eo(c, i, u, s, o)), t;
  };
}
function to(e, t, n, r, i) {
  for (let s = 0, o = r * i; s < o; )
    e(t, n, s, s += r, 1);
}
function eo(e, t, n, r, i) {
  for (let s = 0, o = r * i; s < r; ++s)
    e(t, n, s, s + o, r);
}
function lL(e) {
  const t = dx(e);
  return (n, r, i, s, o) => {
    i <<= 2, s <<= 2, o <<= 2, t(n, r, i + 0, s + 0, o), t(n, r, i + 1, s + 1, o), t(n, r, i + 2, s + 2, o), t(n, r, i + 3, s + 3, o);
  };
}
function dx(e) {
  const t = Math.floor(e);
  if (t === e)
    return fL(e);
  const n = e - t, r = 2 * e + 1;
  return (i, 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)], i[h] = (u + n * (s[Math.max(o, h - f)] + s[Math.min(a, h + f)])) / r, u -= s[Math.max(o, h - l)];
  };
}
function fL(e) {
  const t = 2 * e + 1;
  return (n, r, i, s, o) => {
    if (!((s -= o) >= i))
      return;
    let a = e * r[i];
    const c = o * e;
    for (let u = i, l = i + c; u < l; u += o)
      a += r[Math.min(s, u)];
    for (let u = i, l = s; u <= l; u += o)
      a += r[Math.min(s, u + c)], n[u] = a / t, a -= r[Math.max(i, u - c)];
  };
}
function kh(e, t) {
  let n = 0;
  if (t === void 0)
    for (let r of e)
      r != null && (r = +r) >= r && ++n;
  else {
    let r = -1;
    for (let i of e)
      (i = t(i, ++r, e)) != null && (i = +i) >= i && ++n;
  }
  return n;
}
function hL(e) {
  return e.length | 0;
}
function dL(e) {
  return !(e > 0);
}
function pL(e) {
  return typeof e != "object" || "length" in e ? e : Array.from(e);
}
function yL(e) {
  return (t) => e(...t);
}
function mL(...e) {
  const t = typeof e[e.length - 1] == "function" && yL(e.pop());
  e = e.map(pL);
  const n = e.map(hL), r = e.length - 1, i = new Array(r + 1).fill(0), s = [];
  if (r < 0 || n.some(dL))
    return s;
  for (; ; ) {
    s.push(i.map((a, c) => e[c][a]));
    let o = r;
    for (; ++i[o] === n[o]; ) {
      if (o === 0)
        return t ? s.map(t) : s;
      i[o--] = 0;
    }
  }
}
function gL(e, t) {
  var n = 0, r = 0;
  return Float64Array.from(e, t === void 0 ? (i) => n += +i || 0 : (i) => n += +t(i, r++, e) || 0);
}
function im(e, t) {
  let n = 0, r, i = 0, s = 0;
  if (t === void 0)
    for (let o of e)
      o != null && (o = +o) >= o && (r = o - i, i += r / ++n, s += r * (o - i));
  else {
    let o = -1;
    for (let a of e)
      (a = t(a, ++o, e)) != null && (a = +a) >= a && (r = a - i, i += r / ++n, s += r * (a - i));
  }
  if (n > 1)
    return s / (n - 1);
}
function tu(e, t) {
  const n = im(e, t);
  return n && Math.sqrt(n);
}
function fe(e, t) {
  let n, r;
  if (t === void 0)
    for (const i of e)
      i != null && (n === void 0 ? i >= i && (n = r = i) : (n > i && (n = i), r < i && (r = i)));
  else {
    let i = -1;
    for (let s of e)
      (s = t(s, ++i, e)) != null && (n === void 0 ? s >= s && (n = r = s) : (n > s && (n = s), r < s && (r = s)));
  }
  return [n, r];
}
class hr {
  constructor() {
    this._partials = new Float64Array(32), this._n = 0;
  }
  add(t) {
    const n = this._partials;
    let r = 0;
    for (let i = 0; i < this._n && i < 32; i++) {
      const s = n[i], o = t + s, a = Math.abs(t) < Math.abs(s) ? t - (o - s) : s - (o - t);
      a && (n[r++] = a), t = o;
    }
    return n[r] = t, this._n = r + 1, this;
  }
  valueOf() {
    const t = this._partials;
    let n = this._n, r, i, s, o = 0;
    if (n > 0) {
      for (o = t[--n]; n > 0 && (r = o, i = t[--n], o = r + i, s = i - (o - r), !s); )
        ;
      n > 0 && (s < 0 && t[n - 1] < 0 || s > 0 && t[n - 1] > 0) && (i = s * 2, r = o + i, i == r - o && (o = r));
    }
    return o;
  }
}
class Fs extends Map {
  constructor(t, n = mx) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const [r, i] of t)
        this.set(r, i);
  }
  get(t) {
    return super.get(a0(this, t));
  }
  has(t) {
    return super.has(a0(this, t));
  }
  set(t, n) {
    return super.set(px(this, t), n);
  }
  delete(t) {
    return super.delete(yx(this, t));
  }
}
class eu extends Set {
  constructor(t, n = mx) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const r of t)
        this.add(r);
  }
  has(t) {
    return super.has(a0(this, t));
  }
  add(t) {
    return super.add(px(this, t));
  }
  delete(t) {
    return super.delete(yx(this, t));
  }
}
function a0({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) ? e.get(r) : n;
}
function px({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) ? e.get(r) : (e.set(r, n), n);
}
function yx({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) && (n = e.get(r), e.delete(r)), n;
}
function mx(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function c0(e) {
  return e;
}
function ii(e, ...t) {
  return sm(e, c0, c0, t);
}
function Do(e, t, ...n) {
  return sm(e, c0, t, n);
}
function bL(e, t, ...n) {
  return sm(e, Array.from, t, n);
}
function sm(e, t, n, r) {
  return function i(s, o) {
    if (o >= r.length)
      return n(s);
    const a = new Fs(), c = r[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, i(f, o));
    return t(a);
  }(e, 0);
}
function wL(e, t) {
  return Array.from(t, (n) => e[n]);
}
function Sc(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 r = Uint32Array.from(e, (i, s) => s);
    return t.length > 1 ? (t = t.map((i) => e.map(i)), r.sort((i, s) => {
      for (const o of t) {
        const a = Mc(o[i], o[s]);
        if (a)
          return a;
      }
    })) : (n = e.map(n), r.sort((i, s) => Mc(n[i], n[s]))), wL(e, r);
  }
  return e.sort(om(n));
}
function om(e = re) {
  if (e === re)
    return Mc;
  if (typeof e != "function")
    throw new TypeError("compare is not a function");
  return (t, n) => {
    const r = e(t, n);
    return r || r === 0 ? r : (e(n, n) === 0) - (e(t, t) === 0);
  };
}
function Mc(e, t) {
  return (e == null || !(e >= e)) - (t == null || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0);
}
function am(e, t, n) {
  return (t.length !== 2 ? Sc(Do(e, t, n), ([r, i], [s, o]) => re(i, o) || re(r, s)) : Sc(ii(e, n), ([r, i], [s, o]) => t(i, o) || re(r, s))).map(([r]) => r);
}
const vL = Math.sqrt(50), _L = Math.sqrt(10), xL = Math.sqrt(2);
function hf(e, t, n) {
  const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), s = r / Math.pow(10, i), o = s >= vL ? 10 : s >= _L ? 5 : s >= xL ? 2 : 1;
  let a, c, u;
  return i < 0 ? (u = Math.pow(10, -i) / 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, i) * 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 ? hf(e, t, n * 2) : [a, c, u];
}
function ki(e, t, n) {
  if (t = +t, e = +e, n = +n, !(n > 0))
    return [];
  if (e === t)
    return [e];
  const r = t < e, [i, s, o] = r ? hf(t, e, n) : hf(e, t, n);
  if (!(s >= i))
    return [];
  const a = s - i + 1, c = new Array(a);
  if (r)
    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] = (i + u) / -o;
  else
    for (let u = 0; u < a; ++u)
      c[u] = (i + u) * o;
  return c;
}
function Ac(e, t, n) {
  return t = +t, e = +e, n = +n, hf(e, t, n)[2];
}
function u0(e, t, n) {
  t = +t, e = +e, n = +n;
  const r = t < e, i = r ? Ac(t, e, n) : Ac(e, t, n);
  return (r ? -1 : 1) * (i < 0 ? 1 / -i : i);
}
function gx(e, t, n) {
  let r;
  for (; ; ) {
    const i = Ac(e, t, n);
    if (i === r || i === 0 || !isFinite(i))
      return [e, t];
    i > 0 ? (e = Math.floor(e / i) * i, t = Math.ceil(t / i) * i) : i < 0 && (e = Math.ceil(e * i) / i, t = Math.floor(t * i) / i), r = i;
  }
}
function cm(e) {
  return Math.max(1, Math.ceil(Math.log(kh(e)) / Math.LN2) + 1);
}
function Qt(e, t) {
  let n;
  if (t === void 0)
    for (const r of e)
      r != null && (n < r || n === void 0 && r >= r) && (n = r);
  else {
    let r = -1;
    for (let i of e)
      (i = t(i, ++r, e)) != null && (n < i || n === void 0 && i >= i) && (n = i);
  }
  return n;
}
function SL(e, t) {
  let n, r = -1, i = -1;
  if (t === void 0)
    for (const s of e)
      ++i, s != null && (n < s || n === void 0 && s >= s) && (n = s, r = i);
  else
    for (let s of e)
      (s = t(s, ++i, e)) != null && (n < s || n === void 0 && s >= s) && (n = s, r = i);
  return r;
}
function be(e, t) {
  let n;
  if (t === void 0)
    for (const r of e)
      r != null && (n > r || n === void 0 && r >= r) && (n = r);
  else {
    let r = -1;
    for (let i of e)
      (i = t(i, ++r, e)) != null && (n > i || n === void 0 && i >= i) && (n = i);
  }
  return n;
}
function ML(e, t) {
  let n, r = -1, i = -1;
  if (t === void 0)
    for (const s of e)
      ++i, s != null && (n > s || n === void 0 && s >= s) && (n = s, r = i);
  else
    for (let s of e)
      (s = t(s, ++i, e)) != null && (n > s || n === void 0 && s >= s) && (n = s, r = i);
  return r;
}
function bx(e, t, n = 0, r = 1 / 0, i) {
  if (t = Math.floor(t), n = Math.floor(Math.max(0, n)), r = Math.floor(Math.min(e.length - 1, r)), !(n <= t && t <= r))
    return e;
  for (i = i === void 0 ? Mc : om(i); r > n; ) {
    if (r - n > 600) {
      const c = r - 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(r, Math.floor(t + (c - u) * f / c + h));
      bx(e, t, d, p, i);
    }
    const s = e[t];
    let o = n, a = r;
    for (ka(e, n, t), i(e[r], s) > 0 && ka(e, n, r); o < a; ) {
      for (ka(e, o, a), ++o, --a; i(e[o], s) < 0; )
        ++o;
      for (; i(e[a], s) > 0; )
        --a;
    }
    i(e[n], s) === 0 ? ka(e, n, a) : (++a, ka(e, a, r)), a <= t && (n = a + 1), t <= a && (r = a - 1);
  }
  return e;
}
function ka(e, t, n) {
  const r = e[t];
  e[t] = e[n], e[n] = r;
}
function um(e, t = re) {
  let n, r = !1;
  if (t.length === 1) {
    let i;
    for (const s of e) {
      const o = t(s);
      (r ? re(o, i) > 0 : re(o, o) === 0) && (n = s, i = o, r = !0);
    }
  } else
    for (const i of e)
      (r ? t(i, n) > 0 : t(i, i) === 0) && (n = i, r = !0);
  return n;
}
function Fi(e, t, n) {
  if (e = Float64Array.from(oL(e, n)), !(!(r = e.length) || isNaN(t = +t))) {
    if (t <= 0 || r < 2)
      return be(e);
    if (t >= 1)
      return Qt(e);
    var r, i = (r - 1) * t, s = Math.floor(i), o = Qt(bx(e, s).subarray(0, s + 1)), a = be(e.subarray(s + 1));
    return o + (a - o) * (i - s);
  }
}
function AL(e, t, n = lx) {
  if (!(!(r = e.length) || isNaN(t = +t))) {
    if (t <= 0 || r < 2)
      return +n(e[0], 0, e);
    if (t >= 1)
      return +n(e[r - 1], r - 1, e);
    var r, i = (r - 1) * t, s = Math.floor(i), o = +n(e[s], s, e), a = +n(e[s + 1], s + 1, e);
    return o + (a - o) * (i - s);
  }
}
function $L(e, t, n) {
  const r = kh(e), i = Fi(e, 0.75) - Fi(e, 0.25);
  return r && i ? Math.ceil((n - t) / (2 * i * Math.pow(r, -1 / 3))) : 1;
}
function wx(e, t, n) {
  const r = kh(e), i = tu(e);
  return r && i ? Math.ceil((n - t) * Math.cbrt(r) / (3.49 * i)) : 1;
}
function Fh(e, t) {
  let n = 0, r = 0;
  if (t === void 0)
    for (let i of e)
      i != null && (i = +i) >= i && (++n, r += i);
  else {
    let i = -1;
    for (let s of e)
      (s = t(s, ++i, e)) != null && (s = +s) >= s && (++n, r += s);
  }
  if (n)
    return r / n;
}
function $c(e, t) {
  return Fi(e, 0.5, t);
}
function* IL(e) {
  for (const t of e)
    yield* t;
}
function vx(e) {
  return Array.from(IL(e));
}
function _x(e, t) {
  const n = new Fs();
  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 r, i = 0;
  for (const [s, o] of n)
    o > i && (i = o, r = s);
  return r;
}
function TL(e, t = EL) {
  const n = [];
  let r, i = !1;
  for (const s of e)
    i && n.push(t(r, s)), r = s, i = !0;
  return n;
}
function EL(e, t) {
  return [e, t];
}
function nn(e, t, n) {
  e = +e, t = +t, n = (i = arguments.length) < 2 ? (t = e, e = 0, 1) : i < 3 ? 1 : +n;
  for (var r = -1, i = Math.max(0, Math.ceil((t - e) / n)) | 0, s = new Array(i); ++r < i; )
    s[r] = e + r * n;
  return s;
}
function xx(e, t = re) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  let n = Array.from(e);
  const r = new Float64Array(n.length);
  t.length !== 2 && (n = n.map(t), t = re);
  const i = (a, c) => t(n[a], n[c]);
  let s, o;
  return e = Uint32Array.from(n, (a, c) => c), e.sort(t === re ? (a, c) => Mc(n[a], n[c]) : om(i)), e.forEach((a, c) => {
    const u = i(a, s === void 0 ? a : s);
    u >= 0 ? ((s === void 0 || u > 0) && (s = a, o = c), r[a] = o) : r[a] = NaN;
  }), r;
}
function NL(e, t = re) {
  let n, r = !1;
  if (t.length === 1) {
    let i;
    for (const s of e) {
      const o = t(s);
      (r ? re(o, i) < 0 : re(o, o) === 0) && (n = s, i = o, r = !0);
    }
  } else
    for (const i of e)
      (r ? t(i, n) < 0 : t(i, i) === 0) && (n = i, r = !0);
  return n;
}
function gr(e, t) {
  let n = 0;
  if (t === void 0)
    for (let r of e)
      (r = +r) && (n += r);
  else {
    let r = -1;
    for (let i of e)
      (i = +t(i, ++r, e)) && (n += i);
  }
  return n;
}
function df(e) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  return Array.from(e).reverse();
}
function DL(e) {
  return e;
}
var qd = 1, Vd = 2, l0 = 3, Uu = 4, J1 = 1e-6;
function OL(e) {
  return "translate(" + e + ",0)";
}
function LL(e) {
  return "translate(0," + e + ")";
}
function kL(e) {
  return (t) => +e(t);
}
function FL(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (n) => +e(n) + t;
}
function RL() {
  return !this.__axis;
}
function CL(e, t) {
  var n = [], r = null, i = null, s = 6, o = 6, a = 3, c = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, u = e === qd || e === Uu ? -1 : 1, l = e === Uu || e === Vd ? "x" : "y", f = e === qd || e === l0 ? OL : LL;
  function h(d) {
    var p = r ?? (t.ticks ? t.ticks.apply(t, n) : t.domain()), y = i ?? (t.tickFormat ? t.tickFormat.apply(t, n) : DL), g = Math.max(s, 0) + a, m = t.range(), b = +m[0] + c, w = +m[m.length - 1] + c, v = (t.bandwidth ? FL : kL)(t.copy(), c), x = d.selection ? d.selection() : d, _ = x.selectAll(".domain").data([null]), M = x.selectAll(".tick").data(p, t).order(), T = M.exit(), N = M.enter().append("g").attr("class", "tick"), A = M.select("line"), $ = M.select("text");
    _ = _.merge(_.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), M = M.merge(N), A = A.merge(N.append("line").attr("stroke", "currentColor").attr(l + "2", u * s)), $ = $.merge(N.append("text").attr("fill", "currentColor").attr(l, u * g).attr("dy", e === qd ? "0em" : e === l0 ? "0.71em" : "0.32em")), d !== x && (_ = _.transition(d), M = M.transition(d), A = A.transition(d), $ = $.transition(d), T = T.transition(d).attr("opacity", J1).attr("transform", function(D) {
      return isFinite(D = v(D)) ? f(D + c) : this.getAttribute("transform");
    }), N.attr("opacity", J1).attr("transform", function(D) {
      var F = this.parentNode.__axis;
      return f((F && isFinite(F = F(D)) ? F : v(D)) + c);
    })), T.remove(), _.attr("d", e === Uu || e === Vd ? 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), M.attr("opacity", 1).attr("transform", function(D) {
      return f(v(D) + c);
    }), A.attr(l + "2", u * s), $.attr(l, u * g).text(y), x.filter(RL).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === Vd ? "start" : e === Uu ? "end" : "middle"), x.each(function() {
      this.__axis = v;
    });
  }
  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 ? (r = d == null ? null : Array.from(d), h) : r && r.slice();
  }, h.tickFormat = function(d) {
    return arguments.length ? (i = d, h) : i;
  }, 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 BL(e) {
  return CL(l0, e);
}
var PL = { value: () => {
} };
function Rh() {
  for (var e = 0, t = arguments.length, n = {}, r; e < t; ++e) {
    if (!(r = arguments[e] + "") || r in n || /[\s.]/.test(r))
      throw new Error("illegal type: " + r);
    n[r] = [];
  }
  return new Sl(n);
}
function Sl(e) {
  this._ = e;
}
function UL(e, t) {
  return e.trim().split(/^|\s+/).map(function(n) {
    var r = "", i = n.indexOf(".");
    if (i >= 0 && (r = n.slice(i + 1), n = n.slice(0, i)), n && !t.hasOwnProperty(n))
      throw new Error("unknown type: " + n);
    return { type: n, name: r };
  });
}
Sl.prototype = Rh.prototype = {
  constructor: Sl,
  on: function(e, t) {
    var n = this._, r = UL(e + "", n), i, s = -1, o = r.length;
    if (arguments.length < 2) {
      for (; ++s < o; )
        if ((i = (e = r[s]).type) && (i = zL(n[i], e.name)))
          return i;
      return;
    }
    if (t != null && typeof t != "function")
      throw new Error("invalid callback: " + t);
    for (; ++s < o; )
      if (i = (e = r[s]).type)
        n[i] = Z1(n[i], e.name, t);
      else if (t == null)
        for (i in n)
          n[i] = Z1(n[i], e.name, null);
    return this;
  },
  copy: function() {
    var e = {}, t = this._;
    for (var n in t)
      e[n] = t[n].slice();
    return new Sl(e);
  },
  call: function(e, t) {
    if ((i = arguments.length - 2) > 0)
      for (var n = new Array(i), r = 0, i, s; r < i; ++r)
        n[r] = arguments[r + 2];
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (s = this._[e], r = 0, i = s.length; r < i; ++r)
      s[r].value.apply(t, n);
  },
  apply: function(e, t, n) {
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (var r = this._[e], i = 0, s = r.length; i < s; ++i)
      r[i].value.apply(t, n);
  }
};
function zL(e, t) {
  for (var n = 0, r = e.length, i; n < r; ++n)
    if ((i = e[n]).name === t)
      return i.value;
}
function Z1(e, t, n) {
  for (var r = 0, i = e.length; r < i; ++r)
    if (e[r].name === t) {
      e[r] = PL, e = e.slice(0, r).concat(e.slice(r + 1));
      break;
    }
  return n != null && e.push({ name: t, value: n }), e;
}
var f0 = "http://www.w3.org/1999/xhtml";
const Rs = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: f0,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function Ch(e) {
  var t = e += "", n = t.indexOf(":");
  return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), Rs.hasOwnProperty(t) ? { space: Rs[t], local: e } : e;
}
function jL(e) {
  return function() {
    var t = this.ownerDocument, n = this.namespaceURI;
    return n === f0 && t.documentElement.namespaceURI === f0 ? t.createElement(e) : t.createElementNS(n, e);
  };
}
function qL(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function Bh(e) {
  var t = Ch(e);
  return (t.local ? qL : jL)(t);
}
function VL() {
}
function lm(e) {
  return e == null ? VL : function() {
    return this.querySelector(e);
  };
}
function YL(e) {
  typeof e != "function" && (e = lm(e));
  for (var t = this._groups, n = t.length, r = new Array(n), i = 0; i < n; ++i)
    for (var s = t[i], o = s.length, a = r[i] = 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 an(r, this._parents);
}
function WL(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function XL() {
  return [];
}
function Sx(e) {
  return e == null ? XL : function() {
    return this.querySelectorAll(e);
  };
}
function GL(e) {
  return function() {
    return WL(e.apply(this, arguments));
  };
}
function HL(e) {
  typeof e == "function" ? e = GL(e) : e = Sx(e);
  for (var t = this._groups, n = t.length, r = [], i = [], s = 0; s < n; ++s)
    for (var o = t[s], a = o.length, c, u = 0; u < a; ++u)
      (c = o[u]) && (r.push(e.call(c, c.__data__, u, o)), i.push(c));
  return new an(r, i);
}
function Mx(e) {
  return function() {
    return this.matches(e);
  };
}
function Ax(e) {
  return function(t) {
    return t.matches(e);
  };
}
var JL = Array.prototype.find;
function ZL(e) {
  return function() {
    return JL.call(this.children, e);
  };
}
function KL() {
  return this.firstElementChild;
}
function QL(e) {
  return this.select(e == null ? KL : ZL(typeof e == "function" ? e : Ax(e)));
}
var tk = Array.prototype.filter;
function ek() {
  return Array.from(this.children);
}
function nk(e) {
  return function() {
    return tk.call(this.children, e);
  };
}
function rk(e) {
  return this.selectAll(e == null ? ek : nk(typeof e == "function" ? e : Ax(e)));
}
function ik(e) {
  typeof e != "function" && (e = Mx(e));
  for (var t = this._groups, n = t.length, r = new Array(n), i = 0; i < n; ++i)
    for (var s = t[i], o = s.length, a = r[i] = [], c, u = 0; u < o; ++u)
      (c = s[u]) && e.call(c, c.__data__, u, s) && a.push(c);
  return new an(r, this._parents);
}
function $x(e) {
  return new Array(e.length);
}
function sk() {
  return new an(this._enter || this._groups.map($x), this._parents);
}
function pf(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
pf.prototype = {
  constructor: pf,
  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 ok(e) {
  return function() {
    return e;
  };
}
function ak(e, t, n, r, i, s) {
  for (var o = 0, a, c = t.length, u = s.length; o < u; ++o)
    (a = t[o]) ? (a.__data__ = s[o], r[o] = a) : n[o] = new pf(e, s[o]);
  for (; o < c; ++o)
    (a = t[o]) && (i[o] = a);
}
function ck(e, t, n, r, i, 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) ? i[a] = c : u.set(d, c));
  for (a = 0; a < f; ++a)
    d = o.call(e, s[a], a, s) + "", (c = u.get(d)) ? (r[a] = c, c.__data__ = s[a], u.delete(d)) : n[a] = new pf(e, s[a]);
  for (a = 0; a < l; ++a)
    (c = t[a]) && u.get(h[a]) === c && (i[a] = c);
}
function uk(e) {
  return e.__data__;
}
function lk(e, t) {
  if (!arguments.length)
    return Array.from(this, uk);
  var n = t ? ck : ak, r = this._parents, i = this._groups;
  typeof e != "function" && (e = ok(e));
  for (var s = i.length, o = new Array(s), a = new Array(s), c = new Array(s), u = 0; u < s; ++u) {
    var l = r[u], f = i[u], h = f.length, d = fk(e.call(l, l && l.__data__, u, r)), p = d.length, y = a[u] = new Array(p), g = o[u] = new Array(p), m = c[u] = new Array(h);
    n(l, f, y, g, m, d, t);
    for (var b = 0, w = 0, v, x; b < p; ++b)
      if (v = y[b]) {
        for (b >= w && (w = b + 1); !(x = g[w]) && ++w < p; )
          ;
        v._next = x || null;
      }
  }
  return o = new an(o, r), o._enter = a, o._exit = c, o;
}
function fk(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function hk() {
  return new an(this._exit || this._groups.map($x), this._parents);
}
function dk(e, t, n) {
  var r = this.enter(), i = this, s = this.exit();
  return typeof e == "function" ? (r = e(r), r && (r = r.selection())) : r = r.append(e + ""), t != null && (i = t(i), i && (i = i.selection())), n == null ? s.remove() : n(s), r && i ? r.merge(i).order() : i;
}
function pk(e) {
  for (var t = e.selection ? e.selection() : e, n = this._groups, r = t._groups, i = n.length, s = r.length, o = Math.min(i, s), a = new Array(i), c = 0; c < o; ++c)
    for (var u = n[c], l = r[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 < i; ++c)
    a[c] = n[c];
  return new an(a, this._parents);
}
function yk() {
  for (var e = this._groups, t = -1, n = e.length; ++t < n; )
    for (var r = e[t], i = r.length - 1, s = r[i], o; --i >= 0; )
      (o = r[i]) && (s && o.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(o, s), s = o);
  return this;
}
function mk(e) {
  e || (e = gk);
  function t(f, h) {
    return f && h ? e(f.__data__, h.__data__) : !f - !h;
  }
  for (var n = this._groups, r = n.length, i = new Array(r), s = 0; s < r; ++s) {
    for (var o = n[s], a = o.length, c = i[s] = new Array(a), u, l = 0; l < a; ++l)
      (u = o[l]) && (c[l] = u);
    c.sort(t);
  }
  return new an(i, this._parents).order();
}
function gk(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function bk() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function wk() {
  return Array.from(this);
}
function vk() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var r = e[t], i = 0, s = r.length; i < s; ++i) {
      var o = r[i];
      if (o)
        return o;
    }
  return null;
}
function _k() {
  let e = 0;
  for (const t of this)
    ++e;
  return e;
}
function xk() {
  return !this.node();
}
function Sk(e) {
  for (var t = this._groups, n = 0, r = t.length; n < r; ++n)
    for (var i = t[n], s = 0, o = i.length, a; s < o; ++s)
      (a = i[s]) && e.call(a, a.__data__, s, i);
  return this;
}
function Mk(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function Ak(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function $k(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function Ik(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function Tk(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
  };
}
function Ek(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 Nk(e, t) {
  var n = Ch(e);
  if (arguments.length < 2) {
    var r = this.node();
    return n.local ? r.getAttributeNS(n.space, n.local) : r.getAttribute(n);
  }
  return this.each((t == null ? n.local ? Ak : Mk : typeof t == "function" ? n.local ? Ek : Tk : n.local ? Ik : $k)(n, t));
}
function Ix(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function Dk(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function Ok(e, t, n) {
  return function() {
    this.style.setProperty(e, t, n);
  };
}
function Lk(e, t, n) {
  return function() {
    var r = t.apply(this, arguments);
    r == null ? this.style.removeProperty(e) : this.style.setProperty(e, r, n);
  };
}
function kk(e, t, n) {
  return arguments.length > 1 ? this.each((t == null ? Dk : typeof t == "function" ? Lk : Ok)(e, t, n ?? "")) : Jo(this.node(), e);
}
function Jo(e, t) {
  return e.style.getPropertyValue(t) || Ix(e).getComputedStyle(e, null).getPropertyValue(t);
}
function Fk(e) {
  return function() {
    delete this[e];
  };
}
function Rk(e, t) {
  return function() {
    this[e] = t;
  };
}
function Ck(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? delete this[e] : this[e] = n;
  };
}
function Bk(e, t) {
  return arguments.length > 1 ? this.each((t == null ? Fk : typeof t == "function" ? Ck : Rk)(e, t)) : this.node()[e];
}
function Tx(e) {
  return e.trim().split(/^|\s+/);
}
function fm(e) {
  return e.classList || new Ex(e);
}
function Ex(e) {
  this._node = e, this._names = Tx(e.getAttribute("class") || "");
}
Ex.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 Nx(e, t) {
  for (var n = fm(e), r = -1, i = t.length; ++r < i; )
    n.add(t[r]);
}
function Dx(e, t) {
  for (var n = fm(e), r = -1, i = t.length; ++r < i; )
    n.remove(t[r]);
}
function Pk(e) {
  return function() {
    Nx(this, e);
  };
}
function Uk(e) {
  return function() {
    Dx(this, e);
  };
}
function zk(e, t) {
  return function() {
    (t.apply(this, arguments) ? Nx : Dx)(this, e);
  };
}
function jk(e, t) {
  var n = Tx(e + "");
  if (arguments.length < 2) {
    for (var r = fm(this.node()), i = -1, s = n.length; ++i < s; )
      if (!r.contains(n[i]))
        return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? zk : t ? Pk : Uk)(n, t));
}
function qk() {
  this.textContent = "";
}
function Vk(e) {
  return function() {
    this.textContent = e;
  };
}
function Yk(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function Wk(e) {
  return arguments.length ? this.each(e == null ? qk : (typeof e == "function" ? Yk : Vk)(e)) : this.node().textContent;
}
function Xk() {
  this.innerHTML = "";
}
function Gk(e) {
  return function() {
    this.innerHTML = e;
  };
}
function Hk(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function Jk(e) {
  return arguments.length ? this.each(e == null ? Xk : (typeof e == "function" ? Hk : Gk)(e)) : this.node().innerHTML;
}
function Zk() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function Kk() {
  return this.each(Zk);
}
function Qk() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function tF() {
  return this.each(Qk);
}
function eF(e) {
  var t = typeof e == "function" ? e : Bh(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function nF() {
  return null;
}
function rF(e, t) {
  var n = typeof e == "function" ? e : Bh(e), r = t == null ? nF : typeof t == "function" ? t : lm(t);
  return this.select(function() {
    return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null);
  });
}
function iF() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function sF() {
  return this.each(iF);
}
function oF() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function aF() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function cF(e) {
  return this.select(e ? aF : oF);
}
function uF(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function lF(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function fF(e) {
  return e.trim().split(/^|\s+/).map(function(t) {
    var n = "", r = t.indexOf(".");
    return r >= 0 && (n = t.slice(r + 1), t = t.slice(0, r)), { type: t, name: n };
  });
}
function hF(e) {
  return function() {
    var t = this.__on;
    if (t) {
      for (var n = 0, r = -1, i = t.length, s; n < i; ++n)
        s = t[n], (!e.type || s.type === e.type) && s.name === e.name ? this.removeEventListener(s.type, s.listener, s.options) : t[++r] = s;
      ++r ? t.length = r : delete this.__on;
    }
  };
}
function dF(e, t, n) {
  return function() {
    var r = this.__on, i, s = lF(t);
    if (r) {
      for (var o = 0, a = r.length; o < a; ++o)
        if ((i = r[o]).type === e.type && i.name === e.name) {
          this.removeEventListener(i.type, i.listener, i.options), this.addEventListener(i.type, i.listener = s, i.options = n), i.value = t;
          return;
        }
    }
    this.addEventListener(e.type, s, n), i = { type: e.type, name: e.name, value: t, listener: s, options: n }, r ? r.push(i) : this.__on = [i];
  };
}
function pF(e, t, n) {
  var r = fF(e + ""), i, s = r.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 (i = 0, l = a[c]; i < s; ++i)
          if ((o = r[i]).type === l.type && o.name === l.name)
            return l.value;
    }
    return;
  }
  for (a = t ? dF : hF, i = 0; i < s; ++i)
    this.each(a(r[i], t, n));
  return this;
}
function Ox(e, t, n) {
  var r = Ix(e), i = r.CustomEvent;
  typeof i == "function" ? i = new i(t, n) : (i = r.document.createEvent("Event"), n ? (i.initEvent(t, n.bubbles, n.cancelable), i.detail = n.detail) : i.initEvent(t, !1, !1)), e.dispatchEvent(i);
}
function yF(e, t) {
  return function() {
    return Ox(this, e, t);
  };
}
function mF(e, t) {
  return function() {
    return Ox(this, e, t.apply(this, arguments));
  };
}
function gF(e, t) {
  return this.each((typeof t == "function" ? mF : yF)(e, t));
}
function* bF() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var r = e[t], i = 0, s = r.length, o; i < s; ++i)
      (o = r[i]) && (yield o);
}
var Lx = [null];
function an(e, t) {
  this._groups = e, this._parents = t;
}
function nu() {
  return new an([[document.documentElement]], Lx);
}
function wF() {
  return this;
}
an.prototype = nu.prototype = {
  constructor: an,
  select: YL,
  selectAll: HL,
  selectChild: QL,
  selectChildren: rk,
  filter: ik,
  data: lk,
  enter: sk,
  exit: hk,
  join: dk,
  merge: pk,
  selection: wF,
  order: yk,
  sort: mk,
  call: bk,
  nodes: wk,
  node: vk,
  size: _k,
  empty: xk,
  each: Sk,
  attr: Nk,
  style: kk,
  property: Bk,
  classed: jk,
  text: Wk,
  html: Jk,
  raise: Kk,
  lower: tF,
  append: eF,
  insert: rF,
  remove: sF,
  clone: cF,
  datum: uF,
  on: pF,
  dispatch: gF,
  [Symbol.iterator]: bF
};
function Vt(e) {
  return typeof e == "string" ? new an([[document.querySelector(e)]], [document.documentElement]) : new an([[e]], Lx);
}
function vF(e) {
  let t;
  for (; t = e.sourceEvent; )
    e = t;
  return e;
}
function En(e, t) {
  if (e = vF(e), t === void 0 && (t = e.currentTarget), t) {
    var n = t.ownerSVGElement || t;
    if (n.createSVGPoint) {
      var r = n.createSVGPoint();
      return r.x = e.clientX, r.y = e.clientY, r = r.matrixTransform(t.getScreenCTM().inverse()), [r.x, r.y];
    }
    if (t.getBoundingClientRect) {
      var i = t.getBoundingClientRect();
      return [e.clientX - i.left - t.clientLeft, e.clientY - i.top - t.clientTop];
    }
  }
  return [e.pageX, e.pageY];
}
const h0 = { capture: !0, passive: !1 };
function d0(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function kx(e) {
  var t = e.document.documentElement, n = Vt(e).on("dragstart.drag", d0, h0);
  "onselectstart" in t ? n.on("selectstart.drag", d0, h0) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function Fx(e, t) {
  var n = e.document.documentElement, r = Vt(e).on("dragstart.drag", null);
  t && (r.on("click.drag", d0, h0), setTimeout(function() {
    r.on("click.drag", null);
  }, 0)), "onselectstart" in n ? r.on("selectstart.drag", null) : (n.style.MozUserSelect = n.__noselect, delete n.__noselect);
}
function ga(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function ru(e, t) {
  var n = Object.create(e.prototype);
  for (var r in t)
    n[r] = t[r];
  return n;
}
function Wi() {
}
var Cs = 0.7, Zo = 1 / Cs, Oo = "\\s*([+-]?\\d+)\\s*", Ic = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", dr = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", _F = /^#([0-9a-f]{3,8})$/, xF = new RegExp(`^rgb\\(${Oo},${Oo},${Oo}\\)$`), SF = new RegExp(`^rgb\\(${dr},${dr},${dr}\\)$`), MF = new RegExp(`^rgba\\(${Oo},${Oo},${Oo},${Ic}\\)$`), AF = new RegExp(`^rgba\\(${dr},${dr},${dr},${Ic}\\)$`), $F = new RegExp(`^hsl\\(${Ic},${dr},${dr}\\)$`), IF = new RegExp(`^hsla\\(${Ic},${dr},${dr},${Ic}\\)$`), K1 = {
  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
};
ga(Wi, Ri, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: Q1,
  // Deprecated! Use color.formatHex.
  formatHex: Q1,
  formatHex8: TF,
  formatHsl: EF,
  formatRgb: tb,
  toString: tb
});
function Q1() {
  return this.rgb().formatHex();
}
function TF() {
  return this.rgb().formatHex8();
}
function EF() {
  return Rx(this).formatHsl();
}
function tb() {
  return this.rgb().formatRgb();
}
function Ri(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = _F.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? eb(t) : n === 3 ? new ge(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? zu(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? zu(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 = xF.exec(e)) ? new ge(t[1], t[2], t[3], 1) : (t = SF.exec(e)) ? new ge(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = MF.exec(e)) ? zu(t[1], t[2], t[3], t[4]) : (t = AF.exec(e)) ? zu(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = $F.exec(e)) ? ib(t[1], t[2] / 100, t[3] / 100, 1) : (t = IF.exec(e)) ? ib(t[1], t[2] / 100, t[3] / 100, t[4]) : K1.hasOwnProperty(e) ? eb(K1[e]) : e === "transparent" ? new ge(NaN, NaN, NaN, 0) : null;
}
function eb(e) {
  return new ge(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function zu(e, t, n, r) {
  return r <= 0 && (e = t = n = NaN), new ge(e, t, n, r);
}
function hm(e) {
  return e instanceof Wi || (e = Ri(e)), e ? (e = e.rgb(), new ge(e.r, e.g, e.b, e.opacity)) : new ge();
}
function Sn(e, t, n, r) {
  return arguments.length === 1 ? hm(e) : new ge(e, t, n, r ?? 1);
}
function ge(e, t, n, r) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +r;
}
ga(ge, Sn, ru(Wi, {
  brighter(e) {
    return e = e == null ? Zo : Math.pow(Zo, e), new ge(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Cs : Math.pow(Cs, e), new ge(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new ge(Ms(this.r), Ms(this.g), Ms(this.b), yf(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: nb,
  // Deprecated! Use color.formatHex.
  formatHex: nb,
  formatHex8: NF,
  formatRgb: rb,
  toString: rb
}));
function nb() {
  return `#${gs(this.r)}${gs(this.g)}${gs(this.b)}`;
}
function NF() {
  return `#${gs(this.r)}${gs(this.g)}${gs(this.b)}${gs((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function rb() {
  const e = yf(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${Ms(this.r)}, ${Ms(this.g)}, ${Ms(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function yf(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function Ms(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function gs(e) {
  return e = Ms(e), (e < 16 ? "0" : "") + e.toString(16);
}
function ib(e, t, n, r) {
  return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new On(e, t, n, r);
}
function Rx(e) {
  if (e instanceof On)
    return new On(e.h, e.s, e.l, e.opacity);
  if (e instanceof Wi || (e = Ri(e)), !e)
    return new On();
  if (e instanceof On)
    return e;
  e = e.rgb();
  var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), s = Math.max(t, n, r), o = NaN, a = s - i, c = (s + i) / 2;
  return a ? (t === s ? o = (n - r) / a + (n < r) * 6 : n === s ? o = (r - t) / a + 2 : o = (t - n) / a + 4, a /= c < 0.5 ? s + i : 2 - s - i, o *= 60) : a = c > 0 && c < 1 ? 0 : o, new On(o, a, c, e.opacity);
}
function p0(e, t, n, r) {
  return arguments.length === 1 ? Rx(e) : new On(e, t, n, r ?? 1);
}
function On(e, t, n, r) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
ga(On, p0, ru(Wi, {
  brighter(e) {
    return e = e == null ? Zo : Math.pow(Zo, e), new On(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Cs : Math.pow(Cs, e), new On(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, r = n + (n < 0.5 ? n : 1 - n) * t, i = 2 * n - r;
    return new ge(
      Yd(e >= 240 ? e - 240 : e + 120, i, r),
      Yd(e, i, r),
      Yd(e < 120 ? e + 240 : e - 120, i, r),
      this.opacity
    );
  },
  clamp() {
    return new On(sb(this.h), ju(this.s), ju(this.l), yf(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 = yf(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${sb(this.h)}, ${ju(this.s) * 100}%, ${ju(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function sb(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function ju(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function Yd(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 Cx = Math.PI / 180, Bx = 180 / Math.PI, mf = 18, Px = 0.96422, Ux = 1, zx = 0.82521, jx = 4 / 29, Lo = 6 / 29, qx = 3 * Lo * Lo, DF = Lo * Lo * Lo;
function Vx(e) {
  if (e instanceof pr)
    return new pr(e.l, e.a, e.b, e.opacity);
  if (e instanceof jr)
    return Yx(e);
  e instanceof ge || (e = hm(e));
  var t = Hd(e.r), n = Hd(e.g), r = Hd(e.b), i = Wd((0.2225045 * t + 0.7168786 * n + 0.0606169 * r) / Ux), s, o;
  return t === n && n === r ? s = o = i : (s = Wd((0.4360747 * t + 0.3850649 * n + 0.1430804 * r) / Px), o = Wd((0.0139322 * t + 0.0971045 * n + 0.7141733 * r) / zx)), new pr(116 * i - 16, 500 * (s - i), 200 * (i - o), e.opacity);
}
function y0(e, t, n, r) {
  return arguments.length === 1 ? Vx(e) : new pr(e, t, n, r ?? 1);
}
function pr(e, t, n, r) {
  this.l = +e, this.a = +t, this.b = +n, this.opacity = +r;
}
ga(pr, y0, ru(Wi, {
  brighter(e) {
    return new pr(this.l + mf * (e ?? 1), this.a, this.b, this.opacity);
  },
  darker(e) {
    return new pr(this.l - mf * (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 = Px * Xd(t), e = Ux * Xd(e), n = zx * Xd(n), new ge(
      Gd(3.1338561 * t - 1.6168667 * e - 0.4906146 * n),
      Gd(-0.9787684 * t + 1.9161415 * e + 0.033454 * n),
      Gd(0.0719453 * t - 0.2289914 * e + 1.4052427 * n),
      this.opacity
    );
  }
}));
function Wd(e) {
  return e > DF ? Math.pow(e, 1 / 3) : e / qx + jx;
}
function Xd(e) {
  return e > Lo ? e * e * e : qx * (e - jx);
}
function Gd(e) {
  return 255 * (e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055);
}
function Hd(e) {
  return (e /= 255) <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function OF(e) {
  if (e instanceof jr)
    return new jr(e.h, e.c, e.l, e.opacity);
  if (e instanceof pr || (e = Vx(e)), e.a === 0 && e.b === 0)
    return new jr(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
  var t = Math.atan2(e.b, e.a) * Bx;
  return new jr(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function m0(e, t, n, r) {
  return arguments.length === 1 ? OF(e) : new jr(e, t, n, r ?? 1);
}
function jr(e, t, n, r) {
  this.h = +e, this.c = +t, this.l = +n, this.opacity = +r;
}
function Yx(e) {
  if (isNaN(e.h))
    return new pr(e.l, 0, 0, e.opacity);
  var t = e.h * Cx;
  return new pr(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
ga(jr, m0, ru(Wi, {
  brighter(e) {
    return new jr(this.h, this.c, this.l + mf * (e ?? 1), this.opacity);
  },
  darker(e) {
    return new jr(this.h, this.c, this.l - mf * (e ?? 1), this.opacity);
  },
  rgb() {
    return Yx(this).rgb();
  }
}));
var Wx = -0.14861, dm = 1.78277, pm = -0.29227, Ph = -0.90649, Tc = 1.97294, ob = Tc * Ph, ab = Tc * dm, cb = dm * pm - Ph * Wx;
function LF(e) {
  if (e instanceof As)
    return new As(e.h, e.s, e.l, e.opacity);
  e instanceof ge || (e = hm(e));
  var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = (cb * r + ob * t - ab * n) / (cb + ob - ab), s = r - i, o = (Tc * (n - i) - pm * s) / Ph, a = Math.sqrt(o * o + s * s) / (Tc * i * (1 - i)), c = a ? Math.atan2(o, s) * Bx - 120 : NaN;
  return new As(c < 0 ? c + 360 : c, a, i, e.opacity);
}
function br(e, t, n, r) {
  return arguments.length === 1 ? LF(e) : new As(e, t, n, r ?? 1);
}
function As(e, t, n, r) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
ga(As, br, ru(Wi, {
  brighter(e) {
    return e = e == null ? Zo : Math.pow(Zo, e), new As(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Cs : Math.pow(Cs, e), new As(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = isNaN(this.h) ? 0 : (this.h + 120) * Cx, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), r = Math.cos(e), i = Math.sin(e);
    return new ge(
      255 * (t + n * (Wx * r + dm * i)),
      255 * (t + n * (pm * r + Ph * i)),
      255 * (t + n * (Tc * r)),
      this.opacity
    );
  }
}));
function kF(e, t, n, r, i) {
  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) * r + o * i) / 6;
}
function FF(e) {
  var t = e.length - 1;
  return function(n) {
    var r = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), i = e[r], s = e[r + 1], o = r > 0 ? e[r - 1] : 2 * i - s, a = r < t - 1 ? e[r + 2] : 2 * s - i;
    return kF((n - r / t) * t, o, i, s, a);
  };
}
const Uh = (e) => () => e;
function Xx(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function RF(e, t, n) {
  return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function(r) {
    return Math.pow(e + r * t, n);
  };
}
function ym(e, t) {
  var n = t - e;
  return n ? Xx(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : Uh(isNaN(e) ? t : e);
}
function CF(e) {
  return (e = +e) == 1 ? Ee : function(t, n) {
    return n - t ? RF(t, n, e) : Uh(isNaN(t) ? n : t);
  };
}
function Ee(e, t) {
  var n = t - e;
  return n ? Xx(e, n) : Uh(isNaN(e) ? t : e);
}
const Bs = function e(t) {
  var n = CF(t);
  function r(i, s) {
    var o = n((i = Sn(i)).r, (s = Sn(s)).r), a = n(i.g, s.g), c = n(i.b, s.b), u = Ee(i.opacity, s.opacity);
    return function(l) {
      return i.r = o(l), i.g = a(l), i.b = c(l), i.opacity = u(l), i + "";
    };
  }
  return r.gamma = e, r;
}(1);
function BF(e) {
  return function(t) {
    var n = t.length, r = new Array(n), i = new Array(n), s = new Array(n), o, a;
    for (o = 0; o < n; ++o)
      a = Sn(t[o]), r[o] = a.r || 0, i[o] = a.g || 0, s[o] = a.b || 0;
    return r = e(r), i = e(i), s = e(s), a.opacity = 1, function(c) {
      return a.r = r(c), a.g = i(c), a.b = s(c), a + "";
    };
  };
}
var PF = BF(FF);
function UF(e, t) {
  t || (t = []);
  var n = e ? Math.min(t.length, e.length) : 0, r = t.slice(), i;
  return function(s) {
    for (i = 0; i < n; ++i)
      r[i] = e[i] * (1 - s) + t[i] * s;
    return r;
  };
}
function zF(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function jF(e, t) {
  var n = t ? t.length : 0, r = e ? Math.min(n, e.length) : 0, i = new Array(r), s = new Array(n), o;
  for (o = 0; o < r; ++o)
    i[o] = ba(e[o], t[o]);
  for (; o < n; ++o)
    s[o] = t[o];
  return function(a) {
    for (o = 0; o < r; ++o)
      s[o] = i[o](a);
    return s;
  };
}
function qF(e, t) {
  var n = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(r) {
    return n.setTime(e * (1 - r) + t * r), n;
  };
}
function $e(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function VF(e, t) {
  var n = {}, r = {}, i;
  (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
  for (i in t)
    i in e ? n[i] = ba(e[i], t[i]) : r[i] = t[i];
  return function(s) {
    for (i in n)
      r[i] = n[i](s);
    return r;
  };
}
var g0 = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Jd = new RegExp(g0.source, "g");
function YF(e) {
  return function() {
    return e;
  };
}
function WF(e) {
  return function(t) {
    return e(t) + "";
  };
}
function Gx(e, t) {
  var n = g0.lastIndex = Jd.lastIndex = 0, r, i, s, o = -1, a = [], c = [];
  for (e = e + "", t = t + ""; (r = g0.exec(e)) && (i = Jd.exec(t)); )
    (s = i.index) > n && (s = t.slice(n, s), a[o] ? a[o] += s : a[++o] = s), (r = r[0]) === (i = i[0]) ? a[o] ? a[o] += i : a[++o] = i : (a[++o] = null, c.push({ i: o, x: $e(r, i) })), n = Jd.lastIndex;
  return n < t.length && (s = t.slice(n), a[o] ? a[o] += s : a[++o] = s), a.length < 2 ? c[0] ? WF(c[0].x) : YF(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 ba(e, t) {
  var n = typeof t, r;
  return t == null || n === "boolean" ? Uh(t) : (n === "number" ? $e : n === "string" ? (r = Ri(t)) ? (t = r, Bs) : Gx : t instanceof Ri ? Bs : t instanceof Date ? qF : zF(t) ? UF : Array.isArray(t) ? jF : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? VF : $e)(e, t);
}
function mm(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
var ub = 180 / Math.PI, b0 = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function Hx(e, t, n, r, i, s) {
  var o, a, c;
  return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (c = e * n + t * r) && (n -= e * c, r -= t * c), (a = Math.sqrt(n * n + r * r)) && (n /= a, r /= a, c /= a), e * r < t * n && (e = -e, t = -t, c = -c, o = -o), {
    translateX: i,
    translateY: s,
    rotate: Math.atan2(t, e) * ub,
    skewX: Math.atan(c) * ub,
    scaleX: o,
    scaleY: a
  };
}
var qu;
function XF(e) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
  return t.isIdentity ? b0 : Hx(t.a, t.b, t.c, t.d, t.e, t.f);
}
function GF(e) {
  return e == null || (qu || (qu = document.createElementNS("http://www.w3.org/2000/svg", "g")), qu.setAttribute("transform", e), !(e = qu.transform.baseVal.consolidate())) ? b0 : (e = e.matrix, Hx(e.a, e.b, e.c, e.d, e.e, e.f));
}
function Jx(e, t, n, r) {
  function i(u) {
    return u.length ? u.pop() + " " : "";
  }
  function s(u, l, f, h, d, p) {
    if (u !== f || l !== h) {
      var y = d.push("translate(", null, t, null, n);
      p.push({ i: y - 4, x: $e(u, f) }, { i: y - 2, x: $e(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(i(f) + "rotate(", null, r) - 2, x: $e(u, l) })) : l && f.push(i(f) + "rotate(" + l + r);
  }
  function a(u, l, f, h) {
    u !== l ? h.push({ i: f.push(i(f) + "skewX(", null, r) - 2, x: $e(u, l) }) : l && f.push(i(f) + "skewX(" + l + r);
  }
  function c(u, l, f, h, d, p) {
    if (u !== f || l !== h) {
      var y = d.push(i(d) + "scale(", null, ",", null, ")");
      p.push({ i: y - 4, x: $e(u, f) }, { i: y - 2, x: $e(l, h) });
    } else
      (f !== 1 || h !== 1) && d.push(i(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, y = h.length, g; ++p < y; )
        f[(g = h[p]).i] = g.x(d);
      return f.join("");
    };
  };
}
var HF = Jx(XF, "px, ", "px)", "deg)"), JF = Jx(GF, ", ", ")", ")"), ZF = 1e-12;
function lb(e) {
  return ((e = Math.exp(e)) + 1 / e) / 2;
}
function KF(e) {
  return ((e = Math.exp(e)) - 1 / e) / 2;
}
function QF(e) {
  return ((e = Math.exp(2 * e)) - 1) / (e + 1);
}
const tR = function e(t, n, r) {
  function i(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, y = d * d + p * p, g, m;
    if (y < ZF)
      m = Math.log(h / u) / t, g = function(M) {
        return [
          a + M * d,
          c + M * p,
          u * Math.exp(t * M * m)
        ];
      };
    else {
      var b = Math.sqrt(y), w = (h * h - u * u + r * y) / (2 * u * n * b), v = (h * h - u * u - r * y) / (2 * h * n * b), x = Math.log(Math.sqrt(w * w + 1) - w), _ = Math.log(Math.sqrt(v * v + 1) - v);
      m = (_ - x) / t, g = function(M) {
        var T = M * m, N = lb(x), A = u / (n * b) * (N * QF(t * T + x) - KF(x));
        return [
          a + A * d,
          c + A * p,
          u * N / lb(t * T + x)
        ];
      };
    }
    return g.duration = m * 1e3 * t / Math.SQRT2, g;
  }
  return i.rho = function(s) {
    var o = Math.max(1e-3, +s), a = o * o, c = a * a;
    return e(o, a, c);
  }, i;
}(Math.SQRT2, 2, 4);
function eR(e) {
  return function(t, n) {
    var r = e((t = p0(t)).h, (n = p0(n)).h), i = Ee(t.s, n.s), s = Ee(t.l, n.l), o = Ee(t.opacity, n.opacity);
    return function(a) {
      return t.h = r(a), t.s = i(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const nR = eR(ym);
function rR(e, t) {
  var n = Ee((e = y0(e)).l, (t = y0(t)).l), r = Ee(e.a, t.a), i = Ee(e.b, t.b), s = Ee(e.opacity, t.opacity);
  return function(o) {
    return e.l = n(o), e.a = r(o), e.b = i(o), e.opacity = s(o), e + "";
  };
}
function iR(e) {
  return function(t, n) {
    var r = e((t = m0(t)).h, (n = m0(n)).h), i = Ee(t.c, n.c), s = Ee(t.l, n.l), o = Ee(t.opacity, n.opacity);
    return function(a) {
      return t.h = r(a), t.c = i(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const sR = iR(ym);
function Zx(e) {
  return function t(n) {
    n = +n;
    function r(i, s) {
      var o = e((i = br(i)).h, (s = br(s)).h), a = Ee(i.s, s.s), c = Ee(i.l, s.l), u = Ee(i.opacity, s.opacity);
      return function(l) {
        return i.h = o(l), i.s = a(l), i.l = c(Math.pow(l, n)), i.opacity = u(l), i + "";
      };
    }
    return r.gamma = t, r;
  }(1);
}
Zx(ym);
var gm = Zx(Ee);
function zh(e, t) {
  t === void 0 && (t = e, e = ba);
  for (var n = 0, r = t.length - 1, i = t[0], s = new Array(r < 0 ? 0 : r); n < r; )
    s[n] = e(i, i = t[++n]);
  return function(o) {
    var a = Math.max(0, Math.min(r - 1, Math.floor(o *= r)));
    return s[a](o - a);
  };
}
function Pn(e, t) {
  for (var n = new Array(t), r = 0; r < t; ++r)
    n[r] = e(r / (t - 1));
  return n;
}
var Ko = 0, Xa = 0, Fa = 0, Kx = 1e3, gf, Ga, bf = 0, Ps = 0, jh = 0, Ec = typeof performance == "object" && performance.now ? performance : Date, Qx = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
  setTimeout(e, 17);
};
function bm() {
  return Ps || (Qx(oR), Ps = Ec.now() + jh);
}
function oR() {
  Ps = 0;
}
function wf() {
  this._call = this._time = this._next = null;
}
wf.prototype = tS.prototype = {
  constructor: wf,
  restart: function(e, t, n) {
    if (typeof e != "function")
      throw new TypeError("callback is not a function");
    n = (n == null ? bm() : +n) + (t == null ? 0 : +t), !this._next && Ga !== this && (Ga ? Ga._next = this : gf = this, Ga = this), this._call = e, this._time = n, w0();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, w0());
  }
};
function tS(e, t, n) {
  var r = new wf();
  return r.restart(e, t, n), r;
}
function aR() {
  bm(), ++Ko;
  for (var e = gf, t; e; )
    (t = Ps - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
  --Ko;
}
function fb() {
  Ps = (bf = Ec.now()) + jh, Ko = Xa = 0;
  try {
    aR();
  } finally {
    Ko = 0, uR(), Ps = 0;
  }
}
function cR() {
  var e = Ec.now(), t = e - bf;
  t > Kx && (jh -= t, bf = e);
}
function uR() {
  for (var e, t = gf, n, r = 1 / 0; t; )
    t._call ? (r > t._time && (r = t._time), e = t, t = t._next) : (n = t._next, t._next = null, t = e ? e._next = n : gf = n);
  Ga = e, w0(r);
}
function w0(e) {
  if (!Ko) {
    Xa && (Xa = clearTimeout(Xa));
    var t = e - Ps;
    t > 24 ? (e < 1 / 0 && (Xa = setTimeout(fb, e - Ec.now() - jh)), Fa && (Fa = clearInterval(Fa))) : (Fa || (bf = Ec.now(), Fa = setInterval(cR, Kx)), Ko = 1, Qx(fb));
  }
}
function hb(e, t, n) {
  var r = new wf();
  return t = t == null ? 0 : +t, r.restart((i) => {
    r.stop(), e(i + t);
  }, t, n), r;
}
var lR = Rh("start", "end", "cancel", "interrupt"), fR = [], eS = 0, db = 1, v0 = 2, Ml = 3, pb = 4, _0 = 5, Al = 6;
function qh(e, t, n, r, i, s) {
  var o = e.__transition;
  if (!o)
    e.__transition = {};
  else if (n in o)
    return;
  hR(e, n, {
    name: t,
    index: r,
    // For context during callback.
    group: i,
    // For context during callback.
    on: lR,
    tween: fR,
    time: s.time,
    delay: s.delay,
    duration: s.duration,
    ease: s.ease,
    timer: null,
    state: eS
  });
}
function wm(e, t) {
  var n = Yn(e, t);
  if (n.state > eS)
    throw new Error("too late; already scheduled");
  return n;
}
function _r(e, t) {
  var n = Yn(e, t);
  if (n.state > Ml)
    throw new Error("too late; already running");
  return n;
}
function Yn(e, t) {
  var n = e.__transition;
  if (!n || !(n = n[t]))
    throw new Error("transition not found");
  return n;
}
function hR(e, t, n) {
  var r = e.__transition, i;
  r[t] = n, n.timer = tS(s, 0, n.time);
  function s(u) {
    n.state = db, 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 !== db)
      return c();
    for (l in r)
      if (d = r[l], d.name === n.name) {
        if (d.state === Ml)
          return hb(o);
        d.state === pb ? (d.state = Al, d.timer.stop(), d.on.call("interrupt", e, e.__data__, d.index, d.group), delete r[l]) : +l < t && (d.state = Al, d.timer.stop(), d.on.call("cancel", e, e.__data__, d.index, d.group), delete r[l]);
      }
    if (hb(function() {
      n.state === Ml && (n.state = pb, n.timer.restart(a, n.delay, n.time), a(u));
    }), n.state = v0, n.on.call("start", e, e.__data__, n.index, n.group), n.state === v0) {
      for (n.state = Ml, i = 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)) && (i[++f] = d);
      i.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 = _0, 1), f = -1, h = i.length; ++f < h; )
      i[f].call(e, l);
    n.state === _0 && (n.on.call("end", e, e.__data__, n.index, n.group), c());
  }
  function c() {
    n.state = Al, n.timer.stop(), delete r[t];
    for (var u in r)
      return;
    delete e.__transition;
  }
}
function ko(e, t) {
  var n = e.__transition, r, i, s = !0, o;
  if (n) {
    t = t == null ? null : t + "";
    for (o in n) {
      if ((r = n[o]).name !== t) {
        s = !1;
        continue;
      }
      i = r.state > v0 && r.state < _0, r.state = Al, r.timer.stop(), r.on.call(i ? "interrupt" : "cancel", e, e.__data__, r.index, r.group), delete n[o];
    }
    s && delete e.__transition;
  }
}
function dR(e) {
  return this.each(function() {
    ko(this, e);
  });
}
function pR(e, t) {
  var n, r;
  return function() {
    var i = _r(this, e), s = i.tween;
    if (s !== n) {
      r = n = s;
      for (var o = 0, a = r.length; o < a; ++o)
        if (r[o].name === t) {
          r = r.slice(), r.splice(o, 1);
          break;
        }
    }
    i.tween = r;
  };
}
function yR(e, t, n) {
  var r, i;
  if (typeof n != "function")
    throw new Error();
  return function() {
    var s = _r(this, e), o = s.tween;
    if (o !== r) {
      i = (r = o).slice();
      for (var a = { name: t, value: n }, c = 0, u = i.length; c < u; ++c)
        if (i[c].name === t) {
          i[c] = a;
          break;
        }
      c === u && i.push(a);
    }
    s.tween = i;
  };
}
function mR(e, t) {
  var n = this._id;
  if (e += "", arguments.length < 2) {
    for (var r = Yn(this.node(), n).tween, i = 0, s = r.length, o; i < s; ++i)
      if ((o = r[i]).name === e)
        return o.value;
    return null;
  }
  return this.each((t == null ? pR : yR)(n, e, t));
}
function vm(e, t, n) {
  var r = e._id;
  return e.each(function() {
    var i = _r(this, r);
    (i.value || (i.value = {}))[t] = n.apply(this, arguments);
  }), function(i) {
    return Yn(i, r).value[t];
  };
}
function nS(e, t) {
  var n;
  return (typeof t == "number" ? $e : t instanceof Ri ? Bs : (n = Ri(t)) ? (t = n, Bs) : Gx)(e, t);
}
function gR(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function bR(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function wR(e, t, n) {
  var r, i = n + "", s;
  return function() {
    var o = this.getAttribute(e);
    return o === i ? null : o === r ? s : s = t(r = o, n);
  };
}
function vR(e, t, n) {
  var r, i = n + "", s;
  return function() {
    var o = this.getAttributeNS(e.space, e.local);
    return o === i ? null : o === r ? s : s = t(r = o, n);
  };
}
function _R(e, t, n) {
  var r, i, 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 === r && c === i ? s : (i = c, s = t(r = o, a)));
  };
}
function xR(e, t, n) {
  var r, i, 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 === r && c === i ? s : (i = c, s = t(r = o, a)));
  };
}
function SR(e, t) {
  var n = Ch(e), r = n === "transform" ? JF : nS;
  return this.attrTween(e, typeof t == "function" ? (n.local ? xR : _R)(n, r, vm(this, "attr." + e, t)) : t == null ? (n.local ? bR : gR)(n) : (n.local ? vR : wR)(n, r, t));
}
function MR(e, t) {
  return function(n) {
    this.setAttribute(e, t.call(this, n));
  };
}
function AR(e, t) {
  return function(n) {
    this.setAttributeNS(e.space, e.local, t.call(this, n));
  };
}
function $R(e, t) {
  var n, r;
  function i() {
    var s = t.apply(this, arguments);
    return s !== r && (n = (r = s) && AR(e, s)), n;
  }
  return i._value = t, i;
}
function IR(e, t) {
  var n, r;
  function i() {
    var s = t.apply(this, arguments);
    return s !== r && (n = (r = s) && MR(e, s)), n;
  }
  return i._value = t, i;
}
function TR(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 r = Ch(e);
  return this.tween(n, (r.local ? $R : IR)(r, t));
}
function ER(e, t) {
  return function() {
    wm(this, e).delay = +t.apply(this, arguments);
  };
}
function NR(e, t) {
  return t = +t, function() {
    wm(this, e).delay = t;
  };
}
function DR(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? ER : NR)(t, e)) : Yn(this.node(), t).delay;
}
function OR(e, t) {
  return function() {
    _r(this, e).duration = +t.apply(this, arguments);
  };
}
function LR(e, t) {
  return t = +t, function() {
    _r(this, e).duration = t;
  };
}
function kR(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? OR : LR)(t, e)) : Yn(this.node(), t).duration;
}
function FR(e, t) {
  if (typeof t != "function")
    throw new Error();
  return function() {
    _r(this, e).ease = t;
  };
}
function RR(e) {
  var t = this._id;
  return arguments.length ? this.each(FR(t, e)) : Yn(this.node(), t).ease;
}
function CR(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    if (typeof n != "function")
      throw new Error();
    _r(this, e).ease = n;
  };
}
function BR(e) {
  if (typeof e != "function")
    throw new Error();
  return this.each(CR(this._id, e));
}
function PR(e) {
  typeof e != "function" && (e = Mx(e));
  for (var t = this._groups, n = t.length, r = new Array(n), i = 0; i < n; ++i)
    for (var s = t[i], o = s.length, a = r[i] = [], c, u = 0; u < o; ++u)
      (c = s[u]) && e.call(c, c.__data__, u, s) && a.push(c);
  return new Qr(r, this._parents, this._name, this._id);
}
function UR(e) {
  if (e._id !== this._id)
    throw new Error();
  for (var t = this._groups, n = e._groups, r = t.length, i = n.length, s = Math.min(r, i), o = new Array(r), 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 < r; ++a)
    o[a] = t[a];
  return new Qr(o, this._parents, this._name, this._id);
}
function zR(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 jR(e, t, n) {
  var r, i, s = zR(t) ? wm : _r;
  return function() {
    var o = s(this, e), a = o.on;
    a !== r && (i = (r = a).copy()).on(t, n), o.on = i;
  };
}
function qR(e, t) {
  var n = this._id;
  return arguments.length < 2 ? Yn(this.node(), n).on.on(e) : this.each(jR(n, e, t));
}
function VR(e) {
  return function() {
    var t = this.parentNode;
    for (var n in this.__transition)
      if (+n !== e)
        return;
    t && t.removeChild(this);
  };
}
function YR() {
  return this.on("end.remove", VR(this._id));
}
function WR(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = lm(e));
  for (var r = this._groups, i = r.length, s = new Array(i), o = 0; o < i; ++o)
    for (var a = r[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, qh(u[h], t, n, h, u, Yn(l, n)));
  return new Qr(s, this._parents, t, n);
}
function XR(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = Sx(e));
  for (var r = this._groups, i = r.length, s = [], o = [], a = 0; a < i; ++a)
    for (var c = r[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 = Yn(l, n), y = 0, g = h.length; y < g; ++y)
          (d = h[y]) && qh(d, t, n, y, h, p);
        s.push(h), o.push(l);
      }
  return new Qr(s, o, t, n);
}
var GR = nu.prototype.constructor;
function HR() {
  return new GR(this._groups, this._parents);
}
function JR(e, t) {
  var n, r, i;
  return function() {
    var s = Jo(this, e), o = (this.style.removeProperty(e), Jo(this, e));
    return s === o ? null : s === n && o === r ? i : i = t(n = s, r = o);
  };
}
function rS(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function ZR(e, t, n) {
  var r, i = n + "", s;
  return function() {
    var o = Jo(this, e);
    return o === i ? null : o === r ? s : s = t(r = o, n);
  };
}
function KR(e, t, n) {
  var r, i, s;
  return function() {
    var o = Jo(this, e), a = n(this), c = a + "";
    return a == null && (c = a = (this.style.removeProperty(e), Jo(this, e))), o === c ? null : o === r && c === i ? s : (i = c, s = t(r = o, a));
  };
}
function QR(e, t) {
  var n, r, i, s = "style." + t, o = "end." + s, a;
  return function() {
    var c = _r(this, e), u = c.on, l = c.value[s] == null ? a || (a = rS(t)) : void 0;
    (u !== n || i !== l) && (r = (n = u).copy()).on(o, i = l), c.on = r;
  };
}
function tC(e, t, n) {
  var r = (e += "") == "transform" ? HF : nS;
  return t == null ? this.styleTween(e, JR(e, r)).on("end.style." + e, rS(e)) : typeof t == "function" ? this.styleTween(e, KR(e, r, vm(this, "style." + e, t))).each(QR(this._id, e)) : this.styleTween(e, ZR(e, r, t), n).on("end.style." + e, null);
}
function eC(e, t, n) {
  return function(r) {
    this.style.setProperty(e, t.call(this, r), n);
  };
}
function nC(e, t, n) {
  var r, i;
  function s() {
    var o = t.apply(this, arguments);
    return o !== i && (r = (i = o) && eC(e, o, n)), r;
  }
  return s._value = t, s;
}
function rC(e, t, n) {
  var r = "style." + (e += "");
  if (arguments.length < 2)
    return (r = this.tween(r)) && r._value;
  if (t == null)
    return this.tween(r, null);
  if (typeof t != "function")
    throw new Error();
  return this.tween(r, nC(e, t, n ?? ""));
}
function iC(e) {
  return function() {
    this.textContent = e;
  };
}
function sC(e) {
  return function() {
    var t = e(this);
    this.textContent = t ?? "";
  };
}
function oC(e) {
  return this.tween("text", typeof e == "function" ? sC(vm(this, "text", e)) : iC(e == null ? "" : e + ""));
}
function aC(e) {
  return function(t) {
    this.textContent = e.call(this, t);
  };
}
function cC(e) {
  var t, n;
  function r() {
    var i = e.apply(this, arguments);
    return i !== n && (t = (n = i) && aC(i)), t;
  }
  return r._value = e, r;
}
function uC(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, cC(e));
}
function lC() {
  for (var e = this._name, t = this._id, n = iS(), r = this._groups, i = r.length, s = 0; s < i; ++s)
    for (var o = r[s], a = o.length, c, u = 0; u < a; ++u)
      if (c = o[u]) {
        var l = Yn(c, t);
        qh(c, e, n, u, o, {
          time: l.time + l.delay + l.duration,
          delay: 0,
          duration: l.duration,
          ease: l.ease
        });
      }
  return new Qr(r, this._parents, e, n);
}
function fC() {
  var e, t, n = this, r = n._id, i = n.size();
  return new Promise(function(s, o) {
    var a = { value: o }, c = { value: function() {
      --i === 0 && s();
    } };
    n.each(function() {
      var u = _r(this, r), l = u.on;
      l !== e && (t = (e = l).copy(), t._.cancel.push(a), t._.interrupt.push(a), t._.end.push(c)), u.on = t;
    }), i === 0 && s();
  });
}
var hC = 0;
function Qr(e, t, n, r) {
  this._groups = e, this._parents = t, this._name = n, this._id = r;
}
function iS() {
  return ++hC;
}
var $r = nu.prototype;
Qr.prototype = {
  constructor: Qr,
  select: WR,
  selectAll: XR,
  selectChild: $r.selectChild,
  selectChildren: $r.selectChildren,
  filter: PR,
  merge: UR,
  selection: HR,
  transition: lC,
  call: $r.call,
  nodes: $r.nodes,
  node: $r.node,
  size: $r.size,
  empty: $r.empty,
  each: $r.each,
  on: qR,
  attr: SR,
  attrTween: TR,
  style: tC,
  styleTween: rC,
  text: oC,
  textTween: uC,
  remove: YR,
  tween: mR,
  delay: DR,
  duration: kR,
  ease: RR,
  easeVarying: BR,
  end: fC,
  [Symbol.iterator]: $r[Symbol.iterator]
};
function dC(e) {
  return ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2;
}
var pC = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: dC
};
function yC(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 mC(e) {
  var t, n;
  e instanceof Qr ? (t = e._id, e = e._name) : (t = iS(), (n = pC).time = bm(), e = e == null ? null : e + "");
  for (var r = this._groups, i = r.length, s = 0; s < i; ++s)
    for (var o = r[s], a = o.length, c, u = 0; u < a; ++u)
      (c = o[u]) && qh(c, e, t, u, o, n || yC(c, t));
  return new Qr(r, this._parents, e, t);
}
nu.prototype.interrupt = dR;
nu.prototype.transition = mC;
const Zd = (e) => () => e;
function gC(e, {
  sourceEvent: t,
  target: n,
  selection: r,
  mode: i,
  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: r, enumerable: !0, configurable: !0 },
    mode: { value: i, enumerable: !0, configurable: !0 },
    _: { value: s }
  });
}
function bC(e) {
  e.stopImmediatePropagation();
}
function Kd(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
var yb = { name: "drag" }, Qd = { name: "space" }, no = { name: "handle" }, ro = { name: "center" };
const { abs: mb, max: Se, min: Me } = Math;
function gb(e) {
  return [+e[0], +e[1]];
}
function x0(e) {
  return [gb(e[0]), gb(e[1])];
}
var $l = {
  name: "x",
  handles: ["w", "e"].map(Nc),
  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]];
  }
}, Il = {
  name: "y",
  handles: ["n", "s"].map(Nc),
  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]];
  }
}, wC = {
  name: "xy",
  handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(Nc),
  input: function(e) {
    return e == null ? null : x0(e);
  },
  output: function(e) {
    return e;
  }
}, Ir = {
  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"
}, bb = {
  e: "w",
  w: "e",
  nw: "ne",
  ne: "nw",
  se: "sw",
  sw: "se"
}, wb = {
  n: "s",
  s: "n",
  nw: "sw",
  ne: "se",
  se: "ne",
  sw: "nw"
}, vC = {
  overlay: 1,
  selection: 1,
  n: null,
  e: 1,
  s: null,
  w: -1,
  nw: -1,
  ne: 1,
  se: 1,
  sw: -1
}, _C = {
  overlay: 1,
  selection: 1,
  n: -1,
  e: null,
  s: 1,
  w: null,
  nw: -1,
  ne: -1,
  se: 1,
  sw: 1
};
function Nc(e) {
  return { type: e };
}
function xC(e) {
  return !e.ctrlKey && !e.button;
}
function SC() {
  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 MC() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function tp(e) {
  for (; !e.__brush; )
    if (!(e = e.parentNode))
      return;
  return e.__brush;
}
function AC(e) {
  return e[0][0] === e[1][0] || e[0][1] === e[1][1];
}
function $C() {
  return _m($l);
}
function IC() {
  return _m(Il);
}
function TC() {
  return _m(wC);
}
function _m(e) {
  var t = SC, n = xC, r = MC, i = !0, s = Rh("start", "brush", "end"), o = 6, a;
  function c(g) {
    var m = g.property("__brush", y).selectAll(".overlay").data([Nc("overlay")]);
    m.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", Ir.overlay).merge(m).each(function() {
      var w = tp(this).extent;
      Vt(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]);
    }), g.selectAll(".selection").data([Nc("selection")]).enter().append("rect").attr("class", "selection").attr("cursor", Ir.selection).attr("fill", "#777").attr("fill-opacity", 0.3).attr("stroke", "#fff").attr("shape-rendering", "crispEdges");
    var b = g.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 Ir[w.type];
    }), g.each(u).attr("fill", "none").attr("pointer-events", "all").on("mousedown.brush", h).filter(r).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(g, m, b) {
    g.tween ? g.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, v = w.__brush, x = l(w, arguments), _ = v.selection, M = e.input(typeof m == "function" ? m.apply(this, arguments) : m, v.extent), T = ba(_, M);
      function N(A) {
        v.selection = A === 1 && M === null ? null : T(A), u.call(w), x.brush();
      }
      return _ !== null && M !== null ? N : N(1);
    }) : g.each(function() {
      var w = this, v = arguments, x = w.__brush, _ = e.input(typeof m == "function" ? m.apply(w, v) : m, x.extent), M = l(w, v).beforestart();
      ko(w), x.selection = _ === null ? null : _, u.call(w), M.start(b).brush(b).end(b);
    });
  }, c.clear = function(g, m) {
    c.move(g, null, m);
  };
  function u() {
    var g = Vt(this), m = tp(this).selection;
    m ? (g.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]), g.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;
    })) : g.selectAll(".selection,.handle").style("display", "none").attr("x", null).attr("y", null).attr("width", null).attr("height", null);
  }
  function l(g, m, b) {
    var w = g.__brush.emitter;
    return w && (!b || !w.clean) ? w : new f(g, m, b);
  }
  function f(g, m, b) {
    this.that = g, this.args = m, this.state = g.__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(g, m) {
      return this.starting ? (this.starting = !1, this.emit("start", g, m)) : this.emit("brush", g), this;
    },
    brush: function(g, m) {
      return this.emit("brush", g, m), this;
    },
    end: function(g, m) {
      return --this.active === 0 && (delete this.state.emitter, this.emit("end", g, m)), this;
    },
    emit: function(g, m, b) {
      var w = Vt(this.that).datum();
      s.call(
        g,
        this.that,
        new gC(g, {
          sourceEvent: m,
          target: c,
          selection: e.output(this.state.selection),
          mode: b,
          dispatch: s
        }),
        w
      );
    }
  };
  function h(g) {
    if (a && !g.touches || !n.apply(this, arguments))
      return;
    var m = this, b = g.target.__data__.type, w = (i && g.metaKey ? b = "overlay" : b) === "selection" ? yb : i && g.altKey ? ro : no, v = e === Il ? null : vC[b], x = e === $l ? null : _C[b], _ = tp(m), M = _.extent, T = _.selection, N = M[0][0], A, $, D = M[0][1], F, S, I = M[1][0], E, O, C = M[1][1], B, R, P = 0, U = 0, Y, G = v && x && i && g.shiftKey, Z, H, q = Array.from(g.touches || [g], (J) => {
      const kt = J.identifier;
      return J = En(J, m), J.point0 = J.slice(), J.identifier = kt, J;
    });
    ko(m);
    var W = l(m, arguments, !0).beforestart();
    if (b === "overlay") {
      T && (Y = !0);
      const J = [q[0], q[1] || q[0]];
      _.selection = T = [[
        A = e === Il ? N : Me(J[0][0], J[1][0]),
        F = e === $l ? D : Me(J[0][1], J[1][1])
      ], [
        E = e === Il ? I : Se(J[0][0], J[1][0]),
        B = e === $l ? C : Se(J[0][1], J[1][1])
      ]], q.length > 1 && wt(g);
    } else
      A = T[0][0], F = T[0][1], E = T[1][0], B = T[1][1];
    $ = A, S = F, O = E, R = B;
    var j = Vt(m).attr("pointer-events", "none"), X = j.selectAll(".overlay").attr("cursor", Ir[b]);
    if (g.touches)
      W.moved = z, W.ended = Q;
    else {
      var K = Vt(g.view).on("mousemove.brush", z, !0).on("mouseup.brush", Q, !0);
      i && K.on("keydown.brush", It, !0).on("keyup.brush", Tt, !0), kx(g.view);
    }
    u.call(m), W.start(g, w.name);
    function z(J) {
      for (const kt of J.changedTouches || [J])
        for (const Qe of q)
          Qe.identifier === kt.identifier && (Qe.cur = En(kt, m));
      if (G && !Z && !H && q.length === 1) {
        const kt = q[0];
        mb(kt.cur[0] - kt[0]) > mb(kt.cur[1] - kt[1]) ? H = !0 : Z = !0;
      }
      for (const kt of q)
        kt.cur && (kt[0] = kt.cur[0], kt[1] = kt.cur[1]);
      Y = !0, Kd(J), wt(J);
    }
    function wt(J) {
      const kt = q[0], Qe = kt.point0;
      var Xn;
      switch (P = kt[0] - Qe[0], U = kt[1] - Qe[1], w) {
        case Qd:
        case yb: {
          v && (P = Se(N - A, Me(I - E, P)), $ = A + P, O = E + P), x && (U = Se(D - F, Me(C - B, U)), S = F + U, R = B + U);
          break;
        }
        case no: {
          q[1] ? (v && ($ = Se(N, Me(I, q[0][0])), O = Se(N, Me(I, q[1][0])), v = 1), x && (S = Se(D, Me(C, q[0][1])), R = Se(D, Me(C, q[1][1])), x = 1)) : (v < 0 ? (P = Se(N - A, Me(I - A, P)), $ = A + P, O = E) : v > 0 && (P = Se(N - E, Me(I - E, P)), $ = A, O = E + P), x < 0 ? (U = Se(D - F, Me(C - F, U)), S = F + U, R = B) : x > 0 && (U = Se(D - B, Me(C - B, U)), S = F, R = B + U));
          break;
        }
        case ro: {
          v && ($ = Se(N, Me(I, A - P * v)), O = Se(N, Me(I, E + P * v))), x && (S = Se(D, Me(C, F - U * x)), R = Se(D, Me(C, B + U * x)));
          break;
        }
      }
      O < $ && (v *= -1, Xn = A, A = E, E = Xn, Xn = $, $ = O, O = Xn, b in bb && X.attr("cursor", Ir[b = bb[b]])), R < S && (x *= -1, Xn = F, F = B, B = Xn, Xn = S, S = R, R = Xn, b in wb && X.attr("cursor", Ir[b = wb[b]])), _.selection && (T = _.selection), Z && ($ = T[0][0], O = T[1][0]), H && (S = T[0][1], R = T[1][1]), (T[0][0] !== $ || T[0][1] !== S || T[1][0] !== O || T[1][1] !== R) && (_.selection = [[$, S], [O, R]], u.call(m), W.brush(J, w.name));
    }
    function Q(J) {
      if (bC(J), J.touches) {
        if (J.touches.length)
          return;
        a && clearTimeout(a), a = setTimeout(function() {
          a = null;
        }, 500);
      } else
        Fx(J.view, Y), K.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
      j.attr("pointer-events", "all"), X.attr("cursor", Ir.overlay), _.selection && (T = _.selection), AC(T) && (_.selection = null, u.call(m)), W.end(J, w.name);
    }
    function It(J) {
      switch (J.keyCode) {
        case 16: {
          G = v && x;
          break;
        }
        case 18: {
          w === no && (v && (E = O - P * v, A = $ + P * v), x && (B = R - U * x, F = S + U * x), w = ro, wt(J));
          break;
        }
        case 32: {
          (w === no || w === ro) && (v < 0 ? E = O - P : v > 0 && (A = $ - P), x < 0 ? B = R - U : x > 0 && (F = S - U), w = Qd, X.attr("cursor", Ir.selection), wt(J));
          break;
        }
        default:
          return;
      }
      Kd(J);
    }
    function Tt(J) {
      switch (J.keyCode) {
        case 16: {
          G && (Z = H = G = !1, wt(J));
          break;
        }
        case 18: {
          w === ro && (v < 0 ? E = O : v > 0 && (A = $), x < 0 ? B = R : x > 0 && (F = S), w = no, wt(J));
          break;
        }
        case 32: {
          w === Qd && (J.altKey ? (v && (E = O - P * v, A = $ + P * v), x && (B = R - U * x, F = S + U * x), w = ro) : (v < 0 ? E = O : v > 0 && (A = $), x < 0 ? B = R : x > 0 && (F = S), w = no), X.attr("cursor", Ir[b]), wt(J));
          break;
        }
        default:
          return;
      }
      Kd(J);
    }
  }
  function d(g) {
    l(this, arguments).moved(g);
  }
  function p(g) {
    l(this, arguments).ended(g);
  }
  function y() {
    var g = this.__brush || { selection: null };
    return g.extent = x0(t.apply(this, arguments)), g.dim = e, g;
  }
  return c.extent = function(g) {
    return arguments.length ? (t = typeof g == "function" ? g : Zd(x0(g)), c) : t;
  }, c.filter = function(g) {
    return arguments.length ? (n = typeof g == "function" ? g : Zd(!!g), c) : n;
  }, c.touchable = function(g) {
    return arguments.length ? (r = typeof g == "function" ? g : Zd(!!g), c) : r;
  }, c.handleSize = function(g) {
    return arguments.length ? (o = +g, c) : o;
  }, c.keyModifiers = function(g) {
    return arguments.length ? (i = !!g, c) : i;
  }, c.on = function() {
    var g = s.on.apply(s, arguments);
    return g === s ? c : g;
  }, c;
}
const S0 = Math.PI, M0 = 2 * S0, as = 1e-6, EC = M0 - as;
function sS(e) {
  this._ += e[0];
  for (let t = 1, n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function NC(e) {
  let t = Math.floor(e);
  if (!(t >= 0))
    throw new Error(`invalid digits: ${e}`);
  if (t > 15)
    return sS;
  const n = 10 ** t;
  return function(r) {
    this._ += r[0];
    for (let i = 1, s = r.length; i < s; ++i)
      this._ += Math.round(arguments[i] * n) / n + r[i];
  };
}
let oS = class {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? sS : NC(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, r, i) {
    this._append`Q${+t},${+n},${this._x1 = +r},${this._y1 = +i}`;
  }
  bezierCurveTo(t, n, r, i, s, o) {
    this._append`C${+t},${+n},${+r},${+i},${this._x1 = +s},${this._y1 = +o}`;
  }
  arcTo(t, n, r, i, s) {
    if (t = +t, n = +n, r = +r, i = +i, s = +s, s < 0)
      throw new Error(`negative radius: ${s}`);
    let o = this._x1, a = this._y1, c = r - t, u = i - 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 > as)
      if (!(Math.abs(f * c - u * l) > as) || !s)
        this._append`L${this._x1 = t},${this._y1 = n}`;
      else {
        let d = r - o, p = i - a, y = c * c + u * u, g = d * d + p * p, m = Math.sqrt(y), b = Math.sqrt(h), w = s * Math.tan((S0 - Math.acos((y + h - g) / (2 * m * b))) / 2), v = w / b, x = w / m;
        Math.abs(v - 1) > as && this._append`L${t + v * l},${n + v * 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, r, i, s, o) {
    if (t = +t, n = +n, r = +r, o = !!o, r < 0)
      throw new Error(`negative radius: ${r}`);
    let a = r * Math.cos(i), c = r * Math.sin(i), u = t + a, l = n + c, f = 1 ^ o, h = o ? i - s : s - i;
    this._x1 === null ? this._append`M${u},${l}` : (Math.abs(this._x1 - u) > as || Math.abs(this._y1 - l) > as) && this._append`L${u},${l}`, r && (h < 0 && (h = h % M0 + M0), h > EC ? this._append`A${r},${r},0,1,${f},${t - a},${n - c}A${r},${r},0,1,${f},${this._x1 = u},${this._y1 = l}` : h > as && this._append`A${r},${r},0,${+(h >= S0)},${f},${this._x1 = t + r * Math.cos(s)},${this._y1 = n + r * Math.sin(s)}`);
  }
  rect(t, n, r, i) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${r = +r}v${+i}h${-r}Z`;
  }
  toString() {
    return this._;
  }
};
function qr(e = 3) {
  return new oS(+e);
}
var DC = Array.prototype, aS = DC.slice;
function OC(e, t) {
  return e - t;
}
function LC(e) {
  for (var t = 0, n = e.length, r = e[n - 1][1] * e[0][0] - e[n - 1][0] * e[0][1]; ++t < n; )
    r += e[t - 1][1] * e[t][0] - e[t - 1][0] * e[t][1];
  return r;
}
const mi = (e) => () => e;
function kC(e, t) {
  for (var n = -1, r = t.length, i; ++n < r; )
    if (i = FC(e, t[n]))
      return i;
  return 0;
}
function FC(e, t) {
  for (var n = t[0], r = t[1], i = -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 (RC(c, f, t))
      return 0;
    l > r != d > r && n < (h - u) * (r - l) / (d - l) + u && (i = -i);
  }
  return i;
}
function RC(e, t, n) {
  var r;
  return CC(e, t, n) && BC(e[r = +(e[0] === t[0])], n[r], t[r]);
}
function CC(e, t, n) {
  return (t[0] - e[0]) * (n[1] - e[1]) === (n[0] - e[0]) * (t[1] - e[1]);
}
function BC(e, t, n) {
  return e <= t && t <= n || n <= t && t <= e;
}
function PC() {
}
var Tr = [
  [],
  [[[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 vf() {
  var e = 1, t = 1, n = cm, r = c;
  function i(u) {
    var l = n(u);
    if (Array.isArray(l))
      l = l.slice().sort(OC);
    else {
      const f = fe(u, UC);
      for (l = ki(...gx(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) {
      r(p, u, f), LC(p) > 0 ? h.push([p]) : d.push(p);
    }), d.forEach(function(p) {
      for (var y = 0, g = h.length, m; y < g; ++y)
        if (kC((m = h[y])[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, y, g, m, b, w;
    for (p = y = -1, m = is(u[0], l), Tr[m << 1].forEach(v); ++p < e - 1; )
      g = m, m = is(u[p + 1], l), Tr[g | m << 1].forEach(v);
    for (Tr[m << 0].forEach(v); ++y < t - 1; ) {
      for (p = -1, m = is(u[y * e + e], l), b = is(u[y * e], l), Tr[m << 1 | b << 2].forEach(v); ++p < e - 1; )
        g = m, m = is(u[y * e + e + p + 1], l), w = b, b = is(u[y * e + p + 1], l), Tr[g | m << 1 | b << 2 | w << 3].forEach(v);
      Tr[m | b << 3].forEach(v);
    }
    for (p = -1, b = u[y * e] >= l, Tr[b << 2].forEach(v); ++p < e - 1; )
      w = b, b = is(u[y * e + p + 1], l), Tr[b << 2 | w << 3].forEach(v);
    Tr[b << 3].forEach(v);
    function v(x) {
      var _ = [x[0][0] + p, x[0][1] + y], M = [x[1][0] + p, x[1][1] + y], T = a(_), N = a(M), A, $;
      (A = d[T]) ? ($ = h[N]) ? (delete d[A.end], delete h[$.start], A === $ ? (A.ring.push(M), f(A.ring)) : h[A.start] = d[$.end] = { start: A.start, end: $.end, ring: A.ring.concat($.ring) }) : (delete d[A.end], A.ring.push(M), d[A.end = N] = A) : (A = h[N]) ? ($ = d[T]) ? (delete h[A.start], delete d[$.end], A === $ ? (A.ring.push(M), f(A.ring)) : h[$.start] = d[A.end] = { start: $.start, end: A.end, ring: $.ring.concat(A.ring) }) : (delete h[A.start], A.ring.unshift(_), h[A.start = T] = A) : h[T] = d[N] = { start: T, end: N, ring: [_, M] };
    }
  }
  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], y = d | 0, g = p | 0, m = ep(l[g * e + y]);
      d > 0 && d < e && y === d && (h[0] = vb(d, ep(l[g * e + y - 1]), m, f)), p > 0 && p < t && g === p && (h[1] = vb(p, ep(l[(g - 1) * e + y]), m, f));
    });
  }
  return i.contour = s, i.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, i;
  }, i.thresholds = function(u) {
    return arguments.length ? (n = typeof u == "function" ? u : Array.isArray(u) ? mi(aS.call(u)) : mi(u), i) : n;
  }, i.smooth = function(u) {
    return arguments.length ? (r = u ? c : PC, i) : r === c;
  }, i;
}
function UC(e) {
  return isFinite(e) ? e : NaN;
}
function is(e, t) {
  return e == null ? !1 : +e >= t;
}
function ep(e) {
  return e == null || isNaN(e = +e) ? -1 / 0 : e;
}
function vb(e, t, n, r) {
  const i = r - t, s = n - t, o = isFinite(i) || isFinite(s) ? i / s : Math.sign(i) / Math.sign(s);
  return isNaN(o) ? e : e + o - 0.5;
}
function zC(e) {
  return e[0];
}
function jC(e) {
  return e[1];
}
function qC() {
  return 1;
}
function VC() {
  var e = zC, t = jC, n = qC, r = 960, i = 500, s = 20, o = 2, a = s * 3, c = r + a * 2 >> o, u = i + a * 2 >> o, l = mi(20);
  function f(b) {
    var w = new Float32Array(c * u), v = Math.pow(2, -o), x = -1;
    for (const F of b) {
      var _ = (e(F, ++x, b) + a) * v, M = (t(F, x, b) + a) * v, T = +n(F, x, b);
      if (T && _ >= 0 && _ < c && M >= 0 && M < u) {
        var N = Math.floor(_), A = Math.floor(M), $ = _ - N - 0.5, D = M - A - 0.5;
        w[N + A * c] += (1 - $) * (1 - D) * T, w[N + 1 + A * c] += $ * (1 - D) * T, w[N + 1 + (A + 1) * c] += $ * D * T, w[N + (A + 1) * c] += (1 - $) * D * T;
      }
    }
    return fx({ data: w, width: c, height: u }, s * v), w;
  }
  function h(b) {
    var w = f(b), v = l(w), x = Math.pow(2, 2 * o);
    return Array.isArray(v) || (v = ki(Number.MIN_VALUE, Qt(w) / x, v)), vf().size([c, u]).thresholds(v.map((_) => _ * x))(w).map((_, M) => (_.value = +v[M], d(_)));
  }
  h.contours = function(b) {
    var w = f(b), v = vf().size([c, u]), x = Math.pow(2, 2 * o), _ = (M) => {
      M = +M;
      var T = d(v.contour(w, M * x));
      return T.value = M, T;
    };
    return Object.defineProperty(_, "max", { get: () => Qt(w) / x }), _;
  };
  function d(b) {
    return b.coordinates.forEach(p), b;
  }
  function p(b) {
    b.forEach(y);
  }
  function y(b) {
    b.forEach(g);
  }
  function g(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 = r + a * 2 >> o, u = i + a * 2 >> o, h;
  }
  return h.x = function(b) {
    return arguments.length ? (e = typeof b == "function" ? b : mi(+b), h) : e;
  }, h.y = function(b) {
    return arguments.length ? (t = typeof b == "function" ? b : mi(+b), h) : t;
  }, h.weight = function(b) {
    return arguments.length ? (n = typeof b == "function" ? b : mi(+b), h) : n;
  }, h.size = function(b) {
    if (!arguments.length)
      return [r, i];
    var w = +b[0], v = +b[1];
    if (!(w >= 0 && v >= 0))
      throw new Error("invalid size");
    return r = w, i = v, 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) ? mi(aS.call(b)) : mi(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 Xr = 11102230246251565e-32, Ae = 134217729, YC = (3 + 8 * Xr) * Xr;
function np(e, t, n, r, i) {
  let s, o, a, c, u = t[0], l = r[0], f = 0, h = 0;
  l > u == l > -u ? (s = u, u = t[++f]) : (s = l, l = r[++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 = r[++h]), s = o, a !== 0 && (i[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 = r[++h]), s = o, a !== 0 && (i[d++] = a);
  for (; f < e; )
    o = s + u, c = o - s, a = s - (o - c) + (u - c), u = t[++f], s = o, a !== 0 && (i[d++] = a);
  for (; h < n; )
    o = s + l, c = o - s, a = s - (o - c) + (l - c), l = r[++h], s = o, a !== 0 && (i[d++] = a);
  return (s !== 0 || d === 0) && (i[d++] = s), d;
}
function WC(e, t) {
  let n = t[0];
  for (let r = 1; r < e; r++)
    n += t[r];
  return n;
}
function iu(e) {
  return new Float64Array(e);
}
const XC = (3 + 16 * Xr) * Xr, GC = (2 + 12 * Xr) * Xr, HC = (9 + 64 * Xr) * Xr * Xr, io = iu(4), _b = iu(8), xb = iu(12), Sb = iu(16), Ne = iu(4);
function JC(e, t, n, r, i, s, o) {
  let a, c, u, l, f, h, d, p, y, g, m, b, w, v, x, _, M, T;
  const N = e - i, A = n - i, $ = t - s, D = r - s;
  v = N * D, h = Ae * N, d = h - (h - N), p = N - d, h = Ae * D, y = h - (h - D), g = D - y, x = p * g - (v - d * y - p * y - d * g), _ = $ * A, h = Ae * $, d = h - (h - $), p = $ - d, h = Ae * A, y = h - (h - A), g = A - y, M = p * g - (_ - d * y - p * y - d * g), m = x - M, f = x - m, io[0] = x - (m + f) + (f - M), b = v + m, f = b - v, w = v - (b - f) + (m - f), m = w - _, f = w - m, io[1] = w - (m + f) + (f - _), T = b + m, f = T - b, io[2] = b - (T - f) + (m - f), io[3] = T;
  let F = WC(4, io), S = GC * o;
  if (F >= S || -F >= S || (f = e - N, a = e - (N + f) + (f - i), f = n - A, u = n - (A + f) + (f - i), f = t - $, c = t - ($ + f) + (f - s), f = r - D, l = r - (D + f) + (f - s), a === 0 && c === 0 && u === 0 && l === 0) || (S = HC * o + YC * Math.abs(F), F += N * l + D * a - ($ * u + A * c), F >= S || -F >= S))
    return F;
  v = a * D, h = Ae * a, d = h - (h - a), p = a - d, h = Ae * D, y = h - (h - D), g = D - y, x = p * g - (v - d * y - p * y - d * g), _ = c * A, h = Ae * c, d = h - (h - c), p = c - d, h = Ae * A, y = h - (h - A), g = A - y, M = p * g - (_ - d * y - p * y - d * g), m = x - M, f = x - m, Ne[0] = x - (m + f) + (f - M), b = v + m, f = b - v, w = v - (b - f) + (m - f), m = w - _, f = w - m, Ne[1] = w - (m + f) + (f - _), T = b + m, f = T - b, Ne[2] = b - (T - f) + (m - f), Ne[3] = T;
  const I = np(4, io, 4, Ne, _b);
  v = N * l, h = Ae * N, d = h - (h - N), p = N - d, h = Ae * l, y = h - (h - l), g = l - y, x = p * g - (v - d * y - p * y - d * g), _ = $ * u, h = Ae * $, d = h - (h - $), p = $ - d, h = Ae * u, y = h - (h - u), g = u - y, M = p * g - (_ - d * y - p * y - d * g), m = x - M, f = x - m, Ne[0] = x - (m + f) + (f - M), b = v + m, f = b - v, w = v - (b - f) + (m - f), m = w - _, f = w - m, Ne[1] = w - (m + f) + (f - _), T = b + m, f = T - b, Ne[2] = b - (T - f) + (m - f), Ne[3] = T;
  const E = np(I, _b, 4, Ne, xb);
  v = a * l, h = Ae * a, d = h - (h - a), p = a - d, h = Ae * l, y = h - (h - l), g = l - y, x = p * g - (v - d * y - p * y - d * g), _ = c * u, h = Ae * c, d = h - (h - c), p = c - d, h = Ae * u, y = h - (h - u), g = u - y, M = p * g - (_ - d * y - p * y - d * g), m = x - M, f = x - m, Ne[0] = x - (m + f) + (f - M), b = v + m, f = b - v, w = v - (b - f) + (m - f), m = w - _, f = w - m, Ne[1] = w - (m + f) + (f - _), T = b + m, f = T - b, Ne[2] = b - (T - f) + (m - f), Ne[3] = T;
  const O = np(E, xb, 4, Ne, Sb);
  return Sb[O - 1];
}
function Vu(e, t, n, r, i, s) {
  const o = (t - s) * (n - i), a = (e - i) * (r - 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) >= XC * u ? c : -JC(e, t, n, r, i, s, u);
}
const Mb = Math.pow(2, -52), Yu = new Uint32Array(512);
class _f {
  static from(t, n = eB, r = nB) {
    const i = t.length, s = new Float64Array(i * 2);
    for (let o = 0; o < i; o++) {
      const a = t[o];
      s[2 * o] = n(a), s[2 * o + 1] = r(a);
    }
    return new _f(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 r = Math.max(2 * n - 5, 0);
    this._triangles = new Uint32Array(r * 3), this._halfedges = new Int32Array(r * 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: r, _hullTri: i, _hullHash: s } = this, o = t.length >> 1;
    let a = 1 / 0, c = 1 / 0, u = -1 / 0, l = -1 / 0;
    for (let A = 0; A < o; A++) {
      const $ = t[2 * A], D = t[2 * A + 1];
      $ < a && (a = $), D < c && (c = D), $ > u && (u = $), D > l && (l = D), this._ids[A] = A;
    }
    const f = (a + u) / 2, h = (c + l) / 2;
    let d = 1 / 0, p, y, g;
    for (let A = 0; A < o; A++) {
      const $ = rp(f, h, t[2 * A], t[2 * A + 1]);
      $ < d && (p = A, d = $);
    }
    const m = t[2 * p], b = t[2 * p + 1];
    d = 1 / 0;
    for (let A = 0; A < o; A++) {
      if (A === p)
        continue;
      const $ = rp(m, b, t[2 * A], t[2 * A + 1]);
      $ < d && $ > 0 && (y = A, d = $);
    }
    let w = t[2 * y], v = t[2 * y + 1], x = 1 / 0;
    for (let A = 0; A < o; A++) {
      if (A === p || A === y)
        continue;
      const $ = QC(m, b, w, v, t[2 * A], t[2 * A + 1]);
      $ < x && (g = A, x = $);
    }
    let _ = t[2 * g], M = t[2 * g + 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];
      bo(this._ids, this._dists, 0, o - 1);
      const A = new Uint32Array(o);
      let $ = 0;
      for (let D = 0, F = -1 / 0; D < o; D++) {
        const S = this._ids[D];
        this._dists[S] > F && (A[$++] = S, F = this._dists[S]);
      }
      this.hull = A.subarray(0, $), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
      return;
    }
    if (Vu(m, b, w, v, _, M) < 0) {
      const A = y, $ = w, D = v;
      y = g, w = _, v = M, g = A, _ = $, M = D;
    }
    const T = tB(m, b, w, v, _, M);
    this._cx = T.x, this._cy = T.y;
    for (let A = 0; A < o; A++)
      this._dists[A] = rp(t[2 * A], t[2 * A + 1], T.x, T.y);
    bo(this._ids, this._dists, 0, o - 1), this._hullStart = p;
    let N = 3;
    r[p] = n[g] = y, r[y] = n[p] = g, r[g] = n[y] = p, i[p] = 0, i[y] = 1, i[g] = 2, s.fill(-1), s[this._hashKey(m, b)] = p, s[this._hashKey(w, v)] = y, s[this._hashKey(_, M)] = g, this.trianglesLen = 0, this._addTriangle(p, y, g, -1, -1, -1);
    for (let A = 0, $, D; A < this._ids.length; A++) {
      const F = this._ids[A], S = t[2 * F], I = t[2 * F + 1];
      if (A > 0 && Math.abs(S - $) <= Mb && Math.abs(I - D) <= Mb || ($ = S, D = I, F === p || F === y || F === g))
        continue;
      let E = 0;
      for (let P = 0, U = this._hashKey(S, I); P < this._hashSize && (E = s[(U + P) % this._hashSize], !(E !== -1 && E !== r[E])); P++)
        ;
      E = n[E];
      let O = E, C;
      for (; C = r[O], Vu(S, I, t[2 * O], t[2 * O + 1], t[2 * C], t[2 * C + 1]) >= 0; )
        if (O = C, O === E) {
          O = -1;
          break;
        }
      if (O === -1)
        continue;
      let B = this._addTriangle(O, F, r[O], -1, -1, i[O]);
      i[F] = this._legalize(B + 2), i[O] = B, N++;
      let R = r[O];
      for (; C = r[R], Vu(S, I, t[2 * R], t[2 * R + 1], t[2 * C], t[2 * C + 1]) < 0; )
        B = this._addTriangle(R, F, C, i[F], -1, i[R]), i[F] = this._legalize(B + 2), r[R] = R, N--, R = C;
      if (O === E)
        for (; C = n[O], Vu(S, I, t[2 * C], t[2 * C + 1], t[2 * O], t[2 * O + 1]) < 0; )
          B = this._addTriangle(C, F, O, -1, i[O], i[C]), this._legalize(B + 2), i[C] = B, r[O] = O, N--, O = C;
      this._hullStart = n[F] = O, r[O] = n[R] = F, r[F] = R, s[this._hashKey(S, I)] = F, s[this._hashKey(t[2 * O], t[2 * O + 1])] = O;
    }
    this.hull = new Uint32Array(N);
    for (let A = 0, $ = this._hullStart; A < N; A++)
      this.hull[A] = $, $ = r[$];
    this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
  }
  _hashKey(t, n) {
    return Math.floor(ZC(t - this._cx, n - this._cy) * this._hashSize) % this._hashSize;
  }
  _legalize(t) {
    const { _triangles: n, _halfedges: r, coords: i } = this;
    let s = 0, o = 0;
    for (; ; ) {
      const a = r[t], c = t - t % 3;
      if (o = c + (t + 2) % 3, a === -1) {
        if (s === 0)
          break;
        t = Yu[--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], y = n[f];
      if (KC(
        i[2 * h],
        i[2 * h + 1],
        i[2 * d],
        i[2 * d + 1],
        i[2 * p],
        i[2 * p + 1],
        i[2 * y],
        i[2 * y + 1]
      )) {
        n[t] = y, n[a] = h;
        const m = r[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, r[o]), this._link(o, f);
        const b = u + (a + 1) % 3;
        s < Yu.length && (Yu[s++] = b);
      } else {
        if (s === 0)
          break;
        t = Yu[--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, r, i, s, o) {
    const a = this.trianglesLen;
    return this._triangles[a] = t, this._triangles[a + 1] = n, this._triangles[a + 2] = r, this._link(a, i), this._link(a + 1, s), this._link(a + 2, o), this.trianglesLen += 3, a;
  }
}
function ZC(e, t) {
  const n = e / (Math.abs(e) + Math.abs(t));
  return (t > 0 ? 3 - n : 1 + n) / 4;
}
function rp(e, t, n, r) {
  const i = e - n, s = t - r;
  return i * i + s * s;
}
function KC(e, t, n, r, i, s, o, a) {
  const c = e - o, u = t - a, l = n - o, f = r - a, h = i - o, d = s - a, p = c * c + u * u, y = l * l + f * f, g = h * h + d * d;
  return c * (f * g - y * d) - u * (l * g - y * h) + p * (l * d - f * h) < 0;
}
function QC(e, t, n, r, i, s) {
  const o = n - e, a = r - t, c = i - 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 tB(e, t, n, r, i, s) {
  const o = n - e, a = r - t, c = i - 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 bo(e, t, n, r) {
  if (r - n <= 20)
    for (let i = n + 1; i <= r; i++) {
      const s = e[i], o = t[s];
      let a = i - 1;
      for (; a >= n && t[e[a]] > o; )
        e[a + 1] = e[a--];
      e[a + 1] = s;
    }
  else {
    const i = n + r >> 1;
    let s = n + 1, o = r;
    Ra(e, i, s), t[e[n]] > t[e[r]] && Ra(e, n, r), t[e[s]] > t[e[r]] && Ra(e, s, r), t[e[n]] > t[e[s]] && Ra(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;
      Ra(e, s, o);
    }
    e[n + 1] = e[o], e[o] = a, r - s + 1 >= o - n ? (bo(e, t, s, r), bo(e, t, n, o - 1)) : (bo(e, t, n, o - 1), bo(e, t, s, r));
  }
}
function Ra(e, t, n) {
  const r = e[t];
  e[t] = e[n], e[n] = r;
}
function eB(e) {
  return e[0];
}
function nB(e) {
  return e[1];
}
const Ab = 1e-6;
class bs {
  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, r) {
    t = +t, n = +n, r = +r;
    const i = t + r, s = n;
    if (r < 0)
      throw new Error("negative radius");
    this._x1 === null ? this._ += `M${i},${s}` : (Math.abs(this._x1 - i) > Ab || Math.abs(this._y1 - s) > Ab) && (this._ += "L" + i + "," + s), r && (this._ += `A${r},${r},0,1,1,${t - r},${n}A${r},${r},0,1,1,${this._x1 = i},${this._y1 = s}`);
  }
  rect(t, n, r, i) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${+r}v${+i}h${-r}Z`;
  }
  value() {
    return this._ || null;
  }
}
class A0 {
  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 rB = class {
  constructor(t, [n, r, i, s] = [0, 0, 960, 500]) {
    if (!((i = +i) >= (n = +n)) || !((s = +s) >= (r = +r)))
      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 = i, this.xmin = n, this.ymax = s, this.ymin = r, this._init();
  }
  update() {
    return this.delaunay.update(), this._init(), this;
  }
  _init() {
    const { delaunay: { points: t, hull: n, triangles: r }, vectors: i } = this;
    let s, o;
    const a = this.circumcenters = this._circumcenters.subarray(0, r.length / 3 * 2);
    for (let y = 0, g = 0, m = r.length, b, w; y < m; y += 3, g += 2) {
      const v = r[y] * 2, x = r[y + 1] * 2, _ = r[y + 2] * 2, M = t[v], T = t[v + 1], N = t[x], A = t[x + 1], $ = t[_], D = t[_ + 1], F = N - M, S = A - T, I = $ - M, E = D - T, O = (F * E - S * I) * 2;
      if (Math.abs(O) < 1e-9) {
        if (s === void 0) {
          s = o = 0;
          for (const B of n)
            s += t[B * 2], o += t[B * 2 + 1];
          s /= n.length, o /= n.length;
        }
        const C = 1e9 * Math.sign((s - M) * E - (o - T) * I);
        b = (M + $) / 2 - C * E, w = (T + D) / 2 + C * I;
      } else {
        const C = 1 / O, B = F * F + S * S, R = I * I + E * E;
        b = M + (E * B - S * R) * C, w = T + (F * R - I * B) * C;
      }
      a[g] = b, a[g + 1] = w;
    }
    let c = n[n.length - 1], u, l = c * 4, f, h = t[2 * c], d, p = t[2 * c + 1];
    i.fill(0);
    for (let y = 0; y < n.length; ++y)
      c = n[y], u = l, f = h, d = p, l = c * 4, h = t[2 * c], p = t[2 * c + 1], i[u + 2] = i[l] = d - p, i[u + 3] = i[l + 1] = h - f;
  }
  render(t) {
    const n = t == null ? t = new bs() : void 0, { delaunay: { halfedges: r, inedges: i, hull: s }, circumcenters: o, vectors: a } = this;
    if (s.length <= 1)
      return null;
    for (let l = 0, f = r.length; l < f; ++l) {
      const h = r[l];
      if (h < l)
        continue;
      const d = Math.floor(l / 3) * 2, p = Math.floor(h / 3) * 2, y = o[d], g = o[d + 1], m = o[p], b = o[p + 1];
      this._renderSegment(y, g, 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(i[u] / 3) * 2, h = o[f], d = o[f + 1], p = c * 4, y = this._project(h, d, a[p + 2], a[p + 3]);
      y && this._renderSegment(h, d, y[0], y[1], t);
    }
    return n && n.value();
  }
  renderBounds(t) {
    const n = t == null ? t = new bs() : void 0;
    return t.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin), n && n.value();
  }
  renderCell(t, n) {
    const r = n == null ? n = new bs() : void 0, i = this._clip(t);
    if (i === null || !i.length)
      return;
    n.moveTo(i[0], i[1]);
    let s = i.length;
    for (; i[0] === i[s - 2] && i[1] === i[s - 1] && s > 1; )
      s -= 2;
    for (let o = 2; o < s; o += 2)
      (i[o] !== i[o - 2] || i[o + 1] !== i[o - 1]) && n.lineTo(i[o], i[o + 1]);
    return n.closePath(), r && r.value();
  }
  *cellPolygons() {
    const { delaunay: { points: t } } = this;
    for (let n = 0, r = t.length / 2; n < r; ++n) {
      const i = this.cellPolygon(n);
      i && (i.index = n, yield i);
    }
  }
  cellPolygon(t) {
    const n = new A0();
    return this.renderCell(t, n), n.value();
  }
  _renderSegment(t, n, r, i, s) {
    let o;
    const a = this._regioncode(t, n), c = this._regioncode(r, i);
    a === 0 && c === 0 ? (s.moveTo(t, n), s.lineTo(r, i)) : (o = this._clipSegment(t, n, r, i, a, c)) && (s.moveTo(o[0], o[1]), s.lineTo(o[2], o[3]));
  }
  contains(t, n, r) {
    return n = +n, n !== n || (r = +r, r !== r) ? !1 : this.delaunay._step(t, n, r) === t;
  }
  *neighbors(t) {
    const n = this._clip(t);
    if (n)
      for (const r of this.delaunay.neighbors(t)) {
        const i = this._clip(r);
        if (i) {
          t:
            for (let s = 0, o = n.length; s < o; s += 2)
              for (let a = 0, c = i.length; a < c; a += 2)
                if (n[s] === i[a] && n[s + 1] === i[a + 1] && n[(s + 2) % o] === i[(a + c - 2) % c] && n[(s + 3) % o] === i[(a + c - 1) % c]) {
                  yield r;
                  break t;
                }
        }
      }
  }
  _cell(t) {
    const { circumcenters: n, delaunay: { inedges: r, halfedges: i, triangles: s } } = this, o = r[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 = i[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: r } = this, i = t * 4;
    return this._simplify(r[i] || r[i + 1] ? this._clipInfinite(t, n, r[i], r[i + 1], r[i + 2], r[i + 3]) : this._clipFinite(t, n));
  }
  _clipFinite(t, n) {
    const r = n.length;
    let i = null, s, o, a = n[r - 2], c = n[r - 1], u, l = this._regioncode(a, c), f, h = 0;
    for (let d = 0; d < r; 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, i ? i.push(a, c) : i = [a, c];
      else {
        let p, y, g, m, b;
        if (u === 0) {
          if ((p = this._clipSegment(s, o, a, c, u, l)) === null)
            continue;
          [y, g, m, b] = p;
        } else {
          if ((p = this._clipSegment(a, c, s, o, l, u)) === null)
            continue;
          [m, b, y, g] = p, f = h, h = this._edgecode(y, g), f && h && this._edge(t, f, h, i, i.length), i ? i.push(y, g) : i = [y, g];
        }
        f = h, h = this._edgecode(m, b), f && h && this._edge(t, f, h, i, i.length), i ? i.push(m, b) : i = [m, b];
      }
    if (i)
      f = h, h = this._edgecode(i[0], i[1]), f && h && this._edge(t, f, h, i, i.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 i;
  }
  _clipSegment(t, n, r, i, s, o) {
    const a = s < o;
    for (a && ([t, n, r, i, s, o] = [r, i, t, n, o, s]); ; ) {
      if (s === 0 && o === 0)
        return a ? [r, i, t, n] : [t, n, r, i];
      if (s & o)
        return null;
      let c, u, l = s || o;
      l & 8 ? (c = t + (r - t) * (this.ymax - n) / (i - n), u = this.ymax) : l & 4 ? (c = t + (r - t) * (this.ymin - n) / (i - n), u = this.ymin) : l & 2 ? (u = n + (i - n) * (this.xmax - t) / (r - t), c = this.xmax) : (u = n + (i - n) * (this.xmin - t) / (r - t), c = this.xmin), s ? (t = c, n = u, s = this._regioncode(t, n)) : (r = c, i = u, o = this._regioncode(r, i));
    }
  }
  _clipInfinite(t, n, r, i, s, o) {
    let a = Array.from(n), c;
    if ((c = this._project(a[0], a[1], r, i)) && 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, r, i, s) {
    for (; n !== r; ) {
      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;
      }
      (i[s] !== o || i[s + 1] !== a) && this.contains(t, o, a) && (i.splice(s, 0, o, a), s += 2);
    }
    return s;
  }
  _project(t, n, r, i) {
    let s = 1 / 0, o, a, c;
    if (i < 0) {
      if (n <= this.ymin)
        return null;
      (o = (this.ymin - n) / i) < s && (c = this.ymin, a = t + (s = o) * r);
    } else if (i > 0) {
      if (n >= this.ymax)
        return null;
      (o = (this.ymax - n) / i) < s && (c = this.ymax, a = t + (s = o) * r);
    }
    if (r > 0) {
      if (t >= this.xmax)
        return null;
      (o = (this.xmax - t) / r) < s && (a = this.xmax, c = n + (s = o) * i);
    } else if (r < 0) {
      if (t <= this.xmin)
        return null;
      (o = (this.xmin - t) / r) < s && (a = this.xmin, c = n + (s = o) * i);
    }
    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);
  }
  _simplify(t) {
    if (t && t.length > 4) {
      for (let n = 0; n < t.length; n += 2) {
        const r = (n + 2) % t.length, i = (n + 4) % t.length;
        (t[n] === t[r] && t[r] === t[i] || t[n + 1] === t[r + 1] && t[r + 1] === t[i + 1]) && (t.splice(r, 2), n -= 2);
      }
      t.length || (t = null);
    }
    return t;
  }
};
const iB = 2 * Math.PI, so = Math.pow;
function sB(e) {
  return e[0];
}
function oB(e) {
  return e[1];
}
function aB(e) {
  const { triangles: t, coords: n } = e;
  for (let r = 0; r < t.length; r += 3) {
    const i = 2 * t[r], s = 2 * t[r + 1], o = 2 * t[r + 2];
    if ((n[o] - n[i]) * (n[s + 1] - n[i + 1]) - (n[s] - n[i]) * (n[o + 1] - n[i + 1]) > 1e-10)
      return !1;
  }
  return !0;
}
function cB(e, t, n) {
  return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n];
}
class Xi {
  static from(t, n = sB, r = oB, i) {
    return new Xi("length" in t ? uB(t, n, r, i) : Float64Array.from(lB(t, n, r, i)));
  }
  constructor(t) {
    this._delaunator = new _f(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 && aB(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 = cB(n[2 * h], n[2 * h + 1], f);
        n[2 * h] = p[0], n[2 * h + 1] = p[1];
      }
      this._delaunator = new _f(n);
    } else
      delete this.collinear;
    const r = this.halfedges = this._delaunator.halfedges, i = 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 = r.length; c < u; ++c) {
      const l = s[c % 3 === 2 ? c - 2 : c + 1];
      (r[c] === -1 || o[l] === -1) && (o[l] = c);
    }
    for (let c = 0, u = i.length; c < u; ++c)
      a[i[c]] = c;
    i.length <= 2 && i.length > 0 && (this.triangles = new Int32Array(3).fill(-1), this.halfedges = new Int32Array(3).fill(-1), this.triangles[0] = i[0], o[i[0]] = 1, i.length === 2 && (o[i[1]] = 0, this.triangles[1] = i[1], this.triangles[2] = i[1]));
  }
  voronoi(t) {
    return new rB(this, t);
  }
  *neighbors(t) {
    const { inedges: n, hull: r, _hullIndex: i, 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 = r[(i[t] + 1) % r.length];
        f !== l && (yield f);
        return;
      }
    } while (u !== c);
  }
  find(t, n, r = 0) {
    if (t = +t, t !== t || (n = +n, n !== n))
      return -1;
    const i = r;
    let s;
    for (; (s = this._step(r, t, n)) >= 0 && s !== r && s !== i; )
      r = s;
    return s;
  }
  _step(t, n, r) {
    const { inedges: i, hull: s, _hullIndex: o, halfedges: a, triangles: c, points: u } = this;
    if (i[t] === -1 || !u.length)
      return (t + 1) % (u.length >> 1);
    let l = t, f = so(n - u[t * 2], 2) + so(r - u[t * 2 + 1], 2);
    const h = i[t];
    let d = h;
    do {
      let p = c[d];
      const y = so(n - u[p * 2], 2) + so(r - u[p * 2 + 1], 2);
      if (y < f && (f = y, 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 && so(n - u[d * 2], 2) + so(r - u[d * 2 + 1], 2) < f)
          return d;
        break;
      }
    } while (d !== h);
    return l;
  }
  render(t) {
    const n = t == null ? t = new bs() : void 0, { points: r, halfedges: i, triangles: s } = this;
    for (let o = 0, a = i.length; o < a; ++o) {
      const c = i[o];
      if (c < o)
        continue;
      const u = s[o] * 2, l = s[c] * 2;
      t.moveTo(r[u], r[u + 1]), t.lineTo(r[l], r[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 r = t == null ? t = new bs() : void 0, { points: i } = this;
    for (let s = 0, o = i.length; s < o; s += 2) {
      const a = i[s], c = i[s + 1];
      t.moveTo(a + n, c), t.arc(a, c, n, 0, iB);
    }
    return r && r.value();
  }
  renderHull(t) {
    const n = t == null ? t = new bs() : void 0, { hull: r, points: i } = this, s = r[0] * 2, o = r.length;
    t.moveTo(i[s], i[s + 1]);
    for (let a = 1; a < o; ++a) {
      const c = 2 * r[a];
      t.lineTo(i[c], i[c + 1]);
    }
    return t.closePath(), n && n.value();
  }
  hullPolygon() {
    const t = new A0();
    return this.renderHull(t), t.value();
  }
  renderTriangle(t, n) {
    const r = n == null ? n = new bs() : void 0, { points: i, triangles: s } = this, o = s[t *= 3] * 2, a = s[t + 1] * 2, c = s[t + 2] * 2;
    return n.moveTo(i[o], i[o + 1]), n.lineTo(i[a], i[a + 1]), n.lineTo(i[c], i[c + 1]), n.closePath(), r && r.value();
  }
  *trianglePolygons() {
    const { triangles: t } = this;
    for (let n = 0, r = t.length / 3; n < r; ++n)
      yield this.trianglePolygon(n);
  }
  trianglePolygon(t) {
    const n = new A0();
    return this.renderTriangle(t, n), n.value();
  }
}
function uB(e, t, n, r) {
  const i = e.length, s = new Float64Array(i * 2);
  for (let o = 0; o < i; ++o) {
    const a = e[o];
    s[o * 2] = t.call(r, a, o, e), s[o * 2 + 1] = n.call(r, a, o, e);
  }
  return s;
}
function* lB(e, t, n, r) {
  let i = 0;
  for (const s of e)
    yield t.call(r, s, i, e), yield n.call(r, s, i, e), ++i;
}
function fB(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function xf(e, t) {
  if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0)
    return null;
  var n, r = e.slice(0, n);
  return [
    r.length > 1 ? r[0] + r.slice(2) : r,
    +e.slice(n + 1)
  ];
}
function Qo(e) {
  return e = xf(Math.abs(e)), e ? e[1] : NaN;
}
function hB(e, t) {
  return function(n, r) {
    for (var i = n.length, s = [], o = 0, a = e[0], c = 0; i > 0 && a > 0 && (c + a + 1 > r && (a = Math.max(1, r - c)), s.push(n.substring(i -= a, i + a)), !((c += a + 1) > r)); )
      a = e[o = (o + 1) % e.length];
    return s.reverse().join(t);
  };
}
function dB(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var pB = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function Dc(e) {
  if (!(t = pB.exec(e)))
    throw new Error("invalid format: " + e);
  var t;
  return new xm({
    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]
  });
}
Dc.prototype = xm.prototype;
function xm(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 + "";
}
xm.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 yB(e) {
  t:
    for (var t = e.length, n = 1, r = -1, i; n < t; ++n)
      switch (e[n]) {
        case ".":
          r = i = n;
          break;
        case "0":
          r === 0 && (r = n), i = n;
          break;
        default:
          if (!+e[n])
            break t;
          r > 0 && (r = 0);
          break;
      }
  return r > 0 ? e.slice(0, r) + e.slice(i + 1) : e;
}
var cS;
function mB(e, t) {
  var n = xf(e, t);
  if (!n)
    return e + "";
  var r = n[0], i = n[1], s = i - (cS = Math.max(-8, Math.min(8, Math.floor(i / 3))) * 3) + 1, o = r.length;
  return s === o ? r : s > o ? r + new Array(s - o + 1).join("0") : s > 0 ? r.slice(0, s) + "." + r.slice(s) : "0." + new Array(1 - s).join("0") + xf(e, Math.max(0, t + s - 1))[0];
}
function $b(e, t) {
  var n = xf(e, t);
  if (!n)
    return e + "";
  var r = n[0], i = n[1];
  return i < 0 ? "0." + new Array(-i).join("0") + r : r.length > i + 1 ? r.slice(0, i + 1) + "." + r.slice(i + 1) : r + new Array(i - r.length + 2).join("0");
}
const Ib = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: fB,
  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) => $b(e * 100, t),
  r: $b,
  s: mB,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function Tb(e) {
  return e;
}
var Eb = Array.prototype.map, Nb = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function gB(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? Tb : hB(Eb.call(e.grouping, Number), e.thousands + ""), n = e.currency === void 0 ? "" : e.currency[0] + "", r = e.currency === void 0 ? "" : e.currency[1] + "", i = e.decimal === void 0 ? "." : e.decimal + "", s = e.numerals === void 0 ? Tb : dB(Eb.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 = Dc(f);
    var h = f.fill, d = f.align, p = f.sign, y = f.symbol, g = f.zero, m = f.width, b = f.comma, w = f.precision, v = f.trim, x = f.type;
    x === "n" ? (b = !0, x = "g") : Ib[x] || (w === void 0 && (w = 12), v = !0, x = "g"), (g || h === "0" && d === "=") && (g = !0, h = "0", d = "=");
    var _ = y === "$" ? n : y === "#" && /[boxX]/.test(x) ? "0" + x.toLowerCase() : "", M = y === "$" ? r : /[%p]/.test(x) ? o : "", T = Ib[x], N = /[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 A($) {
      var D = _, F = M, S, I, E;
      if (x === "c")
        F = T($) + F, $ = "";
      else {
        $ = +$;
        var O = $ < 0 || 1 / $ < 0;
        if ($ = isNaN($) ? c : T(Math.abs($), w), v && ($ = yB($)), O && +$ == 0 && p !== "+" && (O = !1), D = (O ? p === "(" ? p : a : p === "-" || p === "(" ? "" : p) + D, F = (x === "s" ? Nb[8 + cS / 3] : "") + F + (O && p === "(" ? ")" : ""), N) {
          for (S = -1, I = $.length; ++S < I; )
            if (E = $.charCodeAt(S), 48 > E || E > 57) {
              F = (E === 46 ? i + $.slice(S + 1) : $.slice(S)) + F, $ = $.slice(0, S);
              break;
            }
        }
      }
      b && !g && ($ = t($, 1 / 0));
      var C = D.length + $.length + F.length, B = C < m ? new Array(m - C + 1).join(h) : "";
      switch (b && g && ($ = t(B + $, B.length ? m - F.length : 1 / 0), B = ""), d) {
        case "<":
          $ = D + $ + F + B;
          break;
        case "=":
          $ = D + B + $ + F;
          break;
        case "^":
          $ = B.slice(0, C = B.length >> 1) + D + $ + F + B.slice(C);
          break;
        default:
          $ = B + D + $ + F;
          break;
      }
      return s($);
    }
    return A.toString = function() {
      return f + "";
    }, A;
  }
  function l(f, h) {
    var d = u((f = Dc(f), f.type = "f", f)), p = Math.max(-8, Math.min(8, Math.floor(Qo(h) / 3))) * 3, y = Math.pow(10, -p), g = Nb[8 + p / 3];
    return function(m) {
      return d(y * m) + g;
    };
  }
  return {
    format: u,
    formatPrefix: l
  };
}
var Wu, wa, uS;
bB({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function bB(e) {
  return Wu = gB(e), wa = Wu.format, uS = Wu.formatPrefix, Wu;
}
function wB(e) {
  return Math.max(0, -Qo(Math.abs(e)));
}
function vB(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Qo(t) / 3))) * 3 - Qo(Math.abs(e)));
}
function _B(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Qo(t) - Qo(e)) + 1;
}
var nt = 1e-6, Sf = 1e-12, Mt = Math.PI, oe = Mt / 2, Db = Mt / 4, cn = Mt * 2, _e = 180 / Mt, Dt = Mt / 180, Lt = Math.abs, va = Math.atan, Un = Math.atan2, ot = Math.cos, Xu = Math.ceil, lS = Math.exp, $0 = Math.hypot, Mf = Math.log, ip = Math.pow, tt = Math.sin, gn = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, Ce = Math.sqrt, Sm = Math.tan;
function fS(e) {
  return e > 1 ? 0 : e < -1 ? Mt : Math.acos(e);
}
function Je(e) {
  return e > 1 ? oe : e < -1 ? -oe : Math.asin(e);
}
function rn() {
}
function Af(e, t) {
  e && Lb.hasOwnProperty(e.type) && Lb[e.type](e, t);
}
var Ob = {
  Feature: function(e, t) {
    Af(e.geometry, t);
  },
  FeatureCollection: function(e, t) {
    for (var n = e.features, r = -1, i = n.length; ++r < i; )
      Af(n[r].geometry, t);
  }
}, Lb = {
  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, r = -1, i = n.length; ++r < i; )
      e = n[r], t.point(e[0], e[1], e[2]);
  },
  LineString: function(e, t) {
    I0(e.coordinates, t, 0);
  },
  MultiLineString: function(e, t) {
    for (var n = e.coordinates, r = -1, i = n.length; ++r < i; )
      I0(n[r], t, 0);
  },
  Polygon: function(e, t) {
    kb(e.coordinates, t);
  },
  MultiPolygon: function(e, t) {
    for (var n = e.coordinates, r = -1, i = n.length; ++r < i; )
      kb(n[r], t);
  },
  GeometryCollection: function(e, t) {
    for (var n = e.geometries, r = -1, i = n.length; ++r < i; )
      Af(n[r], t);
  }
};
function I0(e, t, n) {
  var r = -1, i = e.length - n, s;
  for (t.lineStart(); ++r < i; )
    s = e[r], t.point(s[0], s[1], s[2]);
  t.lineEnd();
}
function kb(e, t) {
  var n = -1, r = e.length;
  for (t.polygonStart(); ++n < r; )
    I0(e[n], t, 1);
  t.polygonEnd();
}
function bi(e, t) {
  e && Ob.hasOwnProperty(e.type) ? Ob[e.type](e, t) : Af(e, t);
}
function T0(e) {
  return [Un(e[1], e[0]), Je(e[2])];
}
function ta(e) {
  var t = e[0], n = e[1], r = ot(n);
  return [r * ot(t), r * tt(t), tt(n)];
}
function Gu(e, t) {
  return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
}
function $f(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 sp(e, t) {
  e[0] += t[0], e[1] += t[1], e[2] += t[2];
}
function Hu(e, t) {
  return [e[0] * t, e[1] * t, e[2] * t];
}
function E0(e) {
  var t = Ce(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= t, e[1] /= t, e[2] /= t;
}
var Ha, If, Tf, Ef, Nf, Df, Of, Lf, N0, D0, O0, hS, dS, Oe, Le, ke, kn = {
  sphere: rn,
  point: Mm,
  lineStart: Fb,
  lineEnd: Rb,
  polygonStart: function() {
    kn.lineStart = MB, kn.lineEnd = AB;
  },
  polygonEnd: function() {
    kn.lineStart = Fb, kn.lineEnd = Rb;
  }
};
function Mm(e, t) {
  e *= Dt, t *= Dt;
  var n = ot(t);
  su(n * ot(e), n * tt(e), tt(t));
}
function su(e, t, n) {
  ++Ha, Tf += (e - Tf) / Ha, Ef += (t - Ef) / Ha, Nf += (n - Nf) / Ha;
}
function Fb() {
  kn.point = xB;
}
function xB(e, t) {
  e *= Dt, t *= Dt;
  var n = ot(t);
  Oe = n * ot(e), Le = n * tt(e), ke = tt(t), kn.point = SB, su(Oe, Le, ke);
}
function SB(e, t) {
  e *= Dt, t *= Dt;
  var n = ot(t), r = n * ot(e), i = n * tt(e), s = tt(t), o = Un(Ce((o = Le * s - ke * i) * o + (o = ke * r - Oe * s) * o + (o = Oe * i - Le * r) * o), Oe * r + Le * i + ke * s);
  If += o, Df += o * (Oe + (Oe = r)), Of += o * (Le + (Le = i)), Lf += o * (ke + (ke = s)), su(Oe, Le, ke);
}
function Rb() {
  kn.point = Mm;
}
function MB() {
  kn.point = $B;
}
function AB() {
  pS(hS, dS), kn.point = Mm;
}
function $B(e, t) {
  hS = e, dS = t, e *= Dt, t *= Dt, kn.point = pS;
  var n = ot(t);
  Oe = n * ot(e), Le = n * tt(e), ke = tt(t), su(Oe, Le, ke);
}
function pS(e, t) {
  e *= Dt, t *= Dt;
  var n = ot(t), r = n * ot(e), i = n * tt(e), s = tt(t), o = Le * s - ke * i, a = ke * r - Oe * s, c = Oe * i - Le * r, u = $0(o, a, c), l = Je(u), f = u && -l / u;
  N0.add(f * o), D0.add(f * a), O0.add(f * c), If += l, Df += l * (Oe + (Oe = r)), Of += l * (Le + (Le = i)), Lf += l * (ke + (ke = s)), su(Oe, Le, ke);
}
function IB(e) {
  Ha = If = Tf = Ef = Nf = Df = Of = Lf = 0, N0 = new hr(), D0 = new hr(), O0 = new hr(), bi(e, kn);
  var t = +N0, n = +D0, r = +O0, i = $0(t, n, r);
  return i < Sf && (t = Df, n = Of, r = Lf, If < nt && (t = Tf, n = Ef, r = Nf), i = $0(t, n, r), i < Sf) ? [NaN, NaN] : [Un(n, t) * _e, Je(r / i) * _e];
}
function L0(e, t) {
  function n(r, i) {
    return r = e(r, i), t(r[0], r[1]);
  }
  return e.invert && t.invert && (n.invert = function(r, i) {
    return r = t.invert(r, i), r && e.invert(r[0], r[1]);
  }), n;
}
function k0(e, t) {
  return Lt(e) > Mt && (e -= Math.round(e / cn) * cn), [e, t];
}
k0.invert = k0;
function yS(e, t, n) {
  return (e %= cn) ? t || n ? L0(Bb(e), Pb(t, n)) : Bb(e) : t || n ? Pb(t, n) : k0;
}
function Cb(e) {
  return function(t, n) {
    return t += e, Lt(t) > Mt && (t -= Math.round(t / cn) * cn), [t, n];
  };
}
function Bb(e) {
  var t = Cb(e);
  return t.invert = Cb(-e), t;
}
function Pb(e, t) {
  var n = ot(e), r = tt(e), i = ot(t), s = tt(t);
  function o(a, c) {
    var u = ot(c), l = ot(a) * u, f = tt(a) * u, h = tt(c), d = h * n + l * r;
    return [
      Un(f * i - d * s, l * n - h * r),
      Je(d * i + f * s)
    ];
  }
  return o.invert = function(a, c) {
    var u = ot(c), l = ot(a) * u, f = tt(a) * u, h = tt(c), d = h * i - f * s;
    return [
      Un(f * i + h * s, l * n + d * r),
      Je(d * n - l * r)
    ];
  }, o;
}
function TB(e) {
  e = yS(e[0] * Dt, e[1] * Dt, e.length > 2 ? e[2] * Dt : 0);
  function t(n) {
    return n = e(n[0] * Dt, n[1] * Dt), n[0] *= _e, n[1] *= _e, n;
  }
  return t.invert = function(n) {
    return n = e.invert(n[0] * Dt, n[1] * Dt), n[0] *= _e, n[1] *= _e, n;
  }, t;
}
function EB(e, t, n, r, i, s) {
  if (n) {
    var o = ot(t), a = tt(t), c = r * n;
    i == null ? (i = t + r * cn, s = t - c / 2) : (i = Ub(o, i), s = Ub(o, s), (r > 0 ? i < s : i > s) && (i += r * cn));
    for (var u, l = i; r > 0 ? l > s : l < s; l -= c)
      u = T0([o, -a * ot(l), -a * tt(l)]), e.point(u[0], u[1]);
  }
}
function Ub(e, t) {
  t = ta(t), t[0] -= e, E0(t);
  var n = fS(-t[1]);
  return ((-t[2] < 0 ? -n : n) + cn - nt) % cn;
}
function mS() {
  var e = [], t;
  return {
    point: function(n, r, i) {
      t.push([n, r, i]);
    },
    lineStart: function() {
      e.push(t = []);
    },
    lineEnd: rn,
    rejoin: function() {
      e.length > 1 && e.push(e.pop().concat(e.shift()));
    },
    result: function() {
      var n = e;
      return e = [], t = null, n;
    }
  };
}
function Tl(e, t) {
  return Lt(e[0] - t[0]) < nt && Lt(e[1] - t[1]) < nt;
}
function Ju(e, t, n, r) {
  this.x = e, this.z = t, this.o = n, this.e = r, this.v = !1, this.n = this.p = null;
}
function gS(e, t, n, r, i) {
  var s = [], o = [], a, c;
  if (e.forEach(function(p) {
    if (!((y = p.length - 1) <= 0)) {
      var y, g = p[0], m = p[y], b;
      if (Tl(g, m)) {
        if (!g[2] && !m[2]) {
          for (i.lineStart(), a = 0; a < y; ++a)
            i.point((g = p[a])[0], g[1]);
          i.lineEnd();
          return;
        }
        m[0] += 2 * nt;
      }
      s.push(b = new Ju(g, p, null, !0)), o.push(b.o = new Ju(g, null, b, !1)), s.push(b = new Ju(m, p, null, !1)), o.push(b.o = new Ju(m, null, b, !0));
    }
  }), !!s.length) {
    for (o.sort(t), zb(s), zb(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, i.lineStart();
      do {
        if (h.v = h.o.v = !0, h.e) {
          if (d)
            for (a = 0, c = l.length; a < c; ++a)
              i.point((f = l[a])[0], f[1]);
          else
            r(h.x, h.n.x, 1, i);
          h = h.n;
        } else {
          if (d)
            for (l = h.p.z, a = l.length - 1; a >= 0; --a)
              i.point((f = l[a])[0], f[1]);
          else
            r(h.x, h.p.x, -1, i);
          h = h.p;
        }
        h = h.o, l = h.z, d = !d;
      } while (!h.v);
      i.lineEnd();
    }
  }
}
function zb(e) {
  if (t = e.length) {
    for (var t, n = 0, r = e[0], i; ++n < t; )
      r.n = i = e[n], i.p = r, r = i;
    r.n = i = e[0], i.p = r;
  }
}
function op(e) {
  return Lt(e[0]) <= Mt ? e[0] : gn(e[0]) * ((Lt(e[0]) + Mt) % cn - Mt);
}
function NB(e, t) {
  var n = op(t), r = t[1], i = tt(r), s = [tt(n), -ot(n), 0], o = 0, a = 0, c = new hr();
  i === 1 ? r = oe + nt : i === -1 && (r = -oe - nt);
  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 = op(d), y = d[1] / 2 + Db, g = tt(y), m = ot(y), b = 0; b < h; ++b, p = v, g = _, m = M, d = w) {
        var w = f[b], v = op(w), x = w[1] / 2 + Db, _ = tt(x), M = ot(x), T = v - p, N = T >= 0 ? 1 : -1, A = N * T, $ = A > Mt, D = g * _;
        if (c.add(Un(D * N * tt(A), m * M + D * ot(A))), o += $ ? T + N * cn : T, $ ^ p >= n ^ v >= n) {
          var F = $f(ta(d), ta(w));
          E0(F);
          var S = $f(s, F);
          E0(S);
          var I = ($ ^ T >= 0 ? -1 : 1) * Je(S[2]);
          (r > I || r === I && (F[0] || F[1])) && (a += $ ^ T >= 0 ? 1 : -1);
        }
      }
  return (o < -nt || o < nt && c < -Sf) ^ a & 1;
}
function bS(e, t, n, r) {
  return function(i) {
    var s = t(i), o = mS(), a = t(o), c = !1, u, l, f, h = {
      point: d,
      lineStart: y,
      lineEnd: g,
      polygonStart: function() {
        h.point = m, h.lineStart = b, h.lineEnd = w, l = [], u = [];
      },
      polygonEnd: function() {
        h.point = d, h.lineStart = y, h.lineEnd = g, l = vx(l);
        var v = NB(u, r);
        l.length ? (c || (i.polygonStart(), c = !0), gS(l, OB, v, n, i)) : v && (c || (i.polygonStart(), c = !0), i.lineStart(), n(null, null, 1, i), i.lineEnd()), c && (i.polygonEnd(), c = !1), l = u = null;
      },
      sphere: function() {
        i.polygonStart(), i.lineStart(), n(null, null, 1, i), i.lineEnd(), i.polygonEnd();
      }
    };
    function d(v, x) {
      e(v, x) && i.point(v, x);
    }
    function p(v, x) {
      s.point(v, x);
    }
    function y() {
      h.point = p, s.lineStart();
    }
    function g() {
      h.point = d, s.lineEnd();
    }
    function m(v, x) {
      f.push([v, x]), a.point(v, x);
    }
    function b() {
      a.lineStart(), f = [];
    }
    function w() {
      m(f[0][0], f[0][1]), a.lineEnd();
      var v = a.clean(), x = o.result(), _, M = x.length, T, N, A;
      if (f.pop(), u.push(f), f = null, !!M) {
        if (v & 1) {
          if (N = x[0], (T = N.length - 1) > 0) {
            for (c || (i.polygonStart(), c = !0), i.lineStart(), _ = 0; _ < T; ++_)
              i.point((A = N[_])[0], A[1]);
            i.lineEnd();
          }
          return;
        }
        M > 1 && v & 2 && x.push(x.pop().concat(x.shift())), l.push(x.filter(DB));
      }
    }
    return h;
  };
}
function DB(e) {
  return e.length > 1;
}
function OB(e, t) {
  return ((e = e.x)[0] < 0 ? e[1] - oe - nt : oe - e[1]) - ((t = t.x)[0] < 0 ? t[1] - oe - nt : oe - t[1]);
}
const jb = bS(
  function() {
    return !0;
  },
  LB,
  FB,
  [-Mt, -oe]
);
function LB(e) {
  var t = NaN, n = NaN, r = NaN, i;
  return {
    lineStart: function() {
      e.lineStart(), i = 1;
    },
    point: function(s, o) {
      var a = s > 0 ? Mt : -Mt, c = Lt(s - t);
      Lt(c - Mt) < nt ? (e.point(t, n = (n + o) / 2 > 0 ? oe : -oe), e.point(r, n), e.lineEnd(), e.lineStart(), e.point(a, n), e.point(s, n), i = 0) : r !== a && c >= Mt && (Lt(t - r) < nt && (t -= r * nt), Lt(s - a) < nt && (s -= a * nt), n = kB(t, n, s, o), e.point(r, n), e.lineEnd(), e.lineStart(), e.point(a, n), i = 0), e.point(t = s, n = o), r = a;
    },
    lineEnd: function() {
      e.lineEnd(), t = n = NaN;
    },
    clean: function() {
      return 2 - i;
    }
  };
}
function kB(e, t, n, r) {
  var i, s, o = tt(e - n);
  return Lt(o) > nt ? va((tt(t) * (s = ot(r)) * tt(n) - tt(r) * (i = ot(t)) * tt(e)) / (i * s * o)) : (t + r) / 2;
}
function FB(e, t, n, r) {
  var i;
  if (e == null)
    i = n * oe, r.point(-Mt, i), r.point(0, i), r.point(Mt, i), r.point(Mt, 0), r.point(Mt, -i), r.point(0, -i), r.point(-Mt, -i), r.point(-Mt, 0), r.point(-Mt, i);
  else if (Lt(e[0] - t[0]) > nt) {
    var s = e[0] < t[0] ? Mt : -Mt;
    i = n * s / 2, r.point(-s, i), r.point(0, i), r.point(s, i);
  } else
    r.point(t[0], t[1]);
}
function RB(e) {
  var t = ot(e), n = 6 * Dt, r = t > 0, i = Lt(t) > nt;
  function s(l, f, h, d) {
    EB(d, e, n, h, l, f);
  }
  function o(l, f) {
    return ot(l) * ot(f) > t;
  }
  function a(l) {
    var f, h, d, p, y;
    return {
      lineStart: function() {
        p = d = !1, y = 1;
      },
      point: function(g, m) {
        var b = [g, m], w, v = o(g, m), x = r ? v ? 0 : u(g, m) : v ? u(g + (g < 0 ? Mt : -Mt), m) : 0;
        if (!f && (p = d = v) && l.lineStart(), v !== d && (w = c(f, b), (!w || Tl(f, w) || Tl(b, w)) && (b[2] = 1)), v !== d)
          y = 0, v ? (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 (i && f && r ^ v) {
          var _;
          !(x & h) && (_ = c(b, f, !0)) && (y = 0, r ? (l.lineStart(), l.point(_[0][0], _[0][1]), l.point(_[1][0], _[1][1]), l.lineEnd()) : (l.point(_[1][0], _[1][1]), l.lineEnd(), l.lineStart(), l.point(_[0][0], _[0][1], 3)));
        }
        v && (!f || !Tl(f, b)) && l.point(b[0], b[1]), f = b, d = v, 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 y | (p && d) << 1;
      }
    };
  }
  function c(l, f, h) {
    var d = ta(l), p = ta(f), y = [1, 0, 0], g = $f(d, p), m = Gu(g, g), b = g[0], w = m - b * b;
    if (!w)
      return !h && l;
    var v = t * m / w, x = -t * b / w, _ = $f(y, g), M = Hu(y, v), T = Hu(g, x);
    sp(M, T);
    var N = _, A = Gu(M, N), $ = Gu(N, N), D = A * A - $ * (Gu(M, M) - 1);
    if (!(D < 0)) {
      var F = Ce(D), S = Hu(N, (-A - F) / $);
      if (sp(S, M), S = T0(S), !h)
        return S;
      var I = l[0], E = f[0], O = l[1], C = f[1], B;
      E < I && (B = I, I = E, E = B);
      var R = E - I, P = Lt(R - Mt) < nt, U = P || R < nt;
      if (!P && C < O && (B = O, O = C, C = B), U ? P ? O + C > 0 ^ S[1] < (Lt(S[0] - I) < nt ? O : C) : O <= S[1] && S[1] <= C : R > Mt ^ (I <= S[0] && S[0] <= E)) {
        var Y = Hu(N, (-A + F) / $);
        return sp(Y, M), [S, T0(Y)];
      }
    }
  }
  function u(l, f) {
    var h = r ? e : Mt - e, d = 0;
    return l < -h ? d |= 1 : l > h && (d |= 2), f < -h ? d |= 4 : f > h && (d |= 8), d;
  }
  return bS(o, a, s, r ? [0, -e] : [-Mt, e - Mt]);
}
function CB(e, t, n, r, i, 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 = i - 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 = r - 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 Ja = 1e9, Zu = -Ja;
function wS(e, t, n, r) {
  function i(u, l) {
    return e <= u && u <= n && t <= l && l <= r;
  }
  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 ? r : t);
      while ((d = (d + f + 4) % 4) !== p);
    else
      h.point(l[0], l[1]);
  }
  function o(u, l) {
    return Lt(u[0] - e) < nt ? l > 0 ? 0 : 3 : Lt(u[0] - n) < nt ? l > 0 ? 2 : 1 : Lt(u[1] - t) < nt ? 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 = mS(), h, d, p, y, g, m, b, w, v, x, _, M = {
      point: T,
      lineStart: D,
      lineEnd: F,
      polygonStart: A,
      polygonEnd: $
    };
    function T(I, E) {
      i(I, E) && l.point(I, E);
    }
    function N() {
      for (var I = 0, E = 0, O = d.length; E < O; ++E)
        for (var C = d[E], B = 1, R = C.length, P = C[0], U, Y, G = P[0], Z = P[1]; B < R; ++B)
          U = G, Y = Z, P = C[B], G = P[0], Z = P[1], Y <= r ? Z > r && (G - U) * (r - Y) > (Z - Y) * (e - U) && ++I : Z <= r && (G - U) * (r - Y) < (Z - Y) * (e - U) && --I;
      return I;
    }
    function A() {
      l = f, h = [], d = [], _ = !0;
    }
    function $() {
      var I = N(), E = _ && I, O = (h = vx(h)).length;
      (E || O) && (u.polygonStart(), E && (u.lineStart(), s(null, null, 1, u), u.lineEnd()), O && gS(h, a, I, s, u), u.polygonEnd()), l = u, h = d = p = null;
    }
    function D() {
      M.point = S, d && d.push(p = []), x = !0, v = !1, b = w = NaN;
    }
    function F() {
      h && (S(y, g), m && v && f.rejoin(), h.push(f.result())), M.point = T, v && l.lineEnd();
    }
    function S(I, E) {
      var O = i(I, E);
      if (d && p.push([I, E]), x)
        y = I, g = E, m = O, x = !1, O && (l.lineStart(), l.point(I, E));
      else if (O && v)
        l.point(I, E);
      else {
        var C = [b = Math.max(Zu, Math.min(Ja, b)), w = Math.max(Zu, Math.min(Ja, w))], B = [I = Math.max(Zu, Math.min(Ja, I)), E = Math.max(Zu, Math.min(Ja, E))];
        CB(C, B, e, t, n, r) ? (v || (l.lineStart(), l.point(C[0], C[1])), l.point(B[0], B[1]), O || l.lineEnd(), _ = !1) : O && (l.lineStart(), l.point(I, E), _ = !1);
      }
      b = I, w = E, v = O;
    }
    return M;
  };
}
function qb(e, t, n) {
  var r = nn(e, t - nt, n).concat(t);
  return function(i) {
    return r.map(function(s) {
      return [i, s];
    });
  };
}
function Vb(e, t, n) {
  var r = nn(e, t - nt, n).concat(t);
  return function(i) {
    return r.map(function(s) {
      return [s, i];
    });
  };
}
function BB() {
  var e, t, n, r, i, s, o, a, c = 10, u = c, l = 90, f = 360, h, d, p, y, g = 2.5;
  function m() {
    return { type: "MultiLineString", coordinates: b() };
  }
  function b() {
    return nn(Xu(r / l) * l, n, l).map(p).concat(nn(Xu(a / f) * f, o, f).map(y)).concat(nn(Xu(t / c) * c, e, c).filter(function(w) {
      return Lt(w % l) > nt;
    }).map(h)).concat(nn(Xu(s / u) * u, i, u).filter(function(w) {
      return Lt(w % f) > nt;
    }).map(d));
  }
  return m.lines = function() {
    return b().map(function(w) {
      return { type: "LineString", coordinates: w };
    });
  }, m.outline = function() {
    return {
      type: "Polygon",
      coordinates: [
        p(r).concat(
          y(o).slice(1),
          p(n).reverse().slice(1),
          y(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 ? (r = +w[0][0], n = +w[1][0], a = +w[0][1], o = +w[1][1], r > n && (w = r, r = n, n = w), a > o && (w = a, a = o, o = w), m.precision(g)) : [[r, a], [n, o]];
  }, m.extentMinor = function(w) {
    return arguments.length ? (t = +w[0][0], e = +w[1][0], s = +w[0][1], i = +w[1][1], t > e && (w = t, t = e, e = w), s > i && (w = s, s = i, i = w), m.precision(g)) : [[t, s], [e, i]];
  }, 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 ? (g = +w, h = qb(s, i, 90), d = Vb(t, e, g), p = qb(a, o, 90), y = Vb(r, n, g), m) : g;
  }, m.extentMajor([[-180, -90 + nt], [180, 90 - nt]]).extentMinor([[-180, -80 - nt], [180, 80 + nt]]);
}
function PB() {
  return BB()();
}
const F0 = (e) => e;
var ap = new hr(), R0 = new hr(), vS, _S, C0, B0, wi = {
  point: rn,
  lineStart: rn,
  lineEnd: rn,
  polygonStart: function() {
    wi.lineStart = UB, wi.lineEnd = jB;
  },
  polygonEnd: function() {
    wi.lineStart = wi.lineEnd = wi.point = rn, ap.add(Lt(R0)), R0 = new hr();
  },
  result: function() {
    var e = ap / 2;
    return ap = new hr(), e;
  }
};
function UB() {
  wi.point = zB;
}
function zB(e, t) {
  wi.point = xS, vS = C0 = e, _S = B0 = t;
}
function xS(e, t) {
  R0.add(B0 * e - C0 * t), C0 = e, B0 = t;
}
function jB() {
  xS(vS, _S);
}
const Yb = wi;
var ea = 1 / 0, kf = ea, Oc = -ea, Ff = Oc, qB = {
  point: VB,
  lineStart: rn,
  lineEnd: rn,
  polygonStart: rn,
  polygonEnd: rn,
  result: function() {
    var e = [[ea, kf], [Oc, Ff]];
    return Oc = Ff = -(kf = ea = 1 / 0), e;
  }
};
function VB(e, t) {
  e < ea && (ea = e), e > Oc && (Oc = e), t < kf && (kf = t), t > Ff && (Ff = t);
}
const Rf = qB;
var P0 = 0, U0 = 0, Za = 0, Cf = 0, Bf = 0, wo = 0, z0 = 0, j0 = 0, Ka = 0, SS, MS, ar, cr, Ln = {
  point: Us,
  lineStart: Wb,
  lineEnd: Xb,
  polygonStart: function() {
    Ln.lineStart = XB, Ln.lineEnd = GB;
  },
  polygonEnd: function() {
    Ln.point = Us, Ln.lineStart = Wb, Ln.lineEnd = Xb;
  },
  result: function() {
    var e = Ka ? [z0 / Ka, j0 / Ka] : wo ? [Cf / wo, Bf / wo] : Za ? [P0 / Za, U0 / Za] : [NaN, NaN];
    return P0 = U0 = Za = Cf = Bf = wo = z0 = j0 = Ka = 0, e;
  }
};
function Us(e, t) {
  P0 += e, U0 += t, ++Za;
}
function Wb() {
  Ln.point = YB;
}
function YB(e, t) {
  Ln.point = WB, Us(ar = e, cr = t);
}
function WB(e, t) {
  var n = e - ar, r = t - cr, i = Ce(n * n + r * r);
  Cf += i * (ar + e) / 2, Bf += i * (cr + t) / 2, wo += i, Us(ar = e, cr = t);
}
function Xb() {
  Ln.point = Us;
}
function XB() {
  Ln.point = HB;
}
function GB() {
  AS(SS, MS);
}
function HB(e, t) {
  Ln.point = AS, Us(SS = ar = e, MS = cr = t);
}
function AS(e, t) {
  var n = e - ar, r = t - cr, i = Ce(n * n + r * r);
  Cf += i * (ar + e) / 2, Bf += i * (cr + t) / 2, wo += i, i = cr * e - ar * t, z0 += i * (ar + e), j0 += i * (cr + t), Ka += i * 3, Us(ar = e, cr = t);
}
const Gb = Ln;
function $S(e) {
  this._context = e;
}
$S.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, cn);
        break;
      }
    }
  },
  result: rn
};
var q0 = new hr(), cp, IS, TS, Qa, tc, Pf = {
  point: rn,
  lineStart: function() {
    Pf.point = JB;
  },
  lineEnd: function() {
    cp && ES(IS, TS), Pf.point = rn;
  },
  polygonStart: function() {
    cp = !0;
  },
  polygonEnd: function() {
    cp = null;
  },
  result: function() {
    var e = +q0;
    return q0 = new hr(), e;
  }
};
function JB(e, t) {
  Pf.point = ES, IS = Qa = e, TS = tc = t;
}
function ES(e, t) {
  Qa -= e, tc -= t, q0.add(Ce(Qa * Qa + tc * tc)), Qa = e, tc = t;
}
const Hb = Pf;
let Jb, Uf, Zb, Kb;
class Qb {
  constructor(t) {
    this._append = t == null ? NS : ZB(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 !== Zb || this._append !== Uf) {
          const r = this._radius, i = this._;
          this._ = "", this._append`m0,${r}a${r},${r} 0 1,1 0,${-2 * r}a${r},${r} 0 1,1 0,${2 * r}z`, Zb = r, Uf = this._append, Kb = this._, this._ = i;
        }
        this._ += Kb;
        break;
      }
    }
  }
  result() {
    const t = this._;
    return this._ = "", t.length ? t : null;
  }
}
function NS(e) {
  let t = 1;
  this._ += e[0];
  for (const n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function ZB(e) {
  const t = Math.floor(e);
  if (!(t >= 0))
    throw new RangeError(`invalid digits: ${e}`);
  if (t > 15)
    return NS;
  if (t !== Jb) {
    const n = 10 ** t;
    Jb = t, Uf = function(i) {
      let s = 1;
      this._ += i[0];
      for (const o = i.length; s < o; ++s)
        this._ += Math.round(arguments[s] * n) / n + i[s];
    };
  }
  return Uf;
}
function Gi(e, t) {
  let n = 3, r = 4.5, i, s;
  function o(a) {
    return a && (typeof r == "function" && s.pointRadius(+r.apply(this, arguments)), bi(a, i(s))), s.result();
  }
  return o.area = function(a) {
    return bi(a, i(Yb)), Yb.result();
  }, o.measure = function(a) {
    return bi(a, i(Hb)), Hb.result();
  }, o.bounds = function(a) {
    return bi(a, i(Rf)), Rf.result();
  }, o.centroid = function(a) {
    return bi(a, i(Gb)), Gb.result();
  }, o.projection = function(a) {
    return arguments.length ? (i = a == null ? (e = null, F0) : (e = a).stream, o) : e;
  }, o.context = function(a) {
    return arguments.length ? (s = a == null ? (t = null, new Qb(n)) : new $S(t = a), typeof r != "function" && s.pointRadius(r), o) : t;
  }, o.pointRadius = function(a) {
    return arguments.length ? (r = typeof a == "function" ? a : (s.pointRadius(+a), +a), o) : r;
  }, 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 Qb(n)), o;
  }, o.projection(e).digits(n).context(t);
}
function zf(e) {
  return {
    stream: Vh(e)
  };
}
function Vh(e) {
  return function(t) {
    var n = new V0();
    for (var r in e)
      n[r] = e[r];
    return n.stream = t, n;
  };
}
function V0() {
}
V0.prototype = {
  constructor: V0,
  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 Am(e, t, n) {
  var r = e.clipExtent && e.clipExtent();
  return e.scale(150).translate([0, 0]), r != null && e.clipExtent(null), bi(n, e.stream(Rf)), t(Rf.result()), r != null && e.clipExtent(r), e;
}
function $m(e, t, n) {
  return Am(e, function(r) {
    var i = t[1][0] - t[0][0], s = t[1][1] - t[0][1], o = Math.min(i / (r[1][0] - r[0][0]), s / (r[1][1] - r[0][1])), a = +t[0][0] + (i - o * (r[1][0] + r[0][0])) / 2, c = +t[0][1] + (s - o * (r[1][1] + r[0][1])) / 2;
    e.scale(150 * o).translate([a, c]);
  }, n);
}
function DS(e, t, n) {
  return $m(e, [[0, 0], t], n);
}
function OS(e, t, n) {
  return Am(e, function(r) {
    var i = +t, s = i / (r[1][0] - r[0][0]), o = (i - s * (r[1][0] + r[0][0])) / 2, a = -s * r[0][1];
    e.scale(150 * s).translate([o, a]);
  }, n);
}
function LS(e, t, n) {
  return Am(e, function(r) {
    var i = +t, s = i / (r[1][1] - r[0][1]), o = -s * r[0][0], a = (i - s * (r[1][1] + r[0][1])) / 2;
    e.scale(150 * s).translate([o, a]);
  }, n);
}
var tw = 16, KB = ot(30 * Dt);
function ew(e, t) {
  return +t ? tP(e, t) : QB(e);
}
function QB(e) {
  return Vh({
    point: function(t, n) {
      t = e(t, n), this.stream.point(t[0], t[1]);
    }
  });
}
function tP(e, t) {
  function n(r, i, s, o, a, c, u, l, f, h, d, p, y, g) {
    var m = u - r, b = l - i, w = m * m + b * b;
    if (w > 4 * t && y--) {
      var v = o + h, x = a + d, _ = c + p, M = Ce(v * v + x * x + _ * _), T = Je(_ /= M), N = Lt(Lt(_) - 1) < nt || Lt(s - f) < nt ? (s + f) / 2 : Un(x, v), A = e(N, T), $ = A[0], D = A[1], F = $ - r, S = D - i, I = b * F - m * S;
      (I * I / w > t || Lt((m * F + b * S) / w - 0.5) > 0.3 || o * h + a * d + c * p < KB) && (n(r, i, s, o, a, c, $, D, N, v /= M, x /= M, _, y, g), g.point($, D), n($, D, N, v, x, _, u, l, f, h, d, p, y, g));
    }
  }
  return function(r) {
    var i, s, o, a, c, u, l, f, h, d, p, y, g = {
      point: m,
      lineStart: b,
      lineEnd: v,
      polygonStart: function() {
        r.polygonStart(), g.lineStart = x;
      },
      polygonEnd: function() {
        r.polygonEnd(), g.lineStart = b;
      }
    };
    function m(T, N) {
      T = e(T, N), r.point(T[0], T[1]);
    }
    function b() {
      f = NaN, g.point = w, r.lineStart();
    }
    function w(T, N) {
      var A = ta([T, N]), $ = e(T, N);
      n(f, h, l, d, p, y, f = $[0], h = $[1], l = T, d = A[0], p = A[1], y = A[2], tw, r), r.point(f, h);
    }
    function v() {
      g.point = m, r.lineEnd();
    }
    function x() {
      b(), g.point = _, g.lineEnd = M;
    }
    function _(T, N) {
      w(i = T, N), s = f, o = h, a = d, c = p, u = y, g.point = w;
    }
    function M() {
      n(f, h, l, d, p, y, s, o, i, a, c, u, tw, r), g.lineEnd = v, v();
    }
    return g;
  };
}
var eP = Vh({
  point: function(e, t) {
    this.stream.point(e * Dt, t * Dt);
  }
});
function nP(e) {
  return Vh({
    point: function(t, n) {
      var r = e(t, n);
      return this.stream.point(r[0], r[1]);
    }
  });
}
function rP(e, t, n, r, i) {
  function s(o, a) {
    return o *= r, a *= i, [t + e * o, n - e * a];
  }
  return s.invert = function(o, a) {
    return [(o - t) / e * r, (n - a) / e * i];
  }, s;
}
function nw(e, t, n, r, i, s) {
  if (!s)
    return rP(e, t, n, r, i);
  var o = ot(s), a = tt(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(y, g) {
    return y *= r, g *= i, [c * y - u * g + t, n - u * y - c * g];
  }
  return p.invert = function(y, g) {
    return [r * (l * y - f * g + h), i * (d - f * y - l * g)];
  }, p;
}
function Hi(e) {
  return kS(function() {
    return e;
  })();
}
function kS(e) {
  var t, n = 150, r = 480, i = 250, s = 0, o = 0, a = 0, c = 0, u = 0, l, f = 0, h = 1, d = 1, p = null, y = jb, g = null, m, b, w, v = F0, x = 0.5, _, M, T, N, A;
  function $(I) {
    return T(I[0] * Dt, I[1] * Dt);
  }
  function D(I) {
    return I = T.invert(I[0], I[1]), I && [I[0] * _e, I[1] * _e];
  }
  $.stream = function(I) {
    return N && A === I ? N : N = eP(nP(l)(y(_(v(A = I)))));
  }, $.preclip = function(I) {
    return arguments.length ? (y = I, p = void 0, S()) : y;
  }, $.postclip = function(I) {
    return arguments.length ? (v = I, g = m = b = w = null, S()) : v;
  }, $.clipAngle = function(I) {
    return arguments.length ? (y = +I ? RB(p = I * Dt) : (p = null, jb), S()) : p * _e;
  }, $.clipExtent = function(I) {
    return arguments.length ? (v = I == null ? (g = m = b = w = null, F0) : wS(g = +I[0][0], m = +I[0][1], b = +I[1][0], w = +I[1][1]), S()) : g == null ? null : [[g, m], [b, w]];
  }, $.scale = function(I) {
    return arguments.length ? (n = +I, F()) : n;
  }, $.translate = function(I) {
    return arguments.length ? (r = +I[0], i = +I[1], F()) : [r, i];
  }, $.center = function(I) {
    return arguments.length ? (s = I[0] % 360 * Dt, o = I[1] % 360 * Dt, F()) : [s * _e, o * _e];
  }, $.rotate = function(I) {
    return arguments.length ? (a = I[0] % 360 * Dt, c = I[1] % 360 * Dt, u = I.length > 2 ? I[2] % 360 * Dt : 0, F()) : [a * _e, c * _e, u * _e];
  }, $.angle = function(I) {
    return arguments.length ? (f = I % 360 * Dt, F()) : f * _e;
  }, $.reflectX = function(I) {
    return arguments.length ? (h = I ? -1 : 1, F()) : h < 0;
  }, $.reflectY = function(I) {
    return arguments.length ? (d = I ? -1 : 1, F()) : d < 0;
  }, $.precision = function(I) {
    return arguments.length ? (_ = ew(M, x = I * I), S()) : Ce(x);
  }, $.fitExtent = function(I, E) {
    return $m($, I, E);
  }, $.fitSize = function(I, E) {
    return DS($, I, E);
  }, $.fitWidth = function(I, E) {
    return OS($, I, E);
  }, $.fitHeight = function(I, E) {
    return LS($, I, E);
  };
  function F() {
    var I = nw(n, 0, 0, h, d, f).apply(null, t(s, o)), E = nw(n, r - I[0], i - I[1], h, d, f);
    return l = yS(a, c, u), M = L0(t, E), T = L0(l, M), _ = ew(M, x), S();
  }
  function S() {
    return N = A = null, $;
  }
  return function() {
    return t = e.apply(this, arguments), $.invert = t.invert && D, F();
  };
}
function Im(e) {
  var t = 0, n = Mt / 3, r = kS(e), i = r(t, n);
  return i.parallels = function(s) {
    return arguments.length ? r(t = s[0] * Dt, n = s[1] * Dt) : [t * _e, n * _e];
  }, i;
}
function iP(e) {
  var t = ot(e);
  function n(r, i) {
    return [r * t, tt(i) / t];
  }
  return n.invert = function(r, i) {
    return [r / t, Je(i * t)];
  }, n;
}
function sP(e, t) {
  var n = tt(e), r = (n + tt(t)) / 2;
  if (Lt(r) < nt)
    return iP(e);
  var i = 1 + n * (2 * r - n), s = Ce(i) / r;
  function o(a, c) {
    var u = Ce(i - 2 * r * tt(c)) / r;
    return [u * tt(a *= r), s - u * ot(a)];
  }
  return o.invert = function(a, c) {
    var u = s - c, l = Un(a, Lt(u)) * gn(u);
    return u * r < 0 && (l -= Mt * gn(a) * gn(u)), [l / r, Je((i - (a * a + u * u) * r * r) / (2 * r))];
  }, o;
}
function jf() {
  return Im(sP).scale(155.424).center([0, 33.6442]);
}
function FS() {
  return jf().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
}
function oP(e) {
  var t = e.length;
  return {
    point: function(n, r) {
      for (var i = -1; ++i < t; )
        e[i].point(n, r);
    },
    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 aP() {
  var e, t, n = FS(), r, i = jf().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), s, o = jf().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, r.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(), y = (h[0] - p[0]) / d, g = (h[1] - p[1]) / d;
    return (g >= 0.12 && g < 0.234 && y >= -0.425 && y < -0.214 ? i : g >= 0.166 && g < 0.234 && y >= -0.214 && y < -0.115 ? o : n).invert(h);
  }, l.stream = function(h) {
    return e && t === h ? e : e = oP([n.stream(t = h), i.stream(h), o.stream(h)]);
  }, l.precision = function(h) {
    return arguments.length ? (n.precision(h), i.precision(h), o.precision(h), f()) : n.precision();
  }, l.scale = function(h) {
    return arguments.length ? (n.scale(h), i.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], y = +h[1];
    return r = n.translate(h).clipExtent([[p - 0.455 * d, y - 0.238 * d], [p + 0.455 * d, y + 0.238 * d]]).stream(u), s = i.translate([p - 0.307 * d, y + 0.201 * d]).clipExtent([[p - 0.425 * d + nt, y + 0.12 * d + nt], [p - 0.214 * d - nt, y + 0.234 * d - nt]]).stream(u), a = o.translate([p - 0.205 * d, y + 0.212 * d]).clipExtent([[p - 0.214 * d + nt, y + 0.166 * d + nt], [p - 0.115 * d - nt, y + 0.234 * d - nt]]).stream(u), f();
  }, l.fitExtent = function(h, d) {
    return $m(l, h, d);
  }, l.fitSize = function(h, d) {
    return DS(l, h, d);
  }, l.fitWidth = function(h, d) {
    return OS(l, h, d);
  }, l.fitHeight = function(h, d) {
    return LS(l, h, d);
  };
  function f() {
    return e = t = null, l;
  }
  return l.scale(1070);
}
function RS(e) {
  return function(t, n) {
    var r = ot(t), i = ot(n), s = e(r * i);
    return s === 1 / 0 ? [2, 0] : [
      s * i * tt(t),
      s * tt(n)
    ];
  };
}
function ou(e) {
  return function(t, n) {
    var r = Ce(t * t + n * n), i = e(r), s = tt(i), o = ot(i);
    return [
      Un(t * s, r * o),
      Je(r && n * s / r)
    ];
  };
}
var CS = RS(function(e) {
  return Ce(2 / (1 + e));
});
CS.invert = ou(function(e) {
  return 2 * Je(e / 2);
});
function cP() {
  return Hi(CS).scale(124.75).clipAngle(180 - 1e-3);
}
var BS = RS(function(e) {
  return (e = fS(e)) && e / tt(e);
});
BS.invert = ou(function(e) {
  return e;
});
function uP() {
  return Hi(BS).scale(79.4188).clipAngle(180 - 1e-3);
}
function Yh(e, t) {
  return [e, Mf(Sm((oe + t) / 2))];
}
Yh.invert = function(e, t) {
  return [e, 2 * va(lS(t)) - oe];
};
function lP() {
  return PS(Yh).scale(961 / cn);
}
function PS(e) {
  var t = Hi(e), n = t.center, r = t.scale, i = t.translate, s = t.clipExtent, o = null, a, c, u;
  t.scale = function(f) {
    return arguments.length ? (r(f), l()) : r();
  }, t.translate = function(f) {
    return arguments.length ? (i(f), l()) : i();
  }, 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 = Mt * r(), h = t(TB(t.rotate()).invert([0, 0]));
    return s(o == null ? [[h[0] - f, h[1] - f], [h[0] + f, h[1] + f]] : e === Yh ? [[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 Ku(e) {
  return Sm((oe + e) / 2);
}
function fP(e, t) {
  var n = ot(e), r = e === t ? tt(e) : Mf(n / ot(t)) / Mf(Ku(t) / Ku(e)), i = n * ip(Ku(e), r) / r;
  if (!r)
    return Yh;
  function s(o, a) {
    i > 0 ? a < -oe + nt && (a = -oe + nt) : a > oe - nt && (a = oe - nt);
    var c = i / ip(Ku(a), r);
    return [c * tt(r * o), i - c * ot(r * o)];
  }
  return s.invert = function(o, a) {
    var c = i - a, u = gn(r) * Ce(o * o + c * c), l = Un(o, Lt(c)) * gn(c);
    return c * r < 0 && (l -= Mt * gn(o) * gn(c)), [l / r, 2 * va(ip(i / u, 1 / r)) - oe];
  }, s;
}
function hP() {
  return Im(fP).scale(109.5).parallels([30, 30]);
}
function qf(e, t) {
  return [e, t];
}
qf.invert = qf;
function dP() {
  return Hi(qf).scale(152.63);
}
function pP(e, t) {
  var n = ot(e), r = e === t ? tt(e) : (n - ot(t)) / (t - e), i = n / r + e;
  if (Lt(r) < nt)
    return qf;
  function s(o, a) {
    var c = i - a, u = r * o;
    return [c * tt(u), i - c * ot(u)];
  }
  return s.invert = function(o, a) {
    var c = i - a, u = Un(o, Lt(c)) * gn(c);
    return c * r < 0 && (u -= Mt * gn(o) * gn(c)), [u / r, i - gn(r) * Ce(o * o + c * c)];
  }, s;
}
function yP() {
  return Im(pP).scale(131.154).center([0, 13.9389]);
}
var ic = 1.340264, sc = -0.081106, oc = 893e-6, ac = 3796e-6, Vf = Ce(3) / 2, mP = 12;
function US(e, t) {
  var n = Je(Vf * tt(t)), r = n * n, i = r * r * r;
  return [
    e * ot(n) / (Vf * (ic + 3 * sc * r + i * (7 * oc + 9 * ac * r))),
    n * (ic + sc * r + i * (oc + ac * r))
  ];
}
US.invert = function(e, t) {
  for (var n = t, r = n * n, i = r * r * r, s = 0, o, a, c; s < mP && (a = n * (ic + sc * r + i * (oc + ac * r)) - t, c = ic + 3 * sc * r + i * (7 * oc + 9 * ac * r), n -= o = a / c, r = n * n, i = r * r * r, !(Lt(o) < Sf)); ++s)
    ;
  return [
    Vf * e * (ic + 3 * sc * r + i * (7 * oc + 9 * ac * r)) / ot(n),
    Je(tt(n) / Vf)
  ];
};
function gP() {
  return Hi(US).scale(177.158);
}
function zS(e, t) {
  var n = ot(t), r = ot(e) * n;
  return [n * tt(e) / r, tt(t) / r];
}
zS.invert = ou(va);
function bP() {
  return Hi(zS).scale(144.049).clipAngle(60);
}
function jS(e, t) {
  return [ot(t) * tt(e), tt(t)];
}
jS.invert = ou(Je);
function wP() {
  return Hi(jS).scale(249.5).clipAngle(90 + nt);
}
function qS(e, t) {
  var n = ot(t), r = 1 + ot(e) * n;
  return [n * tt(e) / r, tt(t) / r];
}
qS.invert = ou(function(e) {
  return 2 * va(e);
});
function vP() {
  return Hi(qS).scale(250).clipAngle(142);
}
function VS(e, t) {
  return [Mf(Sm((oe + t) / 2)), -e];
}
VS.invert = function(e, t) {
  return [-t, 2 * va(lS(e)) - oe];
};
function _P() {
  var e = PS(VS), t = e.center, n = e.rotate;
  return e.center = function(r) {
    return arguments.length ? t([-r[1], r[0]]) : (r = t(), [r[1], -r[0]]);
  }, e.rotate = function(r) {
    return arguments.length ? n([r[0], r[1], r.length > 2 ? r[2] + 90 : 90]) : (r = n(), [r[0], r[1], r[2] - 90]);
  }, n([0, 0, 90]).scale(159.155);
}
function xP(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function SP(e) {
  return e.reduce(MP, 0) / e.length;
}
function MP(e, t) {
  return e + t.x;
}
function AP(e) {
  return 1 + e.reduce($P, 0);
}
function $P(e, t) {
  return Math.max(e, t.y);
}
function IP(e) {
  for (var t; t = e.children; )
    e = t[0];
  return e;
}
function TP(e) {
  for (var t; t = e.children; )
    e = t[t.length - 1];
  return e;
}
function YS() {
  var e = xP, t = 1, n = 1, r = !1;
  function i(s) {
    var o, a = 0;
    s.eachAfter(function(h) {
      var d = h.children;
      d ? (h.x = SP(d), h.y = AP(d)) : (h.x = o ? a += e(h, o) : 0, h.y = 0, o = h);
    });
    var c = IP(s), u = TP(s), l = c.x - e(c, u) / 2, f = u.x + e(u, c) / 2;
    return s.eachAfter(r ? 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 i.separation = function(s) {
    return arguments.length ? (e = s, i) : e;
  }, i.size = function(s) {
    return arguments.length ? (r = !1, t = +s[0], n = +s[1], i) : r ? null : [t, n];
  }, i.nodeSize = function(s) {
    return arguments.length ? (r = !0, t = +s[0], n = +s[1], i) : r ? [t, n] : null;
  }, i;
}
function EP(e) {
  var t = 0, n = e.children, r = n && n.length;
  if (!r)
    t = 1;
  else
    for (; --r >= 0; )
      t += n[r].value;
  e.value = t;
}
function NP() {
  return this.eachAfter(EP);
}
function DP(e, t) {
  let n = -1;
  for (const r of this)
    e.call(t, r, ++n, this);
  return this;
}
function OP(e, t) {
  for (var n = this, r = [n], i, s, o = -1; n = r.pop(); )
    if (e.call(t, n, ++o, this), i = n.children)
      for (s = i.length - 1; s >= 0; --s)
        r.push(i[s]);
  return this;
}
function LP(e, t) {
  for (var n = this, r = [n], i = [], s, o, a, c = -1; n = r.pop(); )
    if (i.push(n), s = n.children)
      for (o = 0, a = s.length; o < a; ++o)
        r.push(s[o]);
  for (; n = i.pop(); )
    e.call(t, n, ++c, this);
  return this;
}
function kP(e, t) {
  let n = -1;
  for (const r of this)
    if (e.call(t, r, ++n, this))
      return r;
}
function FP(e) {
  return this.eachAfter(function(t) {
    for (var n = +e(t.data) || 0, r = t.children, i = r && r.length; --i >= 0; )
      n += r[i].value;
    t.value = n;
  });
}
function RP(e) {
  return this.eachBefore(function(t) {
    t.children && t.children.sort(e);
  });
}
function CP(e) {
  for (var t = this, n = BP(t, e), r = [t]; t !== n; )
    t = t.parent, r.push(t);
  for (var i = r.length; e !== n; )
    r.splice(i, 0, e), e = e.parent;
  return r;
}
function BP(e, t) {
  if (e === t)
    return e;
  var n = e.ancestors(), r = t.ancestors(), i = null;
  for (e = n.pop(), t = r.pop(); e === t; )
    i = e, e = n.pop(), t = r.pop();
  return i;
}
function PP() {
  for (var e = this, t = [e]; e = e.parent; )
    t.push(e);
  return t;
}
function UP() {
  return Array.from(this);
}
function zP() {
  var e = [];
  return this.eachBefore(function(t) {
    t.children || e.push(t);
  }), e;
}
function jP() {
  var e = this, t = [];
  return e.each(function(n) {
    n !== e && t.push({ source: n.parent, target: n });
  }), t;
}
function* qP() {
  var e = this, t, n = [e], r, i, s;
  do
    for (t = n.reverse(), n = []; e = t.pop(); )
      if (yield e, r = e.children)
        for (i = 0, s = r.length; i < s; ++i)
          n.push(r[i]);
  while (n.length);
}
function WS(e, t) {
  e instanceof Map ? (e = [void 0, e], t === void 0 && (t = WP)) : t === void 0 && (t = YP);
  for (var n = new na(e), r, i = [n], s, o, a, c; r = i.pop(); )
    if ((o = t(r.data)) && (c = (o = Array.from(o)).length))
      for (r.children = o, a = c - 1; a >= 0; --a)
        i.push(s = o[a] = new na(o[a])), s.parent = r, s.depth = r.depth + 1;
  return n.eachBefore(XS);
}
function VP() {
  return WS(this).eachBefore(XP);
}
function YP(e) {
  return e.children;
}
function WP(e) {
  return Array.isArray(e) ? e[1] : null;
}
function XP(e) {
  e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
}
function XS(e) {
  var t = 0;
  do
    e.height = t;
  while ((e = e.parent) && e.height < ++t);
}
function na(e) {
  this.data = e, this.depth = this.height = 0, this.parent = null;
}
na.prototype = WS.prototype = {
  constructor: na,
  count: NP,
  each: DP,
  eachAfter: LP,
  eachBefore: OP,
  find: kP,
  sum: FP,
  sort: RP,
  path: CP,
  ancestors: PP,
  descendants: UP,
  leaves: zP,
  links: jP,
  copy: VP,
  [Symbol.iterator]: qP
};
function up(e) {
  return e == null ? null : GP(e);
}
function GP(e) {
  if (typeof e != "function")
    throw new Error();
  return e;
}
var HP = { depth: -1 }, rw = {}, lp = {};
function JP(e) {
  return e.id;
}
function ZP(e) {
  return e.parentId;
}
function GS() {
  var e = JP, t = ZP, n;
  function r(i) {
    var s = Array.from(i), o = e, a = t, c, u, l, f, h, d, p, y, g = /* @__PURE__ */ new Map();
    if (n != null) {
      const m = s.map((v, x) => KP(n(v, x, i))), b = m.map(iw), w = new Set(m).add("");
      for (const v of b)
        w.has(v) || (w.add(v), m.push(v), b.push(iw(v)), s.push(lp));
      o = (v, x) => m[x], a = (v, x) => b[x];
    }
    for (l = 0, c = s.length; l < c; ++l)
      u = s[l], d = s[l] = new na(u), (p = o(u, l, i)) != null && (p += "") && (y = d.id = p, g.set(y, g.has(y) ? rw : d)), (p = a(u, l, i)) != null && (p += "") && (d.parent = p);
    for (l = 0; l < c; ++l)
      if (d = s[l], p = d.parent) {
        if (h = g.get(p), !h)
          throw new Error("missing: " + p);
        if (h === rw)
          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 === lp && f.children.length === 1; )
        f = f.children[0], --c;
      for (let m = s.length - 1; m >= 0 && (d = s[m], d.data === lp); --m)
        d.data = null;
    }
    if (f.parent = HP, f.eachBefore(function(m) {
      m.depth = m.parent.depth + 1, --c;
    }).eachBefore(XS), f.parent = null, c > 0)
      throw new Error("cycle");
    return f;
  }
  return r.id = function(i) {
    return arguments.length ? (e = up(i), r) : e;
  }, r.parentId = function(i) {
    return arguments.length ? (t = up(i), r) : t;
  }, r.path = function(i) {
    return arguments.length ? (n = up(i), r) : n;
  }, r;
}
function KP(e) {
  e = `${e}`;
  let t = e.length;
  return Y0(e, t - 1) && !Y0(e, t - 2) && (e = e.slice(0, -1)), e[0] === "/" ? e : `/${e}`;
}
function iw(e) {
  let t = e.length;
  if (t < 2)
    return "";
  for (; --t > 1 && !Y0(e, t); )
    ;
  return e.slice(0, t);
}
function Y0(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
function QP(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function fp(e) {
  var t = e.children;
  return t ? t[0] : e.t;
}
function hp(e) {
  var t = e.children;
  return t ? t[t.length - 1] : e.t;
}
function tU(e, t, n) {
  var r = n / (t.i - e.i);
  t.c -= r, t.s += n, e.c += r, t.z += n, t.m += n;
}
function eU(e) {
  for (var t = 0, n = 0, r = e.children, i = r.length, s; --i >= 0; )
    s = r[i], s.z += t, s.m += t, t += s.s + (n += s.c);
}
function nU(e, t, n) {
  return e.a.parent === t.parent ? e.a : n;
}
function El(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;
}
El.prototype = Object.create(na.prototype);
function rU(e) {
  for (var t = new El(e, 0), n, r = [t], i, s, o, a; n = r.pop(); )
    if (s = n._.children)
      for (n.children = new Array(a = s.length), o = a - 1; o >= 0; --o)
        r.push(i = n.children[o] = new El(s[o], o)), i.parent = n;
  return (t.parent = new El(null, 0)).children = [t], t;
}
function Yf() {
  var e = QP, t = 1, n = 1, r = null;
  function i(u) {
    var l = rU(u);
    if (l.eachAfter(s), l.parent.m = -l.z, l.eachBefore(o), r)
      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, y = p - f.x, g = t / (h.x + p + y), m = n / (d.depth || 1);
      u.eachBefore(function(b) {
        b.x = (b.x + y) * g, 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) {
      eU(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, y = h.parent.children[0], g = h.m, m = d.m, b = p.m, w = y.m, v; p = hp(p), h = fp(h), p && h; )
        y = fp(y), d = hp(d), d.a = u, v = p.z + b - h.z - g + e(p._, h._), v > 0 && (tU(nU(p, u, f), u, v), g += v, m += v), b += p.m, g += h.m, w += y.m, m += d.m;
      p && !hp(d) && (d.t = p, d.m += b - m), h && !fp(y) && (y.t = h, y.m += g - w, f = u);
    }
    return f;
  }
  function c(u) {
    u.x *= t, u.y = u.depth * n;
  }
  return i.separation = function(u) {
    return arguments.length ? (e = u, i) : e;
  }, i.size = function(u) {
    return arguments.length ? (r = !1, t = +u[0], n = +u[1], i) : r ? null : [t, n];
  }, i.nodeSize = function(u) {
    return arguments.length ? (r = !0, t = +u[0], n = +u[1], i) : r ? [t, n] : null;
  }, i;
}
const iU = 1664525, sU = 1013904223, sw = 1 / 4294967296;
function Tm(e = Math.random()) {
  let t = (0 <= e && e < 1 ? e / sw : Math.abs(e)) | 0;
  return () => (t = iU * t + sU | 0, sw * (t >>> 0));
}
function xr(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
function Wh(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 W0 = Symbol("implicit");
function Em() {
  var e = new Fs(), t = [], n = [], r = W0;
  function i(s) {
    let o = e.get(s);
    if (o === void 0) {
      if (r !== W0)
        return r;
      e.set(s, o = t.push(s) - 1);
    }
    return n[o % n.length];
  }
  return i.domain = function(s) {
    if (!arguments.length)
      return t.slice();
    t = [], e = new Fs();
    for (const o of s)
      e.has(o) || e.set(o, t.push(o) - 1);
    return i;
  }, i.range = function(s) {
    return arguments.length ? (n = Array.from(s), i) : n.slice();
  }, i.unknown = function(s) {
    return arguments.length ? (r = s, i) : r;
  }, i.copy = function() {
    return Em(t, n).unknown(r);
  }, xr.apply(i, arguments), i;
}
function Xh() {
  var e = Em().unknown(void 0), t = e.domain, n = e.range, r = 0, i = 1, s, o, a = !1, c = 0, u = 0, l = 0.5;
  delete e.unknown;
  function f() {
    var h = t().length, d = i < r, p = d ? i : r, y = d ? r : i;
    s = (y - p) / Math.max(1, h - c + u * 2), a && (s = Math.floor(s)), p += (y - p - s * (h - c)) * l, o = s * (1 - c), a && (p = Math.round(p), o = Math.round(o));
    var g = nn(h).map(function(m) {
      return p + s * m;
    });
    return n(d ? g.reverse() : g);
  }
  return e.domain = function(h) {
    return arguments.length ? (t(h), f()) : t();
  }, e.range = function(h) {
    return arguments.length ? ([r, i] = h, r = +r, i = +i, f()) : [r, i];
  }, e.rangeRound = function(h) {
    return [r, i] = h, r = +r, i = +i, 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 Xh(t(), [r, i]).round(a).paddingInner(c).paddingOuter(u).align(l);
  }, xr.apply(f(), arguments);
}
function HS(e) {
  var t = e.copy;
  return e.padding = e.paddingOuter, delete e.paddingInner, delete e.paddingOuter, e.copy = function() {
    return HS(t());
  }, e;
}
function oU() {
  return HS(Xh.apply(null, arguments).paddingInner(1));
}
function aU(e) {
  return function() {
    return e;
  };
}
function X0(e) {
  return +e;
}
var ow = [0, 1];
function bn(e) {
  return e;
}
function G0(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : aU(isNaN(t) ? NaN : 0.5);
}
function cU(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(r) {
    return Math.max(e, Math.min(t, r));
  };
}
function uU(e, t, n) {
  var r = e[0], i = e[1], s = t[0], o = t[1];
  return i < r ? (r = G0(i, r), s = n(o, s)) : (r = G0(r, i), s = n(s, o)), function(a) {
    return s(r(a));
  };
}
function lU(e, t, n) {
  var r = Math.min(e.length, t.length) - 1, i = new Array(r), s = new Array(r), o = -1;
  for (e[r] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++o < r; )
    i[o] = G0(e[o], e[o + 1]), s[o] = n(t[o], t[o + 1]);
  return function(a) {
    var c = Lh(e, a, 1, r) - 1;
    return s[c](i[c](a));
  };
}
function au(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function Gh() {
  var e = ow, t = ow, n = ba, r, i, s, o = bn, a, c, u;
  function l() {
    var h = Math.min(e.length, t.length);
    return o !== bn && (o = cU(e[0], e[h - 1])), a = h > 2 ? lU : uU, c = u = null, f;
  }
  function f(h) {
    return h == null || isNaN(h = +h) ? s : (c || (c = a(e.map(r), t, n)))(r(o(h)));
  }
  return f.invert = function(h) {
    return o(i((u || (u = a(t, e.map(r), $e)))(h)));
  }, f.domain = function(h) {
    return arguments.length ? (e = Array.from(h, X0), 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 = mm, l();
  }, f.clamp = function(h) {
    return arguments.length ? (o = h ? !0 : bn, l()) : o !== bn;
  }, 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 r = h, i = d, l();
  };
}
function JS() {
  return Gh()(bn, bn);
}
function fU(e, t, n, r) {
  var i = u0(e, t, n), s;
  switch (r = Dc(r ?? ",f"), r.type) {
    case "s": {
      var o = Math.max(Math.abs(e), Math.abs(t));
      return r.precision == null && !isNaN(s = vB(i, o)) && (r.precision = s), uS(r, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      r.precision == null && !isNaN(s = _B(i, Math.max(Math.abs(e), Math.abs(t)))) && (r.precision = s - (r.type === "e"));
      break;
    }
    case "f":
    case "%": {
      r.precision == null && !isNaN(s = wB(i)) && (r.precision = s - (r.type === "%") * 2);
      break;
    }
  }
  return wa(r);
}
function cu(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var r = t();
    return ki(r[0], r[r.length - 1], n ?? 10);
  }, e.tickFormat = function(n, r) {
    var i = t();
    return fU(i[0], i[i.length - 1], n ?? 10, r);
  }, e.nice = function(n) {
    n == null && (n = 10);
    var r = t(), i = 0, s = r.length - 1, o = r[i], a = r[s], c, u, l = 10;
    for (a < o && (u = o, o = a, a = u, u = i, i = s, s = u); l-- > 0; ) {
      if (u = Ac(o, a, n), u === c)
        return r[i] = o, r[s] = a, t(r);
      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 Hh() {
  var e = JS();
  return e.copy = function() {
    return au(e, Hh());
  }, xr.apply(e, arguments), cu(e);
}
function ZS(e) {
  var t;
  function n(r) {
    return r == null || isNaN(r = +r) ? t : r;
  }
  return n.invert = n, n.domain = n.range = function(r) {
    return arguments.length ? (e = Array.from(r, X0), n) : e.slice();
  }, n.unknown = function(r) {
    return arguments.length ? (t = r, n) : t;
  }, n.copy = function() {
    return ZS(e).unknown(t);
  }, e = arguments.length ? Array.from(e, X0) : [0, 1], cu(n);
}
function KS(e, t) {
  e = e.slice();
  var n = 0, r = e.length - 1, i = e[n], s = e[r], o;
  return s < i && (o = n, n = r, r = o, o = i, i = s, s = o), e[n] = t.floor(i), e[r] = t.ceil(s), e;
}
function aw(e) {
  return Math.log(e);
}
function cw(e) {
  return Math.exp(e);
}
function hU(e) {
  return -Math.log(-e);
}
function dU(e) {
  return -Math.exp(-e);
}
function pU(e) {
  return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e;
}
function yU(e) {
  return e === 10 ? pU : e === Math.E ? Math.exp : (t) => Math.pow(e, t);
}
function mU(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 uw(e) {
  return (t, n) => -e(-t, n);
}
function QS(e) {
  const t = e(aw, cw), n = t.domain;
  let r = 10, i, s;
  function o() {
    return i = mU(r), s = yU(r), n()[0] < 0 ? (i = uw(i), s = uw(s), e(hU, dU)) : e(aw, cw), t;
  }
  return t.base = function(a) {
    return arguments.length ? (r = +a, o()) : r;
  }, 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 = i(u), d = i(l), p, y;
    const g = a == null ? 10 : +a;
    let m = [];
    if (!(r % 1) && d - h < g) {
      if (h = Math.floor(h), d = Math.ceil(d), u > 0) {
        for (; h <= d; ++h)
          for (p = 1; p < r; ++p)
            if (y = h < 0 ? p / s(-h) : p * s(h), !(y < u)) {
              if (y > l)
                break;
              m.push(y);
            }
      } else
        for (; h <= d; ++h)
          for (p = r - 1; p >= 1; --p)
            if (y = h > 0 ? p / s(-h) : p * s(h), !(y < u)) {
              if (y > l)
                break;
              m.push(y);
            }
      m.length * 2 < g && (m = ki(u, l, g));
    } else
      m = ki(h, d, Math.min(d - h, g)).map(s);
    return f ? m.reverse() : m;
  }, t.tickFormat = (a, c) => {
    if (a == null && (a = 10), c == null && (c = r === 10 ? "s" : ","), typeof c != "function" && (!(r % 1) && (c = Dc(c)).precision == null && (c.trim = !0), c = wa(c)), a === 1 / 0)
      return c;
    const u = Math.max(1, r * a / t.ticks().length);
    return (l) => {
      let f = l / s(Math.round(i(l)));
      return f * r < r - 0.5 && (f *= r), f <= u ? c(l) : "";
    };
  }, t.nice = () => n(KS(n(), {
    floor: (a) => s(Math.floor(i(a))),
    ceil: (a) => s(Math.ceil(i(a)))
  })), t;
}
function t3() {
  const e = QS(Gh()).domain([1, 10]);
  return e.copy = () => au(e, t3()).base(e.base()), xr.apply(e, arguments), e;
}
function lw(e) {
  return function(t) {
    return Math.sign(t) * Math.log1p(Math.abs(t / e));
  };
}
function fw(e) {
  return function(t) {
    return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
  };
}
function e3(e) {
  var t = 1, n = e(lw(t), fw(t));
  return n.constant = function(r) {
    return arguments.length ? e(lw(t = +r), fw(t)) : t;
  }, cu(n);
}
function n3() {
  var e = e3(Gh());
  return e.copy = function() {
    return au(e, n3()).constant(e.constant());
  }, xr.apply(e, arguments);
}
function hw(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function gU(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function bU(e) {
  return e < 0 ? -e * e : e * e;
}
function r3(e) {
  var t = e(bn, bn), n = 1;
  function r() {
    return n === 1 ? e(bn, bn) : n === 0.5 ? e(gU, bU) : e(hw(n), hw(1 / n));
  }
  return t.exponent = function(i) {
    return arguments.length ? (n = +i, r()) : n;
  }, cu(t);
}
function i3() {
  var e = r3(Gh());
  return e.copy = function() {
    return au(e, i3()).exponent(e.exponent());
  }, xr.apply(e, arguments), e;
}
function s3() {
  var e = [], t = [], n = [], r;
  function i() {
    var o = 0, a = Math.max(1, t.length);
    for (n = new Array(a - 1); ++o < a; )
      n[o - 1] = AL(e, o / a);
    return s;
  }
  function s(o) {
    return o == null || isNaN(o = +o) ? r : t[Lh(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(re), i();
  }, s.range = function(o) {
    return arguments.length ? (t = Array.from(o), i()) : t.slice();
  }, s.unknown = function(o) {
    return arguments.length ? (r = o, s) : r;
  }, s.quantiles = function() {
    return n.slice();
  }, s.copy = function() {
    return s3().domain(e).range(t).unknown(r);
  }, xr.apply(s, arguments);
}
function o3() {
  var e = [0.5], t = [0, 1], n, r = 1;
  function i(s) {
    return s != null && s <= s ? t[Lh(e, s, 0, r)] : n;
  }
  return i.domain = function(s) {
    return arguments.length ? (e = Array.from(s), r = Math.min(e.length, t.length - 1), i) : e.slice();
  }, i.range = function(s) {
    return arguments.length ? (t = Array.from(s), r = Math.min(e.length, t.length - 1), i) : t.slice();
  }, i.invertExtent = function(s) {
    var o = t.indexOf(s);
    return [e[o - 1], e[o]];
  }, i.unknown = function(s) {
    return arguments.length ? (n = s, i) : n;
  }, i.copy = function() {
    return o3().domain(e).range(t).unknown(n);
  }, xr.apply(i, arguments);
}
const dp = /* @__PURE__ */ new Date(), pp = /* @__PURE__ */ new Date();
function he(e, t, n, r) {
  function i(s) {
    return e(s = arguments.length === 0 ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date(+s)), s;
  }
  return i.floor = (s) => (e(s = /* @__PURE__ */ new Date(+s)), s), i.ceil = (s) => (e(s = new Date(s - 1)), t(s, 1), e(s), s), i.round = (s) => {
    const o = i(s), a = i.ceil(s);
    return s - o < a - s ? o : a;
  }, i.offset = (s, o) => (t(s = /* @__PURE__ */ new Date(+s), o == null ? 1 : Math.floor(o)), s), i.range = (s, o, a) => {
    const c = [];
    if (s = i.ceil(s), a = a == null ? 1 : Math.floor(a), !(s < o) || !(a > 0))
      return c;
    let u;
    do
      c.push(u = /* @__PURE__ */ new Date(+s)), t(s, a), e(s);
    while (u < s && s < o);
    return c;
  }, i.filter = (s) => he((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 && (i.count = (s, o) => (dp.setTime(+s), pp.setTime(+o), e(dp), e(pp), Math.floor(n(dp, pp))), i.every = (s) => (s = Math.floor(s), !isFinite(s) || !(s > 0) ? null : s > 1 ? i.filter(r ? (o) => r(o) % s === 0 : (o) => i.count(0, o) % s === 0) : i)), i;
}
const Wf = he(() => {
}, (e, t) => {
  e.setTime(+e + t);
}, (e, t) => t - e);
Wf.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? he((t) => {
  t.setTime(Math.floor(t / e) * e);
}, (t, n) => {
  t.setTime(+t + n * e);
}, (t, n) => (n - t) / e) : Wf);
Wf.range;
const Vr = 1e3, wn = Vr * 60, Yr = wn * 60, ti = Yr * 24, Nm = ti * 7, dw = ti * 30, yp = ti * 365, Fn = he((e) => {
  e.setTime(e - e.getMilliseconds());
}, (e, t) => {
  e.setTime(+e + t * Vr);
}, (e, t) => (t - e) / Vr, (e) => e.getUTCSeconds());
Fn.range;
const uu = he((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Vr);
}, (e, t) => {
  e.setTime(+e + t * wn);
}, (e, t) => (t - e) / wn, (e) => e.getMinutes());
uu.range;
const lu = he((e) => {
  e.setUTCSeconds(0, 0);
}, (e, t) => {
  e.setTime(+e + t * wn);
}, (e, t) => (t - e) / wn, (e) => e.getUTCMinutes());
lu.range;
const fu = he((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Vr - e.getMinutes() * wn);
}, (e, t) => {
  e.setTime(+e + t * Yr);
}, (e, t) => (t - e) / Yr, (e) => e.getHours());
fu.range;
const hu = he((e) => {
  e.setUTCMinutes(0, 0, 0);
}, (e, t) => {
  e.setTime(+e + t * Yr);
}, (e, t) => (t - e) / Yr, (e) => e.getUTCHours());
hu.range;
const Ws = he(
  (e) => e.setHours(0, 0, 0, 0),
  (e, t) => e.setDate(e.getDate() + t),
  (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * wn) / ti,
  (e) => e.getDate() - 1
);
Ws.range;
const Jh = he((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / ti, (e) => e.getUTCDate() - 1);
Jh.range;
const Zh = he((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / ti, (e) => Math.floor(e / ti));
Zh.range;
function Xs(e) {
  return he((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()) * wn) / Nm);
}
const ra = Xs(0), Lc = Xs(1), a3 = Xs(2), c3 = Xs(3), zs = Xs(4), u3 = Xs(5), l3 = Xs(6);
ra.range;
Lc.range;
a3.range;
c3.range;
zs.range;
u3.range;
l3.range;
function Gs(e) {
  return he((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) / Nm);
}
const ia = Gs(0), kc = Gs(1), f3 = Gs(2), h3 = Gs(3), js = Gs(4), d3 = Gs(5), p3 = Gs(6);
ia.range;
kc.range;
f3.range;
h3.range;
js.range;
d3.range;
p3.range;
const du = he((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());
du.range;
const pu = he((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());
pu.range;
const zn = he((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());
zn.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : he((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);
});
zn.range;
const jn = he((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());
jn.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : he((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);
});
jn.range;
function y3(e, t, n, r, i, s) {
  const o = [
    [Fn, 1, Vr],
    [Fn, 5, 5 * Vr],
    [Fn, 15, 15 * Vr],
    [Fn, 30, 30 * Vr],
    [s, 1, wn],
    [s, 5, 5 * wn],
    [s, 15, 15 * wn],
    [s, 30, 30 * wn],
    [i, 1, Yr],
    [i, 3, 3 * Yr],
    [i, 6, 6 * Yr],
    [i, 12, 12 * Yr],
    [r, 1, ti],
    [r, 2, 2 * ti],
    [n, 1, Nm],
    [t, 1, dw],
    [t, 3, 3 * dw],
    [e, 1, yp]
  ];
  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 = Oh(([, , g]) => g).right(o, h);
    if (d === o.length)
      return e.every(u0(u / yp, l / yp, f));
    if (d === 0)
      return Wf.every(Math.max(u0(u, l, f), 1));
    const [p, y] = o[h / o[d - 1][2] < o[d][2] / h ? d - 1 : d];
    return p.every(y);
  }
  return [a, c];
}
const [wU, m3] = y3(jn, pu, ia, Zh, hu, lu), [vU, _U] = y3(zn, du, ra, Ws, fu, uu);
function mp(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 gp(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 Ca(e, t, n) {
  return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 };
}
function xU(e) {
  var t = e.dateTime, n = e.date, r = e.time, i = e.periods, s = e.days, o = e.shortDays, a = e.months, c = e.shortMonths, u = Ba(i), l = Pa(i), f = Ba(s), h = Pa(s), d = Ba(o), p = Pa(o), y = Ba(a), g = Pa(a), m = Ba(c), b = Pa(c), w = {
    a: O,
    A: C,
    b: B,
    B: R,
    c: null,
    d: ww,
    e: ww,
    f: YU,
    g: ez,
    G: rz,
    H: jU,
    I: qU,
    j: VU,
    L: g3,
    m: WU,
    M: XU,
    p: P,
    q: U,
    Q: xw,
    s: Sw,
    S: GU,
    u: HU,
    U: JU,
    V: ZU,
    w: KU,
    W: QU,
    x: null,
    X: null,
    y: tz,
    Y: nz,
    Z: iz,
    "%": _w
  }, v = {
    a: Y,
    A: G,
    b: Z,
    B: H,
    c: null,
    d: vw,
    e: vw,
    f: cz,
    g: bz,
    G: vz,
    H: sz,
    I: oz,
    j: az,
    L: w3,
    m: uz,
    M: lz,
    p: q,
    q: W,
    Q: xw,
    s: Sw,
    S: fz,
    u: hz,
    U: dz,
    V: pz,
    w: yz,
    W: mz,
    x: null,
    X: null,
    y: gz,
    Y: wz,
    Z: _z,
    "%": _w
  }, x = {
    a: A,
    A: $,
    b: D,
    B: F,
    c: S,
    d: gw,
    e: gw,
    f: BU,
    g: mw,
    G: yw,
    H: bw,
    I: bw,
    j: kU,
    L: CU,
    m: LU,
    M: FU,
    p: N,
    q: OU,
    Q: UU,
    s: zU,
    S: RU,
    u: IU,
    U: TU,
    V: EU,
    w: $U,
    W: NU,
    x: I,
    X: E,
    y: mw,
    Y: yw,
    Z: DU,
    "%": PU
  };
  w.x = _(n, w), w.X = _(r, w), w.c = _(t, w), v.x = _(n, v), v.X = _(r, v), v.c = _(t, v);
  function _(j, X) {
    return function(K) {
      var z = [], wt = -1, Q = 0, It = j.length, Tt, J, kt;
      for (K instanceof Date || (K = /* @__PURE__ */ new Date(+K)); ++wt < It; )
        j.charCodeAt(wt) === 37 && (z.push(j.slice(Q, wt)), (J = pw[Tt = j.charAt(++wt)]) != null ? Tt = j.charAt(++wt) : J = Tt === "e" ? " " : "0", (kt = X[Tt]) && (Tt = kt(K, J)), z.push(Tt), Q = wt + 1);
      return z.push(j.slice(Q, wt)), z.join("");
    };
  }
  function M(j, X) {
    return function(K) {
      var z = Ca(1900, void 0, 1), wt = T(z, j, K += "", 0), Q, It;
      if (wt != K.length)
        return null;
      if ("Q" in z)
        return new Date(z.Q);
      if ("s" in z)
        return new Date(z.s * 1e3 + ("L" in z ? z.L : 0));
      if (X && !("Z" in z) && (z.Z = 0), "p" in z && (z.H = z.H % 12 + z.p * 12), z.m === void 0 && (z.m = "q" in z ? z.q : 0), "V" in z) {
        if (z.V < 1 || z.V > 53)
          return null;
        "w" in z || (z.w = 1), "Z" in z ? (Q = gp(Ca(z.y, 0, 1)), It = Q.getUTCDay(), Q = It > 4 || It === 0 ? kc.ceil(Q) : kc(Q), Q = Jh.offset(Q, (z.V - 1) * 7), z.y = Q.getUTCFullYear(), z.m = Q.getUTCMonth(), z.d = Q.getUTCDate() + (z.w + 6) % 7) : (Q = mp(Ca(z.y, 0, 1)), It = Q.getDay(), Q = It > 4 || It === 0 ? Lc.ceil(Q) : Lc(Q), Q = Ws.offset(Q, (z.V - 1) * 7), z.y = Q.getFullYear(), z.m = Q.getMonth(), z.d = Q.getDate() + (z.w + 6) % 7);
      } else
        ("W" in z || "U" in z) && ("w" in z || (z.w = "u" in z ? z.u % 7 : "W" in z ? 1 : 0), It = "Z" in z ? gp(Ca(z.y, 0, 1)).getUTCDay() : mp(Ca(z.y, 0, 1)).getDay(), z.m = 0, z.d = "W" in z ? (z.w + 6) % 7 + z.W * 7 - (It + 5) % 7 : z.w + z.U * 7 - (It + 6) % 7);
      return "Z" in z ? (z.H += z.Z / 100 | 0, z.M += z.Z % 100, gp(z)) : mp(z);
    };
  }
  function T(j, X, K, z) {
    for (var wt = 0, Q = X.length, It = K.length, Tt, J; wt < Q; ) {
      if (z >= It)
        return -1;
      if (Tt = X.charCodeAt(wt++), Tt === 37) {
        if (Tt = X.charAt(wt++), J = x[Tt in pw ? X.charAt(wt++) : Tt], !J || (z = J(j, K, z)) < 0)
          return -1;
      } else if (Tt != K.charCodeAt(z++))
        return -1;
    }
    return z;
  }
  function N(j, X, K) {
    var z = u.exec(X.slice(K));
    return z ? (j.p = l.get(z[0].toLowerCase()), K + z[0].length) : -1;
  }
  function A(j, X, K) {
    var z = d.exec(X.slice(K));
    return z ? (j.w = p.get(z[0].toLowerCase()), K + z[0].length) : -1;
  }
  function $(j, X, K) {
    var z = f.exec(X.slice(K));
    return z ? (j.w = h.get(z[0].toLowerCase()), K + z[0].length) : -1;
  }
  function D(j, X, K) {
    var z = m.exec(X.slice(K));
    return z ? (j.m = b.get(z[0].toLowerCase()), K + z[0].length) : -1;
  }
  function F(j, X, K) {
    var z = y.exec(X.slice(K));
    return z ? (j.m = g.get(z[0].toLowerCase()), K + z[0].length) : -1;
  }
  function S(j, X, K) {
    return T(j, t, X, K);
  }
  function I(j, X, K) {
    return T(j, n, X, K);
  }
  function E(j, X, K) {
    return T(j, r, X, K);
  }
  function O(j) {
    return o[j.getDay()];
  }
  function C(j) {
    return s[j.getDay()];
  }
  function B(j) {
    return c[j.getMonth()];
  }
  function R(j) {
    return a[j.getMonth()];
  }
  function P(j) {
    return i[+(j.getHours() >= 12)];
  }
  function U(j) {
    return 1 + ~~(j.getMonth() / 3);
  }
  function Y(j) {
    return o[j.getUTCDay()];
  }
  function G(j) {
    return s[j.getUTCDay()];
  }
  function Z(j) {
    return c[j.getUTCMonth()];
  }
  function H(j) {
    return a[j.getUTCMonth()];
  }
  function q(j) {
    return i[+(j.getUTCHours() >= 12)];
  }
  function W(j) {
    return 1 + ~~(j.getUTCMonth() / 3);
  }
  return {
    format: function(j) {
      var X = _(j += "", w);
      return X.toString = function() {
        return j;
      }, X;
    },
    parse: function(j) {
      var X = M(j += "", !1);
      return X.toString = function() {
        return j;
      }, X;
    },
    utcFormat: function(j) {
      var X = _(j += "", v);
      return X.toString = function() {
        return j;
      }, X;
    },
    utcParse: function(j) {
      var X = M(j += "", !0);
      return X.toString = function() {
        return j;
      }, X;
    }
  };
}
var pw = { "-": "", _: " ", 0: "0" }, we = /^\s*\d+/, SU = /^%/, MU = /[\\^$*+?|[\]().{}]/g;
function Ot(e, t, n) {
  var r = e < 0 ? "-" : "", i = (r ? -e : e) + "", s = i.length;
  return r + (s < n ? new Array(n - s + 1).join(t) + i : i);
}
function AU(e) {
  return e.replace(MU, "\\$&");
}
function Ba(e) {
  return new RegExp("^(?:" + e.map(AU).join("|") + ")", "i");
}
function Pa(e) {
  return new Map(e.map((t, n) => [t.toLowerCase(), n]));
}
function $U(e, t, n) {
  var r = we.exec(t.slice(n, n + 1));
  return r ? (e.w = +r[0], n + r[0].length) : -1;
}
function IU(e, t, n) {
  var r = we.exec(t.slice(n, n + 1));
  return r ? (e.u = +r[0], n + r[0].length) : -1;
}
function TU(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.U = +r[0], n + r[0].length) : -1;
}
function EU(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.V = +r[0], n + r[0].length) : -1;
}
function NU(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.W = +r[0], n + r[0].length) : -1;
}
function yw(e, t, n) {
  var r = we.exec(t.slice(n, n + 4));
  return r ? (e.y = +r[0], n + r[0].length) : -1;
}
function mw(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.y = +r[0] + (+r[0] > 68 ? 1900 : 2e3), n + r[0].length) : -1;
}
function DU(e, t, n) {
  var r = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6));
  return r ? (e.Z = r[1] ? 0 : -(r[2] + (r[3] || "00")), n + r[0].length) : -1;
}
function OU(e, t, n) {
  var r = we.exec(t.slice(n, n + 1));
  return r ? (e.q = r[0] * 3 - 3, n + r[0].length) : -1;
}
function LU(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.m = r[0] - 1, n + r[0].length) : -1;
}
function gw(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.d = +r[0], n + r[0].length) : -1;
}
function kU(e, t, n) {
  var r = we.exec(t.slice(n, n + 3));
  return r ? (e.m = 0, e.d = +r[0], n + r[0].length) : -1;
}
function bw(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.H = +r[0], n + r[0].length) : -1;
}
function FU(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.M = +r[0], n + r[0].length) : -1;
}
function RU(e, t, n) {
  var r = we.exec(t.slice(n, n + 2));
  return r ? (e.S = +r[0], n + r[0].length) : -1;
}
function CU(e, t, n) {
  var r = we.exec(t.slice(n, n + 3));
  return r ? (e.L = +r[0], n + r[0].length) : -1;
}
function BU(e, t, n) {
  var r = we.exec(t.slice(n, n + 6));
  return r ? (e.L = Math.floor(r[0] / 1e3), n + r[0].length) : -1;
}
function PU(e, t, n) {
  var r = SU.exec(t.slice(n, n + 1));
  return r ? n + r[0].length : -1;
}
function UU(e, t, n) {
  var r = we.exec(t.slice(n));
  return r ? (e.Q = +r[0], n + r[0].length) : -1;
}
function zU(e, t, n) {
  var r = we.exec(t.slice(n));
  return r ? (e.s = +r[0], n + r[0].length) : -1;
}
function ww(e, t) {
  return Ot(e.getDate(), t, 2);
}
function jU(e, t) {
  return Ot(e.getHours(), t, 2);
}
function qU(e, t) {
  return Ot(e.getHours() % 12 || 12, t, 2);
}
function VU(e, t) {
  return Ot(1 + Ws.count(zn(e), e), t, 3);
}
function g3(e, t) {
  return Ot(e.getMilliseconds(), t, 3);
}
function YU(e, t) {
  return g3(e, t) + "000";
}
function WU(e, t) {
  return Ot(e.getMonth() + 1, t, 2);
}
function XU(e, t) {
  return Ot(e.getMinutes(), t, 2);
}
function GU(e, t) {
  return Ot(e.getSeconds(), t, 2);
}
function HU(e) {
  var t = e.getDay();
  return t === 0 ? 7 : t;
}
function JU(e, t) {
  return Ot(ra.count(zn(e) - 1, e), t, 2);
}
function b3(e) {
  var t = e.getDay();
  return t >= 4 || t === 0 ? zs(e) : zs.ceil(e);
}
function ZU(e, t) {
  return e = b3(e), Ot(zs.count(zn(e), e) + (zn(e).getDay() === 4), t, 2);
}
function KU(e) {
  return e.getDay();
}
function QU(e, t) {
  return Ot(Lc.count(zn(e) - 1, e), t, 2);
}
function tz(e, t) {
  return Ot(e.getFullYear() % 100, t, 2);
}
function ez(e, t) {
  return e = b3(e), Ot(e.getFullYear() % 100, t, 2);
}
function nz(e, t) {
  return Ot(e.getFullYear() % 1e4, t, 4);
}
function rz(e, t) {
  var n = e.getDay();
  return e = n >= 4 || n === 0 ? zs(e) : zs.ceil(e), Ot(e.getFullYear() % 1e4, t, 4);
}
function iz(e) {
  var t = e.getTimezoneOffset();
  return (t > 0 ? "-" : (t *= -1, "+")) + Ot(t / 60 | 0, "0", 2) + Ot(t % 60, "0", 2);
}
function vw(e, t) {
  return Ot(e.getUTCDate(), t, 2);
}
function sz(e, t) {
  return Ot(e.getUTCHours(), t, 2);
}
function oz(e, t) {
  return Ot(e.getUTCHours() % 12 || 12, t, 2);
}
function az(e, t) {
  return Ot(1 + Jh.count(jn(e), e), t, 3);
}
function w3(e, t) {
  return Ot(e.getUTCMilliseconds(), t, 3);
}
function cz(e, t) {
  return w3(e, t) + "000";
}
function uz(e, t) {
  return Ot(e.getUTCMonth() + 1, t, 2);
}
function lz(e, t) {
  return Ot(e.getUTCMinutes(), t, 2);
}
function fz(e, t) {
  return Ot(e.getUTCSeconds(), t, 2);
}
function hz(e) {
  var t = e.getUTCDay();
  return t === 0 ? 7 : t;
}
function dz(e, t) {
  return Ot(ia.count(jn(e) - 1, e), t, 2);
}
function v3(e) {
  var t = e.getUTCDay();
  return t >= 4 || t === 0 ? js(e) : js.ceil(e);
}
function pz(e, t) {
  return e = v3(e), Ot(js.count(jn(e), e) + (jn(e).getUTCDay() === 4), t, 2);
}
function yz(e) {
  return e.getUTCDay();
}
function mz(e, t) {
  return Ot(kc.count(jn(e) - 1, e), t, 2);
}
function gz(e, t) {
  return Ot(e.getUTCFullYear() % 100, t, 2);
}
function bz(e, t) {
  return e = v3(e), Ot(e.getUTCFullYear() % 100, t, 2);
}
function wz(e, t) {
  return Ot(e.getUTCFullYear() % 1e4, t, 4);
}
function vz(e, t) {
  var n = e.getUTCDay();
  return e = n >= 4 || n === 0 ? js(e) : js.ceil(e), Ot(e.getUTCFullYear() % 1e4, t, 4);
}
function _z() {
  return "+0000";
}
function _w() {
  return "%";
}
function xw(e) {
  return +e;
}
function Sw(e) {
  return Math.floor(+e / 1e3);
}
var oo, Dm, yu;
xz({
  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 xz(e) {
  return oo = xU(e), Dm = oo.format, oo.parse, yu = oo.utcFormat, oo.utcParse, oo;
}
function Sz(e) {
  return new Date(e);
}
function Mz(e) {
  return e instanceof Date ? +e : +/* @__PURE__ */ new Date(+e);
}
function Om(e, t, n, r, i, s, o, a, c, u) {
  var l = JS(), f = l.invert, h = l.domain, d = u(".%L"), p = u(":%S"), y = u("%I:%M"), g = u("%I %p"), m = u("%a %d"), b = u("%b %d"), w = u("%B"), v = u("%Y");
  function x(_) {
    return (c(_) < _ ? d : a(_) < _ ? p : o(_) < _ ? y : s(_) < _ ? g : r(_) < _ ? i(_) < _ ? m : b : n(_) < _ ? w : v)(_);
  }
  return l.invert = function(_) {
    return new Date(f(_));
  }, l.domain = function(_) {
    return arguments.length ? h(Array.from(_, Mz)) : h().map(Sz);
  }, l.ticks = function(_) {
    var M = h();
    return e(M[0], M[M.length - 1], _ ?? 10);
  }, l.tickFormat = function(_, M) {
    return M == null ? x : u(M);
  }, l.nice = function(_) {
    var M = h();
    return (!_ || typeof _.range != "function") && (_ = t(M[0], M[M.length - 1], _ ?? 10)), _ ? h(KS(M, _)) : l;
  }, l.copy = function() {
    return au(l, Om(e, t, n, r, i, s, o, a, c, u));
  }, l;
}
function Az() {
  return xr.apply(Om(vU, _U, zn, du, ra, Ws, fu, uu, Fn, Dm).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
function $z() {
  return xr.apply(Om(wU, m3, jn, pu, ia, Jh, hu, lu, Fn, yu).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
}
function Kh(e, t) {
  return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown());
}
function Qh() {
  var e = 0, t = 0.5, n = 1, r = 1, i, s, o, a, c, u = bn, l, f = !1, h;
  function d(y) {
    return isNaN(y = +y) ? h : (y = 0.5 + ((y = +l(y)) - s) * (r * y < r * s ? a : c), u(f ? Math.max(0, Math.min(1, y)) : y));
  }
  d.domain = function(y) {
    return arguments.length ? ([e, t, n] = y, i = l(e = +e), s = l(t = +t), o = l(n = +n), a = i === s ? 0 : 0.5 / (s - i), c = s === o ? 0 : 0.5 / (o - s), r = s < i ? -1 : 1, d) : [e, t, n];
  }, d.clamp = function(y) {
    return arguments.length ? (f = !!y, d) : f;
  }, d.interpolator = function(y) {
    return arguments.length ? (u = y, d) : u;
  };
  function p(y) {
    return function(g) {
      var m, b, w;
      return arguments.length ? ([m, b, w] = g, u = zh(y, [m, b, w]), d) : [u(0), u(0.5), u(1)];
    };
  }
  return d.range = p(ba), d.rangeRound = p(mm), d.unknown = function(y) {
    return arguments.length ? (h = y, d) : h;
  }, function(y) {
    return l = y, i = y(e), s = y(t), o = y(n), a = i === s ? 0 : 0.5 / (s - i), c = s === o ? 0 : 0.5 / (o - s), r = s < i ? -1 : 1, d;
  };
}
function _3() {
  var e = cu(Qh()(bn));
  return e.copy = function() {
    return Kh(e, _3());
  }, Wh.apply(e, arguments);
}
function x3() {
  var e = QS(Qh()).domain([0.1, 1, 10]);
  return e.copy = function() {
    return Kh(e, x3()).base(e.base());
  }, Wh.apply(e, arguments);
}
function S3() {
  var e = e3(Qh());
  return e.copy = function() {
    return Kh(e, S3()).constant(e.constant());
  }, Wh.apply(e, arguments);
}
function M3() {
  var e = r3(Qh());
  return e.copy = function() {
    return Kh(e, M3()).exponent(e.exponent());
  }, Wh.apply(e, arguments);
}
function _t(e) {
  for (var t = e.length / 6 | 0, n = new Array(t), r = 0; r < t; )
    n[r] = "#" + e.slice(r * 6, ++r * 6);
  return n;
}
const Iz = _t("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"), Tz = _t("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"), Ez = _t("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"), Nz = _t("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"), Dz = _t("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"), Oz = _t("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"), Lz = _t("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"), kz = _t("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"), Fz = _t("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"), Rz = _t("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"), Yt = (e) => PF(e[e.length - 1]);
var A3 = new Array(3).concat(
  "d8b365f5f5f55ab4ac",
  "a6611adfc27d80cdc1018571",
  "a6611adfc27df5f5f580cdc1018571",
  "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
  "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
  "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
  "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
  "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
  "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
).map(_t);
const $3 = Yt(A3);
var I3 = new Array(3).concat(
  "af8dc3f7f7f77fbf7b",
  "7b3294c2a5cfa6dba0008837",
  "7b3294c2a5cff7f7f7a6dba0008837",
  "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
  "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
  "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
  "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
  "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
  "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
).map(_t);
const T3 = Yt(I3);
var E3 = new Array(3).concat(
  "e9a3c9f7f7f7a1d76a",
  "d01c8bf1b6dab8e1864dac26",
  "d01c8bf1b6daf7f7f7b8e1864dac26",
  "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
  "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
  "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
  "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
  "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
  "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
).map(_t);
const N3 = Yt(E3);
var D3 = new Array(3).concat(
  "998ec3f7f7f7f1a340",
  "5e3c99b2abd2fdb863e66101",
  "5e3c99b2abd2f7f7f7fdb863e66101",
  "542788998ec3d8daebfee0b6f1a340b35806",
  "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
  "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
  "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
  "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
  "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
).map(_t);
const O3 = Yt(D3);
var H0 = new Array(3).concat(
  "ef8a62f7f7f767a9cf",
  "ca0020f4a58292c5de0571b0",
  "ca0020f4a582f7f7f792c5de0571b0",
  "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
  "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
  "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
  "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
  "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
  "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
).map(_t);
const Xf = Yt(H0);
var L3 = new Array(3).concat(
  "ef8a62ffffff999999",
  "ca0020f4a582bababa404040",
  "ca0020f4a582ffffffbababa404040",
  "b2182bef8a62fddbc7e0e0e09999994d4d4d",
  "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
  "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
  "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
  "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
  "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
).map(_t);
const k3 = Yt(L3);
var J0 = new Array(3).concat(
  "fc8d59ffffbf91bfdb",
  "d7191cfdae61abd9e92c7bb6",
  "d7191cfdae61ffffbfabd9e92c7bb6",
  "d73027fc8d59fee090e0f3f891bfdb4575b4",
  "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
  "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
  "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
  "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
  "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
).map(_t);
const Gf = Yt(J0);
var F3 = new Array(3).concat(
  "fc8d59ffffbf91cf60",
  "d7191cfdae61a6d96a1a9641",
  "d7191cfdae61ffffbfa6d96a1a9641",
  "d73027fc8d59fee08bd9ef8b91cf601a9850",
  "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
  "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
  "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
  "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
  "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
).map(_t);
const R3 = Yt(F3);
var C3 = new Array(3).concat(
  "fc8d59ffffbf99d594",
  "d7191cfdae61abdda42b83ba",
  "d7191cfdae61ffffbfabdda42b83ba",
  "d53e4ffc8d59fee08be6f59899d5943288bd",
  "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
  "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
  "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
  "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
  "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
).map(_t);
const B3 = Yt(C3);
var P3 = new Array(3).concat(
  "e5f5f999d8c92ca25f",
  "edf8fbb2e2e266c2a4238b45",
  "edf8fbb2e2e266c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
).map(_t);
const U3 = Yt(P3);
var z3 = new Array(3).concat(
  "e0ecf49ebcda8856a7",
  "edf8fbb3cde38c96c688419d",
  "edf8fbb3cde38c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
).map(_t);
const j3 = Yt(z3);
var q3 = new Array(3).concat(
  "e0f3dba8ddb543a2ca",
  "f0f9e8bae4bc7bccc42b8cbe",
  "f0f9e8bae4bc7bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
).map(_t);
const V3 = Yt(q3);
var Y3 = new Array(3).concat(
  "fee8c8fdbb84e34a33",
  "fef0d9fdcc8afc8d59d7301f",
  "fef0d9fdcc8afc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
).map(_t);
const W3 = Yt(Y3);
var X3 = new Array(3).concat(
  "ece2f0a6bddb1c9099",
  "f6eff7bdc9e167a9cf02818a",
  "f6eff7bdc9e167a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
).map(_t);
const G3 = Yt(X3);
var H3 = new Array(3).concat(
  "ece7f2a6bddb2b8cbe",
  "f1eef6bdc9e174a9cf0570b0",
  "f1eef6bdc9e174a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
).map(_t);
const J3 = Yt(H3);
var Z3 = new Array(3).concat(
  "e7e1efc994c7dd1c77",
  "f1eef6d7b5d8df65b0ce1256",
  "f1eef6d7b5d8df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
).map(_t);
const K3 = Yt(Z3);
var Q3 = new Array(3).concat(
  "fde0ddfa9fb5c51b8a",
  "feebe2fbb4b9f768a1ae017e",
  "feebe2fbb4b9f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
).map(_t);
const t6 = Yt(Q3);
var e6 = new Array(3).concat(
  "edf8b17fcdbb2c7fb8",
  "ffffcca1dab441b6c4225ea8",
  "ffffcca1dab441b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
).map(_t);
const n6 = Yt(e6);
var r6 = new Array(3).concat(
  "f7fcb9addd8e31a354",
  "ffffccc2e69978c679238443",
  "ffffccc2e69978c67931a354006837",
  "ffffccd9f0a3addd8e78c67931a354006837",
  "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
).map(_t);
const i6 = Yt(r6);
var s6 = new Array(3).concat(
  "fff7bcfec44fd95f0e",
  "ffffd4fed98efe9929cc4c02",
  "ffffd4fed98efe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
).map(_t);
const o6 = Yt(s6);
var a6 = new Array(3).concat(
  "ffeda0feb24cf03b20",
  "ffffb2fecc5cfd8d3ce31a1c",
  "ffffb2fecc5cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
).map(_t);
const c6 = Yt(a6);
var u6 = new Array(3).concat(
  "deebf79ecae13182bd",
  "eff3ffbdd7e76baed62171b5",
  "eff3ffbdd7e76baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
).map(_t);
const l6 = Yt(u6);
var f6 = new Array(3).concat(
  "e5f5e0a1d99b31a354",
  "edf8e9bae4b374c476238b45",
  "edf8e9bae4b374c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
).map(_t);
const h6 = Yt(f6);
var d6 = new Array(3).concat(
  "f0f0f0bdbdbd636363",
  "f7f7f7cccccc969696525252",
  "f7f7f7cccccc969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
).map(_t);
const p6 = Yt(d6);
var y6 = new Array(3).concat(
  "efedf5bcbddc756bb1",
  "f2f0f7cbc9e29e9ac86a51a3",
  "f2f0f7cbc9e29e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
).map(_t);
const m6 = Yt(y6);
var g6 = new Array(3).concat(
  "fee0d2fc9272de2d26",
  "fee5d9fcae91fb6a4acb181d",
  "fee5d9fcae91fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
).map(_t);
const b6 = Yt(g6);
var w6 = new Array(3).concat(
  "fee6cefdae6be6550d",
  "feeddefdbe85fd8d3cd94701",
  "feeddefdbe85fd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
).map(_t);
const v6 = Yt(w6);
function _6(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 x6 = gm(br(300, 0.5, 0), br(-240, 0.5, 1));
var S6 = gm(br(-100, 0.75, 0.35), br(80, 1.5, 0.8)), M6 = gm(br(260, 0.75, 0.35), br(80, 1.5, 0.8)), Qu = br();
function A6(e) {
  (e < 0 || e > 1) && (e -= Math.floor(e));
  var t = Math.abs(e - 0.5);
  return Qu.h = 360 * e - 100, Qu.s = 1.5 - 1.5 * t, Qu.l = 0.8 - 0.9 * t, Qu + "";
}
var tl = Sn(), Cz = Math.PI / 3, Bz = Math.PI * 2 / 3;
function $6(e) {
  var t;
  return e = (0.5 - e) * Math.PI, tl.r = 255 * (t = Math.sin(e)) * t, tl.g = 255 * (t = Math.sin(e + Cz)) * t, tl.b = 255 * (t = Math.sin(e + Bz)) * t, tl + "";
}
function I6(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 td(e) {
  var t = e.length;
  return function(n) {
    return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))];
  };
}
const T6 = td(_t("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
var E6 = td(_t("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")), N6 = td(_t("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")), D6 = td(_t("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
function me(e) {
  return function() {
    return e;
  };
}
const O6 = Math.cos, Lm = Math.min, Hf = Math.sin, de = Math.sqrt, Mw = 1e-12, Jf = Math.PI, ed = 2 * Jf;
function L6(e) {
  let t = 3;
  return e.digits = function(n) {
    if (!arguments.length)
      return t;
    if (n == null)
      t = null;
    else {
      const r = Math.floor(n);
      if (!(r >= 0))
        throw new RangeError(`invalid digits: ${n}`);
      t = r;
    }
    return e;
  }, () => new oS(t);
}
function k6(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function F6(e) {
  this._context = e;
}
F6.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 mu(e) {
  return new F6(e);
}
function R6(e) {
  return e[0];
}
function C6(e) {
  return e[1];
}
function B6(e, t) {
  var n = me(!0), r = null, i = mu, s = null, o = L6(a);
  e = typeof e == "function" ? e : e === void 0 ? R6 : me(e), t = typeof t == "function" ? t : t === void 0 ? C6 : me(t);
  function a(c) {
    var u, l = (c = k6(c)).length, f, h = !1, d;
    for (r == null && (s = i(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 : me(+c), a) : e;
  }, a.y = function(c) {
    return arguments.length ? (t = typeof c == "function" ? c : me(+c), a) : t;
  }, a.defined = function(c) {
    return arguments.length ? (n = typeof c == "function" ? c : me(!!c), a) : n;
  }, a.curve = function(c) {
    return arguments.length ? (i = c, r != null && (s = i(r)), a) : i;
  }, a.context = function(c) {
    return arguments.length ? (c == null ? r = s = null : s = i(r = c), a) : r;
  }, a;
}
function km(e, t, n) {
  var r = null, i = me(!0), s = null, o = mu, a = null, c = L6(u);
  e = typeof e == "function" ? e : e === void 0 ? R6 : me(+e), t = typeof t == "function" ? t : me(t === void 0 ? 0 : +t), n = typeof n == "function" ? n : n === void 0 ? C6 : me(+n);
  function u(f) {
    var h, d, p, y = (f = k6(f)).length, g, m = !1, b, w = new Array(y), v = new Array(y);
    for (s == null && (a = o(b = c())), h = 0; h <= y; ++h) {
      if (!(h < y && i(g = 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], v[p]);
          a.lineEnd(), a.areaEnd();
        }
      m && (w[h] = +e(g, h, f), v[h] = +t(g, h, f), a.point(r ? +r(g, h, f) : w[h], n ? +n(g, h, f) : v[h]));
    }
    if (b)
      return a = null, b + "" || null;
  }
  function l() {
    return B6().defined(i).curve(o).context(s);
  }
  return u.x = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : me(+f), r = null, u) : e;
  }, u.x0 = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : me(+f), u) : e;
  }, u.x1 = function(f) {
    return arguments.length ? (r = f == null ? null : typeof f == "function" ? f : me(+f), u) : r;
  }, u.y = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : me(+f), n = null, u) : t;
  }, u.y0 = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : me(+f), u) : t;
  }, u.y1 = function(f) {
    return arguments.length ? (n = f == null ? null : typeof f == "function" ? f : me(+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(r).y(t);
  }, u.defined = function(f) {
    return arguments.length ? (i = typeof f == "function" ? f : me(!!f), u) : i;
  }, 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 P6 {
  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 Pz(e) {
  return new P6(e, !0);
}
function Uz(e) {
  return new P6(e, !1);
}
const zz = de(3), U6 = {
  draw(e, t) {
    const n = de(t + Lm(t / 28, 0.75)) * 0.59436, r = n / 2, i = r * zz;
    e.moveTo(0, n), e.lineTo(0, -n), e.moveTo(-i, -r), e.lineTo(i, r), e.moveTo(-i, r), e.lineTo(i, -r);
  }
}, Fc = {
  draw(e, t) {
    const n = de(t / Jf);
    e.moveTo(n, 0), e.arc(0, 0, n, 0, ed);
  }
}, z6 = {
  draw(e, t) {
    const n = de(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();
  }
}, j6 = de(1 / 3), jz = j6 * 2, q6 = {
  draw(e, t) {
    const n = de(t / jz), r = n * j6;
    e.moveTo(0, -n), e.lineTo(r, 0), e.lineTo(0, n), e.lineTo(-r, 0), e.closePath();
  }
}, V6 = {
  draw(e, t) {
    const n = de(t) * 0.62625;
    e.moveTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.lineTo(-n, 0), e.closePath();
  }
}, Y6 = {
  draw(e, t) {
    const n = de(t - Lm(t / 7, 2)) * 0.87559;
    e.moveTo(-n, 0), e.lineTo(n, 0), e.moveTo(0, n), e.lineTo(0, -n);
  }
}, W6 = {
  draw(e, t) {
    const n = de(t), r = -n / 2;
    e.rect(r, r, n, n);
  }
}, X6 = {
  draw(e, t) {
    const n = de(t) * 0.4431;
    e.moveTo(n, n), e.lineTo(n, -n), e.lineTo(-n, -n), e.lineTo(-n, n), e.closePath();
  }
}, qz = 0.8908130915292852, G6 = Hf(Jf / 10) / Hf(7 * Jf / 10), Vz = Hf(ed / 10) * G6, Yz = -O6(ed / 10) * G6, H6 = {
  draw(e, t) {
    const n = de(t * qz), r = Vz * n, i = Yz * n;
    e.moveTo(0, -n), e.lineTo(r, i);
    for (let s = 1; s < 5; ++s) {
      const o = ed * s / 5, a = O6(o), c = Hf(o);
      e.lineTo(c * n, -a * n), e.lineTo(a * r - c * i, c * r + a * i);
    }
    e.closePath();
  }
}, bp = de(3), J6 = {
  draw(e, t) {
    const n = -de(t / (bp * 3));
    e.moveTo(0, n * 2), e.lineTo(-bp * n, -n), e.lineTo(bp * n, -n), e.closePath();
  }
}, Wz = de(3), Z6 = {
  draw(e, t) {
    const n = de(t) * 0.6824, r = n / 2, i = n * Wz / 2;
    e.moveTo(0, -n), e.lineTo(i, r), e.lineTo(-i, r), e.closePath();
  }
}, fn = -0.5, hn = de(3) / 2, Z0 = 1 / de(12), Xz = (Z0 / 2 + 1) * 3, K6 = {
  draw(e, t) {
    const n = de(t / Xz), r = n / 2, i = n * Z0, s = r, o = n * Z0 + n, a = -s, c = o;
    e.moveTo(r, i), e.lineTo(s, o), e.lineTo(a, c), e.lineTo(fn * r - hn * i, hn * r + fn * i), e.lineTo(fn * s - hn * o, hn * s + fn * o), e.lineTo(fn * a - hn * c, hn * a + fn * c), e.lineTo(fn * r + hn * i, fn * i - hn * r), e.lineTo(fn * s + hn * o, fn * o - hn * s), e.lineTo(fn * a + hn * c, fn * c - hn * a), e.closePath();
  }
}, Q6 = {
  draw(e, t) {
    const n = de(t - Lm(t / 6, 1.7)) * 0.6189;
    e.moveTo(-n, -n), e.lineTo(n, n), e.moveTo(-n, n), e.lineTo(n, -n);
  }
}, Gz = [
  Fc,
  z6,
  q6,
  W6,
  H6,
  J6,
  K6
], Hz = [
  Fc,
  Y6,
  Q6,
  Z6,
  U6,
  X6,
  V6
];
function Ci() {
}
function Zf(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 nd(e) {
  this._context = e;
}
nd.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:
        Zf(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:
        Zf(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function Jz(e) {
  return new nd(e);
}
function tM(e) {
  this._context = e;
}
tM.prototype = {
  areaStart: Ci,
  areaEnd: Ci,
  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:
        Zf(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function Zz(e) {
  return new tM(e);
}
function eM(e) {
  this._context = e;
}
eM.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, r = (this._y0 + 4 * this._y1 + t) / 6;
        this._line ? this._context.lineTo(n, r) : this._context.moveTo(n, r);
        break;
      case 3:
        this._point = 4;
      default:
        Zf(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function Kz(e) {
  return new eM(e);
}
function nM(e, t) {
  this._basis = new nd(e), this._beta = t;
}
nM.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 r = e[0], i = t[0], s = e[n] - r, o = t[n] - i, a = -1, c; ++a <= n; )
        c = a / n, this._basis.point(
          this._beta * e[a] + (1 - this._beta) * (r + c * s),
          this._beta * t[a] + (1 - this._beta) * (i + c * o)
        );
    this._x = this._y = null, this._basis.lineEnd();
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
const Qz = function e(t) {
  function n(r) {
    return t === 1 ? new nd(r) : new nM(r, t);
  }
  return n.beta = function(r) {
    return e(+r);
  }, n;
}(0.85);
function Kf(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 Fm(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Fm.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:
        Kf(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:
        Kf(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 tj = function e(t) {
  function n(r) {
    return new Fm(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function Rm(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Rm.prototype = {
  areaStart: Ci,
  areaEnd: Ci,
  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:
        Kf(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 ej = function e(t) {
  function n(r) {
    return new Rm(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function Cm(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Cm.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:
        Kf(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 nj = function e(t) {
  function n(r) {
    return new Cm(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function Bm(e, t, n) {
  var r = e._x1, i = e._y1, s = e._x2, o = e._y2;
  if (e._l01_a > Mw) {
    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);
    r = (r * a - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / c, i = (i * a - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / c;
  }
  if (e._l23_a > Mw) {
    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(r, i, s, o, e._x2, e._y2);
}
function rM(e, t) {
  this._context = e, this._alpha = t;
}
rM.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, r = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, 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:
        Bm(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 rj = function e(t) {
  function n(r) {
    return t ? new rM(r, t) : new Fm(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function iM(e, t) {
  this._context = e, this._alpha = t;
}
iM.prototype = {
  areaStart: Ci,
  areaEnd: Ci,
  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, r = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, 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:
        Bm(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 ij = function e(t) {
  function n(r) {
    return t ? new iM(r, t) : new Rm(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function sM(e, t) {
  this._context = e, this._alpha = t;
}
sM.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, r = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, 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:
        Bm(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 sj = function e(t) {
  function n(r) {
    return t ? new sM(r, t) : new Cm(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function oM(e) {
  this._context = e;
}
oM.prototype = {
  areaStart: Ci,
  areaEnd: Ci,
  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 oj(e) {
  return new oM(e);
}
function Aw(e) {
  return e < 0 ? -1 : 1;
}
function $w(e, t, n) {
  var r = e._x1 - e._x0, i = t - e._x1, s = (e._y1 - e._y0) / (r || i < 0 && -0), o = (n - e._y1) / (i || r < 0 && -0), a = (s * i + o * r) / (r + i);
  return (Aw(s) + Aw(o)) * Math.min(Math.abs(s), Math.abs(o), 0.5 * Math.abs(a)) || 0;
}
function Iw(e, t) {
  var n = e._x1 - e._x0;
  return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
}
function wp(e, t, n) {
  var r = e._x0, i = e._y0, s = e._x1, o = e._y1, a = (s - r) / 3;
  e._context.bezierCurveTo(r + a, i + a * t, s - a, o - a * n, s, o);
}
function Qf(e) {
  this._context = e;
}
Qf.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:
        wp(this, this._t0, Iw(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, wp(this, Iw(this, n = $w(this, e, t)), n);
          break;
        default:
          wp(this, this._t0, n = $w(this, e, t));
          break;
      }
      this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
    }
  }
};
function aM(e) {
  this._context = new cM(e);
}
(aM.prototype = Object.create(Qf.prototype)).point = function(e, t) {
  Qf.prototype.point.call(this, t, e);
};
function cM(e) {
  this._context = e;
}
cM.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, r, i, s) {
    this._context.bezierCurveTo(t, e, r, n, s, i);
  }
};
function aj(e) {
  return new Qf(e);
}
function cj(e) {
  return new aM(e);
}
function uM(e) {
  this._context = e;
}
uM.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 r = Tw(e), i = Tw(t), s = 0, o = 1; o < n; ++s, ++o)
          this._context.bezierCurveTo(r[0][s], i[0][s], r[1][s], i[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 Tw(e) {
  var t, n = e.length - 1, r, i = new Array(n), s = new Array(n), o = new Array(n);
  for (i[0] = 0, s[0] = 2, o[0] = e[0] + 2 * e[1], t = 1; t < n - 1; ++t)
    i[t] = 1, s[t] = 4, o[t] = 4 * e[t] + 2 * e[t + 1];
  for (i[n - 1] = 2, s[n - 1] = 7, o[n - 1] = 8 * e[n - 1] + e[n], t = 1; t < n; ++t)
    r = i[t] / s[t - 1], s[t] -= r, o[t] -= r * o[t - 1];
  for (i[n - 1] = o[n - 1] / s[n - 1], t = n - 2; t >= 0; --t)
    i[t] = (o[t] - i[t + 1]) / s[t];
  for (s[n - 1] = (e[n] + i[n - 1]) / 2, t = 0; t < n - 1; ++t)
    s[t] = 2 * e[t + 1] - i[t + 1];
  return [i, s];
}
function uj(e) {
  return new uM(e);
}
function rd(e, t) {
  this._context = e, this._t = t;
}
rd.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 lj(e) {
  return new rd(e, 0.5);
}
function fj(e) {
  return new rd(e, 0);
}
function hj(e) {
  return new rd(e, 1);
}
const el = (e) => () => e;
function dj(e, {
  sourceEvent: t,
  target: n,
  transform: r,
  dispatch: i
}) {
  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: r, enumerable: !0, configurable: !0 },
    _: { value: i }
  });
}
function lr(e, t, n) {
  this.k = e, this.x = t, this.y = n;
}
lr.prototype = {
  constructor: lr,
  scale: function(e) {
    return e === 1 ? this : new lr(this.k * e, this.x, this.y);
  },
  translate: function(e, t) {
    return e === 0 & t === 0 ? this : new lr(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 lM = new lr(1, 0, 0);
lr.prototype;
function vp(e) {
  e.stopImmediatePropagation();
}
function Ua(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function pj(e) {
  return (!e.ctrlKey || e.type === "wheel") && !e.button;
}
function yj() {
  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 Ew() {
  return this.__zoom || lM;
}
function mj(e) {
  return -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 2e-3) * (e.ctrlKey ? 10 : 1);
}
function gj() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function bj(e, t, n) {
  var r = e.invertX(t[0][0]) - n[0][0], i = 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(
    i > r ? (r + i) / 2 : Math.min(0, r) || Math.max(0, i),
    o > s ? (s + o) / 2 : Math.min(0, s) || Math.max(0, o)
  );
}
function wj() {
  var e = pj, t = yj, n = bj, r = mj, i = gj, s = [0, 1 / 0], o = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], a = 250, c = tR, u = Rh("start", "zoom", "end"), l, f, h, d = 500, p = 150, y = 0, g = 10;
  function m(S) {
    S.property("__zoom", Ew).on("wheel.zoom", T, { passive: !1 }).on("mousedown.zoom", N).on("dblclick.zoom", A).filter(i).on("touchstart.zoom", $).on("touchmove.zoom", D).on("touchend.zoom touchcancel.zoom", F).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  m.transform = function(S, I, E, O) {
    var C = S.selection ? S.selection() : S;
    C.property("__zoom", Ew), S !== C ? x(S, I, E, O) : C.interrupt().each(function() {
      _(this, arguments).event(O).start().zoom(null, typeof I == "function" ? I.apply(this, arguments) : I).end();
    });
  }, m.scaleBy = function(S, I, E, O) {
    m.scaleTo(S, function() {
      var C = this.__zoom.k, B = typeof I == "function" ? I.apply(this, arguments) : I;
      return C * B;
    }, E, O);
  }, m.scaleTo = function(S, I, E, O) {
    m.transform(S, function() {
      var C = t.apply(this, arguments), B = this.__zoom, R = E == null ? v(C) : typeof E == "function" ? E.apply(this, arguments) : E, P = B.invert(R), U = typeof I == "function" ? I.apply(this, arguments) : I;
      return n(w(b(B, U), R, P), C, o);
    }, E, O);
  }, m.translateBy = function(S, I, E, O) {
    m.transform(S, function() {
      return n(this.__zoom.translate(
        typeof I == "function" ? I.apply(this, arguments) : I,
        typeof E == "function" ? E.apply(this, arguments) : E
      ), t.apply(this, arguments), o);
    }, null, O);
  }, m.translateTo = function(S, I, E, O, C) {
    m.transform(S, function() {
      var B = t.apply(this, arguments), R = this.__zoom, P = O == null ? v(B) : typeof O == "function" ? O.apply(this, arguments) : O;
      return n(lM.translate(P[0], P[1]).scale(R.k).translate(
        typeof I == "function" ? -I.apply(this, arguments) : -I,
        typeof E == "function" ? -E.apply(this, arguments) : -E
      ), B, o);
    }, O, C);
  };
  function b(S, I) {
    return I = Math.max(s[0], Math.min(s[1], I)), I === S.k ? S : new lr(I, S.x, S.y);
  }
  function w(S, I, E) {
    var O = I[0] - E[0] * S.k, C = I[1] - E[1] * S.k;
    return O === S.x && C === S.y ? S : new lr(S.k, O, C);
  }
  function v(S) {
    return [(+S[0][0] + +S[1][0]) / 2, (+S[0][1] + +S[1][1]) / 2];
  }
  function x(S, I, E, O) {
    S.on("start.zoom", function() {
      _(this, arguments).event(O).start();
    }).on("interrupt.zoom end.zoom", function() {
      _(this, arguments).event(O).end();
    }).tween("zoom", function() {
      var C = this, B = arguments, R = _(C, B).event(O), P = t.apply(C, B), U = E == null ? v(P) : typeof E == "function" ? E.apply(C, B) : E, Y = Math.max(P[1][0] - P[0][0], P[1][1] - P[0][1]), G = C.__zoom, Z = typeof I == "function" ? I.apply(C, B) : I, H = c(G.invert(U).concat(Y / G.k), Z.invert(U).concat(Y / Z.k));
      return function(q) {
        if (q === 1)
          q = Z;
        else {
          var W = H(q), j = Y / W[2];
          q = new lr(j, U[0] - W[0] * j, U[1] - W[1] * j);
        }
        R.zoom(null, q);
      };
    });
  }
  function _(S, I, E) {
    return !E && S.__zooming || new M(S, I);
  }
  function M(S, I) {
    this.that = S, this.args = I, this.active = 0, this.sourceEvent = null, this.extent = t.apply(S, I), this.taps = 0;
  }
  M.prototype = {
    event: function(S) {
      return S && (this.sourceEvent = S), this;
    },
    start: function() {
      return ++this.active === 1 && (this.that.__zooming = this, this.emit("start")), this;
    },
    zoom: function(S, I) {
      return this.mouse && S !== "mouse" && (this.mouse[1] = I.invert(this.mouse[0])), this.touch0 && S !== "touch" && (this.touch0[1] = I.invert(this.touch0[0])), this.touch1 && S !== "touch" && (this.touch1[1] = I.invert(this.touch1[0])), this.that.__zoom = I, this.emit("zoom"), this;
    },
    end: function() {
      return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
    },
    emit: function(S) {
      var I = Vt(this.that).datum();
      u.call(
        S,
        this.that,
        new dj(S, {
          sourceEvent: this.sourceEvent,
          target: m,
          type: S,
          transform: this.that.__zoom,
          dispatch: u
        }),
        I
      );
    }
  };
  function T(S, ...I) {
    if (!e.apply(this, arguments))
      return;
    var E = _(this, I).event(S), O = this.__zoom, C = Math.max(s[0], Math.min(s[1], O.k * Math.pow(2, r.apply(this, arguments)))), B = En(S);
    if (E.wheel)
      (E.mouse[0][0] !== B[0] || E.mouse[0][1] !== B[1]) && (E.mouse[1] = O.invert(E.mouse[0] = B)), clearTimeout(E.wheel);
    else {
      if (O.k === C)
        return;
      E.mouse = [B, O.invert(B)], ko(this), E.start();
    }
    Ua(S), E.wheel = setTimeout(R, p), E.zoom("mouse", n(w(b(O, C), E.mouse[0], E.mouse[1]), E.extent, o));
    function R() {
      E.wheel = null, E.end();
    }
  }
  function N(S, ...I) {
    if (h || !e.apply(this, arguments))
      return;
    var E = S.currentTarget, O = _(this, I, !0).event(S), C = Vt(S.view).on("mousemove.zoom", U, !0).on("mouseup.zoom", Y, !0), B = En(S, E), R = S.clientX, P = S.clientY;
    kx(S.view), vp(S), O.mouse = [B, this.__zoom.invert(B)], ko(this), O.start();
    function U(G) {
      if (Ua(G), !O.moved) {
        var Z = G.clientX - R, H = G.clientY - P;
        O.moved = Z * Z + H * H > y;
      }
      O.event(G).zoom("mouse", n(w(O.that.__zoom, O.mouse[0] = En(G, E), O.mouse[1]), O.extent, o));
    }
    function Y(G) {
      C.on("mousemove.zoom mouseup.zoom", null), Fx(G.view, O.moved), Ua(G), O.event(G).end();
    }
  }
  function A(S, ...I) {
    if (e.apply(this, arguments)) {
      var E = this.__zoom, O = En(S.changedTouches ? S.changedTouches[0] : S, this), C = E.invert(O), B = E.k * (S.shiftKey ? 0.5 : 2), R = n(w(b(E, B), O, C), t.apply(this, I), o);
      Ua(S), a > 0 ? Vt(this).transition().duration(a).call(x, R, O, S) : Vt(this).call(m.transform, R, O, S);
    }
  }
  function $(S, ...I) {
    if (e.apply(this, arguments)) {
      var E = S.touches, O = E.length, C = _(this, I, S.changedTouches.length === O).event(S), B, R, P, U;
      for (vp(S), R = 0; R < O; ++R)
        P = E[R], U = En(P, this), U = [U, this.__zoom.invert(U), P.identifier], C.touch0 ? !C.touch1 && C.touch0[2] !== U[2] && (C.touch1 = U, C.taps = 0) : (C.touch0 = U, B = !0, C.taps = 1 + !!l);
      l && (l = clearTimeout(l)), B && (C.taps < 2 && (f = U[0], l = setTimeout(function() {
        l = null;
      }, d)), ko(this), C.start());
    }
  }
  function D(S, ...I) {
    if (this.__zooming) {
      var E = _(this, I).event(S), O = S.changedTouches, C = O.length, B, R, P, U;
      for (Ua(S), B = 0; B < C; ++B)
        R = O[B], P = En(R, this), E.touch0 && E.touch0[2] === R.identifier ? E.touch0[0] = P : E.touch1 && E.touch1[2] === R.identifier && (E.touch1[0] = P);
      if (R = E.that.__zoom, E.touch1) {
        var Y = E.touch0[0], G = E.touch0[1], Z = E.touch1[0], H = E.touch1[1], q = (q = Z[0] - Y[0]) * q + (q = Z[1] - Y[1]) * q, W = (W = H[0] - G[0]) * W + (W = H[1] - G[1]) * W;
        R = b(R, Math.sqrt(q / W)), P = [(Y[0] + Z[0]) / 2, (Y[1] + Z[1]) / 2], U = [(G[0] + H[0]) / 2, (G[1] + H[1]) / 2];
      } else if (E.touch0)
        P = E.touch0[0], U = E.touch0[1];
      else
        return;
      E.zoom("touch", n(w(R, P, U), E.extent, o));
    }
  }
  function F(S, ...I) {
    if (this.__zooming) {
      var E = _(this, I).event(S), O = S.changedTouches, C = O.length, B, R;
      for (vp(S), h && clearTimeout(h), h = setTimeout(function() {
        h = null;
      }, d), B = 0; B < C; ++B)
        R = O[B], E.touch0 && E.touch0[2] === R.identifier ? delete E.touch0 : E.touch1 && E.touch1[2] === R.identifier && delete E.touch1;
      if (E.touch1 && !E.touch0 && (E.touch0 = E.touch1, delete E.touch1), E.touch0)
        E.touch0[1] = this.__zoom.invert(E.touch0[0]);
      else if (E.end(), E.taps === 2 && (R = En(R, this), Math.hypot(f[0] - R[0], f[1] - R[1]) < g)) {
        var P = Vt(this).on("dblclick.zoom");
        P && P.apply(this, arguments);
      }
    }
  }
  return m.wheelDelta = function(S) {
    return arguments.length ? (r = typeof S == "function" ? S : el(+S), m) : r;
  }, m.filter = function(S) {
    return arguments.length ? (e = typeof S == "function" ? S : el(!!S), m) : e;
  }, m.touchable = function(S) {
    return arguments.length ? (i = typeof S == "function" ? S : el(!!S), m) : i;
  }, m.extent = function(S) {
    return arguments.length ? (t = typeof S == "function" ? S : el([[+S[0][0], +S[0][1]], [+S[1][0], +S[1][1]]]), m) : t;
  }, m.scaleExtent = function(S) {
    return arguments.length ? (s[0] = +S[0], s[1] = +S[1], m) : [s[0], s[1]];
  }, m.translateExtent = function(S) {
    return arguments.length ? (o[0][0] = +S[0][0], o[1][0] = +S[1][0], o[0][1] = +S[0][1], o[1][1] = +S[1][1], m) : [[o[0][0], o[0][1]], [o[1][0], o[1][1]]];
  }, m.constrain = function(S) {
    return arguments.length ? (n = S, m) : n;
  }, m.duration = function(S) {
    return arguments.length ? (a = +S, m) : a;
  }, m.interpolate = function(S) {
    return arguments.length ? (c = S, m) : c;
  }, m.on = function() {
    var S = u.on.apply(u, arguments);
    return S === u ? m : S;
  }, m.clickDistance = function(S) {
    return arguments.length ? (y = (S = +S) * S, m) : Math.sqrt(y);
  }, m.tapDistance = function(S) {
    return arguments.length ? (g = +S, m) : g;
  }, m;
}
function Re(e) {
  return e != null && !Number.isNaN(e);
}
function Mn(e, t) {
  return +Re(t) - +Re(e) || re(e, t);
}
function th(e, t) {
  return +Re(t) - +Re(e) || ks(e, t);
}
function Pm(e) {
  return e != null && `${e}` != "";
}
function eh(e) {
  return isFinite(e) ? e : NaN;
}
function Gr(e) {
  return e > 0 && isFinite(e) ? e : NaN;
}
function id(e) {
  return e < 0 && isFinite(e) ? e : NaN;
}
function fM(e, t) {
  if (e instanceof Date || (e = /* @__PURE__ */ new Date(+e)), isNaN(e))
    return typeof t == "function" ? t(e) : t;
  const n = e.getUTCHours(), r = e.getUTCMinutes(), i = e.getUTCSeconds(), s = e.getUTCMilliseconds();
  return `${vj(e.getUTCFullYear())}-${Cr(e.getUTCMonth() + 1, 2)}-${Cr(e.getUTCDate(), 2)}${n || r || i || s ? `T${Cr(n, 2)}:${Cr(r, 2)}${i || s ? `:${Cr(i, 2)}${s ? `.${Cr(s, 3)}` : ""}` : ""}Z` : ""}`;
}
function vj(e) {
  return e < 0 ? `-${Cr(-e, 6)}` : e > 9999 ? `+${Cr(e, 6)}` : Cr(e, 4);
}
function Cr(e, t) {
  return `${e}`.padStart(t, "0");
}
const _j = /^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;
function Um(e, t) {
  return _j.test(e += "") ? new Date(e) : typeof t == "function" ? t(e) : t;
}
const vo = 1e3, xi = vo * 60, Si = xi * 60, wr = Si * 24, Kn = wr * 7, $s = wr * 30, fi = wr * 365, _p = [
  ["millisecond", 1],
  ["2 milliseconds", 2],
  ["5 milliseconds", 5],
  ["10 milliseconds", 10],
  ["20 milliseconds", 20],
  ["50 milliseconds", 50],
  ["100 milliseconds", 100],
  ["200 milliseconds", 200],
  ["500 milliseconds", 500],
  ["second", vo],
  ["5 seconds", 5 * vo],
  ["15 seconds", 15 * vo],
  ["30 seconds", 30 * vo],
  ["minute", xi],
  ["5 minutes", 5 * xi],
  ["15 minutes", 15 * xi],
  ["30 minutes", 30 * xi],
  ["hour", Si],
  ["3 hours", 3 * Si],
  ["6 hours", 6 * Si],
  ["12 hours", 12 * Si],
  ["day", wr],
  ["2 days", 2 * wr],
  ["week", Kn],
  ["2 weeks", 2 * Kn],
  // https://github.com/d3/d3-time/issues/46
  ["month", $s],
  ["3 months", 3 * $s],
  ["6 months", 6 * $s],
  // https://github.com/d3/d3-time/issues/46
  ["year", fi],
  ["2 years", 2 * fi],
  ["5 years", 5 * fi],
  ["10 years", 10 * fi],
  ["20 years", 20 * fi],
  ["50 years", 50 * fi],
  ["100 years", 100 * fi]
  // TODO generalize to longer time scales
], zm = /* @__PURE__ */ new Map([
  ["second", vo],
  ["minute", xi],
  ["hour", Si],
  ["day", wr],
  ["monday", Kn],
  ["tuesday", Kn],
  ["wednesday", Kn],
  ["thursday", Kn],
  ["friday", Kn],
  ["saturday", Kn],
  ["sunday", Kn],
  ["week", Kn],
  ["month", $s],
  ["year", fi]
]), hM = /* @__PURE__ */ new Map([
  ["second", Fn],
  ["minute", uu],
  ["hour", fu],
  ["day", Ws],
  // https://github.com/d3/d3-time/issues/62
  ["monday", Lc],
  ["tuesday", a3],
  ["wednesday", c3],
  ["thursday", zs],
  ["friday", u3],
  ["saturday", l3],
  ["sunday", ra],
  ["week", ra],
  ["month", du],
  ["year", zn]
]), jm = /* @__PURE__ */ new Map([
  ["second", Fn],
  ["minute", lu],
  ["hour", hu],
  ["day", Zh],
  ["monday", kc],
  ["tuesday", f3],
  ["wednesday", h3],
  ["thursday", js],
  ["friday", d3],
  ["saturday", p3],
  ["sunday", ia],
  ["week", ia],
  ["month", pu],
  ["year", jn]
]), gu = Symbol("intervalDuration"), sd = Symbol("intervalType");
for (const [e, t] of hM)
  t[gu] = zm.get(e), t[sd] = "time";
for (const [e, t] of jm)
  t[gu] = zm.get(e), t[sd] = "utc";
const ec = [
  ["year", jn, "utc"],
  ["month", pu, "utc"],
  ["day", Zh, "utc", 6 * $s],
  ["hour", hu, "utc", 3 * wr],
  ["minute", lu, "utc", 6 * Si],
  ["second", Fn, "utc", 30 * xi]
], Nl = [
  ["year", zn, "time"],
  ["month", du, "time"],
  ["day", Ws, "time", 6 * $s],
  ["hour", fu, "time", 3 * wr],
  ["minute", uu, "time", 6 * Si],
  ["second", Fn, "time", 30 * xi]
], xj = [
  ec[0],
  Nl[0],
  ec[1],
  Nl[1],
  ec[2],
  Nl[2],
  // Below day, local time typically has an hourly offset from UTC and hence the
  // two are aligned and indistinguishable; therefore, we only consider UTC, and
  // we don’t consider these if the domain only has a single value.
  ...ec.slice(3)
];
function qm(e) {
  let t = `${e}`.toLowerCase();
  t.endsWith("s") && (t = t.slice(0, -1));
  let n = 1;
  const r = /^(?:(\d+)\s+)/.exec(t);
  switch (r && (t = t.slice(r[0].length), n = +r[1]), t) {
    case "quarter":
      t = "month", n *= 3;
      break;
    case "half":
      t = "month", n *= 6;
      break;
  }
  let i = jm.get(t);
  if (!i)
    throw new Error(`unknown interval: ${e}`);
  if (n > 1 && !i.every)
    throw new Error(`non-periodic interval: ${t}`);
  return [t, n];
}
function dM(e) {
  return pM(qm(e), "time");
}
function Vm(e) {
  return pM(qm(e), "utc");
}
function pM([e, t], n) {
  let r = (n === "time" ? hM : jm).get(e);
  return t > 1 && (r = r.every(t), r[gu] = zm.get(e) * t, r[sd] = n), r;
}
function Nw(e, t) {
  if (!(t > 1))
    return;
  const n = e[gu];
  if (!_p.some(([, i]) => i === n) || n % wr === 0 && wr < n && n < $s)
    return;
  const [r] = _p[Oh(([, i]) => Math.log(i)).center(_p, Math.log(n * t))];
  return (e[sd] === "time" ? dM : Vm)(r);
}
function Dw(e, t, n) {
  const r = t === "time" ? Dm : yu;
  if (n == null)
    return r(
      e === "year" ? "%Y" : e === "month" ? "%Y-%m" : e === "day" ? "%Y-%m-%d" : e === "hour" || e === "minute" ? "%Y-%m-%dT%H:%M" : e === "second" ? "%Y-%m-%dT%H:%M:%S" : "%Y-%m-%dT%H:%M:%S.%L"
    );
  const i = Sj(n);
  switch (e) {
    case "millisecond":
      return ao(r(".%L"), r(":%M:%S"), i);
    case "second":
      return ao(r(":%S"), r("%-I:%M"), i);
    case "minute":
      return ao(r("%-I:%M"), r("%p"), i);
    case "hour":
      return ao(r("%-I %p"), r("%b %-d"), i);
    case "day":
      return ao(r("%-d"), r("%b"), i);
    case "month":
      return ao(r("%b"), r("%Y"), i);
    case "year":
      return r("%Y");
  }
  throw new Error("unable to format time ticks");
}
function Sj(e) {
  return e === "left" || e === "right" ? (t, n) => `
${t}
${n}` : e === "top" ? (t, n) => `${n}
${t}` : (t, n) => `${t}
${n}`;
}
function Mj(e) {
  return e === "time" ? Nl : e === "utc" ? ec : xj;
}
function Aj(e, t, n) {
  const r = Qt(TL(t, (i, s) => Math.abs(s - i)));
  if (r < 1e3)
    return Dw("millisecond", "utc", n);
  for (const [i, s, o, a] of Mj(e)) {
    if (r > a || i === "hour" && !r)
      break;
    if (t.every((c) => s.floor(c) >= c))
      return Dw(i, o, n);
  }
}
function ao(e, t, n) {
  return (r, i, s) => {
    const o = e(r, i), a = t(r, i), c = i - aa(s);
    return i !== c && s[c] !== void 0 && a === t(s[c], c) ? o : n(o, a);
  };
}
const sa = Object.getPrototypeOf(Uint8Array), $j = Object.prototype.toString, yM = Symbol("reindex");
function At(e, t, n) {
  const r = typeof t;
  return r === "string" ? Ow(e, mM(t), n) : r === "function" ? Ow(e, t, n) : r === "number" || t instanceof Date || r === "boolean" ? Gt(e, un(t), n) : typeof (t == null ? void 0 : t.transform) == "function" ? Lw(t.transform(e), n) : Ij(Lw(t, n), e == null ? void 0 : e[yM]);
}
function Ij(e, t) {
  return t ? ad(e, t) : e;
}
function Ow(e, t, n) {
  return Gt(e, (n == null ? void 0 : n.prototype) instanceof sa ? Tj(t) : t, n);
}
function Lw(e, t) {
  return t === void 0 ? Ze(e) : e instanceof t ? e : t.prototype instanceof sa && !(e instanceof sa) ? t.from(e, Xm) : t.from(e);
}
function Tj(e) {
  return (t, n) => Xm(e(t, n));
}
const cc = [null], mM = (e) => (t) => t[e], ze = { transform: si }, at = { transform: (e) => e }, Ym = () => 1, Ej = () => !0, Te = (e) => e == null ? e : `${e}`, Et = (e) => e == null ? e : +e, bu = (e) => e ? e[0] : void 0, Rc = (e) => e ? e[1] : void 0, Nj = (e) => e ? e[2] : void 0, un = (e) => () => e;
function Wm(e) {
  const t = +`${e}`.slice(1) / 100;
  return (n, r) => Fi(n, t, r);
}
function We(e) {
  return e instanceof sa ? e : Gt(e, Xm, Float64Array);
}
function Xm(e) {
  return e == null ? NaN : Number(e);
}
function Dj(e) {
  return Gt(e, gM);
}
function gM(e) {
  return e instanceof Date && !isNaN(e) ? e : typeof e == "string" ? Um(e) : e == null || isNaN(e = +e) ? void 0 : new Date(e);
}
function Be(e, t) {
  return e === void 0 && (e = t), e === null ? [void 0, "none"] : wu(e) ? [void 0, e] : [e, void 0];
}
function ce(e, t) {
  return e === void 0 && (e = t), e === null || typeof e == "number" ? [void 0, e] : [e, void 0];
}
function bM(e, t, n) {
  if (e != null)
    return ln(e, t, n);
}
function ln(e, t, n) {
  const r = `${e}`.toLowerCase();
  if (!n.includes(r))
    throw new Error(`invalid ${t}: ${e}`);
  return r;
}
function Ze(e) {
  return e == null || e instanceof Array || e instanceof sa ? e : Array.from(e);
}
function Gt(e, t, n = Array) {
  return e == null ? e : e instanceof n ? e.map(t) : n.from(e, t);
}
function Cc(e, t = Array) {
  return e instanceof t ? e.slice() : t.from(e);
}
function wM({ x: e, x1: t, x2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function vM({ y: e, y1: t, y2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function od(e) {
  return wM(e) || vM(e) || e.interval !== void 0;
}
function $n(e) {
  return (e == null ? void 0 : e.toString) === $j;
}
function Is(e) {
  return $n(e) && (e.type !== void 0 || e.domain !== void 0);
}
function Qn(e) {
  return $n(e) && typeof e.transform != "function";
}
function Bi(e) {
  return Qn(e) && e.value === void 0 && e.channel === void 0;
}
function _M(e, t, n, r = at) {
  return t === void 0 && n === void 0 ? (t = 0, n = e === void 0 ? r : e) : t === void 0 ? t = e === void 0 ? 0 : e : n === void 0 && (n = e === void 0 ? 0 : e), [t, n];
}
function Wn(e, t) {
  return e === void 0 && t === void 0 ? [bu, Rc] : [e, t];
}
function Ji({ z: e, fill: t, stroke: n } = {}) {
  return e === void 0 && ([e] = Be(t)), e === void 0 && ([e] = Be(n)), e;
}
function si(e) {
  const t = e.length, n = new Uint32Array(t);
  for (let r = 0; r < t; ++r)
    n[r] = r;
  return n;
}
function ad(e, t) {
  return Gt(t, (n) => e[n], e.constructor);
}
function Gm(e) {
  return e.length === 1 ? (t, n) => e(ad(n, t)) : e;
}
function Ts(e, t, n) {
  return e.subarray ? e.subarray(t, n) : e.slice(t, n);
}
function ws(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function xM(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 sn(e) {
  let t;
  return [
    {
      transform: () => t,
      label: Sr(e)
    },
    (n) => t = n
  ];
}
function qe(e) {
  return e == null ? [e] : sn(e);
}
function Sr(e, t) {
  return typeof e == "string" ? e : e && e.label !== void 0 ? e.label : t;
}
function nh(e, t) {
  return {
    transform(n) {
      const r = e.transform(n), i = t.transform(n);
      return Pe(r) || Pe(i) ? Gt(r, (s, o) => new Date((+r[o] + +i[o]) / 2)) : Gt(r, (s, o) => (+r[o] + +i[o]) / 2, Float64Array);
    },
    label: e.label
  };
}
function rh(e, t) {
  const n = SM(t == null ? void 0 : t.interval, t == null ? void 0 : t.type);
  return n ? Gt(e, n) : e;
}
function SM(e, t) {
  const n = cd(e, t);
  return n && ((r) => Re(r) ? n.floor(r) : r);
}
function cd(e, t) {
  if (e != null) {
    if (typeof e == "number") {
      0 < e && e < 1 && Number.isInteger(1 / e) && (e = -1 / e);
      const n = Math.abs(e);
      return e < 0 ? {
        floor: (r) => Math.floor(r * n) / n,
        offset: (r) => (r * n + 1) / n,
        // note: no optional step for simplicity
        range: (r, i) => nn(Math.ceil(r * n), i * n).map((s) => s / n)
      } : {
        floor: (r) => Math.floor(r / n) * n,
        offset: (r) => r + n,
        // note: no optional step for simplicity
        range: (r, i) => nn(Math.ceil(r / n), i / n).map((s) => s * n)
      };
    }
    if (typeof e == "string")
      return (t === "time" ? dM : Vm)(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 _a(e, t) {
  if (e = cd(e, t), e && typeof e.range != "function")
    throw new Error("invalid interval: missing range method");
  return e;
}
function Oj(e, t) {
  if (e = _a(e, t), e && typeof e.ceil != "function")
    throw new Error("invalid interval: missing ceil method");
  return e;
}
function Lj(e) {
  return _o(e) && typeof (e == null ? void 0 : e.floor) == "function" && e.floor() instanceof Date;
}
function _o(e) {
  return typeof (e == null ? void 0 : e.range) == "function";
}
function xa(e) {
  return e === void 0 || Qn(e) ? e : { value: e };
}
function kj(e) {
  return e == null ? null : {
    transform: (t) => At(t, e, Float64Array),
    label: Sr(e)
  };
}
function Fj(e) {
  if (!oi(e))
    return !1;
  for (const t of e)
    if (t != null)
      return typeof t == "object" && "0" in t && "1" in t;
}
function oi(e) {
  return e && typeof e[Symbol.iterator] == "function";
}
function MM(e) {
  for (const t of e)
    if (t != null)
      return typeof t != "object" || t instanceof Date;
}
function ie(e) {
  for (const t of e) {
    if (t == null)
      continue;
    const n = typeof t;
    return n === "string" || n === "boolean";
  }
}
function Pe(e) {
  for (const t of e)
    if (t != null)
      return t instanceof Date;
}
function Rj(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "string" && isNaN(t) && Um(t);
}
function Cj(e) {
  for (const t of e)
    if (t != null) {
      if (typeof t != "string")
        return !1;
      if (t.trim())
        return !isNaN(t);
    }
}
function xo(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "number";
}
function xp(e, t) {
  let n;
  for (const r of e)
    if (r != null) {
      if (!t(r))
        return !1;
      n = !0;
    }
  return n;
}
const Bj = new Set("none,currentcolor,transparent,aliceblue,antiquewhite,aqua,aquamarine,azure,beige,bisque,black,blanchedalmond,blue,blueviolet,brown,burlywood,cadetblue,chartreuse,chocolate,coral,cornflowerblue,cornsilk,crimson,cyan,darkblue,darkcyan,darkgoldenrod,darkgray,darkgreen,darkgrey,darkkhaki,darkmagenta,darkolivegreen,darkorange,darkorchid,darkred,darksalmon,darkseagreen,darkslateblue,darkslategray,darkslategrey,darkturquoise,darkviolet,deeppink,deepskyblue,dimgray,dimgrey,dodgerblue,firebrick,floralwhite,forestgreen,fuchsia,gainsboro,ghostwhite,gold,goldenrod,gray,green,greenyellow,grey,honeydew,hotpink,indianred,indigo,ivory,khaki,lavender,lavenderblush,lawngreen,lemonchiffon,lightblue,lightcoral,lightcyan,lightgoldenrodyellow,lightgray,lightgreen,lightgrey,lightpink,lightsalmon,lightseagreen,lightskyblue,lightslategray,lightslategrey,lightsteelblue,lightyellow,lime,limegreen,linen,magenta,maroon,mediumaquamarine,mediumblue,mediumorchid,mediumpurple,mediumseagreen,mediumslateblue,mediumspringgreen,mediumturquoise,mediumvioletred,midnightblue,mintcream,mistyrose,moccasin,navajowhite,navy,oldlace,olive,olivedrab,orange,orangered,orchid,palegoldenrod,palegreen,paleturquoise,palevioletred,papayawhip,peachpuff,peru,pink,plum,powderblue,purple,rebeccapurple,red,rosybrown,royalblue,saddlebrown,salmon,sandybrown,seagreen,seashell,sienna,silver,skyblue,slateblue,slategray,slategrey,snow,springgreen,steelblue,tan,teal,thistle,tomato,turquoise,violet,wheat,white,whitesmoke,yellow".split(","));
function wu(e) {
  return typeof e != "string" ? !1 : (e = e.toLowerCase().trim(), /^#[0-9a-f]{3,8}$/.test(e) || // hex rgb, rgba, rrggbb, rrggbbaa
  /^(?:url|var|rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.*\)$/.test(e) || // <funciri>, CSS variable, color, etc.
  Bj.has(e));
}
function Pj(e) {
  return typeof e == "number" && (0 <= e && e <= 1 || isNaN(e));
}
function Kt(e) {
  return e == null || oa(e);
}
function oa(e) {
  return /^\s*none\s*$/i.test(e);
}
function Uj(e) {
  return /^\s*round\s*$/i.test(e);
}
function K0(e, t) {
  return bM(e, t, [
    "middle",
    "top-left",
    "top",
    "top-right",
    "right",
    "bottom-right",
    "bottom",
    "bottom-left",
    "left"
  ]);
}
function vu(e = "middle") {
  return K0(e, "frameAnchor");
}
function aa(e) {
  if (e == null)
    return;
  const t = e[0], n = e[e.length - 1];
  return ks(t, n);
}
function zj(e = {}, ...t) {
  let n = e;
  for (const r of t)
    for (const i in r)
      if (n[i] === void 0) {
        const s = r[i];
        n === e ? n = { ...n, [i]: s } : n[i] = s;
      }
  return n;
}
function jj(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: r } = n;
      if (r == null)
        throw new Error("missing name");
      const i = `${r}`;
      if (i === "__proto__")
        throw new Error(`illegal name: ${i}`);
      if (t.has(i))
        throw new Error(`duplicate name: ${i}`);
      return t.add(i), [r, n];
    })
  );
}
function Hm(e) {
  return oi(e) ? jj(e) : e;
}
const fr = Symbol("position"), ai = Symbol("color"), _u = Symbol("radius"), xu = Symbol("length"), Su = Symbol("opacity"), ud = Symbol("symbol"), AM = Symbol("projection"), ne = /* @__PURE__ */ new Map([
  ["x", fr],
  ["y", fr],
  ["fx", fr],
  ["fy", fr],
  ["r", _u],
  ["color", ai],
  ["opacity", Su],
  ["symbol", ud],
  ["length", xu],
  ["projection", AM]
]);
function qj(e) {
  return e === fr || e === AM;
}
function Vj(e) {
  return e === fr || e === _u || e === xu || e === Su;
}
const $M = Math.sqrt(3), IM = 2 / $M, Yj = {
  draw(e, t) {
    const n = Math.sqrt(t / Math.PI), r = n * IM, i = r / 2;
    e.moveTo(0, r), e.lineTo(n, i), e.lineTo(n, -i), e.lineTo(0, -r), e.lineTo(-n, -i), e.lineTo(-n, i), e.closePath();
  }
}, Jm = /* @__PURE__ */ new Map([
  ["asterisk", U6],
  ["circle", Fc],
  ["cross", z6],
  ["diamond", q6],
  ["diamond2", V6],
  ["hexagon", Yj],
  ["plus", Y6],
  ["square", W6],
  ["square2", X6],
  ["star", H6],
  ["times", Q6],
  ["triangle", J6],
  ["triangle2", Z6],
  ["wye", K6]
]);
function Zm(e) {
  return e && typeof e.draw == "function";
}
function Wj(e) {
  return Zm(e) ? !0 : typeof e != "string" ? !1 : Jm.has(e.toLowerCase());
}
function Km(e) {
  if (e == null || Zm(e))
    return e;
  const t = Jm.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid symbol: ${e}`);
}
function Xj(e) {
  if (e == null || Zm(e))
    return [void 0, e];
  if (typeof e == "string") {
    const t = Jm.get(`${e}`.toLowerCase());
    if (t)
      return [void 0, t];
  }
  return [e, void 0];
}
function Mr({ filter: e, sort: t, reverse: n, transform: r, initializer: i, ...s } = {}, o) {
  if (r === void 0 && (e != null && (r = Qm(e)), t != null && !Bi(t) && (r = Sp(r, eg(t))), n && (r = Sp(r, tg))), o != null && i != null)
    throw new Error("transforms cannot be applied after initializers");
  return {
    ...s,
    ...(t === null || Bi(t)) && { sort: t },
    transform: Sp(r, o)
  };
}
function Ke({ filter: e, sort: t, reverse: n, initializer: r, ...i } = {}, s) {
  return r === void 0 && (e != null && (r = Qm(e)), t != null && !Bi(t) && (r = Mp(r, eg(t))), n && (r = Mp(r, tg))), {
    ...i,
    ...(t === null || Bi(t)) && { sort: t },
    initializer: Mp(r, s)
  };
}
function Sp(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, r, i) {
    return { data: n, facets: r } = e.call(this, n, r, i), t.call(this, Ze(n), r, i);
  };
}
function Mp(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, r, i, ...s) {
    let o, a, c, u, l, f;
    return { data: a = n, facets: c = r, channels: o } = e.call(this, n, r, i, ...s), { data: l = a, facets: f = c, channels: u } = t.call(this, a, c, { ...i, ...o }, ...s), { data: l, facets: f, channels: { ...o, ...u } };
  };
}
function ld(e, t) {
  return (e.initializer != null ? Ke : Mr)(e, t);
}
function Gj(e, t) {
  return ld(t, Qm(e));
}
function Qm(e) {
  return (t, n) => {
    const r = At(t, e);
    return { data: t, facets: n.map((i) => i.filter((s) => r[s])) };
  };
}
function Hj({ sort: e, ...t } = {}) {
  return {
    ...ld(t, tg),
    sort: Bi(e) ? e : null
  };
}
function tg(e, t) {
  return { data: e, facets: t.map((n) => n.slice().reverse()) };
}
function Jj({ seed: e, sort: t, ...n } = {}) {
  return {
    ...ld(n, EM(e == null ? Math.random : Tm(e))),
    sort: Bi(t) ? t : null
  };
}
function TM(e, { sort: t, ...n } = {}) {
  return {
    ...(Qn(e) && e.channel !== void 0 ? Ke : ld)(n, eg(e)),
    sort: Bi(t) ? t : null
  };
}
function eg(e) {
  return (typeof e == "function" && e.length !== 1 ? Zj : EM)(e);
}
function Zj(e) {
  return (t, n) => {
    const r = (i, s) => e(t[i], t[s]);
    return { data: t, facets: n.map((i) => i.slice().sort(r)) };
  };
}
function EM(e) {
  let t, n;
  ({ channel: t, value: e, order: n } = { ...xa(e) });
  const r = t == null ? void 0 : t.startsWith("-");
  if (r && (t = t.slice(1)), n === void 0 && (n = r ? th : Mn), typeof n != "function")
    switch (`${n}`.toLowerCase()) {
      case "ascending":
        n = Mn;
        break;
      case "descending":
        n = th;
        break;
      default:
        throw new Error(`invalid order: ${n}`);
    }
  return (i, s, o) => {
    let a;
    if (t === void 0)
      a = At(i, e);
    else {
      if (o === void 0)
        throw new Error("channel sort requires an initializer");
      if (a = o[t], !a)
        return {};
      a = a.value;
    }
    const c = (u, l) => n(a[u], a[l]);
    return { data: i, facets: s.map((u) => u.slice().sort(c)) };
  };
}
function ng(e, t) {
  return fd(null, null, e, t);
}
function Bc(e = { y: "count" }, t = {}) {
  const { x: n = at } = t;
  if (n == null)
    throw new Error("missing channel: x");
  return fd(n, null, e, t);
}
function Pc(e = { x: "count" }, t = {}) {
  const { y: n = at } = t;
  if (n == null)
    throw new Error("missing channel: y");
  return fd(null, n, e, t);
}
function rg(e = { fill: "count" }, t = {}) {
  let { x: n, y: r } = t;
  if ([n, r] = Wn(n, r), n == null)
    throw new Error("missing channel: x");
  if (r == null)
    throw new Error("missing channel: y");
  return fd(n, r, e, t);
}
function fd(e, t, {
  data: n = ag,
  filter: r,
  sort: i,
  reverse: s,
  ...o
  // output channel definitions
} = {}, a = {}) {
  o = DM(o, a), n = kM(n, at), i = i == null ? void 0 : OM("sort", i, a), r = r == null ? void 0 : LM("filter", r, a);
  const [c, u] = qe(e), [l, f] = qe(t), {
    z: h,
    fill: d,
    stroke: p,
    x1: y,
    x2: g,
    // consumed if x is an output
    y1: m,
    y2: b,
    // consumed if y is an output
    ...w
  } = a, [v, x] = qe(h), [_] = Be(d), [M] = Be(p), [T, N] = qe(_), [A, $] = qe(M);
  return {
    ..."z" in a && { z: v || h },
    ..."fill" in a && { fill: T || d },
    ..."stroke" in a && { stroke: A || p },
    ...Mr(w, (D, F, S) => {
      const I = rh(At(D, e), S == null ? void 0 : S.x), E = rh(At(D, t), S == null ? void 0 : S.y), O = At(D, h), C = At(D, _), B = At(D, M), R = og(o, { z: O, fill: C, stroke: B }), P = [], U = [], Y = I && u([]), G = E && f([]), Z = O && x([]), H = C && N([]), q = B && $([]);
      let W = 0;
      for (const j of o)
        j.initialize(D);
      i && i.initialize(D), r && r.initialize(D);
      for (const j of F) {
        const X = [];
        for (const K of o)
          K.scope("facet", j);
        i && i.scope("facet", j), r && r.scope("facet", j);
        for (const [K, z] of Fo(j, R))
          for (const [wt, Q] of Fo(z, E))
            for (const [It, Tt] of Fo(Q, I)) {
              const J = { data: D };
              if (I && (J.x = It), E && (J.y = wt), !(r && !r.reduce(Tt, J))) {
                X.push(W++), U.push(n.reduceIndex(Tt, D, J)), I && Y.push(It), E && G.push(wt), O && Z.push(R === O ? K : O[Tt[0]]), C && H.push(R === C ? K : C[Tt[0]]), B && q.push(R === B ? K : B[Tt[0]]);
                for (const kt of o)
                  kt.reduce(Tt, J);
                i && i.reduce(Tt, J);
              }
            }
        P.push(X);
      }
      return FM(P, i, s), { data: U, facets: P };
    }),
    ...!Mi(o, "x") && (c ? { x: c } : { x1: y, x2: g }),
    ...!Mi(o, "y") && (l ? { y: l } : { y1: m, y2: b }),
    ...Object.fromEntries(o.map(({ name: D, output: F }) => [D, F]))
  };
}
function Mi(e, ...t) {
  for (const { name: n } of e)
    if (t.includes(n))
      return !0;
  return !1;
}
function NM(e, t, n = ig) {
  const r = Object.entries(e);
  return t.title != null && e.title === void 0 && r.push(["title", rq]), t.href != null && e.href === void 0 && r.push(["href", cg]), r.filter(([, i]) => i !== void 0).map(([i, s]) => s === null ? Kj(i) : n(i, s, t));
}
function ig(e, t, n, r = sg) {
  let i;
  $n(t) && "reduce" in t && (i = t.scale, t = t.reduce);
  const s = r(e, t, n), [o, a] = sn(s.label);
  let c;
  return {
    name: e,
    output: i === void 0 ? o : { value: o, scale: i },
    initialize(u) {
      s.initialize(u), c = a([]);
    },
    scope(u, l) {
      s.scope(u, l);
    },
    reduce(u, l) {
      c.push(s.reduce(u, l));
    }
  };
}
function Kj(e) {
  return { name: e, initialize() {
  }, scope() {
  }, reduce() {
  } };
}
function sg(e, t, n, r = hd) {
  const i = xM(e, n), s = r(t, i);
  let o, a;
  return {
    label: Sr(s === ih ? null : i, s.label),
    initialize(c) {
      o = i === void 0 ? c : At(c, i), s.scope === "data" && (a = s.reduceIndex(si(c), o));
    },
    scope(c, u) {
      s.scope === c && (a = s.reduceIndex(u, o));
    },
    reduce(c, u) {
      return s.scope == null ? s.reduceIndex(c, o, u) : s.reduceIndex(c, o, a, u);
    }
  };
}
function Fo(e, t) {
  return t ? Sc(
    ii(e, (n) => t[n]),
    bu
  ) : [[, e]];
}
function hd(e, t, n = Qj) {
  if (e == null)
    return n(e);
  if (typeof e.reduceIndex == "function")
    return e;
  if (typeof e.reduce == "function" && $n(e))
    return eq(e);
  if (typeof e == "function")
    return nq(e);
  if (/^p\d{2}$/i.test(e))
    return Lr(Wm(e));
  switch (`${e}`.toLowerCase()) {
    case "first":
      return cg;
    case "last":
      return iq;
    case "identity":
      return ag;
    case "count":
      return ih;
    case "distinct":
      return sq;
    case "sum":
      return t == null ? ih : oq;
    case "proportion":
      return Fw(t, "data");
    case "proportion-facet":
      return Fw(t, "facet");
    case "deviation":
      return Lr(tu);
    case "min":
      return Lr(be);
    case "min-index":
      return Lr(ML);
    case "max":
      return Lr(Qt);
    case "max-index":
      return Lr(SL);
    case "mean":
      return kw(Fh);
    case "median":
      return kw($c);
    case "variance":
      return Lr(im);
    case "mode":
      return Lr(_x);
  }
  return n(e);
}
function Qj(e) {
  throw new Error(`invalid reduce: ${e}`);
}
function DM(e, t) {
  return NM(e, t, OM);
}
function OM(e, t, n) {
  return ig(e, t, n, LM);
}
function LM(e, t, n) {
  return sg(e, t, n, kM);
}
function kM(e, t) {
  return hd(e, t, tq);
}
function tq(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return aq;
    case "y":
      return cq;
  }
  throw new Error(`invalid group reduce: ${e}`);
}
function og(e, t) {
  for (const n in t) {
    const r = t[n];
    if (r !== void 0 && !e.some((i) => i.name === n))
      return r;
  }
}
function FM(e, t, n) {
  if (t) {
    const r = t.output.transform(), i = (s, o) => Mn(r[s], r[o]);
    e.forEach((s) => s.sort(i));
  }
  n && e.forEach((r) => r.reverse());
}
function eq(e) {
  return console.warn("deprecated reduce interface; implement reduceIndex instead."), { ...e, reduceIndex: e.reduce.bind(e) };
}
function nq(e) {
  return {
    reduceIndex(t, n, r) {
      return e(ad(n, t), r);
    }
  };
}
function Lr(e) {
  return {
    reduceIndex(t, n) {
      return e(t, (r) => n[r]);
    }
  };
}
function kw(e) {
  return {
    reduceIndex(t, n) {
      const r = e(t, (i) => n[i]);
      return Pe(n) ? new Date(r) : r;
    }
  };
}
const ag = {
  reduceIndex(e, t) {
    return ad(t, e);
  }
}, cg = {
  reduceIndex(e, t) {
    return t[e[0]];
  }
}, rq = {
  reduceIndex(e, t) {
    const r = Sc(
      Do(
        e,
        (s) => s.length,
        (s) => t[s]
      ),
      Rc
    ), i = r.slice(-5).reverse();
    if (i.length < r.length) {
      const s = r.slice(0, -4);
      i[4] = [`… ${s.length.toLocaleString("en-US")} more`, gr(s, Rc)];
    }
    return i.map(([s, o]) => `${s} (${o.toLocaleString("en-US")})`).join(`
`);
  }
}, iq = {
  reduceIndex(e, t) {
    return t[e[e.length - 1]];
  }
}, ih = {
  label: "Frequency",
  reduceIndex(e) {
    return e.length;
  }
}, sq = {
  label: "Distinct",
  reduceIndex(e, t) {
    const n = new eu();
    for (const r of e)
      n.add(t[r]);
    return n.size;
  }
}, oq = Lr(gr);
function Fw(e, t) {
  return e == null ? { scope: t, label: "Frequency", reduceIndex: (n, r, i = 1) => n.length / i } : { scope: t, reduceIndex: (n, r, i = 1) => gr(n, (s) => r[s]) / i };
}
const aq = {
  reduceIndex(e, t, { x: n }) {
    return n;
  }
}, cq = {
  reduceIndex(e, t, { y: n }) {
    return n;
  }
};
function uq(e) {
  if (typeof e != "function")
    throw new Error(`invalid test function: ${e}`);
  return {
    reduceIndex(t, n, { data: r }) {
      return n[t.find((i) => e(r[i], i, r))];
    }
  };
}
function Uc(e, { scale: t, type: n, value: r, filter: i, hint: s, label: o = Sr(r) }, a) {
  return s === void 0 && typeof (r == null ? void 0 : r.transform) == "function" && (s = r.hint), CM(a, {
    scale: t,
    type: n,
    value: At(e, r),
    label: o,
    filter: i,
    hint: s
  });
}
function RM(e, t) {
  return Object.fromEntries(
    Object.entries(e).map(([n, r]) => [n, Uc(t, r, n)])
  );
}
function ug(e, t) {
  const n = Object.fromEntries(
    Object.entries(e).map(([r, { scale: i, value: s }]) => {
      const o = i == null ? null : t[i];
      return [r, o == null ? s : Gt(s, o)];
    })
  );
  return n.channels = e, n;
}
function CM(e, t) {
  const { scale: n, value: r } = t;
  if (n === !0 || n === "auto")
    switch (e) {
      case "fill":
      case "stroke":
      case "color":
        t.scale = n !== !0 && xp(r, wu) ? null : "color";
        break;
      case "fillOpacity":
      case "strokeOpacity":
      case "opacity":
        t.scale = n !== !0 && xp(r, Pj) ? null : "opacity";
        break;
      case "symbol":
        n !== !0 && xp(r, Wj) ? (t.scale = null, t.value = Gt(r, Km)) : t.scale = "symbol";
        break;
      default:
        t.scale = ne.has(e) ? e : null;
        break;
    }
  else if (n === !1)
    t.scale = null;
  else if (n != null && !ne.has(n))
    throw new Error(`unknown scale: ${n}`);
  return t;
}
function lq(e, t, n, r, i) {
  const { order: s, reverse: o, reduce: a = !0, limit: c } = i;
  for (const u in i) {
    if (!ne.has(u))
      continue;
    let { value: l, order: f = s, reverse: h = o, reduce: d = a, limit: p = c } = xa(i[u]);
    const y = l == null ? void 0 : l.startsWith("-");
    if (y && (l = l.slice(1)), f = f === void 0 ? y !== (l === "width" || l === "height") ? PM : BM : dq(f), d == null || d === !1)
      continue;
    const g = u === "fx" || u === "fy" ? hq(t, r[u]) : fq(n, u);
    if (!g)
      throw new Error(`missing channel for scale: ${u}`);
    const m = g.value, [b = 0, w = 1 / 0] = oi(p) ? p : p < 0 ? [p] : [0, p];
    if (l == null)
      g.domain = () => {
        let v = Array.from(new eu(m));
        return h && (v = v.reverse()), (b !== 0 || w !== 1 / 0) && (v = v.slice(b, w)), v;
      };
    else {
      const v = l === "data" ? e : l === "height" ? Rw(n, "y1", "y2") : l === "width" ? Rw(n, "x1", "x2") : Q0(n, l, l === "y" ? "y2" : l === "x" ? "x2" : void 0), x = hd(d === !0 ? "max" : d, v);
      g.domain = () => {
        let _ = bL(
          si(m),
          (M) => x.reduceIndex(M, v),
          (M) => m[M]
        );
        return f && _.sort(f), h && _.reverse(), (b !== 0 || w !== 1 / 0) && (_ = _.slice(b, w)), _.map(bu);
      };
    }
  }
}
function fq(e, t) {
  for (const n in e) {
    const r = e[n];
    if (r.scale === t)
      return r;
  }
}
function hq(e, t) {
  const n = e.original;
  if (n === e)
    return t;
  const r = t.value, i = t.value = [];
  for (let s = 0; s < n.length; ++s) {
    const o = r[n[s][0]];
    for (const a of e[s])
      i[a] = o;
  }
  return t;
}
function Rw(e, t, n) {
  const r = Q0(e, t), i = Q0(e, n);
  return Gt(i, (s, o) => Math.abs(s - r[o]), Float64Array);
}
function Q0(e, t, n) {
  let r = e[t];
  if (!r && n !== void 0 && (r = e[n]), r)
    return r.value;
  throw new Error(`missing channel: ${t}`);
}
function dq(e) {
  if (e == null || typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "ascending":
      return BM;
    case "descending":
      return PM;
  }
  throw new Error(`invalid order: ${e}`);
}
function BM([e, t], [n, r]) {
  return Mn(t, r) || Mn(e, n);
}
function PM([e, t], [n, r]) {
  return th(t, r) || Mn(e, n);
}
function ty(e, t) {
  let n = e[t];
  if (n) {
    for (; n.source; )
      n = n.source;
    return n.source === null ? null : n;
  }
}
function lg(e) {
  let t, n;
  return (...r) => (((n == null ? void 0 : n.length) !== r.length || n.some((i, s) => i !== r[s])) && (n = r, t = e(...r)), t);
}
const pq = lg((e) => new Intl.NumberFormat(e)), yq = lg((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { month: t } })), mq = lg((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { weekday: t } }));
function gq(e = "en-US") {
  const t = pq(e);
  return (n) => n != null && !isNaN(n) ? t.format(n) : void 0;
}
function bq(e = "en-US", t = "short") {
  const n = yq(e, t);
  return (r) => r != null && !isNaN(r = +new Date(Date.UTC(2e3, +r))) ? n.format(r) : void 0;
}
function wq(e = "en-US", t = "short") {
  const n = mq(e, t);
  return (r) => r != null && !isNaN(r = +new Date(Date.UTC(2001, 0, +r))) ? n.format(r) : void 0;
}
function UM(e) {
  return fM(e, "Invalid Date");
}
function vq(e = "en-US") {
  const t = gq(e);
  return (n) => (n instanceof Date ? UM : typeof n == "number" ? t : Te)(n);
}
const qs = vq();
let ey = 0, ny;
function _q() {
  const e = ey;
  return ey = 0, ny = void 0, e;
}
function Hr(e) {
  e !== ny && (ny = e, console.warn(e), ++ey);
}
const xe = (typeof window < "u" ? window.devicePixelRatio > 1 : typeof it > "u") ? 0 : 0.5;
let xq = 0;
function ry() {
  return `plot-clip-${++xq}`;
}
function zM(e, {
  title: t,
  href: n,
  ariaLabel: r,
  ariaDescription: i,
  ariaHidden: s,
  target: o,
  fill: a,
  fillOpacity: c,
  stroke: u,
  strokeWidth: l,
  strokeOpacity: f,
  strokeLinejoin: h,
  strokeLinecap: d,
  strokeMiterlimit: p,
  strokeDasharray: y,
  strokeDashoffset: g,
  opacity: m,
  mixBlendMode: b,
  imageFilter: w,
  paintOrder: v,
  pointerEvents: x,
  shapeRendering: _,
  channels: M
}, {
  ariaLabel: T,
  fill: N = "currentColor",
  fillOpacity: A,
  stroke: $ = "none",
  strokeOpacity: D,
  strokeWidth: F,
  strokeLinecap: S,
  strokeLinejoin: I,
  strokeMiterlimit: E,
  paintOrder: O
}) {
  N === null && (a = null, c = null), $ === null && (u = null, f = null), Kt(N) ? !Kt($) && (!Kt(a) || M != null && M.fill) && ($ = "none") : Kt($) && (!Kt(u) || M != null && M.stroke) && (N = "none");
  const [C, B] = Be(a, N), [R, P] = ce(c, A), [U, Y] = Be(u, $), [G, Z] = ce(f, D), [H, q] = ce(m);
  oa(Y) || (l === void 0 && (l = F), d === void 0 && (d = S), h === void 0 && (h = I), p === void 0 && !Uj(h) && (p = E), !oa(B) && v === void 0 && (v = O));
  const [W, j] = ce(l);
  return N !== null && (e.fill = se(B, "currentColor"), e.fillOpacity = za(P, 1)), $ !== null && (e.stroke = se(Y, "none"), e.strokeWidth = za(j, 1), e.strokeOpacity = za(Z, 1), e.strokeLinejoin = se(h, "miter"), e.strokeLinecap = se(d, "butt"), e.strokeMiterlimit = za(p, 4), e.strokeDasharray = se(y, "none"), e.strokeDashoffset = se(g, "0")), e.target = Te(o), e.ariaLabel = Te(T), e.ariaDescription = Te(i), e.ariaHidden = Te(s), e.opacity = za(q, 1), e.mixBlendMode = se(b, "normal"), e.imageFilter = se(w, "none"), e.paintOrder = se(v, "normal"), e.pointerEvents = se(x, "auto"), e.shapeRendering = se(_, "auto"), {
    title: { value: t, optional: !0, filter: null },
    href: { value: n, optional: !0, filter: null },
    ariaLabel: { value: r, optional: !0, filter: null },
    fill: { value: C, scale: "auto", optional: !0 },
    fillOpacity: { value: R, scale: "auto", optional: !0 },
    stroke: { value: U, scale: "auto", optional: !0 },
    strokeOpacity: { value: G, scale: "auto", optional: !0 },
    strokeWidth: { value: W, optional: !0 },
    opacity: { value: H, scale: "auto", optional: !0 }
  };
}
function Sq(e, t) {
  t && e.filter((n) => Pm(t[n])).append("title").call(Aq, t);
}
function Mq(e, t) {
  t && e.filter(([n]) => Pm(t[n])).append("title").call($q, t);
}
function Aq(e, t) {
  t && e.text((n) => qs(t[n]));
}
function $q(e, t) {
  t && e.text(([n]) => qs(t[n]));
}
function pe(e, { target: t, tip: n }, {
  ariaLabel: r,
  title: i,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: u,
  opacity: l,
  href: f
}) {
  r && et(e, "aria-label", (h) => r[h]), s && et(e, "fill", (h) => s[h]), o && et(e, "fill-opacity", (h) => o[h]), a && et(e, "stroke", (h) => a[h]), c && et(e, "stroke-opacity", (h) => c[h]), u && et(e, "stroke-width", (h) => u[h]), l && et(e, "opacity", (h) => l[h]), f && VM(e, (h) => f[h], t), n || Sq(e, i);
}
function sh(e, { target: t, tip: n }, {
  ariaLabel: r,
  title: i,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: u,
  opacity: l,
  href: f
}) {
  r && et(e, "aria-label", ([h]) => r[h]), s && et(e, "fill", ([h]) => s[h]), o && et(e, "fill-opacity", ([h]) => o[h]), a && et(e, "stroke", ([h]) => a[h]), c && et(e, "stroke-opacity", ([h]) => c[h]), u && et(e, "stroke-width", ([h]) => u[h]), l && et(e, "opacity", ([h]) => l[h]), f && VM(e, ([h]) => f[h], t), n || Mq(e, i);
}
function Iq({
  ariaLabel: e,
  title: t,
  fill: n,
  fillOpacity: r,
  stroke: i,
  strokeOpacity: s,
  strokeWidth: o,
  opacity: a,
  href: c
}, { tip: u }) {
  return [e, u ? void 0 : t, n, r, i, s, o, a, c].filter((l) => l !== void 0);
}
function fg(e, t, n) {
  const r = ii(e, (i) => t[i]);
  return n === void 0 && r.size > 1 + e.length >> 1 && Hr(
    "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."
  ), r.values();
}
function* jM(e, t, n, r) {
  const { z: i } = n, { z: s } = r, o = Iq(r, n), a = [...t, ...o];
  for (const c of s ? fg(e, s, i) : [e]) {
    let u, l;
    t:
      for (const f of c) {
        for (const h of a)
          if (!Re(h[f])) {
            l && l.push(-1);
            continue t;
          }
        if (u === void 0) {
          l && (yield l), u = o.map((h) => ws(h[f])), l = [f];
          continue;
        }
        l.push(f);
        for (let h = 0; h < o.length; ++h)
          if (ws(o[h][f]) !== u[h]) {
            yield l, u = o.map((p) => ws(p[f])), l = [f];
            continue t;
          }
      }
    l && (yield l);
  }
}
function qM(e) {
  return e === !0 ? e = "frame" : e === !1 ? e = null : e != null && (e = ln(e, "clip", ["frame", "sphere"])), e;
}
function Tq(e, t, n, r) {
  let i;
  const { clip: s = r.clip } = t;
  switch (s) {
    case "frame": {
      const { width: o, height: a, marginLeft: c, marginRight: u, marginTop: l, marginBottom: f } = n, h = ry();
      i = `url(#${h})`, e = Nt("svg:g", r).call(
        (d) => d.append("svg:clipPath").attr("id", h).append("rect").attr("x", c).attr("y", l).attr("width", o - u - c).attr("height", a - l - f)
      ).each(function() {
        this.appendChild(e.node()), e.node = () => this;
      });
      break;
    }
    case "sphere": {
      const { projection: o } = r;
      if (!o)
        throw new Error('the "sphere" clip option requires a projection');
      const a = ry();
      i = `url(#${a})`, e.append("clipPath").attr("id", a).append("path").attr("d", Gi(o)({ type: "Sphere" }));
      break;
    }
  }
  et(e, "aria-label", t.ariaLabel), et(e, "aria-description", t.ariaDescription), et(e, "aria-hidden", t.ariaHidden), et(e, "clip-path", i);
}
function te(e, t, n, r) {
  Tq(e, t, n, r), et(e, "fill", t.fill), et(e, "fill-opacity", t.fillOpacity), et(e, "stroke", t.stroke), et(e, "stroke-width", t.strokeWidth), et(e, "stroke-opacity", t.strokeOpacity), et(e, "stroke-linejoin", t.strokeLinejoin), et(e, "stroke-linecap", t.strokeLinecap), et(e, "stroke-miterlimit", t.strokeMiterlimit), et(e, "stroke-dasharray", t.strokeDasharray), et(e, "stroke-dashoffset", t.strokeDashoffset), et(e, "shape-rendering", t.shapeRendering), et(e, "filter", t.imageFilter), et(e, "paint-order", t.paintOrder);
  const { pointerEvents: i = r.pointerSticky === !1 ? "none" : void 0 } = t;
  et(e, "pointer-events", i);
}
function Jt(e, t) {
  Eq(e, "mix-blend-mode", t.mixBlendMode), et(e, "opacity", t.opacity);
}
function VM(e, t, n) {
  e.each(function(r) {
    const i = t(r);
    if (i != null) {
      const s = this.ownerDocument.createElementNS(Rs.svg, "a");
      s.setAttribute("fill", "inherit"), s.setAttributeNS(Rs.xlink, "href", i), n != null && s.setAttribute("target", n), this.parentNode.insertBefore(s, this).appendChild(this);
    }
  });
}
function et(e, t, n) {
  n != null && e.attr(t, n);
}
function Eq(e, t, n) {
  n != null && e.style(t, n);
}
function Wt(e, t, { x: n, y: r }, i = xe, s = xe) {
  i += t.dx, s += t.dy, n != null && n.bandwidth && (i += n.bandwidth() / 2), r != null && r.bandwidth && (s += r.bandwidth() / 2), (i || s) && e.attr("transform", `translate(${i},${s})`);
}
function se(e, t) {
  if ((e = Te(e)) !== t)
    return e;
}
function za(e, t) {
  if ((e = Et(e)) !== t)
    return e;
}
const Nq = /^-?([_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])*$/i;
function hg(e) {
  if (e === void 0)
    return "plot-d6a7b5";
  if (e = `${e}`, !Nq.test(e))
    throw new Error(`invalid class name: ${e}`);
  return e;
}
function dg(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 Ar({ frameAnchor: e }, { width: t, height: n, marginTop: r, marginRight: i, marginBottom: s, marginLeft: o }) {
  return [
    /left$/.test(e) ? o : /right$/.test(e) ? t - i : (o + t - i) / 2,
    /^top/.test(e) ? r : /^bottom/.test(e) ? n - s : (r + n - s) / 2
  ];
}
function dd(e = {}) {
  const { document: t = typeof window < "u" ? window.document : void 0, clip: n } = e;
  return { document: t, clip: qM(n) };
}
function Nt(e, { document: t }) {
  return Vt(Bh(e).call(t.documentElement));
}
const YM = Math.PI, Er = 2 * YM, Cw = 0.618;
function Dq({
  projection: e,
  inset: t = 0,
  insetTop: n = t,
  insetRight: r = t,
  insetBottom: i = t,
  insetLeft: s = t
} = {}, o) {
  if (e == null)
    return;
  if (typeof e.stream == "function")
    return e;
  let a, c, u = "frame";
  if ($n(e)) {
    let x;
    if ({
      type: e,
      domain: c,
      inset: x,
      insetTop: n = x !== void 0 ? x : n,
      insetRight: r = x !== void 0 ? x : r,
      insetBottom: i = x !== void 0 ? x : i,
      insetLeft: s = x !== void 0 ? x : s,
      clip: u = u,
      ...a
    } = e, e == null)
      return;
  }
  typeof e != "function" && ({ type: e } = WM(e));
  const { width: l, height: f, marginLeft: h, marginRight: d, marginTop: p, marginBottom: y } = o, g = l - h - d - s - r, m = f - p - y - n - i;
  if (e = e == null ? void 0 : e({ width: g, height: m, clip: u, ...a }), e == null)
    return;
  u = Oq(u, h, p, l - d, f - y);
  let b = h + s, w = p + n, v;
  if (c != null) {
    const [[x, _], [M, T]] = Gi(e).bounds(c), N = Math.min(g / (M - x), m / (T - _));
    N > 0 ? (b -= (N * (x + M) - g) / 2, w -= (N * (_ + T) - m) / 2, v = zf({
      point(A, $) {
        this.stream.point(A * N + b, $ * N + w);
      }
    })) : Hr("Warning: the projection could not be fit to the specified domain; using the default scale.");
  }
  return v ?? (v = b === 0 && w === 0 ? XM() : zf({
    point(x, _) {
      this.stream.point(x + b, _ + w);
    }
  })), { stream: (x) => e.stream(v.stream(u(x))) };
}
function WM(e) {
  switch (`${e}`.toLowerCase()) {
    case "albers-usa":
      return In(aP, 0.7463, 0.4673);
    case "albers":
      return nl(FS, 0.7463, 0.4673);
    case "azimuthal-equal-area":
      return In(cP, 4, 4);
    case "azimuthal-equidistant":
      return In(uP, Er, Er);
    case "conic-conformal":
      return nl(hP, Er, Er);
    case "conic-equal-area":
      return nl(jf, 6.1702, 2.9781);
    case "conic-equidistant":
      return nl(yP, 7.312, 3.6282);
    case "equal-earth":
      return In(gP, 5.4133, 2.6347);
    case "equirectangular":
      return In(dP, Er, YM);
    case "gnomonic":
      return In(bP, 3.4641, 3.4641);
    case "identity":
      return { type: XM };
    case "reflect-y":
      return { type: Lq };
    case "mercator":
      return In(lP, Er, Er);
    case "orthographic":
      return In(wP, 2, 2);
    case "stereographic":
      return In(vP, 2, 2);
    case "transverse-mercator":
      return In(_P, Er, Er);
    default:
      throw new Error(`unknown projection type: ${e}`);
  }
}
function Oq(e, t, n, r, i) {
  if (e === !1 || e == null || typeof e == "number")
    return (s) => s;
  switch (e === !0 && (e = "frame"), `${e}`.toLowerCase()) {
    case "frame":
      return wS(t, n, r, i);
    default:
      throw new Error(`unknown projection clip type: ${e}`);
  }
}
function In(e, t, n) {
  return {
    type: ({ width: r, height: i, 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(r / t, i / n)), c.translate([r / 2, i / 2]), c;
    },
    aspectRatio: n / t
  };
}
function nl(e, t, n) {
  const { type: r, aspectRatio: i } = In(e, t, n);
  return {
    type: (s) => {
      const { parallels: o, domain: a, width: c, height: u } = s, l = r(s);
      return o != null && (l.parallels(o), a === void 0 && l.fitSize([c, u], { type: "Sphere" })), l;
    },
    aspectRatio: i
  };
}
const XM = un({ stream: (e) => e }), Lq = un(
  zf({
    point(e, t) {
      this.stream.point(e, -t);
    }
  })
);
function GM(e, t, n, r) {
  const i = n[e], s = n[t], o = i.length, a = n[e] = new Float64Array(o).fill(NaN), c = n[t] = new Float64Array(o).fill(NaN);
  let u;
  const l = r.stream({
    point(f, h) {
      a[u] = f, c[u] = h;
    }
  });
  for (u = 0; u < o; ++u)
    l.point(i[u], s[u]);
}
function kq({ projection: e } = {}) {
  return e == null ? !1 : typeof e.stream == "function" ? !0 : ($n(e) && (e = e.type), e != null);
}
function Fq(e) {
  if (typeof (e == null ? void 0 : e.stream) == "function")
    return Cw;
  if ($n(e) && (e = e.type), e != null) {
    if (typeof e != "function") {
      const { aspectRatio: t } = WM(e);
      if (t)
        return t;
    }
    return Cw;
  }
}
function pd(e, t, { projection: n }) {
  const { x: r, y: i } = e;
  let s = {};
  return r && (s.x = r), i && (s.y = i), s = ug(s, t), n && (r == null ? void 0 : r.scale) === "x" && (i == null ? void 0 : i.scale) === "y" && GM("x", "y", s, n), r && (s.x = We(s.x)), i && (s.y = We(s.y)), s;
}
function Rq(e) {
  const t = [], n = [], r = { scale: "x", value: t }, i = { scale: "y", value: n }, s = {
    point(o, a) {
      t.push(o), n.push(a);
    },
    lineStart() {
    },
    lineEnd() {
    },
    polygonStart() {
    },
    polygonEnd() {
    },
    sphere() {
    }
  };
  for (const o of e.value)
    bi(o, s);
  return [r, i];
}
const Cq = [
  "#4269d0",
  "#efb118",
  "#ff725c",
  "#6cc5b0",
  "#3ca951",
  "#ff8ab7",
  "#a463f2",
  "#97bbf5",
  "#9c6b4e",
  "#9498a0"
], HM = /* @__PURE__ */ new Map([
  ["accent", Tz],
  ["category10", Iz],
  ["dark2", Ez],
  ["observable10", Cq],
  ["paired", Nz],
  ["pastel1", Dz],
  ["pastel2", Oz],
  ["set1", Lz],
  ["set2", kz],
  ["set3", Fz],
  ["tableau10", Rz]
]);
function Bq(e) {
  return e != null && HM.has(`${e}`.toLowerCase());
}
const Bw = new Map([
  ...HM,
  // diverging
  ["brbg", Nr(A3, $3)],
  ["prgn", Nr(I3, T3)],
  ["piyg", Nr(E3, N3)],
  ["puor", Nr(D3, O3)],
  ["rdbu", Nr(H0, Xf)],
  ["rdgy", Nr(L3, k3)],
  ["rdylbu", Nr(J0, Gf)],
  ["rdylgn", Nr(F3, R3)],
  ["spectral", Nr(C3, B3)],
  // reversed diverging (for temperature data)
  ["burd", Pw(H0, Xf)],
  ["buylrd", Pw(J0, Gf)],
  // sequential (single-hue)
  ["blues", ye(u6, l6)],
  ["greens", ye(f6, h6)],
  ["greys", ye(d6, p6)],
  ["oranges", ye(w6, v6)],
  ["purples", ye(y6, m6)],
  ["reds", ye(g6, b6)],
  // sequential (multi-hue)
  ["turbo", Dr(I6)],
  ["viridis", Dr(T6)],
  ["magma", Dr(E6)],
  ["inferno", Dr(N6)],
  ["plasma", Dr(D6)],
  ["cividis", Dr(_6)],
  ["cubehelix", Dr(x6)],
  ["warm", Dr(S6)],
  ["cool", Dr(M6)],
  ["bugn", ye(P3, U3)],
  ["bupu", ye(z3, j3)],
  ["gnbu", ye(q3, V3)],
  ["orrd", ye(Y3, W3)],
  ["pubu", ye(H3, J3)],
  ["pubugn", ye(X3, G3)],
  ["purd", ye(Z3, K3)],
  ["rdpu", ye(Q3, t6)],
  ["ylgn", ye(r6, i6)],
  ["ylgnbu", ye(e6, n6)],
  ["ylorbr", ye(s6, o6)],
  ["ylorrd", ye(a6, c6)],
  // cyclical
  ["rainbow", Uw(A6)],
  ["sinebow", Uw($6)]
]);
function ye(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 ? Pn(t, n) : e[n]);
}
function Nr(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][0], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 11 ? Pn(t, n) : e[n]);
}
function Pw(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][2], e[3][0]] : (n = Math.max(3, Math.floor(n)), n > 11 ? Pn((r) => t(1 - r), n) : e[n].slice().reverse());
}
function Dr(e) {
  return ({ length: t }) => Pn(e, Math.max(2, Math.floor(t)));
}
function Uw(e) {
  return ({ length: t }) => Pn(e, Math.floor(t) + 1).slice(0, -1);
}
function JM(e) {
  const t = `${e}`.toLowerCase();
  if (!Bw.has(t))
    throw new Error(`unknown ordinal scheme: ${t}`);
  return Bw.get(t);
}
function yd(e, t) {
  const n = JM(e), r = typeof n == "function" ? n({ length: t }) : n;
  return r.length !== t ? r.slice(0, t) : r;
}
function Pq(e, t = "greys") {
  const n = /* @__PURE__ */ new Set(), [r, i] = yd(t, 2);
  for (const s of e)
    if (s != null)
      if (s === !0)
        n.add(i);
      else if (s === !1)
        n.add(r);
      else
        return;
  return [...n];
}
const zw = /* @__PURE__ */ new Map([
  // diverging
  ["brbg", $3],
  ["prgn", T3],
  ["piyg", N3],
  ["puor", O3],
  ["rdbu", Xf],
  ["rdgy", k3],
  ["rdylbu", Gf],
  ["rdylgn", R3],
  ["spectral", B3],
  // reversed diverging (for temperature data)
  ["burd", (e) => Xf(1 - e)],
  ["buylrd", (e) => Gf(1 - e)],
  // sequential (single-hue)
  ["blues", l6],
  ["greens", h6],
  ["greys", p6],
  ["purples", m6],
  ["reds", b6],
  ["oranges", v6],
  // sequential (multi-hue)
  ["turbo", I6],
  ["viridis", T6],
  ["magma", E6],
  ["inferno", N6],
  ["plasma", D6],
  ["cividis", _6],
  ["cubehelix", x6],
  ["warm", S6],
  ["cool", M6],
  ["bugn", U3],
  ["bupu", j3],
  ["gnbu", V3],
  ["orrd", W3],
  ["pubugn", G3],
  ["pubu", J3],
  ["purd", K3],
  ["rdpu", t6],
  ["ylgnbu", n6],
  ["ylgn", i6],
  ["ylorbr", o6],
  ["ylorrd", c6],
  // cyclical
  ["rainbow", A6],
  ["sinebow", $6]
]);
function pg(e) {
  const t = `${e}`.toLowerCase();
  if (!zw.has(t))
    throw new Error(`unknown quantitative scheme: ${t}`);
  return zw.get(t);
}
const Uq = /* @__PURE__ */ new Set([
  "brbg",
  "prgn",
  "piyg",
  "puor",
  "rdbu",
  "rdgy",
  "rdylbu",
  "rdylgn",
  "spectral",
  "burd",
  "buylrd"
]);
function zq(e) {
  return e != null && Uq.has(`${e}`.toLowerCase());
}
const ZM = (e) => (t) => e(1 - t), Ap = [0, 1], jw = /* @__PURE__ */ new Map([
  // numbers
  ["number", $e],
  // color spaces
  ["rgb", Bs],
  ["hsl", nR],
  ["hcl", sR],
  ["lab", rR]
]);
function KM(e) {
  const t = `${e}`.toLowerCase();
  if (!jw.has(t))
    throw new Error(`unknown interpolator: ${t}`);
  return jw.get(t);
}
function Mu(e, t, n, {
  type: r,
  nice: i,
  clamp: s,
  zero: o,
  domain: a = tA(e, n),
  unknown: c,
  round: u,
  scheme: l,
  interval: f,
  range: h = ne.get(e) === _u ? Kq(n, a) : ne.get(e) === xu ? Qq(n, a) : ne.get(e) === Su ? Ap : void 0,
  interpolate: d = ne.get(e) === ai ? l == null && h !== void 0 ? Bs : pg(l !== void 0 ? l : r === "cyclical" ? "rainbow" : "turbo") : u ? mm : $e,
  reverse: p
}) {
  if (f = _a(f, r), (r === "cyclical" || r === "sequential") && (r = "linear"), typeof d != "function" && (d = KM(d)), p = !!p, h !== void 0) {
    const y = (a = Ze(a)).length, g = (h = Ze(h)).length;
    if (y !== g) {
      if (d.length === 1)
        throw new Error("invalid piecewise interpolator");
      d = zh(d, h), h = void 0;
    }
  }
  if (d.length === 1 ? (p && (d = ZM(d), p = !1), h === void 0 && (h = Float64Array.from(a, (y, g) => g / (a.length - 1)), h.length === 2 && (h = Ap)), t.interpolate((h === Ap ? un : mg)(d))) : t.interpolate(d), o) {
    const [y, g] = fe(a);
    (y > 0 || g < 0) && (a = Cc(a), aa(a) !== Math.sign(y) ? a[a.length - 1] = 0 : a[0] = 0);
  }
  return p && (a = df(a)), t.domain(a).unknown(c), i && (t.nice(jq(i, r)), a = t.domain()), h !== void 0 && t.range(h), s && t.clamp(s), { type: r, domain: a, range: h, scale: t, interpolate: d, interval: f };
}
function jq(e, t) {
  return e === !0 ? void 0 : typeof e == "number" ? e : Oj(e, t);
}
function qq(e, t, n) {
  return Mu(e, Hh(), t, n);
}
function Vq(e, t, n) {
  return QM(e, t, { ...n, exponent: 0.5 });
}
function QM(e, t, { exponent: n = 1, ...r }) {
  return Mu(e, i3().exponent(n), t, { ...r, type: "pow" });
}
function Yq(e, t, { base: n = 10, domain: r = tV(t), ...i }) {
  return Mu(e, t3().base(n), t, { ...i, domain: r });
}
function Wq(e, t, { constant: n = 1, ...r }) {
  return Mu(e, n3().constant(n), t, r);
}
function Xq(e, t, {
  range: n,
  quantiles: r = n === void 0 ? 5 : (n = [...n]).length,
  // deprecated; use n instead
  n: i = r,
  scheme: s = "rdylbu",
  domain: o = eV(t),
  unknown: a,
  interpolate: c,
  reverse: u
}) {
  return n === void 0 && (n = c !== void 0 ? Pn(c, i) : ne.get(e) === ai ? yd(s, i) : void 0), o.length > 0 && (o = s3(o, n === void 0 ? { length: i } : n).quantiles()), yg(e, t, { domain: o, range: n, reverse: u, unknown: a });
}
function Gq(e, t, {
  range: n,
  n: r = n === void 0 ? 5 : (n = [...n]).length,
  scheme: i = "rdylbu",
  domain: s = tA(e, t),
  unknown: o,
  interpolate: a,
  reverse: c
}) {
  const [u, l] = fe(s);
  let f;
  return n === void 0 ? (f = ki(u, l, r), f[0] <= u && f.splice(0, 1), f[f.length - 1] >= l && f.pop(), r = f.length + 1, n = a !== void 0 ? Pn(a, r) : ne.get(e) === ai ? yd(i, r) : void 0) : (f = Pn($e(u, l), r + 1).slice(1, -1), u instanceof Date && (f = f.map((h) => new Date(h)))), aa(Ze(s)) < 0 && f.reverse(), yg(e, t, { domain: f, range: n, reverse: c, unknown: o });
}
function yg(e, t, {
  domain: n = [0],
  // explicit thresholds in ascending order
  unknown: r,
  scheme: i = "rdylbu",
  interpolate: s,
  range: o = s !== void 0 ? Pn(s, n.length + 1) : ne.get(e) === ai ? yd(i, n.length + 1) : void 0,
  reverse: a
}) {
  n = Ze(n);
  const c = aa(n);
  if (!isNaN(c) && !Hq(n, c))
    throw new Error(`the ${e} scale has a non-monotonic domain`);
  return a && (o = df(o)), {
    type: "threshold",
    scale: o3(c < 0 ? df(n) : n, o === void 0 ? [] : o).unknown(r),
    domain: n,
    range: o
  };
}
function Hq(e, t) {
  for (let n = 1, r = e.length, i = e[0]; n < r; ++n) {
    const s = ks(i, i = e[n]);
    if (s !== 0 && s !== t)
      return !1;
  }
  return !0;
}
function Jq(e) {
  return { type: "identity", scale: Vj(ne.get(e)) ? ZS() : (t) => t };
}
function zc(e, t = eh) {
  return e.length ? [
    be(e, ({ value: n }) => n === void 0 ? n : be(n, t)),
    Qt(e, ({ value: n }) => n === void 0 ? n : Qt(n, t))
  ] : [0, 1];
}
function tA(e, t) {
  const n = ne.get(e);
  return (n === _u || n === Su || n === xu ? Zq : zc)(t);
}
function Zq(e) {
  return [0, e.length ? Qt(e, ({ value: t }) => t === void 0 ? t : Qt(t, eh)) : 1];
}
function Kq(e, t) {
  const n = e.find(({ radius: o }) => o !== void 0);
  if (n !== void 0)
    return [0, n.radius];
  const r = Fi(e, 0.5, ({ value: o }) => o === void 0 ? NaN : Fi(o, 0.25, Gr)), i = t.map((o) => 3 * Math.sqrt(o / r)), s = 30 / Qt(i);
  return s < 1 ? i.map((o) => o * s) : i;
}
function Qq(e, t) {
  const n = $c(e, ({ value: s }) => s === void 0 ? NaN : $c(s, Math.abs)), r = t.map((s) => 12 * s / n), i = 60 / Qt(r);
  return i < 1 ? r.map((s) => s * i) : r;
}
function tV(e) {
  for (const { value: t } of e)
    if (t !== void 0)
      for (let n of t) {
        if (n > 0)
          return zc(e, Gr);
        if (n < 0)
          return zc(e, id);
      }
  return [1, 10];
}
function eV(e) {
  const t = [];
  for (const { value: n } of e)
    if (n !== void 0)
      for (const r of n)
        t.push(r);
  return t;
}
function mg(e) {
  return (t, n) => (r) => e(t + r * (n - t));
}
function md(e, t, n, r, {
  type: i,
  nice: s,
  clamp: o,
  domain: a = zc(r),
  unknown: c,
  pivot: u = 0,
  scheme: l,
  range: f,
  symmetric: h = !0,
  interpolate: d = ne.get(e) === ai ? l == null && f !== void 0 ? Bs : pg(l !== void 0 ? l : "rdbu") : $e,
  reverse: p
}) {
  u = +u, a = Ze(a);
  let [y, g] = a;
  if (a.length > 2 && Hr(`Warning: the diverging ${e} scale domain contains extra elements.`), ks(y, g) < 0 && ([y, g] = [g, y], p = !p), y = Math.min(y, u), g = Math.max(g, u), typeof d != "function" && (d = KM(d)), f !== void 0 && (d = d.length === 1 ? mg(d)(...f) : zh(d, f)), p && (d = ZM(d)), h) {
    const m = n.apply(u), b = m - n.apply(y), w = n.apply(g) - m;
    b < w ? y = n.invert(m - w) : b > w && (g = n.invert(m + b));
  }
  return t.domain([y, u, g]).unknown(c).interpolator(d), o && t.clamp(o), s && t.nice(s), { type: i, domain: [y, g], pivot: u, interpolate: d, scale: t };
}
function nV(e, t, n) {
  return md(e, _3(), oV, t, n);
}
function rV(e, t, n) {
  return eA(e, t, { ...n, exponent: 0.5 });
}
function eA(e, t, { exponent: n = 1, ...r }) {
  return md(e, M3().exponent(n = +n), uV(n), t, {
    ...r,
    type: "diverging-pow"
  });
}
function iV(e, t, { base: n = 10, pivot: r = 1, domain: i = zc(t, r < 0 ? id : Gr), ...s }) {
  return md(e, x3().base(n = +n), aV, t, {
    domain: i,
    pivot: r,
    ...s
  });
}
function sV(e, t, { constant: n = 1, ...r }) {
  return md(
    e,
    S3().constant(n = +n),
    lV(n),
    t,
    r
  );
}
const oV = {
  apply(e) {
    return e;
  },
  invert(e) {
    return e;
  }
}, aV = {
  apply: Math.log,
  invert: Math.exp
}, cV = {
  apply(e) {
    return Math.sign(e) * Math.sqrt(Math.abs(e));
  },
  invert(e) {
    return Math.sign(e) * (e * e);
  }
};
function uV(e) {
  return e === 0.5 ? cV : {
    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 lV(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 nA(e, t, n, r) {
  return Mu(e, t, n, r);
}
function fV(e, t, n) {
  return nA(e, Az(), t, n);
}
function hV(e, t, n) {
  return nA(e, $z(), t, n);
}
const Au = Symbol("ordinal");
function rA(e, t, n, { type: r, interval: i, domain: s, range: o, reverse: a, hint: c }) {
  return i = _a(i, r), s === void 0 && (s = sA(n, i, e)), (r === "categorical" || r === Au) && (r = "ordinal"), a && (s = df(s)), s = t.domain(s).domain(), o !== void 0 && (typeof o == "function" && (o = o(s)), t.range(o)), { type: r, domain: s, range: o, scale: t, hint: c, interval: i };
}
function dV(e, t, { type: n, interval: r, domain: i, range: s, scheme: o, unknown: a, ...c }) {
  r = _a(r, n), i === void 0 && (i = sA(t, r, e));
  let u;
  if (ne.get(e) === ud)
    u = mV(t), s = s === void 0 ? gV(u) : Gt(s, Km);
  else if (ne.get(e) === ai && (s === void 0 && (n === "ordinal" || n === Au) && (s = Pq(i, o), s !== void 0 && (o = void 0)), o === void 0 && s === void 0 && (o = n === "ordinal" ? "turbo" : "observable10"), o !== void 0))
    if (s !== void 0) {
      const l = pg(o), f = s[0], h = s[1] - s[0];
      s = ({ length: d }) => Pn((p) => l(f + h * p), d);
    } else
      s = JM(o);
  if (a === W0)
    throw new Error(`implicit unknown on ${e} scale is not supported`);
  return rA(e, Em().unknown(a), t, { ...c, type: n, domain: i, range: s, hint: u });
}
function pV(e, t, { align: n = 0.5, padding: r = 0.5, ...i }) {
  return iA(oU().align(n).padding(r), t, i, e);
}
function yV(e, t, {
  align: n = 0.5,
  padding: r = 0.1,
  paddingInner: i = r,
  paddingOuter: s = e === "fx" || e === "fy" ? 0 : r,
  ...o
}) {
  return iA(
    Xh().align(n).paddingInner(i).paddingOuter(s),
    t,
    o,
    e
  );
}
function iA(e, t, n, r) {
  let { round: i } = n;
  return i !== void 0 && e.round(i = !!i), e = rA(r, e, t, n), e.round = i, e;
}
function sA(e, t, n) {
  const r = new eu();
  for (const { value: i, domain: s } of e) {
    if (s !== void 0)
      return s();
    if (i !== void 0)
      for (const o of i)
        r.add(o);
  }
  if (t !== void 0) {
    const [i, s] = fe(r).map(t.floor, t);
    return t.range(i, t.offset(s));
  }
  if (r.size > 1e4 && ne.get(n) === fr)
    throw new Error(`implicit ordinal domain of ${n} scale has more than 10,000 values`);
  return Sc(r, Mn);
}
function qw(e, t) {
  let n;
  for (const { hint: r } of e) {
    const i = r == null ? void 0 : r[t];
    if (i !== void 0) {
      if (n === void 0)
        n = i;
      else if (n !== i)
        return;
    }
  }
  return n;
}
function mV(e) {
  return {
    fill: qw(e, "fill"),
    stroke: qw(e, "stroke")
  };
}
function gV(e) {
  return Kt(e.fill) ? Hz : Gz;
}
function iy(e, {
  label: t,
  inset: n = 0,
  insetTop: r = n,
  insetRight: i = 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 } = {},
  ...y
} = {}) {
  const g = {};
  for (const [m, b] of e) {
    const w = y[m], v = lA(m, b, {
      round: ne.get(m) === fr ? a : void 0,
      // only for position
      nice: c,
      clamp: u,
      zero: l,
      align: f,
      padding: h,
      projection: d,
      ...w
    });
    if (v) {
      let {
        label: x = m === "fx" || m === "fy" ? p : t,
        percent: _,
        transform: M,
        inset: T,
        insetTop: N = T !== void 0 ? T : m === "y" ? r : 0,
        // not fy
        insetRight: A = T !== void 0 ? T : m === "x" ? i : 0,
        // not fx
        insetBottom: $ = T !== void 0 ? T : m === "y" ? s : 0,
        // not fy
        insetLeft: D = T !== void 0 ? T : m === "x" ? o : 0
        // not fx
      } = w || {};
      if (M == null)
        M = void 0;
      else if (typeof M != "function")
        throw new Error("invalid scale transform; not a function");
      v.percent = !!_, v.label = x === void 0 ? wV(b, v) : x, v.transform = M, m === "x" || m === "fx" ? (v.insetLeft = +D, v.insetRight = +A) : (m === "y" || m === "fy") && (v.insetTop = +N, v.insetBottom = +$), g[m] = v;
    }
  }
  return g;
}
function Vw(e) {
  const t = {}, n = { scales: t };
  for (const [r, i] of Object.entries(e)) {
    const { scale: s, type: o, interval: a, label: c } = i;
    t[r] = hA(i), n[r] = s, s.type = o, a != null && (s.interval = a), c != null && (s.label = c);
  }
  return n;
}
function bV(e, t) {
  const { x: n, y: r, fx: i, fy: s } = e, o = i || s ? gg(t) : t;
  i && Yw(i, o), s && Ww(s, o);
  const a = i || s ? aA(e, t) : t;
  n && Yw(n, a), r && Ww(r, a);
}
function wV(e = [], t) {
  let n;
  for (const { label: r } of e)
    if (r !== void 0) {
      if (n === void 0)
        n = r;
      else if (n !== r)
        return;
    }
  if (n !== void 0)
    return !Hs(t) && t.percent && (n = `${n} (%)`), { inferred: !0, toString: () => n };
}
function oA(e) {
  return Math.sign(aa(e.domain())) * Math.sign(aa(e.range()));
}
function gg(e) {
  const {
    marginTop: t,
    marginRight: n,
    marginBottom: r,
    marginLeft: i,
    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(r, u),
    marginLeft: Math.max(i, l),
    width: s,
    height: o
  };
}
function aA({ fx: e, fy: t }, n) {
  const { marginTop: r, marginRight: i, marginBottom: s, marginLeft: o, width: a, height: c } = gg(n);
  return {
    marginTop: r,
    marginRight: i,
    marginBottom: s,
    marginLeft: o,
    width: e ? e.scale.bandwidth() + o + i : a,
    height: t ? t.scale.bandwidth() + r + s : c,
    facet: { width: a, height: c }
  };
}
function Yw(e, t) {
  if (e.range === void 0) {
    const { insetLeft: n, insetRight: r } = e, { width: i, marginLeft: s = 0, marginRight: o = 0 } = t, a = s + n, c = i - o - r;
    e.range = [a, Math.max(a, c)], Hs(e) || (e.range = uA(e)), e.scale.range(e.range);
  }
  cA(e);
}
function Ww(e, t) {
  if (e.range === void 0) {
    const { insetTop: n, insetBottom: r } = e, { height: i, marginTop: s = 0, marginBottom: o = 0 } = t, a = s + n, c = i - o - r;
    e.range = [Math.max(a, c), a], Hs(e) ? e.range.reverse() : e.range = uA(e), e.scale.range(e.range);
  }
  cA(e);
}
function cA(e) {
  e.round === void 0 && xV(e) && vV(e) <= 30 && e.scale.round(!0);
}
function vV({ scale: e }) {
  const t = e.domain().length, [n, r] = e.range(), i = e.paddingInner ? e.paddingInner() : 1, s = e.paddingOuter ? e.paddingOuter() : e.padding(), o = t - i, a = Math.abs(r - n) / Math.max(1, o + s * 2);
  return (a - Math.floor(a)) * o;
}
function uA(e) {
  const t = e.scale.domain().length + fA(e);
  if (!(t > 2))
    return e.range;
  const [n, r] = e.range;
  return Array.from({ length: t }, (i, s) => n + s / (t - 1) * (r - n));
}
function sy(e, t, n) {
  return lA(e, n === void 0 ? void 0 : [{ hint: n }], { ...t });
}
function lA(e, t = [], n = {}) {
  const r = _V(e, t, n);
  if (n.type === void 0 && n.domain === void 0 && n.range === void 0 && n.interval == null && e !== "fx" && e !== "fy" && Hs({ type: r })) {
    const i = t.map(({ value: s }) => s).filter((s) => s !== void 0);
    i.some(Pe) ? Hr(
      `Warning: some data associated with the ${e} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${co(
        r
      )}" 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 "${co(
        r
      )}".`
    ) : i.some(Rj) ? Hr(
      `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 "${co(
        r
      )}" 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 "${co(
        r
      )}".`
    ) : i.some(Cj) && Hr(
      `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 "${co(
        r
      )}" 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 "${co(
        r
      )}".`
    );
  }
  switch (n.type = r, r) {
    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 = rl(t, n, We);
      break;
    case "identity":
      switch (ne.get(e)) {
        case fr:
          n = rl(t, n, We);
          break;
        case ud:
          n = rl(t, n, SV);
          break;
      }
      break;
    case "utc":
    case "time":
      n = rl(t, n, Dj);
      break;
  }
  switch (r) {
    case "diverging":
      return nV(e, t, n);
    case "diverging-sqrt":
      return rV(e, t, n);
    case "diverging-pow":
      return eA(e, t, n);
    case "diverging-log":
      return iV(e, t, n);
    case "diverging-symlog":
      return sV(e, t, n);
    case "categorical":
    case "ordinal":
    case Au:
      return dV(e, t, n);
    case "cyclical":
    case "sequential":
    case "linear":
      return qq(e, t, n);
    case "sqrt":
      return Vq(e, t, n);
    case "threshold":
      return yg(e, t, n);
    case "quantile":
      return Xq(e, t, n);
    case "quantize":
      return Gq(e, t, n);
    case "pow":
      return QM(e, t, n);
    case "log":
      return Yq(e, t, n);
    case "symlog":
      return Wq(e, t, n);
    case "utc":
      return hV(e, t, n);
    case "time":
      return fV(e, t, n);
    case "point":
      return pV(e, t, n);
    case "band":
      return yV(e, t, n);
    case "identity":
      return Jq(e);
    case void 0:
      return;
    default:
      throw new Error(`unknown scale type: ${r}`);
  }
}
function co(e) {
  return typeof e == "symbol" ? e.description : e;
}
function Xw(e) {
  return typeof e == "string" ? `${e}`.toLowerCase() : e;
}
const Gw = { toString: () => "projection" };
function _V(e, t, { type: n, domain: r, range: i, scheme: s, pivot: o, projection: a }) {
  if (n = Xw(n), e === "fx" || e === "fy")
    return "band";
  (e === "x" || e === "y") && a != null && (n = Gw);
  for (const u of t) {
    const l = Xw(u.type);
    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 === Gw)
    return;
  if (n !== void 0)
    return n;
  if (r === void 0 && !t.some(({ value: u }) => u !== void 0))
    return;
  const c = ne.get(e);
  if (c === _u)
    return "sqrt";
  if (c === Su || c === xu)
    return "linear";
  if (c === ud)
    return "ordinal";
  if ((r || i || []).length > 2)
    return $p(c);
  if (r !== void 0) {
    if (ie(r))
      return $p(c);
    if (Pe(r))
      return "utc";
  } else {
    const u = t.map(({ value: l }) => l).filter((l) => l !== void 0);
    if (u.some(ie))
      return $p(c);
    if (u.some(Pe))
      return "utc";
  }
  if (c === ai) {
    if (o != null || zq(s))
      return "diverging";
    if (Bq(s))
      return "categorical";
  }
  return "linear";
}
function $p(e) {
  switch (e) {
    case fr:
      return "point";
    case ai:
      return Au;
    default:
      return "ordinal";
  }
}
function Hs({ type: e }) {
  return e === "ordinal" || e === "point" || e === "band" || e === Au;
}
function fA({ type: e }) {
  return e === "threshold";
}
function xV({ type: e }) {
  return e === "point" || e === "band";
}
function vn(e) {
  if (e === void 0)
    return !0;
  const t = e.domain(), n = e(t[0]);
  for (let r = 1, i = t.length; r < i; ++r)
    if (e(t[r]) - n)
      return !1;
  return !0;
}
function rl(e, { domain: t, ...n }, r) {
  var i;
  for (const s of e)
    s.value !== void 0 && (t === void 0 && (t = (i = s.value) == null ? void 0 : i.domain), s.value = r(s.value));
  return {
    domain: t === void 0 ? t : r(t),
    ...n
  };
}
function SV(e) {
  return Gt(e, Km);
}
function Vs(e = {}) {
  let t;
  for (const n in e)
    if (ne.has(n) && Is(e[n])) {
      if (t !== void 0)
        throw new Error("ambiguous scale definition; multiple scales found");
      t = hA(sy(n, e[n]));
    }
  if (t === void 0)
    throw new Error("invalid scale definition; no scale found");
  return t;
}
function MV(e) {
  return (t) => {
    if (!ne.has(t = `${t}`))
      throw new Error(`unknown scale: ${t}`);
    return e[t];
  };
}
function hA({ scale: e, type: t, domain: n, range: r, interpolate: i, 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: Cc(n),
    // defensive copy
    ...r !== void 0 && { range: Cc(r) },
    // defensive copy
    ...o !== void 0 && { transform: o },
    ...a && { percent: a },
    // only exposed if truthy
    ...u !== void 0 && { unknown: u },
    ...s !== void 0 && { interval: s },
    // quantitative
    ...i !== void 0 && { interpolate: i },
    ...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) }
  };
}
function AV(e, t, n = {}) {
  let r = 0.5 - xe, i = 0.5 + xe, s = 0.5 + xe, o = 0.5 - xe;
  for (const { marginTop: y, marginRight: g, marginBottom: m, marginLeft: b } of t)
    y > r && (r = y), g > i && (i = g), m > s && (s = m), b > o && (o = b);
  let {
    margin: a,
    marginTop: c = a !== void 0 ? a : r,
    marginRight: u = a !== void 0 ? a : i,
    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 = $V(e, n, {
      width: h,
      marginTopDefault: r,
      marginRightDefault: i,
      marginBottomDefault: s,
      marginLeftDefault: o
    }) + Math.max(0, c - r + 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: y,
      marginTop: g = y !== void 0 ? y : c,
      marginRight: m = y !== void 0 ? y : u,
      marginBottom: b = y !== void 0 ? y : l,
      marginLeft: w = y !== void 0 ? y : f
    } = n.facet ?? {};
    g = +g, m = +m, b = +b, w = +w, p.facet = {
      marginTop: g,
      marginRight: m,
      marginBottom: b,
      marginLeft: w
    };
  }
  return p;
}
function $V({ x: e, y: t, fy: n, fx: r }, { projection: i, aspectRatio: s }, { width: o, marginTopDefault: a, marginRightDefault: c, marginBottomDefault: u, marginLeftDefault: l }) {
  const f = n ? n.scale.domain().length : 1, h = Fq(i);
  if (h) {
    const p = r ? r.scale.domain().length : 1, y = (1.1 * f - 0.1) / (1.1 * p - 0.1) * h, g = Math.max(0.1, Math.min(10, y));
    return Math.round((o - l - c) * g + a + u);
  }
  const d = t ? Hs(t) ? t.scale.domain().length : Math.max(7, 17 / f) : 1;
  if (s != null) {
    if (s = +s, !(isFinite(s) && s > 0))
      throw new Error(`invalid aspectRatio: ${s}`);
    const p = Hw("y", t) / (Hw("x", e) * s), y = r ? r.scale.bandwidth() : 1, g = n ? n.scale.bandwidth() : 1, m = y * (o - l - c) - e.insetLeft - e.insetRight;
    return (p * m + t.insetTop + t.insetBottom) / g + a + u;
  }
  return !!(t || n) * Math.max(1, Math.min(60, d * f)) * 20 + !!r * 30 + 60;
}
function Hw(e, t) {
  if (!t)
    throw new Error(`aspectRatio requires ${e} scale`);
  const { type: n, domain: r } = t;
  let i;
  switch (n) {
    case "linear":
    case "utc":
    case "time":
      i = Number;
      break;
    case "pow": {
      const a = t.scale.exponent();
      i = (c) => Math.pow(c, a);
      break;
    }
    case "log":
      i = Math.log;
      break;
    case "point":
    case "band":
      return r.length;
    default:
      throw new Error(`unsupported ${e} scale for aspectRatio: ${n}`);
  }
  const [s, o] = fe(r);
  return Math.abs(i(o) - i(s));
}
function IV(e, t) {
  const { fx: n, fy: r } = iy(e, t), i = n == null ? void 0 : n.scale.domain(), s = r == null ? void 0 : r.scale.domain();
  return i && s ? mL(i, s).map(([o, a], c) => ({ x: o, y: a, i: c })) : i ? i.map((o, a) => ({ x: o, i: a })) : s ? s.map((o, a) => ({ y: o, i: a })) : void 0;
}
function TV(e, { x: t, y: n }) {
  return t && (t = oy(t)), n && (n = oy(n)), e.filter(
    t && n ? (r) => t.has(r.x) && n.has(r.y) : t ? (r) => t.has(r.x) : (r) => n.has(r.y)
  ).sort(
    t && n ? (r, i) => t.get(r.x) - t.get(i.x) || n.get(r.y) - n.get(i.y) : t ? (r, i) => t.get(r.x) - t.get(i.x) : (r, i) => n.get(r.y) - n.get(i.y)
  );
}
function bg(e, { fx: t, fy: n }) {
  const r = si(e), i = t == null ? void 0 : t.value, s = n == null ? void 0 : n.value;
  return t && n ? Do(
    r,
    (o) => (o.fx = i[o[0]], o.fy = s[o[0]], o),
    (o) => i[o],
    (o) => s[o]
  ) : t ? Do(
    r,
    (o) => (o.fx = i[o[0]], o),
    (o) => i[o]
  ) : Do(
    r,
    (o) => (o.fy = s[o[0]], o),
    (o) => s[o]
  );
}
function EV(e, t, { marginTop: n, marginLeft: r }) {
  return e && t ? ({ x: i, y: s }) => `translate(${e(i) - r},${t(s) - n})` : e ? ({ x: i }) => `translate(${e(i) - r},0)` : ({ y: i }) => `translate(0,${t(i) - n})`;
}
function NV(e) {
  const t = [], n = new Uint32Array(gr(e, (r) => r.length));
  for (const r of e) {
    let i = 0;
    for (const s of e)
      r !== s && (n.set(s, i), i += s.length);
    t.push(n.slice(0, i));
  }
  return t;
}
const DV = /* @__PURE__ */ new Map([
  ["top", Ip],
  ["right", Np],
  ["bottom", Tp],
  ["left", Ep],
  ["top-left", il(Ip, Ep)],
  ["top-right", il(Ip, Np)],
  ["bottom-left", il(Tp, Ep)],
  ["bottom-right", il(Tp, Np)],
  ["top-empty", kV],
  ["right-empty", CV],
  ["bottom-empty", FV],
  ["left-empty", RV],
  ["empty", BV]
]);
function OV(e) {
  if (e == null)
    return null;
  const t = DV.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid facet anchor: ${e}`);
}
const Jw = /* @__PURE__ */ new WeakMap();
function oy(e) {
  let t = Jw.get(e);
  return t || Jw.set(e, t = new Fs(Gt(e, (n, r) => [n, r]))), t;
}
function Zi(e, t) {
  return oy(e).get(t);
}
function LV(e, t, n) {
  return t = ws(t), n = ws(n), e.find((r) => Object.is(ws(r.x), t) && Object.is(ws(r.y), n));
}
function gd(e, t, n) {
  var r;
  return (r = LV(e, t, n)) == null ? void 0 : r.empty;
}
function Ip(e, { y: t }, { y: n }) {
  return t ? Zi(t, n) === 0 : !0;
}
function Tp(e, { y: t }, { y: n }) {
  return t ? Zi(t, n) === t.length - 1 : !0;
}
function Ep(e, { x: t }, { x: n }) {
  return t ? Zi(t, n) === 0 : !0;
}
function Np(e, { x: t }, { x: n }) {
  return t ? Zi(t, n) === t.length - 1 : !0;
}
function kV(e, { y: t }, { x: n, y: r, empty: i }) {
  if (i)
    return !1;
  if (!t)
    return;
  const s = Zi(t, r);
  if (s > 0)
    return gd(e, n, t[s - 1]);
}
function FV(e, { y: t }, { x: n, y: r, empty: i }) {
  if (i)
    return !1;
  if (!t)
    return;
  const s = Zi(t, r);
  if (s < t.length - 1)
    return gd(e, n, t[s + 1]);
}
function RV(e, { x: t }, { x: n, y: r, empty: i }) {
  if (i)
    return !1;
  if (!t)
    return;
  const s = Zi(t, n);
  if (s > 0)
    return gd(e, t[s - 1], r);
}
function CV(e, { x: t }, { x: n, y: r, empty: i }) {
  if (i)
    return !1;
  if (!t)
    return;
  const s = Zi(t, n);
  if (s < t.length - 1)
    return gd(e, t[s + 1], r);
}
function BV(e, t, { empty: n }) {
  return n;
}
function il(e, t) {
  return function() {
    return e.apply(null, arguments) && t.apply(null, arguments);
  };
}
function Dp(e, { channels: { fx: t, fy: n }, groups: r }) {
  return t && n ? e.map(({ x: i, y: s }) => {
    var o;
    return ((o = r.get(i)) == null ? void 0 : o.get(s)) ?? [];
  }) : t ? e.map(({ x: i }) => r.get(i) ?? []) : e.map(({ y: i }) => r.get(i) ?? []);
}
let Xt = class {
  constructor(t, n = {}, r = {}, i) {
    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: y = h,
      marginLeft: g = h,
      clip: m = i == null ? void 0 : i.clip,
      channels: b,
      tip: w,
      render: v
    } = r;
    if (this.data = t, this.sort = Bi(u) ? u : null, this.initializer = Ke(r).initializer, this.transform = this.initializer ? r.transform : Mr(r).transform, s === null || s === !1 ? this.facet = null : (this.facet = ln(s === !0 ? "include" : s, "facet", ["auto", "include", "exclude", "super"]), this.fx = t === cc && typeof a == "string" ? [a] : a, this.fy = t === cc && typeof c == "string" ? [c] : c), this.facetAnchor = OV(o), n = Hm(n), b !== void 0 && (n = { ...PV(b), ...n }), i !== void 0 && (n = { ...zM(this, r, i), ...n }), this.channels = Object.fromEntries(
      Object.entries(n).map(([x, _]) => {
        if (Qn(_.value)) {
          const { value: M, label: T = _.label, scale: N = _.scale } = _.value;
          _ = { ..._, label: T, scale: N, value: M };
        }
        if (t === cc && typeof _.value == "string") {
          const { value: M } = _;
          _ = { ..._, value: [M] };
        }
        return [x, _];
      }).filter(([x, { value: _, optional: M }]) => {
        if (_ != null)
          return !0;
        if (M)
          return !1;
        throw new Error(`missing channel value: ${x}`);
      })
    ), this.dx = +l, this.dy = +f, this.marginTop = +d, this.marginRight = +p, this.marginBottom = +y, this.marginLeft = +g, this.clip = qM(m), this.tip = UV(w), this.facet === "super") {
      if (a || c)
        throw new Error("super-faceting cannot use fx or fy");
      for (const x in this.channels) {
        const { scale: _ } = n[x];
        if (!(_ !== "x" && _ !== "y"))
          throw new Error("super-faceting cannot use x or y");
      }
    }
    v != null && (this.render = oh(v, this.render));
  }
  initialize(t, n, r) {
    let i = Ze(this.data);
    t === void 0 && i != null && (t = [si(i)]);
    const s = t;
    this.transform != null && ({ facets: t, data: i } = this.transform(i, t, r), i = Ze(i)), t !== void 0 && (t.original = s);
    const o = RM(this.channels, i);
    return this.sort != null && lq(i, t, o, n, this.sort), { data: i, facets: t, channels: o };
  }
  filter(t, n, r) {
    for (const i in n) {
      const { filter: s = Re } = n[i];
      if (s !== null) {
        const o = r[i];
        t = t.filter((a) => s(o[a]));
      }
    }
    return t;
  }
  // If there is a projection, and there are paired x and y channels 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, r) {
    for (const i in t)
      if (t[i].scale === "x" && /^x|x$/.test(i)) {
        const s = i.replace(/^x|x$/, "y");
        s in t && t[s].scale === "y" && GM(i, s, n, r.projection);
      }
  }
  scale(t, n, r) {
    const i = ug(t, n);
    return r.projection && this.project(t, i, r), i;
  }
};
function An(...e) {
  return e.plot = Xt.prototype.plot, e;
}
function oh(e, t) {
  if (e == null)
    return t === null ? void 0 : t;
  if (t == null)
    return e === null ? void 0 : e;
  if (typeof e != "function")
    throw new TypeError(`invalid render transform: ${e}`);
  if (typeof t != "function")
    throw new TypeError(`invalid render transform: ${t}`);
  return function(n, r, i, s, o, a) {
    return e.call(this, n, r, i, s, o, (c, u, l, f, h) => t.call(this, c, u, l, f, h, a));
  };
}
function PV(e) {
  return Object.fromEntries(
    Object.entries(Hm(e)).map(([t, n]) => (n = typeof n == "string" ? { value: n, label: t } : xa(n), n.filter === void 0 && n.scale == null && (n = { ...n, filter: null }), [t, n]))
  );
}
function UV(e) {
  return e === !0 ? "xy" : e === !1 || e == null ? null : typeof e == "string" ? ln(e, "tip", ["x", "y", "xy"]) : e;
}
function Js(e, t) {
  return (e == null ? void 0 : e.tip) === !0 ? { ...e, tip: t } : $n(e == null ? void 0 : e.tip) && e.tip.pointer === void 0 ? { ...e, tip: { ...e.tip, pointer: t } } : e;
}
const Zw = /* @__PURE__ */ new WeakMap();
function wg(e, t, { x: n, y: r, px: i, py: s, maxRadius: o = 40, channels: a, render: c, ...u } = {}) {
  return o = +o, i != null && (n ?? (n = null), a = { ...a, px: { value: i, scale: "x" } }), s != null && (r ?? (r = null), a = { ...a, py: { value: s, scale: "y" } }), {
    x: n,
    y: r,
    channels: a,
    ...u,
    // Unlike other composed transforms, the render transform must be the
    // outermost render function because it will re-render dynamically in
    // response to pointer events.
    render: oh(function(l, f, h, d, p, y) {
      p = { ...p, pointerSticky: !1 };
      const g = p.ownerSVGElement, { data: m } = p.getMarkState(this);
      let b = Zw.get(g);
      b || Zw.set(g, b = { sticky: !1, roots: [], renders: [] });
      let w = b.renders.push(Y) - 1;
      const { x: v, y: x, fx: _, fy: M } = f;
      let T = _ ? _(l.fx) - d.marginLeft : 0, N = M ? M(l.fy) - d.marginTop : 0;
      v != null && v.bandwidth && (T += v.bandwidth() / 2), x != null && x.bandwidth && (N += x.bandwidth() / 2);
      const A = l.fi != null;
      let $;
      if (A) {
        let q = b.facetStates;
        q || (b.facetStates = q = /* @__PURE__ */ new Map()), $ = q.get(this), $ || q.set(this, $ = /* @__PURE__ */ new Map());
      }
      const [D, F] = Ar(this, d), { px: S, py: I } = h, E = S ? (q) => S[q] : dA(h, D), O = I ? (q) => I[q] : pA(h, F);
      let C, B, R, P;
      function U(q, W) {
        if (A)
          if (P && (P = cancelAnimationFrame(P)), q == null)
            $.delete(l.fi);
          else {
            $.set(l.fi, W), P = requestAnimationFrame(() => {
              P = null;
              for (const [j, X] of $)
                if (X < W || X === W && j < l.fi) {
                  q = null;
                  break;
                }
              Y(q);
            });
            return;
          }
        Y(q);
      }
      function Y(q) {
        if (C === q && R === b.sticky)
          return;
        C = q, R = p.pointerSticky = b.sticky;
        const W = C == null ? [] : [C];
        A && (W.fx = l.fx, W.fy = l.fy, W.fi = l.fi);
        const j = y(W, f, h, d, p);
        if (B) {
          if (A) {
            const X = B.parentNode, K = B.getAttribute("transform"), z = j.getAttribute("transform");
            K ? j.setAttribute("transform", K) : j.removeAttribute("transform"), z ? X.setAttribute("transform", z) : X.removeAttribute("transform"), j.removeAttribute("aria-label"), j.removeAttribute("aria-description"), j.removeAttribute("aria-hidden");
          }
          B.replaceWith(j);
        }
        return b.roots[w] = B = j, C == null && ($ == null ? void 0 : $.size) > 1 || p.dispatchValue(C == null ? null : m[C]), j;
      }
      function G(q) {
        if (b.sticky || q.pointerType === "mouse" && q.buttons === 1)
          return;
        let [W, j] = En(q);
        W -= T, j -= N;
        const X = W < d.marginLeft || W > d.width - d.marginRight ? 1 : e, K = j < d.marginTop || j > d.height - d.marginBottom ? 1 : t;
        let z = null, wt = o * o;
        for (const Q of l) {
          const It = X * (E(Q) - W), Tt = K * (O(Q) - j), J = It * It + Tt * Tt;
          J <= wt && (z = Q, wt = J);
        }
        if (z != null && (e !== 1 || t !== 1)) {
          const Q = E(z) - W, It = O(z) - j;
          wt = Q * Q + It * It;
        }
        U(z, wt);
      }
      function Z(q) {
        q.pointerType === "mouse" && C != null && (b.sticky && b.roots.some((W) => W == null ? void 0 : W.contains(q.target)) || (b.sticky ? (b.sticky = !1, b.renders.forEach((W) => W(null))) : (b.sticky = !0, Y(C)), q.stopImmediatePropagation()));
      }
      function H(q) {
        q.pointerType === "mouse" && (b.sticky || U(null));
      }
      return g.addEventListener("pointerenter", G), g.addEventListener("pointermove", G), g.addEventListener("pointerdown", Z), g.addEventListener("pointerleave", H), Y(null);
    }, c)
  };
}
function vg(e) {
  return wg(1, 1, e);
}
function _g(e) {
  return wg(1, 0.01, e);
}
function ah(e) {
  return wg(0.01, 1, e);
}
function dA({ x1: e, x2: t, x: n = e }, r) {
  return e && t ? (i) => (e[i] + t[i]) / 2 : n ? (i) => n[i] : () => r;
}
function pA({ y1: e, y2: t, y: n = e }, r) {
  return e && t ? (i) => (e[i] + t[i]) / 2 : n ? (i) => n[i] : () => r;
}
function yA(e) {
  return Hs(e) && e.interval === void 0 ? void 0 : "tabular-nums";
}
function zV(e, t) {
  let {
    label: n = e.label,
    tickSize: r = 6,
    width: i = 240,
    height: s = 44 + r,
    marginTop: o = 18,
    marginRight: a = 0,
    marginBottom: c = 16 + r,
    marginLeft: u = 0,
    style: l,
    ticks: f = (i - u - a) / 64,
    tickFormat: h,
    fontVariant: d = yA(e),
    round: p = !0,
    opacity: y,
    className: g
  } = t;
  const m = dd(t);
  g = hg(g), y = ce(y)[1], h === null && (h = () => null);
  const b = Nt("svg", m).attr("class", `${g}-ramp`).attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("width", i).attr("height", s).attr("viewBox", `0 0 ${i} ${s}`).call(
    (D) => (
      // Warning: if you edit this, change defaultClassName.
      D.append("style").text(
        `:where(.${g}-ramp) {
  display: block;
  height: auto;
  height: intrinsic;
  max-width: 100%;
  overflow: visible;
}
:where(.${g}-ramp text) {
  white-space: pre;
}`
      )
    )
  ).call(dg, l);
  let w = (D) => D.selectAll(".tick line").attr("y1", o + c - s), v;
  const x = p ? (D, F) => D.rangeRound(F) : (D, F) => D.range(F), { type: _, domain: M, range: T, interpolate: N, scale: A, pivot: $ } = e;
  if (N) {
    const D = T === void 0 ? N : zh(N.length === 1 ? mg(N) : N, T);
    v = x(
      A.copy(),
      Pn(
        $e(u, i - a),
        Math.min(M.length + ($ !== void 0), T === void 0 ? 1 / 0 : T.length)
      )
    );
    const F = 256, S = m.document.createElement("canvas");
    S.width = F, S.height = 1;
    const I = S.getContext("2d");
    for (let E = 0, O = F - 1; E < F; ++E)
      I.fillStyle = D(E / O), I.fillRect(E, 0, 1, 1);
    b.append("image").attr("opacity", y).attr("x", u).attr("y", o).attr("width", i - u - a).attr("height", s - o - c).attr("preserveAspectRatio", "none").attr("xlink:href", S.toDataURL());
  } else if (_ === "threshold") {
    const D = M, F = h === void 0 ? (S) => S : typeof h == "string" ? wa(h) : h;
    v = x(Hh().domain([-1, T.length - 1]), [u, i - a]), b.append("g").attr("fill-opacity", y).selectAll().data(T).enter().append("rect").attr("x", (S, I) => v(I - 1)).attr("y", o).attr("width", (S, I) => v(I) - v(I - 1)).attr("height", s - o - c).attr("fill", (S) => S), f = Gt(D, (S, I) => I), h = (S) => F(D[S], S);
  } else
    v = x(Xh().domain(M), [u, i - a]), b.append("g").attr("fill-opacity", y).selectAll().data(M).enter().append("rect").attr("x", v).attr("y", o).attr("width", Math.max(0, v.bandwidth() - 1)).attr("height", s - o - c).attr("fill", A), w = () => {
    };
  return b.append("g").attr("transform", `translate(0,${s - c})`).call(
    BL(v).ticks(Array.isArray(f) ? null : f, typeof h == "string" ? h : void 0).tickFormat(typeof h == "function" ? h : void 0).tickSize(r).tickValues(Array.isArray(f) ? f : null)
  ).attr("font-size", null).attr("font-family", null).attr("font-variant", se(d, "normal")).call(w).call((D) => D.select(".domain").remove()), n !== void 0 && b.append("text").attr("x", u).attr("y", o - 6).attr("fill", "currentColor").attr("font-weight", "bold").text(n), b.node();
}
const ch = Math.PI / 180;
function Sa(e, { marker: t, markerStart: n = t, markerMid: r = t, markerEnd: i = t } = {}) {
  e.markerStart = Op(n), e.markerMid = Op(r), e.markerEnd = Op(i);
}
function Op(e) {
  if (e == null || e === !1)
    return null;
  if (e === !0)
    return Qw;
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return null;
    case "arrow":
      return Kw("auto");
    case "arrow-reverse":
      return Kw("auto-start-reverse");
    case "dot":
      return jV;
    case "circle":
    case "circle-fill":
      return Qw;
    case "circle-stroke":
      return qV;
    case "tick":
      return Lp("auto");
    case "tick-x":
      return Lp(90);
    case "tick-y":
      return Lp(0);
  }
  throw new Error(`invalid marker: ${e}`);
}
function Kw(e) {
  return (t, n) => Nt("svg:marker", n).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("orient", e).attr("fill", "none").attr("stroke", t).attr("stroke-width", 1.5).attr("stroke-linecap", "round").attr("stroke-linejoin", "round").call((r) => r.append("path").attr("d", "M-1.5,-3l3,3l-3,3")).node();
}
function jV(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 Qw(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", "var(--plot-background)").attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
function qV(e, t) {
  return Nt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", "var(--plot-background)").attr("stroke", e).attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
function Lp(e) {
  return (t, n) => Nt("svg:marker", n).attr("viewBox", "-3 -3 6 6").attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", e).attr("stroke", t).call((r) => r.append("path").attr("d", "M0,-3v6")).node();
}
let VV = 0;
function $u(e, t, { stroke: n }, r) {
  return mA(e, t, n && ((i) => n[i]), r);
}
function YV(e, t, { stroke: n }, r) {
  return mA(e, t, n && (([i]) => n[i]), r);
}
function mA(e, { markerStart: t, markerMid: n, markerEnd: r, stroke: i }, s = () => i, o) {
  const a = /* @__PURE__ */ new Map();
  function c(u) {
    return function(l) {
      const f = s(l);
      let h = a.get(u);
      h || a.set(u, h = /* @__PURE__ */ new Map());
      let d = h.get(f);
      if (!d) {
        const p = this.parentNode.insertBefore(u(f, o), this), y = `plot-marker-${++VV}`;
        p.setAttribute("id", y), h.set(f, d = `url(#${y})`);
      }
      return d;
    };
  }
  t && e.attr("marker-start", c(t)), n && e.attr("marker-mid", c(n)), r && e.attr("marker-end", c(r));
}
function Iu({ inset: e, insetLeft: t, insetRight: n, ...r } = {}) {
  return [t, n] = gA(e, t, n), { inset: e, insetLeft: t, insetRight: n, ...r };
}
function Tu({ inset: e, insetTop: t, insetBottom: n, ...r } = {}) {
  return [t, n] = gA(e, t, n), { inset: e, insetTop: t, insetBottom: n, ...r };
}
function gA(e, t, n) {
  return e === void 0 && t === void 0 && n === void 0 ? xe ? [1, 0] : [0.5, 0.5] : [t, n];
}
function bA(e, { interval: t }) {
  return e = { ...xa(e) }, e.interval = cd(e.interval === void 0 ? t : e.interval), e;
}
function bd(e, t, n, r) {
  const { [e]: i, [`${e}1`]: s, [`${e}2`]: o } = n, { value: a, interval: c } = bA(i, n);
  if (a == null || c == null && !r)
    return n;
  const u = Sr(i);
  if (c == null) {
    let d;
    const p = { transform: (y) => d || (d = At(y, a)), label: u };
    return {
      ...n,
      [e]: void 0,
      [`${e}1`]: s === void 0 ? p : s,
      [`${e}2`]: o === void 0 && !(s === o && r) ? p : o
    };
  }
  let l, f;
  function h(d) {
    return f !== void 0 && d === l ? f : f = Gt(At(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 wA(e, t, n) {
  const { [e]: r } = n, { value: i, interval: s } = bA(r, n);
  return i == null || s == null ? n : t({
    ...n,
    [e]: {
      label: Sr(r),
      transform: (o) => {
        const a = Gt(At(o, i), (u) => s.floor(u)), c = a.map((u) => s.offset(u));
        return a.map(
          Pe(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 vA(e = {}) {
  return bd("x", Iu, e, !0);
}
function _A(e = {}) {
  return bd("y", Tu, e, !0);
}
function xA(e = {}) {
  return bd("x", Iu, e);
}
function SA(e = {}) {
  return bd("y", Tu, e);
}
function MA(e = {}) {
  return wA("x", Iu, e);
}
function AA(e = {}) {
  return wA("y", Tu, e);
}
const $A = {
  ariaLabel: "rule",
  fill: null,
  stroke: "currentColor"
};
class IA extends Xt {
  constructor(t, n = {}) {
    const { x: r, y1: i, y2: s, inset: o = 0, insetTop: a = o, insetBottom: c = o } = n;
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y1: { value: i, scale: "y", optional: !0 },
        y2: { value: s, scale: "y", optional: !0 }
      },
      Js(n, "x"),
      $A
    ), this.insetTop = Et(a), this.insetBottom = Et(c), Sa(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y1: u, y2: l } = r, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: y, marginBottom: g } = i, { insetTop: m, insetBottom: b } = this;
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, { x: c && o }, xe, 0).call(
      (w) => w.selectAll().data(t).enter().append("line").call(Jt, this).attr("x1", c ? (v) => c[v] : (y + f - p) / 2).attr("x2", c ? (v) => c[v] : (y + f - p) / 2).attr("y1", u && !vn(a) ? (v) => u[v] + m : d + m).attr(
        "y2",
        l && !vn(a) ? a.bandwidth ? (v) => l[v] + a.bandwidth() - b : (v) => l[v] - b : h - g - b
      ).call(pe, this, r).call($u, this, r, s)
    ).node();
  }
}
class TA extends Xt {
  constructor(t, n = {}) {
    const { x1: r, x2: i, y: s, inset: o = 0, insetRight: a = o, insetLeft: c = o } = n;
    super(
      t,
      {
        y: { value: s, scale: "y", optional: !0 },
        x1: { value: r, scale: "x", optional: !0 },
        x2: { value: i, scale: "x", optional: !0 }
      },
      Js(n, "y"),
      $A
    ), this.insetRight = Et(a), this.insetLeft = Et(c), Sa(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { y: c, x1: u, x2: l } = r, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: y, marginBottom: g } = i, { insetLeft: m, insetRight: b } = this;
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, { y: c && a }, 0, xe).call(
      (w) => w.selectAll().data(t).enter().append("line").call(Jt, this).attr("x1", u && !vn(o) ? (v) => u[v] + m : y + m).attr(
        "x2",
        l && !vn(o) ? o.bandwidth ? (v) => l[v] + o.bandwidth() - b : (v) => l[v] - b : f - p - b
      ).attr("y1", c ? (v) => c[v] : (d + h - g) / 2).attr("y2", c ? (v) => c[v] : (d + h - g) / 2).call(pe, this, r).call($u, this, r, s)
    ).node();
  }
}
function Pi(e, t) {
  let { x: n = at, y: r, y1: i, y2: s, ...o } = SA(t);
  return [i, s] = EA(r, i, s), new IA(e, { ...o, x: n, y1: i, y2: s });
}
function Ui(e, t) {
  let { y: n = at, x: r, x1: i, x2: s, ...o } = xA(t);
  return [i, s] = EA(r, i, s), new TA(e, { ...o, y: n, x1: i, x2: s });
}
function EA(e, t, n) {
  if (e == null) {
    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 wd(e, ...t) {
  let n = t.length;
  for (let r = 0, i = !0; r < n; ++r)
    typeof t[r] != "function" && (i && (e = e.slice(), i = !1), e.splice(r, 2, e[r] + t[r] + e[r + 1]), t.splice(r, 1), --r, --n);
  return (r) => {
    let i = e[0];
    for (let s = 0; s < n; ++s)
      i += t[s](r) + e[s + 1];
    return i;
  };
}
const WV = {
  ariaLabel: "text",
  strokeLinejoin: "round",
  strokeWidth: 3,
  paintOrder: "stroke"
}, NA = "­";
class vd extends Xt {
  constructor(t, n = {}) {
    const {
      x: r,
      y: i,
      text: s = oi(t) && MM(t) ? at : 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,
      textOverflow: f,
      monospace: h,
      fontFamily: d = h ? "ui-monospace, monospace" : void 0,
      fontSize: p,
      fontStyle: y,
      fontVariant: g,
      fontWeight: m,
      rotate: b
    } = n, [w, v] = ce(b, 0), [x, _] = JV(p);
    if (super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        fontSize: { value: x, optional: !0 },
        rotate: { value: kj(w), optional: !0 },
        text: { value: s, filter: Pm, optional: !0 }
      },
      n,
      WV
    ), this.rotate = v, this.textAnchor = se(a, "middle"), this.lineAnchor = ln(c, "lineAnchor", ["top", "middle", "bottom"]), this.lineHeight = +u, this.lineWidth = +l, this.textOverflow = DA(f), this.monospace = !!h, this.fontFamily = Te(d), this.fontSize = _, this.fontStyle = Te(y), this.fontVariant = Te(g), this.fontWeight = Te(m), this.frameAnchor = vu(o), !(this.lineWidth >= 0))
      throw new Error(`invalid lineWidth: ${l}`);
    this.splitLines = FA(this), this.clipLine = RA(this);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, rotate: l, text: f, title: h, fontSize: d } = r, { rotate: p } = this, [y, g] = Ar(this, i);
    return Nt("svg:g", s).call(te, this, i, s).call(kA, this, f, i).call(Wt, this, { x: c && o, y: u && a }).call(
      (m) => m.selectAll().data(t).enter().append("text").call(Jt, this).call(XV, this, f, h).attr(
        "transform",
        wd`translate(${c ? (b) => c[b] : y},${u ? (b) => u[b] : g})${l ? (b) => ` rotate(${l[b]})` : p ? ` rotate(${p})` : ""}`
      ).call(et, "font-size", d && ((b) => d[b])).call(pe, this, r)
    ).node();
  }
}
function DA(e) {
  return e == null ? null : ln(e, "textOverflow", [
    "clip",
    // shorthand for clip-end
    "ellipsis",
    // … ellipsis-end
    "clip-start",
    "clip-end",
    "ellipsis-start",
    "ellipsis-middle",
    "ellipsis-end"
  ]).replace(/^(clip|ellipsis)$/, "$1-end");
}
function XV(e, t, n, r) {
  if (!n)
    return;
  const { lineAnchor: i, lineHeight: s, textOverflow: o, splitLines: a, clipLine: c } = t;
  e.each(function(u) {
    const l = a(qs(n[u]) ?? "").map(c), f = l.length, h = i === "top" ? 0.71 : i === "bottom" ? 1 - f : (164 - f * 100) / 200;
    if (f > 1) {
      let d = 0;
      for (let p = 0; p < f; ++p) {
        if (++d, !l[p])
          continue;
        const y = this.ownerDocument.createElementNS(Rs.svg, "tspan");
        y.setAttribute("x", 0), p === d - 1 ? y.setAttribute("y", `${(h + p) * s}em`) : y.setAttribute("dy", `${d * s}em`), y.textContent = l[p], this.appendChild(y), d = 0;
      }
    } else
      h && this.setAttribute("y", `${h * s}em`), this.textContent = l[0];
    if (o && !r && l[0] !== n[u]) {
      const d = this.ownerDocument.createElementNS(Rs.svg, "title");
      d.textContent = n[u], this.appendChild(d);
    }
  });
}
function ca(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Wn(t, n)), new vd(e, { ...r, x: t, y: n });
}
function OA(e, { x: t = at, ...n } = {}) {
  return new vd(e, AA({ ...n, x: t }));
}
function LA(e, { y: t = at, ...n } = {}) {
  return new vd(e, MA({ ...n, y: t }));
}
function kA(e, t, n) {
  et(e, "text-anchor", t.textAnchor), et(e, "font-family", t.fontFamily), et(e, "font-size", t.fontSize), et(e, "font-style", t.fontStyle), et(e, "font-variant", t.fontVariant === void 0 ? GV(n) : t.fontVariant), et(e, "font-weight", t.fontWeight);
}
function GV(e) {
  return e && (xo(e) || Pe(e)) ? "tabular-nums" : void 0;
}
const HV = /* @__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 JV(e) {
  return e == null || typeof e == "number" ? [void 0, e] : typeof e != "string" ? [e, void 0] : (e = e.trim().toLowerCase(), HV.has(e) || /^[+-]?\d*\.?\d+(e[+-]?\d+)?(\w*|%)$/.test(e) ? [void 0, e] : [e, void 0]);
}
function ZV(e, t, n) {
  const r = [];
  let i, s = 0;
  for (const [o, a, c] of KV(e)) {
    if (i === void 0 && (i = o), s > i && n(e, i, a) > t && (r.push(e.slice(i, s) + (e[s - 1] === NA ? "-" : "")), i = o), c) {
      r.push(e.slice(i, a)), i = void 0;
      continue;
    }
    s = a;
  }
  return r;
}
function* KV(e) {
  let t = 0, n = 0;
  const r = e.length;
  for (; n < r; ) {
    let i = 1;
    switch (e[n]) {
      case NA:
      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] === `
` && ++i;
      case `
`:
        yield [t, n, !0], n += i, t = n;
        break;
      default:
        ++n;
        break;
    }
  }
  yield [t, n, !0];
}
const t2 = {
  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,
  "…": 82
};
function xg(e, t = 0, n = e.length) {
  let r = 0;
  for (let i = t; i < n; i = Ma(e, i))
    r += t2[e[i]] ?? (BA(e, i) ? 120 : t2.e);
  return r;
}
function Sg(e, t = 0, n = e.length) {
  let r = 0;
  for (let i = t; i < n; i = Ma(e, i))
    r += BA(e, i) ? 126 : 63;
  return r;
}
function FA({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n != null || t == 1 / 0)
    return (s) => s.split(/\r\n?|\n/g);
  const r = e ? Sg : xg, i = t * 100;
  return (s) => ZV(s, i, r);
}
function RA({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n == null || t == 1 / 0)
    return (s) => s;
  const r = e ? Sg : xg, i = t * 100;
  switch (n) {
    case "clip-start":
      return (s) => n2(s, i, r, "");
    case "clip-end":
      return (s) => e2(s, i, r, "");
    case "ellipsis-start":
      return (s) => n2(s, i, r, Ro);
    case "ellipsis-middle":
      return (s) => QV(s, i, r, Ro);
    case "ellipsis-end":
      return (s) => e2(s, i, r, Ro);
  }
}
const Ro = "…";
function ua(e, t, n, r) {
  const i = [];
  let s = 0;
  for (let o = 0, a = 0, c = e.length; o < c; o = a) {
    a = Ma(e, o);
    const u = n(e, o, a);
    if (s + u > t) {
      for (s += r; s > t && o > 0; )
        a = o, o = i.pop(), s -= n(e, o, a);
      return [o, t - s];
    }
    s += u, i.push(o);
  }
  return [-1, 0];
}
function e2(e, t, n, r) {
  e = e.trim();
  const i = n(r), [s] = ua(e, t, n, i);
  return s < 0 ? e : e.slice(0, s).trimEnd() + r;
}
function QV(e, t, n, r) {
  e = e.trim();
  const i = n(e);
  if (i <= t)
    return e;
  const s = n(r) / 2, [o, a] = ua(e, t / 2, n, s), [c] = ua(e, i - t / 2 - a + s, n, -s);
  return c < 0 ? r : e.slice(0, o).trimEnd() + r + e.slice(Ma(e, c)).trimStart();
}
function n2(e, t, n, r) {
  e = e.trim();
  const i = n(e);
  if (i <= t)
    return e;
  const s = n(r), [o] = ua(e, i - t + s, n, -s);
  return o < 0 ? r : r + e.slice(Ma(e, o)).trimStart();
}
const ay = /[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy, r2 = new RegExp("\\p{Extended_Pictographic}", "uy");
function Ma(e, t) {
  return t += tY(e, t) ? 2 : 1, nY(e, t) && (t = ay.lastIndex), eY(e, t) ? Ma(e, t + 1) : t;
}
function CA(e, t) {
  return e.charCodeAt(t) < 128;
}
function tY(e, t) {
  const n = e.charCodeAt(t);
  if (n >= 55296 && n < 56320) {
    const r = e.charCodeAt(t + 1);
    return r >= 56320 && r < 57344;
  }
  return !1;
}
function eY(e, t) {
  return e.charCodeAt(t) === 8205;
}
function nY(e, t) {
  return CA(e, t) ? !1 : (ay.lastIndex = t, ay.test(e));
}
function BA(e, t) {
  return CA(e, t) ? !1 : (r2.lastIndex = t, r2.test(e));
}
const PA = {
  ariaLabel: "vector",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinejoin: "round",
  strokeLinecap: "round"
}, UA = 3.5, rY = UA * 5, zA = {
  draw(e, t, n) {
    const r = t * n / rY;
    e.moveTo(0, 0), e.lineTo(0, -t), e.moveTo(-r, r - t), e.lineTo(0, -t), e.lineTo(r, r - t);
  }
}, jA = {
  draw(e, t, n) {
    e.moveTo(-n, 0), e.lineTo(0, -t), e.lineTo(n, 0);
  }
}, iY = /* @__PURE__ */ new Map([
  ["arrow", zA],
  ["spike", jA]
]);
function sY(e) {
  return e && typeof e.draw == "function";
}
function oY(e) {
  if (sY(e))
    return e;
  const t = iY.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid shape: ${e}`);
}
class _d extends Xt {
  constructor(t, n = {}) {
    const { x: r, y: i, r: s = UA, length: o, rotate: a, shape: c = zA, anchor: u = "middle", frameAnchor: l } = n, [f, h] = ce(o, 12), [d, p] = ce(a, 0);
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        length: { value: f, scale: "length", optional: !0 },
        rotate: { value: d, optional: !0 }
      },
      n,
      PA
    ), this.r = +s, this.length = h, this.rotate = p, this.shape = oY(c), this.anchor = ln(u, "anchor", ["start", "middle", "end"]), this.frameAnchor = vu(l);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, length: l, rotate: f } = r, { length: h, rotate: d, anchor: p, shape: y, r: g } = this, [m, b] = Ar(this, i);
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, { x: c && o, y: u && a }).call(
      (w) => w.selectAll().data(t).enter().append("path").call(Jt, this).attr(
        "transform",
        wd`translate(${c ? (v) => c[v] : m},${u ? (v) => u[v] : b})${f ? (v) => ` rotate(${f[v]})` : d ? ` rotate(${d})` : ""}${p === "start" ? "" : p === "end" ? l ? (v) => ` translate(0,${l[v]})` : ` translate(0,${h})` : l ? (v) => ` translate(0,${l[v] / 2})` : ` translate(0,${h / 2})`}`
      ).attr(
        "d",
        l ? (v) => {
          const x = qr();
          return y.draw(x, l[v], g), x;
        } : (() => {
          const v = qr();
          return y.draw(v, h, g), v;
        })()
      ).call(pe, this, r)
    ).node();
  }
}
function qA(e, t = {}) {
  let { x: n, y: r, ...i } = t;
  return t.frameAnchor === void 0 && ([n, r] = Wn(n, r)), new _d(e, { ...i, x: n, y: r });
}
function VA(e, t = {}) {
  const { x: n = at, ...r } = t;
  return new _d(e, { ...r, x: n });
}
function YA(e, t = {}) {
  const { y: n = at, ...r } = t;
  return new _d(e, { ...r, y: n });
}
function aY(e, t = {}) {
  const {
    shape: n = jA,
    stroke: r = PA.stroke,
    strokeWidth: i = 1,
    fill: s = r,
    fillOpacity: o = 0.3,
    anchor: a = "start",
    ...c
  } = t;
  return qA(e, { ...c, shape: n, stroke: r, strokeWidth: i, fill: s, fillOpacity: o, anchor: a });
}
function Ki(e, t) {
  return arguments.length < 2 && !oi(e) && (t = e, e = null), t === void 0 && (t = {}), [e, t];
}
function xd({ anchor: e } = {}, t) {
  return e === void 0 ? t[0] : ln(e, "anchor", t);
}
function WA(e) {
  return xd(e, ["left", "right"]);
}
function XA(e) {
  return xd(e, ["right", "left"]);
}
function GA(e) {
  return xd(e, ["bottom", "top"]);
}
function HA(e) {
  return xd(e, ["top", "bottom"]);
}
function Mg() {
  const [e, t] = Ki(...arguments);
  return KA("y", WA(t), e, t);
}
function JA() {
  const [e, t] = Ki(...arguments);
  return KA("fy", XA(t), e, t);
}
function Ag() {
  const [e, t] = Ki(...arguments);
  return QA("x", GA(t), e, t);
}
function ZA() {
  const [e, t] = Ki(...arguments);
  return QA("fx", HA(t), e, t);
}
function KA(e, t, n, {
  color: r = "currentColor",
  opacity: i = 1,
  stroke: s = r,
  strokeOpacity: o = i,
  strokeWidth: a = 1,
  fill: c = r,
  fillOpacity: u = i,
  textAnchor: l,
  textStroke: f,
  textStrokeOpacity: h,
  textStrokeWidth: d,
  tickSize: p = e === "y" ? 6 : 0,
  tickPadding: y,
  tickRotate: g,
  x: m,
  margin: b,
  marginTop: w = b === void 0 ? 20 : b,
  marginRight: v = b === void 0 ? t === "right" ? 40 : 0 : b,
  marginBottom: x = b === void 0 ? 20 : b,
  marginLeft: _ = b === void 0 ? t === "left" ? 40 : 0 : b,
  label: M,
  labelAnchor: T,
  labelArrow: N,
  labelOffset: A,
  ...$
}) {
  return p = Et(p), y = Et(y), g = Et(g), T !== void 0 && (T = ln(T, "labelAnchor", ["center", "top", "bottom"])), N = f$(N), An(
    p && !Kt(s) ? cY(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      x: m,
      ...$
    }) : null,
    Kt(c) ? null : lY(e, t, n, {
      fill: c,
      fillOpacity: u,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: l,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      x: m,
      marginTop: w,
      marginRight: v,
      marginBottom: x,
      marginLeft: _,
      ...$
    }),
    !Kt(c) && M !== null ? ca(
      [],
      a$({ fill: c, fillOpacity: u, ...$ }, function(D, F, S, I, E) {
        const O = I[e], { marginTop: C, marginRight: B, marginBottom: R, marginLeft: P } = e === "y" && E.inset || E, U = T ?? (O.bandwidth ? "center" : "top"), Y = A ?? (t === "right" ? B : P) - 3;
        return U === "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 = U, this.frameAnchor = `${U}-${t}`, this.rotate = 0), this.dy = U === "top" ? 3 - C : U === "bottom" ? R - 3 : 0, this.dx = t === "right" ? Y : -Y, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [l$(e, O, { anchor: t, label: M, labelAnchor: U, labelArrow: N })] } }
        };
      })
    ) : null
  );
}
function QA(e, t, n, {
  color: r = "currentColor",
  opacity: i = 1,
  stroke: s = r,
  strokeOpacity: o = i,
  strokeWidth: a = 1,
  fill: c = r,
  fillOpacity: u = i,
  textAnchor: l,
  textStroke: f,
  textStrokeOpacity: h,
  textStrokeWidth: d,
  tickSize: p = e === "x" ? 6 : 0,
  tickPadding: y,
  tickRotate: g,
  y: m,
  margin: b,
  marginTop: w = b === void 0 ? t === "top" ? 30 : 0 : b,
  marginRight: v = b === void 0 ? 20 : b,
  marginBottom: x = b === void 0 ? t === "bottom" ? 30 : 0 : b,
  marginLeft: _ = b === void 0 ? 20 : b,
  label: M,
  labelAnchor: T,
  labelArrow: N,
  labelOffset: A,
  ...$
}) {
  return p = Et(p), y = Et(y), g = Et(g), T !== void 0 && (T = ln(T, "labelAnchor", ["center", "left", "right"])), N = f$(N), An(
    p && !Kt(s) ? uY(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      y: m,
      ...$
    }) : null,
    Kt(c) ? null : fY(e, t, n, {
      fill: c,
      fillOpacity: u,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: l,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      y: m,
      marginTop: w,
      marginRight: v,
      marginBottom: x,
      marginLeft: _,
      ...$
    }),
    !Kt(c) && M !== null ? ca(
      [],
      a$({ fill: c, fillOpacity: u, ...$ }, function(D, F, S, I, E) {
        const O = I[e], { marginTop: C, marginRight: B, marginBottom: R, marginLeft: P } = e === "x" && E.inset || E, U = T ?? (O.bandwidth ? "center" : "right"), Y = A ?? (t === "top" ? C : R) - 3;
        return U === "center" ? (this.frameAnchor = t, this.textAnchor = void 0) : (this.frameAnchor = `${t}-${U}`, this.textAnchor = U === "right" ? "end" : "start"), this.lineAnchor = t, this.dy = t === "top" ? -Y : Y, this.dx = U === "right" ? B - 3 : U === "left" ? 3 - P : 0, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [l$(e, O, { anchor: t, label: M, labelAnchor: U, labelArrow: N })] } }
        };
      })
    ) : null
  );
}
function cY(e, t, n, {
  strokeWidth: r = 1,
  strokeLinecap: i = 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 Aa(YA, e, t, `${e}-axis tick`, n, {
    strokeWidth: r,
    strokeLinecap: i,
    strokeLinejoin: s,
    facetAnchor: o,
    frameAnchor: a,
    y: d,
    ...p,
    dx: t === "left" ? +h - xe + +l : +h + xe - f,
    anchor: "start",
    length: c,
    shape: t === "left" ? yY : mY
  });
}
function uY(e, t, n, {
  strokeWidth: r = 1,
  strokeLinecap: i = 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 Aa(VA, e, t, `${e}-axis tick`, n, {
    strokeWidth: r,
    strokeLinejoin: s,
    strokeLinecap: i,
    facetAnchor: o,
    frameAnchor: a,
    x: d,
    ...p,
    dy: t === "bottom" ? +h - xe - f : +h + xe + +l,
    anchor: "start",
    length: c,
    shape: t === "bottom" ? dY : pY
  });
}
function lY(e, t, n, {
  facetAnchor: r = t + (e === "y" ? "-empty" : ""),
  frameAnchor: i = t,
  tickSize: s,
  tickRotate: o = 0,
  tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) > 60 ? 4 * Math.cos(o * ch) : 0),
  text: c,
  textAnchor: u = Math.abs(o) > 60 ? "middle" : t === "left" ? "end" : "start",
  lineAnchor: l = o > 60 ? "top" : o < -60 ? "bottom" : "middle",
  fontVariant: f,
  inset: h = 0,
  insetLeft: d = h,
  insetRight: p = h,
  dx: y = 0,
  y: g = e === "y" ? void 0 : null,
  ...m
}) {
  return Aa(
    LA,
    e,
    t,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: r,
      frameAnchor: i,
      text: c,
      textAnchor: u,
      lineAnchor: l,
      fontVariant: f,
      rotate: o,
      y: g,
      ...m,
      dx: t === "left" ? +y - s - a + +d : +y + +s + +a - p
    },
    function(b, w, v, x, _) {
      f === void 0 && (this.fontVariant = u$(b)), c === void 0 && (_.text = c$(b, w, v, x, t));
    }
  );
}
function fY(e, t, n, {
  facetAnchor: r = t + (e === "x" ? "-empty" : ""),
  frameAnchor: i = t,
  tickSize: s,
  tickRotate: o = 0,
  tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) >= 10 ? 4 * Math.cos(o * ch) : 0),
  text: c,
  textAnchor: u = Math.abs(o) >= 10 ? o < 0 ^ t === "bottom" ? "start" : "end" : "middle",
  lineAnchor: l = Math.abs(o) >= 10 ? "middle" : t === "bottom" ? "top" : "bottom",
  fontVariant: f,
  inset: h = 0,
  insetTop: d = h,
  insetBottom: p = h,
  dy: y = 0,
  x: g = e === "x" ? void 0 : null,
  ...m
}) {
  return Aa(
    OA,
    e,
    t,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: r,
      frameAnchor: i,
      text: c === void 0 ? null : c,
      textAnchor: u,
      lineAnchor: l,
      fontVariant: f,
      rotate: o,
      x: g,
      ...m,
      dy: t === "bottom" ? +y + +s + +a - p : +y - s - a + +d
    },
    function(b, w, v, x, _) {
      f === void 0 && (this.fontVariant = u$(b)), c === void 0 && (_.text = c$(b, w, v, x, t));
    }
  );
}
function t$() {
  const [e, t] = Ki(...arguments);
  return i$("y", WA(t), e, t);
}
function e$() {
  const [e, t] = Ki(...arguments);
  return i$("fy", XA(t), e, t);
}
function n$() {
  const [e, t] = Ki(...arguments);
  return s$("x", GA(t), e, t);
}
function r$() {
  const [e, t] = Ki(...arguments);
  return s$("fx", HA(t), e, t);
}
function i$(e, t, n, {
  y: r = e === "y" ? void 0 : null,
  x: i = null,
  x1: s = t === "left" ? i : null,
  x2: o = t === "right" ? i : null,
  ...a
}) {
  return Aa(Ui, e, t, `${e}-grid`, n, { y: r, x1: s, x2: o, ...o$(a) });
}
function s$(e, t, n, {
  x: r = e === "x" ? void 0 : null,
  y: i = null,
  y1: s = t === "top" ? i : null,
  y2: o = t === "bottom" ? i : null,
  ...a
}) {
  return Aa(Pi, e, t, `${e}-grid`, n, { x: r, y1: s, y2: o, ...o$(a) });
}
function o$({
  color: e = "currentColor",
  opacity: t = 0.1,
  stroke: n = e,
  strokeOpacity: r = t,
  strokeWidth: i = 1,
  ...s
}) {
  return { stroke: n, strokeOpacity: r, strokeWidth: i, ...s };
}
function a$({
  fill: e,
  fillOpacity: t,
  fontFamily: n,
  fontSize: r,
  fontStyle: i,
  fontVariant: s,
  fontWeight: o,
  monospace: a,
  pointerEvents: c,
  shapeRendering: u,
  clip: l = !1
}, f) {
  return [, e] = Be(e), [, t] = ce(t), {
    facet: "super",
    x: null,
    y: null,
    fill: e,
    fillOpacity: t,
    fontFamily: n,
    fontSize: r,
    fontStyle: i,
    fontVariant: s,
    fontWeight: o,
    monospace: a,
    pointerEvents: c,
    shapeRendering: u,
    clip: l,
    initializer: f
  };
}
function Aa(e, t, n, r, i, s, o) {
  let a;
  function c(f, h, d, p, y, g) {
    const m = f == null && (t === "fx" || t === "fy"), { [t]: b } = p;
    if (!b)
      throw new Error(`missing scale: ${t}`);
    const w = b.domain();
    let { interval: v, ticks: x, tickFormat: _, tickSpacing: M = t === "x" ? 80 : 35 } = s;
    if (typeof x == "string" && h$(b) && (v = x, x = void 0), x === void 0 && (x = _a(v, b.type) ?? hY(b, M)), f == null) {
      if (oi(x))
        f = Ze(x);
      else if (_o(x))
        f = kp(x, ...fe(w));
      else if (b.interval) {
        let N = b.interval;
        if (b.ticks) {
          const [A, $] = fe(w), D = ($ - A) / N[gu];
          N = Nw(N, D / x) ?? N, f = kp(N, A, $);
        } else {
          f = w;
          const A = f.length;
          N = Nw(N, A / x) ?? N, N !== b.interval && (f = kp(N, ...fe(f)));
        }
        if (N === b.interval) {
          const A = Math.round(f.length / x);
          A > 1 && (f = f.filter(($, D) => D % A === 0));
        }
      } else
        b.ticks ? f = b.ticks(x) : f = w;
      if (!b.ticks && f.length && f !== w) {
        const N = new eu(w);
        f = f.filter((A) => N.has(A)), f.length || Hr(`Warning: the ${t}-axis ticks appear to not align with the scale domain, resulting in no ticks. Try different ticks?`);
      }
      t === "y" || t === "x" ? h = [si(f)] : a[t] = { scale: t, value: at };
    }
    o == null || o.call(this, b, f, x, _, a);
    const T = Object.fromEntries(
      Object.entries(a).map(([N, A]) => [N, { ...A, value: At(f, A.value) }])
    );
    return m && (h = g.filterFacets(f, T)), { data: f, facets: h, channels: T };
  }
  const u = Ke(s).initializer, l = e(i, Ke({ ...s, initializer: c }, u));
  return i == null ? (a = l.channels, l.channels = {}) : a = {}, l.ariaLabel = r, l.clip === void 0 && (l.clip = !1), l;
}
function hY(e, t) {
  const [n, r] = fe(e.range());
  return (r - n) / t;
}
function c$(e, t, n, r, i) {
  return { value: $g(e, t, n, r, i) };
}
function $g(e, t, n, r, i) {
  return typeof r == "function" ? r : r === void 0 && t && Pe(t) ? Aj(e.type, t, i) ?? qs : e.tickFormat ? e.tickFormat(typeof n == "number" ? n : null, r) : r === void 0 ? qs : typeof r == "string" ? (Pe(e.domain()) ? yu : wa)(r) : un(r);
}
function kp(e, t, n) {
  return e.range(t, e.offset(e.floor(n)));
}
const dY = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, t);
  }
}, pY = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, -t);
  }
}, yY = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(-t, 0);
  }
}, mY = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(t, 0);
  }
};
function u$(e) {
  return e.bandwidth && !e.interval ? void 0 : "tabular-nums";
}
function l$(e, t, { anchor: n, label: r = t.label, labelAnchor: i, labelArrow: s } = {}) {
  if (!(r == null || r.inferred && h$(t) && /^(date|time|year)$/i.test(r))) {
    if (r = String(r), s === "auto" && (s = (!t.bandwidth || t.interval) && !/[↑↓→←]/.test(r)), !s)
      return r;
    if (s === !0) {
      const o = oA(t);
      o && (s = /x$/.test(e) || i === "center" ? /x$/.test(e) === o < 0 ? "left" : "right" : o < 0 ? "up" : "down");
    }
    switch (s) {
      case "left":
        return `← ${r}`;
      case "right":
        return `${r} →`;
      case "up":
        return n === "right" ? `${r} ↑` : `↑ ${r}`;
      case "down":
        return n === "right" ? `${r} ↓` : `↓ ${r}`;
    }
    return r;
  }
}
function f$(e = "auto") {
  return Kt(e) ? !1 : typeof e == "boolean" ? e : ln(e, "labelArrow", ["auto", "up", "right", "down", "left"]);
}
function h$(e) {
  return Pe(e.domain());
}
function i2(e, t) {
  if (t == null)
    return t;
  const n = e(t);
  if (!n)
    throw new Error(`scale not found: ${t}`);
  return n;
}
function gY(e, { opacity: t, ...n } = {}) {
  if (!Hs(e) && !fA(e))
    throw new Error(`swatches legend requires ordinal or threshold color scale (not ${e.type})`);
  return d$(
    e,
    n,
    (r, i, s, o) => r.append("svg").attr("width", s).attr("height", o).attr("fill", i.scale).attr("fill-opacity", ce(t)[1]).append("rect").attr("width", "100%").attr("height", "100%")
  );
}
function bY(e, {
  fill: t = ((u) => (u = e.hint) == null ? void 0 : u.fill)() !== void 0 ? e.hint.fill : "none",
  fillOpacity: n = 1,
  stroke: r = ((l) => (l = e.hint) == null ? void 0 : l.stroke)() !== void 0 ? e.hint.stroke : Kt(t) ? "currentColor" : "none",
  strokeOpacity: i = 1,
  strokeWidth: s = 1.5,
  r: o = 4.5,
  ...a
} = {}, c) {
  const [f, h] = Be(t), [d, p] = Be(r), y = i2(c, f), g = i2(c, d), m = o * o * Math.PI;
  return n = ce(n)[1], i = ce(i)[1], s = ce(s)[1], d$(
    e,
    a,
    (b, w, v, x) => b.append("svg").attr("viewBox", "-8 -8 16 16").attr("width", v).attr("height", x).attr("fill", f === "color" ? (_) => y.scale(_) : h).attr("fill-opacity", n).attr("stroke", d === "color" ? (_) => g.scale(_) : p).attr("stroke-opacity", i).attr("stroke-width", s).append("path").attr("d", (_) => {
      const M = qr();
      return e.scale(_).draw(M, m), M;
    })
  );
}
function d$(e, t = {}, n) {
  let {
    columns: r,
    tickFormat: i,
    fontVariant: s = yA(e),
    // TODO label,
    swatchSize: o = 15,
    swatchWidth: a = o,
    swatchHeight: c = o,
    marginLeft: u = 0,
    className: l,
    style: f,
    width: h
  } = t;
  const d = dd(t);
  l = hg(l), i = $g(e.scale, e.domain, void 0, i);
  const p = Nt("div", d).attr(
    "class",
    `${l}-swatches ${l}-swatches-${r != null ? "columns" : "wrap"}`
  );
  let y;
  return r != null ? (y = `:where(.${l}-swatches-columns .${l}-swatch) {
  display: flex;
  align-items: center;
  break-inside: avoid;
  padding-bottom: 1px;
}
:where(.${l}-swatches-columns .${l}-swatch::before) {
  flex-shrink: 0;
}
:where(.${l}-swatches-columns .${l}-swatch-label) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}`, p.style("columns", r).selectAll().data(e.domain).enter().append("div").attr("class", `${l}-swatch`).call(n, e, a, c).call(
    (g) => g.append("div").attr("class", `${l}-swatch-label`).attr("title", i).text(i)
  )) : (y = `:where(.${l}-swatches-wrap) {
  display: flex;
  align-items: center;
  min-height: 33px;
  flex-wrap: wrap;
}
:where(.${l}-swatches-wrap .${l}-swatch) {
  display: inline-flex;
  align-items: center;
  margin-right: 1em;
}`, p.selectAll().data(e.domain).enter().append("span").attr("class", `${l}-swatch`).call(n, e, a, c).append(function() {
    return this.ownerDocument.createTextNode(i.apply(this, arguments));
  })), p.call(
    (g) => g.insert("style", "*").text(
      `:where(.${l}-swatches) {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  margin-bottom: 0.5em;
}
:where(.${l}-swatch > svg) {
  margin-right: 0.5em;
  overflow: visible;
}
${y}`
    )
  ).style("margin-left", u ? `${+u}px` : null).style("width", h === void 0 ? null : `${+h}px`).style("font-variant", se(s, "normal")).call(dg, f).node();
}
const uh = /* @__PURE__ */ new Map([
  ["symbol", bY],
  ["color", p$],
  ["opacity", _Y]
]);
function wY(e = {}) {
  for (const [t, n] of uh) {
    const r = e[t];
    if (Is(r)) {
      const i = dd(e);
      let s;
      if (t === "symbol") {
        const { fill: o, stroke: a = o === void 0 && Is(e.color) ? "color" : void 0 } = e;
        s = { fill: o, stroke: a };
      }
      return n(
        sy(t, r, s),
        Ig(i, r, e),
        (o) => Is(e[o]) ? sy(o, e[o]) : null
      );
    }
  }
  throw new Error("unknown legend type; no scale found");
}
function vY(e, t, n = {}) {
  return (r, i) => {
    if (!uh.has(r))
      throw new Error(`unknown legend type: ${r}`);
    if (r in e)
      return uh.get(r)(e[r], Ig(t, n[r], i), (s) => e[s]);
  };
}
function Ig({ className: e, ...t }, { label: n, ticks: r, tickFormat: i } = {}, s) {
  return zj(s, { className: e, ...t }, { label: n, ticks: r, tickFormat: i });
}
function p$(e, { legend: t = !0, ...n }) {
  if (t === !0 && (t = e.type === "ordinal" ? "swatches" : "ramp"), e.domain !== void 0)
    switch (`${t}`.toLowerCase()) {
      case "swatches":
        return gY(e, n);
      case "ramp":
        return zV(e, n);
      default:
        throw new Error(`unknown legend type: ${t}`);
    }
}
function _Y({ type: e, interpolate: t, ...n }, { legend: r = !0, color: i = Sn(0, 0, 0), ...s }) {
  if (!t)
    throw new Error(`${e} opacity scales are not supported`);
  if (r === !0 && (r = "ramp"), `${r}`.toLowerCase() !== "ramp")
    throw new Error(`${r} opacity legends are not supported`);
  return p$({ type: e, ...n, interpolate: xY(i) }, { legend: r, ...s });
}
function xY(e) {
  const { r: t, g: n, b: r } = Sn(e) || Sn(0, 0, 0);
  return (i) => `rgba(${t},${n},${r},${i})`;
}
function SY(e, t, n) {
  const r = [];
  for (const [i, s] of uh) {
    const o = n[i];
    if (o != null && o.legend && i in e) {
      const a = s(e[i], Ig(t, e[i], o), (c) => e[c]);
      a != null && r.push(a);
    }
  }
  return r;
}
const MY = {
  ariaLabel: "frame",
  fill: "none",
  stroke: "currentColor",
  clip: !1
}, AY = {
  ariaLabel: "frame",
  fill: null,
  stroke: "currentColor",
  strokeLinecap: "square",
  clip: !1
};
class y$ extends Xt {
  constructor(t = {}) {
    const {
      anchor: n = null,
      inset: r = 0,
      insetTop: i = r,
      insetRight: s = r,
      insetBottom: o = r,
      insetLeft: a = r,
      rx: c,
      ry: u
    } = t;
    super(cc, void 0, t, n == null ? MY : AY), this.anchor = bM(n, "anchor", ["top", "right", "bottom", "left"]), this.insetTop = Et(i), this.insetRight = Et(s), this.insetBottom = Et(o), this.insetLeft = Et(a), this.rx = Et(c), this.ry = Et(u);
  }
  render(t, n, r, i, s) {
    const { marginTop: o, marginRight: a, marginBottom: c, marginLeft: u, width: l, height: f } = i, { anchor: h, insetTop: d, insetRight: p, insetBottom: y, insetLeft: g, rx: m, ry: b } = this, w = u + g, v = l - a - p, x = o + d, _ = f - c - y;
    return Nt(h ? "svg:line" : "svg:rect", s).datum(0).call(te, this, i, s).call(Jt, this).call(pe, this, r).call(Wt, this, {}).call(
      h === "left" ? (M) => M.attr("x1", w).attr("x2", w).attr("y1", x).attr("y2", _) : h === "right" ? (M) => M.attr("x1", v).attr("x2", v).attr("y1", x).attr("y2", _) : h === "top" ? (M) => M.attr("x1", w).attr("x2", v).attr("y1", x).attr("y2", x) : h === "bottom" ? (M) => M.attr("x1", w).attr("x2", v).attr("y1", _).attr("y2", _) : (M) => M.attr("x", w).attr("y", x).attr("width", v - w).attr("height", _ - x).attr("rx", m).attr("ry", b)
    ).node();
  }
}
function Tg(e) {
  return new y$(e);
}
const Fp = {
  ariaLabel: "tip",
  fill: "var(--plot-background)",
  stroke: "currentColor"
}, $Y = /* @__PURE__ */ new Set(["geometry", "href", "src", "ariaLabel", "scales"]);
class m$ extends Xt {
  constructor(t, n = {}) {
    n.tip && (n = { ...n, tip: !1 }), n.title === void 0 && oi(t) && MM(t) && (n = { ...n, title: at });
    const {
      x: r,
      y: i,
      x1: s,
      x2: o,
      y1: a,
      y2: c,
      anchor: u,
      preferredAnchor: l = "bottom",
      monospace: f,
      fontFamily: h = f ? "ui-monospace, monospace" : void 0,
      fontSize: d,
      fontStyle: p,
      fontVariant: y,
      fontWeight: g,
      lineHeight: m = 1,
      lineWidth: b = 20,
      frameAnchor: w,
      format: v,
      textAnchor: x = "start",
      textOverflow: _,
      textPadding: M = 8,
      title: T,
      pointerSize: N = 12,
      pathFilter: A = "drop-shadow(0 3px 4px rgba(0,0,0,0.2))"
    } = n;
    super(
      t,
      {
        x: { value: s != null && o != null ? null : r, scale: "x", optional: !0 },
        // ignore midpoint
        y: { value: a != null && c != null ? null : i, scale: "y", optional: !0 },
        // ignore midpoint
        x1: { value: s, scale: "x", optional: o == null },
        y1: { value: a, scale: "y", optional: c == null },
        x2: { value: o, scale: "x", optional: s == null },
        y2: { value: c, scale: "y", optional: a == null },
        title: { value: T, optional: !0 }
        // filter: defined
      },
      n,
      Fp
    ), this.anchor = K0(u, "anchor"), this.preferredAnchor = K0(l, "preferredAnchor"), this.frameAnchor = vu(w), this.textAnchor = se(x, "middle"), this.textPadding = +M, this.pointerSize = +N, this.pathFilter = Te(A), this.lineHeight = +m, this.lineWidth = +b, this.textOverflow = DA(_), this.monospace = !!f, this.fontFamily = Te(h), this.fontSize = Et(d), this.fontStyle = Te(p), this.fontVariant = Te(y), this.fontWeight = Te(g);
    for (const $ in Fp)
      $ in this.channels && (this[$] = Fp[$]);
    this.splitLines = FA(this), this.clipLine = RA(this), this.format = { ...v };
  }
  render(t, n, r, i, s) {
    const o = this, { x: a, y: c, fx: u, fy: l } = n, { ownerSVGElement: f, document: h } = s, { anchor: d, monospace: p, lineHeight: y, lineWidth: g } = this, { textPadding: m, pointerSize: b, pathFilter: w } = this, { marginTop: v, marginLeft: x } = i, { x1: _, y1: M, x2: T, y2: N, x: A = _ ?? T, y: $ = M ?? N } = r, D = u ? u(t.fx) - x : 0, F = l ? l(t.fy) - v : 0, [S, I] = Ar(this, i), E = dA(r, S), O = pA(r, I), C = p ? Sg : xg, B = C(Ro);
    let R, P;
    "title" in r ? (R = r.channels, P = DY) : (R = NY.call(this, r, n), P = OY);
    const U = Nt("svg:g", s).call(te, this, i, s).call(kA, this).call(Wt, this, { x: A && a, y: $ && c }).call(
      (Z) => Z.selectAll().data(t).enter().append("g").attr("transform", (H) => `translate(${Math.round(E(H))},${Math.round(O(H))})`).call(Jt, this).call((H) => H.append("path").attr("filter", w)).call(
        (H) => H.append("text").each(function(q) {
          const W = Vt(this);
          this.setAttribute("fill", "currentColor"), this.setAttribute("fill-opacity", 1), this.setAttribute("stroke", "none");
          const j = P.call(o, q, t, R, n, r);
          if (typeof j == "string")
            for (const X of o.splitLines(j))
              Y(W, { value: o.clipLine(X) });
          else {
            const X = /* @__PURE__ */ new Set();
            for (const K of j) {
              const { label: z = "" } = K;
              z && X.has(z) || (X.add(z), Y(W, K));
            }
          }
        })
      )
    );
    function Y(Z, { label: H, value: q, color: W, opacity: j }) {
      H ?? (H = ""), q ?? (q = "");
      const X = W != null || j != null;
      let K, z = g * 100;
      const [wt] = ua(H, z, C, B);
      if (wt >= 0)
        H = H.slice(0, wt).trimEnd() + Ro, K = q.trim(), q = "";
      else {
        (H || !q && !X) && (q = " " + q);
        const [It] = ua(q, z - C(H), C, B);
        It >= 0 && (K = q.trim(), q = q.slice(0, It).trimEnd() + Ro);
      }
      const Q = Z.append("tspan").attr("x", 0).attr("dy", `${y}em`).text("​");
      H && Q.append("tspan").attr("font-weight", "bold").text(H), q && Q.append(() => h.createTextNode(q)), X && Q.append("tspan").text(" ■").attr("fill", W).attr("fill-opacity", j).style("user-select", "none"), K && Q.append("title").text(K);
    }
    function G() {
      const { width: Z, height: H } = i.facet ?? i;
      U.selectChildren().each(function(q) {
        let { x: W, width: j, height: X } = this.getBBox();
        j = Math.round(j), X = Math.round(X);
        let K = d;
        if (K === void 0) {
          const Q = E(q) + D, It = O(q) + F, Tt = Q + j + b + m * 2 < Z, J = Q - j - b - m * 2 > 0, kt = It + X + b + m * 2 < H, Qe = It - X - b - m * 2 > 0;
          K = Tt && J ? kt && Qe ? o.preferredAnchor : Qe ? "bottom" : "top" : kt && Qe ? Tt ? "left" : "right" : (Tt || J) && (kt || Qe) ? `${Qe ? "bottom" : "top"}-${Tt ? "left" : "right"}` : o.preferredAnchor;
        }
        const z = this.firstChild, wt = this.lastChild;
        if (z.setAttribute("d", EY(K, b, m, j, X)), W)
          for (const Q of wt.childNodes)
            Q.setAttribute("x", -W);
        wt.setAttribute("y", `${+IY(K, wt.childNodes.length, y).toFixed(6)}em`), wt.setAttribute("transform", `translate(${TY(K, b, m, j, X)})`);
      }), U.attr("visibility", null);
    }
    return t.length && (U.attr("visibility", "hidden"), f.isConnected ? Promise.resolve().then(G) : typeof requestAnimationFrame < "u" && requestAnimationFrame(G)), U.node();
  }
}
function g$(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Wn(t, n)), new m$(e, { ...r, x: t, y: n });
}
function IY(e, t, n) {
  return /^top(?:-|$)/.test(e) ? 0.94 - n : -0.29 - t * n;
}
function TY(e, t, n, r, i) {
  switch (e) {
    case "middle":
      return [-r / 2, i / 2];
    case "top-left":
      return [n, t + n];
    case "top":
      return [-r / 2, t / 2 + n];
    case "top-right":
      return [-r - n, t + n];
    case "right":
      return [-t / 2 - r - n, i / 2];
    case "bottom-left":
      return [n, -t - n];
    case "bottom":
      return [-r / 2, -t / 2 - n];
    case "bottom-right":
      return [-r - n, -t - n];
    case "left":
      return [n + t / 2, i / 2];
  }
}
function EY(e, t, n, r, i) {
  const s = r + n * 2, o = i + n * 2;
  switch (e) {
    case "middle":
      return `M${-s / 2},${-o / 2}h${s}v${o}h${-s}z`;
    case "top-left":
      return `M0,0l${t},${t}h${s - t}v${o}h${-s}z`;
    case "top":
      return `M0,0l${t / 2},${t / 2}h${(s - t) / 2}v${o}h${-s}v${-o}h${(s - t) / 2}z`;
    case "top-right":
      return `M0,0l${-t},${t}h${t - s}v${o}h${s}z`;
    case "right":
      return `M0,0l${-t / 2},${-t / 2}v${t / 2 - o / 2}h${-s}v${o}h${s}v${t / 2 - o / 2}z`;
    case "bottom-left":
      return `M0,0l${t},${-t}h${s - t}v${-o}h${-s}z`;
    case "bottom":
      return `M0,0l${t / 2},${-t / 2}h${(s - t) / 2}v${-o}h${-s}v${o}h${(s - t) / 2}z`;
    case "bottom-right":
      return `M0,0l${-t},${-t}h${t - s}v${-o}h${s}z`;
    case "left":
      return `M0,0l${t / 2},${-t / 2}v${t / 2 - o / 2}h${s}v${o}h${-s}v${t / 2 - o / 2}z`;
  }
}
function NY({ channels: e }, t) {
  var i, s;
  const n = {};
  let r = this.format;
  r = s2(r, e, "x"), r = s2(r, e, "y"), this.format = r;
  for (const o in r) {
    const a = r[o];
    if (!(a === null || a === !1))
      if (o === "fx" || o === "fy")
        n[o] = !0;
      else {
        const c = ty(e, o);
        c && (n[o] = c);
      }
  }
  for (const o in e) {
    if (o in n || o in r || $Y.has(o))
      continue;
    const a = ty(e, o);
    a && (n[o] = a);
  }
  this.facet && (t.fx && !("fx" in r) && (n.fx = !0), t.fy && !("fy" in r) && (n.fy = !0));
  for (const o in n) {
    const a = this.format[o];
    if (typeof a == "string") {
      const c = ((i = n[o]) == null ? void 0 : i.value) ?? ((s = t[o]) == null ? void 0 : s.domain()) ?? [];
      this.format[o] = (Pe(c) ? yu : wa)(a);
    } else if (a === void 0 || a === !0) {
      const c = t[o];
      this.format[o] = c != null && c.bandwidth ? $g(c, c.domain()) : qs;
    }
  }
  return n;
}
function s2(e, t, n) {
  if (!(n in e))
    return e;
  const r = `${n}1`, i = `${n}2`;
  if ((r in e || !(r in t)) && (i in e || !(i in t)))
    return e;
  const s = Object.entries(e), o = e[n];
  return s.splice(s.findIndex(([a]) => a === n) + 1, 0, [r, o], [i, o]), Object.fromEntries(s);
}
function DY(e, t, { title: n }) {
  return qs(n.value[e], e);
}
function* OY(e, t, n, r, i) {
  for (const s in n) {
    if (s === "fx" || s === "fy") {
      yield {
        label: lh(r, n, s),
        value: this.format[s](t[s], e)
      };
      continue;
    }
    if (s === "x1" && "x2" in n || s === "y1" && "y2" in n)
      continue;
    const o = n[s];
    if (s === "x2" && "x1" in n)
      yield {
        label: a2(r, n, "x"),
        value: o2(this.format.x2, n.x1, o, e)
      };
    else if (s === "y2" && "y1" in n)
      yield {
        label: a2(r, n, "y"),
        value: o2(this.format.y2, n.y1, o, e)
      };
    else {
      const a = o.value[e], c = o.scale;
      if (!Re(a) && c == null)
        continue;
      yield {
        label: lh(r, n, s),
        value: this.format[s](a, e),
        color: c === "color" ? i[s][e] : null,
        opacity: c === "opacity" ? i[s][e] : null
      };
    }
  }
}
function o2(e, t, n, r) {
  var i;
  return (i = n.hint) != null && i.length ? `${e(n.value[r] - t.value[r], r)}` : `${e(t.value[r], r)}–${e(n.value[r], r)}`;
}
function a2(e, t, n) {
  const r = lh(e, t, `${n}1`, n), i = lh(e, t, `${n}2`, n);
  return r === i ? r : `${r}–${i}`;
}
function lh(e, t, n, r = n) {
  const i = t[n], s = e[(i == null ? void 0 : i.scale) ?? n];
  return String((s == null ? void 0 : s.label) ?? (i == null ? void 0 : i.label) ?? r);
}
function Eg(e = {}) {
  var B;
  const { facet: t, style: n, title: r, subtitle: i, caption: s, ariaLabel: o, ariaDescription: a } = e, c = hg(e.className), u = e.marks === void 0 ? [] : u2(e.marks);
  u.push(...UY(u));
  const l = BY(t, e), f = /* @__PURE__ */ new Map();
  for (const R of u) {
    const P = l2(R, l, e);
    P && f.set(R, P);
  }
  const h = /* @__PURE__ */ new Map();
  l && ja(h, [l], e), ja(h, f, e);
  const d = u2(zY(u, h, e));
  for (const R of d) {
    const P = l2(R, l, e);
    P && f.set(R, P);
  }
  u.unshift(...d);
  let p = IV(h, e);
  if (p !== void 0) {
    const R = l ? Dp(p, l) : void 0;
    for (const U of u) {
      if (U.facet === null || U.facet === "super")
        continue;
      const Y = f.get(U);
      Y !== void 0 && (Y.facetsIndex = U.fx != null || U.fy != null ? Dp(p, Y) : R);
    }
    const P = /* @__PURE__ */ new Set();
    for (const { facetsIndex: U } of f.values())
      U == null || U.forEach((Y, G) => {
        (Y == null ? void 0 : Y.length) > 0 && P.add(G);
      });
    p.forEach(
      0 < P.size && P.size < p.length ? (U, Y) => U.empty = !P.has(Y) : (U) => U.empty = !1
    );
    for (const U of u)
      if (U.facet === "exclude") {
        const Y = f.get(U);
        Y !== void 0 && (Y.facetsIndex = NV(Y.facetsIndex));
      }
  }
  for (const R of ne.keys())
    Is(e[R]) && R !== "fx" && R !== "fy" && h.set(R, []);
  const y = /* @__PURE__ */ new Map();
  for (const R of u) {
    if (y.has(R))
      throw new Error("duplicate mark; each mark must be unique");
    const { facetsIndex: P, channels: U } = f.get(R) ?? {}, { data: Y, facets: G, channels: Z } = R.initialize(P, U, e);
    Ng(Z, e), y.set(R, { data: Y, facets: G, channels: Z });
  }
  const g = iy(ja(h, y, e), e), m = AV(g, u, e);
  bV(g, m);
  const b = Vw(g), { fx: w, fy: v } = b, x = w || v ? aA(g, m) : m, _ = w || v ? GY(b, m) : m, M = dd(e), T = M.document, N = Bh("svg").call(T.documentElement);
  let A = N;
  M.ownerSVGElement = N, M.className = c, M.projection = Dq(e, x), M.filterFacets = (R, P) => Dp(p, { channels: P, groups: bg(R, P) }), M.getMarkState = (R) => {
    const P = y.get(R), U = f.get(R);
    return { ...P, channels: { ...P.channels, ...U == null ? void 0 : U.channels } };
  }, M.dispatchValue = (R) => {
    A.value !== R && (A.value = R, A.dispatchEvent(new Event("input", { bubbles: !0 })));
  };
  const $ = /* @__PURE__ */ new Set();
  for (const [R, P] of y)
    if (R.initializer != null) {
      const U = R.facet === "super" ? _ : x, Y = R.initializer(P.data, P.facets, P.channels, b, U, M);
      if (Y.data !== void 0 && (P.data = Y.data), Y.facets !== void 0 && (P.facets = Y.facets), Y.channels !== void 0) {
        const { fx: G, fy: Z, ...H } = Y.channels;
        CY(H), Object.assign(P.channels, H);
        for (const q of Object.values(H)) {
          const { scale: W } = q;
          W != null && !qj(ne.get(W)) && (b$(q, e), $.add(W));
        }
        (G != null || Z != null) && f.set(R, !0);
      }
    }
  if ($.size) {
    const R = /* @__PURE__ */ new Map();
    ja(R, y, e, (G) => $.has(G)), ja(h, y, e, (G) => $.has(G));
    const P = XY(iy(R, e), g), { scales: U, ...Y } = Vw(P);
    Object.assign(g, P), Object.assign(b, Y), Object.assign(b.scales, U);
  }
  let D, F;
  p !== void 0 && (D = { x: w == null ? void 0 : w.domain(), y: v == null ? void 0 : v.domain() }, p = TV(p, D), F = EV(w, v, m));
  for (const [R, P] of y)
    P.values = R.scale(P.channels, b, M);
  const { width: S, height: I } = m;
  Vt(N).attr("class", c).attr("fill", "currentColor").attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("text-anchor", "middle").attr("width", S).attr("height", I).attr("viewBox", `0 0 ${S} ${I}`).attr("aria-label", o).attr("aria-description", a).call(
    (R) => (
      // Warning: if you edit this, change defaultClassName.
      R.append("style").text(
        `:where(.${c}) {
  --plot-background: white;
  display: block;
  height: auto;
  height: intrinsic;
  max-width: 100%;
}
:where(.${c} text),
:where(.${c} tspan) {
  white-space: pre;
}`
      )
    )
  ).call(dg, n);
  for (const R of u) {
    const { channels: P, values: U, facets: Y } = y.get(R);
    if (p === void 0 || R.facet === "super") {
      let G = null;
      if (Y && (G = Y[0], G = R.filter(G, P, U), G.length === 0))
        continue;
      const Z = R.render(G, b, U, _, M);
      if (Z == null)
        continue;
      N.appendChild(Z);
    } else {
      let G;
      for (const Z of p) {
        if (!(((B = R.facetAnchor) == null ? void 0 : B.call(R, p, D, Z)) ?? !Z.empty))
          continue;
        let H = null;
        if (Y) {
          const W = f.has(R);
          if (H = Y[W ? Z.i : 0], H = R.filter(H, P, U), H.length === 0)
            continue;
          !W && H === Y[0] && (H = Ts(H)), H.fx = Z.x, H.fy = Z.y, H.fi = Z.i;
        }
        const q = R.render(H, b, U, x, M);
        if (q != null) {
          (G ?? (G = Vt(N).append("g"))).append(() => q).datum(Z);
          for (const W of ["aria-label", "aria-description", "aria-hidden", "transform"])
            q.hasAttribute(W) && (G.attr(W, q.getAttribute(W)), q.removeAttribute(W));
        }
      }
      G == null || G.selectChildren().attr("transform", F);
    }
  }
  const E = SY(g, M, e), { figure: O = r != null || i != null || s != null || E.length > 0 } = e;
  O && (A = T.createElement("figure"), A.className = `${c}-figure`, A.style.maxWidth = "initial", r != null && A.append(c2(T, r, "h2")), i != null && A.append(c2(T, i, "h3")), A.append(...E, N), s != null && A.append(LY(T, s))), A.scale = MV(b.scales), A.legend = vY(g, M, e);
  const C = _q();
  return C > 0 && Vt(N).append("text").attr("x", S).attr("y", 20).attr("dy", "-1em").attr("text-anchor", "end").attr("font-family", "initial").text("⚠️").append("title").text(`${C.toLocaleString("en-US")} warning${C === 1 ? "" : "s"}. Please check the console.`), A;
}
function c2(e, t, n) {
  if (t.ownerDocument)
    return t;
  const r = e.createElement(n);
  return r.append(t), r;
}
function LY(e, t) {
  const n = e.createElement("figcaption");
  return n.append(t), n;
}
function kY({ marks: e = [], ...t } = {}) {
  return Eg({ ...t, marks: [...e, this] });
}
Xt.prototype.plot = kY;
function u2(e) {
  return e.flat(1 / 0).filter((t) => t != null).map(FY);
}
function FY(e) {
  return typeof e.render == "function" ? e : new RY(e);
}
class RY extends Xt {
  constructor(t) {
    if (typeof t != "function")
      throw new TypeError("invalid mark; missing render function");
    super(), this.render = t;
  }
  render() {
  }
}
function Ng(e, t) {
  for (const n in e)
    b$(e[n], t);
  return e;
}
function b$(e, t) {
  const { scale: n, transform: r = !0 } = e;
  if (n == null || !r)
    return;
  const {
    type: i,
    percent: s,
    interval: o,
    transform: a = s ? (c) => c * 100 : SM(o, i)
  } = t[n] ?? {};
  a != null && (e.value = Gt(e.value, a), e.transform = !1);
}
function CY(e) {
  for (const t in e)
    CM(t, e[t]);
}
function ja(e, t, n, r = Ej) {
  var i, s;
  for (const { channels: o } of t.values())
    for (const a in o) {
      const c = o[a], { scale: u } = c;
      if (u != null && r(u))
        if (u === "projection") {
          if (!kq(n)) {
            const l = ((i = n.x) == null ? void 0 : i.domain) === void 0, f = ((s = n.y) == null ? void 0 : s.domain) === void 0;
            if (l || f) {
              const [h, d] = Rq(c);
              l && Rp(e, "x", h), f && Rp(e, "y", d);
            }
          }
        } else
          Rp(e, u, c);
    }
  return e;
}
function Rp(e, t, n) {
  const r = e.get(t);
  r !== void 0 ? r.push(n) : e.set(t, [n]);
}
function BY(e, t) {
  if (e == null)
    return;
  const { x: n, y: r } = e;
  if (n == null && r == null)
    return;
  const i = Ze(e.data);
  if (i == null)
    throw new Error("missing facet data");
  const s = {};
  n != null && (s.fx = Uc(i, { value: n, scale: "fx" })), r != null && (s.fy = Uc(i, { value: r, scale: "fy" })), Ng(s, t);
  const o = bg(i, s);
  return { channels: s, groups: o, data: e.data };
}
function l2(e, t, n) {
  var c;
  if (e.facet === null || e.facet === "super")
    return;
  const { fx: r, fy: i } = e;
  if (r != null || i != null) {
    const u = Ze(e.data ?? r ?? i);
    if (u === void 0)
      throw new Error(`missing facet data in ${e.ariaLabel}`);
    if (u === null)
      return;
    const l = {};
    return r != null && (l.fx = Uc(u, { value: r, scale: "fx" })), i != null && (l.fy = Uc(u, { value: i, scale: "fy" })), Ng(l, n), { channels: l, groups: bg(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 };
  a.length > 0 && (o.size > 1 || o.size === 1 && s.fx && s.fy && [...o][0][1].size > 1) && ((c = Ze(e.data)) == null ? void 0 : c.length) === a.length && Hr(
    `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 PY(e, t = {}) {
  return Ke({ ...t, x: null, y: null }, (n, r, i, s, o, a) => a.getMarkState(e));
}
function UY(e) {
  const t = [];
  for (const n of e) {
    let r = n.tip;
    if (r) {
      r === !0 ? r = {} : typeof r == "string" && (r = { pointer: r });
      let { pointer: i, preferredAnchor: s } = r;
      i = /^x$/i.test(i) ? _g : /^y$/i.test(i) ? ah : vg, r = i(PY(n, r)), r.title = null, s === void 0 && (r.preferredAnchor = i === ah ? "left" : "bottom");
      const o = g$(n.data, r);
      o.facet = n.facet, o.facetAnchor = n.facetAnchor, t.push(o);
    }
  }
  return t;
}
function zY(e, t, n) {
  let {
    projection: r,
    x: i = {},
    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 } = i,
    y: { axis: y = c, grid: g = y === null ? null : u } = s,
    fx: { axis: m = f, grid: b = m === null ? null : h } = o,
    fy: { axis: w = f, grid: v = w === null ? null : h } = a
  } = n;
  (r || !Is(i) && !f2("x", e)) && (d = p = null), (r || !Is(s) && !f2("y", e)) && (y = g = null), t.has("fx") || (m = b = null), t.has("fy") || (w = v = null), d === void 0 && (d = !al(e, "x")), y === void 0 && (y = !al(e, "y")), m === void 0 && (m = !al(e, "fx")), w === void 0 && (w = !al(e, "fy")), d === !0 && (d = "bottom"), y === !0 && (y = "left"), m === !0 && (m = d === "top" || d === null ? "bottom" : "top"), w === !0 && (w = y === "right" || y === null ? "left" : "right");
  const x = [];
  return ol(x, v, e$, a), sl(x, w, JA, "right", "left", l, a), ol(x, b, r$, o), sl(x, m, ZA, "top", "bottom", l, o), ol(x, g, t$, s), sl(x, y, Mg, "left", "right", n, s), ol(x, p, n$, i), sl(x, d, Ag, "bottom", "top", n, i), x;
}
function sl(e, t, n, r, i, s, o) {
  if (!t)
    return;
  const a = jY(t);
  o = qY(a ? r : t, s, o);
  const { line: c } = o;
  (n === Mg || n === Ag) && c && !oa(c) && e.push(Tg(VY(o))), e.push(n(o)), a && e.push(n({ ...o, anchor: i, label: null }));
}
function ol(e, t, n, r) {
  !t || oa(t) || e.push(n(YY(t, r)));
}
function jY(e) {
  return /^\s*both\s*$/i.test(e);
}
function qY(e, t, {
  line: n = t.line,
  ticks: r,
  tickSize: i,
  tickSpacing: s,
  tickPadding: o,
  tickFormat: a,
  tickRotate: c,
  fontVariant: u,
  ariaLabel: l,
  ariaDescription: f,
  label: h = t.label,
  labelAnchor: d,
  labelArrow: p = t.labelArrow,
  labelOffset: y
}) {
  return {
    anchor: e,
    line: n,
    ticks: r,
    tickSize: i,
    tickSpacing: s,
    tickPadding: o,
    tickFormat: a,
    tickRotate: c,
    fontVariant: u,
    ariaLabel: l,
    ariaDescription: f,
    label: h,
    labelAnchor: d,
    labelArrow: p,
    labelOffset: y
  };
}
function VY(e) {
  const { anchor: t, line: n } = e;
  return { anchor: t, facetAnchor: t + "-empty", stroke: n === !0 ? void 0 : n };
}
function YY(e, {
  stroke: t = wu(e) ? e : void 0,
  ticks: n = WY(e) ? e : void 0,
  tickSpacing: r,
  ariaLabel: i,
  ariaDescription: s
}) {
  return {
    stroke: t,
    ticks: n,
    tickSpacing: r,
    ariaLabel: i,
    ariaDescription: s
  };
}
function WY(e) {
  switch (typeof e) {
    case "number":
      return !0;
    case "string":
      return !wu(e);
  }
  return oi(e) || typeof (e == null ? void 0 : e.range) == "function";
}
function al(e, t) {
  const n = `${t}-axis `;
  return e.some((r) => {
    var i;
    return (i = r.ariaLabel) == null ? void 0 : i.startsWith(n);
  });
}
function f2(e, t) {
  for (const n of t)
    for (const r in n.channels) {
      const { scale: i } = n.channels[r];
      if (i === e || i === "projection")
        return !0;
    }
  return !1;
}
function XY(e, t) {
  for (const n in e) {
    const r = e[n], i = t[n];
    r.label === void 0 && i && (r.label = i.label);
  }
  return e;
}
function GY({ fx: e, fy: t }, n) {
  const { marginTop: r, marginRight: i, marginBottom: s, marginLeft: o, width: a, height: c } = gg(n), u = e && h2(e), l = t && h2(t);
  return {
    marginTop: t ? l[0] : r,
    marginRight: e ? a - u[1] : i,
    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 h2(e) {
  const t = e.domain();
  let n = e(t[0]), r = e(t[t.length - 1]);
  return r < n && ([n, r] = [r, n]), [n, r + e.bandwidth()];
}
const HY = /* @__PURE__ */ new Map([
  ["basis", Jz],
  ["basis-closed", Zz],
  ["basis-open", Kz],
  ["bundle", Qz],
  ["bump-x", Pz],
  ["bump-y", Uz],
  ["cardinal", tj],
  ["cardinal-closed", ej],
  ["cardinal-open", nj],
  ["catmull-rom", rj],
  ["catmull-rom-closed", ij],
  ["catmull-rom-open", sj],
  ["linear", mu],
  ["linear-closed", oj],
  ["monotone-x", aj],
  ["monotone-y", cj],
  ["natural", uj],
  ["step", lj],
  ["step-after", hj],
  ["step-before", fj]
]);
function Dg(e = mu, t) {
  if (typeof e == "function")
    return e;
  const n = HY.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 w$(e = la, t) {
  return typeof e != "function" && `${e}`.toLowerCase() === "auto" ? la : Dg(e, t);
}
function la(e) {
  return mu(e);
}
function vi(e = { y: "count" }, t = {}) {
  [e, t] = Fg(e, t);
  const { x: n, y: r } = t;
  return kg(fh(n, t, at), null, null, r, e, Iu(t));
}
function _i(e = { x: "count" }, t = {}) {
  [e, t] = Fg(e, t);
  const { x: n, y: r } = t;
  return kg(null, fh(r, t, at), n, null, e, Tu(t));
}
function us(e = { fill: "count" }, t = {}) {
  [e, t] = Fg(e, t);
  const { x: n, y: r } = JY(t);
  return kg(n, r, null, null, e, Iu(Tu(t)));
}
function v$(e, t, n = {}) {
  if ((n == null ? void 0 : n.interval) == null)
    return n;
  const { reduce: r = cg } = n, i = { filter: null };
  return n[t] != null && (i[t] = r), n[`${t}1`] != null && (i[`${t}1`] = r), n[`${t}2`] != null && (i[`${t}2`] = r), e(i, n);
}
function Og(e = {}) {
  return v$(vi, "y", Js(e, "x"));
}
function Lg(e = {}) {
  return v$(_i, "x", Js(e, "y"));
}
function kg(e, t, n, r, {
  data: i = ag,
  // TODO avoid materializing when unused?
  filter: s = ih,
  // return only non-empty bins by default
  sort: o,
  reverse: a,
  ...c
  // output channel definitions
} = {}, u = {}) {
  e = d2(e), t = d2(t), c = ZY(c, u), i = M$(i, at), o = o == null ? void 0 : x$("sort", o, u), s = s == null ? void 0 : S$("filter", s, u), n != null && Mi(c, "x", "x1", "x2") && (n = null), r != null && Mi(c, "y", "y1", "y2") && (r = null);
  const [l, f] = qe(e), [h, d] = qe(e), [p, y] = qe(t), [g, m] = qe(t), [b, w] = n != null ? [n, "x"] : r != null ? [r, "y"] : [], [v, x] = qe(b), {
    x: _,
    y: M,
    z: T,
    fill: N,
    stroke: A,
    x1: $,
    x2: D,
    // consumed if x is an output
    y1: F,
    y2: S,
    // consumed if y is an output
    domain: I,
    cumulative: E,
    thresholds: O,
    interval: C,
    ...B
  } = u, [R, P] = qe(T), [U] = Be(N), [Y] = Be(A), [G, Z] = qe(U), [H, q] = qe(Y);
  return {
    ..."z" in u && { z: R || T },
    ..."fill" in u && { fill: G || N },
    ..."stroke" in u && { stroke: H || A },
    ...Mr(B, (W, j, X) => {
      const K = rh(At(W, b), X == null ? void 0 : X[w]), z = At(W, T), wt = At(W, U), Q = At(W, Y), It = og(c, { z, fill: wt, stroke: Q }), Tt = [], J = [], kt = K && x([]), Qe = z && P([]), Xn = wt && Z([]), hN = Q && q([]), w1 = e && f([]), dN = e && d([]), v1 = t && y([]), pN = t && m([]), yN = tW(e, t, W);
      let mN = 0;
      for (const Ks of c)
        Ks.initialize(W);
      o && o.initialize(W), s && s.initialize(W);
      for (const Ks of j) {
        const _1 = [];
        for (const Da of c)
          Da.scope("facet", Ks);
        o && o.scope("facet", Ks), s && s.scope("facet", Ks);
        for (const [Da, gN] of Fo(Ks, It))
          for (const [bN, ku] of Fo(gN, K))
            for (const [Gn, ns] of yN(ku))
              if (!(s && !s.reduce(Gn, ns))) {
                _1.push(mN++), J.push(i.reduceIndex(Gn, W, ns)), K && kt.push(bN), z && Qe.push(It === z ? Da : z[(Gn.length > 0 ? Gn : ku)[0]]), wt && Xn.push(It === wt ? Da : wt[(Gn.length > 0 ? Gn : ku)[0]]), Q && hN.push(It === Q ? Da : Q[(Gn.length > 0 ? Gn : ku)[0]]), w1 && (w1.push(ns.x1), dN.push(ns.x2)), v1 && (v1.push(ns.y1), pN.push(ns.y2));
                for (const wN of c)
                  wN.reduce(Gn, ns);
                o && o.reduce(Gn);
              }
        Tt.push(_1);
      }
      return FM(Tt, o, a), { data: J, facets: Tt };
    }),
    ...!Mi(c, "x") && (l ? { x1: l, x2: h, x: nh(l, h) } : { x: _, x1: $, x2: D }),
    ...!Mi(c, "y") && (p ? { y1: p, y2: g, y: nh(p, g) } : { y: M, y1: F, y2: S }),
    ...v && { [w]: v },
    ...Object.fromEntries(c.map(({ name: W, output: j }) => [W, j]))
  };
}
function Fg({ cumulative: e, domain: t, thresholds: n, interval: r, ...i }, s) {
  return [i, { cumulative: e, domain: t, thresholds: n, interval: r, ...s }];
}
function fh(e, { cumulative: t, domain: n, thresholds: r, interval: i }, s) {
  return e = { ...xa(e) }, e.domain === void 0 && (e.domain = n), e.cumulative === void 0 && (e.cumulative = t), e.thresholds === void 0 && (e.thresholds = r), e.interval === void 0 && (e.interval = i), e.value === void 0 && (e.value = s), e.thresholds = _$(e.thresholds, e.interval), e;
}
function JY(e) {
  let { x: t, y: n } = e;
  return t = fh(t, e), n = fh(n, e), [t.value, n.value] = Wn(t.value, n.value), { x: t, y: n };
}
function d2(e) {
  if (e == null)
    return;
  const { value: t, cumulative: n, domain: r = fe, thresholds: i } = e, s = (o) => {
    let a = At(o, t), c;
    if (Pe(a) || QY(i)) {
      a = Gt(a, gM, Float64Array);
      let [l, f] = typeof r == "function" ? r(a) : r, h = typeof i == "function" && !_o(i) ? i(a, l, f) : i;
      typeof h == "number" && (h = m3(l, f, h)), _o(h) && (r === fe && (l = h.floor(l), f = h.offset(h.floor(f))), h = h.range(l, h.offset(f))), c = h;
    } else {
      a = We(a);
      let [l, f] = typeof r == "function" ? r(a) : r, h = typeof i == "function" && !_o(i) ? i(a, l, f) : i;
      if (typeof h == "number")
        if (r === fe) {
          let d = Ac(l, f, h);
          if (isFinite(d))
            if (d > 0) {
              let p = Math.round(l / d), y = Math.round(f / d);
              p * d <= l || --p, y * d > f || ++y;
              let g = y - p + 1;
              h = new Float64Array(g);
              for (let m = 0; m < g; ++m)
                h[m] = (p + m) * d;
            } else if (d < 0) {
              d = -d;
              let p = Math.round(l * d), y = Math.round(f * d);
              p / d <= l || --p, y / d > f || ++y;
              let g = y - p + 1;
              h = new Float64Array(g);
              for (let m = 0; m < g; ++m)
                h[m] = (p + m) / d;
            } else
              h = [l];
          else
            h = [l];
        } else
          h = ki(l, f, h);
      else
        _o(h) && (r === fe && (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 ? nW : n > 0 ? eW : Rg)(u, c, a), u;
  };
  return s.label = Sr(t), s;
}
function _$(e, t, n = p2) {
  if (e === void 0)
    return t === void 0 ? n : _a(t);
  if (typeof e == "string") {
    switch (e.toLowerCase()) {
      case "freedman-diaconis":
        return $L;
      case "scott":
        return wx;
      case "sturges":
        return cm;
      case "auto":
        return p2;
    }
    return Vm(e);
  }
  return e;
}
function ZY(e, t) {
  return NM(e, t, x$);
}
function x$(e, t, n) {
  return ig(e, t, n, S$);
}
function S$(e, t, n) {
  return sg(e, t, n, M$);
}
function M$(e, t) {
  return hd(e, t, KY);
}
function KY(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return rW;
    case "x1":
      return sW;
    case "x2":
      return oW;
    case "y":
      return iW;
    case "y1":
      return aW;
    case "y2":
      return cW;
  }
  throw new Error(`invalid bin reduce: ${e}`);
}
function p2(e, t, n) {
  return Math.min(200, wx(e, t, n));
}
function QY(e) {
  return Lj(e) || oi(e) && Pe(e);
}
function tW(e, t, n) {
  const r = e == null ? void 0 : e(n), i = t == null ? void 0 : t(n);
  return r && i ? function* (s) {
    const o = r.bin(s);
    for (const [a, [c, u]] of r.entries()) {
      const l = i.bin(o[a]);
      for (const [f, [h, d]] of i.entries())
        yield [l[f], { data: n, x1: c, y1: h, x2: u, y2: d }];
    }
  } : r ? function* (s) {
    const o = r.bin(s);
    for (const [a, [c, u]] of r.entries())
      yield [o[a], { data: n, x1: c, x2: u }];
  } : function* (s) {
    const o = i.bin(s);
    for (const [a, [c, u]] of i.entries())
      yield [o[a], { data: n, y1: c, y2: u }];
  };
}
function Rg(e, t, n) {
  return t = We(t), (r) => {
    var s;
    const i = e.map(() => []);
    for (const o of r)
      (s = i[Lh(t, n[o]) - 1]) == null || s.push(o);
    return i;
  };
}
function eW(e, t, n) {
  const r = Rg(e, t, n);
  return (i) => {
    const s = r(i);
    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 nW(e, t, n) {
  const r = Rg(e, t, n);
  return (i) => {
    const s = r(i);
    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 A$(e, t) {
  const n = (+e + +t) / 2;
  return e instanceof Date ? new Date(n) : n;
}
const rW = {
  reduceIndex(e, t, { x1: n, x2: r }) {
    return A$(n, r);
  }
}, iW = {
  reduceIndex(e, t, { y1: n, y2: r }) {
    return A$(n, r);
  }
}, sW = {
  reduceIndex(e, t, { x1: n }) {
    return n;
  }
}, oW = {
  reduceIndex(e, t, { x2: n }) {
    return n;
  }
}, aW = {
  reduceIndex(e, t, { y1: n }) {
    return n;
  }
}, cW = {
  reduceIndex(e, t, { y2: n }) {
    return n;
  }
};
function Cg(e = {}) {
  return wM(e) ? e : { ...e, x: at };
}
function Bg(e = {}) {
  return vM(e) ? e : { ...e, y: at };
}
function uW(e, t) {
  if (t.length === 1)
    return { data: e, facets: t };
  const n = e.length, r = new Uint8Array(n);
  let i = 0;
  for (const a of t)
    for (const c of a)
      r[c] && ++i, r[c] = 1;
  if (i === 0)
    return { data: e, facets: t };
  e = Cc(e);
  const s = e[yM] = new Uint32Array(n + i);
  t = t.map((a) => Cc(a, Uint32Array));
  let o = n;
  r.fill(0);
  for (const a of t)
    for (let c = 0, u = a.length; c < u; ++c) {
      const l = a[c];
      r[l] ? (a[c] = o, e[o] = e[l], s[o] = l, ++o) : s[l] = l, r[l] = 1;
    }
  return { data: e, facets: t };
}
function $$(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = $a(e));
  const { y1: n, y: r = n, x: i, ...s } = t, [o, a, c, u] = Ia(r, i, "y", "x", e, s);
  return { ...o, y1: n, y: a, x1: c, x2: u, x: nh(c, u) };
}
function lW(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = $a(e));
  const { y1: n, y: r = n, x: i } = t, [s, o, a] = Ia(r, i, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function fW(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = $a(e));
  const { y1: n, y: r = n, x: i } = t, [s, o, , a] = Ia(r, i, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function I$(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = $a(e));
  const { x1: n, x: r = n, y: i, ...s } = t, [o, a, c, u] = Ia(r, i, "x", "y", e, s);
  return { ...o, x1: n, x: a, y1: c, y2: u, y: nh(c, u) };
}
function hW(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = $a(e));
  const { x1: n, x: r = n, y: i } = t, [s, o, a] = Ia(r, i, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function dW(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = $a(e));
  const { x1: n, x: r = n, y: i } = t, [s, o, , a] = Ia(r, i, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function Pg({ x: e, x1: t, x2: n, ...r } = {}) {
  return r = Js(r, "y"), t === void 0 && n === void 0 ? $$({ x: e, ...r }) : ([t, n] = _M(e, t, n), { ...r, x1: t, x2: n });
}
function Ug({ y: e, y1: t, y2: n, ...r } = {}) {
  return r = Js(r, "x"), t === void 0 && n === void 0 ? I$({ y: e, ...r }) : ([t, n] = _M(e, t, n), { ...r, y1: t, y2: n });
}
function $a(e) {
  const { offset: t, order: n, reverse: r, ...i } = e;
  return [{ offset: t, order: n, reverse: r }, i];
}
const pW = { length: !0 };
function Ia(e, t = Ym, n, r, { offset: i, order: s, reverse: o }, a) {
  if (t === null)
    throw new Error(`stack requires ${r}`);
  const c = Ji(a), [u, l] = qe(e), [f, h] = sn(t), [d, p] = sn(t);
  return f.hint = d.hint = pW, i = yW(i), s = bW(s, i, r), [
    Mr(a, (y, g, m) => {
      ({ data: y, facets: g } = uW(y, g));
      const b = e == null ? void 0 : l(rh(At(y, e), m == null ? void 0 : m[n])), w = At(y, t, Float64Array), v = At(y, c), x = s && s(y, b, w, v), _ = y.length, M = h(new Float64Array(_)), T = p(new Float64Array(_)), N = [];
      for (const A of g) {
        const $ = b ? Array.from(ii(A, (D) => b[D]).values()) : [A];
        if (x)
          for (const D of $)
            D.sort(x);
        for (const D of $) {
          let F = 0, S = 0;
          o && D.reverse();
          for (const I of D) {
            const E = w[I];
            E < 0 ? F = T[I] = (M[I] = F) + E : E > 0 ? S = T[I] = (M[I] = S) + E : T[I] = M[I] = S;
          }
        }
        N.push($);
      }
      return i && i(N, M, T, v), { data: y, facets: g };
    }),
    u,
    f,
    d
  ];
}
function yW(e) {
  if (e != null) {
    if (typeof e == "function")
      return e;
    switch (`${e}`.toLowerCase()) {
      case "expand":
      case "normalize":
        return mW;
      case "center":
      case "silhouette":
        return gW;
      case "wiggle":
        return E$;
    }
    throw new Error(`unknown offset: ${e}`);
  }
}
function T$(e, t) {
  let n = 0, r = 0;
  for (const i of e) {
    const s = t[i];
    s < n && (n = s), s > r && (r = s);
  }
  return [n, r];
}
function mW(e, t, n) {
  for (const r of e)
    for (const i of r) {
      const [s, o] = T$(i, n);
      for (const a of i) {
        const c = 1 / (o - s || 1);
        t[a] = c * (t[a] - s), n[a] = c * (n[a] - s);
      }
    }
}
function gW(e, t, n) {
  for (const r of e) {
    for (const i of r) {
      const [s, o] = T$(i, n);
      for (const a of i) {
        const c = (o + s) / 2;
        t[a] -= c, n[a] -= c;
      }
    }
    N$(r, t, n);
  }
  D$(e, t, n);
}
function E$(e, t, n, r) {
  for (const i of e) {
    const s = new Fs();
    let o = 0;
    for (const a of i) {
      let c = -1;
      const u = a.map((d) => Math.abs(n[d] - t[d])), l = a.map((d) => {
        c = r ? r[d] : ++c;
        const p = n[d] - t[d], y = s.has(c) ? p - s.get(c) : 0;
        return s.set(c, p), y;
      }), f = [0, ...gL(l)];
      for (const d of a)
        t[d] += o, n[d] += o;
      const h = gr(u);
      h && (o -= gr(u, (d, p) => (l[p] / 2 + f[p]) * d) / h);
    }
    N$(i, t, n);
  }
  D$(e, t, n);
}
function N$(e, t, n) {
  const r = be(e, (i) => be(i, (s) => t[s]));
  for (const i of e)
    for (const s of i)
      t[s] -= r, n[s] -= r;
}
function D$(e, t, n) {
  const r = e.length;
  if (r === 1)
    return;
  const i = e.map((a) => a.flat()), s = i.map((a) => (be(a, (c) => t[c]) + Qt(a, (c) => n[c])) / 2), o = be(s);
  for (let a = 0; a < r; a++) {
    const c = o - s[a];
    for (const u of i[a])
      t[u] += c, n[u] += c;
  }
}
function bW(e, t, n) {
  if (e === void 0 && t === E$)
    return y2(Mn);
  if (e != null) {
    if (typeof e == "string") {
      const r = e.startsWith("-"), i = r ? th : Mn;
      switch ((r ? e.slice(1) : e).toLowerCase()) {
        case "value":
        case n:
          return wW(i);
        case "z":
          return vW(i);
        case "sum":
          return _W(i);
        case "appearance":
          return xW(i);
        case "inside-out":
          return y2(i);
      }
      return m2(mM(e));
    }
    if (typeof e == "function")
      return (e.length === 1 ? m2 : SW)(e);
    if (Array.isArray(e))
      return MW(e);
    throw new Error(`invalid order: ${e}`);
  }
}
function wW(e) {
  return (t, n, r) => (i, s) => e(r[i], r[s]);
}
function vW(e) {
  return (t, n, r, i) => (s, o) => e(i[s], i[o]);
}
function _W(e) {
  return Sd(
    e,
    (t, n, r, i) => am(
      si(t),
      (s) => gr(s, (o) => r[o]),
      (s) => i[s]
    )
  );
}
function xW(e) {
  return Sd(
    e,
    (t, n, r, i) => am(
      si(t),
      (s) => n[um(s, (o) => r[o])],
      (s) => i[s]
    )
  );
}
function y2(e) {
  return Sd(e, (t, n, r, i) => {
    const s = si(t), o = am(
      s,
      (f) => n[um(f, (h) => r[h])],
      (f) => i[f]
    ), a = Do(
      s,
      (f) => gr(f, (h) => r[h]),
      (f) => i[f]
    ), c = [], u = [];
    let l = 0;
    for (const f of o)
      l < 0 ? (l += a.get(f), c.push(f)) : (l -= a.get(f), u.push(f));
    return u.reverse().concat(c);
  });
}
function m2(e) {
  return (t) => {
    const n = At(t, e);
    return (r, i) => Mn(n[r], n[i]);
  };
}
function SW(e) {
  return (t) => (n, r) => e(t[n], t[r]);
}
function MW(e) {
  return Sd(Mn, () => e);
}
function Sd(e, t) {
  return (n, r, i, s) => {
    if (!s)
      throw new Error("missing channel: z");
    const o = new Fs(t(n, r, i, s).map((a, c) => [a, c]));
    return (a, c) => e(o.get(s[a]), o.get(s[c]));
  };
}
const AW = {
  ariaLabel: "area",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class Md extends Xt {
  constructor(t, n = {}) {
    const { x1: r, y1: i, x2: s, y2: o, z: a, curve: c, tension: u } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x" },
        y1: { value: i, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 },
        z: { value: Ji(n), optional: !0 }
      },
      n,
      AW
    ), this.z = a, this.curve = Dg(c, u);
  }
  filter(t) {
    return t;
  }
  render(t, n, r, i, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a } = r;
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, n, 0, 0).call(
      (l) => l.selectAll().data(jM(t, [o, a, c, u], this, r)).enter().append("path").call(Jt, this).call(sh, this, r).attr(
        "d",
        km().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 cy(e, t) {
  return t === void 0 ? fa(e, { x: bu, y: Rc }) : new Md(e, t);
}
function jc(e, t) {
  const { y: n = ze, ...r } = Lg(t);
  return new Md(e, Pg(Cg({ ...r, y1: n, y2: void 0 })));
}
function fa(e, t) {
  const { x: n = ze, ...r } = Og(t);
  return new Md(e, Ug(Bg({ ...r, x1: n, x2: void 0 })));
}
const $W = {
  ariaLabel: "link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class O$ extends Xt {
  constructor(t, n = {}) {
    const { x1: r, y1: i, x2: s, y2: o, curve: a, tension: c } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x" },
        y1: { value: i, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      $W
    ), this.curve = w$(a, c), Sa(this, n);
  }
  project(t, n, r) {
    this.curve !== la && super.project(t, n, r);
  }
  render(t, n, r, i, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a } = r, { curve: l } = this;
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, n).call(
      (f) => f.selectAll().data(t).enter().append("path").call(Jt, this).attr(
        "d",
        l === la && s.projection ? IW(s.projection, o, a, c, u) : (h) => {
          const d = qr(), p = l(d);
          return p.lineStart(), p.point(o[h], a[h]), p.point(c[h], u[h]), p.lineEnd(), d;
        }
      ).call(pe, this, r).call($u, this, r, s)
    ).node();
  }
}
function IW(e, t, n, r, i) {
  const s = Gi(e);
  return t = We(t), n = We(n), r = We(r), i = We(i), (o) => s({
    type: "LineString",
    coordinates: [
      [t[o], n[o]],
      [r[o], i[o]]
    ]
  });
}
function L$(e, { x: t, x1: n, x2: r, y: i, y1: s, y2: o, ...a } = {}) {
  return [n, r] = hh(t, n, r), [s, o] = hh(i, s, o), new O$(e, { ...a, x1: n, x2: r, y1: s, y2: o });
}
function hh(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 TW = {
  ariaLabel: "arrow",
  fill: "none",
  stroke: "currentColor",
  strokeLinecap: "round",
  strokeMiterlimit: 1,
  strokeWidth: 1.5
};
class k$ extends Xt {
  constructor(t, n = {}) {
    const {
      x1: r,
      y1: i,
      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,
      sweep: d
    } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x" },
        y1: { value: i, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      TW
    ), 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, this.sweep = EW(d);
  }
  render(t, n, r, i, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a, SW: l } = r, { strokeWidth: f, bend: h, headAngle: d, headLength: p, insetStart: y, insetEnd: g } = this, m = l ? (v) => l[v] : un(f === void 0 ? 1 : f), b = d * ch / 2, w = p / 1.5;
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, n).call(
      (v) => v.selectAll().data(t).enter().append("path").call(Jt, this).attr("d", (x) => {
        let _ = o[x], M = a[x], T = c[x], N = u[x];
        const A = Math.hypot(T - _, N - M);
        if (A <= y + g)
          return null;
        let $ = Math.atan2(N - M, T - _);
        const D = Math.min(w * m(x), A / 3), F = this.sweep(_, M, T, N) * h * ch, S = Math.hypot(A / Math.tan(F), A) / 2;
        if (y || g)
          if (S < 1e5) {
            const G = Math.sign(F), [Z, H] = NW([_, M], [T, N], S, G);
            if (y && ([_, M] = g2([Z, H, S], [_, M, y], -G * Math.sign(y))), g) {
              const [q, W] = g2([Z, H, S], [T, N, g], G * Math.sign(g));
              $ += Math.atan2(W - H, q - Z) - Math.atan2(N - H, T - Z), T = q, N = W;
            }
          } else {
            const G = T - _, Z = N - M, H = Math.hypot(G, Z);
            y && (_ += G / H * y, M += Z / H * y), g && (T -= G / H * g, N -= Z / H * g);
          }
        const I = $ + F, E = I + b, O = I - b, C = T - D * Math.cos(E), B = N - D * Math.sin(E), R = T - D * Math.cos(O), P = N - D * Math.sin(O), U = S < 1e5 ? `A${S},${S} 0,0,${F > 0 ? 1 : 0} ` : "L", Y = D ? `M${C},${B}L${T},${N}L${R},${P}` : "";
        return `M${_},${M}${U}${T},${N}${Y}`;
      }).call(pe, this, r)
    ).node();
  }
}
function EW(e = 1) {
  if (typeof e == "number")
    return un(Math.sign(e));
  if (typeof e == "function")
    return (t, n, r, i) => Math.sign(e(t, n, r, i));
  switch (ln(e, "sweep", ["+x", "-x", "+y", "-y"])) {
    case "+x":
      return (t, n, r) => re(t, r);
    case "-x":
      return (t, n, r) => ks(t, r);
    case "+y":
      return (t, n, r, i) => re(n, i);
    case "-y":
      return (t, n, r, i) => ks(n, i);
  }
}
function NW([e, t], [n, r], i, s) {
  const o = n - e, a = r - t, c = Math.hypot(o, a), u = s * Math.sqrt(i * i - c * c / 4) / c;
  return [(e + n) / 2 - a * u, (t + r) / 2 + o * u];
}
function g2([e, t, n], [r, i, s], o) {
  const a = r - e, c = i - 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 DW(e, { x: t, x1: n, x2: r, y: i, y1: s, y2: o, ...a } = {}) {
  return [n, r] = hh(t, n, r), [s, o] = hh(i, s, o), new k$(e, { ...a, x1: n, x2: r, y1: s, y2: o });
}
class zg extends Xt {
  constructor(t, n, r = {}, i) {
    super(t, n, r, i);
    const { inset: s = 0, insetTop: o = s, insetRight: a = s, insetBottom: c = s, insetLeft: u = s, rx: l, ry: f } = r;
    this.insetTop = Et(o), this.insetRight = Et(a), this.insetBottom = Et(c), this.insetLeft = Et(u), this.rx = se(l, "auto"), this.ry = se(f, "auto");
  }
  render(t, n, r, i, s) {
    const { rx: o, ry: a } = this;
    return Nt("svg:g", s).call(te, this, i, s).call(this._transform, this, n).call(
      (c) => c.selectAll().data(t).enter().append("rect").call(Jt, this).attr("x", this._x(n, r, i)).attr("width", this._width(n, r, i)).attr("y", this._y(n, r, i)).attr("height", this._height(n, r, i)).call(et, "rx", o).call(et, "ry", a).call(pe, this, r)
    ).node();
  }
  _x(t, { x: n }, { marginLeft: r }) {
    const { insetLeft: i } = this;
    return n ? (s) => n[s] + i : r + i;
  }
  _y(t, { y: n }, { marginTop: r }) {
    const { insetTop: i } = this;
    return n ? (s) => n[s] + i : r + i;
  }
  _width({ x: t }, { x: n }, { marginRight: r, marginLeft: i, width: s }) {
    const { insetLeft: o, insetRight: a } = this, c = n && t ? t.bandwidth() : s - r - i;
    return Math.max(0, c - o - a);
  }
  _height({ y: t }, { y: n }, { marginTop: r, marginBottom: i, height: s }) {
    const { insetTop: o, insetBottom: a } = this, c = n && t ? t.bandwidth() : s - r - i;
    return Math.max(0, c - o - a);
  }
}
const F$ = {
  ariaLabel: "bar"
};
class R$ extends zg {
  constructor(t, n = {}) {
    const { x1: r, x2: i, y: s } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x" },
        x2: { value: i, scale: "x" },
        y: { value: s, scale: "y", type: "band", optional: !0 }
      },
      n,
      F$
    );
  }
  _transform(t, n, { x: r }) {
    t.call(Wt, n, { x: r }, 0, 0);
  }
  _x({ x: t }, { x1: n, x2: r }, { marginLeft: i }) {
    const { insetLeft: s } = this;
    return vn(t) ? i + s : (o) => Math.min(n[o], r[o]) + s;
  }
  _width({ x: t }, { x1: n, x2: r }, { marginRight: i, marginLeft: s, width: o }) {
    const { insetLeft: a, insetRight: c } = this;
    return vn(t) ? o - i - s - a - c : (u) => Math.max(0, Math.abs(r[u] - n[u]) - a - c);
  }
}
class C$ extends zg {
  constructor(t, n = {}) {
    const { x: r, y1: i, y2: s } = n;
    super(
      t,
      {
        y1: { value: i, scale: "y" },
        y2: { value: s, scale: "y" },
        x: { value: r, scale: "x", type: "band", optional: !0 }
      },
      n,
      F$
    );
  }
  _transform(t, n, { y: r }) {
    t.call(Wt, n, { y: r }, 0, 0);
  }
  _y({ y: t }, { y1: n, y2: r }, { marginTop: i }) {
    const { insetTop: s } = this;
    return vn(t) ? i + s : (o) => Math.min(n[o], r[o]) + s;
  }
  _height({ y: t }, { y1: n, y2: r }, { marginTop: i, marginBottom: s, height: o }) {
    const { insetTop: a, insetBottom: c } = this;
    return vn(t) ? o - i - s - a - c : (u) => Math.max(0, Math.abs(r[u] - n[u]) - a - c);
  }
}
function vs(e, t = {}) {
  return od(t) || (t = { ...t, y: ze, x2: at }), new R$(e, Pg(xA(Cg(t))));
}
function _s(e, t = {}) {
  return od(t) || (t = { ...t, x: ze, y2: at }), new C$(e, Ug(SA(Bg(t))));
}
const OW = {
  ariaLabel: "cell"
};
class Ad extends zg {
  constructor(t, { x: n, y: r, ...i } = {}) {
    super(
      t,
      {
        x: { value: n, scale: "x", type: "band", optional: !0 },
        y: { value: r, scale: "y", type: "band", optional: !0 }
      },
      i,
      OW
    );
  }
  _transform(t, n) {
    t.call(Wt, n, {}, 0, 0);
  }
}
function So(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Wn(t, n), new Ad(e, { ...r, x: t, y: n });
}
function LW(e, { x: t = ze, fill: n, stroke: r, ...i } = {}) {
  return n === void 0 && Be(r)[0] === void 0 && (n = at), new Ad(e, { ...i, x: t, fill: n, stroke: r });
}
function kW(e, { y: t = ze, fill: n, stroke: r, ...i } = {}) {
  return n === void 0 && Be(r)[0] === void 0 && (n = at), new Ad(e, { ...i, y: t, fill: n, stroke: r });
}
const FW = {
  ariaLabel: "dot",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5
};
function jg(e) {
  return e.sort === void 0 && e.reverse === void 0 ? TM({ channel: "-r" }, e) : e;
}
class $d extends Xt {
  constructor(t, n = {}) {
    const { x: r, y: i, r: s, rotate: o, symbol: a = Fc, frameAnchor: c } = n, [u, l] = ce(o, 0), [f, h] = Xj(a), [d, p] = ce(s, f == null ? 3 : 4.5);
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        r: { value: d, scale: "r", filter: Gr, optional: !0 },
        rotate: { value: u, optional: !0 },
        symbol: { value: f, scale: "auto", optional: !0 }
      },
      jg(n),
      FW
    ), this.r = p, this.rotate = l, this.symbol = h, this.frameAnchor = vu(c);
    const { channels: y } = this, { symbol: g } = y;
    if (g) {
      const { fill: m, stroke: b } = y;
      g.hint = {
        fill: m ? m.value === g.value ? "color" : "currentColor" : this.fill ?? "currentColor",
        stroke: b ? b.value === g.value ? "color" : "currentColor" : this.stroke ?? "none"
      };
    }
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, r: l, rotate: f, symbol: h } = r, { r: d, rotate: p, symbol: y } = this, [g, m] = Ar(this, i), b = y === Fc, w = l ? void 0 : d * d * Math.PI;
    return id(d) && (t = []), Nt("svg:g", s).call(te, this, i, s).call(Wt, this, { x: c && o, y: u && a }).call(
      (v) => v.selectAll().data(t).enter().append(b ? "circle" : "path").call(Jt, this).call(
        b ? (x) => {
          x.attr("cx", c ? (_) => c[_] : g).attr("cy", u ? (_) => u[_] : m).attr("r", l ? (_) => l[_] : d);
        } : (x) => {
          x.attr(
            "transform",
            wd`translate(${c ? (_) => c[_] : g},${u ? (_) => u[_] : m})${f ? (_) => ` rotate(${f[_]})` : p ? ` rotate(${p})` : ""}`
          ).attr(
            "d",
            l && h ? (_) => {
              const M = qr();
              return h[_].draw(M, l[_] * l[_] * Math.PI), M;
            } : l ? (_) => {
              const M = qr();
              return y.draw(M, l[_] * l[_] * Math.PI), M;
            } : h ? (_) => {
              const M = qr();
              return h[_].draw(M, w), M;
            } : (() => {
              const _ = qr();
              return y.draw(_, w), _;
            })()
          );
        }
      ).call(pe, this, r)
    ).node();
  }
}
function Qi(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Wn(t, n)), new $d(e, { ...r, x: t, y: n });
}
function RW(e, { x: t = at, ...n } = {}) {
  return new $d(e, AA({ ...n, x: t }));
}
function CW(e, { y: t = at, ...n } = {}) {
  return new $d(e, MA({ ...n, y: t }));
}
function BW(e, t) {
  return Qi(e, { ...t, symbol: "circle" });
}
function PW(e, t) {
  return Qi(e, { ...t, symbol: "hexagon" });
}
const UW = {
  ariaLabel: "line",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class Id extends Xt {
  constructor(t, n = {}) {
    const { x: r, y: i, z: s, curve: o, tension: a } = n;
    super(
      t,
      {
        x: { value: r, scale: "x" },
        y: { value: i, scale: "y" },
        z: { value: Ji(n), optional: !0 }
      },
      n,
      UW
    ), this.z = s, this.curve = w$(o, a), Sa(this, n);
  }
  filter(t) {
    return t;
  }
  project(t, n, r) {
    this.curve !== la && super.project(t, n, r);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = r, { curve: c } = this;
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, n).call(
      (u) => u.selectAll().data(jM(t, [o, a], this, r)).enter().append("path").call(Jt, this).call(sh, this, r).call(YV, this, r, s).attr(
        "d",
        c === la && s.projection ? zW(s.projection, o, a) : B6().curve(c).defined((l) => l >= 0).x((l) => o[l]).y((l) => a[l])
      )
    ).node();
  }
}
function zW(e, t, n) {
  const r = Gi(e);
  return t = We(t), n = We(n), (i) => {
    let s = [];
    const o = [s];
    for (const a of i)
      a === -1 ? (s = [], o.push(s)) : s.push([t[a], n[a]]);
    return r({ type: "MultiLineString", coordinates: o });
  };
}
function Td(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Wn(t, n), new Id(e, { ...r, x: t, y: n });
}
function qc(e, { x: t = at, y: n = ze, ...r } = {}) {
  return new Id(e, Lg({ ...r, x: t, y: n }));
}
function Vc(e, { x: t = ze, y: n = at, ...r } = {}) {
  return new Id(e, Og({ ...r, x: t, y: n }));
}
const jW = {
  ariaLabel: "rect"
};
class Ed extends Xt {
  constructor(t, n = {}) {
    const {
      x1: r,
      y1: i,
      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: r, scale: "x", type: r != null && s == null ? "band" : void 0, optional: !0 },
        y1: { value: i, scale: "y", type: i != null && o == null ? "band" : void 0, optional: !0 },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      jW
    ), this.insetTop = Et(c), this.insetRight = Et(u), this.insetBottom = Et(l), this.insetLeft = Et(f), this.rx = se(h, "auto"), this.ry = se(d, "auto");
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x1: c, y1: u, x2: l, y2: f } = r, { marginTop: h, marginRight: d, marginBottom: p, marginLeft: y, width: g, height: m } = i, { projection: b } = s, { insetTop: w, insetRight: v, insetBottom: x, insetLeft: _, rx: M, ry: T } = this, N = (o != null && o.bandwidth ? o.bandwidth() : 0) - _ - v, A = (a != null && a.bandwidth ? a.bandwidth() : 0) - w - x;
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, {}, 0, 0).call(
      ($) => $.selectAll().data(t).enter().append("rect").call(Jt, this).attr(
        "x",
        c && (b || !vn(o)) ? l ? (D) => Math.min(c[D], l[D]) + _ : (D) => c[D] + _ : y + _
      ).attr(
        "y",
        u && (b || !vn(a)) ? f ? (D) => Math.min(u[D], f[D]) + w : (D) => u[D] + w : h + w
      ).attr(
        "width",
        c && (b || !vn(o)) ? l ? (D) => Math.max(0, Math.abs(l[D] - c[D]) + N) : N : g - d - y - v - _
      ).attr(
        "height",
        u && (b || !vn(a)) ? f ? (D) => Math.max(0, Math.abs(u[D] - f[D]) + A) : A : m - h - p - w - x
      ).call(et, "rx", M).call(et, "ry", T).call(pe, this, r)
    ).node();
  }
}
function qg(e, t) {
  return new Ed(e, vA(_A(t)));
}
function dh(e, t = {}) {
  return od(t) || (t = { ...t, y: ze, x2: at, interval: 1 }), new Ed(e, Pg(_A(Cg(t))));
}
function ph(e, t = {}) {
  return od(t) || (t = { ...t, x: ze, y2: at, interval: 1 }), new Ed(e, Ug(vA(Bg(t))));
}
function B$(e, t) {
  t = VW(t);
  const { x: n, y: r, color: i, size: s } = t, o = cl(e, n), a = cl(e, r), c = cl(e, i), u = cl(e, s);
  let {
    fx: l,
    fy: f,
    x: { value: h, reduce: d, zero: p, ...y },
    y: { value: g, reduce: m, zero: b, ...w },
    color: { value: v, color: x, reduce: _ },
    size: { value: M, reduce: T },
    // TODO constant radius?
    mark: N
  } = t;
  if (d === void 0 && (d = m == null && h == null && M == null && g != null ? "count" : null), m === void 0 && (m = d == null && g == null && M == null && h != null ? "count" : null), T === void 0 && M == null && _ == null && d == null && m == null && (h == null || ie(o)) && (g == null || ie(a)) && (T = "count"), p === void 0 && (p = ul(d) ? !0 : void 0), b === void 0 && (b = ul(m) ? !0 : void 0), h == null && g == null)
    throw new Error("must specify x or y");
  if (d != null && g == null)
    throw new Error("reducing x requires y");
  if (m != null && h == null)
    throw new Error("reducing y requires x");
  N === void 0 && (N = M != null || T != null ? "dot" : ul(d) || ul(m) || _ != null ? "bar" : h != null && g != null ? ie(o) || ie(a) || d == null && m == null && !qa(o) && !qa(a) ? "dot" : "line" : h != null || g != null ? "rule" : null);
  let A, $, D;
  switch (N) {
    case "dot":
      D = Qi, $ = "stroke";
      break;
    case "line":
      D = o && a || d != null || m != null ? b || m != null || o && qa(o) ? Vc : p || d != null || a && qa(a) ? qc : Td : o ? qc : Vc, $ = "stroke", w2(c) && (A = null);
      break;
    case "area":
      D = !(b || m != null) && (p || d != null || a && qa(a)) ? jc : fa, $ = "fill", w2(c) && (A = null);
      break;
    case "rule":
      D = o ? Pi : Ui, $ = "stroke";
      break;
    case "bar":
      D = d != null ? ie(a) ? b2(d) && o && ie(o) ? So : vs : dh : m != null ? ie(o) ? b2(m) && a && ie(a) ? So : _s : ph : _ != null || T != null ? o && ie(o) && a && ie(a) ? So : o && ie(o) ? _s : a && ie(a) ? vs : qg : o && xo(o) && !(a && xo(a)) ? vs : a && xo(a) && !(o && xo(o)) ? _s : So, $ = "fill";
      break;
    default:
      throw new Error(`invalid mark: ${N}`);
  }
  let F = {
    fx: l,
    fy: f,
    x: o ?? void 0,
    // treat null x as undefined for implicit stack
    y: a ?? void 0,
    // treat null y as undefined for implicit stack
    [$]: c ?? x,
    z: A,
    r: u ?? void 0,
    // treat null size as undefined for default constant radius
    tip: !0
  }, S, I = { [$]: _ ?? void 0, r: T ?? void 0 };
  if (d != null && m != null)
    throw new Error("cannot reduce both x and y");
  return m != null ? (I.y = m, S = ie(o) ? Bc : vi) : d != null ? (I.x = d, S = ie(a) ? Pc : _i) : (_ != null || T != null) && (o && a ? S = ie(o) && ie(a) ? rg : ie(o) ? _i : ie(a) ? vi : us : o ? S = ie(o) ? Bc : vi : a && (S = ie(a) ? Pc : _i)), (S === us || S === vi) && (F.x = { value: o, ...y }), (S === us || S === _i) && (F.y = { value: a, ...w }), p === void 0 && (p = o && !(S === us || S === vi) && (D === vs || D === jc || D === dh || D === Ui)), b === void 0 && (b = a && !(S === us || S === _i) && (D === _s || D === fa || D === ph || D === Pi)), {
    fx: l ?? null,
    fy: f ?? null,
    x: {
      value: h ?? null,
      reduce: d ?? null,
      zero: !!p,
      ...y
    },
    y: {
      value: g ?? null,
      reduce: m ?? null,
      zero: !!b,
      ...w
    },
    color: {
      value: v ?? null,
      reduce: _ ?? null,
      ...x !== void 0 && { color: x }
    },
    size: {
      value: M ?? null,
      reduce: T ?? null
    },
    mark: N,
    markImpl: v2[D],
    markOptions: F,
    transformImpl: v2[S],
    transformOptions: I,
    colorMode: $
  };
}
function qW(e, t) {
  const n = B$(e, t), {
    fx: r,
    fy: i,
    x: { zero: s },
    y: { zero: o },
    markOptions: a,
    transformOptions: c,
    colorMode: u
  } = n, l = uy[n.markImpl], f = uy[n.transformImpl], h = r != null || i != null ? Tg({ strokeOpacity: 0.1 }) : null, d = [s ? Pi([0]) : null, o ? Ui([0]) : null], p = l(e, f ? f(c, a) : a);
  return u === "stroke" ? An(h, d, p) : An(h, p, d);
}
function qa(e) {
  let t, n;
  for (const r of e) {
    if (r == null)
      continue;
    if (t === void 0) {
      t = r;
      continue;
    }
    const i = Math.sign(re(t, r));
    if (i) {
      if (n !== void 0 && i !== n)
        return !1;
      t = r, n = i;
    }
  }
  return !0;
}
function VW({ x: e, y: t, color: n, size: r, fx: i, fy: s, mark: o } = {}) {
  return Qn(e) || (e = uo(e)), Qn(t) || (t = uo(t)), Qn(n) || (n = wu(n) ? { color: n } : uo(n)), Qn(r) || (r = uo(r)), Qn(i) && ({ value: i } = uo(i)), Qn(s) && ({ value: s } = uo(s)), o != null && (o = `${o}`.toLowerCase()), { x: e, y: t, color: n, size: r, fx: i, fy: s, mark: o };
}
function cl(e, t) {
  const n = At(e, t.value);
  return n && (n.label = Sr(t.value)), n;
}
function uo(e) {
  return YW(e) ? { reduce: e } : { value: e };
}
function ul(e) {
  return /^(?:distinct|count|sum|proportion)$/i.test(e);
}
function b2(e) {
  return /^(?:first|last|mode)$/i.test(e);
}
function YW(e) {
  if (e == null)
    return !1;
  if (typeof e.reduceIndex == "function" || typeof e.reduce == "function" && $n(e) || /^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 w2(e) {
  return e ? new eu(e).size > e.length >> 1 : !1;
}
const uy = {
  dot: Qi,
  line: Td,
  lineX: qc,
  lineY: Vc,
  areaX: jc,
  areaY: fa,
  ruleX: Pi,
  ruleY: Ui,
  barX: vs,
  barY: _s,
  rect: qg,
  rectX: dh,
  rectY: ph,
  cell: So,
  bin: us,
  binX: vi,
  binY: _i,
  group: rg,
  groupX: Bc,
  groupY: Pc
}, v2 = Object.fromEntries(Object.entries(uy).map(([e, t]) => [t, e]));
function Vg(e, t = {}) {
  let { x: n, x1: r, x2: i } = t;
  n === void 0 && r === void 0 && i === void 0 && (t = { ...t, x: n = at });
  const s = {};
  return n != null && (s.x = e), r != null && (s.x1 = e), i != null && (s.x2 = e), vr(s, t);
}
function Yg(e, t = {}) {
  let { y: n, y1: r, y2: i } = t;
  n === void 0 && r === void 0 && i === void 0 && (t = { ...t, y: n = at });
  const s = {};
  return n != null && (s.y = e), r != null && (s.y1 = e), i != null && (s.y2 = e), vr(s, t);
}
function vr(e = {}, t = {}) {
  const n = Ji(t), r = Object.entries(e).map(([i, s]) => {
    const o = xM(i, t);
    if (o == null)
      throw new Error(`missing channel: ${i}`);
    const [a, c] = sn(o);
    return { key: i, input: o, output: a, setOutput: c, map: WW(s) };
  });
  return {
    ...Mr(t, (i, s) => {
      const o = At(i, n), a = r.map(({ input: u }) => At(i, u)), c = r.map(({ setOutput: u }) => u(new Array(i.length)));
      for (const u of s)
        for (const l of o ? ii(u, (f) => o[f]).values() : [u])
          r.forEach(({ map: f }, h) => f.mapIndex(l, a[h], c[h]));
      return { data: i, facets: s };
    }),
    ...Object.fromEntries(r.map(({ key: i, output: s }) => [i, s]))
  };
}
function WW(e) {
  if (e == null)
    throw new Error("missing map");
  if (typeof e.mapIndex == "function")
    return e;
  if (typeof e.map == "function" && $n(e))
    return XW(e);
  if (typeof e == "function")
    return Cp(Gm(e));
  switch (`${e}`.toLowerCase()) {
    case "cumsum":
      return HW;
    case "rank":
      return Cp((t, n) => xx(t, (r) => n[r]));
    case "quantile":
      return Cp((t, n) => GW(t, (r) => n[r]));
  }
  throw new Error(`invalid map: ${e}`);
}
function XW(e) {
  return console.warn("deprecated map interface; implement mapIndex instead."), { mapIndex: e.map.bind(e) };
}
function GW(e, t) {
  const n = kh(e, t) - 1;
  return xx(e, t).map((r) => r / n);
}
function Cp(e) {
  return {
    mapIndex(t, n, r) {
      const i = e(t, n);
      if (i.length !== t.length)
        throw new Error("map function returned a mismatched length");
      for (let s = 0, o = t.length; s < o; ++s)
        r[t[s]] = i[s];
    }
  };
}
const HW = {
  mapIndex(e, t, n) {
    let r = 0;
    for (const i of e)
      n[i] = r += t[i];
  }
};
function JW(e = {}, t) {
  return arguments.length === 1 && (t = e), Vg(Nd(e), t);
}
function ZW(e = {}, t) {
  return arguments.length === 1 && (t = e), Yg(Nd(e), t);
}
function Nd(e = {}) {
  typeof e == "number" && (e = { k: e });
  let { k: t, reduce: n, shift: r, anchor: i, strict: s } = e;
  if (i === void 0 && r !== void 0 && (i = QW(r), Hr(`Warning: the shift option is deprecated; please use anchor "${i}" instead.`)), !((t = Math.floor(t)) > 0))
    throw new Error(`invalid k: ${t}`);
  return tX(n)(t, KW(i, t), s);
}
function KW(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 QW(e) {
  switch (`${e}`.toLowerCase()) {
    case "centered":
      return "middle";
    case "leading":
      return "start";
    case "trailing":
      return "end";
  }
  throw new Error(`invalid shift: ${e}`);
}
function tX(e = "mean") {
  if (typeof e == "string") {
    if (/^p\d{2}$/i.test(e))
      return ll(Wm(e));
    switch (e.toLowerCase()) {
      case "deviation":
        return ll(tu);
      case "max":
        return fl((t, n) => Qt(t, (r) => n[r]));
      case "mean":
        return eX;
      case "median":
        return ll($c);
      case "min":
        return fl((t, n) => be(t, (r) => n[r]));
      case "mode":
        return fl((t, n) => _x(t, (r) => n[r]));
      case "sum":
        return P$;
      case "variance":
        return ll(im);
      case "difference":
        return iX;
      case "ratio":
        return sX;
      case "first":
        return oX;
      case "last":
        return aX;
    }
  }
  if (typeof e != "function")
    throw new Error(`invalid reduce: ${e}`);
  return fl(Gm(e));
}
function ll(e) {
  return (t, n, r) => r ? {
    mapIndex(i, s, o) {
      const a = (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 = i.length - t + 1; u < l; ++u)
        isNaN(a(u + t - 1)) && ++c, o[i[u + n]] = c === 0 ? e(Ts(i, u, u + t), a) : NaN, isNaN(a(u)) && --c;
    }
  } : {
    mapIndex(i, s, o) {
      const a = (c) => s[c] == null ? NaN : +s[c];
      for (let c = -n; c < 0; ++c)
        o[i[c + n]] = e(Ts(i, 0, c + t), a);
      for (let c = 0, u = i.length - n; c < u; ++c)
        o[i[c + n]] = e(Ts(i, c, c + t), a);
    }
  };
}
function fl(e) {
  return (t, n, r) => r ? {
    mapIndex(i, s, o) {
      let a = 0;
      for (let c = 0; c < t - 1; ++c)
        a += Re(s[i[c]]);
      for (let c = 0, u = i.length - t + 1; c < u; ++c)
        a += Re(s[i[c + t - 1]]), a === t && (o[i[c + n]] = e(Ts(i, c, c + t), s)), a -= Re(s[i[c]]);
    }
  } : {
    mapIndex(i, s, o) {
      for (let a = -n; a < 0; ++a)
        o[i[a + n]] = e(Ts(i, 0, a + t), s);
      for (let a = 0, c = i.length - n; a < c; ++a)
        o[i[a + n]] = e(Ts(i, a, a + t), s);
    }
  };
}
function P$(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      let o = 0, a = 0;
      for (let c = 0; c < e - 1; ++c) {
        const u = i[r[c]];
        u === null || isNaN(u) ? ++o : a += +u;
      }
      for (let c = 0, u = r.length - e + 1; c < u; ++c) {
        const l = i[r[c]], f = i[r[c + e - 1]];
        f === null || isNaN(f) ? ++o : a += +f, s[r[c + t]] = o === 0 ? a : NaN, l === null || isNaN(l) ? --o : a -= +l;
      }
    }
  } : {
    mapIndex(r, i, s) {
      let o = 0;
      const a = r.length;
      for (let c = 0, u = Math.min(a, e - t - 1); c < u; ++c)
        o += +i[r[c]] || 0;
      for (let c = -t, u = a - t; c < u; ++c)
        o += +i[r[c + e - 1]] || 0, s[r[c + t]] = o, o -= +i[r[c]] || 0;
    }
  };
}
function eX(e, t, n) {
  if (n) {
    const r = P$(e, t, n);
    return {
      mapIndex(i, s, o) {
        r.mapIndex(i, s, o);
        for (let a = 0, c = i.length - e + 1; a < c; ++a)
          o[i[a + t]] /= e;
      }
    };
  } else
    return {
      mapIndex(r, i, s) {
        let o = 0, a = 0;
        const c = r.length;
        for (let u = 0, l = Math.min(c, e - t - 1); u < l; ++u) {
          let f = i[r[u]];
          f !== null && !isNaN(f = +f) && (o += f, ++a);
        }
        for (let u = -t, l = c - t; u < l; ++u) {
          let f = i[r[u + e - 1]], h = i[r[u]];
          f !== null && !isNaN(f = +f) && (o += f, ++a), s[r[u + t]] = o / a, h !== null && !isNaN(h = +h) && (o -= h, --a);
        }
      }
    };
}
function nX(e, t, n, r) {
  for (let i = n + r; n < i; ++n) {
    const s = e[t[n]];
    if (Re(s))
      return s;
  }
}
function rX(e, t, n, r) {
  for (let i = n + r - 1; i >= n; --i) {
    const s = e[t[i]];
    if (Re(s))
      return s;
  }
}
function U$(e, t, n, r) {
  for (let i = n + r; n < i; ++n) {
    let s = e[t[n]];
    if (s !== null && !isNaN(s = +s))
      return s;
  }
}
function z$(e, t, n, r) {
  for (let i = n + r - 1; i >= n; --i) {
    let s = e[t[i]];
    if (s !== null && !isNaN(s = +s))
      return s;
  }
}
function iX(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      for (let o = 0, a = r.length - e; o < a; ++o) {
        const c = i[r[o]], u = i[r[o + e - 1]];
        s[r[o + t]] = c === null || u === null ? NaN : u - c;
      }
    }
  } : {
    mapIndex(r, i, s) {
      for (let o = -t, a = r.length - e + t + 1; o < a; ++o)
        s[r[o + t]] = z$(i, r, o, e) - U$(i, r, o, e);
    }
  };
}
function sX(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      for (let o = 0, a = r.length - e; o < a; ++o) {
        const c = i[r[o]], u = i[r[o + e - 1]];
        s[r[o + t]] = c === null || u === null ? NaN : u / c;
      }
    }
  } : {
    mapIndex(r, i, s) {
      for (let o = -t, a = r.length - e + t + 1; o < a; ++o)
        s[r[o + t]] = z$(i, r, o, e) / U$(i, r, o, e);
    }
  };
}
function oX(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      for (let o = 0, a = r.length - e; o < a; ++o)
        s[r[o + t]] = i[r[o]];
    }
  } : {
    mapIndex(r, i, s) {
      for (let o = -t, a = r.length - e + t + 1; o < a; ++o)
        s[r[o + t]] = nX(i, r, o, e);
    }
  };
}
function aX(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      for (let o = 0, a = r.length - e; o < a; ++o)
        s[r[o + t]] = i[r[o + e - 1]];
    }
  } : {
    mapIndex(r, i, s) {
      for (let o = -t, a = r.length - e + t + 1; o < a; ++o)
        s[r[o + t]] = rX(i, r, o, e);
    }
  };
}
const Jr = {
  n: 20,
  k: 2,
  color: "currentColor",
  opacity: 0.2,
  strict: !0,
  anchor: "end"
};
function cX(e, {
  x: t = at,
  y: n,
  k: r = Jr.k,
  color: i = Jr.color,
  opacity: s = Jr.opacity,
  fill: o = i,
  fillOpacity: a = s,
  stroke: c = i,
  strokeOpacity: u,
  strokeWidth: l,
  ...f
} = {}) {
  return An(
    Kt(o) ? null : jc(
      e,
      vr(
        { x1: Es({ k: -r, ...f }), x2: Es({ k: r, ...f }) },
        { x1: t, x2: t, y: n, fill: o, fillOpacity: a, ...f }
      )
    ),
    Kt(c) ? null : qc(e, vr({ x: Es(f) }, { x: t, y: n, stroke: c, strokeOpacity: u, strokeWidth: l, ...f }))
  );
}
function uX(e, {
  x: t,
  y: n = at,
  k: r = Jr.k,
  color: i = Jr.color,
  opacity: s = Jr.opacity,
  fill: o = i,
  fillOpacity: a = s,
  stroke: c = i,
  strokeOpacity: u,
  strokeWidth: l,
  ...f
} = {}) {
  return An(
    Kt(o) ? null : fa(
      e,
      vr(
        { y1: Es({ k: -r, ...f }), y2: Es({ k: r, ...f }) },
        { x: t, y1: n, y2: n, fill: o, fillOpacity: a, ...f }
      )
    ),
    Kt(c) ? null : Vc(e, vr({ y: Es(f) }, { x: t, y: n, stroke: c, strokeOpacity: u, strokeWidth: l, ...f }))
  );
}
function Es({ n: e = Jr.n, k: t = 0, strict: n = Jr.strict, anchor: r = Jr.anchor } = {}) {
  return Nd({ k: e, reduce: (i) => Fh(i) + t * (tu(i) || 0), strict: n, anchor: r });
}
const lX = {
  ariaLabel: "tick",
  fill: null,
  stroke: "currentColor"
};
class j$ extends Xt {
  constructor(t, n, r) {
    super(t, n, r, lX), Sa(this, r);
  }
  render(t, n, r, i, s) {
    return Nt("svg:g", s).call(te, this, i, s).call(this._transform, this, n).call(
      (o) => o.selectAll().data(t).enter().append("line").call(Jt, this).attr("x1", this._x1(n, r, i)).attr("x2", this._x2(n, r, i)).attr("y1", this._y1(n, r, i)).attr("y2", this._y2(n, r, i)).call(pe, this, r).call($u, this, r, s)
    ).node();
  }
}
class q$ extends j$ {
  constructor(t, n = {}) {
    const { x: r, y: i, inset: s = 0, insetTop: o = s, insetBottom: a = s } = n;
    super(
      t,
      {
        x: { value: r, scale: "x" },
        y: { value: i, scale: "y", type: "band", optional: !0 }
      },
      n
    ), this.insetTop = Et(o), this.insetBottom = Et(a);
  }
  _transform(t, n, { x: r }) {
    t.call(Wt, n, { x: r }, xe, 0);
  }
  _x1(t, { x: n }) {
    return (r) => n[r];
  }
  _x2(t, { x: n }) {
    return (r) => n[r];
  }
  _y1({ y: t }, { y: n }, { marginTop: r }) {
    const { insetTop: i } = this;
    return n && t ? (s) => n[s] + i : r + i;
  }
  _y2({ y: t }, { y: n }, { height: r, marginBottom: i }) {
    const { insetBottom: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : r - i - s;
  }
}
class V$ extends j$ {
  constructor(t, n = {}) {
    const { x: r, y: i, inset: s = 0, insetRight: o = s, insetLeft: a = s } = n;
    super(
      t,
      {
        y: { value: i, scale: "y" },
        x: { value: r, scale: "x", type: "band", optional: !0 }
      },
      n
    ), this.insetRight = Et(o), this.insetLeft = Et(a);
  }
  _transform(t, n, { y: r }) {
    t.call(Wt, n, { y: r }, 0, xe);
  }
  _x1({ x: t }, { x: n }, { marginLeft: r }) {
    const { insetLeft: i } = this;
    return n && t ? (s) => n[s] + i : r + i;
  }
  _x2({ x: t }, { x: n }, { width: r, marginRight: i }) {
    const { insetRight: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : r - i - s;
  }
  _y1(t, { y: n }) {
    return (r) => n[r];
  }
  _y2(t, { y: n }) {
    return (r) => n[r];
  }
}
function Y$(e, { x: t = at, ...n } = {}) {
  return new q$(e, { ...n, x: t });
}
function W$(e, { y: t = at, ...n } = {}) {
  return new V$(e, { ...n, y: t });
}
function fX(e, {
  x: t = at,
  y: n = null,
  fill: r = "#ccc",
  fillOpacity: i,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...u
} = {}) {
  const l = n != null ? Pc : ng;
  return An(
    Ui(e, l({ x1: Wg, x2: Xg }, { x: t, y: n, stroke: s, strokeOpacity: o, ...u })),
    vs(e, l({ x1: "p25", x2: "p75" }, { x: t, y: n, fill: r, fillOpacity: i, ...u })),
    Y$(e, l({ x: "p50" }, { x: t, y: n, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...u })),
    Qi(e, vr({ x: X$ }, { x: t, y: n, z: n, stroke: s, strokeOpacity: o, ...u }))
  );
}
function hX(e, {
  y: t = at,
  x: n = null,
  fill: r = "#ccc",
  fillOpacity: i,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...u
} = {}) {
  const l = n != null ? Bc : ng;
  return An(
    Pi(e, l({ y1: Wg, y2: Xg }, { x: n, y: t, stroke: s, strokeOpacity: o, ...u })),
    _s(e, l({ y1: "p25", y2: "p75" }, { x: n, y: t, fill: r, fillOpacity: i, ...u })),
    W$(e, l({ y: "p50" }, { x: n, y: t, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...u })),
    Qi(e, vr({ y: X$ }, { x: n, y: t, z: n, stroke: s, strokeOpacity: o, ...u }))
  );
}
function X$(e) {
  const t = Wg(e), n = Xg(e);
  return e.map((r) => r < t || r > n ? r : NaN);
}
function Wg(e) {
  const t = G$(e) * 2.5 - H$(e) * 1.5;
  return be(e, (n) => n >= t ? n : NaN);
}
function Xg(e) {
  const t = H$(e) * 2.5 - G$(e) * 1.5;
  return Qt(e, (n) => n <= t ? n : NaN);
}
function G$(e) {
  return Fi(e, 0.25);
}
function H$(e) {
  return Fi(e, 0.75);
}
const dX = {
  ariaLabel: "raster",
  stroke: null,
  pixelSize: 1
};
function lo(e, t) {
  const n = +e;
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
function _2(e, t) {
  const n = Math.floor(e);
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
class J$ extends Xt {
  constructor(t, n, r = {}, i) {
    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 = i.pixelSize,
      blur: p = 0,
      interpolate: y
    } = r;
    if (s != null && (s = _2(s, "width")), o != null && (o = _2(o, "height")), u != null && (u = lo(u, "x1")), l != null && (l = lo(l, "y1")), f != null && (f = lo(f, "x2")), h != null && (h = lo(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 = xX(u, f, s)), c === void 0 && l != null && h != null && (c = SX(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
      },
      r,
      i
    ), this.width = s, this.height = o, this.pixelSize = lo(d, "pixelSize"), this.blur = lo(p, "blur"), this.interpolate = a == null || c == null ? null : yX(y);
  }
}
class Z$ extends J$ {
  constructor(t, n = {}) {
    const { imageRendering: r } = n;
    if (t == null) {
      const { fill: i, fillOpacity: s } = n;
      ce(s)[0] !== void 0 && (n = ly("fillOpacity", n)), Be(i)[0] !== void 0 && (n = ly("fill", n));
    }
    super(t, void 0, n, dX), this.imageRendering = se(r, "auto");
  }
  // Ignore the color scale, so the fill channel is returned unscaled.
  scale(t, { color: n, ...r }, i) {
    return super.scale(t, r, i);
  }
  render(t, n, r, i, s) {
    var I;
    const o = n[(I = r.channels.fill) == null ? void 0 : I.scale] ?? ((E) => E), { x: a, y: c } = r, { document: u } = s, [l, f, h, d] = Q$(r, i, s), p = h - l, y = d - f, { pixelSize: g, width: m = Math.round(Math.abs(p) / g), height: b = Math.round(Math.abs(y) / g) } = this, w = m * b;
    let { fill: v, fillOpacity: x } = r, _ = 0;
    if (this.interpolate) {
      const E = m / p, O = b / y, C = Gt(a, (R) => (R - l) * E, Float64Array), B = Gt(c, (R) => (R - f) * O, Float64Array);
      v && (v = this.interpolate(t, m, b, C, B, v)), x && (x = this.interpolate(t, m, b, C, B, x));
    } else
      this.data == null && t && (_ = t.fi * w);
    const M = u.createElement("canvas");
    M.width = m, M.height = b;
    const T = M.getContext("2d"), N = T.createImageData(m, b), A = N.data;
    let { r: $, g: D, b: F } = Sn(this.fill) ?? { r: 0, g: 0, b: 0 }, S = (this.fillOpacity ?? 1) * 255;
    for (let E = 0; E < w; ++E) {
      const O = E << 2;
      if (v) {
        const C = o(v[E + _]);
        if (C == null) {
          A[O + 3] = 0;
          continue;
        }
        ({ r: $, g: D, b: F } = Sn(C));
      }
      x && (S = x[E + _] * 255), A[O + 0] = $, A[O + 1] = D, A[O + 2] = F, A[O + 3] = S;
    }
    return this.blur > 0 && uL(N, this.blur), T.putImageData(N, 0, 0), Nt("svg:g", s).call(te, this, i, s).call(Wt, this, n).call(
      (E) => E.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(y)).attr("preserveAspectRatio", "none").call(et, "image-rendering", this.imageRendering).call(Jt, this).attr("xlink:href", M.toDataURL())
    ).node();
  }
}
function K$(e, t, n) {
  arguments.length < 3 && (n = t, t = null);
  let { x: r, y: i, [e]: s, ...o } = n;
  return r === void 0 && i === void 0 && Fj(t) && (r = bu, i = Rc, s === void 0 && (s = Nj)), [t, { ...o, x: r, y: i, [e]: s }];
}
function pX() {
  const [e, t] = K$("fill", ...arguments);
  return new Z$(
    e,
    e == null || t.fill !== void 0 || t.fillOpacity !== void 0 ? t : { ...t, fill: at }
  );
}
function Q$({ x1: e, y1: t, x2: n, y2: r }, i, { projection: s }) {
  const { width: o, height: a, marginTop: c, marginRight: u, marginBottom: l, marginLeft: f } = i;
  return [
    e && s == null ? e[0] : f,
    t && s == null ? t[0] : c,
    n && s == null ? n[0] : o - u,
    r && s == null ? r[0] : a - l
  ];
}
function t4({ x1: e, y1: t, x2: n, y2: r }, i, s, o) {
  const a = {};
  return e && (a.x1 = e), t && (a.y1 = t), n && (a.x2 = n), r && (a.y2 = r), Q$(ug(a, i), s, o);
}
function ly(e, t = {}) {
  const { [e]: n } = t;
  if (typeof n != "function")
    throw new Error(`invalid ${e}: not a function`);
  return Ke({ ...t, [e]: void 0 }, function(r, i, 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] = t4(s, o, a, c), y = d - f, g = p - h, { pixelSize: m } = this, { width: b = Math.round(Math.abs(y) / m), height: w = Math.round(Math.abs(g) / m) } = t, v = new Array(b * w * (i ? i.length : 1)), x = y / b, _ = g / w;
    let M = 0;
    for (const T of i ?? [void 0])
      for (let N = 0.5; N < w; ++N)
        for (let A = 0.5; A < b; ++A, ++M)
          v[M] = n(u.invert(f + A * x), l.invert(h + N * _), T);
    return { data: v, facets: i, channels: { [e]: { value: v, scale: "auto" } } };
  });
}
function yX(e) {
  if (typeof e == "function")
    return e;
  if (e == null)
    return fy;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return fy;
    case "nearest":
      return n4;
    case "barycentric":
      return e4();
    case "random-walk":
      return r4();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function fy(e, t, n, r, i, s) {
  const o = new Array(t * n);
  for (const a of e)
    r[a] < 0 || r[a] >= t || i[a] < 0 || i[a] >= n || (o[Math.floor(i[a]) * t + Math.floor(r[a])] = s[a]);
  return o;
}
function e4({ random: e = Tm(42) } = {}) {
  return (t, n, r, i, s, o) => {
    const { points: a, triangles: c, hull: u } = Xi.from(
      t,
      (d) => i[d],
      (d) => s[d]
    ), l = new o.constructor(n * r).fill(NaN), f = new Uint8Array(n * r), h = _X(o, e);
    for (let d = 0; d < c.length; d += 3) {
      const p = c[d], y = c[d + 1], g = c[d + 2], m = a[2 * p], b = a[2 * y], w = a[2 * g], v = a[2 * p + 1], x = a[2 * y + 1], _ = a[2 * g + 1], M = Math.min(m, b, w), T = Math.max(m, b, w), N = Math.min(v, x, _), A = Math.max(v, x, _), $ = (x - _) * (m - w) + (v - _) * (w - b);
      if (!$)
        continue;
      const D = o[t[p]], F = o[t[y]], S = o[t[g]];
      for (let I = Math.floor(M); I < T; ++I)
        for (let E = Math.floor(N); E < A; ++E) {
          if (I < 0 || I >= n || E < 0 || E >= r)
            continue;
          const O = I + 0.5, C = E + 0.5, B = ((x - _) * (O - w) + (C - _) * (w - b)) / $;
          if (B < 0)
            continue;
          const R = ((_ - v) * (O - w) + (C - _) * (m - w)) / $;
          if (R < 0)
            continue;
          const P = 1 - B - R;
          if (P < 0)
            continue;
          const U = I + n * E;
          l[U] = h(D, B, F, R, S, P, I, E), f[U] = 1;
        }
    }
    return mX(l, f, i, s, o, n, r, u, t, h), l;
  };
}
function mX(e, t, n, r, i, s, o, a, c, u) {
  n = Float64Array.from(a, (d) => n[c[d]]), r = Float64Array.from(a, (d) => r[c[d]]), i = Array.from(a, (d) => i[c[d]]);
  const l = n.length, f = Array.from({ length: l }, (d, p) => bX(p, n, r));
  let h = 0;
  for (let d = 0; d < o; ++d) {
    const p = d + 0.5;
    for (let y = 0; y < s; ++y) {
      const g = y + s * d;
      if (!t[g]) {
        const m = y + 0.5;
        for (let b = 0; b < l; ++b) {
          const w = (l + h + (b % 2 ? (b + 1) / 2 : -b / 2)) % l;
          if (f[w](m, p)) {
            const v = gX(n.at(w - 1), r.at(w - 1), n[w], r[w], m, p);
            e[g] = u(i.at(w - 1), v, i[w], 1 - v, i[w], 0, y, d), h = w;
            break;
          }
        }
      }
    }
  }
}
function gX(e, t, n, r, i, s) {
  const o = n - e, a = r - t, c = o * (n - i) + a * (r - s), u = o * (i - e) + a * (s - t);
  return c > 0 && u > 0 ? c / (c + u) : +(c > u);
}
function Va(e, t, n, r) {
  return e * r - n * t;
}
function bX(e, t, n) {
  const r = t.length, i = t.at(e - 2), s = n.at(e - 2), o = t.at(e - 1), a = n.at(e - 1), c = t[e], u = n[e], l = t.at(e + 1 - r), f = n.at(e + 1 - r), h = o - c, d = a - u, p = i - o, y = s - a, g = c - l, m = u - f, b = Math.hypot(h, d), w = Math.hypot(p, y), v = Math.hypot(g, m);
  return (x, _) => {
    const M = x - o, T = _ - a, N = x - c, A = _ - u;
    return Va(M, T, N, A) > -1e-6 && Va(M, T, h, d) * w - Va(M, T, p, y) * b > -1e-6 && Va(N, A, g, m) * b - Va(N, A, h, d) * v <= 0;
  };
}
function n4(e, t, n, r, i, s) {
  const o = new s.constructor(t * n), a = Xi.from(
    e,
    (l) => r[l],
    (l) => i[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 r4({ random: e = Tm(42), minDistance: t = 0.5, maxSteps: n = 2 } = {}) {
  return (r, i, s, o, a, c) => {
    const u = new c.constructor(i * s), l = Xi.from(
      r,
      (p) => o[p],
      (p) => a[p]
    );
    let f, h, d;
    for (let p = 0.5, y = 0; p < s; ++p) {
      h = f;
      for (let g = 0.5; g < i; ++g, ++y) {
        let m = g, b = p;
        d = h = l.find(m, b, h), g === 0.5 && (f = h);
        let w, v = 0;
        for (; (w = Math.hypot(o[r[d]] - m, a[r[d]] - b)) > t && v < n; ) {
          const x = e(g, p, v) * 2 * Math.PI;
          m += Math.cos(x) * w, b += Math.sin(x) * w, d = l.find(m, b, d), ++v;
        }
        u[y] = c[r[d]];
      }
    }
    return u;
  };
}
function wX(e, t, n, r, i, s) {
  return t * e + r * n + s * i;
}
function vX(e) {
  return (t, n, r, i, s, o, a, c) => {
    const u = e(a, c);
    return u < n ? t : u < n + i ? r : s;
  };
}
function _X(e, t) {
  return xo(e) || Pe(e) ? wX : vX(t);
}
function xX(e, t, n) {
  return {
    transform(r) {
      const i = r.length, s = new Float64Array(i), o = (t - e) / n, a = e + o / 2;
      for (let c = 0; c < i; ++c)
        s[c] = c % n * o + a;
      return s;
    }
  };
}
function SX(e, t, n, r) {
  return {
    transform(i) {
      const s = i.length, o = new Float64Array(s), a = (t - e) / r, c = e + a / 2;
      for (let u = 0; u < s; ++u)
        o[u] = Math.floor(u / n) % r * a + c;
      return o;
    }
  };
}
const x2 = {
  ariaLabel: "contour",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1,
  pixelSize: 2
};
class i4 extends J$ {
  constructor(t, { smooth: n = !0, value: r, ...i } = {}) {
    const s = zM({}, i, x2);
    if (r === void 0) {
      for (const a in s)
        if (s[a].value != null) {
          if (r !== void 0)
            throw new Error("ambiguous contour value");
          r = i[a], i[a] = "value";
        }
    }
    if (r != null) {
      const a = { transform: (c) => c.map((u) => u.value), label: Sr(r) };
      for (const c in s)
        i[c] === "value" && (i[c] = a);
    }
    if (t == null) {
      if (r == null)
        throw new Error("missing contour value");
      i = ly("value", { value: r, ...i }), r = null;
    } else {
      let { interpolate: a } = i;
      r === void 0 && (r = at), a === void 0 && (i.interpolate = "nearest");
    }
    super(t, { value: { value: r, optional: !0 } }, MX(i), x2);
    const o = { geometry: { value: at } };
    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: r, value: i, ...s }, o) {
    return super.filter(t, s, o);
  }
  render(t, n, r, i, s) {
    const { geometry: o } = r, a = Gi();
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, n).call((c) => {
      c.selectAll().data(t).enter().append("path").call(Jt, this).attr("d", (u) => a(o[u])).call(pe, this, r);
    }).node();
  }
}
function MX({ thresholds: e, interval: t, ...n }) {
  return e = _$(e, t, cm), Ke(n, function(r, i, s, o, a, c) {
    const [u, l, f, h] = t4(s, o, a, c), d = f - u, p = h - l, { pixelSize: y, width: g = Math.round(Math.abs(d) / y), height: m = Math.round(Math.abs(p) / y) } = this, b = g / d, w = m / p, v = s.value.value, x = [];
    if (this.interpolate) {
      const { x: A, y: $ } = pd(s, o, c), D = Gt(A, (E) => (E - u) * b, Float64Array), F = Gt($, (E) => (E - l) * w, Float64Array), S = [s.x, s.y, s.value], I = [D, F, v];
      for (const E of i) {
        const O = this.filter(E, S, I);
        x.push(this.interpolate(O, g, m, D, F, v));
      }
    } else if (i) {
      const A = g * m, $ = i.length;
      for (let D = 0; D < $; ++D)
        x.push(v.slice(D * A, D * A + A));
    } else
      x.push(v);
    if (this.blur > 0)
      for (const A of x)
        fx({ data: A, width: g, height: m }, this.blur);
    const _ = AX(e, v, ...IX(x));
    if (_ === null)
      throw new Error(`unsupported thresholds: ${e}`);
    const { contour: M } = vf().size([g, m]).smooth(this.smooth), T = [], N = [];
    for (const A of x)
      N.push(nn(T.length, T.push(...Gt(_, ($) => M(A, $)))));
    for (const { coordinates: A } of T)
      for (const $ of A)
        for (const D of $)
          for (const F of D)
            F[0] = F[0] / b + u, F[1] = F[1] / w + l;
    return {
      data: T,
      facets: N,
      channels: RM(this.contourChannels, T)
    };
  });
}
function AX(e, t, n, r) {
  if (typeof (e == null ? void 0 : e.range) == "function")
    return e.range(e.floor(n), r);
  if (typeof e == "function" && (e = e(t, n, r)), typeof e != "number")
    return Ze(e);
  const i = ki(...gx(n, r, e), e);
  for (; i[i.length - 1] >= r; )
    i.pop();
  for (; i[1] < n; )
    i.shift();
  return i;
}
function $X() {
  return new i4(...K$("value", ...arguments));
}
function IX(e) {
  return [be(e, (t) => be(t, S2)), Qt(e, (t) => Qt(t, S2))];
}
function S2(e) {
  return isFinite(e) ? e : NaN;
}
function TX(e, t) {
  return Gg(vg, e, t);
}
function EX(e, t = {}) {
  return Gg(_g, e, t);
}
function NX(e, t = {}) {
  return Gg(ah, e, t);
}
function Gg(e, t, n = {}) {
  const { x: r, y: i, maxRadius: s } = n, o = e({ px: r, py: i, maxRadius: s }), a = [];
  r != null && a.push(Pi(t, M2("x", { ...o, inset: -6 }, n))), i != null && a.push(Ui(t, M2("y", { ...o, inset: -6 }, n))), r != null && a.push(ca(t, A2("x", { ...o, dy: 9, frameAnchor: "bottom", lineAnchor: "top" }, n))), i != null && a.push(ca(t, A2("y", { ...o, dx: -9, frameAnchor: "left", textAnchor: "end" }, n)));
  for (const c of a)
    c.ariaLabel = `crosshair ${c.ariaLabel}`;
  return An(...a);
}
function s4(e, { channels: t, ...n }, { facet: r, facetAnchor: i, fx: s, fy: o, [e]: a, channels: c, transform: u, initializer: l }) {
  return {
    ...n,
    facet: r,
    facetAnchor: i,
    fx: s,
    fy: o,
    [e]: a,
    channels: { ...t, ...c },
    transform: u,
    initializer: DX(e, l)
  };
}
function DX(e, t) {
  return t == null ? t : function(n, r, { x: i, y: s, px: o, py: a, ...c }, ...u) {
    const { channels: { x: l, y: f, ...h } = {}, ...d } = t.call(this, n, r, { ...c, x: o, y: a }, ...u);
    return {
      channels: {
        ...h,
        ...l && { px: l, ...e === "x" && { x: l } },
        ...f && { py: f, ...e === "y" && { y: f } }
      },
      ...d
    };
  };
}
function M2(e, t, n) {
  const {
    color: r = "currentColor",
    opacity: i = 0.2,
    ruleStroke: s = r,
    ruleStrokeOpacity: o = i,
    ruleStrokeWidth: a
  } = n;
  return {
    ...s4(e, t, n),
    stroke: s,
    strokeOpacity: o,
    strokeWidth: a
  };
}
function A2(e, t, n) {
  const {
    color: r = "currentColor",
    textFill: i = r,
    textFillOpacity: s,
    textStroke: o = "var(--plot-background)",
    textStrokeOpacity: a,
    textStrokeWidth: c = 5
  } = n;
  return {
    ...s4(e, t, OX(e, n)),
    fill: i,
    fillOpacity: s,
    stroke: o,
    strokeOpacity: a,
    strokeWidth: c
  };
}
function OX(e, t) {
  return Ke(t, (n, r, i) => {
    var s;
    return { channels: { text: { value: (s = ty(i, e)) == null ? void 0 : s.value } } };
  });
}
const LX = {
  ariaLabel: "delaunay link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, kX = {
  ariaLabel: "delaunay mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
}, FX = {
  ariaLabel: "hull",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeMiterlimit: 1
}, RX = {
  ariaLabel: "voronoi",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, CX = {
  ariaLabel: "voronoi mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
};
class BX extends Xt {
  constructor(t, n = {}) {
    const { x: r, y: i, z: s, curve: o, tension: a } = n;
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        z: { value: s, optional: !0 }
      },
      n,
      LX
    ), this.curve = Dg(o, a), Sa(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = r, { curve: f } = this, [h, d] = Ar(this, i), p = c ? (b) => c[b] : un(h), y = u ? (b) => u[b] : un(d), g = this;
    function m(b) {
      let w = -1;
      const v = [], x = {};
      for (const S in r)
        x[S] = [];
      const _ = [], M = [], T = [], N = [];
      function A(S, I) {
        S = b[S], I = b[I], v.push(++w), _[w] = p(S), T[w] = y(S), M[w] = p(I), N[w] = y(I);
        for (const E in r)
          x[E].push(r[E][I]);
      }
      const { halfedges: $, hull: D, triangles: F } = Xi.from(b, p, y);
      for (let S = 0; S < $.length; ++S) {
        const I = $[S];
        I > S && A(F[S], F[I]);
      }
      for (let S = 0; S < D.length; ++S)
        A(D[S], D[(S + 1) % D.length]);
      Vt(this).selectAll().data(v).enter().append("path").call(Jt, g).attr("d", (S) => {
        const I = qr(), E = f(I);
        return E.lineStart(), E.point(_[S], T[S]), E.point(M[S], N[S]), E.lineEnd(), I;
      }).call(pe, g, x).call($u, g, x, s);
    }
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, { x: c && o, y: u && a }).call(
      l ? (b) => b.selectAll().data(ii(t, (w) => l[w]).values()).enter().append("g").each(m) : (b) => b.datum(t).each(m)
    ).node();
  }
}
class Hg extends Xt {
  constructor(t, n = {}, r, i = ({ 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: i(n), optional: !0 }
      },
      n,
      r
    );
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = r, [f, h] = Ar(this, i), d = c ? (m) => c[m] : un(f), p = u ? (m) => u[m] : un(h), y = this;
    function g(m) {
      const b = Xi.from(m, d, p);
      Vt(this).append("path").datum(m[0]).call(Jt, y).attr("d", y._render(b, i)).call(pe, y, r);
    }
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, { x: c && o, y: u && a }).call(
      l ? (m) => m.selectAll().data(ii(t, (b) => l[b]).values()).enter().append("g").each(g) : (m) => m.datum(t).each(g)
    ).node();
  }
}
class PX extends Hg {
  constructor(t, n = {}) {
    super(t, n, kX), this.fill = "none";
  }
  _render(t) {
    return t.render();
  }
}
class UX extends Hg {
  constructor(t, n = {}) {
    super(t, n, FX, Ji);
  }
  _render(t) {
    return t.renderHull();
  }
}
class zX extends Xt {
  constructor(t, n = {}) {
    const { x: r, y: i, z: s } = n;
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        z: { value: s, optional: !0 }
      },
      n,
      RX
    );
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = r, [f, h] = Ar(this, i), d = c ? (m) => c[m] : un(f), p = u ? (m) => u[m] : un(h), y = this;
    function g(m) {
      const b = Xi.from(m, d, p), w = o4(b, i);
      Vt(this).selectAll().data(m).enter().append("path").call(Jt, y).attr("d", (v, x) => w.renderCell(x)).call(pe, y, r);
    }
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, { x: c && o, y: u && a }).call(
      l ? (m) => m.selectAll().data(ii(t, (b) => l[b]).values()).enter().append("g").each(g) : (m) => m.datum(t).each(g)
    ).node();
  }
}
class jX extends Hg {
  constructor(t, n) {
    super(t, n, CX), this.fill = "none";
  }
  _render(t, n) {
    return o4(t, n).render();
  }
}
function o4(e, t) {
  const { width: n, height: r, marginTop: i, marginRight: s, marginBottom: o, marginLeft: a } = t;
  return e.voronoi([a, i, n - s, r - o]);
}
function Eu(e, t, { x: n, y: r, ...i } = {}) {
  return [n, r] = Wn(n, r), new e(t, { ...i, x: n, y: r });
}
function qX(e, t) {
  return Eu(BX, e, t);
}
function VX(e, t) {
  return Eu(PX, e, t);
}
function YX(e, t) {
  return Eu(UX, e, t);
}
function WX(e, t) {
  return Eu(zX, e, t);
}
function XX(e, t) {
  return Eu(jX, e, t);
}
const GX = {
  ariaLabel: "density",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class a4 extends Xt {
  constructor(t, { x: n, y: r, z: i, weight: s, fill: o, stroke: a, ...c } = {}) {
    const u = $2(o) && (o = "currentColor", !0), l = $2(a) && (a = "currentColor", !0);
    super(
      t,
      {
        x: { value: n, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        z: { value: Ji({ z: i, fill: o, stroke: a }), optional: !0 },
        weight: { value: s, optional: !0 }
      },
      ZX({ ...c, fill: o, stroke: a }, u, l),
      GX
    ), u && (this.fill = void 0), l && (this.stroke = void 0), this.z = i;
  }
  filter(t) {
    return t;
  }
  render(t, n, r, i, s) {
    const { contours: o } = r, a = Gi();
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, {}).call(
      (c) => c.selectAll().data(t).enter().append("path").call(Jt, this).call(pe, this, r).attr("d", (u) => a(o[u]))
    ).node();
  }
}
function HX(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Wn(t, n), new a4(e, { ...r, x: t, y: n });
}
const JX = /* @__PURE__ */ new Set(["x", "y", "z", "weight"]);
function ZX(e, t, n) {
  let { bandwidth: i, thresholds: s } = e;
  return i = i === void 0 ? 20 : +i, s = s === void 0 ? 20 : typeof (s == null ? void 0 : s[Symbol.iterator]) == "function" ? We(s) : +s, Ke(e, function(o, a, c, u, l, f) {
    var F;
    const h = c.weight ? We(c.weight.value) : null, d = (F = c.z) == null ? void 0 : F.value, { z: p } = this, [y, g] = Ar(this, l), { width: m, height: b } = l, { x: w, y: v } = pd(c, u, f), x = Object.fromEntries(
      Object.entries(c).filter(([S]) => !JX.has(S)).map(([S, I]) => [S, { ...I, value: [] }])
    ), _ = t && [], M = n && [], T = VC().x(w ? (S) => w[S] : y).y(v ? (S) => v[S] : g).weight(h ? (S) => h[S] : 1).size([m, b]).bandwidth(i), N = [];
    for (const S of a) {
      const I = [];
      N.push(I);
      for (const E of d ? fg(S, d, p) : [S]) {
        const O = T.contours(E);
        I.push([E, O]);
      }
    }
    let A = s;
    if (!(A instanceof sa)) {
      let S = 0;
      for (const I of N)
        for (const [, E] of I) {
          const O = E.max;
          O > S && (S = O);
        }
      A = Float64Array.from({ length: s - 1 }, (I, E) => S * 100 * (E + 1) / s);
    }
    const $ = [], D = [];
    for (const S of N) {
      const I = [];
      $.push(I);
      for (const [E, O] of S)
        for (const C of A) {
          I.push(D.length), D.push(O(C / 100)), _ && _.push(C), M && M.push(C);
          for (const B in x)
            x[B].value.push(c[B].value[E[0]]);
        }
    }
    return _ && _.push(0), M && M.push(0), {
      data: o,
      facets: $,
      channels: {
        ...x,
        ..._ && { fill: { value: _, scale: "color" } },
        ...M && { stroke: { value: M, scale: "color" } },
        contours: { value: D }
      }
    };
  });
}
function $2(e) {
  return /^density$/i.test(e);
}
function KX(e, {
  x1: t,
  x2: n,
  y1: r,
  y2: i,
  x: s = t === void 0 && n === void 0 ? ze : void 0,
  y: o = r === void 0 && i === void 0 ? at : void 0,
  fill: a,
  // ignored
  positiveFill: c = "#3ca951",
  negativeFill: u = "#4269d0",
  fillOpacity: l = 1,
  positiveFillOpacity: f = l,
  negativeFillOpacity: h = l,
  stroke: d,
  strokeOpacity: p,
  z: y = Be(d)[0],
  clip: g,
  // optional additional clip for area
  tip: m,
  render: b,
  ...w
} = {}) {
  return [t, n] = I2(s, t, n), [r, i] = I2(o, r, i), t === n && r === i && (r = hi(0)), { tip: m } = Js({ tip: m }, "x"), An(
    Kt(c) ? null : Object.assign(
      cy(e, {
        x1: t,
        x2: n,
        y1: r,
        y2: i,
        z: y,
        fill: c,
        fillOpacity: f,
        render: oh(b, T2(!0)),
        clip: g,
        ...w
      }),
      { ariaLabel: "positive difference" }
    ),
    Kt(u) ? null : Object.assign(
      cy(e, {
        x1: t,
        x2: n,
        y1: r,
        y2: i,
        z: y,
        fill: u,
        fillOpacity: h,
        render: oh(b, T2(!1)),
        clip: g,
        ...w
      }),
      { ariaLabel: "negative difference" }
    ),
    Td(e, {
      x: n,
      y: i,
      z: y,
      stroke: d,
      strokeOpacity: p,
      tip: m,
      clip: !0,
      ...w
    })
  );
}
function I2(e, t, n) {
  return t === void 0 && n === void 0 ? t = n = hi(e) : t === void 0 ? (n = hi(n), t = e === void 0 ? n : hi(e)) : n === void 0 ? (t = hi(t), n = e === void 0 ? t : hi(e)) : (t = hi(t), n = hi(n)), [t, n];
}
function hi(e) {
  let t;
  const { value: n, label: r = Sr(n) } = xa(e);
  return { transform: (i) => t || (t = At(i, n)), label: r };
}
function T2(e) {
  return (t, n, r, i, s, o) => {
    const { x1: a, x2: c } = r, { height: u } = i, l = new Float32Array(a.length), f = new Float32Array(c.length);
    (e === oA(n.y) < 0 ? l : f).fill(u);
    const h = o(t, n, { ...r, x2: a, y2: f }, i, s), d = o(t, n, { ...r, x1: c, y1: l }, i, s), p = h.querySelector("g") ?? h, y = d.querySelector("g") ?? d;
    for (let g = 0; p.firstChild; g += 2) {
      const m = ry(), b = Nt("svg:clipPath", s).attr("id", m).node();
      b.appendChild(p.firstChild), y.childNodes[g].setAttribute("clip-path", `url(#${m})`), y.insertBefore(b, y.childNodes[g]);
    }
    return d;
  };
}
const QX = {
  ariaLabel: "geo",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class c4 extends Xt {
  constructor(t, n = {}) {
    const [r, i] = ce(n.r, 3);
    super(
      t,
      {
        geometry: { value: n.geometry, scale: "projection" },
        r: { value: r, scale: "r", filter: Gr, optional: !0 }
      },
      jg(n),
      QX
    ), this.r = i;
  }
  render(t, n, r, i, s) {
    const { geometry: o, r: a } = r, c = Gi(s.projection ?? tG(n)), { r: u } = this;
    return id(u) ? t = [] : u !== void 0 && c.pointRadius(u), Nt("svg:g", s).call(te, this, i, s).call(Wt, this, n).call((l) => {
      l.selectAll().data(t).enter().append("path").call(Jt, this).attr("d", a ? (f) => c.pointRadius(a[f])(o[f]) : (f) => c(o[f])).call(pe, this, r);
    }).node();
  }
}
function tG({ x: e, y: t }) {
  if (e || t)
    return e ?? (e = (n) => n), t ?? (t = (n) => n), zf({
      point(n, r) {
        this.stream.point(e(n), t(r));
      }
    });
}
function Jg(e, { geometry: t = at, ...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 c4(e, { geometry: t, ...n });
}
function eG({ strokeWidth: e = 1.5, ...t } = {}) {
  return Jg({ type: "Sphere" }, { strokeWidth: e, ...t });
}
function nG({ strokeOpacity: e = 0.1, ...t } = {}) {
  return Jg(PB(), { strokeOpacity: e, ...t });
}
const uc = 0.5, lc = 0;
function rG(e = { fill: "count" }, { binWidth: t, ...n } = {}) {
  const { z: r } = n;
  return t = t === void 0 ? 20 : Et(t), e = DM(e, n), Mi(e, "fill") && (n.channels = { ...n.channels, fill: { value: [] } }), n.symbol === void 0 && (n.symbol = "hexagon"), n.r === void 0 && !Mi(e, "r") && (n.r = t / 2), Ke(n, (i, s, o, a, c, u) => {
    let { x: l, y: f, z: h, fill: d, stroke: p, symbol: y } = o;
    if (l === void 0)
      throw new Error("missing channel: x");
    if (f === void 0)
      throw new Error("missing channel: y");
    ({ x: l, y: f } = pd(o, a, u)), h = h ? h.value : At(i, r), d = d == null ? void 0 : d.value, p = p == null ? void 0 : p.value, y = y == null ? void 0 : y.value;
    const g = og(e, { z: h, fill: d, stroke: p, symbol: y }), m = h && [], b = d && [], w = p && [], v = y && [], x = [], _ = [], M = [];
    let T = -1;
    for (const D of e)
      D.initialize(i);
    for (const D of s) {
      const F = [];
      for (const S of e)
        S.scope("facet", D);
      for (const [S, I] of Fo(D, g))
        for (const { index: E, extent: O } of iG(i, I, l, f, t)) {
          F.push(++T), _.push(O.x), M.push(O.y), h && m.push(g === h ? S : h[E[0]]), d && b.push(g === d ? S : d[E[0]]), p && w.push(g === p ? S : p[E[0]]), y && v.push(g === y ? S : y[E[0]]);
          for (const C of e)
            C.reduce(E, O);
        }
      x.push(F);
    }
    const N = o.x.scale, A = o.y.scale, $ = {
      x: { value: _, source: a[N] ? { value: Gt(_, a[N].invert), scale: N } : null },
      y: { value: M, source: a[A] ? { value: Gt(M, a[A].invert), scale: A } : null },
      ...h && { z: { value: m } },
      ...d && { fill: { value: b, scale: "auto" } },
      ...p && { stroke: { value: w, scale: "auto" } },
      ...y && { symbol: { value: v, scale: "auto" } },
      ...Object.fromEntries(
        e.map(({ name: D, output: F }) => [
          D,
          {
            scale: "auto",
            label: F.label,
            radius: D === "r" ? t / 2 : void 0,
            value: F.transform()
          }
        ])
      )
    };
    return { data: i, facets: x, channels: $ };
  });
}
function iG(e, t, n, r, i) {
  const s = i * (1.5 / $M), o = /* @__PURE__ */ new Map();
  for (const a of t) {
    let c = n[a], u = r[a];
    if (isNaN(c) || isNaN(u))
      continue;
    let l = Math.round(u = (u - lc) / s), f = Math.round(c = (c - uc) / i - (l & 1) / 2), h = u - l;
    if (Math.abs(h) * 3 > 1) {
      let y = c - f, g = f + (c < f ? -1 : 1) / 2, m = l + (u < l ? -1 : 1), b = c - g, w = u - m;
      y * y + h * h > b * b + w * w && (f = g + (l & 1 ? 1 : -1) / 2, l = m);
    }
    const d = `${f},${l}`;
    let p = o.get(d);
    p === void 0 && (p = { index: [], extent: { data: e, x: (f + (l & 1) / 2) * i + uc, y: l * s + lc } }, o.set(d, p)), p.index.push(a);
  }
  return o.values();
}
const sG = {
  ariaLabel: "hexgrid",
  fill: "none",
  stroke: "currentColor",
  strokeOpacity: 0.1
};
function oG(e) {
  return new u4(e);
}
class u4 extends Xt {
  constructor({ binWidth: t = 20, clip: n = !0, ...r } = {}) {
    super(cc, void 0, { clip: n, ...r }, sG), this.binWidth = Et(t);
  }
  render(t, n, r, i, s) {
    const { binWidth: o } = this, { marginTop: a, marginRight: c, marginBottom: u, marginLeft: l, width: f, height: h } = i, d = l - uc, p = f - c - uc, y = a - lc, g = h - u - lc, m = o / 2, b = m * IM, w = b / 2, v = m * 2, x = b * 1.5, _ = Math.floor(d / v), M = Math.ceil(p / v), T = Math.floor((y + w) / x), N = Math.ceil((g - w) / x) + 1, A = `m0,${li(-b)}l${li(m)},${li(w)}v${li(b)}l${li(-m)},${li(w)}`;
    let $ = A;
    for (let D = T; D < N; ++D)
      for (let F = _; F < M; ++F)
        $ += `M${li(F * v + (D & 1) * m)},${li(D * x)}${A}`;
    return Nt("svg:g", s).datum(0).call(te, this, i, s).call(Wt, this, {}, xe + uc, xe + lc).call((D) => D.append("path").call(Jt, this).call(pe, this, r).attr("d", $)).node();
  }
}
function li(e) {
  return Math.round(e * 1e3) / 1e3;
}
const aG = {
  ariaLabel: "image",
  fill: null,
  stroke: null
};
function cG(e) {
  return /^\.*\//.test(e);
}
function uG(e) {
  return /^(blob|data|file|http|https):/i.test(e);
}
function lG(e) {
  return typeof e == "string" && (cG(e) || uG(e)) ? [void 0, e] : [e, void 0];
}
class l4 extends Xt {
  constructor(t, n = {}) {
    let { x: r, y: i, r: s, width: o, height: a, rotate: c, src: u, preserveAspectRatio: l, crossOrigin: f, frameAnchor: h, imageRendering: d } = n;
    s == null && (s = void 0), s === void 0 && o === void 0 && a === void 0 ? o = a = 16 : o === void 0 && a !== void 0 ? o = a : a === void 0 && o !== void 0 && (a = o);
    const [p, y] = lG(u), [g, m] = ce(s), [b, w] = ce(o, m !== void 0 ? m * 2 : void 0), [v, x] = ce(a, m !== void 0 ? m * 2 : void 0), [_, M] = ce(c, 0);
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        r: { value: g, scale: "r", filter: Gr, optional: !0 },
        width: { value: b, filter: Gr, optional: !0 },
        height: { value: v, filter: Gr, optional: !0 },
        rotate: { value: _, optional: !0 },
        src: { value: p, optional: !0 }
      },
      jg(n),
      aG
    ), this.src = y, this.width = w, this.rotate = M, this.height = x, this.r = m, this.preserveAspectRatio = se(l, "xMidYMid"), this.crossOrigin = Te(f), this.frameAnchor = vu(h), this.imageRendering = se(d, "auto");
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, width: l, height: f, r: h, rotate: d, src: p } = r, { r: y, width: g, height: m, rotate: b } = this, [w, v] = Ar(this, i);
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, { x: c && o, y: u && a }).call(
      (x) => x.selectAll().data(t).enter().append("image").call(Jt, this).attr("x", E2(c, l, h, w, g, y)).attr("y", E2(u, f, h, v, m, y)).attr("width", l ? (_) => l[_] : g !== void 0 ? g : h ? (_) => h[_] * 2 : y * 2).attr("height", f ? (_) => f[_] : m !== void 0 ? m : h ? (_) => h[_] * 2 : y * 2).attr("transform", d ? (_) => `rotate(${d[_]})` : b ? `rotate(${b})` : null).attr("transform-origin", d || b ? wd`${c ? (_) => c[_] : w}px ${u ? (_) => u[_] : v}px` : null).call(et, "href", p ? (_) => p[_] : this.src).call(et, "preserveAspectRatio", this.preserveAspectRatio).call(et, "crossorigin", this.crossOrigin).call(et, "image-rendering", this.imageRendering).call(et, "clip-path", h ? (_) => `circle(${h[_]}px)` : y !== void 0 ? `circle(${y}px)` : null).call(pe, this, r)
    ).node();
  }
}
function E2(e, t, n, r, i, s) {
  return t && e ? (o) => e[o] - t[o] / 2 : t ? (o) => r - t[o] / 2 : e && i !== void 0 ? (o) => e[o] - i / 2 : i !== void 0 ? r - i / 2 : n && e ? (o) => e[o] - n[o] : n ? (o) => r - n[o] : e ? (o) => e[o] - s : r - s;
}
function fG(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Wn(t, n)), new l4(e, { ...r, x: t, y: n });
}
function hG(e, t, n) {
  var r = 1e-8, i = t - 1, s = n - 1, o = 0, a, c, u, l, f, h, d, p, y, g, 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, y = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), g = d * Math.sqrt(p + y) / y - (1 / (2 * n - 1) - 1 / (2 * t - 1)) * (p + 5 / 6 - 2 / (3 * y)), d = t / (t + n * Math.exp(2 * g))) : (a = Math.log(t / (t + n)), c = Math.log(n / (t + n)), l = Math.exp(t * a) / t, f = Math.exp(n * c) / n, g = l + f, e < l / g ? d = Math.pow(t * g * e, 1 / t) : d = 1 - Math.pow(n * g * (1 - e), 1 / n)), m = -Co(t) - Co(n) + Co(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = dG(d, t, n) - e, l = Math.exp(i * Math.log(d) + s * Math.log(1 - d) + m), f = h / l, d -= l = f / (1 - 0.5 * Math.min(1, f * (i / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + l)), d >= 1 && (d = 0.5 * (d + l + 1)), Math.abs(l) < r * d && o > 0)
      break;
  }
  return d;
}
function dG(e, t, n) {
  var r = e === 0 || e === 1 ? 0 : Math.exp(Co(t + n) - Co(t) - Co(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? r * N2(e, t, n) / t : 1 - r * N2(1 - e, n, t) / n;
}
function N2(e, t, n) {
  var r = 1e-30, i = 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) < r && (u = r), u = 1 / u, d = u; i <= 100 && (l = 2 * i, f = i * (n - i) * e / ((a + l) * (t + l)), u = 1 + f * u, Math.abs(u) < r && (u = r), c = 1 + f / c, Math.abs(c) < r && (c = r), u = 1 / u, d *= u * c, f = -(t + i) * (s + i) * e / ((t + l) * (o + l)), u = 1 + f * u, Math.abs(u) < r && (u = r), c = 1 + f / c, Math.abs(c) < r && (c = r), u = 1 / u, h = u * c, d *= h, !(Math.abs(h - 1) < 3e-7)); i++)
    ;
  return d;
}
function Co(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], r = 1.000000000190015, i, s, o;
  for (o = (s = i = e) + 5.5, o -= (i + 0.5) * Math.log(o); t < 6; t++)
    r += n[t] / ++s;
  return Math.log(2.506628274631 * r / i) - o;
}
function pG(e, t) {
  var n = hG(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 yG = {
  ariaLabel: "linear-regression",
  fill: "currentColor",
  fillOpacity: 0.1,
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class f4 extends Xt {
  constructor(t, n = {}) {
    const { x: r, y: i, z: s, ci: o = 0.95, precision: a = 4 } = n;
    if (super(
      t,
      {
        x: { value: r, scale: "x" },
        y: { value: i, scale: "y" },
        z: { value: Ji(n), optional: !0 }
      },
      n,
      yG
    ), 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, r, i, s) {
    const { x: o, y: a, z: c } = r, { ci: u } = this;
    return Nt("svg:g", s).call(te, this, i, s).call(Wt, this, n).call(
      (l) => l.selectAll().data(c ? fg(t, c, this.z) : [t]).enter().call(
        (f) => f.append("path").attr("fill", "none").call(Jt, this).call(sh, this, { ...r, fill: null, fillOpacity: null }).attr("d", (h) => this._renderLine(h, o, a)).call(
          u && !oa(this.fill) ? (h) => h.select(mG).attr("stroke", "none").call(Jt, this).call(sh, this, {
            ...r,
            stroke: null,
            strokeOpacity: null,
            strokeWidth: null
          }).attr("d", (d) => this._renderBand(d, o, a)) : () => {
          }
        )
      )
    ).node();
  }
}
function mG() {
  return this.parentNode.insertBefore(this.ownerDocument.createElementNS(Rs.svg, "path"), this);
}
class gG extends f4 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, r) {
    const { ci: i, precision: s } = this, [o, a] = fe(t, (l) => r[l]), c = yh(t, r, n), u = h4(t, r, n, (1 - i) / 2, c);
    return km().y((l) => l).x0((l) => u(l, -1)).x1((l) => u(l, 1))(nn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, r) {
    const [i, s] = fe(t, (a) => r[a]), o = yh(t, r, n);
    return `M${o(i)},${i}L${o(s)},${s}`;
  }
}
class bG extends f4 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, r) {
    const { ci: i, precision: s } = this, [o, a] = fe(t, (l) => n[l]), c = yh(t, n, r), u = h4(t, n, r, (1 - i) / 2, c);
    return km().x((l) => l).y0((l) => u(l, -1)).y1((l) => u(l, 1))(nn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, r) {
    const [i, s] = fe(t, (a) => n[a]), o = yh(t, n, r);
    return `M${i},${o(i)}L${s},${o(s)}`;
  }
}
function wG(e, { y: t = ze, x: n = at, stroke: r, fill: i = Kt(r) ? "currentColor" : r, ...s } = {}) {
  return new gG(e, Lg({ ...s, x: n, y: t, fill: i, stroke: r }));
}
function vG(e, { x: t = ze, y: n = at, stroke: r, fill: i = Kt(r) ? "currentColor" : r, ...s } = {}) {
  return new bG(e, Og({ ...s, x: t, y: n, fill: i, stroke: r }));
}
function yh(e, t, n) {
  let r = 0, i = 0, s = 0, o = 0;
  for (const l of e) {
    const f = t[l], h = n[l];
    r += f, i += h, s += f * h, o += f * f;
  }
  const a = e.length, c = (a * s - r * i) / (a * o - r * r), u = (i - c * r) / a;
  return (l) => c * l + u;
}
function h4(e, t, n, r, i) {
  const s = gr(e, (l) => t[l]) / e.length;
  let o = 0, a = 0;
  for (const l of e)
    o += (t[l] - s) ** 2, a += (n[l] - i(t[l])) ** 2;
  const c = Math.sqrt(a / (e.length - 2)), u = pG(r, e.length - 2);
  return (l, f) => {
    const h = i(l), d = c * Math.sqrt(1 / e.length + (l - s) ** 2 / o);
    return h + f * u * d;
  };
}
function hy({
  path: e = at,
  // the delimited path
  delimiter: t,
  // how the path is separated
  frameAnchor: n,
  treeLayout: r = Yf,
  treeSort: i,
  treeSeparation: s,
  treeAnchor: o,
  treeFilter: a,
  ...c
} = {}) {
  o = Zg(o), i = p4(i), a != null && (a = py(a)), n === void 0 && (n = o.frameAnchor);
  const u = y4(t), l = x4(c, py), [f, h] = sn(), [d, p] = sn();
  return {
    x: f,
    y: d,
    frameAnchor: n,
    ...Mr(c, (y, g) => {
      const m = u(At(y, e)), b = h([]), w = p([]);
      let v = -1;
      const x = [], _ = [], M = GS().path((N) => m[N]), T = r();
      T.nodeSize && T.nodeSize([1, 1]), T.separation && s !== void 0 && T.separation(s ?? Ym);
      for (const N of l)
        N[mh] = N[v4]([]);
      for (const N of g) {
        const A = [], $ = M(N.filter((D) => m[D] != null)).each((D) => D.data = y[D.data]);
        i != null && $.sort(i), T($);
        for (const D of $.descendants())
          if (!(a != null && !a(D))) {
            A.push(++v), x[v] = D.data, o.position(D, v, b, w);
            for (const F of l)
              F[mh][v] = F[_4](D);
          }
        _.push(A);
      }
      return { data: x, facets: _ };
    }),
    ...Object.fromEntries(l)
  };
}
function d4({
  path: e = at,
  // the delimited path
  delimiter: t,
  // how the path is separated
  curve: n = "bump-x",
  stroke: r = "#555",
  strokeWidth: i = 1.5,
  strokeOpacity: s = 0.5,
  treeLayout: o = Yf,
  treeSort: a,
  treeSeparation: c,
  treeAnchor: u,
  treeFilter: l,
  ...f
} = {}) {
  u = Zg(u), a = p4(a), l != null && (l = O2(l)), f = { curve: n, stroke: r, strokeWidth: i, strokeOpacity: s, ...f };
  const h = y4(t), d = x4(f, O2), [p, y] = sn(), [g, m] = sn(), [b, w] = sn(), [v, x] = sn();
  return {
    x1: p,
    x2: g,
    y1: b,
    y2: v,
    ...Mr(f, (_, M) => {
      const T = h(At(_, e)), N = y([]), A = m([]), $ = w([]), D = x([]);
      let F = -1;
      const S = [], I = [], E = GS().path((C) => T[C]), O = o();
      O.nodeSize && O.nodeSize([1, 1]), O.separation && c !== void 0 && O.separation(c ?? Ym);
      for (const C of d)
        C[mh] = C[v4]([]);
      for (const C of M) {
        const B = [], R = E(C.filter((P) => T[P] != null)).each((P) => P.data = _[P.data]);
        a != null && R.sort(a), O(R);
        for (const { source: P, target: U } of R.links())
          if (!(l != null && !l(U, P))) {
            B.push(++F), S[F] = U.data, u.position(P, F, N, $), u.position(U, F, A, D);
            for (const Y of d)
              Y[mh][F] = Y[_4](U, P);
          }
        I.push(B);
      }
      return { data: S, facets: I };
    }),
    ...Object.fromEntries(d)
  };
}
function Zg(e = "left") {
  switch (`${e}`.trim().toLowerCase()) {
    case "left":
      return _G;
    case "right":
      return xG;
  }
  throw new Error(`invalid tree anchor: ${e}`);
}
const _G = {
  frameAnchor: "left",
  dx: 6,
  position({ x: e, y: t }, n, r, i) {
    r[n] = t, i[n] = -e;
  }
}, xG = {
  frameAnchor: "right",
  dx: -6,
  position({ x: e, y: t }, n, r, i) {
    r[n] = -t, i[n] = -e;
  }
};
function p4(e) {
  return e == null || typeof e == "function" ? e : `${e}`.trim().toLowerCase().startsWith("node:") ? D2(py(e)) : D2(SG(e));
}
function D2(e) {
  return (t, n) => Mn(e(t), e(n));
}
function SG(e) {
  return (t) => {
    var n;
    return (n = t.data) == null ? void 0 : n[e];
  };
}
function y4(e = "/") {
  if (e = `${e}`, e === "/")
    return (n) => n;
  if (e.length !== 1)
    throw new Error("delimiter must be exactly one character");
  const t = e.charCodeAt(0);
  return (n) => n.map((r) => MG(r, t));
}
const dy = 92, m4 = 47;
function MG(e, t) {
  if (t === dy)
    throw new Error("delimiter cannot be backslash");
  let n = !1;
  for (let r = 0, i = e.length; r < i; ++r) {
    switch (e.charCodeAt(r)) {
      case dy:
        if (!n) {
          n = !0;
          continue;
        }
        break;
      case t:
        n ? (e = e.slice(0, r - 1) + e.slice(r), --r, --i) : e = e.slice(0, r) + "/" + e.slice(r + 1);
        break;
      case m4:
        n ? (e = e.slice(0, r) + "\\\\" + e.slice(r), r += 2, i += 2) : (e = e.slice(0, r) + "\\" + e.slice(r), ++r, ++i);
        break;
    }
    n = !1;
  }
  return e;
}
function AG(e) {
  let t = !1;
  for (let n = 0, r = e.length; n < r; ++n) {
    switch (e.charCodeAt(n)) {
      case dy:
        if (!t) {
          t = !0;
          continue;
        }
      case m4:
        t && (e = e.slice(0, n - 1) + e.slice(n), --n, --r);
        break;
    }
    t = !1;
  }
  return e;
}
function g4(e) {
  return $n(e) && typeof e.node == "function";
}
function $G(e) {
  return $n(e) && typeof e.link == "function";
}
function py(e) {
  if (g4(e))
    return e.node;
  if (e = `${e}`.trim().toLowerCase(), !!e.startsWith("node:")) {
    switch (e) {
      case "node:name":
        return my;
      case "node:path":
        return yy;
      case "node:internal":
        return b4;
      case "node:external":
        return w4;
      case "node:depth":
        return gy;
      case "node:height":
        return by;
    }
    throw new Error(`invalid node value: ${e}`);
  }
}
function O2(e) {
  if (g4(e))
    return e.node;
  if ($G(e))
    return e.link;
  if (e = `${e}`.trim().toLowerCase(), !(!e.startsWith("node:") && !e.startsWith("parent:"))) {
    switch (e) {
      case "parent:name":
        return hl(my);
      case "parent:path":
        return hl(yy);
      case "parent:depth":
        return hl(gy);
      case "parent:height":
        return hl(by);
      case "node:name":
        return my;
      case "node:path":
        return yy;
      case "node:internal":
        return b4;
      case "node:external":
        return w4;
      case "node:depth":
        return gy;
      case "node:height":
        return by;
    }
    throw new Error(`invalid link value: ${e}`);
  }
}
function yy(e) {
  return e.id;
}
function my(e) {
  return IG(e.id);
}
function gy(e) {
  return e.depth;
}
function by(e) {
  return e.height;
}
function b4(e) {
  return !!e.children;
}
function w4(e) {
  return !e.children;
}
function hl(e) {
  return (t, n) => n == null ? void 0 : e(n);
}
function IG(e) {
  let t = e.length;
  for (; --t > 0 && !TG(e, t); )
    ;
  return AG(e.slice(t + 1));
}
function TG(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
const v4 = 2, _4 = 3, mh = 4;
function x4(e, t) {
  const n = [];
  for (const r in e) {
    const i = e[r], s = t(i);
    s !== void 0 && n.push([r, ...sn(i), s]);
  }
  return n;
}
function S4(e, {
  fill: t,
  stroke: n,
  strokeWidth: r,
  strokeOpacity: i,
  strokeLinejoin: s,
  strokeLinecap: o,
  strokeMiterlimit: a,
  strokeDasharray: c,
  strokeDashoffset: u,
  marker: l,
  markerStart: f = l,
  markerEnd: h = l,
  dot: d = Kt(f) && Kt(h),
  text: p = "node:name",
  textStroke: y = "var(--plot-background)",
  title: g = "node:path",
  dx: m,
  dy: b,
  textAnchor: w,
  treeLayout: v = Yf,
  textLayout: x = v === Yf || v === YS ? "mirrored" : "normal",
  tip: _,
  ...M
} = {}) {
  if (m === void 0 && (m = Zg(M.treeAnchor).dx), w !== void 0)
    throw new Error("textAnchor is not a configurable tree option");
  x = ln(x, "textLayout", ["mirrored", "normal"]);
  function T(N) {
    return ca(
      e,
      hy({
        treeLayout: v,
        text: p,
        fill: t === void 0 ? "currentColor" : t,
        stroke: y,
        dx: m,
        dy: b,
        title: g,
        ...N,
        ...M
      })
    );
  }
  return An(
    L$(
      e,
      d4({
        treeLayout: v,
        markerStart: f,
        markerEnd: h,
        stroke: n !== void 0 ? n : t === void 0 ? "node:internal" : t,
        strokeWidth: r,
        strokeOpacity: i,
        strokeLinejoin: s,
        strokeLinecap: o,
        strokeMiterlimit: a,
        strokeDasharray: c,
        strokeDashoffset: u,
        ...M
      })
    ),
    d ? Qi(e, hy({ treeLayout: v, fill: t === void 0 ? "node:internal" : t, title: g, tip: _, ...M })) : null,
    p != null ? x === "mirrored" ? [
      T({ textAnchor: "start", treeFilter: "node:external" }),
      T({ textAnchor: "end", treeFilter: "node:internal", dx: -m })
    ] : T() : null
  );
}
function EG(e, t) {
  return S4(e, { ...t, treeLayout: YS });
}
function NG({ geometry: e = at, ...t } = {}) {
  return Ke({ ...t, x: null, y: null }, (n, r, i, s, o, { projection: a }) => {
    const c = At(n, e), u = c.length, l = new Float64Array(u), f = new Float64Array(u), h = Gi(a);
    for (let d = 0; d < u; ++d)
      [l[d], f[d]] = h.centroid(c[d]);
    return {
      data: n,
      facets: r,
      channels: {
        x: { value: l, scale: a == null ? "x" : null, source: null },
        y: { value: f, scale: a == null ? "y" : null, source: null }
      }
    };
  });
}
function DG({ geometry: e = at, ...t } = {}) {
  let n;
  return {
    ...t,
    x: { transform: (r) => Float64Array.from(n = At(At(r, e), IB), ([i]) => i) },
    y: { transform: () => Float64Array.from(n, ([, r]) => r) }
  };
}
function OG(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function LG(e, t, n, r, i) {
  for (var s = i + 1; r <= i; ) {
    var o = r + i >>> 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 kG(e, t, n, r, i) {
  for (var s = i + 1; r <= i; ) {
    var o = r + i >>> 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 FG(e, t, n, r, i) {
  for (var s = r - 1; r <= i; ) {
    var o = r + i >>> 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 RG(e, t, n, r, i) {
  for (var s = r - 1; r <= i; ) {
    var o = r + i >>> 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 CG(e, t, n, r, i) {
  for (; r <= i; ) {
    var s = r + i >>> 1, o = e[s], a = n !== void 0 ? n(o, t) : o - t;
    if (a === 0)
      return s;
    a <= 0 ? r = s + 1 : i = s - 1;
  }
  return -1;
}
function Ya(e, t, n, r, i, s) {
  return typeof n == "function" ? s(e, t, n, r === void 0 ? 0 : r | 0, i === void 0 ? e.length - 1 : i | 0) : s(e, t, void 0, n === void 0 ? 0 : n | 0, r === void 0 ? e.length - 1 : r | 0);
}
var BG = {
  ge: function(e, t, n, r, i) {
    return Ya(e, t, n, r, i, LG);
  },
  gt: function(e, t, n, r, i) {
    return Ya(e, t, n, r, i, kG);
  },
  lt: function(e, t, n, r, i) {
    return Ya(e, t, n, r, i, FG);
  },
  le: function(e, t, n, r, i) {
    return Ya(e, t, n, r, i, RG);
  },
  eq: function(e, t, n, r, i) {
    return Ya(e, t, n, r, i, CG);
  }
}, gh = BG, Mo = 0, cs = 1, Dl = 2, PG = zG;
function Kg(e, t, n, r, i) {
  this.mid = e, this.left = t, this.right = n, this.leftPoints = r, this.rightPoints = i, this.count = (t ? t.count : 0) + (n ? n.count : 0) + r.length;
}
var Nu = Kg.prototype;
function Bp(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 M4(e, t) {
  var n = ha(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 L2(e, t) {
  var n = e.intervals([]);
  n.push(t), M4(e, n);
}
function k2(e, t) {
  var n = e.intervals([]), r = n.indexOf(t);
  return r < 0 ? Mo : (n.splice(r, 1), M4(e, n), cs);
}
Nu.intervals = function(e) {
  return e.push.apply(e, this.leftPoints), this.left && this.left.intervals(e), this.right && this.right.intervals(e), e;
};
Nu.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) ? L2(this, e) : this.left.insert(e) : this.left = ha([e]);
  else if (e[0] > this.mid)
    this.right ? 4 * (this.right.count + 1) > 3 * (t + 1) ? L2(this, e) : this.right.insert(e) : this.right = ha([e]);
  else {
    var n = gh.ge(this.leftPoints, e, Qg), r = gh.ge(this.rightPoints, e, t1);
    this.leftPoints.splice(n, 0, e), this.rightPoints.splice(r, 0, e);
  }
};
Nu.remove = function(e) {
  var t = this.count - this.leftPoints;
  if (e[1] < this.mid) {
    if (!this.left)
      return Mo;
    var n = this.right ? this.right.count : 0;
    if (4 * n > 3 * (t - 1))
      return k2(this, e);
    var r = this.left.remove(e);
    return r === Dl ? (this.left = null, this.count -= 1, cs) : (r === cs && (this.count -= 1), r);
  } else if (e[0] > this.mid) {
    if (!this.right)
      return Mo;
    var i = this.left ? this.left.count : 0;
    if (4 * i > 3 * (t - 1))
      return k2(this, e);
    var r = this.right.remove(e);
    return r === Dl ? (this.right = null, this.count -= 1, cs) : (r === cs && (this.count -= 1), r);
  } else {
    if (this.count === 1)
      return this.leftPoints[0] === e ? Dl : Mo;
    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, r = this.right;
          s.count -= o.count, s.right = o.left, o.left = a, o.right = r;
        }
        Bp(this, o), this.count = (this.left ? this.left.count : 0) + (this.right ? this.right.count : 0) + this.leftPoints.length;
      } else
        this.left ? Bp(this, this.left) : Bp(this, this.right);
      return cs;
    }
    for (var a = gh.ge(this.leftPoints, e, Qg); 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 r = gh.ge(this.rightPoints, e, t1); r < this.rightPoints.length && this.rightPoints[r][1] === e[1]; ++r)
          if (this.rightPoints[r] === e)
            return this.rightPoints.splice(r, 1), cs;
      }
    return Mo;
  }
};
function A4(e, t, n) {
  for (var r = 0; r < e.length && e[r][0] <= t; ++r) {
    var i = n(e[r]);
    if (i)
      return i;
  }
}
function $4(e, t, n) {
  for (var r = e.length - 1; r >= 0 && e[r][1] >= t; --r) {
    var i = n(e[r]);
    if (i)
      return i;
  }
}
function I4(e, t) {
  for (var n = 0; n < e.length; ++n) {
    var r = t(e[n]);
    if (r)
      return r;
  }
}
Nu.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 $4(this.rightPoints, e, t);
  } else
    return I4(this.leftPoints, t);
};
Nu.queryInterval = function(e, t, n) {
  if (e < this.mid && this.left) {
    var r = this.left.queryInterval(e, t, n);
    if (r)
      return r;
  }
  if (t > this.mid && this.right) {
    var r = this.right.queryInterval(e, t, n);
    if (r)
      return r;
  }
  return t < this.mid ? A4(this.leftPoints, t, n) : e > this.mid ? $4(this.rightPoints, e, n) : I4(this.leftPoints, n);
};
function UG(e, t) {
  return e - t;
}
function Qg(e, t) {
  var n = e[0] - t[0];
  return n || e[1] - t[1];
}
function t1(e, t) {
  var n = e[1] - t[1];
  return n || e[0] - t[0];
}
function ha(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(UG);
  for (var r = t[t.length >> 1], i = [], s = [], o = [], n = 0; n < e.length; ++n) {
    var a = e[n];
    a[1] < r ? i.push(a) : r < a[0] ? s.push(a) : o.push(a);
  }
  var c = o, u = o.slice();
  return c.sort(Qg), u.sort(t1), new Kg(
    r,
    ha(i),
    ha(s),
    c,
    u
  );
}
function wy(e) {
  this.root = e;
}
var Ta = wy.prototype;
Ta.insert = function(e) {
  this.root ? this.root.insert(e) : this.root = new Kg(e[0], null, null, [e], [e]);
};
Ta.remove = function(e) {
  if (this.root) {
    var t = this.root.remove(e);
    return t === Dl && (this.root = null), t !== Mo;
  }
  return !1;
};
Ta.queryPoint = function(e, t) {
  if (this.root)
    return this.root.queryPoint(e, t);
};
Ta.queryInterval = function(e, t, n) {
  if (e <= t && this.root)
    return this.root.queryInterval(e, t, n);
};
Object.defineProperty(Ta, "count", {
  get: function() {
    return this.root ? this.root.count : 0;
  }
});
Object.defineProperty(Ta, "intervals", {
  get: function() {
    return this.root ? this.root.intervals([]) : [];
  }
});
function zG(e) {
  return !e || e.length === 0 ? new wy(null) : new wy(ha(e));
}
const jG = /* @__PURE__ */ OG(PG), qG = ({ marginLeft: e }) => [1, e], VG = ({ width: e, marginRight: t }) => [-1, e - t], YG = ({ width: e, marginLeft: t, marginRight: n }) => [0, (t + e - n) / 2], WG = ({ marginTop: e }) => [1, e], XG = ({ height: e, marginBottom: t }) => [-1, e - t], GG = ({ height: e, marginTop: t, marginBottom: n }) => [0, (t + e - n) / 2];
function T4(e) {
  return typeof e == "string" ? { anchor: e } : e;
}
function HG(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = E4(e));
  let { anchor: n = "left", padding: r = 1, r: i = t.r } = T4(e);
  switch (`${n}`.toLowerCase()) {
    case "left":
      n = qG;
      break;
    case "right":
      n = VG;
      break;
    case "middle":
      n = YG;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return N4("x", "y", n, Et(r), i, t);
}
function JG(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = E4(e));
  let { anchor: n = "bottom", padding: r = 1, r: i = t.r } = T4(e);
  switch (`${n}`.toLowerCase()) {
    case "top":
      n = WG;
      break;
    case "bottom":
      n = XG;
      break;
    case "middle":
      n = GG;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return N4("y", "x", n, Et(r), i, t);
}
function E4(e) {
  const { anchor: t, padding: n, ...r } = e, { r: i } = r;
  return [{ anchor: t, padding: n, r: i }, r];
}
function N4(e, t, n, r, i, s) {
  if (i != null && typeof i != "number") {
    let { channels: o, sort: a, reverse: c } = s;
    o = Hm(o), (o == null ? void 0 : o.r) === void 0 && (s = { ...s, channels: { ...o, r: { value: i, scale: "r" } } }), a === void 0 && c === void 0 && (s.sort = { channel: "-r" });
  }
  return Ke(s, function(o, a, c, u, l, f) {
    let { [t]: h, r: d } = c;
    if (!c[t])
      throw new Error(`missing channel: ${t}`);
    ({ [t]: h } = pd(c, u, f));
    const p = d ? void 0 : i !== void 0 ? Et(i) : this.r !== void 0 ? this.r : 3;
    d && (d = At(d.value, u[d.scale] || at, Float64Array));
    let [y, g] = n(l);
    const m = y ? KG : ZG, b = new Float64Array(h.length), w = d ? (v) => d[v] : () => p;
    for (let v of a) {
      const x = jG();
      v = v.filter(d ? (M) => eh(h[M]) && Gr(d[M]) : (M) => eh(h[M]));
      const _ = new Float64Array(2 * v.length + 2);
      for (const M of v) {
        const T = w(M), N = y ? T + r : 0, A = h[M] - T, $ = h[M] + T;
        let D = 2;
        x.queryInterval(A - r, $ + r, ([, , S]) => {
          const I = b[S] - N, E = h[M] - h[S], O = r + (d ? d[M] + d[S] : 2 * p), C = Math.sqrt(O * O - E * E);
          _[D++] = I - C, _[D++] = I + C;
        });
        let F = _.slice(0, D);
        y && (F = F.filter((S) => S >= 0));
        t:
          for (const S of F.sort(m)) {
            for (let I = 0; I < D; I += 2)
              if (_[I] + 1e-6 < S && S < _[I + 1] - 1e-6)
                continue t;
            b[M] = S + N;
            break;
          }
        x.insert([A, $, M]);
      }
    }
    y || (y = 1);
    for (const v of a)
      for (const x of v)
        b[x] = b[x] * y + g;
    return {
      data: o,
      facets: a,
      channels: {
        [e]: { value: b, source: null },
        // don’t show in tooltip
        [t]: { value: h, source: c[t] },
        ...d && { r: { value: d, source: c.r } }
      }
    };
  });
}
function ZG(e, t) {
  return Math.abs(e) - Math.abs(t);
}
function KG(e, t) {
  return e - t;
}
function QG(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), Vg(e1(e), t);
}
function tH(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), Yg(e1(e), t);
}
function e1(e) {
  if (e === void 0)
    return F2;
  if (typeof e == "function")
    return Dd(Gm(e));
  if (/^p\d{2}$/i.test(e))
    return Ea(Wm(e));
  switch (`${e}`.toLowerCase()) {
    case "deviation":
      return rH;
    case "first":
      return F2;
    case "last":
      return nH;
    case "max":
      return iH;
    case "mean":
      return sH;
    case "median":
      return oH;
    case "min":
      return aH;
    case "sum":
      return cH;
    case "extent":
      return eH;
  }
  throw new Error(`invalid basis: ${e}`);
}
function Dd(e) {
  return {
    mapIndex(t, n, r) {
      const i = +e(t, n);
      for (const s of t)
        r[s] = n[s] === null ? NaN : n[s] / i;
    }
  };
}
function Ea(e) {
  return Dd((t, n) => e(t, (r) => n[r]));
}
const eH = {
  mapIndex(e, t, n) {
    const [r, i] = fe(e, (o) => t[o]), s = i - r;
    for (const o of e)
      n[o] = t[o] === null ? NaN : (t[o] - r) / s;
  }
}, F2 = Dd((e, t) => {
  for (let n = 0; n < e.length; ++n) {
    const r = t[e[n]];
    if (Re(r))
      return r;
  }
}), nH = Dd((e, t) => {
  for (let n = e.length - 1; n >= 0; --n) {
    const r = t[e[n]];
    if (Re(r))
      return r;
  }
}), rH = {
  mapIndex(e, t, n) {
    const r = Fh(e, (s) => t[s]), i = tu(e, (s) => t[s]);
    for (const s of e)
      n[s] = t[s] === null ? NaN : i ? (t[s] - r) / i : 0;
  }
}, iH = Ea(Qt), sH = Ea(Fh), oH = Ea($c), aH = Ea(be), cH = Ea(gr);
function uH(e, t) {
  return lH("x", e, t);
}
function lH(e, t, n = {}) {
  let r, i = 1;
  if (typeof t == "number")
    i = t, r = (u, l) => +u + l;
  else {
    if (typeof t == "string") {
      const u = t.startsWith("-") ? -1 : 1;
      [t, i] = qm(t.replace(/^[+-]/, "")), i *= u;
    }
    t = cd(t), r = (u, l) => t.offset(u, l);
  }
  const s = `${e}1`, o = `${e}2`, a = vr(
    {
      [s]: (u) => u.map((l) => r(l, i)),
      [o]: (u) => u
    },
    n
  ), c = a[o].transform;
  return a[o].transform = () => {
    const u = c(), [l, f] = fe(u);
    return u.domain = i < 0 ? [l, r(f, i)] : [r(l, i), f], u;
  }, a;
}
function fH(e, t = {}) {
  if (typeof e == "string")
    switch (e.toLowerCase()) {
      case "first":
        return D4(t);
      case "last":
        return O4(t);
    }
  if (typeof e == "function")
    return zi(null, e, t);
  let n, r;
  for (n in e) {
    if (r !== void 0)
      throw new Error("ambiguous selector; multiple inputs");
    r = hH(e[n]);
  }
  if (r === void 0)
    throw new Error(`invalid selector: ${e}`);
  return zi(n, r, t);
}
function hH(e) {
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "min":
      return n1;
    case "max":
      return r1;
  }
  throw new Error(`unknown selector: ${e}`);
}
function D4(e) {
  return zi(null, gH, e);
}
function O4(e) {
  return zi(null, bH, e);
}
function dH(e) {
  return zi("x", n1, e);
}
function pH(e) {
  return zi("y", n1, e);
}
function yH(e) {
  return zi("x", r1, e);
}
function mH(e) {
  return zi("y", r1, e);
}
function* gH(e) {
  yield e[0];
}
function* bH(e) {
  yield e[e.length - 1];
}
function* n1(e, t) {
  yield NL(e, (n) => t[n]);
}
function* r1(e, t) {
  yield um(e, (n) => t[n]);
}
function zi(e, t, n) {
  if (e != null) {
    if (n[e] == null)
      throw new Error(`missing channel: ${e}`);
    e = n[e];
  }
  const r = Ji(n);
  return Mr(n, (i, s) => {
    const o = At(i, r), a = At(i, e), c = [];
    for (const u of s) {
      const l = [];
      for (const f of o ? ii(u, (h) => o[h]).values() : [u])
        for (const h of t(f, a))
          l.push(h);
      c.push(l);
    }
    return { data: i, facets: c };
  });
}
const R2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Area: Md,
  Arrow: k$,
  BarX: R$,
  BarY: C$,
  Cell: Ad,
  Contour: i4,
  Density: a4,
  Dot: $d,
  Frame: y$,
  Geo: c4,
  Hexgrid: u4,
  Image: l4,
  Line: Id,
  Link: O$,
  Mark: Xt,
  Raster: Z$,
  Rect: Ed,
  RuleX: IA,
  RuleY: TA,
  Text: vd,
  TickX: q$,
  TickY: V$,
  Tip: m$,
  Vector: _d,
  area: cy,
  areaX: jc,
  areaY: fa,
  arrow: DW,
  auto: qW,
  autoSpec: B$,
  axisFx: ZA,
  axisFy: JA,
  axisX: Ag,
  axisY: Mg,
  barX: vs,
  barY: _s,
  bin: us,
  binX: vi,
  binY: _i,
  bollinger: Es,
  bollingerX: cX,
  bollingerY: uX,
  boxX: fX,
  boxY: hX,
  cell: So,
  cellX: LW,
  cellY: kW,
  centroid: NG,
  circle: BW,
  cluster: EG,
  column: sn,
  contour: $X,
  crosshair: TX,
  crosshairX: EX,
  crosshairY: NX,
  delaunayLink: qX,
  delaunayMesh: VX,
  density: HX,
  differenceY: KX,
  dodgeX: HG,
  dodgeY: JG,
  dot: Qi,
  dotX: RW,
  dotY: CW,
  filter: Gj,
  find: uq,
  formatIsoDate: UM,
  formatMonth: bq,
  formatWeekday: wq,
  frame: Tg,
  geo: Jg,
  geoCentroid: DG,
  graticule: nG,
  gridFx: r$,
  gridFy: e$,
  gridX: n$,
  gridY: t$,
  group: rg,
  groupX: Bc,
  groupY: Pc,
  groupZ: ng,
  hexagon: PW,
  hexbin: rG,
  hexgrid: oG,
  hull: YX,
  identity: at,
  image: fG,
  indexOf: ze,
  initializer: Ke,
  interpolateNearest: n4,
  interpolateNone: fy,
  interpolatorBarycentric: e4,
  interpolatorRandomWalk: r4,
  legend: wY,
  line: Td,
  lineX: qc,
  lineY: Vc,
  linearRegressionX: wG,
  linearRegressionY: vG,
  link: L$,
  map: vr,
  mapX: Vg,
  mapY: Yg,
  marks: An,
  normalize: e1,
  normalizeX: QG,
  normalizeY: tH,
  plot: Eg,
  pointer: vg,
  pointerX: _g,
  pointerY: ah,
  raster: pX,
  rect: qg,
  rectX: dh,
  rectY: ph,
  reverse: Hj,
  ruleX: Pi,
  ruleY: Ui,
  scale: Vs,
  select: fH,
  selectFirst: D4,
  selectLast: O4,
  selectMaxX: yH,
  selectMaxY: mH,
  selectMinX: dH,
  selectMinY: pH,
  shiftX: uH,
  shuffle: Jj,
  sort: TM,
  sphere: eG,
  spike: aY,
  stackX: $$,
  stackX1: lW,
  stackX2: fW,
  stackY: I$,
  stackY1: hW,
  stackY2: dW,
  text: ca,
  textX: OA,
  textY: LA,
  tickX: Y$,
  tickY: W$,
  tip: g$,
  transform: Mr,
  tree: S4,
  treeLink: d4,
  treeNode: hy,
  valueof: At,
  vector: qA,
  vectorX: VA,
  vectorY: YA,
  voronoi: WX,
  voronoiMesh: XX,
  window: Nd,
  windowX: JW,
  windowY: ZW
}, Symbol.toStringTag, { value: "Module" })), wH = /* @__PURE__ */ new Map([
  ["style", "style"],
  ["width", "width"],
  ["height", "height"],
  ["margin", "margin"],
  ["marginLeft", "marginLeft"],
  ["marginRight", "marginRight"],
  ["marginTop", "marginTop"],
  ["marginBottom", "marginBottom"],
  ["align", "align"],
  ["aspectRatio", "aspectRatio"],
  ["axis", "axis"],
  ["inset", "inset"],
  ["grid", "grid"],
  ["label", "label"],
  ["padding", "padding"],
  ["round", "round"],
  ["xScale", "x.type"],
  ["xDomain", "x.domain"],
  ["xRange", "x.range"],
  ["xNice", "x.nice"],
  ["xInset", "x.inset"],
  ["xInsetLeft", "x.insetLeft"],
  ["xInsetRight", "x.insetRight"],
  ["xClamp", "x.clamp"],
  ["xRound", "x.round"],
  ["xAlign", "x.align"],
  ["xPadding", "x.padding"],
  ["xPaddingInner", "x.paddingInner"],
  ["xPaddingOuter", "x.paddingOuter"],
  ["xAxis", "x.axis"],
  ["xTicks", "x.ticks"],
  ["xTickSize", "x.tickSize"],
  ["xTickSpacing", "x.tickSpacing"],
  ["xTickPadding", "x.tickPadding"],
  ["xTickFormat", "x.tickFormat"],
  ["xTickRotate", "x.tickRotate"],
  ["xGrid", "x.grid"],
  ["xLine", "x.line"],
  ["xLabel", "x.label"],
  ["xLabelAnchor", "x.labelAnchor"],
  ["xLabelOffset", "x.labelOffset"],
  ["xFontVariant", "x.fontVariant"],
  ["xAriaLabel", "x.ariaLabel"],
  ["xAriaDescription", "x.ariaDescription"],
  ["xReverse", "x.reverse"],
  ["xZero", "x.zero"],
  ["yScale", "y.type"],
  ["yDomain", "y.domain"],
  ["yRange", "y.range"],
  ["yNice", "y.nice"],
  ["yInset", "y.inset"],
  ["yInsetTop", "y.insetTop"],
  ["yInsetBottom", "y.insetBottom"],
  ["yClamp", "y.clamp"],
  ["yRound", "y.round"],
  ["yAlign", "y.align"],
  ["yPadding", "y.padding"],
  ["yPaddingInner", "y.paddingInner"],
  ["yPaddingOuter", "y.paddingOuter"],
  ["yAxis", "y.axis"],
  ["yTicks", "y.ticks"],
  ["yTickSize", "y.tickSize"],
  ["yTickSpacing", "y.tickSpacing"],
  ["yTickPadding", "y.tickPadding"],
  ["yTickFormat", "y.tickFormat"],
  ["yTickRotate", "y.tickRotate"],
  ["yGrid", "y.grid"],
  ["yLine", "y.line"],
  ["yLabel", "y.label"],
  ["yLabelAnchor", "y.labelAnchor"],
  ["yLabelOffset", "y.labelOffset"],
  ["yFontVariant", "y.fontVariant"],
  ["yAriaLabel", "y.ariaLabel"],
  ["yAriaDescription", "y.ariaDescription"],
  ["yReverse", "y.reverse"],
  ["yZero", "y.zero"],
  ["facetMargin", "facet.margin"],
  ["facetMarginTop", "facet.marginTop"],
  ["facetMarginBottom", "facet.marginBottom"],
  ["facetMarginLeft", "facet.marginLeft"],
  ["facetMarginRight", "facet.marginRight"],
  ["facetGrid", "facet.grid"],
  ["facetLabel", "facet.label"],
  ["fxDomain", "fx.domain"],
  ["fxRange", "fx.range"],
  ["fxNice", "fx.nice"],
  ["fxInset", "fx.inset"],
  ["fxInsetLeft", "fx.insetLeft"],
  ["fxInsetRight", "fx.insetRight"],
  ["fxRound", "fx.round"],
  ["fxAlign", "fx.align"],
  ["fxPadding", "fx.padding"],
  ["fxPaddingInner", "fx.paddingInner"],
  ["fxPaddingOuter", "fx.paddingOuter"],
  ["fxAxis", "fx.axis"],
  ["fxTicks", "fx.ticks"],
  ["fxTickSize", "fx.tickSize"],
  ["fxTickSpacing", "fx.tickSpacing"],
  ["fxTickPadding", "fx.tickPadding"],
  ["fxTickFormat", "fx.tickFormat"],
  ["fxTickRotate", "fx.tickRotate"],
  ["fxGrid", "fx.grid"],
  ["fxLine", "fx.line"],
  ["fxLabel", "fx.label"],
  ["fxLabelAnchor", "fx.labelAnchor"],
  ["fxLabelOffset", "fx.labelOffset"],
  ["fxFontVariant", "fx.fontVariant"],
  ["fxAriaLabel", "fx.ariaLabel"],
  ["fxAriaDescription", "fx.ariaDescription"],
  ["fxReverse", "fx.reverse"],
  ["fyDomain", "fy.domain"],
  ["fyRange", "fy.range"],
  ["fyNice", "fy.mice"],
  ["fyInset", "fy,inset"],
  ["fyInsetTop", "fy.insetTop"],
  ["fyInsetBottom", "fy.insetBottom"],
  ["fyRound", "fy.round"],
  ["fyAlign", "fy.align"],
  ["fyPadding", "fy.padding"],
  ["fyPaddingInner", "fy.paddingInner"],
  ["fyPaddingOuter", "fy.paddingOuter"],
  ["fyAxis", "fy.axis"],
  ["fyTicks", "fy.ticks"],
  ["fyTickSize", "fy.tickSize"],
  ["fyTickSpacing", "fy.tickSpacing"],
  ["fyTickPadding", "fy.tickPadding"],
  ["fyTickFormat", "fy.tickFormat"],
  ["fyTickRotate", "fy.tickRotate"],
  ["fyGrid", "fy.grid"],
  ["fyLine", "fy.line"],
  ["fyLabel", "fy.label"],
  ["fyLabelAnchor", "fy.labelAnchor"],
  ["fyLabelOffset", "fy.labelOffset"],
  ["fyFontVariant", "fy.fontVariant"],
  ["fyAriaLabel", "fy.ariaLabel"],
  ["fyAriaDescription", "fy.ariaDescription"],
  ["fyReverse", "fy.reverse"],
  ["colorScale", "color.type"],
  ["colorDomain", "color.domain"],
  ["colorRange", "color.range"],
  ["colorClamp", "color.clamp"],
  ["colorN", "color.n"],
  ["colorNice", "color.nice"],
  ["colorScheme", "color.scheme"],
  ["colorInterpolate", "color.interpolate"],
  ["colorPivot", "color.pivot"],
  ["colorSymmetric", "color.symmetric"],
  ["colorLabel", "color.label"],
  ["colorReverse", "color.reverse"],
  ["colorZero", "color.zero"],
  ["colorTickFormat", "color.tickFormat"],
  ["opacityScale", "opacity.type"],
  ["opacityDomain", "opacity.domain"],
  ["opacityRange", "opacity.range"],
  ["opacityClamp", "opacity.clamp"],
  ["opacityNice", "opacity.nice"],
  ["opacityLabel", "opacity.label"],
  ["opacityReverse", "opacity.reverse"],
  ["opacityZero", "opacity.zero"],
  ["opacityTickFormat", "opacity.tickFormat"],
  ["rScale", "r.type"],
  ["rDomain", "r.domain"],
  ["rRange", "r.range"],
  ["rClamp", "r.clamp"],
  ["rNice", "r.nice"],
  ["rZero", "r.zero"],
  ["lengthScale", "length.type"],
  ["lengthDomain", "length.domain"],
  ["lengthRange", "length.range"],
  ["lengthClamp", "length.clamp"],
  ["lengthNice", "length.nice"],
  ["lengthZero", "length.zero"],
  ["projectionType", "projection.type"],
  ["projectionParallels", "projection.parallels"],
  ["projectionPrecision", "projection.precision"],
  ["projectionRotate", "projection.rotate"],
  ["projectionDomain", "projection.domain"],
  ["projectionInset", "projection.inset"],
  ["projectionInsetLeft", "projection.insetLeft"],
  ["projectionInsetRight", "projection.insetRight"],
  ["projectionInsetTop", "projection.insetTop"],
  ["projectionInsetBottom", "projection.insetBottom"],
  ["projectionClip", "projection.clip"]
]);
function vH(e, t, n) {
  for (let r = 0; r < t.length; ++r) {
    const i = t[r];
    r === t.length - 1 ? e[i] = n : e = e[i] || (e[i] = {});
  }
}
function _H(e, t, n) {
  for (const r in e) {
    const i = wH.get(r);
    if (i == null)
      throw new Error(`Unrecognized plot attribute: ${r}`);
    const s = e[r];
    typeof s == "symbol" ? n.push(r) : s !== void 0 && vH(t, i.split("."), s);
  }
}
const xH = /* @__PURE__ */ new Set([
  "frame",
  "hexgrid",
  "sphere",
  "graticule"
]);
async function SH(e) {
  const t = { marks: [] }, n = [], { attributes: r, marks: i } = e;
  _H(r, t, n);
  const s = [];
  for (const a of i)
    for (const { type: c, data: u, options: l } of a.plotSpecs())
      xH.has(c) ? t.marks.push(R2[c](l)) : t.marks.push(R2[c](u, l)), s.push(a.index);
  AH(t, e);
  const o = Eg(t);
  $H(o, s), MH(e, o, r, n);
  for (const a of e.interactors)
    await a.init(o);
  return o;
}
function MH(e, t, n, r) {
  r.forEach((i) => {
    const s = n[i];
    if (s === rm) {
      if (!i.endsWith("Domain"))
        throw new Error(`Unsupported fixed attribute: ${i}`);
      const o = i.slice(0, -6), a = t.scale(o);
      a != null && a.domain && e.setAttribute(i, n[`${o}Reverse`] ? a.domain.slice().reverse() : a.domain);
    } else
      throw new Error(`Unrecognized symbol: ${s}`);
  });
}
function AH(e, t) {
  const { marks: n } = t;
  dl("x", e, n, ["x", "x1", "x2"]), dl("y", e, n, ["y", "y1", "y2"]), dl("fx", e, n), dl("fy", e, n);
}
function dl(e, t, n, r = [e]) {
  const i = t[e] || {};
  if (i.axis === null || i.label !== void 0)
    return;
  const s = n.map((l) => {
    var f;
    return (f = l.channelField(r)) == null ? void 0 : f.field;
  });
  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 = IH(n[l].data, r) || "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")) {
      i.percent && (u = `${u} (%)`);
      const l = (e === "x" ? 1 : -1) * (i.reverse ? -1 : 1);
      e === "x" || i.labelAnchor === "center" ? u = e === "x" == l < 0 ? `← ${u}` : `${u} →` : u = `${l < 0 ? "↑ " : "↓ "}${u}`;
    }
    t[e] = { ...i, label: u };
  }
}
function $H(e, t) {
  const n = e.querySelectorAll('g[aria-label="facet"]');
  if (n.length)
    for (const r of n)
      C2(r, t);
  else
    C2(e, t);
}
function C2(e, t) {
  let n = -1;
  for (const r of e.children) {
    const i = r.getAttribute("aria-label") || "";
    r.nodeName === "style" || i.includes("-axis") || i.includes("-grid") || r.setAttribute("data-index", t[++n]);
  }
}
function IH(e, t) {
  for (const n of e)
    for (let r = 0; r < t.length; ++r) {
      const i = n[t[r]];
      if (i != null)
        return i instanceof Date ? "date" : typeof i;
    }
}
const TH = {
  width: 640,
  marginLeft: 40,
  marginRight: 20,
  marginTop: 20,
  marginBottom: 30
};
class EH {
  constructor(t) {
    this.attributes = { ...TH }, 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.style.display = "flex", this.element.value = this, this.params = /* @__PURE__ */ new Map(), this.synch = iL();
  }
  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.synch.pending(t);
  }
  update(t) {
    return this.synch.ready(t) && !this.pendingRender && (this.pendingRender = !0, requestAnimationFrame(() => this.render())), this.synch.promise;
  }
  async render() {
    this.pendingRender = !1;
    const t = await SH(this), n = this.legends.flatMap(({ legend: r, include: i }) => {
      const s = r.init(t);
      return i ? s : [];
    });
    this.element.replaceChildren(t, ...n), this.synch.resolve();
  }
  getAttribute(t) {
    return this.attributes[t];
  }
  setAttribute(t, n, r) {
    var i, s;
    return cx(this.attributes[t], n) ? (n === void 0 ? delete this.attributes[t] : this.attributes[t] = n, r != null && r.silent || (s = (i = this.listeners) == null ? void 0 : i.get(t)) == null || s.forEach((o) => o(t, n)), !0) : !1;
  }
  addAttributeListener(t, n) {
    const r = this.listeners || (this.listeners = /* @__PURE__ */ new Map());
    return r.has(t) || r.set(t, /* @__PURE__ */ new Set()), r.get(t).add(n), this;
  }
  removeAttributeListener(t, n) {
    var r, i;
    return (i = (r = this.listeners) == null ? void 0 : r.get(t)) == null ? void 0 : i.delete(n);
  }
  addParams(t, n) {
    const { params: r } = this;
    for (const i of n)
      r.has(i) ? r.get(i).push(t) : (r.set(i, [t]), i.addEventListener("value", () => Promise.allSettled(
        r.get(i).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 i1(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
  Ri(e) !== null);
}
const NH = /* @__PURE__ */ new Set([
  "order",
  "sort",
  "label",
  "anchor",
  "curve",
  "tension",
  "marker",
  "markerStart",
  "markerMid",
  "markerEnd",
  "textAnchor",
  "lineAnchor",
  "lineHeight",
  "textOverflow",
  "monospace",
  "fontFamily",
  "fontSize",
  "fontStyle",
  "fontVariant",
  "fontWeight",
  "frameAnchor",
  "strokeLinejoin",
  "strokeLinecap",
  "strokeMiterlimit",
  "strokeDasharray",
  "strokeDashoffset",
  "mixBlendMode",
  "shapeRendering",
  "imageRendering",
  "preserveAspectRatio",
  "interpolate",
  "crossOrigin",
  "paintOrder",
  "pointerEvents",
  "target"
]);
function DH(e) {
  return NH.has(e);
}
const OH = /* @__PURE__ */ new Set([
  "asterisk",
  "circle",
  "cross",
  "diamond",
  "diamond2",
  "hexagon",
  "plus",
  "square",
  "square2",
  "star",
  "times",
  "triangle",
  "triangle2",
  "wye"
]);
function LH(e) {
  return OH.has(`${e}`.toLowerCase());
}
function s1(e) {
  return typeof (e == null ? void 0 : e.getChild) == "function";
}
const kH = 2, FH = 10;
function L4(e) {
  return s1(e) ? RH(e) : e;
}
function RH(e) {
  const { batches: t, numRows: n } = e;
  if (!n)
    return [];
  const r = Array.from({ length: n }, () => ({}));
  for (let i = 0, s = 0; s < t.length; ++s) {
    const o = t[s], { schema: a, numRows: c, numCols: u } = o;
    for (let l = 0; l < u; ++l) {
      const f = o.getChildAt(l), { name: h, type: d } = a.fields[l], p = CH(d);
      for (let y = i, g = 0; g < c; ++g, ++y)
        r[y][h] = p(f.get(g));
    }
    i += c;
  }
  return r;
}
function CH(e) {
  const { typeId: t } = e;
  return t === FH ? (n) => n == null ? n : new Date(n) : t === kH && e.bitWidth >= 64 ? (n) => n == null ? n : Number(n) : (n) => n;
}
const k4 = (e) => e === "stroke" || e === "fill", BH = (e) => e === "symbol", PH = (e, t) => e !== "sort" && e !== "tip" && t != null && !Array.isArray(t), Pp = (e, t) => ({
  channel: e,
  field: t,
  as: t instanceof Oi ? t.column : e
}), Up = (e, t) => ({ channel: e, value: t }), vy = (e) => Array.isArray(e);
class Zs extends Yc {
  constructor(t, n, r, i = {}) {
    var u;
    super((u = n == null ? void 0 : n.options) == null ? void 0 : u.filterBy), this.type = t, this.reqs = i, this.source = n, vy(this.source) && (this.data = this.source);
    const s = this.channels = [], o = this.detail = /* @__PURE__ */ new Set(), a = this.params = /* @__PURE__ */ new Set(), c = (l, f) => {
      const h = typeof f;
      if (l === "channels")
        for (const d in f)
          o.add(d), c(d, f[d]);
      else if (h === "function" && f[ux]) {
        const d = f(this, l);
        for (const p in d)
          c(p, d[p]);
      } else if (h === "string")
        DH(l) || k4(l) && i1(f) || BH(l) && LH(f) ? s.push(Up(l, f)) : s.push(Pp(l, Th(f)));
      else if (Xo(f))
        if (Array.isArray(f.columns))
          s.push(Pp(l, f)), a.add(f);
        else {
          const d = Up(l, f.value);
          s.push(d), f.addEventListener("value", (p) => (d.value = p, this.update()));
        }
      else
        h === "object" && PH(l, f) ? s.push(Pp(l, f)) : f !== void 0 && s.push(Up(l, f));
    };
    for (const l in r)
      c(l, r[l]);
  }
  setPlot(t, n) {
    var r;
    this.plot = t, this.index = n, t.addParams(this, this.params), (r = this.source) != null && r.table && this.queryPending();
  }
  hasOwnData() {
    return this.source == null || vy(this.source);
  }
  channel(t) {
    return this.channels.find((n) => n.channel === t);
  }
  channelField(...t) {
    const n = t.flat();
    for (const r of n) {
      const i = this.channel(r);
      if (i != null && i.field)
        return i;
    }
    return null;
  }
  fields() {
    var s, o, a;
    if (this.hasOwnData())
      return null;
    const { source: { table: t }, channels: n, reqs: r } = this, i = /* @__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 || r[c]) {
          i.has(l) || i.set(l, /* @__PURE__ */ new Set());
          const f = i.get(l);
          (o = r[c]) == null || o.forEach((h) => f.add(h)), (a = u.stats) == null || a.forEach((h) => f.add(h));
        }
      } else
        continue;
    }
    return Array.from(i, ([c, u]) => ({ table: t, column: c, stats: Array.from(u) }));
  }
  fieldInfo(t) {
    return this.stats = t.reduce(
      (n, r) => (n[r.column] = r, n),
      /* @__PURE__ */ Object.create(null)
    ), this;
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { channels: n, source: { table: r } } = this;
    return F4(n, r).where(t);
  }
  queryPending() {
    return this.plot.pending(this), this;
  }
  queryResult(t) {
    return this.data = L4(t), this;
  }
  update() {
    return this.plot.update(this);
  }
  plotSpecs() {
    const { type: t, data: n, detail: r, channels: i } = this, s = {}, o = {};
    for (const a of i) {
      const c = r.has(a.channel) ? o : s;
      c[a.channel] = Ai(a);
    }
    return r.size && (s.channels = o), [{ type: t, data: n, options: s }];
  }
}
function Ai(e) {
  return Object.hasOwn(e, "value") ? e.value : k4(e.channel) ? { value: e.as, scale: "color" } : e.as;
}
function F4(e, t, n = []) {
  const r = St.from({ source: t }), i = /* @__PURE__ */ new Set();
  let s = !1;
  for (const o of e) {
    const { channel: a, field: c, as: u } = o;
    if (!n.includes(a)) {
      if (a === "orderby")
        r.orderby(o.value);
      else if (c) {
        if (c.aggregate)
          s = !0;
        else {
          if (i.has(u))
            continue;
          i.add(u);
        }
        r.select({ [u]: c });
      }
    }
  }
  return s && r.groupby(Array.from(i)), r;
}
function ji(e, t, n) {
  if (!e.stats)
    return r;
  const { field: r } = e.channelField(t), { type: i } = e.stats[r.column];
  return n = n ?? r, i === "date" ? nx(n) : n;
}
function _y(e, t, n, r, i = !1, s = 1) {
  const o = (r - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return i ? V`(${+n} - ${e}::DOUBLE)${a}` : V`(${e}::DOUBLE - ${+t})${a}`;
}
const R4 = { x: ["min", "max"] }, C4 = { y: ["min", "max"] }, B4 = { ...R4, ...C4 };
function P4(e, t, n, r, i) {
  const { plot: s, stats: o } = e, a = s.getAttribute(r), c = s.getAttribute(i);
  if (Array.isArray(a) && !a[Ls])
    return a;
  {
    const { field: u } = e.channelField(n), { column: l } = u, { min: f, max: h } = o[l], d = U4(t, l) || (c ? Hh().domain([f, h]).nice().domain() : [f, h]);
    return a !== rm && (d[Ls] = !0), s.setAttribute(r, d, { silent: !0 }), d;
  }
}
function Du(e, t) {
  return P4(e, t, "x", "xDomain", "xNice");
}
function Ou(e, t) {
  return P4(e, t, "y", "yDomain", "yNice");
}
function U4(e, t) {
  if (!e)
    return;
  let n, r;
  const i = (s, o) => {
    if (s === "BETWEEN" && o.field.column === t) {
      const { range: a } = o;
      a && (n == null || a[0] < n) && (n = a[0]), a && (r == null || a[1] > r) && (r = a[1]);
    }
  };
  return Array.isArray(e) ? e.forEach((s) => {
    var o;
    return (o = s.visit) == null ? void 0 : o.call(s, i);
  }) : e.visit && e.visit(i), n != null && r != null && n !== r ? [n, r] : void 0;
}
class UH extends Zs {
  constructor(t, n, r) {
    const i = t.endsWith("X") ? "y" : t.endsWith("Y") ? "x" : null, s = { [i]: ["count", "min", "max"] };
    super(t, n, r, s), this.dim = i;
  }
  query(t = []) {
    const { plot: n, dim: r, source: i, stats: s } = this, { optimize: o = !0 } = i.options || {}, a = super.query(t);
    if (o && r) {
      const { field: c, as: u } = this.channelField(r), { column: l } = c, { count: f, max: h, min: d } = s[l], p = r === "x" ? n.innerWidth() : n.innerHeight(), [y, g] = U4(t, l) || [d, h], m = (g - y) / (h - d);
      if (f * m > p * 4) {
        const b = ji(this, r, u), w = this.channelField(r === "x" ? "y" : "x").as, v = a.select().map((x) => x.as).filter((x) => x !== u && x !== w);
        return zH(a, b, u, w, y, g, p, v);
      }
      a.orderby(u);
    }
    return a;
  }
}
function zH(e, t, n, r, i, s, o, a = []) {
  const c = V`FLOOR(${o / (s - i)}::DOUBLE * (${t} - ${+i}::DOUBLE))::INTEGER`, u = (l) => St.from(e).select(l).groupby(c, a);
  return St.union(
    u([{ [n]: Ho(n), [r]: n0(r, n) }, ...a]),
    u([{ [n]: Go(n), [r]: r0(r, n) }, ...a]),
    u([{ [n]: n0(n, r), [r]: Ho(r) }, ...a]),
    u([{ [n]: r0(n, r), [r]: Go(r) }, ...a])
  ).orderby(a, n);
}
function _n(e, t, n, r) {
  $i(n) ? (r = r || (() => e.requestUpdate()), n.addEventListener("value", (i) => (e[t] = i, r())), e[t] = n.value) : e[t] = n;
}
function xy(e, t = !1) {
  const n = new Float64Array(5), r = new Float64Array(4);
  jH(n, r, e);
  const i = Float64Array.of(
    0,
    r[1] - n[1] * r[0],
    r[2] - n[2] * r[0],
    r[3] - n[3] * r[0],
    -n[4] * r[0]
  ), s = 1 + n[1] + n[2] + n[3] + n[4], o = (r[0] + r[1] + r[2] + r[3]) / s, a = (i[1] + i[2] + i[3] + i[4]) / s;
  return {
    sigma: e,
    negative: t,
    a: n,
    b_causal: r,
    b_anticausal: i,
    sum_causal: o,
    sum_anticausal: a
  };
}
function jH(e, t, n) {
  const i = 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(i[0], i[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] += i[p] * h[d] - i[p + 1] * h[d + 1], f[d + 1] += i[p] * h[d + 1] + i[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 qH(e, t, n, [r, i]) {
  const s = new Float64Array(Math.max(r, i)), o = new Float64Array(Math.max(r, i)), a = new Float64Array(5), c = new Float64Array(n.length);
  for (let u = 0, l = 0; u < i; ++u, l += r) {
    const f = c.subarray(l);
    Sy(e, n.subarray(l), r, 1, s, o, a, f);
  }
  for (let u = 0; u < r; ++u) {
    const l = c.subarray(u);
    Sy(t, l, i, r, s, o, a, l);
  }
  return c;
}
function Sy(e, t, n, r = 1, i = new Float64Array(n), s = new Float64Array(n), o = new Float64Array(5), a = i, c = VH) {
  const u = r * 2, l = r * 3, f = r * 4, h = r * n;
  let d, p;
  for (c(
    i,
    t,
    n,
    r,
    e.b_causal,
    3,
    e.a,
    4,
    e.sum_causal,
    o,
    e.sigma
  ), p = 4, d = f; p < n; ++p, d += r)
    i[p] = e.b_causal[0] * t[d] + e.b_causal[1] * t[d - r] + e.b_causal[2] * t[d - u] + e.b_causal[3] * t[d - l] - e.a[1] * i[p - 1] - e.a[2] * i[p - 2] - e.a[3] * i[p - 3] - e.a[4] * i[p - 4];
  for (c(
    s,
    t,
    n,
    -r,
    e.b_anticausal,
    4,
    e.a,
    4,
    e.sum_anticausal,
    o,
    e.sigma
  ), p = 4, d = h - r * 5; p < n; ++p, d -= r)
    s[p] = e.b_anticausal[1] * t[d + r] + 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 += r)
      a[d] = i[p] + s[n - p - 1];
  else
    for (p = 0, d = 0; p < n; ++p, d += r)
      a[d] = Math.max(0, i[p] + s[n - p - 1]);
  return a;
}
function VH(e, t, n, r, i, s, o, a, c, u) {
  const l = Math.abs(r) * n, f = r < 0 ? l + r : 0;
  let h, d, p;
  for (d = 0; d < a; ++d)
    for (u[d] = d <= s ? i[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 + r * d, h >= 0 && h < l && (e[p] += u[p - d] * t[h]);
  const y = t[f];
  if (y > 0)
    for (p = 0; p < a; ++p)
      e[p] += u[p] * y;
}
function YH(e, t) {
  return z4(new Float64Array(e), t);
}
function WH(e, t, n, r = []) {
  return r.length ? Object.values(XH(e * t, n, r)) : [{ grid: z4(new Float64Array(e * t), n) }];
}
function z4(e, t) {
  if (s1(t)) {
    const n = t.numRows;
    if (n === 0)
      return e;
    const r = t.getChild("index").toArray(), i = t.getChild("value").toArray();
    for (let s = 0; s < n; ++s)
      e[r[s]] = i[s];
  } else
    for (const n of t)
      e[n.index] = n.value;
  return e;
}
function XH(e, t, n) {
  const r = {}, i = (s) => (r[s] || (r[s] = { key: s, grid: new Float64Array(e) })).grid;
  if (s1(t)) {
    const s = t.numRows;
    if (s === 0)
      return r;
    const o = t.getChild("index").toArray(), a = t.getChild("value").toArray(), c = n.map((u) => t.getChild(u));
    for (let u = 0; u < s; ++u) {
      const l = c.map((f) => f.get(u));
      i(l)[o[u]] = a[u];
    }
  } else
    for (const s of t) {
      const o = n.map((a) => s[a]);
      i(o)[s.index] = s.value;
    }
  return r;
}
class Od extends Zs {
  constructor(t, n, r) {
    const {
      bandwidth: i = 20,
      binType: s = "linear",
      binWidth: o = 2,
      binPad: a = 1,
      ...c
    } = r, u = GH(c);
    super(t, n, c, B4), this.densityMap = u, _n(this, "bandwidth", i, () => this.grids ? this.convolve().update() : null), _n(this, "binWidth", o), _n(this, "binType", s), _n(this, "binPad", a);
  }
  setPlot(t, n) {
    const r = () => {
      this.stats && this.requestUpdate();
    };
    return t.addAttributeListener("domainX", r), t.addAttributeListener("domainY", r), super.setPlot(t, n);
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[Ls] && !n[Ls];
  }
  query(t = []) {
    const { plot: n, binType: r, binPad: i, channels: s, densityMap: o, source: a } = this, [c, u] = this.extentX = Du(this, t), [l, f] = this.extentY = Ou(this, t), [h, d] = this.bins = this.binDimensions(this), p = ji(this, "x"), y = ji(this, "y"), g = !!n.getAttribute("xReverse"), m = !!n.getAttribute("yReverse"), b = B2(p, c, u, h, g, this.binPad), w = B2(y, l, f, d, m, this.binPad), v = i ? [He(p, [c, u]), He(y, [l, f])] : [xc(c, p), _c(p, u), xc(l, y), _c(y, f)], x = St.from(a.table).where(t.concat(v)), _ = this.groupby = [];
    let M = xs();
    for (const T of s)
      if (Object.hasOwn(T, "field")) {
        const { as: N, channel: A, field: $ } = T;
        $.aggregate ? (M = $, o[A] = !0) : A === "weight" ? M = Ys($) : A !== "x" && A !== "y" && (x.select({ [N]: $ }), _.push(N));
      }
    return r === "linear" ? JH(x, b, w, M, h, _) : HH(x, b, w, M, h, _);
  }
  binDimensions() {
    const { plot: t, binWidth: n } = this;
    return [
      Math.round(t.innerWidth() / n),
      Math.round(t.innerHeight() / n)
    ];
  }
  queryResult(t) {
    const [n, r] = this.bins;
    return this.grids = WH(n, r, t, this.groupby), this.convolve();
  }
  convolve() {
    const { bandwidth: t, bins: n, grids: r, plot: i } = this;
    if (t <= 0)
      this.kde = this.grids.map(({ key: s, grid: o }) => (o.key = s, o));
    else {
      const s = i.innerWidth(), o = i.innerHeight(), [a, c] = n, u = r.some(({ grid: h }) => h.some((d) => d < 0)), l = xy(t * (a - 1) / s, u), f = xy(t * (c - 1) / o, u);
      this.kde = this.grids.map(({ key: h, grid: d }) => {
        const p = qH(l, f, d, n);
        return p.key = h, p;
      });
    }
    return this;
  }
  plotSpecs() {
    throw new Error("Unimplemented. Use a Grid2D mark subclass.");
  }
}
function GH(e) {
  const t = {};
  for (const n in e)
    e[n] === "density" && (delete e[n], t[n] = !0);
  return t;
}
function B2(e, t, n, r, i, s) {
  const o = (r - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return i ? V`(${n} - ${e}::DOUBLE)${a}` : V`(${e}::DOUBLE - ${t})${a}`;
}
function HH(e, t, n, r, i, s) {
  return e.select({
    index: V`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${i}`,
    value: r
  }).groupby("index", s);
}
function JH(e, t, n, r, i, s) {
  const o = r.column ? `* ${r.column}` : "", a = (h, d) => e.clone().select({ xp: t, yp: n, i: h, w: d }), c = a(
    V`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${i}`,
    V`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), u = a(
    V`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    V`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), l = a(
    V`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${i}`,
    V`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), f = a(
    V`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    V`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return St.from(St.unionAll(c, u, l, f)).select({ index: "i", value: Ys("w") }, s).groupby("index", s).having(tm("value", 0));
}
class ZH extends Od {
  constructor(t, n) {
    const { thresholds: r = 10, ...i } = n;
    super("geo", t, i), _n(this, "thresholds", r, () => this.grids ? this.contours().update() : null);
  }
  convolve() {
    return super.convolve().contours();
  }
  contours() {
    const { bins: t, densityMap: n, kde: r, thresholds: i, groupby: s, plot: o } = this;
    let a = i;
    if (!Array.isArray(a)) {
      const x = Qt(r.map((_) => Qt(_)));
      a = Array.from({ length: a - 1 }, (_, M) => x * (M + 1) / a);
    }
    (n.fill || n.stroke) && this.plot.getAttribute("colorScale") !== "log" && this.plot.setAttribute("colorZero", !0);
    const [c, u] = t, [l, f] = o.getAttribute("xDomain"), [h, d] = o.getAttribute("yDomain"), p = (f - l) / c, y = (d - h) / u, g = +l, m = +h, b = (x) => g + x * p, w = (x) => m + x * y, v = vf().size(t);
    return this.data = r.flatMap((x) => a.map((_) => {
      const M = KH(v.contour(x, _), b, w);
      return s.forEach((T, N) => M[T] = x.key[N]), M.density = _, M;
    })), this;
  }
  plotSpecs() {
    const { type: t, channels: n, densityMap: r, data: i } = this, s = {};
    for (const o of n) {
      const { channel: a } = o;
      a !== "x" && a !== "y" && (s[a] = Ai(o));
    }
    return r.fill && (s.fill = "density"), r.stroke && (s.stroke = "density"), [{ type: t, data: i, options: s }];
  }
}
function KH(e, t, n) {
  function r(o) {
    o.forEach(i);
  }
  function i(o) {
    o.forEach(s);
  }
  function s(o) {
    o[0] = t(o[0]), o[1] = n(o[1]);
  }
  return e.coordinates.forEach(r), e;
}
function j4(e, t, n, r, i, s) {
  const o = (s.length >> 2) - 1;
  for (let a = 0, c = 0; a < r; ++a)
    for (let u = 0, l = (r - a - 1) * n; u < n; ++u, c += 4) {
      const f = o * i(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 bh(e, t) {
  const n = new Uint8ClampedArray(4 * e), r = e - 1;
  for (let i = 0; i <= r; ++i) {
    const s = t(i / r), { r: o, g: a, b: c, opacity: u = 1 } = typeof s == "string" ? Sn(s) : s, l = i << 2;
    n[l + 0] = o, n[l + 1] = a, n[l + 2] = c, n[l + 3] = 255 * u | 0;
  }
  return n;
}
function q4(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 V4(e = "black") {
  const { r: t, g: n, b: r } = Sn(e);
  return (i) => ({ r: t, g: n, b: r, opacity: i });
}
class Y4 extends Od {
  constructor(t, n) {
    super("image", t, n);
  }
  setPlot(t, n) {
    const r = () => {
      this.stats && this.rasterize();
    };
    t.addAttributeListener("schemeColor", r), super.setPlot(t, n);
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var h;
    const { bins: t, kde: n, groupby: r } = this, [i, s] = t, { canvas: o, ctx: a, img: c } = QH(this, i, s), u = tJ(this), l = r.indexOf((h = this.channelField("fill")) == null ? void 0 : h.as), f = l < 0 ? [] : n.map(({ key: d }) => d[l]);
    return this.data = n.map((d) => {
      var y;
      const p = eJ(this, f, (y = d.key) == null ? void 0 : y[l]);
      return j4(d, c.data, i, s, u, p), a.putImageData(c, 0, 0), { src: o.toDataURL() };
    }), this;
  }
  plotSpecs() {
    var s;
    const { type: t, plot: n, data: r } = this, i = {
      src: "src",
      width: n.innerWidth(),
      height: n.innerHeight(),
      preserveAspectRatio: "none",
      imageRendering: (s = this.channel("imageRendering")) == null ? void 0 : s.value,
      frameAnchor: "middle"
    };
    return [{ type: t, data: r, options: i }];
  }
}
function QH(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const r = q4(t, n), i = r.getContext("2d", { willReadFrequently: !0 }), s = i.getImageData(0, 0, t, n);
    e.image = { canvas: r, ctx: i, img: s, w: t, h: n };
  }
  return e.image;
}
function tJ(e) {
  const { densityMap: t, kde: n, plot: r } = e;
  let i = t.fill && r.getAttribute("colorDomain");
  if (!i) {
    let o = 0, a = 0;
    n.forEach((c) => {
      for (const u of c)
        u < o && (o = u), u > a && (a = u);
    }), i = o === 0 && a === 0 ? [0, 1] : [o, a];
  }
  const s = r.getAttribute("colorScale");
  return Vs({ x: { type: s, domain: i, range: [0, 1] } }).apply;
}
function eJ(e, t, n, r = 1024) {
  const { densityMap: i, plot: s } = e, o = s.getAttribute("colorScheme"), a = e.channel("fill");
  let c = i1(a == null ? void 0 : a.value) ? a.value : void 0;
  if (i.fill || o && !c) {
    if (o)
      try {
        return bh(
          r,
          Vs({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (u) {
        console.warn(u);
      }
  } else if (t.length) {
    const u = s.getAttribute("colorRange");
    c = Vs({ color: {
      domain: t,
      range: u,
      scheme: o || (u ? void 0 : "tableau10")
    } }).apply(n);
  }
  return bh(r, V4(c));
}
class nJ extends Y4 {
  constructor(t, n) {
    const { normalize: r = !0, ...i } = n;
    super(t, { bandwidth: 0, ...i }), _n(this, "normalize", r);
  }
  query(t = []) {
    const { plot: n, channels: r, normalize: i, source: s } = this, [o, a] = Du(this, t), [c, u] = Ou(this, t), [l, f] = this.bins = this.binDimensions(this), h = ji(this, "x"), d = ji(this, "y"), p = !!n.getAttribute("xReverse"), y = !!n.getAttribute("yReverse"), g = _y(h, o, a, l, p, this.binPad), m = _y(d, c, u, f, y, this.binPad), b = St.from(s.table).where(rJ(this, t)), w = this.groupby = [], v = [];
    for (const x of r)
      if (Object.hasOwn(x, "field")) {
        const { channel: _, field: M } = x;
        _ === "z" ? (b.select({ [_]: M }), v.push("z")) : _ !== "x" && _ !== "y" && (b.select({ [_]: M }), w.push(_));
      }
    return iJ(b, g, m, v, l, f, w, i);
  }
}
function rJ(e, t) {
  if (Array.isArray(t) && !t.length)
    return t;
  const n = e.channelField("x").field.column, r = e.channelField("y").field.column, i = (o) => o.op !== "BETWEEN" || o.field.column !== n && o.field.column !== r, s = (o) => o.op === "AND" ? Li(o.children.filter((a) => i(a))) : o;
  return Array.isArray(t) ? t.filter((o) => i(o)).map((o) => s(o)) : s(t);
}
function iJ(e, t, n, r, i, s, o = [], a = !0) {
  e.select({
    x: V`FLOOR(${t})::INTEGER`,
    y: V`FLOOR(${n})::INTEGER`
  });
  const c = o.concat(r), u = c.length ? `PARTITION BY ${c.join(", ")} ` : "", l = St.from(e).select(c, {
    x0: "x",
    y0: "y",
    dx: V`(lead(x) OVER sw - x)`,
    dy: V`(lead(y) OVER sw - y)`
  }).window({ sw: V`${u}ORDER BY x ASC` }).qualify(Li(
    V`(x0 < ${i} OR x0 + dx < ${i})`,
    V`(y0 < ${s} OR y0 + dy < ${s})`,
    V`(x0 > 0 OR x0 + dx > 0)`,
    V`(y0 > 0 OR y0 + dy > 0)`
  )), f = St.select({ x: V`GREATEST(MAX(ABS(dx)), MAX(ABS(dy)))` }).from("pairs"), h = St.select({ i: V`UNNEST(range((${f})))::INTEGER` }), d = St.unionAll(
    St.select(c, {
      x: V`x0 + i`,
      y: V`y0 + ROUND(i * dy / dx::FLOAT)::INTEGER`
    }).from("pairs", "indices").where(V`ABS(dy) <= ABS(dx) AND i < ABS(dx)`),
    St.select(c, {
      x: V`x0 + ROUND(SIGN(dy) * i * dx / dy::FLOAT)::INTEGER`,
      y: V`y0 + SIGN(dy) * i`
    }).from("pairs", "indices").where(V`ABS(dy) > ABS(dx) AND i < ABS(dy)`),
    St.select(c, { x: "x0", y: "y0" }).from("pairs").where(Qy("dx"))
  ), p = ["x"].concat(c).join(", "), y = St.from("raster").select(
    c,
    "x",
    "y",
    a ? { w: V`1.0 / COUNT(*) OVER (PARTITION BY ${p})` } : null
  ).where(Li(He("x", [0, i]), He("y", [0, s])));
  return St.with({ pairs: l, indices: h, raster: d, points: y }).from("points").select(o, {
    index: V`x + y * ${i}::INTEGER`,
    value: a ? Ys("w") : xs()
  }).groupby("index", o);
}
class W4 extends Zs {
  constructor(t, n, r) {
    const { bins: i = 1024, bandwidth: s = 20, ...o } = r, a = t.endsWith("X") ? "y" : "x";
    super(t, n, o, a === "x" ? R4 : C4), this.dim = a, _n(this, "bins", i), _n(this, "bandwidth", s, () => this.grid ? this.convolve().update() : null);
  }
  get filterIndexable() {
    const t = this.dim === "x" ? "xDomain" : "yDomain", n = this.plot.getAttribute(t);
    return n && !n[Ls];
  }
  query(t = []) {
    if (this.hasOwnData())
      throw new Error("Density1DMark requires a data source");
    const { bins: n, channels: r, dim: i, source: { table: s } } = this, [o, a] = this.extent = (i === "x" ? Du : Ou)(this, t), c = ji(this, i);
    return sJ(
      F4(r, s, [i]).where(t.concat(He(c, [o, a]))),
      _y(c, o, a, n),
      this.channelField("weight") ? "weight" : null
    );
  }
  queryResult(t) {
    return this.grid = YH(this.bins, t), this.convolve();
  }
  convolve() {
    const { bins: t, bandwidth: n, dim: r, grid: i, plot: s, extent: [o, a] } = this, c = i.some((b) => b < 0), u = r === "x" ? s.innerWidth() : s.innerHeight(), l = xy(n * (t - 1) / u, c), f = Sy(l, i, t), h = this.data = [], d = r === "x" ? "y" : "x", p = this.channelField(r).as, y = +o, g = (a - y) / (t - 1), m = 1 / g;
    for (let b = 0; b < t; ++b)
      h.push({
        [p]: y + b * g,
        [d]: f[b] * m
      });
    return this;
  }
  plotSpecs() {
    const { type: t, data: n, channels: r, dim: i } = this, s = i === "x" ? { y: "y" } : { x: "x" };
    for (const o of r)
      s[o.channel] = Ai(o);
    return [{ type: t, data: n, options: s }];
  }
}
function sJ(e, t, n) {
  const r = n ? `* ${n}` : "", i = e.clone().select({
    p: t,
    i: V`FLOOR(p)::INTEGER`,
    w: V`(FLOOR(p) + 1 - p)${r}`
  }), s = e.clone().select({
    p: t,
    i: V`FLOOR(p)::INTEGER + 1`,
    w: V`(p - FLOOR(p))${r}`
  });
  return St.from(St.unionAll(i, s)).select({ index: "i", value: Ys("w") }).groupby("index").having(tm("value", 0));
}
class oJ extends Od {
  constructor(t, n) {
    const { type: r = "dot", binsX: i, binsY: s, ...o } = n;
    o.binPad = o.binPad ?? 0, super(r, t, o), _n(this, "binsX", i), _n(this, "binsY", s);
  }
  convolve() {
    super.convolve();
    const { bins: t, binPad: n, extentX: r, extentY: i } = this, [s, o] = t, [a, c] = r, [u, l] = i, f = (c - a) / (s - n), h = (l - u) / (o - n), d = n ? 0 : 0.5;
    return this.data = aJ(this.kde, t, a, u, f, h, d), this;
  }
  binDimensions() {
    const { plot: t, binWidth: n, binsX: r, binsY: i } = this;
    return [
      r ?? Math.round(t.innerWidth() / n),
      i ?? Math.round(t.innerHeight() / n)
    ];
  }
  plotSpecs() {
    const { type: t, channels: n, densityMap: r, data: i } = this, s = {};
    for (const o of n) {
      const { channel: a } = o;
      s[a] = a === "x" || a === "y" ? a : Ai(o);
    }
    for (const o in r)
      r[o] && (s[o] = "density");
    return [{ type: t, data: i, options: s }];
  }
}
function aJ(e, t, n, r, i, s, o) {
  const a = 1 / (i * s), [c, u] = t, l = [];
  for (const f of e)
    for (let h = 0, d = 0; d < u; ++d)
      for (let p = 0; p < c; ++p, ++h)
        l.push({
          x: n + (p + o) * i,
          y: r + (d + o) * s,
          density: f[h] * a
        });
  return l;
}
const cJ = "geom";
class uJ extends Zs {
  constructor(t, n = {}, r) {
    !vy(t) && !(n != null && n.geometry) && (n.geometry = rx(cJ)), super("geo", t, n, r);
  }
  queryResult(t) {
    var r;
    super.queryResult(t);
    const n = (r = this.channelField("geometry")) == null ? void 0 : r.as;
    return n && this.data && this.data.forEach((i) => {
      typeof i[n] == "string" && (i[n] = JSON.parse(i[n]));
    }), this;
  }
}
class lJ extends Zs {
  constructor(t, n) {
    const { type: r = "hexagon", binWidth: i = 20, ...s } = n;
    super(r, t, { r: i / 2, clip: !0, ...s }, B4), this.binWidth = i;
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[Ls] && !n[Ls];
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { plot: n, binWidth: r, channels: i, source: s } = this, [o, a] = Du(this, t), [c, u] = Ou(this, t), l = 0.5 - n.getAttribute("marginLeft"), f = 0 - n.getAttribute("marginTop"), h = `${r}::DOUBLE`, d = `${r * (1.5 / Math.sqrt(3))}::DOUBLE`, p = `${n.innerWidth() / (a - o)}::DOUBLE`, y = `${n.innerHeight() / (u - c)}::DOUBLE`;
    let g, m;
    const b = /* @__PURE__ */ new Set(), w = {};
    for (const T of i)
      T.channel === "orderby" ? v.orderby(T.value) : T.channel === "x" ? g = T : T.channel === "y" ? m = T : Object.hasOwn(T, "field") && (w[T.as] = T.field, T.field.aggregate && T.field.columns.forEach((N) => b.add(N)));
    const v = St.select({
      [g.as]: V`${o}::DOUBLE + ((x + 0.5 * (y & 1)) * ${h} + ${l})::DOUBLE / ${p}`,
      [m.as]: V`${u}::DOUBLE - (y * ${d} + ${f})::DOUBLE / ${y}`,
      ...w
    }).groupby("x", "y"), x = `${p} * (${g.field} - ${o}::DOUBLE)`, _ = `${y} * (${u}::DOUBLE - ${m.field})`, M = St.select({
      py: V`(${_} - ${f}) / ${d}`,
      pj: V`ROUND(py)::INTEGER`,
      px: V`(${x} - ${l}) / ${h} - 0.5 * (pj & 1)`,
      pi: V`ROUND(px)::INTEGER`,
      tt: V`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: V`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: V`CASE WHEN tt THEN (pj + CASE WHEN py < pj THEN -1 ELSE 1 END)::INTEGER ELSE pj END`
    }).select(Array.from(b)).from(s.table).where(vc(g.field), vc(m.field), t);
    return v.from(M);
  }
}
class fJ extends Od {
  constructor(t, n) {
    const { origin: r = [0, 0], dim: i = "xy", ...s } = n;
    super("image", t, s), this.origin = r, this.tileX = i.toLowerCase().includes("x"), this.tileY = i.toLowerCase().includes("y");
  }
  setPlot(t, n) {
    const r = () => {
      this.stats && this.rasterize();
    };
    t.addAttributeListener("schemeColor", r), super.setPlot(t, n);
  }
  requestQuery() {
    return this.requestTiles();
  }
  query(t = []) {
    return this._filter = t, null;
  }
  tileQuery(t) {
    const { plot: n, binType: r, binPad: i, channels: s, densityMap: o, source: a } = this, [[c, u], [l, f]] = t, [h, d] = this.bins, p = ji(this, "x"), y = ji(this, "y"), g = !!n.getAttribute("xReverse"), m = !!n.getAttribute("yReverse"), b = P2(p, c, u, h, g, i), w = P2(y, l, f, d, m, i), v = i ? [He(p, [c, u]), He(y, [l, f])] : [xc(c, p), _c(p, u), xc(l, y), _c(y, f)], x = St.from(a.table).where(v), _ = this.groupby = [];
    let M = xs();
    for (const T of s)
      if (Object.hasOwn(T, "field")) {
        const { channel: N, field: A } = T;
        A.aggregate ? (M = A, o[N] = !0) : N === "weight" ? M = Ys(A) : N !== "x" && N !== "y" && (x.select({ [N]: A }), _.push(N));
      }
    return r === "linear" ? bJ(x, b, w, M, h, _) : gJ(x, b, w, M, h, _);
  }
  async requestTiles() {
    const t = zr();
    this.prefetch && t.cancel(this.prefetch);
    const { binPad: n, tileX: r, tileY: i, origin: [s, o] } = this, [a, c] = this.bins = this.binDimensions(this), [u, l] = Du(this, this._filter), [f, h] = Ou(this, this._filter), d = l - u, p = h - f, y = Math.floor((u - s) * (a - n) / d), g = Math.floor((f - o) * (c - n) / p), m = (A, $) => [
      [s + A * d, s + (A + 1) * d],
      [o + $ * p, o + ($ + 1) * p]
    ], b = Math.floor((u - s) / d), w = r ? U2((l - s) / d) : b, v = Math.floor((f - o) / p), x = i ? U2((h - o) / p) : v, _ = [];
    for (let A = b; A <= w; ++A)
      for (let $ = v; $ <= x; ++$)
        _.push([A, $]);
    const M = _.map(
      ([A, $]) => t.query(this.tileQuery(m(A, $)))
    ), T = [];
    if (r)
      for (let A = v; A <= x; ++A)
        T.push([w + 1, A]), T.push([b - 1, A]);
    if (i) {
      const A = r ? b - 1 : b, $ = r ? w + 1 : w;
      for (let D = A; D <= $; ++D)
        T.push([D, x + 1]), T.push([D, v - 1]);
    }
    this.prefetch = T.map(
      ([A, $]) => t.prefetch(this.tileQuery(m(A, $)))
    );
    const N = await Promise.all(M);
    this.grids = [{ grid: hJ(a, c, y, g, _, N) }], this.convolve().update();
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var h;
    const { bins: t, kde: n, groupby: r } = this, [i, s] = t, { canvas: o, ctx: a, img: c } = pJ(this, i, s), u = yJ(this), l = r.indexOf((h = this.channelField("fill")) == null ? void 0 : h.as), f = l < 0 ? [] : n.map(({ key: d }) => d[l]);
    return this.data = n.map((d) => {
      var y;
      const p = mJ(this, f, (y = d.key) == null ? void 0 : y[l]);
      return j4(d, c.data, i, s, u, p), a.putImageData(c, 0, 0), { src: o.toDataURL() };
    }), this;
  }
  plotSpecs() {
    var s;
    const { type: t, data: n, plot: r } = this, i = {
      src: "src",
      width: r.innerWidth(),
      height: r.innerHeight(),
      preserveAspectRatio: "none",
      imageRendering: (s = this.channel("imageRendering")) == null ? void 0 : s.value,
      frameAnchor: "middle"
    };
    return [{ type: t, data: n, options: i }];
  }
}
function hJ(e, t, n, r, i, s) {
  const o = new Float64Array(e * t);
  return s.forEach((a, c) => {
    const [u, l] = i[c], f = u * e - n, h = l * t - r;
    dJ(e, t, o, a, f, h);
  }), o;
}
function dJ(e, t, n, r, i, s) {
  const o = r.numRows;
  if (o === 0)
    return;
  const a = r.getChild("index").toArray(), c = r.getChild("value").toArray();
  for (let u = 0; u < o; ++u) {
    const l = a[u], f = i + l % e, h = s + Math.floor(l / e);
    0 <= f && f < e && 0 <= h && h < t && (n[f + h * e] = c[u]);
  }
}
function pJ(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const r = q4(t, n), i = r.getContext("2d", { willReadFrequently: !0 }), s = i.getImageData(0, 0, t, n);
    e.image = { canvas: r, ctx: i, img: s, w: t, h: n };
  }
  return e.image;
}
function yJ(e) {
  const { densityMap: t, kde: n, plot: r } = e;
  let i = t.fill && r.getAttribute("colorDomain");
  if (!i) {
    let o = 0, a = 0;
    n.forEach((c) => {
      for (const u of c)
        u < o && (o = u), u > a && (a = u);
    }), i = o === 0 && a === 0 ? [0, 1] : [o, a];
  }
  const s = r.getAttribute("colorScale");
  return Vs({ x: { type: s, domain: i, range: [0, 1] } }).apply;
}
function mJ(e, t, n, r = 1024) {
  const { densityMap: i, plot: s } = e, o = s.getAttribute("colorScheme"), a = e.channel("fill");
  let c = i1(a == null ? void 0 : a.value) ? a.value : void 0;
  if (i.fill || o && !c) {
    if (o)
      try {
        return bh(
          r,
          Vs({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (u) {
        console.warn(u);
      }
  } else if (t.length) {
    const u = s.getAttribute("colorRange");
    c = Vs({ color: {
      domain: t,
      range: u,
      scheme: o || (u ? void 0 : "tableau10")
    } }).apply(n);
  }
  return bh(r, V4(c));
}
function P2(e, t, n, r, i, s) {
  const o = (r - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return i ? V`(${n} - ${e}::DOUBLE)${a}` : V`(${e}::DOUBLE - ${t})${a}`;
}
function gJ(e, t, n, r, i, s) {
  return e.select({
    index: V`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${i}`,
    value: r
  }).groupby("index", s);
}
function bJ(e, t, n, r, i, s) {
  const o = r.column ? `* ${r.column}` : "", a = (h, d) => e.clone().select({ xp: t, yp: n, i: h, w: d }), c = a(
    V`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${i}`,
    V`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), u = a(
    V`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    V`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), l = a(
    V`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${i}`,
    V`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), f = a(
    V`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    V`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return St.from(St.unionAll(c, u, l, f)).select({ index: "i", value: Ys("w") }, s).groupby("index", s).having(Q_("value", 0));
}
function U2(e) {
  const t = Math.floor(e);
  return t === e ? t - 1 : t;
}
function wJ(e, t, n) {
  var r = 1e-8, i = t - 1, s = n - 1, o = 0, a, c, u, l, f, h, d, p, y, g, 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, y = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), g = d * Math.sqrt(p + y) / y - (1 / (2 * n - 1) - 1 / (2 * t - 1)) * (p + 5 / 6 - 2 / (3 * y)), d = t / (t + n * Math.exp(2 * g))) : (a = Math.log(t / (t + n)), c = Math.log(n / (t + n)), l = Math.exp(t * a) / t, f = Math.exp(n * c) / n, g = l + f, e < l / g ? d = Math.pow(t * g * e, 1 / t) : d = 1 - Math.pow(n * g * (1 - e), 1 / n)), m = -Bo(t) - Bo(n) + Bo(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = vJ(d, t, n) - e, l = Math.exp(i * Math.log(d) + s * Math.log(1 - d) + m), f = h / l, d -= l = f / (1 - 0.5 * Math.min(1, f * (i / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + l)), d >= 1 && (d = 0.5 * (d + l + 1)), Math.abs(l) < r * d && o > 0)
      break;
  }
  return d;
}
function vJ(e, t, n) {
  var r = e === 0 || e === 1 ? 0 : Math.exp(Bo(t + n) - Bo(t) - Bo(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? r * z2(e, t, n) / t : 1 - r * z2(1 - e, n, t) / n;
}
function z2(e, t, n) {
  var r = 1e-30, i = 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) < r && (u = r), u = 1 / u, d = u; i <= 100 && (l = 2 * i, f = i * (n - i) * e / ((a + l) * (t + l)), u = 1 + f * u, Math.abs(u) < r && (u = r), c = 1 + f / c, Math.abs(c) < r && (c = r), u = 1 / u, d *= u * c, f = -(t + i) * (s + i) * e / ((t + l) * (o + l)), u = 1 + f * u, Math.abs(u) < r && (u = r), c = 1 + f / c, Math.abs(c) < r && (c = r), u = 1 / u, h = u * c, d *= h, !(Math.abs(h - 1) < 3e-7)); i++)
    ;
  return d;
}
function Bo(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], r = 1.000000000190015, i, s, o;
  for (o = (s = i = e) + 5.5, o -= (i + 0.5) * Math.log(o); t < 6; t++)
    r += n[t] / ++s;
  return Math.log(2.506628274631 * r / i) - o;
}
function _J(e, t) {
  var n = wJ(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 xJ extends Zs {
  constructor(t, n) {
    const { ci: r = 0.95, precision: i = 4, ...s } = n;
    super("line", t, s);
    const o = () => this.modelFit ? this.confidenceBand().update() : null;
    _n(this, "ci", r, o), _n(this, "precision", i, o);
  }
  query(t = []) {
    const n = this.channelField("x").as, r = this.channelField("y").as, i = Array.from(new Set(
      ["stroke", "z", "fx", "fy"].flatMap((s) => {
        var o;
        return ((o = this.channelField(s)) == null ? void 0 : o.as) || [];
      })
    ));
    return St.from(super.query(t)).select({
      intercept: GO(r, n),
      slope: HO(r, n),
      n: JO(r, n),
      ssy: ZO(r, n),
      ssx: KO(r, n),
      xm: QO(r, n),
      x0: i0(Ho(n).where(vc(r))),
      x1: i0(Go(n).where(vc(r)))
    }).select(i).groupby(i);
  }
  queryResult(t) {
    return this.modelFit = L4(t), this.lineData = this.modelFit.flatMap((n) => SJ(n)), this.confidenceBand();
  }
  confidenceBand() {
    const { ci: t, modelFit: n, precision: r, plot: i } = this, s = i.innerWidth();
    return this.areaData = t ? n.flatMap((o) => MJ(t, r, o, s)) : null, this;
  }
  plotSpecs() {
    const { lineData: t, areaData: n, channels: r, ci: i } = this, s = { x: "x", y: "y" }, o = { x: "x", y1: "y1", y2: "y2", fillOpacity: 0.1 };
    for (const a of r)
      switch (a.channel) {
        case "x":
        case "y":
        case "fill":
          break;
        case "stroke":
          s.stroke = o.fill = Ai(a);
          break;
        case "strokeOpacity":
          s.strokeOpacity = Ai(a);
          break;
        case "fillOpacity":
          o.fillOpacity = Ai(a);
          break;
        default:
          s[a.channel] = o[a.channel] = Ai(a);
          break;
      }
    return [
      ...i ? [{ type: "areaY", data: n, options: o }] : [],
      { type: "line", data: t, options: s }
    ];
  }
}
function SJ(e) {
  const { x0: t, x1: n, xm: r, intercept: i, slope: s, n: o, ssx: a, ssy: c, ...u } = e;
  return [
    { x: t, y: i + t * s, ...u },
    { x: n, y: i + n * s, ...u }
  ];
}
function MJ(e, t, n, r) {
  const { x0: i, x1: s, xm: o, intercept: a, slope: c, n: u, ssx: l, ssy: f, ...h } = n, d = t * (s - i) / r, p = _J((1 - e) / 2, u - 2) * Math.sqrt(f / (u - 2));
  return nn(i, s - d / 2, d).concat(s).map((y) => {
    const g = a + y * c, m = p * Math.sqrt(1 / u + (y - o) ** 2 / l);
    return { x: y, y1: g - m, y2: g + m, ...h };
  });
}
function AJ(e) {
  const t = e.toLowerCase(), n = e.length;
  let r = "";
  for (let i = 0; i < n; ++i)
    r += (e[i] !== t[i] ? "-" : "") + t[i];
  return r;
}
function o1(e) {
  const t = {};
  for (const n in e)
    t[AJ(n)] = e[n];
  return t;
}
function $J(e) {
  const { channels: t } = e, n = /* @__PURE__ */ new Set();
  let r = !1, i = !1;
  for (const s of t) {
    const { channel: o, field: a, as: c } = s;
    if (o === "orderby")
      r = !0;
    else if (a)
      if (a.aggregate)
        i = !0;
      else {
        if (n.has(c))
          continue;
        n.add(c);
      }
  }
  return !r && i && n.size && e.channels.push({ channel: "orderby", value: Array.from(n) }), e;
}
class IJ {
  constructor(t, {
    selection: n,
    channels: r = {}
  }) {
    this.mark = $J(t), this.selection = n;
    const i = Object.entries(o1(r));
    this.channels = i.length ? i : [["opacity", 0.2]], this.selection.addEventListener("value", J2(() => this.update()));
  }
  init(t) {
    this.svg = t;
    const n = this.values = [], r = this.mark.index, i = this.nodes = t.querySelectorAll(`[data-index="${r}"] > *`), { channels: s } = this;
    for (let o = 0; o < i.length; ++o) {
      const a = i[o];
      n.push(s.map((c) => a.getAttribute(c[0])));
    }
    return this.update();
  }
  async update() {
    const { svg: t, nodes: n, channels: r, values: i, mark: s, selection: o } = this;
    if (!t)
      return;
    const a = await TJ(s, o);
    for (let c = 0; c < n.length; ++c) {
      const u = n[c], l = i[c], f = a(u.__data__);
      for (let h = 0; h < r.length; ++h) {
        const [d, p] = r[h];
        u.setAttribute(d, f ? l[h] : p);
      }
    }
  }
}
async function TJ(e, t) {
  var u, l;
  const n = t == null ? void 0 : t.predicate(e);
  if (!n || n.length === 0)
    return () => !0;
  const r = (u = e.filterBy) == null ? void 0 : u.predicate(e, !0), i = { __: Li(n) }, s = e.query(r), o = s.groupby().length ? s.select(i) : s.$select(i), a = await e.coordinator.query(o), c = (l = a.getChild) == null ? void 0 : l.call(a, "__");
  return a.numRows || a.length ? c ? (f) => c.get(f) : (f) => a[f].__ : () => !1;
}
function a1(e) {
  const t = e.on;
  let n = !0;
  function r(i) {
    n = !1, i(), n = !0;
  }
  return e.reset = (...i) => {
    r(() => e.clear(...i));
  }, e.moveSilent = (...i) => {
    r(() => e.move(...i));
  }, e.on = (...i) => {
    if (i.length > 1 && i[1]) {
      const s = i[1];
      i[1] = (...o) => n && s(...o);
    }
    return t(...i);
  }, e;
}
function EJ() {
  return a1(TC());
}
function NJ() {
  return a1($C());
}
function DJ() {
  return a1(IC());
}
const j2 = 1e-12;
function My(e, t) {
  return e === t || e && t && Math.abs(e[0] - t[0]) < j2 && Math.abs(e[1] - t[1]) < j2 || !1;
}
function da(e, t) {
  var r;
  const n = (r = e.channelField(t)) == null ? void 0 : r.field;
  return (n == null ? void 0 : n.basis) || n;
}
function Ay(e, t, n = 1) {
  return t.invert(n * Math.floor(e / n));
}
function X4() {
  const e = this, t = e.getScreenCTM;
  let n;
  e.getScreenCTM = () => e.isConnected ? n = t.call(e) : n;
}
class G4 {
  constructor(t, {
    channel: n,
    selection: r,
    field: i,
    pixelSize: s = 1,
    peers: o = !0,
    brush: a
  }) {
    this.mark = t, this.channel = n, this.pixelSize = s || 1, this.selection = r, this.peers = o, this.field = i || da(t, [n, n + "1", n + "2"]), this.style = a && o1(a), this.brush = n === "y" ? DJ() : NJ(), this.brush.on("brush end", ({ selection: c }) => this.publish(c));
  }
  reset() {
    this.value = void 0, this.g && this.brush.reset(this.g);
  }
  activate() {
    this.selection.activate(this.clause(this.value || [0, 1]));
  }
  publish(t) {
    let n;
    t && (n = t.map((r) => Ay(r, this.scale, this.pixelSize)).sort((r, i) => r - i)), My(n, this.value) || (this.value = n, this.g.call(this.brush.moveSilent, t), this.selection.update(this.clause(n)));
  }
  clause(t) {
    const { mark: n, pixelSize: r, field: i, scale: s } = this;
    return {
      source: this,
      schema: { type: "interval", pixelSize: r, scales: [s] },
      clients: this.peers ? n.plot.markSet : (/* @__PURE__ */ new Set()).add(n),
      value: t,
      predicate: t ? He(i, t) : null
    };
  }
  init(t) {
    var u;
    const { brush: n, channel: r, style: i } = this;
    this.scale = t.scale(r);
    const s = t.scale("x").range, o = t.scale("y").range;
    n.extent([[be(s), be(o)], [Qt(s), Qt(o)]]);
    const a = Vt(t).selectAll('g[aria-label="facet"]'), c = a.size() ? a : Vt(t);
    if (this.g = c.append("g").attr("class", `interval-${r}`).each(X4).call(n).call(n.moveSilent, (u = this.value) == null ? void 0 : u.map(this.scale.apply)), i) {
      const l = this.g.selectAll("rect.selection");
      for (const f in i)
        l.attr(f, i[f]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
const pl = (e, t) => e - t;
class OJ {
  constructor(t, {
    selection: n,
    xfield: r,
    yfield: i,
    pixelSize: s = 1,
    peers: o = !0,
    brush: a
  }) {
    this.mark = t, this.pixelSize = s || 1, this.selection = n, this.peers = o, this.xfield = r || da(t, ["x", "x1", "x2"]), this.yfield = i || da(t, ["y", "y1", "y2"]), this.style = a && o1(a), this.brush = EJ(), this.brush.on("brush end", ({ selection: c }) => this.publish(c));
  }
  reset() {
    this.value = void 0, this.g && this.brush.reset(this.g);
  }
  activate() {
    this.selection.activate(this.clause(this.value || [[0, 1], [0, 1]]));
  }
  publish(t) {
    const { value: n, pixelSize: r, xscale: i, yscale: s } = this;
    let o, a;
    if (t) {
      const [c, u] = t;
      o = [c[0], u[0]].map((l) => Ay(l, i, r)).sort(pl), a = [c[1], u[1]].map((l) => Ay(l, s, r)).sort(pl);
    }
    (!My(o, n == null ? void 0 : n[0]) || !My(a, n == null ? void 0 : n[1])) && (this.value = t ? [o, a] : void 0, this.g.call(this.brush.moveSilent, t), this.selection.update(this.clause(this.value)));
  }
  clause(t) {
    const { mark: n, pixelSize: r, xfield: i, yfield: s, xscale: o, yscale: a } = this;
    return {
      source: this,
      schema: { type: "interval", pixelSize: r, scales: [o, a] },
      clients: this.peers ? n.plot.markSet : (/* @__PURE__ */ new Set()).add(n),
      value: t,
      predicate: t ? Li(He(i, t[0]), He(s, t[1])) : null
    };
  }
  init(t) {
    const { brush: n, style: r } = this, i = this.xscale = t.scale("x"), s = this.yscale = t.scale("y"), o = i.range, a = s.range;
    n.extent([[be(o), be(a)], [Qt(o), Qt(a)]]);
    const c = Vt(t).selectAll('g[aria-label="facet"]'), u = c.size() ? c : Vt(t);
    if (this.g = u.append("g").attr("class", "interval-xy").each(X4).call(n), r) {
      const l = this.g.selectAll("rect.selection");
      for (const f in r)
        l.attr(f, r[f]);
    }
    if (this.value) {
      const [l, f] = this.value[0].map(i.apply).sort(pl), [h, d] = this.value[1].map(s.apply).sort(pl);
      this.g.call(n.moveSilent, [[l, h], [f, d]]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
class H4 {
  constructor(t, {
    selection: n,
    channel: r,
    field: i
  }) {
    this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.channel = r, this.field = i || da(t, [r]);
  }
  clause(t) {
    const { clients: n, field: r } = this, i = t ? Nh(r, ma(t)) : null;
    return {
      source: this,
      schema: { type: "point" },
      clients: n,
      value: t,
      predicate: i
    };
  }
  init(t) {
    const n = this, { mark: r, channel: i, selection: s } = this, { data: o } = r, a = r.channelField(i).as, c = Vt(t).selectAll('g[aria-label="facet"]'), u = c.size() ? c : Vt(t), l = t.scale(i), f = !Os(s);
    u.on("pointerdown pointermove", function(h) {
      const [d, p] = En(h, this), y = LJ(o, a, l.invert(i === "x" ? d : p));
      s.update(f ? y : n.clause(y));
    }), !f && t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause(0));
    });
  }
}
function LJ(e, t, n) {
  let r = 1 / 0, i;
  return e.forEach((s) => {
    const o = Math.abs(s[t] - n);
    o < r && (r = o, i = s[t]);
  }), i;
}
const q2 = (e, t) => e - t;
class kJ {
  constructor(t, {
    x: n = new ff(),
    y: r = new ff(),
    xfield: i,
    yfield: s,
    zoom: o = !0,
    panx: a = !0,
    pany: c = !0
  }) {
    this.mark = t, this.xsel = n, this.ysel = r, this.xfield = i || da(t, ["x", "x1", "x2"]), this.yfield = s || da(t, ["y", "y1", "y2"]), this.zoom = zp(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("xDomain", l) && u.update();
    }), c && this.ysel.addEventListener("value", (l) => {
      u.setAttribute("yDomain", l) && u.update();
    });
  }
  publish(t) {
    if (this.panx) {
      const n = FJ(t, this.xscale);
      this.xsel.update(this.clause(n, this.xfield, this.xscale));
    }
    if (this.pany) {
      const n = RJ(t, this.yscale);
      this.ysel.update(this.clause(n, this.yfield, this.yscale));
    }
  }
  clause(t, n, r) {
    return {
      source: this,
      schema: { type: "interval", scales: [r] },
      clients: this.mark.plot.markSet,
      value: t,
      predicate: t ? He(n, t) : null
    };
  }
  init(t) {
    if (this.svg = t, this.initialized)
      return;
    this.initialized = !0;
    const { panx: n, pany: r, mark: { plot: { element: i } }, xsel: s, ysel: o } = this;
    this.xscale = t.scale("x"), this.yscale = t.scale("y");
    const a = this.xscale.range.slice().sort(q2), c = this.yscale.range.slice().sort(q2), u = zp(n, [-1 / 0, 1 / 0], a), l = zp(r, [-1 / 0, 1 / 0], c), f = wj().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", () => i.__zoom = new lr(1, 0, 0)).on("zoom", ({ transform: h }) => this.publish(h));
    if (Vt(i).call(f), n || r) {
      let h = !1;
      i.addEventListener("mouseenter", () => {
        if (!h) {
          if (h = !0, n) {
            const { xscale: d, xfield: p } = this;
            s.activate(this.clause(d.domain, p, d));
          }
          if (r) {
            const { yscale: d, yfield: p } = this;
            o.activate(this.clause(d.domain, p, d));
          }
        }
      }), i.addEventListener("mouseleave", () => h = !1);
    }
  }
}
function zp(e, t, n) {
  return e ? Array.isArray(e) ? e : t : n;
}
function FJ(e, t) {
  return t.range.map(e.invertX, e).map(t.invert, t);
}
function RJ(e, t) {
  return t.range.map(e.invertY, e).map(t.invert, t);
}
class J4 {
  constructor(t, {
    selection: n,
    channels: r,
    peers: i = !0
  }) {
    this.value = null, this.mark = t, this.selection = n, this.peers = i, this.channels = r.map((s) => {
      var a;
      const o = s === "color" ? ["fill", "stroke"] : s === "x" ? ["x", "x1", "x2"] : s === "y" ? ["y", "y1", "y2"] : [s];
      for (let c = 0; c < o.length; ++c) {
        const u = t.channelField(o[c]);
        if (u)
          return {
            field: ((a = u.field) == null ? void 0 : a.basis) || u.field,
            as: u.as
          };
      }
      throw new Error(`Missing channel: ${s}`);
    });
  }
  clause(t) {
    const { channels: n, mark: r } = this;
    let i = null;
    if (t) {
      const s = t.map((o) => {
        const a = o.map((c, u) => tx(n[u].field, ma(c)));
        return a.length > 1 ? Li(a) : a[0];
      });
      i = s.length > 1 ? Ky(s) : s[0];
    }
    return {
      source: this,
      schema: { type: "point" },
      clients: this.peers ? r.plot.markSet : (/* @__PURE__ */ new Set()).add(r),
      value: t,
      predicate: i
    };
  }
  init(t, n, r) {
    const { mark: i, channels: s, selection: o } = this, { data: a } = i;
    r = r || ((u) => {
      const l = a[u.__data__];
      return s.map((f) => l[f.as]);
    }), n = n || `[data-index="${i.index}"]`;
    const c = new Set(t.querySelectorAll(n));
    t.addEventListener("pointerdown", (u) => {
      const l = o.single ? o.value : this.value, f = u.target;
      let h = null;
      if (CJ(c, f)) {
        const d = r(f);
        u.shiftKey && (l != null && l.length) ? (h = l.filter((p) => $y(p, d)), h.length === l.length && h.push(d)) : (l == null ? void 0 : l.length) === 1 && !$y(l[0], d) ? h = null : h = [d];
      }
      this.value = h, BJ(l, h) && o.update(this.clause(h));
    }), t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause([this.channels.map(() => 0)]));
    });
  }
}
function CJ(e, t) {
  var n;
  return e.has(t) || e.has(t.parentNode) || e.has((n = t.parentNode) == null ? void 0 : n.parentNode);
}
function BJ(e, t) {
  return e == null || t == null ? e != null || t != null : e.length !== t.length || e.some((n, r) => $y(n, t[r]));
}
function $y(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !0;
  for (let r = 0; r < n; ++r)
    if (e[r] !== t[r])
      return !0;
  return !1;
}
class V2 {
  constructor(t, n) {
    const { as: r, ...i } = n;
    this.channel = t, this.options = { label: null, ...i }, this.selection = r, this.element = document.createElement("div"), this.element.setAttribute("class", "legend"), this.element.value = this;
  }
  setPlot(t) {
    const { channel: n, selection: r } = this, i = PJ(t, n);
    this.selection && i && (this.handler = new J4(i, { selection: r, channels: [n] }), this.selection.addEventListener("value", () => this.update()));
  }
  init(t) {
    const { channel: n, options: r, handler: i } = this, o = t.scale(n).type === "ordinal" ? r : { marginTop: 1, tickSize: 2, height: 28, ...r };
    return this.legend = t.legend(n, o), i && (i.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 && t.length ? new Set(t.map((i) => i[0])) : null, r = this.legend.querySelectorAll(":scope > div");
    for (const i of r) {
      const s = n ? n.has(i.__data__) : !0;
      i.style.opacity = s ? 1 : 0.2;
    }
  }
}
function PJ({ marks: e }, t) {
  const n = t === "color" ? ["fill", "stroke"] : t === "opacity" ? ["opacity", "fillOpacity", "strokeOpacity"] : null;
  if (n == null)
    return null;
  for (let r = e.length - 1; r > -1; --r)
    if (e[r].channelField(n))
      return e[r];
  return null;
}
const UJ = [
  "rectY-x",
  "rectX-y",
  "rect-x",
  "rect-y"
];
function zJ(e, t) {
  return UJ.includes(`${t}-${e}`);
}
function jJ(e, t = { steps: 25 }) {
  const n = (r, i) => zJ(i, r.type) ? {
    [`${i}1`]: jp(r, e, t),
    [`${i}2`]: jp(r, e, { ...t, offset: 1 })
  } : {
    [i]: jp(r, e, t)
  };
  return n[ux] = !0, n;
}
function jp(e, t, n) {
  return {
    column: t,
    label: t,
    get stats() {
      return ["min", "max"];
    },
    get columns() {
      return [t];
    },
    get basis() {
      return t;
    },
    toString() {
      const { min: r, max: i } = e.stats[t], s = qJ(r, i, n), o = qt(t), a = s.min === 0 ? o : `(${o} - ${s.min})`, c = `${(s.max - s.min) / s.steps}::DOUBLE`, u = n.offset ? `${n.offset} + ` : "";
      return `${s.min} + ${c} * (${u}FLOOR(${a} / ${c})::INTEGER)`;
    }
  };
}
function qJ(e, t, n) {
  let { steps: r = 25, minstep: i = 0, nice: s = !0 } = n;
  if (s !== !1) {
    const o = t - e, a = r, c = Math.LN10, u = Math.ceil(Math.log(a) / c);
    let l = Math.max(
      i,
      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 y = 0, g = f.length; y < g; ++y)
      h = l / f[y], h >= i && 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, r = Math.round((t - e) / l);
  }
  return { min: e, max: t, steps: r };
}
const VJ = (e) => e && typeof e == "object" && !Array.isArray(e);
class YJ extends Yc {
  constructor({
    element: t,
    filterBy: n,
    from: r,
    column: i,
    label: s = i,
    format: o = (l) => l,
    // TODO
    options: a,
    value: c,
    as: u
  } = {}) {
    var f, h, d, p;
    super(n), this.from = r, this.column = i, this.selection = u, this.format = o, this.element = t ?? document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this;
    const l = document.createElement("label");
    l.innerText = s || i, this.element.appendChild(l), this.select = document.createElement("select"), a && (this.data = a.map((y) => VJ(y) ? y : { value: y }), this.update()), c = c ?? ((f = this.selection) == null ? void 0 : f.value) ?? ((d = (h = this.data) == null ? void 0 : h[0]) == null ? void 0 : d.value), ((p = this.selection) == null ? void 0 : p.value) === void 0 && this.publish(c), this.element.appendChild(this.select), this.selection && (this.select.addEventListener("input", () => {
      this.publish(this.selectedValue() ?? null);
    }), Os(this.selection) || this.selection.addEventListener("value", (y) => {
      y !== this.select.value && this.selectedValue(y);
    }));
  }
  selectedValue(t) {
    var n;
    if (arguments.length === 0) {
      const r = this.select.selectedIndex;
      return this.data[r].value;
    } else {
      const r = (n = this.data) == null ? void 0 : n.findIndex((i) => i.value === t);
      r >= 0 ? this.select.selectedIndex = r : this.select.value = String(t);
    }
  }
  reset() {
    this.select.selectedIndex = this.from ? 0 : -1;
  }
  publish(t) {
    const { selection: n, column: r } = this;
    Os(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: t !== "" && t !== void 0 ? Nh(r, ma(t)) : null
    }) : $i(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: r } = this;
    return n ? St.from(n).select({ value: r }).distinct().where(t).orderby(r) : null;
  }
  queryResult(t) {
    return this.data = [{ value: "", label: "All" }, ...t], this;
  }
  update() {
    var i;
    const { data: t, format: n, select: r } = this;
    r.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.selectedValue(((i = this.selection) == null ? void 0 : i.value) ?? ""), this;
  }
}
const WJ = { contains: mO, prefix: gO, suffix: bO, regexp: yO };
let XJ = 0;
class GJ extends Yc {
  constructor({
    element: t,
    filterBy: n,
    from: r,
    column: i,
    label: s,
    type: o = "contains",
    as: a
  } = {}) {
    if (super(n), this.id = "search_" + ++XJ, this.type = o, this.from = r, this.column = i, this.selection = a, this.element = t ?? document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this, s) {
      const c = document.createElement("label");
      c.setAttribute("for", this.id), c.innerText = s, this.element.appendChild(c);
    }
    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);
    }), Os(this.selection) || this.selection.addEventListener("value", (c) => {
      c !== this.searchbox.value && (this.searchbox.value = c);
    }));
  }
  reset() {
    this.searchbox.value = "";
  }
  publish(t) {
    const { selection: n, column: r, type: i } = this;
    Os(n) ? n.update({
      source: this,
      schema: { type: i },
      value: t,
      predicate: t ? WJ[i](r, ma(t)) : null
    }) : $i(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: r } = this;
    return n ? St.from(n).select({ list: r }).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 r of this.data) {
      const i = document.createElement("option");
      i.setAttribute("value", r.list), t.append(i);
    }
    return this.datalist && this.datalist.remove(), this.element.appendChild(this.datalist = t), this.searchbox.setAttribute("list", n), this;
  }
}
let HJ = 0;
class JJ extends Yc {
  constructor({
    element: t,
    filterBy: n,
    as: r,
    min: i,
    max: s,
    step: o,
    from: a,
    column: c,
    label: u = c,
    value: l = r == null ? void 0 : r.value,
    width: f
  } = {}) {
    var h;
    if (super(n), this.id = "slider_" + ++HJ, this.from = a, this.column = c || "value", this.selection = r, this.min = i, this.max = s, this.step = o, this.element = t || document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this, u) {
      const d = document.createElement("label");
      d.setAttribute("for", this.id), d.innerText = u, this.element.appendChild(d);
    }
    this.slider = document.createElement("input"), this.slider.setAttribute("id", this.id), this.slider.setAttribute("type", "range"), f != null && (this.slider.style.width = `${+f}px`), i != null && this.slider.setAttribute("min", i), s != null && this.slider.setAttribute("max", s), o != null && this.slider.setAttribute("step", o), l != null && (this.slider.setAttribute("value", l), ((h = this.selection) == null ? void 0 : h.value) === void 0 && this.publish(l)), this.element.appendChild(this.slider), this.selection && (this.slider.addEventListener("input", () => {
      this.publish(+this.slider.value);
    }), Os(this.selection) || this.selection.addEventListener("value", (d) => {
      d !== +this.slider.value && (this.slider.value = d);
    }));
  }
  query(t = []) {
    const { from: n, column: r } = this;
    return !n || this.min != null && this.max != null ? null : St.select({ min: Ho(r), max: Go(r) }).from(n).where(t);
  }
  queryResult(t) {
    const { min: n, max: r } = Array.from(t)[0];
    return this.min == null && this.slider.setAttribute("min", n), this.max == null && this.slider.setAttribute("max", r), this.step == null && this.slider.setAttribute("step", (r - n) / 500), this;
  }
  publish(t) {
    const { selection: n, column: r } = this;
    Os(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: Nh(r, ma(t))
    }) : $i(this.selection) && n.update(t);
  }
}
const Z4 = u1((e) => {
  const t = c1(e);
  return (n) => n == null ? "" : typeof n == "number" ? t(n) : n instanceof Date ? K4(n) : `${n}`;
}), c1 = u1((e) => (t) => t === 0 ? "0" : t.toLocaleString(e));
Z4();
c1();
function K4(e) {
  return fM(e, "Invalid Date");
}
function u1(e) {
  let t = u1, n;
  return (r = "en") => r === t ? n : n = e(t = r);
}
let ZJ = -1;
class KJ extends Yc {
  constructor({
    element: t,
    filterBy: n,
    from: r,
    columns: i = ["*"],
    align: s = {},
    format: o,
    width: a,
    maxWidth: c,
    height: u = 500,
    rowBatch: l = 100
  } = {}) {
    super(n), this.id = `table-${++ZJ}`, this.from = r, this.columns = i, this.format = o, this.align = s, this.widths = typeof a == "object" ? a : {}, this.offset = 0, this.limit = +l, this.pending = !1, this.sortHeader = null, this.sortColumn = null, this.sortDesc = !1, this.element = t || document.createElement("div"), this.element.setAttribute("id", this.id), this.element.value = this, typeof a == "number" && (this.element.style.width = `${a}px`), c && (this.element.style.maxWidth = `${c}px`), this.element.style.maxHeight = `${u}px`, this.element.style.overflow = "auto";
    let f = -1;
    this.element.addEventListener("scroll", (h) => {
      const { pending: d, loaded: p } = this, { scrollHeight: y, scrollTop: g, clientHeight: m } = h.target, b = g < f;
      f = g, !(b || d || p) && y - g < 2 * m && (this.pending = !0, this.requestData(this.offset + this.limit));
    }), 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);
  }
  requestData(t = 0) {
    var r;
    this.offset = t;
    const n = this.query((r = this.filterBy) == null ? void 0 : r.predicate(this));
    this.requestQuery(n), zr().prefetch(n.clone().offset(t + this.limit));
  }
  fields() {
    return this.columns.map((t) => Th(this.from, t));
  }
  fieldInfo(t) {
    this.schema = t;
    const n = this.head;
    n.innerHTML = "";
    const r = document.createElement("tr");
    for (const { column: i } of t) {
      const s = document.createElement("th");
      s.addEventListener("click", (o) => this.sort(o, i)), s.appendChild(document.createElement("span")), s.appendChild(document.createTextNode(i)), r.appendChild(s);
    }
    return n.appendChild(r), this.formats = QJ(this.format, t), this.style.innerText = nZ(
      this.id,
      tZ(this.align, t),
      eZ(this.widths, t)
    ), this;
  }
  query(t = []) {
    const { from: n, limit: r, offset: i, schema: s, sortColumn: o, sortDesc: a } = this;
    return St.from(n).select(s.map((c) => c.column)).where(t).orderby(o ? a ? uO(o) : o : []).limit(r).offset(i);
  }
  queryResult(t) {
    return this.pending || (this.loaded = !1, this.body.replaceChildren()), this.data = t, this;
  }
  update() {
    const { body: t, formats: n, data: r, schema: i, limit: s } = this, o = i.length;
    let a = 0;
    for (const c of r) {
      ++a;
      const u = document.createElement("tr");
      for (let l = 0; l < o; ++l) {
        const f = c[i[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) {
    n === this.sortColumn ? this.sortDesc = !this.sortDesc : (this.sortColumn = n, this.sortDesc = !1);
    const r = t.currentTarget, i = this.sortHeader;
    i === r && t.metaKey ? (i.firstChild.textContent = "", this.sortHeader = null, this.sortColumn = null) : (i && (i.firstChild.textContent = ""), this.sortHeader = r, r.firstChild.textContent = this.sortDesc ? "▾" : "▴"), this.requestData();
  }
}
function QJ(e = {}, t, n) {
  return t.map(({ column: r, type: i }) => {
    if (r in e)
      return e[r];
    switch (i) {
      case "number":
        return c1(n);
      case "date":
        return K4;
      default:
        return Z4(n);
    }
  });
}
function tZ(e = {}, t) {
  return t.map(({ column: n, type: r }) => n in e ? e[n] : r === "number" ? "right" : "left");
}
function eZ(e = {}, t) {
  return t.map(({ column: n }) => e[n]);
}
function nZ(e, t, n) {
  const r = [];
  return t.forEach((i, s) => {
    const o = +n[s];
    if (i !== "left" || o) {
      const a = i !== "left" ? `text-align:${i};` : "", c = o ? `width:${o}px;max-width:${o}px;` : "";
      r.push(`#${e} tr>:nth-child(${s + 1}) {${a}${c}}`);
    }
  }), r.join(" ");
}
function Q4(e, ...t) {
  var r;
  const n = ((r = e == null ? void 0 : e.context) == null ? void 0 : r.coordinator) ?? zr();
  for (const i of t)
    n.connect(i);
}
function Ld(e, t, n) {
  const r = new t(n);
  return Q4(e, r), r.element;
}
function rZ(e) {
  return Ld(this, YJ, e);
}
function iZ(e) {
  return Ld(this, GJ, e);
}
function sZ(e) {
  return Ld(this, JJ, e);
}
function oZ(e) {
  return Ld(this, KJ, e);
}
function tI({ direction: e = "vertical", wrap: t = !1 }, n) {
  const r = document.createElement("div");
  return r.style.display = "flex", r.style.flexDirection = e === "vertical" ? "column" : "row", r.style.flexWrap = t ? t === !0 ? "wrap" : t : "nowrap", r.style.justifyContent = "flex-start", r.style.alignItems = "flex-start", n.forEach((i) => r.appendChild(i)), r.value = { element: r }, r;
}
function aZ(...e) {
  return tI({ direction: "vertical" }, e.flat());
}
function cZ(...e) {
  return tI({ direction: "horizontal" }, e.flat());
}
function eI({ dim: e = "width", size: t = 10 }) {
  const n = document.createElement("span");
  n.style.display = "inline-block", n.style[e] = Number.isNaN(+t) ? t : `${t}px`;
  const r = { element: n };
  return n.value = r, n;
}
function uZ(e) {
  return eI({ dim: "height", size: e });
}
function lZ(e) {
  return eI({ dim: "width", size: e });
}
class nI extends Map {
  request(t, n) {
    if (this.has(t))
      n(this.get(t));
    else {
      const r = this.waiting || (this.waiting = /* @__PURE__ */ new Map()), i = r.get(t) || [];
      r.set(t, i.concat(n));
    }
  }
  set(t, n) {
    this.has(t) && console.warn(`Overwriting named plot "${t}".`);
    const { waiting: r } = this;
    return r != null && r.has(t) && (r.get(t).forEach((i) => i(n)), r.delete(t)), super.set(t, n);
  }
}
const l1 = new nI();
function fZ(e, t, n) {
  var i;
  (((i = e == null ? void 0 : e.context) == null ? void 0 : i.namedPlots) ?? l1).request(t, n);
}
function hZ(e, t, n) {
  var i;
  (((i = e == null ? void 0 : e.context) == null ? void 0 : i.namedPlots) ?? l1).set(t, n);
}
function rI(e) {
  return (t) => hZ(this, e, t);
}
function iI(e, t, n) {
  $i(n) ? (n.addEventListener("value", (r) => {
    e.setAttribute(t, r), e.update();
  }), n.value !== void 0 && e.setAttribute(t, n.value)) : e.setAttribute(t, n);
}
function dZ(e, t) {
  return (n) => {
    iI(n, e, t);
  };
}
function f1(e) {
  return (t) => {
    for (const [n, r] of Object.entries(e))
      iI(t, n, r);
  };
}
function sI(e) {
  const { top: t, bottom: n, left: r, right: i } = e, s = {};
  return t !== void 0 && (s.marginTop = t), n !== void 0 && (s.marginBottom = n), r !== void 0 && (s.marginLeft = r), i !== void 0 && (s.marginRight = i), f1(s);
}
function oI(e) {
  return f1({
    marginTop: e,
    marginBottom: e,
    marginLeft: e,
    marginRight: e
  });
}
function aI(e) {
  return f1({ xDomain: e, yDomain: e });
}
const k = (e) => (t) => dZ(e, t), cI = k("style"), uI = k("width"), lI = k("height"), fI = k("marginLeft"), hI = k("marginRight"), dI = k("marginTop"), pI = k("marginBottom"), yI = k("align"), mI = k("aspectRatio"), gI = k("axis"), bI = k("inset"), wI = k("grid"), vI = k("label"), _I = k("padding"), xI = k("round"), SI = k("xScale"), MI = k("xDomain"), AI = k("xRange"), $I = k("xNice"), II = k("xInset"), TI = k("xInsetLeft"), EI = k("xInsetRight"), NI = k("xClamp"), DI = k("xRound"), OI = k("xAlign"), LI = k("xPadding"), kI = k("xPaddingInner"), FI = k("xPaddingOuter"), RI = k("xAxis"), CI = k("xTicks"), BI = k("xTickSize"), PI = k("xTickSpacing"), UI = k("xTickPadding"), zI = k("xTickFormat"), jI = k("xTickRotate"), qI = k("xGrid"), VI = k("xLine"), YI = k("xLabel"), WI = k("xLabelAnchor"), XI = k("xLabelOffset"), GI = k("xFontVariant"), HI = k("xAriaLabel"), JI = k("xAriaDescription"), ZI = k("xReverse"), KI = k("xZero"), QI = k("yScale"), t8 = k("yDomain"), e8 = k("yRange"), n8 = k("yNice"), r8 = k("yInset"), i8 = k("yInsetTop"), s8 = k("yInsetBottom"), o8 = k("yClamp"), a8 = k("yRound"), c8 = k("yAlign"), u8 = k("yPadding"), l8 = k("yPaddingInner"), f8 = k("yPaddingOuter"), h8 = k("yAxis"), d8 = k("yTicks"), p8 = k("yTickSize"), y8 = k("yTickSpacing"), m8 = k("yTickPadding"), g8 = k("yTickFormat"), b8 = k("yTickRotate"), w8 = k("yGrid"), v8 = k("yLine"), _8 = k("yLabel"), x8 = k("yLabelAnchor"), S8 = k("yLabelOffset"), M8 = k("yFontVariant"), A8 = k("yAriaLabel"), $8 = k("yAriaDescription"), I8 = k("yReverse"), T8 = k("yZero"), E8 = k("facetMargin"), N8 = k("facetMarginTop"), D8 = k("facetMarginBottom"), O8 = k("facetMarginLeft"), L8 = k("facetMarginRight"), k8 = k("facetGrid"), F8 = k("facetLabel"), R8 = k("fxDomain"), C8 = k("fxRange"), B8 = k("fxNice"), P8 = k("fxInset"), U8 = k("fxInsetLeft"), z8 = k("fxInsetRight"), j8 = k("fxRound"), q8 = k("fxAlign"), V8 = k("fxPadding"), Y8 = k("fxPaddingInner"), W8 = k("fxPaddingOuter"), X8 = k("fxAxis"), G8 = k("fxTicks"), H8 = k("fxTickSize"), J8 = k("fxTickSpacing"), Z8 = k("fxTickPadding"), K8 = k("fxTickFormat"), Q8 = k("fxTickRotate"), t5 = k("fxGrid"), e5 = k("fxLine"), n5 = k("fxLabel"), r5 = k("fxLabelAnchor"), i5 = k("fxLabelOffset"), s5 = k("fxFontVariant"), o5 = k("fxAriaLabel"), a5 = k("fxAriaDescription"), c5 = k("fxReverse"), u5 = k("fyDomain"), l5 = k("fyRange"), f5 = k("fyNice"), h5 = k("fyInset"), d5 = k("fyInsetTop"), p5 = k("fyInsetBottom"), y5 = k("fyRound"), m5 = k("fyAlign"), g5 = k("fyPadding"), b5 = k("fyPaddingInner"), w5 = k("fyPaddingOuter"), v5 = k("fyAxis"), _5 = k("fyTicks"), x5 = k("fyTickSize"), S5 = k("fyTickSpacing"), M5 = k("fyTickPadding"), A5 = k("fyTickFormat"), $5 = k("fyTickRotate"), I5 = k("fyGrid"), T5 = k("fyLine"), E5 = k("fyLabel"), N5 = k("fyLabelAnchor"), D5 = k("fyLabelOffset"), O5 = k("fyFontVariant"), L5 = k("fyAriaLabel"), k5 = k("fyAriaDescription"), F5 = k("fyReverse"), R5 = k("colorScale"), C5 = k("colorDomain"), B5 = k("colorRange"), P5 = k("colorClamp"), U5 = k("colorN"), z5 = k("colorNice"), j5 = k("colorScheme"), q5 = k("colorInterpolate"), V5 = k("colorPivot"), Y5 = k("colorSymmetric"), W5 = k("colorLabel"), X5 = k("colorReverse"), G5 = k("colorZero"), H5 = k("colorTickFormat"), J5 = k("opacityScale"), Z5 = k("opacityDomain"), K5 = k("opacityRange"), Q5 = k("opacityClamp"), tT = k("opacityNice"), eT = k("opacityLabel"), nT = k("opacityReverse"), rT = k("opacityZero"), iT = k("opacityTickFormat"), sT = k("rScale"), oT = k("rDomain"), aT = k("rRange"), cT = k("rClamp"), uT = k("rNice"), lT = k("rZero"), fT = k("lengthScale"), hT = k("lengthDomain"), dT = k("lengthRange"), pT = k("lengthClamp"), yT = k("lengthNice"), mT = k("lengthZero"), gT = k("projectionType"), bT = k("projectionParallels"), wT = k("projectionPrecision"), vT = k("projectionRotate"), _T = k("projectionDomain"), xT = k("projectionInset"), ST = k("projectionInsetLeft"), MT = k("projectionInsetRight"), AT = k("projectionInsetTop"), $T = k("projectionInsetBottom"), IT = k("projectionClip"), pZ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  align: yI,
  aspectRatio: mI,
  axis: gI,
  colorClamp: P5,
  colorDomain: C5,
  colorInterpolate: q5,
  colorLabel: W5,
  colorN: U5,
  colorNice: z5,
  colorPivot: V5,
  colorRange: B5,
  colorReverse: X5,
  colorScale: R5,
  colorScheme: j5,
  colorSymmetric: Y5,
  colorTickFormat: H5,
  colorZero: G5,
  facetGrid: k8,
  facetLabel: F8,
  facetMargin: E8,
  facetMarginBottom: D8,
  facetMarginLeft: O8,
  facetMarginRight: L8,
  facetMarginTop: N8,
  fxAlign: q8,
  fxAriaDescription: a5,
  fxAriaLabel: o5,
  fxAxis: X8,
  fxDomain: R8,
  fxFontVariant: s5,
  fxGrid: t5,
  fxInset: P8,
  fxInsetLeft: U8,
  fxInsetRight: z8,
  fxLabel: n5,
  fxLabelAnchor: r5,
  fxLabelOffset: i5,
  fxLine: e5,
  fxNice: B8,
  fxPadding: V8,
  fxPaddingInner: Y8,
  fxPaddingOuter: W8,
  fxRange: C8,
  fxReverse: c5,
  fxRound: j8,
  fxTickFormat: K8,
  fxTickPadding: Z8,
  fxTickRotate: Q8,
  fxTickSize: H8,
  fxTickSpacing: J8,
  fxTicks: G8,
  fyAlign: m5,
  fyAriaDescription: k5,
  fyAriaLabel: L5,
  fyAxis: v5,
  fyDomain: u5,
  fyFontVariant: O5,
  fyGrid: I5,
  fyInset: h5,
  fyInsetBottom: p5,
  fyInsetTop: d5,
  fyLabel: E5,
  fyLabelAnchor: N5,
  fyLabelOffset: D5,
  fyLine: T5,
  fyNice: f5,
  fyPadding: g5,
  fyPaddingInner: b5,
  fyPaddingOuter: w5,
  fyRange: l5,
  fyReverse: F5,
  fyRound: y5,
  fyTickFormat: A5,
  fyTickPadding: M5,
  fyTickRotate: $5,
  fyTickSize: x5,
  fyTickSpacing: S5,
  fyTicks: _5,
  grid: wI,
  height: lI,
  inset: bI,
  label: vI,
  lengthClamp: pT,
  lengthDomain: hT,
  lengthNice: yT,
  lengthRange: dT,
  lengthScale: fT,
  lengthZero: mT,
  margin: oI,
  marginBottom: pI,
  marginLeft: fI,
  marginRight: hI,
  marginTop: dI,
  margins: sI,
  name: rI,
  opacityClamp: Q5,
  opacityDomain: Z5,
  opacityLabel: eT,
  opacityNice: tT,
  opacityRange: K5,
  opacityReverse: nT,
  opacityScale: J5,
  opacityTickFormat: iT,
  opacityZero: rT,
  padding: _I,
  projectionClip: IT,
  projectionDomain: _T,
  projectionInset: xT,
  projectionInsetBottom: $T,
  projectionInsetLeft: ST,
  projectionInsetRight: MT,
  projectionInsetTop: AT,
  projectionParallels: bT,
  projectionPrecision: wT,
  projectionRotate: vT,
  projectionType: gT,
  rClamp: cT,
  rDomain: oT,
  rNice: uT,
  rRange: aT,
  rScale: sT,
  rZero: lT,
  round: xI,
  style: cI,
  width: uI,
  xAlign: OI,
  xAriaDescription: JI,
  xAriaLabel: HI,
  xAxis: RI,
  xClamp: NI,
  xDomain: MI,
  xFontVariant: GI,
  xGrid: qI,
  xInset: II,
  xInsetLeft: TI,
  xInsetRight: EI,
  xLabel: YI,
  xLabelAnchor: WI,
  xLabelOffset: XI,
  xLine: VI,
  xNice: $I,
  xPadding: LI,
  xPaddingInner: kI,
  xPaddingOuter: FI,
  xRange: AI,
  xReverse: ZI,
  xRound: DI,
  xScale: SI,
  xTickFormat: zI,
  xTickPadding: UI,
  xTickRotate: jI,
  xTickSize: BI,
  xTickSpacing: PI,
  xTicks: CI,
  xZero: KI,
  xyDomain: aI,
  yAlign: c8,
  yAriaDescription: $8,
  yAriaLabel: A8,
  yAxis: h8,
  yClamp: o8,
  yDomain: t8,
  yFontVariant: M8,
  yGrid: w8,
  yInset: r8,
  yInsetBottom: s8,
  yInsetTop: i8,
  yLabel: _8,
  yLabelAnchor: x8,
  yLabelOffset: S8,
  yLine: v8,
  yNice: n8,
  yPadding: u8,
  yPaddingInner: l8,
  yPaddingOuter: f8,
  yRange: e8,
  yReverse: I8,
  yRound: a8,
  yScale: QI,
  yTickFormat: g8,
  yTickPadding: m8,
  yTickRotate: b8,
  yTickSize: p8,
  yTickSpacing: y8,
  yTicks: d8,
  yZero: T8
}, Symbol.toStringTag, { value: "Module" }));
function yZ(e, t) {
  return { table: e, options: t };
}
const mZ = /* @__PURE__ */ new Set([
  "frame",
  "axisX",
  "axisY",
  "axisFx",
  "axisFy",
  "gridX",
  "gridY",
  "gridFx",
  "gridFy",
  "hexgrid",
  "graticule",
  "sphere"
]);
function rt(e, t, n = {}) {
  arguments.length === 2 && !Array.isArray(t) && (n = t, t = mZ.has(e) ? null : [{}]);
  const r = e.startsWith("area") || e.startsWith("line") ? UH : Zs;
  return h1(r, e, t, n);
}
function h1(e, t, n, r) {
  return (i) => {
    i.addMark(new e(t, n, r));
  };
}
function ts(e, t, n) {
  return (r) => {
    r.addMark(new e(t, n));
  };
}
const TT = (...e) => rt("area", ...e), ET = (...e) => rt("areaX", ...e), NT = (...e) => rt("areaY", ...e), DT = (...e) => rt("line", ...e), OT = (...e) => rt("lineX", ...e), LT = (...e) => rt("lineY", ...e), kT = (...e) => rt("barX", ...e), FT = (...e) => rt("barY", ...e), RT = (...e) => rt("cell", ...e), CT = (...e) => rt("cellX", ...e), BT = (...e) => rt("cellY", ...e), PT = (...e) => rt("rect", ...e), UT = (...e) => rt("rectX", ...e), zT = (...e) => rt("rectY", ...e), jT = (...e) => rt("dot", ...e), qT = (...e) => rt("dotX", ...e), VT = (...e) => rt("dotY", ...e), YT = (...e) => rt("circle", ...e), WT = (...e) => rt("hexagon", ...e), XT = (...e) => rt("text", ...e), GT = (...e) => rt("textX", ...e), HT = (...e) => rt("textY", ...e), JT = (...e) => rt("ruleX", ...e), ZT = (...e) => rt("ruleY", ...e), KT = (...e) => rt("tickX", ...e), QT = (...e) => rt("tickY", ...e), tE = (...e) => rt("vector", ...e), eE = (...e) => rt("vectoX", ...e), nE = (...e) => rt("vectorY", ...e), rE = (...e) => rt("spike", ...e), iE = (...e) => rt("image", ...e), sE = (...e) => h1(W4, "areaX", ...e), oE = (...e) => h1(W4, "areaY", ...e), aE = (...e) => ts(oJ, ...e), cE = (...e) => ts(nJ, ...e), uE = (...e) => ts(ZH, ...e), lE = (...e) => ts(Y4, ...e), fE = (...e) => ts(fJ, ...e), hE = (...e) => ts(lJ, ...e), dE = (...e) => rt("hexgrid", ...e), pE = (...e) => ts(xJ, ...e), yE = (...e) => rt("voronoi", ...e), mE = (...e) => rt("voronoiMesh", ...e), gE = (...e) => rt("delaunayLink", ...e), bE = (...e) => rt("delaunayMesh", ...e), wE = (...e) => rt("hull", ...e), vE = (...e) => rt("arrow", ...e), _E = (...e) => rt("link", ...e), xE = (...e) => rt("frame", ...e), SE = (...e) => rt("axisX", ...e), ME = (...e) => rt("axisY", ...e), AE = (...e) => rt("axisFx", ...e), $E = (...e) => rt("axisFy", ...e), IE = (...e) => rt("gridX", ...e), TE = (...e) => rt("gridY", ...e), EE = (...e) => rt("gridFx", ...e), NE = (...e) => rt("gridFy", ...e), DE = (...e) => ts(uJ, ...e), OE = (...e) => rt("sphere", ...e), LE = (...e) => rt("graticule", ...e), gZ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  area: TT,
  areaX: ET,
  areaY: NT,
  arrow: vE,
  axisFx: AE,
  axisFy: $E,
  axisX: SE,
  axisY: ME,
  barX: kT,
  barY: FT,
  cell: RT,
  cellX: CT,
  cellY: BT,
  circle: YT,
  contour: uE,
  delaunayLink: gE,
  delaunayMesh: bE,
  denseLine: cE,
  density: aE,
  densityX: sE,
  densityY: oE,
  dot: jT,
  dotX: qT,
  dotY: VT,
  frame: xE,
  geo: DE,
  graticule: LE,
  gridFx: EE,
  gridFy: NE,
  gridX: IE,
  gridY: TE,
  hexagon: WT,
  hexbin: hE,
  hexgrid: dE,
  hull: wE,
  image: iE,
  line: DT,
  lineX: OT,
  lineY: LT,
  link: _E,
  raster: lE,
  rasterTile: fE,
  rect: PT,
  rectX: UT,
  rectY: zT,
  regressionY: pE,
  ruleX: JT,
  ruleY: ZT,
  sphere: OE,
  spike: rE,
  text: XT,
  textX: GT,
  textY: HT,
  tickX: KT,
  tickY: QT,
  vector: tE,
  vectorX: eE,
  vectorY: nE,
  voronoi: yE,
  voronoiMesh: mE
}, Symbol.toStringTag, { value: "Module" }));
function es(e, t) {
  return (n) => {
    const r = n.marks[n.marks.length - 1];
    n.addInteractor(new e(r, t));
  };
}
function kE({ by: e, ...t }) {
  return es(IJ, { selection: e, channels: t });
}
function Lu({ as: e, ...t }) {
  return es(J4, { ...t, selection: e });
}
function FE(e) {
  return Lu({ ...e, channels: ["x"] });
}
function RE(e) {
  return Lu({ ...e, channels: ["y"] });
}
function CE(e) {
  return Lu({ ...e, channels: ["color"] });
}
function BE({ as: e, ...t }) {
  return es(H4, { ...t, selection: e, channel: "x" });
}
function PE({ as: e, ...t }) {
  return es(H4, { ...t, selection: e, channel: "y" });
}
function UE({ as: e, ...t }) {
  return es(G4, { ...t, selection: e, channel: "x" });
}
function zE({ as: e, ...t }) {
  return es(G4, { ...t, selection: e, channel: "y" });
}
function jE({ as: e, ...t }) {
  return es(OJ, { ...t, selection: e });
}
function Na(e) {
  return es(kJ, e);
}
function qE(e = {}) {
  return Na({ ...e, zoom: !1 });
}
function VE(e = {}) {
  return Na({ ...e, zoom: !1, pany: !1 });
}
function YE(e = {}) {
  return Na({ ...e, zoom: !1, panx: !1 });
}
function WE(e = {}) {
  return Na(e);
}
function XE(e = {}) {
  return Na({ ...e, pany: !1 });
}
function GE(e = {}) {
  return Na({ ...e, panx: !1 });
}
const bZ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  highlight: kE,
  intervalX: UE,
  intervalXY: jE,
  intervalY: zE,
  nearestX: BE,
  nearestY: PE,
  pan: qE,
  panX: VE,
  panY: YE,
  panZoom: WE,
  panZoomX: XE,
  panZoomY: GE,
  toggle: Lu,
  toggleColor: CE,
  toggleX: FE,
  toggleY: RE
}, Symbol.toStringTag, { value: "Module" }));
function d1(e, t = {}) {
  if (t.for) {
    const { for: n, ...r } = t, i = new V2(e, r), s = typeof n, o = (a) => a.addLegend(i, !1);
    return s === "string" ? fZ(this, n, o) : n.value && o(n.value), i.element;
  } else
    return (n) => n.addLegend(new V2(e, t));
}
function HE(e) {
  return d1.call(this, "color", e);
}
function JE(e) {
  return d1.call(this, "opacity", e);
}
function ZE(e) {
  return d1.call(this, "symbol", e);
}
const wZ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  colorLegend: HE,
  opacityLegend: JE,
  symbolLegend: ZE
}, Symbol.toStringTag, { value: "Module" }));
function vZ(...e) {
  const t = new EH();
  return e.flat().forEach((n) => n(t)), Q4(this, ...t.marks), t.element;
}
const _Z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Fixed: rm,
  Param: Ss,
  Query: St,
  Selection: ff,
  agg: NO,
  align: yI,
  and: Li,
  area: TT,
  areaX: ET,
  areaY: NT,
  argmax: r0,
  argmin: n0,
  arrayAgg: n9,
  arrow: vE,
  aspectRatio: mI,
  avg: LO,
  axis: gI,
  axisFx: AE,
  axisFy: $E,
  axisX: SE,
  axisY: ME,
  barX: kT,
  barY: FT,
  bin: jJ,
  cast: em,
  castDouble: i0,
  castInteger: r9,
  cell: RT,
  cellX: CT,
  cellY: BT,
  centroid: nm,
  centroidX: u9,
  centroidY: l9,
  circle: YT,
  colorClamp: P5,
  colorDomain: C5,
  colorInterpolate: q5,
  colorLabel: W5,
  colorLegend: HE,
  colorN: U5,
  colorNice: z5,
  colorPivot: V5,
  colorRange: B5,
  colorReverse: X5,
  colorScale: R5,
  colorScheme: j5,
  colorSymmetric: Y5,
  colorTickFormat: H5,
  colorZero: G5,
  column: Th,
  contour: uE,
  coordinator: zr,
  corr: WO,
  count: xs,
  covarPop: XO,
  create: Qc,
  cume_dist: SO,
  dateDay: o9,
  dateMonth: i9,
  dateMonthDay: s9,
  delaunayLink: gE,
  delaunayMesh: bE,
  denseLine: cE,
  dense_rank: _O,
  density: aE,
  densityX: sE,
  densityY: oE,
  dot: jT,
  dotX: qT,
  dotY: VT,
  entropy: qO,
  eq: Nh,
  facetGrid: k8,
  facetLabel: F8,
  facetMargin: E8,
  facetMarginBottom: D8,
  facetMarginLeft: O8,
  facetMarginRight: L8,
  facetMarginTop: N8,
  first_value: IO,
  frame: xE,
  from: yZ,
  fxAlign: q8,
  fxAriaDescription: a5,
  fxAriaLabel: o5,
  fxAxis: X8,
  fxDomain: R8,
  fxFontVariant: s5,
  fxGrid: t5,
  fxInset: P8,
  fxInsetLeft: U8,
  fxInsetRight: z8,
  fxLabel: n5,
  fxLabelAnchor: r5,
  fxLabelOffset: i5,
  fxLine: e5,
  fxNice: B8,
  fxPadding: V8,
  fxPaddingInner: Y8,
  fxPaddingOuter: W8,
  fxRange: C8,
  fxReverse: c5,
  fxRound: j8,
  fxTickFormat: K8,
  fxTickPadding: Z8,
  fxTickRotate: Q8,
  fxTickSize: H8,
  fxTickSpacing: J8,
  fxTicks: G8,
  fyAlign: m5,
  fyAriaDescription: k5,
  fyAriaLabel: L5,
  fyAxis: v5,
  fyDomain: u5,
  fyFontVariant: O5,
  fyGrid: I5,
  fyInset: h5,
  fyInsetBottom: p5,
  fyInsetTop: d5,
  fyLabel: E5,
  fyLabelAnchor: N5,
  fyLabelOffset: D5,
  fyLine: T5,
  fyNice: f5,
  fyPadding: g5,
  fyPaddingInner: b5,
  fyPaddingOuter: w5,
  fyRange: l5,
  fyReverse: F5,
  fyRound: y5,
  fyTickFormat: A5,
  fyTickPadding: M5,
  fyTickRotate: $5,
  fyTickSize: x5,
  fyTickSpacing: S5,
  fyTicks: _5,
  geo: DE,
  geojson: rx,
  graticule: LE,
  grid: wI,
  gridFx: EE,
  gridFy: NE,
  gridX: IE,
  gridY: TE,
  gt: tm,
  gte: hO,
  hconcat: cZ,
  height: lI,
  hexagon: WT,
  hexbin: hE,
  hexgrid: dE,
  highlight: kE,
  hspace: lZ,
  hull: wE,
  image: iE,
  inset: bI,
  intervalX: UE,
  intervalXY: jE,
  intervalY: zE,
  isBetween: He,
  isDistinct: dO,
  isNotBetween: pO,
  isNotDistinct: tx,
  isNotNull: vc,
  isNull: Qy,
  kurtosis: jO,
  label: vI,
  lag: AO,
  last: t9,
  last_value: TO,
  lead: $O,
  lengthClamp: pT,
  lengthDomain: hT,
  lengthNice: yT,
  lengthRange: dT,
  lengthScale: fT,
  lengthZero: mT,
  line: DT,
  lineX: OT,
  lineY: LT,
  link: _E,
  literal: ma,
  loadCSV: d9,
  loadExtension: ix,
  loadJSON: p9,
  loadObjects: g9,
  loadParquet: y9,
  loadSpatial: m9,
  lt: _c,
  lte: xc,
  mad: kO,
  margin: oI,
  marginBottom: pI,
  marginLeft: fI,
  marginRight: hI,
  marginTop: dI,
  margins: sI,
  max: Go,
  median: RO,
  menu: rZ,
  min: Ho,
  mode: BO,
  name: rI,
  nearestX: BE,
  nearestY: PE,
  neq: Q_,
  not: fO,
  nth_value: EO,
  ntile: MO,
  opacityClamp: Q5,
  opacityDomain: Z5,
  opacityLabel: eT,
  opacityLegend: JE,
  opacityNice: tT,
  opacityRange: K5,
  opacityReverse: nT,
  opacityScale: J5,
  opacityTickFormat: iT,
  opacityZero: rT,
  or: Ky,
  padding: _I,
  pan: qE,
  panX: VE,
  panY: YE,
  panZoom: WE,
  panZoomX: XE,
  panZoomY: GE,
  percent_rank: xO,
  plot: vZ,
  product: FO,
  projectionClip: IT,
  projectionDomain: _T,
  projectionInset: xT,
  projectionInsetBottom: $T,
  projectionInsetLeft: ST,
  projectionInsetRight: MT,
  projectionInsetTop: AT,
  projectionParallels: bT,
  projectionPrecision: wT,
  projectionRotate: vT,
  projectionType: gT,
  quantile: CO,
  rClamp: cT,
  rDomain: oT,
  rNice: uT,
  rRange: aT,
  rScale: sT,
  rZero: lT,
  rank: vO,
  raster: lE,
  rasterTile: fE,
  rect: PT,
  rectX: UT,
  rectY: zT,
  regressionY: pE,
  round: xI,
  row_number: wO,
  ruleX: JT,
  ruleY: ZT,
  search: iZ,
  skewness: zO,
  slider: sZ,
  sphere: OE,
  spike: rE,
  sql: V,
  stddev: UO,
  stddevPop: YO,
  stringAgg: e9,
  style: cI,
  sum: Ys,
  symbolLegend: ZE,
  table: oZ,
  text: XT,
  textX: GT,
  textY: HT,
  tickX: KT,
  tickY: QT,
  toggle: Lu,
  toggleColor: CE,
  toggleX: FE,
  toggleY: RE,
  varPop: VO,
  variance: PO,
  vconcat: aZ,
  vector: tE,
  vectorX: eE,
  vectorY: nE,
  voronoi: yE,
  voronoiMesh: mE,
  vspace: uZ,
  width: uI,
  xAlign: OI,
  xAriaDescription: JI,
  xAriaLabel: HI,
  xAxis: RI,
  xClamp: NI,
  xDomain: MI,
  xFontVariant: GI,
  xGrid: qI,
  xInset: II,
  xInsetLeft: TI,
  xInsetRight: EI,
  xLabel: YI,
  xLabelAnchor: WI,
  xLabelOffset: XI,
  xLine: VI,
  xNice: $I,
  xPadding: LI,
  xPaddingInner: kI,
  xPaddingOuter: FI,
  xRange: AI,
  xReverse: ZI,
  xRound: DI,
  xScale: SI,
  xTickFormat: zI,
  xTickPadding: UI,
  xTickRotate: jI,
  xTickSize: BI,
  xTickSpacing: PI,
  xTicks: CI,
  xZero: KI,
  xyDomain: aI,
  yAlign: c8,
  yAriaDescription: $8,
  yAriaLabel: A8,
  yAxis: h8,
  yClamp: o8,
  yDomain: t8,
  yFontVariant: M8,
  yGrid: w8,
  yInset: r8,
  yInsetBottom: s8,
  yInsetTop: i8,
  yLabel: _8,
  yLabelAnchor: x8,
  yLabelOffset: S8,
  yLine: v8,
  yNice: n8,
  yPadding: u8,
  yPaddingInner: l8,
  yPaddingOuter: f8,
  yRange: e8,
  yReverse: I8,
  yRound: a8,
  yScale: QI,
  yTickFormat: g8,
  yTickPadding: m8,
  yTickRotate: b8,
  yTickSize: p8,
  yTickSpacing: y8,
  yTicks: d8,
  yZero: T8
}, Symbol.toStringTag, { value: "Module" }));
function xZ({
  coordinator: e = zr(),
  namedPlots: t = new nI(),
  extensions: n = null,
  ...r
} = {}) {
  return {
    ..._Z,
    ...n,
    context: {
      coordinator: e,
      namedPlots: t,
      ...r
    }
  };
}
const SZ = "spec", KE = "literal", MZ = "options", AZ = "selection", $Z = "paramref", IZ = "param", QE = "select", Iy = "value", TZ = "crossfilter", tN = "intersect", EZ = "union", NZ = "single", DZ = "data", OZ = "expression", Po = "sql", Ns = "agg", p1 = "input", wh = "hconcat", vh = "vconcat", _h = "hspace", xh = "vspace", eN = "mark", Y2 = "from", Sh = "plot", y1 = "legend", LZ = "attribute", kZ = "transform", FZ = "interactor", Ol = "Fixed";
class ue {
  constructor(t, n = null) {
    this.type = t, this.children = n;
  }
  instantiate() {
    throw Error("instantiate not implemented");
  }
  codegen() {
    return Error("codegen not implemented");
  }
  toJSON() {
    return Error("toJSON not implemented");
  }
}
class RZ extends ue {
  constructor(t, n, r, i, s, o) {
    super(SZ, [t]), this.root = t, this.meta = n, this.config = r, this.data = i, this.params = s, this.plotDefaults = o;
  }
  toJSON() {
    const { root: t, meta: n, config: r, plotDefaults: i } = this, s = new Map(Object.entries(this.data)), o = new Map(Object.entries(this.params)), a = {};
    if (n && (a.meta = { ...n }), r && (a.config = { ...r }), s != null && s.size) {
      const c = a.data = {};
      for (const [u, l] of s)
        c[u] = l.toJSON();
    }
    if (o != null && o.size) {
      const c = a.params = {};
      for (const [u, l] of o)
        c[u] = l.toJSON();
    }
    if (i != null && i.length) {
      const c = a.plotDefaults = {};
      for (const u of i)
        Object.assign(c, u.toJSON());
    }
    return Object.assign(a, t.toJSON());
  }
}
function CZ(e) {
  const t = typeof e;
  return t === "object" ? e == null ? void 0 : e.param : t === "string" ? BZ(e) : null;
}
function BZ(e) {
  return (e == null ? void 0 : e[0]) === "$" ? e.slice(1) : null;
}
function W2(e) {
  return `$${e}`;
}
function PZ(e) {
  return [e].flat();
}
function Ds(e) {
  return Array.isArray(e);
}
function nN(e) {
  return e !== null && typeof e == "object" && !Ds(e);
}
function fc(e) {
  return typeof e == "string";
}
function rN(e, t) {
  throw Object.assign(Error(e), { data: t });
}
function ci(e, t) {
  const n = {};
  for (const r in e)
    n[r] = t.maybeSelection(e[r]);
  return new kd(n);
}
class kd extends ue {
  constructor(t) {
    super(MZ), this.options = t;
  }
  filter(t) {
    const n = Object.fromEntries(
      Object.entries(this.options).filter(([r, i]) => t(r, i))
    );
    return new kd(n);
  }
  instantiate(t) {
    const { options: n } = this, r = {};
    for (const i in n)
      r[i] = n[i].instantiate(t);
    return r;
  }
  codegen(t) {
    const { options: n } = this, r = [];
    for (const i in n)
      r.push(`${i}: ${n[i].codegen(t)}`);
    return r.length ? `{${t.maybeLineWrap(r)}}` : "";
  }
  toJSON() {
    const { options: t } = this, n = {};
    for (const r in t)
      n[r] = t[r].toJSON();
    return n;
  }
}
const iN = "table", sN = "parquet", oN = "csv", m1 = "json", g1 = "spatial", X2 = /* @__PURE__ */ new Map([
  [iN, zZ],
  [sN, jZ],
  [oN, qZ],
  [m1, VZ],
  [g1, YZ]
]);
function UZ(e, t, n) {
  if (t = WZ(t), X2.has(t.type))
    return X2.get(t.type)(e, t, n);
  n.error("Unrecognized data format type.", t);
}
function zZ(e, t, n) {
  const { query: r, type: i, ...s } = t;
  return new ZZ(e, r, ci(s, n));
}
function jZ(e, t, n) {
  const { file: r, type: i, ...s } = t;
  return new QZ(e, r, ci(s, n));
}
function qZ(e, t, n) {
  const { file: r, type: i, ...s } = t;
  return new tK(e, r, ci(s, n));
}
function VZ(e, t, n) {
  const { data: r, file: i, type: s, ...o } = t, a = ci(o, n);
  return r ? new nK(e, r, a) : new eK(e, i, a);
}
function YZ(e, t, n) {
  const { file: r, type: i, ...s } = t;
  return new KZ(e, r, ci(s, n));
}
function WZ(e) {
  return Ds(e) && (e = { type: "json", data: e }), fc(e) && (e = { type: "table", query: e }), { ...e, type: XZ(e) };
}
function XZ(e) {
  return e.type || GZ(e.file) || "table";
}
function GZ(e) {
  const t = e == null ? void 0 : e.lastIndexOf(".");
  return t > 0 ? e.slice(t + 1) : null;
}
function G2(e, t) {
  return t ? new URL(e, t).toString() : e;
}
function HZ(e, t) {
  const n = e == null ? void 0 : e.codegen(t);
  return n ? `, ${n}` : "";
}
class JZ extends ue {
  constructor(t, n) {
    super(DZ), this.name = t, this.format = n;
  }
}
class b1 extends JZ {
  constructor(t, n) {
    super(t, n);
  }
  instantiateQuery(t) {
    t.error("instantiateQuery not implemented");
  }
  codegenQuery(t) {
    t.error("codegenQuery not implemented");
  }
  instantiate(t) {
    const n = this.instantiateQuery(t);
    if (n)
      return n;
  }
  codegen(t) {
    const n = this.codegenQuery(t);
    if (n)
      return n;
  }
}
class ZZ extends b1 {
  constructor(t, n, r) {
    super(t, iN), this.query = n == null ? void 0 : n.trim(), this.options = r;
  }
  instantiateQuery(t) {
    const { name: n, query: r, options: i } = this;
    if (r)
      return t.api.create(n, r, i.instantiate(t));
  }
  codegenQuery(t) {
    const { name: n, query: r, options: i } = this;
    if (r)
      return `\`${Qc(n, r, i.instantiate(t))}\``;
  }
  toJSON() {
    const { format: t, query: n, options: r } = this;
    return { type: t, query: n, ...r.toJSON() };
  }
}
class Fd extends b1 {
  constructor(t, n, r, i, s) {
    super(t, n), this.file = i, this.method = r, this.options = s;
  }
  instantiateQuery(t) {
    const { name: n, method: r, file: i, options: s } = this, o = G2(i, t.baseURL), a = s == null ? void 0 : s.instantiate(t);
    return t.api[r](n, o, a);
  }
  codegenQuery(t) {
    const { name: n, method: r, file: i, options: s } = this, o = G2(i, t.baseURL), a = HZ(s, t);
    return `${t.ns()}${r}("${n}", "${o}"${a})`;
  }
  toJSON() {
    const { format: t, file: n, options: r } = this;
    return { type: t, file: n, ...r.toJSON() };
  }
}
class KZ extends Fd {
  constructor(t, n, r) {
    super(t, g1, "loadSpatial", n, r);
  }
}
class QZ extends Fd {
  constructor(t, n, r) {
    super(t, sN, "loadParquet", n, r);
  }
}
class tK extends Fd {
  constructor(t, n, r) {
    super(t, oN, "loadCSV", n, r);
  }
}
class eK extends Fd {
  constructor(t, n, r) {
    super(t, m1, "loadJSON", n, r);
  }
}
class nK extends b1 {
  constructor(t, n, r) {
    super(t, m1), this.data = n, this.options = r;
  }
  instantiateQuery(t) {
    const { name: n, data: r, options: i } = this;
    return t.api.loadObjects(n, r, i.instantiate(t));
  }
  codegenQuery(t) {
    const { name: n, data: r, options: i } = this, s = i ? "," + i.codegen(t) : "", o = `[
    ` + r.map((a) => JSON.stringify(a)).join(`,
    `) + `
  ]`;
    return `${t.ns()}loadObjects("${n}", ${o}${s})`;
  }
  toJSON() {
    const { format: t, data: n, options: r } = this;
    return { type: t, data: n, ...r.toJSON() };
  }
}
function rK(e) {
  var r;
  const t = (r = e.config) == null ? void 0 : r.extensions, n = new Set(t ? PZ(t) : []);
  for (const i of Object.values(e.data))
    i.format === g1 && n.add("spatial");
  return n;
}
async function iK(e, t) {
  const { data: n, params: r, plotDefaults: i } = e, s = new sK({ plotDefaults: i, ...t }), o = [], a = rK(e);
  o.push(...Array.from(a).map((c) => ix(c)));
  for (const c of Object.values(n)) {
    const u = c.instantiate(s);
    u && o.push(u);
  }
  o.length > 0 && await s.coordinator.exec(o);
  for (const [c, u] of Object.entries(r)) {
    const l = u.instantiate(s);
    s.activeParams.set(c, l);
  }
  return {
    element: e.root.instantiate(s),
    params: s.activeParams
  };
}
class sK {
  constructor({
    api: t = xZ(),
    plotDefaults: n = [],
    activeParams: r = /* @__PURE__ */ new Map(),
    baseURL: i = null
  } = {}) {
    this.api = t, this.plotDefaults = n, this.activeParams = r, this.baseURL = i, this.coordinator = t.context.coordinator;
  }
  error(t, n) {
    rN(t, n);
  }
}
class aN extends ue {
  constructor(t) {
    super(KE), this.value = t;
  }
  instantiate() {
    return this.value;
  }
  codegen(t) {
    return t.stringify(this.value);
  }
  toJSON() {
    return this.value;
  }
}
class cN extends ue {
  constructor(t = tN, n) {
    super(AZ), this.select = t, this.cross = n;
  }
  instantiate(t) {
    const { select: n, cross: r } = this;
    return t.api.Selection[n]({ cross: r });
  }
  codegen(t) {
    const { select: n, cross: r } = this, i = r != null ? `{ cross: ${r} }` : "";
    return `${t.ns()}Selection.${n}(${i})`;
  }
  toJSON() {
    const { select: t, cross: n } = this;
    return { select: t, cross: n };
  }
}
const oK = /* @__PURE__ */ new Set([Iy, NZ, TZ, tN, EZ]);
function aK(e, t) {
  const n = nN(e) ? e : { value: e }, { select: r = Iy, cross: i, date: s, value: o } = n;
  return oK.has(r) || t.error(`Unrecognized param type: ${r}`, n), r !== Iy ? new cN(r, i) : Ds(o) ? new Ty(o.map((a) => t.maybeParam(a))) : new Ty(o, s);
}
class Ty extends ue {
  constructor(t, n) {
    super(IZ), this.value = t, this.date = n;
  }
  instantiate(t) {
    const { date: n, value: r } = this, { Param: i } = t.api;
    return Ds(r) ? i.array(r.map((s) => s.instantiate(t))) : i.value(Um(n, r));
  }
  codegen(t) {
    const { value: n, date: r } = this, i = `${t.ns()}Param.`;
    return Ds(n) ? `${i}array([${n.map((s) => s.codegen(t)).join(", ")}])` : r ? `${i}value(new Date(${JSON.stringify(r)}))` : `${i}value(${JSON.stringify(n)})`;
  }
  toJSON() {
    const { date: t, value: n } = this;
    return Ds(n) ? n.map((r) => r.toJSON()) : t ? { date: t } : n;
  }
}
class cK extends ue {
  constructor(t) {
    super($Z), this.name = t;
  }
  instantiate(t) {
    var n;
    return (n = t.activeParams) == null ? void 0 : n.get(this.name);
  }
  codegen() {
    return W2(this.name);
  }
  toJSON() {
    return W2(this.name);
  }
}
function uN(e, t, n) {
  var r, i;
  return (i = (r = n.plot) == null ? void 0 : r.attributes) != null && i.has(e) || n.error(`Unrecognized attribute: ${e}`), new uK(
    e,
    t === Ol ? new lK() : n.maybeParam(t)
  );
}
class uK extends ue {
  constructor(t, n) {
    super(LZ), this.name = t, this.value = n;
  }
  instantiate(t) {
    const { name: n, value: r } = this, i = t.api[n];
    return i(r.instantiate(t));
  }
  codegen(t) {
    const { name: n, value: r } = this;
    return `${t.tab()}${t.ns()}${n}(${r.codegen(t)})`;
  }
  toJSON() {
    const { name: t, value: n } = this;
    return { [t]: n.toJSON() };
  }
}
class lK extends ue {
  constructor() {
    super(KE), this.value = Ol;
  }
  instantiate(t) {
    return t.api[Ol];
  }
  codegen(t) {
    return `${t.ns()}${Ol}`;
  }
  toJSON() {
    return this.value;
  }
}
function fK(e, t) {
  const n = e[wh].map((r) => t.parseComponent(r));
  return new hK(n);
}
class hK extends ue {
  constructor(t) {
    super(wh, t);
  }
  instantiate(t) {
    return t.api[wh](this.children.map((n) => n.instantiate(t)));
  }
  codegen(t) {
    t.indent();
    const n = this.children.map((r) => r.codegen(t));
    return t.undent(), `${t.tab()}${t.ns()}${this.type}(
${n.join(`,
`)}
${t.tab()})`;
  }
  toJSON() {
    return { [this.type]: this.children.map((t) => t.toJSON()) };
  }
}
function dK(e) {
  return new pK(e[_h]);
}
class pK extends ue {
  constructor(t) {
    super(_h), this.value = t;
  }
  instantiate(t) {
    return t.api[_h](this.value);
  }
  codegen(t) {
    return `${t.tab()}${t.ns()}${this.type}(${this.value})`;
  }
  toJSON() {
    return { [this.type]: this.value };
  }
}
function yK(e, t) {
  var i;
  const { [p1]: n, ...r } = e;
  return (i = t.inputs) != null && i.has(n) || t.error(`Unrecognized input type: ${n}`, e), new mK(n, ci(r, t));
}
class mK extends ue {
  constructor(t, n) {
    super(p1), this.name = t, this.options = n;
  }
  instantiate(t) {
    const n = t.api[this.name];
    return n(this.options.instantiate(t));
  }
  codegen(t) {
    const n = this.options.codegen(t);
    return `${t.tab()}${t.ns()}${this.name}(${n})`;
  }
  toJSON() {
    const { type: t, name: n, options: r } = this;
    return { [t]: n, ...r.toJSON() };
  }
}
function lN(e, t) {
  var s, o;
  const { [y1]: n, ...r } = e, i = `${n}Legend`;
  return (o = (s = t.plot) == null ? void 0 : s.legends) != null && o.has(i) || t.error(`Unrecognized legend type: ${n}`, e), new gK(i, n, ci(r, t));
}
class gK extends ue {
  constructor(t, n, r) {
    super(y1), this.key = t, this.name = n, this.options = r;
  }
  instantiate(t) {
    const n = t.api[this.key];
    return n(this.options.instantiate(t));
  }
  codegen(t) {
    const n = this.options.codegen(t);
    return `${t.tab()}${t.ns()}${this.key}(${n})`;
  }
  toJSON() {
    const { type: t, name: n, options: r } = this;
    return { [t]: n, ...r.toJSON() };
  }
}
function bK(e, t) {
  var i, s;
  const { [QE]: n, ...r } = e;
  return (s = (i = t.plot) == null ? void 0 : i.interactors) != null && s.has(n) || t.error(`Unrecognized interactor type: ${n}`, e), new wK(n, ci(r, t));
}
class wK extends ue {
  constructor(t, n) {
    super(FZ), this.name = t, this.options = n;
  }
  instantiate(t) {
    const n = t.api[this.name];
    return n(this.options.instantiate(t));
  }
  codegen(t) {
    const n = this.options.codegen(t);
    return `${t.tab()}${t.ns()}${this.name}(${n})`;
  }
  toJSON() {
    const { name: t, options: n } = this;
    return { [QE]: t, ...n.toJSON() };
  }
}
function vK(e, t) {
  const { label: n } = e, r = e[Po] ? Po : e[Ns] ? Ns : t.error("Unrecognized expression type", e), i = e[r], s = i.split(/(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\$\w+)/g), o = [""], a = [];
  for (let c = 0, u = 0; c < s.length; ++c) {
    const l = s[c];
    l.startsWith("$") ? (a[u] = t.maybeParam(l), o[++u] = "") : o[u] += l;
  }
  return new _K(i, o, a, n, r === Ns);
}
class _K extends ue {
  constructor(t, n, r, i, s) {
    super(OZ), this.value = t, this.spans = n, this.params = r, this.label = i, this.aggregate = s;
  }
  instantiate(t) {
    const { spans: n, params: r, label: i, aggregate: s } = this, o = t.api[s ? Ns : Po], a = r.map((c) => c.instantiate(t));
    return o(n, ...a).annotate({ label: i });
  }
  codegen(t) {
    const { spans: n, params: r, label: i, aggregate: s } = this, o = s ? Ns : Po;
    let a = "";
    const c = r.length;
    for (let u = 0; u < c; ++u)
      a += n[u] + "${" + r[u].codegen(t) + "}";
    return a += n[c], `${t.ns()}${o}\`${a}\`` + (i ? `.annotate({ label: ${JSON.stringify(i)} })` : "");
  }
  toJSON() {
    return { [this.aggregate ? Ns : Po]: this.value };
  }
}
function xK(e, t) {
  if (!e)
    return null;
  if (Ds(e))
    return new aN(e);
  const { from: n, ...r } = e;
  return new SK(n, ci(r, t));
}
class SK extends ue {
  constructor(t, n) {
    super(Y2), this.table = t, this.options = n;
  }
  instantiate(t) {
    const { table: n, options: r } = this;
    return t.api[Y2](n, r.instantiate(t));
  }
  codegen(t) {
    const { type: n, table: r, options: i } = this, s = i.codegen(t);
    return `${t.ns()}${n}("${r}"${s ? ", " + s : ""})`;
  }
  toJSON() {
    const { type: t, table: n, options: r } = this;
    return { [t]: n, ...r.toJSON() };
  }
}
function qp(e) {
  return e == null ? [] : [e].flat();
}
function MK(e, t) {
  let n;
  for (const s in e)
    t.transforms.has(s) && (n = s);
  if (!n)
    return;
  const r = n === "count" || n == null ? [] : qp(e[n]), i = {
    distinct: e.distinct,
    orderby: qp(e.orderby).map((s) => t.maybeParam(s)),
    partitionby: qp(e.partitionby).map((s) => t.maybeParam(s)),
    rows: e.rows ? t.maybeParam(e.rows) : null,
    range: e.range ? t.maybeParam(e.range) : null
  };
  return new AK(n, r, i);
}
class AK extends ue {
  constructor(t, n, r) {
    super(kZ), this.name = t, this.args = n, this.options = r;
  }
  instantiate(t) {
    const { name: n, args: r, options: i } = this, { distinct: s, orderby: o, partitionby: a, rows: c, range: u } = i, l = t.api[n];
    let f = l(...r);
    return s && (f = f.distinct()), o.length && (f = f.orderby(o.map((h) => h.instantiate(t)))), a.length && (f = f.partitionby(a.map((h) => h.instantiate(t)))), c != null ? f = f.rows(c.instantiate(t)) : u != null && (f = f.range(u.instantiate(t))), f;
  }
  codegen(t) {
    const { name: n, args: r, options: i } = this, { distinct: s, orderby: o, partitionby: a, rows: c, range: u } = i;
    let l = `${t.ns()}${n}(` + r.map((f) => JSON.stringify(f)).join(", ") + ")";
    if (s && (l += ".distinct()"), o.length) {
      const f = o.map((h) => h.codegen(t));
      l += `.orderby(${f.join(", ")})`;
    }
    if (a.length) {
      const f = a.map((h) => h.codegen(t));
      l += `.partitionby(${f.join(", ")})`;
    }
    return c ? l += `.rows(${c.codegen(t)})` : u && (l += `.range(${u.codegen(t)})`), l;
  }
  toJSON() {
    const { name: t, args: n, options: r } = this, { distinct: i, orderby: s, partitionby: o, rows: a, range: c } = r, u = { [t]: Vp(n) };
    return i && (u.distinct = !0), s.length && (u.orderby = Vp(s.map((l) => l.toJSON()))), o.length && (u.partitionby = Vp(o.map((l) => l.toJSON()))), a ? u.rows = a.toJSON() : c && (u.range = c.toJSON()), u;
  }
}
function Vp(e) {
  return e.length === 0 ? "" : e.length === 1 ? e[0] : e;
}
function $K(e, t) {
  if (nN(e))
    return e[Po] || e[Ns] ? vK(e, t) : MK(e, t);
}
function IK(e, t) {
  var a, c;
  const { mark: n, data: r, ...i } = e;
  (c = (a = t.plot) == null ? void 0 : a.marks) != null && c.has(n) || t.error(`Unrecognized mark type: ${n}`, e);
  const s = xK(r, t), o = {};
  for (const u in i) {
    const l = i[u];
    o[u] = $K(l, t) || t.maybeParam(l);
  }
  return new TK(n, s, new kd(o));
}
class TK extends ue {
  constructor(t, n, r) {
    super(eN), this.name = t, this.data = n, this.options = r;
  }
  instantiate(t) {
    const { name: n, data: r, options: i } = this, s = t.api[n], o = i.instantiate(t);
    return r ? s(r.instantiate(t), o) : s(o);
  }
  codegen(t) {
    const { name: n, data: r, options: i } = this, s = r ? r.codegen(t) : "", o = i.codegen(t);
    let a;
    if (s && o) {
      t.indent();
      const c = i.codegen(t);
      a = `
${t.tab()}${s},
${t.tab()}${c}
`, t.undent(), a += t.tab();
    } else
      a = `${s}${o}`;
    return `${t.tab()}${t.ns()}${n}(${a})`;
  }
  toJSON() {
    const { type: t, name: n, data: r, options: i } = this;
    return {
      [t]: n,
      ...r ? { data: r.toJSON() } : {},
      ...i.toJSON()
    };
  }
}
function EK(e, t) {
  return fN({ plot: [e] }, t);
}
function fN(e, t) {
  const { [Sh]: n, ...r } = e, i = Object.entries(r).map(([o, a]) => uN(o, a, t)), s = n.map((o) => fc(o.mark) ? IK(o, t) : fc(o.legend) ? lN(o, t) : fc(o.select) ? bK(o, t) : t.error("Invalid plot entry.", o));
  return new NK(s, i);
}
class NK extends ue {
  constructor(t, n) {
    super(Sh, t), this.attributes = n;
  }
  instantiate(t) {
    const n = [
      ...t.plotDefaults || [],
      ...this.attributes || []
    ];
    return t.api[Sh](
      this.children.map((r) => r.instantiate(t)),
      n.map((r) => r.instantiate(t))
    );
  }
  codegen(t) {
    var o;
    const { type: n, children: r, attributes: i } = this;
    t.indent();
    const s = [
      ...r.map((a) => a.codegen(t)),
      ...(o = t.plotDefaults) != null && o.length ? [`${t.tab()}...defaultAttributes`] : [],
      ...i.map((a) => a.codegen(t))
    ].join(`,
`);
    return t.undent(), `${t.tab()}${t.ns()}${n}(
${s}
${t.tab()})`;
  }
  toJSON() {
    const { type: t, children: n, attributes: r } = this, i = { [t]: n.map((s) => s.toJSON()) };
    for (const s of r)
      Object.assign(i, s.toJSON());
    return i;
  }
}
function DK(e, t) {
  const n = e[vh].map((r) => t.parseComponent(r));
  return new OK(n);
}
class OK extends ue {
  constructor(t) {
    super(vh, t);
  }
  instantiate(t) {
    return t.api[vh](this.children.map((n) => n.instantiate(t)));
  }
  codegen(t) {
    t.indent();
    const n = this.children.map((r) => r.codegen(t));
    return t.undent(), `${t.tab()}${t.ns()}${this.type}(
${n.join(`,
`)}
${t.tab()})`;
  }
  toJSON() {
    return { [this.type]: this.children.map((t) => t.toJSON()) };
  }
}
function LK(e) {
  return new kK(e[xh]);
}
class kK extends ue {
  constructor(t) {
    super(xh), this.value = t;
  }
  instantiate(t) {
    return t.api[xh](this.value);
  }
  codegen(t) {
    return `${t.tab()}${t.ns()}${this.type}(${this.value})`;
  }
  toJSON() {
    return { [this.type]: this.value };
  }
}
function FK(e = []) {
  return new Map([
    [Sh, fN],
    [eN, EK],
    [y1, lN],
    [p1, yK],
    [wh, fK],
    [vh, DK],
    [_h, dK],
    [xh, LK],
    ...e
  ]);
}
function RK(e = []) {
  return /* @__PURE__ */ new Set([
    "menu",
    "search",
    "slider",
    "table",
    ...e
  ]);
}
function CK({
  attributes: e = BK(),
  interactors: t = PK(),
  legends: n = UK(),
  marks: r = zK()
} = {}) {
  return { attributes: e, interactors: t, legends: n, marks: r };
}
function BK(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(pZ),
    ...e
  ]);
}
function PK(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(bZ),
    ...e
  ]);
}
function UK(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(wZ),
    ...e
  ]);
}
function zK(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(gZ),
    ...e
  ]);
}
function jK(e = []) {
  return /* @__PURE__ */ new Set([
    "avg",
    "bin",
    "centroid",
    "centroidX",
    "centroidY",
    "count",
    "dateMonth",
    "dateMonthDay",
    "dateDay",
    "geojson",
    "max",
    "median",
    "min",
    "mode",
    "quantile",
    "sum",
    "row_number",
    "rank",
    "dense_rank",
    "percent_rank",
    "cume_dist",
    "ntile",
    "lag",
    "lead",
    "first_value",
    "last_value",
    "nth_value",
    ...e
  ]);
}
function qK(e, t) {
  return e = fc(e) ? JSON.parse(e) : e, new VK(t).parse(e);
}
class VK {
  constructor({
    components: t = FK(),
    transforms: n = jK(),
    inputs: r = RK(),
    plot: i = CK(),
    params: s = [],
    datasets: o = []
  } = {}) {
    this.components = t, this.transforms = n, this.inputs = r, this.plot = i, this.params = new Map(s), this.datasets = new Map(o);
  }
  parse(t) {
    const {
      meta: n,
      config: r,
      data: i = {},
      params: s,
      plotDefaults: o = {},
      ...a
    } = t;
    for (const c in i)
      this.datasets.set(c, UZ(c, i[c], this));
    this.plotDefaults = Object.entries(o).map(([c, u]) => uN(c, u, this));
    for (const c in s)
      this.params.set(c, aK(s[c], this));
    return new RZ(
      this.parseComponent(a),
      n ? { ...n } : void 0,
      r ? { ...r } : void 0,
      Object.fromEntries(this.datasets),
      Object.fromEntries(this.params),
      this.plotDefaults
    );
  }
  parseComponent(t) {
    for (const [n, r] of this.components)
      if (t[n] != null)
        return r(t, this);
    this.error("Invalid specification.", t);
  }
  maybeParam(t, n = () => new Ty()) {
    const { params: r } = this, i = CZ(t);
    if (i) {
      if (!r.has(i)) {
        const s = n();
        r.set(i, s);
      }
      return new cK(i);
    }
    return new aN(t);
  }
  maybeSelection(t) {
    return this.maybeParam(t, () => new cN());
  }
  error(t, n) {
    rN(t, n);
  }
}
let yl;
const YK = new Uint8Array(16);
function WK() {
  if (!yl && (yl = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !yl))
    throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
  return yl(YK);
}
const ve = [];
for (let e = 0; e < 256; ++e)
  ve.push((e + 256).toString(16).slice(1));
function XK(e, t = 0) {
  return ve[e[t + 0]] + ve[e[t + 1]] + ve[e[t + 2]] + ve[e[t + 3]] + "-" + ve[e[t + 4]] + ve[e[t + 5]] + "-" + ve[e[t + 6]] + ve[e[t + 7]] + "-" + ve[e[t + 8]] + ve[e[t + 9]] + "-" + ve[e[t + 10]] + ve[e[t + 11]] + ve[e[t + 12]] + ve[e[t + 13]] + ve[e[t + 14]] + ve[e[t + 15]];
}
const GK = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), H2 = {
  randomUUID: GK
};
function HK(e, t, n) {
  if (H2.randomUUID && !t && !e)
    return H2.randomUUID();
  e = e || {};
  const r = e.random || (e.rng || WK)();
  if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, t) {
    n = n || 0;
    for (let i = 0; i < 16; ++i)
      t[n + i] = r[i];
    return t;
  }
  return XK(r);
}
const lQ = {
  /** @type {import('anywidget/types').Initialize<Model>} */
  // eslint-disable-next-line no-unused-vars
  initialize(e) {
  },
  /** @type {import('anywidget/types').Render<Model>} */
  render(e) {
    e.el.classList.add("mosaic-widget");
    const t = () => e.model.get("spec"), n = () => e.model.get("temp_indexes"), r = zr().logger(), i = /* @__PURE__ */ new Map();
    function s(l, f, h) {
      const d = HK();
      i.set(d, {
        query: l,
        startTime: performance.now(),
        resolve: f,
        reject: h
      }), e.model.send({ ...l, uuid: d });
    }
    const o = {
      query(l) {
        return new Promise((f, h) => s(l, f, h));
      }
    };
    function a() {
      zr().clear(), l1.clear();
    }
    async function c() {
      const l = t();
      a(), r.log("Setting spec:", l);
      const f = await JK(l);
      e.el.replaceChildren(f.element);
      const h = {};
      for (const [d, p] of f.params)
        h[d] = {
          value: p.value,
          ...p.predicate ? { predicate: String(p.predicate()) } : {}
        }, p.addEventListener("value", (y) => {
          h[d] = { value: y, predicate: String(p.predicate()) }, e.model.set("params", h), e.model.save_changes();
        });
      e.model.set("params", h), e.model.save_changes();
    }
    e.model.on("change:spec", () => c());
    function u() {
      const l = { temp: n() };
      zr().configure({ indexes: l });
    }
    return e.model.on("change:temp_indexes", () => u()), e.model.on("msg:custom", (l, f) => {
      r.group(`query ${l.uuid}`), r.log("received message", l, f);
      const h = i.get(l.uuid);
      if (i.delete(l.uuid), r.log(h.query.sql, (performance.now() - h.startTime).toFixed(1)), l.error)
        h.reject(l.error), r.error(l.error);
      else
        switch (l.type) {
          case "arrow": {
            const d = Zy(f[0].buffer);
            r.log("table", d), h.resolve(d);
            break;
          }
          case "json": {
            r.log("json", l.result), h.resolve(l.result);
            break;
          }
          default: {
            h.resolve({});
            break;
          }
        }
      r.groupEnd("query");
    }), zr().databaseConnector(o), u(), c(), () => {
      a();
    };
  }
};
function JK(e) {
  const t = qK(e);
  return iK(t);
}
export {
  lQ as default
};
