function ct(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 (h) {
        o(h);
      }
    }
    function c(l) {
      try {
        u(r.throw(l));
      } catch (h) {
        o(h);
      }
    }
    function u(l) {
      l.done ? s(l.value) : i(l.value).then(a, c);
    }
    u((r = r.apply(e, t || [])).next());
  });
}
function vg(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 bt(e) {
  return this instanceof bt ? (this.v = e, this) : new bt(e);
}
function Qn(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(f) {
    r[f] && (i[f] = function(d) {
      return new Promise(function(p, y) {
        s.push([f, d, p, y]) > 1 || a(f, d);
      });
    });
  }
  function a(f, d) {
    try {
      c(r[f](d));
    } catch (p) {
      h(s[0][3], p);
    }
  }
  function c(f) {
    f.value instanceof bt ? Promise.resolve(f.value.v).then(u, l) : h(s[0][2], f);
  }
  function u(f) {
    a("next", f);
  }
  function l(f) {
    a("throw", f);
  }
  function h(f, d) {
    f(d), s.shift(), s.length && a(s[0][0], s[0][1]);
  }
}
function ku(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: bt(e[i](o)), done: !1 } : s ? s(o) : o;
    } : s;
  }
}
function Qs(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 vg == "function" ? vg(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 C$ = new TextDecoder("utf-8"), tp = (e) => C$.decode(e), P$ = new TextEncoder(), E0 = (e) => P$.encode(e), [AH, z$] = (() => {
  const e = () => {
    throw new Error("BigInt is not available in this environment");
  };
  function t() {
    throw e();
  }
  return t.asIntN = () => {
    throw e();
  }, t.asUintN = () => {
    throw e();
  }, typeof BigInt < "u" ? [BigInt, !0] : [t, !1];
})(), [bc, IH] = (() => {
  const e = () => {
    throw new Error("BigInt64Array is not available in this environment");
  };
  class t {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw e();
    }
    static from() {
      throw e();
    }
    constructor() {
      throw e();
    }
  }
  return typeof BigInt64Array < "u" ? [BigInt64Array, !0] : [t, !1];
})(), [wc, TH] = (() => {
  const e = () => {
    throw new Error("BigUint64Array is not available in this environment");
  };
  class t {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw e();
    }
    static from() {
      throw e();
    }
    constructor() {
      throw e();
    }
  }
  return typeof BigUint64Array < "u" ? [BigUint64Array, !0] : [t, !1];
})(), U$ = (e) => typeof e == "number", j$ = (e) => typeof e == "boolean", Te = (e) => typeof e == "function", Tn = (e) => e != null && Object(e) === e, Va = (e) => Tn(e) && Te(e.then), Df = (e) => Tn(e) && Te(e[Symbol.iterator]), N0 = (e) => Tn(e) && Te(e[Symbol.asyncIterator]), ep = (e) => Tn(e) && Tn(e.schema), Cw = (e) => Tn(e) && "done" in e && "value" in e, Pw = (e) => Tn(e) && Te(e.stat) && U$(e.fd), zw = (e) => Tn(e) && L0(e.body), Uw = (e) => "_getDOMStream" in e && "_getNodeStream" in e, L0 = (e) => Tn(e) && Te(e.cancel) && Te(e.getReader) && !Uw(e), jw = (e) => Tn(e) && Te(e.read) && Te(e.pipe) && j$(e.readable) && !Uw(e), q$ = (e) => Tn(e) && Te(e.clear) && Te(e.bytes) && Te(e.position) && Te(e.setPosition) && Te(e.capacity) && Te(e.getBufferIdentifier) && Te(e.createLong), D0 = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function V$(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 _g(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 sr(e, t) {
  const n = V$(e), r = n.reduce((l, h) => l + h.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 ? _g(o, s, a) : o = s;
      break;
    }
    _g(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 = Cw(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = E0(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof D0 ? new e(n) : q$(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 la = (e) => Pt(Int32Array, e), Ft = (e) => Pt(Uint8Array, e), np = (e) => (e.next(), e);
function* Y$(e, t) {
  const n = function* (i) {
    yield i;
  }, r = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof D0 ? n(t) : Df(t) ? t : n(t);
  return yield* np(function* (i) {
    let s = null;
    do
      s = i.next(yield Pt(e, s));
    while (!s.done);
  }(r[Symbol.iterator]())), new e();
}
const W$ = (e) => Y$(Uint8Array, e);
function qw(e, t) {
  return Qn(this, arguments, function* () {
    if (Va(t))
      return yield bt(yield bt(yield* ku(Qs(qw(e, yield bt(t))))));
    const r = function(o) {
      return Qn(this, arguments, function* () {
        yield yield bt(yield bt(o));
      });
    }, i = function(o) {
      return Qn(this, arguments, function* () {
        yield bt(yield* ku(Qs(np(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 D0 ? r(t) : Df(t) ? i(t) : N0(t) ? t : r(t);
    return yield bt(
      // otherwise if AsyncIterable, use it
      yield* ku(Qs(np(function(o) {
        return Qn(this, arguments, function* () {
          let a = null;
          do
            a = yield bt(o.next(yield yield bt(Pt(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield bt(new e());
  });
}
const X$ = (e) => qw(Uint8Array, e);
function G$(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 cn = {
  fromIterable(e) {
    return eu(H$(e));
  },
  fromAsyncIterable(e) {
    return eu(Z$(e));
  },
  fromDOMStream(e) {
    return eu(K$(e));
  },
  fromNodeStream(e) {
    return eu(Q$(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');
  }
}, eu = (e) => (e.next(), e);
function* H$(e) {
  let t, n = !1, r = [], i, s, o, a = 0;
  function c() {
    return s === "peek" ? sr(r, o)[0] : ([i, r, a] = sr(r, o), i);
  }
  ({ cmd: s, size: o } = yield null);
  const u = W$(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 Z$(e) {
  return Qn(this, arguments, function* () {
    let n, r = !1, i = [], s, o, a, c = 0;
    function u() {
      return o === "peek" ? sr(i, a)[0] : ([s, i, c] = sr(i, a), s);
    }
    ({ cmd: o, size: a } = yield yield bt(null));
    const l = X$(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield bt(l.next()) : yield bt(l.next(a - c)), !n && s.byteLength > 0 && (i.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield bt(u()));
          while (a < c);
      while (!n);
    } catch (h) {
      (r = !0) && typeof l.throw == "function" && (yield bt(l.throw(h)));
    } finally {
      r === !1 && typeof l.return == "function" && (yield bt(l.return(new Uint8Array(0))));
    }
    return yield bt(null);
  });
}
function K$(e) {
  return Qn(this, arguments, function* () {
    let n = !1, r = !1, i = [], s, o, a, c = 0;
    function u() {
      return o === "peek" ? sr(i, a)[0] : ([s, i, c] = sr(i, a), s);
    }
    ({ cmd: o, size: a } = yield yield bt(null));
    const l = new J$(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield bt(l.read()) : yield bt(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 bt(u()));
          while (a < c);
      while (!n);
    } catch (h) {
      (r = !0) && (yield bt(l.cancel(h)));
    } finally {
      r === !1 ? yield bt(l.cancel()) : e.locked && l.releaseLock();
    }
    return yield bt(null);
  });
}
class J$ {
  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 ct(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 ct(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 Xh = (e, t) => {
  const n = (i) => r([t, i]);
  let r;
  return [t, n, new Promise((i) => (r = i) && e.once(t, n))];
};
function Q$(e) {
  return Qn(this, arguments, function* () {
    const n = [];
    let r = "error", i = !1, s = null, o, a, c = 0, u = [], l;
    function h() {
      return o === "peek" ? sr(u, a)[0] : ([l, u, c] = sr(u, a), l);
    }
    if ({ cmd: o, size: a } = yield yield bt(null), e.isTTY)
      return yield yield bt(new Uint8Array(0)), yield bt(null);
    try {
      n[0] = Xh(e, "end"), n[1] = Xh(e, "error");
      do {
        if (n[2] = Xh(e, "readable"), [r, s] = yield bt(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 bt(h()));
          while (a < c);
      } while (!i);
    } finally {
      yield bt(f(n, r === "error" ? s : null));
    }
    return yield bt(null);
    function f(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 fn;
(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";
})(fn || (fn = {}));
var En;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(En || (En = {}));
var ze;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(ze || (ze = {}));
var jr;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(jr || (jr = {}));
var Nt;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(Nt || (Nt = {}));
var bi;
(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";
})(bi || (bi = {}));
var Rt;
(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";
})(Rt || (Rt = {}));
var B;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Null = 1] = "Null", e[e.Int = 2] = "Int", e[e.Float = 3] = "Float", e[e.Binary = 4] = "Binary", e[e.Utf8 = 5] = "Utf8", e[e.Bool = 6] = "Bool", e[e.Decimal = 7] = "Decimal", e[e.Date = 8] = "Date", e[e.Time = 9] = "Time", e[e.Timestamp = 10] = "Timestamp", e[e.Interval = 11] = "Interval", e[e.List = 12] = "List", e[e.Struct = 13] = "Struct", e[e.Union = 14] = "Union", e[e.FixedSizeBinary = 15] = "FixedSizeBinary", e[e.FixedSizeList = 16] = "FixedSizeList", e[e.Map = 17] = "Map", e[e.Dictionary = -1] = "Dictionary", e[e.Int8 = -2] = "Int8", e[e.Int16 = -3] = "Int16", e[e.Int32 = -4] = "Int32", e[e.Int64 = -5] = "Int64", e[e.Uint8 = -6] = "Uint8", e[e.Uint16 = -7] = "Uint16", e[e.Uint32 = -8] = "Uint32", e[e.Uint64 = -9] = "Uint64", e[e.Float16 = -10] = "Float16", e[e.Float32 = -11] = "Float32", e[e.Float64 = -12] = "Float64", e[e.DateDay = -13] = "DateDay", e[e.DateMillisecond = -14] = "DateMillisecond", e[e.TimestampSecond = -15] = "TimestampSecond", e[e.TimestampMillisecond = -16] = "TimestampMillisecond", e[e.TimestampMicrosecond = -17] = "TimestampMicrosecond", e[e.TimestampNanosecond = -18] = "TimestampNanosecond", e[e.TimeSecond = -19] = "TimeSecond", e[e.TimeMillisecond = -20] = "TimeMillisecond", e[e.TimeMicrosecond = -21] = "TimeMicrosecond", e[e.TimeNanosecond = -22] = "TimeNanosecond", e[e.DenseUnion = -23] = "DenseUnion", e[e.SparseUnion = -24] = "SparseUnion", e[e.IntervalDayTime = -25] = "IntervalDayTime", e[e.IntervalYearMonth = -26] = "IntervalYearMonth";
})(B || (B = {}));
var Mr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(Mr || (Mr = {}));
const t8 = void 0;
function Ya(e) {
  if (e === null)
    return "null";
  if (e === t8)
    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 bc || e instanceof wc ? `[${[...e].map((t) => Ya(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const e8 = Symbol.for("isArrowBigNum");
function Bn(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);
}
Bn.prototype[e8] = !0;
Bn.prototype.toJSON = function() {
  return `"${as(this)}"`;
};
Bn.prototype.valueOf = function() {
  return Vw(this);
};
Bn.prototype.toString = function() {
  return as(this);
};
Bn.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return Vw(this);
    case "string":
      return as(this);
    case "default":
      return rp(this);
  }
  return as(this);
};
function to(...e) {
  return Bn.apply(this, e);
}
function eo(...e) {
  return Bn.apply(this, e);
}
function Wa(...e) {
  return Bn.apply(this, e);
}
Object.setPrototypeOf(to.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(eo.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(Wa.prototype, Object.create(Uint32Array.prototype));
Object.assign(to.prototype, Bn.prototype, { constructor: to, signed: !0, TypedArray: Int32Array, BigIntArray: bc });
Object.assign(eo.prototype, Bn.prototype, { constructor: eo, signed: !1, TypedArray: Uint32Array, BigIntArray: wc });
Object.assign(Wa.prototype, Bn.prototype, { constructor: Wa, signed: !0, TypedArray: Uint32Array, BigIntArray: wc });
function Vw(e) {
  const { buffer: t, byteOffset: n, length: r, signed: i } = e, s = new wc(t, n, r), o = i && s[s.length - 1] & BigInt(1) << BigInt(63);
  let a = BigInt(o ? 1 : 0), c = BigInt(0);
  if (o) {
    for (const u of s)
      a += ~u * (BigInt(1) << BigInt(32) * c++);
    a *= BigInt(-1);
  } else
    for (const u of s)
      a += u * (BigInt(1) << BigInt(32) * c++);
  return a;
}
let as, rp;
z$ ? (rp = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : Gh(e), as = (e) => e.byteLength === 8 ? `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}` : Gh(e)) : (as = Gh, rp = as);
function Gh(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 O0 {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new to(t);
      case !1:
        return new eo(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case bc:
        return new to(t);
    }
    return t.byteLength === 16 ? new Wa(t) : new eo(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new to(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new eo(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new Wa(t);
  }
  constructor(t, n) {
    return O0.new(t, n);
  }
}
var Yw, Ww, Xw, Gw, Hw, Zw, Kw, Jw, Qw, t2, e2, n2, r2, i2, s2, o2, a2, c2, u2;
class mt {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === B.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === B.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === B.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === B.Binary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === B.Utf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === B.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === B.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === B.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === B.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === B.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === B.Interval;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === B.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === B.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === B.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === B.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === B.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === B.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === B.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return mt.isUnion(t) && t.mode === En.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return mt.isUnion(t) && t.mode === En.Sparse;
  }
  get typeId() {
    return B.NONE;
  }
}
Yw = Symbol.toStringTag;
mt[Yw] = ((e) => (e.children = null, e.ArrayType = Array, e[Symbol.toStringTag] = "DataType"))(mt.prototype);
let wi = class extends mt {
  toString() {
    return "Null";
  }
  get typeId() {
    return B.Null;
  }
};
Ww = Symbol.toStringTag;
wi[Ww] = ((e) => e[Symbol.toStringTag] = "Null")(wi.prototype);
class vi extends mt {
  constructor(t, n) {
    super(), this.isSigned = t, this.bitWidth = n;
  }
  get typeId() {
    return B.Int;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 8:
        return this.isSigned ? Int8Array : Uint8Array;
      case 16:
        return this.isSigned ? Int16Array : Uint16Array;
      case 32:
        return this.isSigned ? Int32Array : Uint32Array;
      case 64:
        return this.isSigned ? bc : wc;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
}
Xw = Symbol.toStringTag;
vi[Xw] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(vi.prototype);
class Xa extends vi {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
}
Object.defineProperty(Xa.prototype, "ArrayType", { value: Int32Array });
class Ga extends mt {
  constructor(t) {
    super(), this.precision = t;
  }
  get typeId() {
    return B.Float;
  }
  get ArrayType() {
    switch (this.precision) {
      case ze.HALF:
        return Uint16Array;
      case ze.SINGLE:
        return Float32Array;
      case ze.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
}
Gw = Symbol.toStringTag;
Ga[Gw] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(Ga.prototype);
let Hu = class extends mt {
  constructor() {
    super();
  }
  get typeId() {
    return B.Binary;
  }
  toString() {
    return "Binary";
  }
};
Hw = Symbol.toStringTag;
Hu[Hw] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(Hu.prototype);
let Zu = class extends mt {
  constructor() {
    super();
  }
  get typeId() {
    return B.Utf8;
  }
  toString() {
    return "Utf8";
  }
};
Zw = Symbol.toStringTag;
Zu[Zw] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(Zu.prototype);
let Ku = class extends mt {
  constructor() {
    super();
  }
  get typeId() {
    return B.Bool;
  }
  toString() {
    return "Bool";
  }
};
Kw = Symbol.toStringTag;
Ku[Kw] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(Ku.prototype);
let Ju = class extends mt {
  constructor(t, n, r = 128) {
    super(), this.scale = t, this.precision = n, this.bitWidth = r;
  }
  get typeId() {
    return B.Decimal;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
};
Jw = Symbol.toStringTag;
Ju[Jw] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(Ju.prototype);
class Qu extends mt {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return B.Date;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${jr[this.unit]}>`;
  }
}
Qw = Symbol.toStringTag;
Qu[Qw] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(Qu.prototype);
class Ha extends mt {
  constructor(t, n) {
    super(), this.unit = t, this.bitWidth = n;
  }
  get typeId() {
    return B.Time;
  }
  toString() {
    return `Time${this.bitWidth}<${Nt[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return bc;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
}
t2 = Symbol.toStringTag;
Ha[t2] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(Ha.prototype);
class tl extends mt {
  constructor(t, n) {
    super(), this.unit = t, this.timezone = n;
  }
  get typeId() {
    return B.Timestamp;
  }
  toString() {
    return `Timestamp<${Nt[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
}
e2 = Symbol.toStringTag;
tl[e2] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(tl.prototype);
class el extends mt {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return B.Interval;
  }
  toString() {
    return `Interval<${bi[this.unit]}>`;
  }
}
n2 = Symbol.toStringTag;
el[n2] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(el.prototype);
let nl = class extends mt {
  constructor(t) {
    super(), this.children = [t];
  }
  get typeId() {
    return B.List;
  }
  toString() {
    return `List<${this.valueType}>`;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
};
r2 = Symbol.toStringTag;
nl[r2] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(nl.prototype);
class De extends mt {
  constructor(t) {
    super(), this.children = t;
  }
  get typeId() {
    return B.Struct;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
i2 = Symbol.toStringTag;
De[i2] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(De.prototype);
class rl extends mt {
  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 B.Union;
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
}
s2 = Symbol.toStringTag;
rl[s2] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(rl.prototype);
let il = class extends mt {
  constructor(t) {
    super(), this.byteWidth = t;
  }
  get typeId() {
    return B.FixedSizeBinary;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
};
o2 = Symbol.toStringTag;
il[o2] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(il.prototype);
let sl = class extends mt {
  constructor(t, n) {
    super(), this.listSize = t, this.children = [n];
  }
  get typeId() {
    return B.FixedSizeList;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
  toString() {
    return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
  }
};
a2 = Symbol.toStringTag;
sl[a2] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(sl.prototype);
class ol extends mt {
  constructor(t, n = !1) {
    super(), this.children = [t], this.keysSorted = n;
  }
  get typeId() {
    return B.Map;
  }
  get keyType() {
    return this.children[0].type.children[0].type;
  }
  get valueType() {
    return this.children[0].type.children[1].type;
  }
  get childType() {
    return this.children[0].type;
  }
  toString() {
    return `Map<{${this.children[0].type.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
c2 = Symbol.toStringTag;
ol[c2] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(ol.prototype);
const n8 = ((e) => () => ++e)(-1);
class bo extends mt {
  constructor(t, n, r, i) {
    super(), this.indices = n, this.dictionary = t, this.isOrdered = i || !1, this.id = r == null ? n8() : typeof r == "number" ? r : r.low;
  }
  get typeId() {
    return B.Dictionary;
  }
  get children() {
    return this.dictionary.children;
  }
  get valueType() {
    return this.dictionary;
  }
  get ArrayType() {
    return this.dictionary.ArrayType;
  }
  toString() {
    return `Dictionary<${this.indices}, ${this.dictionary}>`;
  }
}
u2 = Symbol.toStringTag;
bo[u2] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(bo.prototype);
function $r(e) {
  const t = e;
  switch (e.typeId) {
    case B.Decimal:
      return e.bitWidth / 32;
    case B.Timestamp:
      return 2;
    case B.Date:
      return 1 + t.unit;
    case B.Interval:
      return 1 + t.unit;
    case B.FixedSizeList:
      return t.listSize;
    case B.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
class It {
  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 r8(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return Vs(this, t, n);
  }
  visitNull(t, ...n) {
    return null;
  }
  visitBool(t, ...n) {
    return null;
  }
  visitInt(t, ...n) {
    return null;
  }
  visitFloat(t, ...n) {
    return null;
  }
  visitUtf8(t, ...n) {
    return null;
  }
  visitBinary(t, ...n) {
    return null;
  }
  visitFixedSizeBinary(t, ...n) {
    return null;
  }
  visitDate(t, ...n) {
    return null;
  }
  visitTimestamp(t, ...n) {
    return null;
  }
  visitTime(t, ...n) {
    return null;
  }
  visitDecimal(t, ...n) {
    return null;
  }
  visitList(t, ...n) {
    return null;
  }
  visitStruct(t, ...n) {
    return null;
  }
  visitUnion(t, ...n) {
    return null;
  }
  visitDictionary(t, ...n) {
    return null;
  }
  visitInterval(t, ...n) {
    return null;
  }
  visitFixedSizeList(t, ...n) {
    return null;
  }
  visitMap(t, ...n) {
    return null;
  }
}
function r8(e, t, n = !0) {
  return typeof t == "number" ? Vs(e, t, n) : typeof t == "string" && t in B ? Vs(e, B[t], n) : t && t instanceof mt ? Vs(e, xg(t), n) : t != null && t.type && t.type instanceof mt ? Vs(e, xg(t.type), n) : Vs(e, B.NONE, n);
}
function Vs(e, t, n = !0) {
  let r = null;
  switch (t) {
    case B.Null:
      r = e.visitNull;
      break;
    case B.Bool:
      r = e.visitBool;
      break;
    case B.Int:
      r = e.visitInt;
      break;
    case B.Int8:
      r = e.visitInt8 || e.visitInt;
      break;
    case B.Int16:
      r = e.visitInt16 || e.visitInt;
      break;
    case B.Int32:
      r = e.visitInt32 || e.visitInt;
      break;
    case B.Int64:
      r = e.visitInt64 || e.visitInt;
      break;
    case B.Uint8:
      r = e.visitUint8 || e.visitInt;
      break;
    case B.Uint16:
      r = e.visitUint16 || e.visitInt;
      break;
    case B.Uint32:
      r = e.visitUint32 || e.visitInt;
      break;
    case B.Uint64:
      r = e.visitUint64 || e.visitInt;
      break;
    case B.Float:
      r = e.visitFloat;
      break;
    case B.Float16:
      r = e.visitFloat16 || e.visitFloat;
      break;
    case B.Float32:
      r = e.visitFloat32 || e.visitFloat;
      break;
    case B.Float64:
      r = e.visitFloat64 || e.visitFloat;
      break;
    case B.Utf8:
      r = e.visitUtf8;
      break;
    case B.Binary:
      r = e.visitBinary;
      break;
    case B.FixedSizeBinary:
      r = e.visitFixedSizeBinary;
      break;
    case B.Date:
      r = e.visitDate;
      break;
    case B.DateDay:
      r = e.visitDateDay || e.visitDate;
      break;
    case B.DateMillisecond:
      r = e.visitDateMillisecond || e.visitDate;
      break;
    case B.Timestamp:
      r = e.visitTimestamp;
      break;
    case B.TimestampSecond:
      r = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case B.TimestampMillisecond:
      r = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case B.TimestampMicrosecond:
      r = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case B.TimestampNanosecond:
      r = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case B.Time:
      r = e.visitTime;
      break;
    case B.TimeSecond:
      r = e.visitTimeSecond || e.visitTime;
      break;
    case B.TimeMillisecond:
      r = e.visitTimeMillisecond || e.visitTime;
      break;
    case B.TimeMicrosecond:
      r = e.visitTimeMicrosecond || e.visitTime;
      break;
    case B.TimeNanosecond:
      r = e.visitTimeNanosecond || e.visitTime;
      break;
    case B.Decimal:
      r = e.visitDecimal;
      break;
    case B.List:
      r = e.visitList;
      break;
    case B.Struct:
      r = e.visitStruct;
      break;
    case B.Union:
      r = e.visitUnion;
      break;
    case B.DenseUnion:
      r = e.visitDenseUnion || e.visitUnion;
      break;
    case B.SparseUnion:
      r = e.visitSparseUnion || e.visitUnion;
      break;
    case B.Dictionary:
      r = e.visitDictionary;
      break;
    case B.Interval:
      r = e.visitInterval;
      break;
    case B.IntervalDayTime:
      r = e.visitIntervalDayTime || e.visitInterval;
      break;
    case B.IntervalYearMonth:
      r = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case B.FixedSizeList:
      r = e.visitFixedSizeList;
      break;
    case B.Map:
      r = e.visitMap;
      break;
  }
  if (typeof r == "function")
    return r;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${B[t]}'`);
}
function xg(e) {
  switch (e.typeId) {
    case B.Null:
      return B.Null;
    case B.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? B.Int8 : B.Uint8;
        case 16:
          return n ? B.Int16 : B.Uint16;
        case 32:
          return n ? B.Int32 : B.Uint32;
        case 64:
          return n ? B.Int64 : B.Uint64;
      }
      return B.Int;
    }
    case B.Float:
      switch (e.precision) {
        case ze.HALF:
          return B.Float16;
        case ze.SINGLE:
          return B.Float32;
        case ze.DOUBLE:
          return B.Float64;
      }
      return B.Float;
    case B.Binary:
      return B.Binary;
    case B.Utf8:
      return B.Utf8;
    case B.Bool:
      return B.Bool;
    case B.Decimal:
      return B.Decimal;
    case B.Time:
      switch (e.unit) {
        case Nt.SECOND:
          return B.TimeSecond;
        case Nt.MILLISECOND:
          return B.TimeMillisecond;
        case Nt.MICROSECOND:
          return B.TimeMicrosecond;
        case Nt.NANOSECOND:
          return B.TimeNanosecond;
      }
      return B.Time;
    case B.Timestamp:
      switch (e.unit) {
        case Nt.SECOND:
          return B.TimestampSecond;
        case Nt.MILLISECOND:
          return B.TimestampMillisecond;
        case Nt.MICROSECOND:
          return B.TimestampMicrosecond;
        case Nt.NANOSECOND:
          return B.TimestampNanosecond;
      }
      return B.Timestamp;
    case B.Date:
      switch (e.unit) {
        case jr.DAY:
          return B.DateDay;
        case jr.MILLISECOND:
          return B.DateMillisecond;
      }
      return B.Date;
    case B.Interval:
      switch (e.unit) {
        case bi.DAY_TIME:
          return B.IntervalDayTime;
        case bi.YEAR_MONTH:
          return B.IntervalYearMonth;
      }
      return B.Interval;
    case B.Map:
      return B.Map;
    case B.List:
      return B.List;
    case B.Struct:
      return B.Struct;
    case B.Union:
      switch (e.mode) {
        case En.Dense:
          return B.DenseUnion;
        case En.Sparse:
          return B.SparseUnion;
      }
      return B.Union;
    case B.FixedSizeBinary:
      return B.FixedSizeBinary;
    case B.FixedSizeList:
      return B.FixedSizeList;
    case B.Dictionary:
      return B.Dictionary;
  }
  throw new Error(`Unrecognized type '${B[e.typeId]}'`);
}
It.prototype.visitInt8 = null;
It.prototype.visitInt16 = null;
It.prototype.visitInt32 = null;
It.prototype.visitInt64 = null;
It.prototype.visitUint8 = null;
It.prototype.visitUint16 = null;
It.prototype.visitUint32 = null;
It.prototype.visitUint64 = null;
It.prototype.visitFloat16 = null;
It.prototype.visitFloat32 = null;
It.prototype.visitFloat64 = null;
It.prototype.visitDateDay = null;
It.prototype.visitDateMillisecond = null;
It.prototype.visitTimestampSecond = null;
It.prototype.visitTimestampMillisecond = null;
It.prototype.visitTimestampMicrosecond = null;
It.prototype.visitTimestampNanosecond = null;
It.prototype.visitTimeSecond = null;
It.prototype.visitTimeMillisecond = null;
It.prototype.visitTimeMicrosecond = null;
It.prototype.visitTimeNanosecond = null;
It.prototype.visitDenseUnion = null;
It.prototype.visitSparseUnion = null;
It.prototype.visitIntervalDayTime = null;
It.prototype.visitIntervalYearMonth = null;
const l2 = new Float64Array(1), Ds = new Uint32Array(l2.buffer);
function f2(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 i8(e) {
  if (e !== e)
    return 32256;
  l2[0] = e;
  const t = (Ds[1] & 2147483648) >> 16 & 65535;
  let n = Ds[1] & 2146435072, r = 0;
  return n >= 1089470464 ? Ds[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, r = (Ds[1] & 1048575) >> 10) : n <= 1056964608 ? (r = 1048576 + (Ds[1] & 1048575), r = 1048576 + (r << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, r = (Ds[1] & 1048575) + 512 >> 10), t | n | r & 65535;
}
class dt extends It {
}
function gt(e) {
  return (t, n, r) => {
    if (t.setValid(n, r != null))
      return e(t, n, r);
  };
}
const s8 = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, F0 = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, o8 = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, a8 = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, h2 = (e, t, n, r) => {
  if (n + 1 < t.length) {
    const { [n]: i, [n + 1]: s } = t;
    e.set(r.subarray(0, s - i), i);
  }
}, c8 = ({ offset: e, values: t }, n, r) => {
  const i = e + n;
  r ? t[i >> 3] |= 1 << i % 8 : t[i >> 3] &= ~(1 << i % 8);
}, Zr = ({ values: e }, t, n) => {
  e[t] = n;
}, k0 = ({ values: e }, t, n) => {
  e[t] = n;
}, d2 = ({ values: e }, t, n) => {
  e[t] = i8(n);
}, u8 = (e, t, n) => {
  switch (e.type.precision) {
    case ze.HALF:
      return d2(e, t, n);
    case ze.SINGLE:
    case ze.DOUBLE:
      return k0(e, t, n);
  }
}, p2 = ({ values: e }, t, n) => {
  s8(e, t, n.valueOf());
}, y2 = ({ values: e }, t, n) => {
  F0(e, t * 2, n.valueOf());
}, l8 = ({ stride: e, values: t }, n, r) => {
  t.set(r.subarray(0, e), e * n);
}, f8 = ({ values: e, valueOffsets: t }, n, r) => h2(e, t, n, r), h8 = ({ values: e, valueOffsets: t }, n, r) => {
  h2(e, t, n, E0(r));
}, d8 = (e, t, n) => {
  e.type.unit === jr.DAY ? p2(e, t, n) : y2(e, t, n);
}, m2 = ({ values: e }, t, n) => F0(e, t * 2, n / 1e3), g2 = ({ values: e }, t, n) => F0(e, t * 2, n), b2 = ({ values: e }, t, n) => o8(e, t * 2, n), w2 = ({ values: e }, t, n) => a8(e, t * 2, n), p8 = (e, t, n) => {
  switch (e.type.unit) {
    case Nt.SECOND:
      return m2(e, t, n);
    case Nt.MILLISECOND:
      return g2(e, t, n);
    case Nt.MICROSECOND:
      return b2(e, t, n);
    case Nt.NANOSECOND:
      return w2(e, t, n);
  }
}, v2 = ({ values: e }, t, n) => {
  e[t] = n;
}, _2 = ({ values: e }, t, n) => {
  e[t] = n;
}, x2 = ({ values: e }, t, n) => {
  e[t] = n;
}, S2 = ({ values: e }, t, n) => {
  e[t] = n;
}, y8 = (e, t, n) => {
  switch (e.type.unit) {
    case Nt.SECOND:
      return v2(e, t, n);
    case Nt.MILLISECOND:
      return _2(e, t, n);
    case Nt.MICROSECOND:
      return x2(e, t, n);
    case Nt.NANOSECOND:
      return S2(e, t, n);
  }
}, m8 = ({ values: e, stride: t }, n, r) => {
  e.set(r.subarray(0, t), t * n);
}, g8 = (e, t, n) => {
  const r = e.children[0], i = e.valueOffsets, s = gn.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));
}, b8 = (e, t, n) => {
  const r = e.children[0], { valueOffsets: i } = e, s = gn.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;
}, w8 = (e, t) => (n, r, i, s) => r && n(r, e, t[s]), v8 = (e, t) => (n, r, i, s) => r && n(r, e, t.get(s)), _8 = (e, t) => (n, r, i, s) => r && n(r, e, t.get(i.name)), x8 = (e, t) => (n, r, i, s) => r && n(r, e, t[i.name]), S8 = (e, t, n) => {
  const r = e.type.children.map((s) => gn.getVisitFn(s.type)), i = n instanceof Map ? _8(t, n) : n instanceof re ? v8(t, n) : Array.isArray(n) ? w8(t, n) : x8(t, n);
  e.type.children.forEach((s, o) => i(r[o], e.children[o], s, o));
}, M8 = (e, t, n) => {
  e.type.mode === En.Dense ? M2(e, t, n) : $2(e, t, n);
}, M2 = (e, t, n) => {
  const r = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[r];
  gn.visit(i, e.valueOffsets[t], n);
}, $2 = (e, t, n) => {
  const r = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[r];
  gn.visit(i, t, n);
}, $8 = (e, t, n) => {
  var r;
  (r = e.dictionary) === null || r === void 0 || r.set(e.values[t], n);
}, A8 = (e, t, n) => {
  e.type.unit === bi.DAY_TIME ? A2(e, t, n) : I2(e, t, n);
}, A2 = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, I2 = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, I8 = (e, t, n) => {
  const { stride: r } = e, i = e.children[0], s = gn.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));
};
dt.prototype.visitBool = gt(c8);
dt.prototype.visitInt = gt(Zr);
dt.prototype.visitInt8 = gt(Zr);
dt.prototype.visitInt16 = gt(Zr);
dt.prototype.visitInt32 = gt(Zr);
dt.prototype.visitInt64 = gt(Zr);
dt.prototype.visitUint8 = gt(Zr);
dt.prototype.visitUint16 = gt(Zr);
dt.prototype.visitUint32 = gt(Zr);
dt.prototype.visitUint64 = gt(Zr);
dt.prototype.visitFloat = gt(u8);
dt.prototype.visitFloat16 = gt(d2);
dt.prototype.visitFloat32 = gt(k0);
dt.prototype.visitFloat64 = gt(k0);
dt.prototype.visitUtf8 = gt(h8);
dt.prototype.visitBinary = gt(f8);
dt.prototype.visitFixedSizeBinary = gt(l8);
dt.prototype.visitDate = gt(d8);
dt.prototype.visitDateDay = gt(p2);
dt.prototype.visitDateMillisecond = gt(y2);
dt.prototype.visitTimestamp = gt(p8);
dt.prototype.visitTimestampSecond = gt(m2);
dt.prototype.visitTimestampMillisecond = gt(g2);
dt.prototype.visitTimestampMicrosecond = gt(b2);
dt.prototype.visitTimestampNanosecond = gt(w2);
dt.prototype.visitTime = gt(y8);
dt.prototype.visitTimeSecond = gt(v2);
dt.prototype.visitTimeMillisecond = gt(_2);
dt.prototype.visitTimeMicrosecond = gt(x2);
dt.prototype.visitTimeNanosecond = gt(S2);
dt.prototype.visitDecimal = gt(m8);
dt.prototype.visitList = gt(g8);
dt.prototype.visitStruct = gt(S8);
dt.prototype.visitUnion = gt(M8);
dt.prototype.visitDenseUnion = gt(M2);
dt.prototype.visitSparseUnion = gt($2);
dt.prototype.visitDictionary = gt($8);
dt.prototype.visitInterval = gt(A8);
dt.prototype.visitIntervalDayTime = gt(A2);
dt.prototype.visitIntervalYearMonth = gt(I2);
dt.prototype.visitFixedSizeList = gt(I8);
dt.prototype.visitMap = gt(b8);
const gn = new dt(), vn = Symbol.for("parent"), no = Symbol.for("rowIndex");
class B0 {
  constructor(t, n) {
    return this[vn] = t, this[no] = n, new Proxy(this, new E8());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[no], n = this[vn], r = n.type.children, i = {};
    for (let s = -1, o = r.length; ++s < o; )
      i[r[s].name] = Ue.visit(n.children[s], t);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${Ya(t)}: ${Ya(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new T8(this[vn], this[no]);
  }
}
class T8 {
  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,
        Ue.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
}
Object.defineProperties(B0.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [vn]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [no]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
class E8 {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[vn].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[vn].type.children.findIndex((r) => r.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[vn].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[vn].type.children.findIndex((i) => i.name === n);
    if (r !== -1) {
      const i = Ue.visit(t[vn].children[r], t[no]);
      return Reflect.set(t, n, i), i;
    }
  }
  set(t, n, r) {
    const i = t[vn].type.children.findIndex((s) => s.name === n);
    return i !== -1 ? (gn.visit(t[vn].children[i], t[no], r), Reflect.set(t, n, r)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, r) : !1;
  }
}
class ut extends It {
}
function pt(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const N8 = (e, t) => 864e5 * e[t], R0 = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), L8 = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, D8 = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, T2 = (e) => new Date(e), O8 = (e, t) => T2(N8(e, t)), F8 = (e, t) => T2(R0(e, t)), k8 = (e, t) => null, E2 = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const r = t[n], i = t[n + 1];
  return e.subarray(r, i);
}, B8 = ({ offset: e, values: t }, n) => {
  const r = e + n;
  return (t[r >> 3] & 1 << r % 8) !== 0;
}, N2 = ({ values: e }, t) => O8(e, t), L2 = ({ values: e }, t) => F8(e, t * 2), Li = ({ stride: e, values: t }, n) => t[e * n], R8 = ({ stride: e, values: t }, n) => f2(t[e * n]), D2 = ({ values: e }, t) => e[t], C8 = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), P8 = ({ values: e, valueOffsets: t }, n) => E2(e, t, n), z8 = ({ values: e, valueOffsets: t }, n) => {
  const r = E2(e, t, n);
  return r !== null ? tp(r) : null;
}, U8 = ({ values: e }, t) => e[t], j8 = ({ type: e, values: t }, n) => e.precision !== ze.HALF ? t[n] : f2(t[n]), q8 = (e, t) => e.type.unit === jr.DAY ? N2(e, t) : L2(e, t), O2 = ({ values: e }, t) => 1e3 * R0(e, t * 2), F2 = ({ values: e }, t) => R0(e, t * 2), k2 = ({ values: e }, t) => L8(e, t * 2), B2 = ({ values: e }, t) => D8(e, t * 2), V8 = (e, t) => {
  switch (e.type.unit) {
    case Nt.SECOND:
      return O2(e, t);
    case Nt.MILLISECOND:
      return F2(e, t);
    case Nt.MICROSECOND:
      return k2(e, t);
    case Nt.NANOSECOND:
      return B2(e, t);
  }
}, R2 = ({ values: e }, t) => e[t], C2 = ({ values: e }, t) => e[t], P2 = ({ values: e }, t) => e[t], z2 = ({ values: e }, t) => e[t], Y8 = (e, t) => {
  switch (e.type.unit) {
    case Nt.SECOND:
      return R2(e, t);
    case Nt.MILLISECOND:
      return C2(e, t);
    case Nt.MICROSECOND:
      return P2(e, t);
    case Nt.NANOSECOND:
      return z2(e, t);
  }
}, W8 = ({ values: e, stride: t }, n) => O0.decimal(e.subarray(t * n, t * (n + 1))), X8 = (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 re([c]);
}, G8 = (e, t) => {
  const { valueOffsets: n, children: r } = e, { [t]: i, [t + 1]: s } = n, o = r[0];
  return new C0(o.slice(i, s - i));
}, H8 = (e, t) => new B0(e, t), Z8 = (e, t) => e.type.mode === En.Dense ? U2(e, t) : j2(e, t), U2 = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[n];
  return Ue.visit(r, e.valueOffsets[t]);
}, j2 = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[n];
  return Ue.visit(r, t);
}, K8 = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, J8 = (e, t) => e.type.unit === bi.DAY_TIME ? q2(e, t) : V2(e, t), q2 = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), V2 = ({ 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;
}, Q8 = (e, t) => {
  const { stride: n, children: r } = e, s = r[0].slice(t * n, n);
  return new re([s]);
};
ut.prototype.visitNull = pt(k8);
ut.prototype.visitBool = pt(B8);
ut.prototype.visitInt = pt(U8);
ut.prototype.visitInt8 = pt(Li);
ut.prototype.visitInt16 = pt(Li);
ut.prototype.visitInt32 = pt(Li);
ut.prototype.visitInt64 = pt(D2);
ut.prototype.visitUint8 = pt(Li);
ut.prototype.visitUint16 = pt(Li);
ut.prototype.visitUint32 = pt(Li);
ut.prototype.visitUint64 = pt(D2);
ut.prototype.visitFloat = pt(j8);
ut.prototype.visitFloat16 = pt(R8);
ut.prototype.visitFloat32 = pt(Li);
ut.prototype.visitFloat64 = pt(Li);
ut.prototype.visitUtf8 = pt(z8);
ut.prototype.visitBinary = pt(P8);
ut.prototype.visitFixedSizeBinary = pt(C8);
ut.prototype.visitDate = pt(q8);
ut.prototype.visitDateDay = pt(N2);
ut.prototype.visitDateMillisecond = pt(L2);
ut.prototype.visitTimestamp = pt(V8);
ut.prototype.visitTimestampSecond = pt(O2);
ut.prototype.visitTimestampMillisecond = pt(F2);
ut.prototype.visitTimestampMicrosecond = pt(k2);
ut.prototype.visitTimestampNanosecond = pt(B2);
ut.prototype.visitTime = pt(Y8);
ut.prototype.visitTimeSecond = pt(R2);
ut.prototype.visitTimeMillisecond = pt(C2);
ut.prototype.visitTimeMicrosecond = pt(P2);
ut.prototype.visitTimeNanosecond = pt(z2);
ut.prototype.visitDecimal = pt(W8);
ut.prototype.visitList = pt(X8);
ut.prototype.visitStruct = pt(H8);
ut.prototype.visitUnion = pt(Z8);
ut.prototype.visitDenseUnion = pt(U2);
ut.prototype.visitSparseUnion = pt(j2);
ut.prototype.visitDictionary = pt(K8);
ut.prototype.visitInterval = pt(J8);
ut.prototype.visitIntervalDayTime = pt(q2);
ut.prototype.visitIntervalYearMonth = pt(V2);
ut.prototype.visitFixedSizeList = pt(Q8);
ut.prototype.visitMap = pt(G8);
const Ue = new ut(), Yn = Symbol.for("keys"), ro = Symbol.for("vals");
class C0 {
  constructor(t) {
    return this[Yn] = new re([t.children[0]]).memoize(), this[ro] = t.children[1], new Proxy(this, new eA());
  }
  [Symbol.iterator]() {
    return new tA(this[Yn], this[ro]);
  }
  get size() {
    return this[Yn].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[Yn], n = this[ro], r = {};
    for (let i = -1, s = t.length; ++i < s; )
      r[t.get(i)] = Ue.visit(n, i);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${Ya(t)}: ${Ya(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}
class tA {
  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),
        Ue.visit(this.vals, t)
      ]
    });
  }
}
class eA {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[Yn].toArray().map(String);
  }
  has(t, n) {
    return t[Yn].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[Yn].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const r = t[Yn].indexOf(n);
    if (r !== -1) {
      const i = Ue.visit(Reflect.get(t, ro), r);
      return Reflect.set(t, n, i), i;
    }
  }
  set(t, n, r) {
    const i = t[Yn].indexOf(n);
    return i !== -1 ? (gn.visit(Reflect.get(t, ro), i, r), Reflect.set(t, n, r)) : Reflect.has(t, n) ? Reflect.set(t, n, r) : !1;
  }
}
Object.defineProperties(C0.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [Yn]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [ro]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let Sg;
function Y2(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 && (Sg = s, s = o, o = Sg), o > i && (o = i), r ? r(e, s, o) : [s, o];
}
const Mg = (e) => e !== e;
function Yo(e) {
  if (typeof e !== "object" || e === null)
    return Mg(e) ? Mg : (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 ? G$(e, n) : !1 : e instanceof Map ? rA(e) : Array.isArray(e) ? nA(e) : e instanceof re ? iA(e) : sA(e, !0);
}
function nA(e) {
  const t = [];
  for (let n = -1, r = e.length; ++n < r; )
    t[n] = Yo(e[n]);
  return Of(t);
}
function rA(e) {
  let t = -1;
  const n = [];
  for (const r of e.values())
    n[++t] = Yo(r);
  return Of(n);
}
function iA(e) {
  const t = [];
  for (let n = -1, r = e.length; ++n < r; )
    t[n] = Yo(e.get(n));
  return Of(t);
}
function sA(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] = Yo(e[n[i]]);
  return Of(r, n);
}
function Of(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return oA(e, n);
      case Map:
        return $g(e, n, n.keys());
      case C0:
      case B0:
      case Object:
      case void 0:
        return $g(e, n, t || Object.keys(n));
    }
    return n instanceof re ? aA(e, n) : !1;
  };
}
function oA(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 aA(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 $g(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 W2(e, t, n, r) {
  return (n & 1 << r) !== 0;
}
function cA(e, t, n, r) {
  return (n & 1 << r) >> r;
}
function uA(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
      ip(new P0(n, e, t, null, W2)).subarray(0, r)
    )), i;
  }
  return n;
}
function ip(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 P0 {
  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 sp(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new P0(e, t, n - t, e, cA))
      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
    sp(e, t, i) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    sp(e, r, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    lA(e, i >> 3, r - i >> 3)
  );
}
function lA(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 += Hh(s.getUint32(i)), i += 4;
  for (; o - i >= 2; )
    r += Hh(s.getUint16(i)), i += 2;
  for (; o - i >= 1; )
    r += Hh(s.getUint8(i)), i += 1;
  return r;
}
function Hh(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 fA = -1;
class Yt {
  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 Yt ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = $r(t), s && ((c = s[0]) && (this.valueOffsets = c), (c = s[1]) && (this.values = c), (c = s[2]) && (this.nullBitmap = c), (c = s[3]) && (this.typeIds = c))), this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;
  }
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  get byteLength() {
    let t = 0;
    const { valueOffsets: n, values: 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() {
    let t = this._nullCount, n;
    return t <= fA && (n = this.nullBitmap) && (this._nullCount = t = this.length - sp(n, this.offset, this.offset + this.length)), t;
  }
  getValid(t) {
    if (this.nullable && this.nullCount > 0) {
      const n = this.offset + t;
      return (this.nullBitmap[n >> 3] & 1 << n % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    if (!this.nullable)
      return n;
    if (!this.nullBitmap || this.nullBitmap.byteLength <= t >> 3) {
      const { nullBitmap: c } = this._changeLengthAndBackfillNullBitmap(this.length);
      Object.assign(this, { nullBitmap: c, _nullCount: 0 });
    }
    const { nullBitmap: r, offset: i } = this, s = i + t >> 3, o = (i + t) % 8, a = r[s] >> o & 1;
    return n ? a === 0 && (r[s] |= 1 << o, this._nullCount = this.nullCount + 1) : a === 1 && (r[s] &= ~(1 << o), this._nullCount = this.nullCount - 1), n;
  }
  clone(t = this.type, n = this.offset, r = this.length, i = this._nullCount, s = this, o = this.children) {
    return new Yt(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 === B.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(uA(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[Mr.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[Mr.TYPE]) && (o[Mr.TYPE] = s.subarray(t, t + n)), (s = o[Mr.OFFSET]) && (o[Mr.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[Mr.DATA]) && (o[Mr.DATA] = i === 6 ? s : s.subarray(r * t, r * (t + n))), o;
  }
  _sliceChildren(t, n, r) {
    return t.map((i) => i.slice(n, r));
  }
}
Yt.prototype.children = Object.freeze([]);
class Oa extends It {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["length"]: i = 0 } = t;
    return new Yt(n, r, i, 0);
  }
  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 Yt(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 Yt(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 Yt(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 = la(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(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 = la(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(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 / $r(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(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 / $r(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(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 / $r(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(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 / $r(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(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 / $r(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(n, r, o, a, [void 0, s, i]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i } = t, s = Ft(t.nullBitmap), o = la(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(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 Yt(n, r, o, a, [void 0, void 0, s], i);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["children"]: i = [] } = t, s = Ft(t.nullBitmap), o = Pt(n.ArrayType, t.typeIds), { ["length"]: a = o.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    if (mt.isSparseUnion(n))
      return new Yt(n, r, a, c, [void 0, void 0, s, o], i);
    const u = la(t.valueOffsets);
    return new Yt(n, r, a, c, [u, void 0, s, o], i);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Ft(t.nullBitmap), s = Pt(n.indices.ArrayType, t.data), { ["dictionary"]: o = new re([new Oa().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(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 / $r(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(n, r, o, a, [void 0, s, i]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i = new Oa().visit({ type: n.valueType }) } = t, s = Ft(t.nullBitmap), { ["length"]: o = i.length / $r(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(n, r, o, a, [void 0, void 0, s], [i]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i = new Oa().visit({ type: n.childType }) } = t, s = Ft(t.nullBitmap), o = la(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new Yt(n, r, a, c, [o, void 0, s], [i]);
  }
}
function $t(e) {
  return new Oa().visit(e);
}
class Ag {
  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 X2(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function G2(e) {
  return e.reduce((t, n, r) => (t[r + 1] = t[r] + n.length, t), new Uint32Array(e.length + 1));
}
function H2(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), h = Math.min(r - c, u);
    i.push(a.slice(l, h - l));
  }
  return i.length === 0 && i.push(e[0].slice(0, 0)), i;
}
function z0(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 U0(e, t) {
  return e.getValid(t);
}
function io(e) {
  function t(n, r, i) {
    return e(n[r], i);
  }
  return function(n) {
    const r = this.data;
    return z0(r, this._offsets, n, t);
  };
}
function Z2(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 = z0(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
function K2(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 h = r[u];
      if (~(a = e(h, t, o)))
        return c + a;
      o = 0, c += h.length;
    }
    return -1;
  }
  return function(r, i) {
    t = r;
    const s = this.data, o = typeof i != "number" ? n(s, 0, 0) : z0(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
class lt extends It {
}
function hA(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function dA(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let r = 0;
  for (const i of new P0(n, e.offset + (t || 0), e.length, n, W2)) {
    if (!i)
      return r;
    ++r;
  }
  return -1;
}
function vt(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    return dA(e, n);
  const r = Ue.getVisitFn(e), i = Yo(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (i(r(e, s)))
      return s;
  return -1;
}
function J2(e, t, n) {
  const r = Ue.getVisitFn(e), i = Yo(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (i(r(e, s)))
      return s;
  return -1;
}
lt.prototype.visitNull = hA;
lt.prototype.visitBool = vt;
lt.prototype.visitInt = vt;
lt.prototype.visitInt8 = vt;
lt.prototype.visitInt16 = vt;
lt.prototype.visitInt32 = vt;
lt.prototype.visitInt64 = vt;
lt.prototype.visitUint8 = vt;
lt.prototype.visitUint16 = vt;
lt.prototype.visitUint32 = vt;
lt.prototype.visitUint64 = vt;
lt.prototype.visitFloat = vt;
lt.prototype.visitFloat16 = vt;
lt.prototype.visitFloat32 = vt;
lt.prototype.visitFloat64 = vt;
lt.prototype.visitUtf8 = vt;
lt.prototype.visitBinary = vt;
lt.prototype.visitFixedSizeBinary = vt;
lt.prototype.visitDate = vt;
lt.prototype.visitDateDay = vt;
lt.prototype.visitDateMillisecond = vt;
lt.prototype.visitTimestamp = vt;
lt.prototype.visitTimestampSecond = vt;
lt.prototype.visitTimestampMillisecond = vt;
lt.prototype.visitTimestampMicrosecond = vt;
lt.prototype.visitTimestampNanosecond = vt;
lt.prototype.visitTime = vt;
lt.prototype.visitTimeSecond = vt;
lt.prototype.visitTimeMillisecond = vt;
lt.prototype.visitTimeMicrosecond = vt;
lt.prototype.visitTimeNanosecond = vt;
lt.prototype.visitDecimal = vt;
lt.prototype.visitList = vt;
lt.prototype.visitStruct = vt;
lt.prototype.visitUnion = vt;
lt.prototype.visitDenseUnion = J2;
lt.prototype.visitSparseUnion = J2;
lt.prototype.visitDictionary = vt;
lt.prototype.visitInterval = vt;
lt.prototype.visitIntervalDayTime = vt;
lt.prototype.visitIntervalYearMonth = vt;
lt.prototype.visitFixedSizeList = vt;
lt.prototype.visitMap = vt;
const al = new lt();
class ft extends It {
}
function yt(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === B.Timestamp || t instanceof vi && t.bitWidth !== 64 || t instanceof Ha && t.bitWidth !== 64 || t instanceof Ga && t.precision !== ze.HALF))
    return new Ag(e.data.length, (r) => {
      const i = e.data[r];
      return i.values.subarray(0, i.length)[Symbol.iterator]();
    });
  let n = 0;
  return new Ag(e.data.length, (r) => {
    const s = e.data[r].length, o = e.slice(n, n + s);
    return n += s, new pA(o);
  });
}
class pA {
  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;
  }
}
ft.prototype.visitNull = yt;
ft.prototype.visitBool = yt;
ft.prototype.visitInt = yt;
ft.prototype.visitInt8 = yt;
ft.prototype.visitInt16 = yt;
ft.prototype.visitInt32 = yt;
ft.prototype.visitInt64 = yt;
ft.prototype.visitUint8 = yt;
ft.prototype.visitUint16 = yt;
ft.prototype.visitUint32 = yt;
ft.prototype.visitUint64 = yt;
ft.prototype.visitFloat = yt;
ft.prototype.visitFloat16 = yt;
ft.prototype.visitFloat32 = yt;
ft.prototype.visitFloat64 = yt;
ft.prototype.visitUtf8 = yt;
ft.prototype.visitBinary = yt;
ft.prototype.visitFixedSizeBinary = yt;
ft.prototype.visitDate = yt;
ft.prototype.visitDateDay = yt;
ft.prototype.visitDateMillisecond = yt;
ft.prototype.visitTimestamp = yt;
ft.prototype.visitTimestampSecond = yt;
ft.prototype.visitTimestampMillisecond = yt;
ft.prototype.visitTimestampMicrosecond = yt;
ft.prototype.visitTimestampNanosecond = yt;
ft.prototype.visitTime = yt;
ft.prototype.visitTimeSecond = yt;
ft.prototype.visitTimeMillisecond = yt;
ft.prototype.visitTimeMicrosecond = yt;
ft.prototype.visitTimeNanosecond = yt;
ft.prototype.visitDecimal = yt;
ft.prototype.visitList = yt;
ft.prototype.visitStruct = yt;
ft.prototype.visitUnion = yt;
ft.prototype.visitDenseUnion = yt;
ft.prototype.visitSparseUnion = yt;
ft.prototype.visitDictionary = yt;
ft.prototype.visitInterval = yt;
ft.prototype.visitIntervalDayTime = yt;
ft.prototype.visitIntervalYearMonth = yt;
ft.prototype.visitFixedSizeList = yt;
ft.prototype.visitMap = yt;
const j0 = new ft(), yA = (e, t) => e + t;
class Di extends It {
  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 === Nt.SECOND ? 4 : 8;
  }
  visitInterval(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitStruct(t, n) {
    return t.children.reduce((r, i) => r + or.visit(i, n), 0);
  }
  visitFixedSizeBinary(t, n) {
    return t.type.byteWidth;
  }
  visitMap(t, n) {
    return 8 + t.children.reduce((r, i) => r + or.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 mA = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), gA = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), bA = ({ valueOffsets: e, stride: t, children: n }, r) => {
  const i = n[0], { [r * t]: s } = e, { [r * t + 1]: o } = e, a = or.getVisitFn(i.type), c = i.slice(s, o - s);
  let u = 8;
  for (let l = -1, h = o - s; ++l < h; )
    u += a(c, l);
  return u;
}, wA = ({ stride: e, children: t }, n) => {
  const r = t[0], i = r.slice(n * e, e), s = or.getVisitFn(r.type);
  let o = 0;
  for (let a = -1, c = i.length; ++a < c; )
    o += s(i, a);
  return o;
}, vA = (e, t) => e.type.mode === En.Dense ? Q2(e, t) : tv(e, t), Q2 = ({ type: e, children: t, typeIds: n, valueOffsets: r }, i) => {
  const s = e.typeIdToChildIndex[n[i]];
  return 8 + or.visit(t[s], r[i]);
}, tv = ({ children: e }, t) => 4 + or.visitMany(e, e.map(() => t)).reduce(yA, 0);
Di.prototype.visitUtf8 = mA;
Di.prototype.visitBinary = gA;
Di.prototype.visitList = bA;
Di.prototype.visitFixedSizeList = wA;
Di.prototype.visitUnion = vA;
Di.prototype.visitDenseUnion = Q2;
Di.prototype.visitSparseUnion = tv;
const or = new Di();
var ev;
const nv = {}, rv = {};
let re = class Yi {
  constructor(t) {
    var n, r, i;
    const s = t[0] instanceof Yi ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof Yt)))
      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 } = nv[o.typeId], h = s[0];
        this.isValid = (f) => U0(h, f), this.get = (f) => a(h, f), this.set = (f, d) => c(h, f, d), this.indexOf = (f) => u(h, f), this.getByteLength = (f) => l(h, f), this._offsets = [0, h.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, rv[o.typeId]), this._offsets = G2(s);
        break;
    }
    this.data = s, this.type = o, this.stride = $r(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[this._offsets.length - 1];
  }
  /**
   * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
   */
  get byteLength() {
    return this._byteLength === -1 && (this._byteLength = this.data.reduce((t, n) => t + n.byteLength, 0)), this._byteLength;
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return this._nullCount === -1 && (this._nullCount = X2(this.data)), this._nullCount;
  }
  /**
   * The Array or TypedAray constructor used for the JS representation
   *  of the element's values in {@link Vector.prototype.toArray `toArray()`}.
   */
  get ArrayType() {
    return this.type.ArrayType;
  }
  /**
   * The name that should be printed when the Vector is logged in a message.
   */
  get [Symbol.toStringTag]() {
    return `${this.VectorName}<${this.type[Symbol.toStringTag]}>`;
  }
  /**
   * The name of this Vector.
   */
  get VectorName() {
    return `${B[this.type.typeId]}Vector`;
  }
  /**
   * Check whether an element is null.
   * @param index The index at which to read the validity bitmap.
   */
  // @ts-ignore
  isValid(t) {
    return !1;
  }
  /**
   * Get an element value by position.
   * @param index The index of the element to read.
   */
  // @ts-ignore
  get(t) {
    return null;
  }
  /**
   * Set an element value by position.
   * @param index The index of the element to write.
   * @param value The value to set.
   */
  // @ts-ignore
  set(t, n) {
  }
  /**
   * Retrieve the index of the first occurrence of a value in an Vector.
   * @param element The value to locate in the Vector.
   * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.
   */
  // @ts-ignore
  indexOf(t, n) {
    return -1;
  }
  includes(t, n) {
    return this.indexOf(t, n) > 0;
  }
  /**
   * Get the size in bytes of an element by index.
   * @param index The index at which to get the byteLength.
   */
  // @ts-ignore
  getByteLength(t) {
    return 0;
  }
  /**
   * Iterator for the Vector's elements.
   */
  [Symbol.iterator]() {
    return j0.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 Yi(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 Yi(Y2(this, t, n, ({ data: r, _offsets: i }, s, o) => H2(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 B.Int:
      case B.Float:
      case B.Decimal:
      case B.Time:
      case B.Timestamp:
        switch (n.length) {
          case 0:
            return new s();
          case 1:
            return n[0].values.subarray(0, 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 Yi(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return mt.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 (mt.isDictionary(this.type)) {
      const t = new cl(this.data[0].dictionary), n = this.data.map((r) => {
        const i = r.clone();
        return i.dictionary = t, i;
      });
      return new Yi(n);
    }
    return new cl(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 (mt.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 Yi(n);
    }
    return this;
  }
};
ev = Symbol.toStringTag;
re[ev] = ((e) => {
  e.type = mt.prototype, e.data = [], e.length = 0, e.stride = 1, e.numChildren = 0, e._nullCount = -1, e._byteLength = -1, e._offsets = new Uint32Array([0]), e[Symbol.isConcatSpreadable] = !0;
  const t = Object.keys(B).map((n) => B[n]).filter((n) => typeof n == "number" && n !== B.NONE);
  for (const n of t) {
    const r = Ue.getVisitFnByTypeId(n), i = gn.getVisitFnByTypeId(n), s = al.getVisitFnByTypeId(n), o = or.getVisitFnByTypeId(n);
    nv[n] = { get: r, set: i, indexOf: s, byteLength: o }, rv[n] = Object.create(e, {
      isValid: { value: io(U0) },
      get: { value: io(Ue.getVisitFnByTypeId(n)) },
      set: { value: Z2(gn.getVisitFnByTypeId(n)) },
      indexOf: { value: K2(al.getVisitFnByTypeId(n)) },
      getByteLength: { value: io(or.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(re.prototype);
class cl extends re {
  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 cl(i.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new re(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}
class op {
  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(i), t.pad(4), t.writeInt32(r), t.writeInt64(n), t.offset();
  }
}
const Zh = 2, Wn = 4, Tr = 4, Ut = 4, si = new Int32Array(2), Ig = new Float32Array(si.buffer), Tg = new Float64Array(si.buffer), nu = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
let Br = class ap {
  constructor(t, n) {
    this.low = t | 0, this.high = n | 0;
  }
  static create(t, n) {
    return t == 0 && n == 0 ? ap.ZERO : new ap(t, n);
  }
  toFloat64() {
    return (this.low >>> 0) + this.high * 4294967296;
  }
  equals(t) {
    return this.low == t.low && this.high == t.high;
  }
};
Br.ZERO = new Br(0, 0);
var cp;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(cp || (cp = {}));
let wo = class iv {
  /**
   * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
   */
  constructor(t) {
    this.bytes_ = t, this.position_ = 0;
  }
  /**
   * Create and allocate a new ByteBuffer with a given size.
   */
  static allocate(t) {
    return new iv(new Uint8Array(t));
  }
  clear() {
    this.position_ = 0;
  }
  /**
   * Get the underlying `Uint8Array`.
   */
  bytes() {
    return this.bytes_;
  }
  /**
   * Get the buffer's position.
   */
  position() {
    return this.position_;
  }
  /**
   * Set the buffer's position.
   */
  setPosition(t) {
    this.position_ = t;
  }
  /**
   * Get the buffer's capacity.
   */
  capacity() {
    return this.bytes_.length;
  }
  readInt8(t) {
    return this.readUint8(t) << 24 >> 24;
  }
  readUint8(t) {
    return this.bytes_[t];
  }
  readInt16(t) {
    return this.readUint16(t) << 16 >> 16;
  }
  readUint16(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8;
  }
  readInt32(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8 | this.bytes_[t + 2] << 16 | this.bytes_[t + 3] << 24;
  }
  readUint32(t) {
    return this.readInt32(t) >>> 0;
  }
  readInt64(t) {
    return new Br(this.readInt32(t), this.readInt32(t + 4));
  }
  readUint64(t) {
    return new Br(this.readUint32(t), this.readUint32(t + 4));
  }
  readFloat32(t) {
    return si[0] = this.readInt32(t), Ig[0];
  }
  readFloat64(t) {
    return si[nu ? 0 : 1] = this.readInt32(t), si[nu ? 1 : 0] = this.readInt32(t + 4), Tg[0];
  }
  writeInt8(t, n) {
    this.bytes_[t] = n;
  }
  writeUint8(t, n) {
    this.bytes_[t] = n;
  }
  writeInt16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeUint16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeInt32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeUint32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeInt64(t, n) {
    this.writeInt32(t, n.low), this.writeInt32(t + 4, n.high);
  }
  writeUint64(t, n) {
    this.writeUint32(t, n.low), this.writeUint32(t + 4, n.high);
  }
  writeFloat32(t, n) {
    Ig[0] = n, this.writeInt32(t, si[0]);
  }
  writeFloat64(t, n) {
    Tg[0] = n, this.writeInt32(t, si[nu ? 0 : 1]), this.writeInt32(t + 4, si[nu ? 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_ + Wn + Tr)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < Tr; n++)
      t += String.fromCharCode(this.readInt8(this.position_ + Wn + 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 UTF-16, pass Encoding.UTF8_BYTES as
   * the "optionalEncoding" argument. This is useful for avoiding conversion to
   * and from UTF-16 when the data will just be packaged back up in another
   * FlatBuffer later on.
   *
   * @param offset
   * @param opt_encoding Defaults to UTF16_STRING
   */
  __string(t, n) {
    t += this.readInt32(t);
    const r = this.readInt32(t);
    let i = "", s = 0;
    if (t += Wn, n === cp.UTF8_BYTES)
      return this.bytes_.subarray(t, t + r);
    for (; s < r; ) {
      let o;
      const a = this.readUint8(t + s++);
      if (a < 192)
        o = a;
      else {
        const c = this.readUint8(t + s++);
        if (a < 224)
          o = (a & 31) << 6 | c & 63;
        else {
          const u = this.readUint8(t + s++);
          if (a < 240)
            o = (a & 15) << 12 | (c & 63) << 6 | u & 63;
          else {
            const l = this.readUint8(t + s++);
            o = (a & 7) << 18 | (c & 63) << 12 | (u & 63) << 6 | l & 63;
          }
        }
      }
      o < 65536 ? i += String.fromCharCode(o) : (o -= 65536, i += String.fromCharCode((o >> 10) + 55296, (o & 1024 - 1) + 56320));
    }
    return 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) + Wn;
  }
  /**
   * 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 != Tr)
      throw new Error("FlatBuffers: file identifier must be length " + Tr);
    for (let n = 0; n < Tr; n++)
      if (t.charCodeAt(n) != this.readInt8(this.position() + Wn + n))
        return !1;
    return !0;
  }
  /**
   * A helper function to avoid generated code depending on this file directly.
   */
  createLong(t, n) {
    return Br.create(t, n);
  }
  /**
   * A helper function for generating list for obj api
   */
  createScalarList(t, n) {
    const r = [];
    for (let i = 0; i < n; ++i)
      t(i) !== null && r.push(t(i));
    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;
  }
}, sv = class ov {
  /**
   * Create a FlatBufferBuilder.
   */
  constructor(t) {
    this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null;
    let n;
    t ? n = t : n = 1024, this.bb = wo.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 = ov.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 the buffer.
   */
  addInt8(t) {
    this.prep(1, 0), this.writeInt8(t);
  }
  /**
   * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int16` to add the the buffer.
   */
  addInt16(t) {
    this.prep(2, 0), this.writeInt16(t);
  }
  /**
   * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int32` to add the the buffer.
   */
  addInt32(t) {
    this.prep(4, 0), this.writeInt32(t);
  }
  /**
   * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int64` to add the the buffer.
   */
  addInt64(t) {
    this.prep(8, 0), this.writeInt64(t);
  }
  /**
   * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float32` to add the the buffer.
   */
  addFloat32(t) {
    this.prep(4, 0), this.writeFloat32(t);
  }
  /**
   * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float64` to add the the buffer.
   */
  addFloat64(t) {
    this.prep(8, 0), this.writeFloat64(t);
  }
  addFieldInt8(t, n, 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.equals(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 Error("FlatBuffers: struct must be serialized inline.");
  }
  /**
   * Should not be creating any other object, string or vector
   * while an object is being constructed
   */
  notNested() {
    if (this.isNested)
      throw new Error("FlatBuffers: object serialization must not be nested.");
  }
  /**
   * Set the current vtable at `voffset` to the current location in the buffer.
   */
  slot(t) {
    this.vtable !== null && (this.vtable[t] = this.offset());
  }
  /**
   * @returns Offset relative to the end of the buffer.
   */
  offset() {
    return this.bb.capacity() - this.space;
  }
  /**
   * Doubles the size of the backing ByteBuffer and copies the old data towards
   * the end of the new buffer (since we build the buffer backwards).
   *
   * @param bb The current buffer with the existing data
   * @returns A new byte buffer with the old data copied
   * to it. The data is located at the end of the buffer.
   *
   * uint8Array.set() formally takes {Array<number>|ArrayBufferView}, so to pass
   * it a uint8Array we need to suppress the type check:
   * @suppress {checkTypes}
   */
  static growByteBuffer(t) {
    const n = t.capacity();
    if (n & 3221225472)
      throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
    const r = n << 1, i = wo.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(Wn, 0), this.writeInt32(this.offset() - t + Wn);
  }
  /**
   * 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) * Zh;
    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 = Zh; u < s; u += Zh)
            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 ? Ut : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, Wn + Tr + i), s.length != Tr)
        throw new Error("FlatBuffers: file identifier must be length " + Tr);
      for (let o = Tr - 1; o >= 0; o--)
        this.writeInt8(s.charCodeAt(o));
    }
    this.prep(this.minalign, Wn + 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 (!(this.bb.readInt16(i + n) != 0))
      throw new Error("FlatBuffers: field " + n + " must be set");
  }
  /**
   * Start a new array/vector of objects.  Users usually will not call
   * this directly. The FlatBuffers compiler will create a start/end
   * method for vector types in generated code.
   *
   * @param elem_size The size of each element in the array
   * @param num_elems The number of elements in the array
   * @param alignment The alignment of the array
   */
  startVector(t, n, r) {
    this.notNested(), this.vector_num_elems = n, this.prep(Wn, 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)
      return 0;
    let n;
    if (t instanceof Uint8Array)
      n = t;
    else {
      n = [];
      let r = 0;
      for (; r < t.length; ) {
        let i;
        const s = t.charCodeAt(r++);
        if (s < 55296 || s >= 56320)
          i = s;
        else {
          const o = t.charCodeAt(r++);
          i = (s << 10) + o + (65536 - 56623104 - 56320);
        }
        i < 128 ? n.push(i) : (i < 2048 ? n.push(i >> 6 & 31 | 192) : (i < 65536 ? n.push(i >> 12 & 15 | 224) : n.push(i >> 18 & 7 | 240, i >> 12 & 63 | 128), n.push(i >> 6 & 63 | 128)), n.push(i & 63 | 128));
      }
    }
    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 avoid generated code depending on this file directly.
   */
  createLong(t, n) {
    return Br.create(t, n);
  }
  /**
   * A helper function to pack an object
   *
   * @returns offset of obj
   */
  createObjectOffset(t) {
    return t === null ? 0 : typeof t == "string" ? this.createString(t) : t.pack(this);
  }
  /**
   * A helper function to pack a list of object
   *
   * @returns list of offsets of each non null object
   */
  createObjectOffsetList(t) {
    const n = [];
    for (let r = 0; r < t.length; ++r) {
      const i = t[r];
      if (i !== null)
        n.push(this.createObjectOffset(i));
      else
        throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return n;
  }
  createStructOffsetList(t, n) {
    return n(this, t.length), this.createObjectOffsetList(t), this.endVector();
  }
};
class oe {
  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 oe()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + Ut), (n || new oe()).__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 oe.startKeyValue(t), oe.addKey(t, n), oe.addValue(t, r), oe.endKeyValue(t);
  }
}
var vo;
(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";
})(vo || (vo = {}));
var _o;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(_o || (_o = {}));
var ul;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(ul || (ul = {}));
class He {
  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 He()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + Ut), (n || new He()).__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 He.startInt(t), He.addBitWidth(t, n), He.addIsSigned(t, r), He.endInt(t);
  }
}
class Er {
  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 Er()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Er()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * The known dictionary id in the application where this data is used. In
   * the file or streaming formats, the dictionary ids are found in the
   * DictionaryBatch messages
   */
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : this.bb.createLong(0, 0);
  }
  /**
   * The dictionary indices are constrained to be non-negative integers. If
   * this field is null, the indices must be signed int32. To maximize
   * cross-language compatibility and performance, implementations are
   * recommended to prefer signed integer types over unsigned integer types
   * and to avoid uint64 indices unless they are required by an application.
   */
  indexType(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new He()).__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) : ul.DenseArray;
  }
  static startDictionaryEncoding(t) {
    t.startObject(4);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, t.createLong(0, 0));
  }
  static addIndexType(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsOrdered(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static addDictionaryKind(t, n) {
    t.addFieldInt16(3, n, ul.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}
class Ki {
  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 Ki()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Ki()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return Ki.startBinary(t), Ki.endBinary(t);
  }
}
class Ji {
  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 Ji()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Ji()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return Ji.startBool(t), Ji.endBool(t);
  }
}
var ll;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(ll || (ll = {}));
let Bu = class Ys {
  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 Ys()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Ys()).__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) : ll.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, ll.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return Ys.startDate(t), Ys.addUnit(t, n), Ys.endDate(t);
  }
};
class Re {
  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 Re()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Re()).__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 Re.startDecimal(t), Re.addPrecision(t, n), Re.addScale(t, r), Re.addBitWidth(t, i), Re.endDecimal(t);
  }
}
var xo;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(xo || (xo = {}));
class Xn {
  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 Xn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Xn()).__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 Xn.startFixedSizeBinary(t), Xn.addByteWidth(t, n), Xn.endFixedSizeBinary(t);
  }
}
class Gn {
  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 Gn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Gn()).__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 Gn.startFixedSizeList(t), Gn.addListSize(t, n), Gn.endFixedSizeList(t);
  }
}
var fl;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(fl || (fl = {}));
class Hn {
  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 Hn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Hn()).__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) : fl.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, fl.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return Hn.startFloatingPoint(t), Hn.addPrecision(t, n), Hn.endFloatingPoint(t);
  }
}
var hl;
(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";
})(hl || (hl = {}));
class Zn {
  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 Zn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Zn()).__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.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, hl.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return Zn.startInterval(t), Zn.addUnit(t, n), Zn.endInterval(t);
  }
}
class Qi {
  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 Qi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Qi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return Qi.startList(t), Qi.endList(t);
  }
}
let Ru = class Ws {
  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 Ws()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Ws()).__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 Ws.startMap(t), Ws.addKeysSorted(t, n), Ws.endMap(t);
  }
};
class ts {
  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 ts()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + Ut), (n || new ts()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return ts.startNull(t), ts.endNull(t);
  }
}
class es {
  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 es()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + Ut), (n || new es()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return es.startStruct_(t), es.endStruct_(t);
  }
}
class un {
  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 un()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + Ut), (n || new un()).__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) : xo.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, xo.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, r) {
    return un.startTime(t), un.addUnit(t, n), un.addBitWidth(t, r), un.endTime(t);
  }
}
class ln {
  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 ln()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + Ut), (n || new ln()).__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) : xo.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, xo.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, r) {
    return ln.startTimestamp(t), ln.addUnit(t, n), ln.addTimezone(t, r), ln.endTimestamp(t);
  }
}
var dl;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(dl || (dl = {}));
class Ce {
  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 Ce()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Ce()).__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) : dl.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, dl.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 Ce.startUnion(t), Ce.addMode(t, n), Ce.addTypeIds(t, r), Ce.endUnion(t);
  }
}
class ns {
  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 ns()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + Ut), (n || new ns()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return ns.startUtf8(t), ns.endUtf8(t);
  }
}
var Kt;
(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";
})(Kt || (Kt = {}));
let an = class Cu {
  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 Cu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Cu()).__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) : Kt.NONE;
  }
  /**
   * This is the type of the decoded value if the field is dictionary encoded.
   */
  // @ts-ignore
  type(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  /**
   * Present only if the field is dictionary encoded.
   */
  dictionary(t) {
    const n = this.bb.__offset(this.bb_pos, 12);
    return n ? (t || new Er()).__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 Cu()).__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 oe()).__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, Kt.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 xr {
  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 xr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsSchema(t, n) {
    return t.setPosition(t.position() + Ut), (n || new xr()).__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) : _o.Little;
  }
  fields(t, n) {
    const r = this.bb.__offset(this.bb_pos, 6);
    return r ? (n || new an()).__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 oe()).__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) : this.bb.createLong(0, 0);
  }
  featuresLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startSchema(t) {
    t.startObject(4);
  }
  static addEndianness(t, n) {
    t.addFieldInt16(0, n, _o.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 xr.startSchema(t), xr.addEndianness(t, n), xr.addFields(t, r), xr.addCustomMetadata(t, i), xr.addFeatures(t, s), xr.endSchema(t);
  }
};
class Ge {
  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 Ge()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Ge()).__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) : vo.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 op()).__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 op()).__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 oe()).__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, vo.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 kt {
  constructor(t = [], n, r) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), r || (r = up(t)), this.dictionaries = r;
  }
  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 kt(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 kt(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof kt ? t[0] : Array.isArray(t[0]) ? new kt(t[0]) : new kt(t), r = [...this.fields], i = ru(ru(/* @__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: ru(ru(/* @__PURE__ */ new Map(), r[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = up(s, /* @__PURE__ */ new Map());
    return new kt([...r, ...s], i, new Map([...this.dictionaries, ...o]));
  }
}
kt.prototype.fields = null;
kt.prototype.metadata = null;
kt.prototype.dictionaries = null;
class Gt {
  constructor(t, n, r = !1, i) {
    this.name = t, this.type = n, this.nullable = r, this.metadata = i || /* @__PURE__ */ new Map();
  }
  /** @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 Gt(`${n}`, r, i, s);
  }
  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], Gt.new(n, r, i, s);
  }
}
Gt.prototype.type = null;
Gt.prototype.name = null;
Gt.prototype.nullable = null;
Gt.prototype.metadata = null;
function ru(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function up(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, r = e.length; ++n < r; ) {
    const s = e[n].type;
    if (mt.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 && up(s.children, t);
  }
  return t;
}
var Eg = Br, _A = sv, xA = wo;
class q0 {
  constructor(t, n = fn.V4, r, i) {
    this.schema = t, this.version = n, r && (this._recordBatches = r), i && (this._dictionaryBatches = i);
  }
  /** @nocollapse */
  static decode(t) {
    t = new xA(Ft(t));
    const n = Ge.getRootAsFooter(t), r = kt.decode(n.schema());
    return new SA(r, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new _A(), r = kt.encode(n, t.schema);
    Ge.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      So.encode(n, o);
    const i = n.endVector();
    Ge.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      So.encode(n, o);
    const s = n.endVector();
    return Ge.startFooter(n), Ge.addSchema(n, r), Ge.addVersion(n, fn.V4), Ge.addRecordBatches(n, i), Ge.addDictionaries(n, s), Ge.finishFooterBuffer(n, Ge.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  *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 SA extends q0 {
  constructor(t, n) {
    super(t, n.version()), this._footer = n;
  }
  get numRecordBatches() {
    return this._footer.recordBatchesLength();
  }
  get numDictionaries() {
    return this._footer.dictionariesLength();
  }
  getRecordBatch(t) {
    if (t >= 0 && t < this.numRecordBatches) {
      const n = this._footer.recordBatches(t);
      if (n)
        return So.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return So.decode(n);
    }
    return null;
  }
}
class So {
  constructor(t, n, r) {
    this.metaDataLength = t, this.offset = typeof r == "number" ? r : r.low, this.bodyLength = typeof n == "number" ? n : n.low;
  }
  /** @nocollapse */
  static decode(t) {
    return new So(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: r } = n, i = new Eg(n.offset, 0), s = new Eg(n.bodyLength, 0);
    return op.createBlock(t, i, r, s);
  }
}
const Jt = Object.freeze({ done: !0, value: void 0 });
class Ng {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}
class av {
  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 MA extends av {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return ct(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(Jt);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return cn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return cn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return ct(this, void 0, void 0, function* () {
      return yield this.abort(t), Jt;
    });
  }
  return(t) {
    return ct(this, void 0, void 0, function* () {
      return yield this.close(), Jt;
    });
  }
  read(t) {
    return ct(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return ct(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(Jt);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}
class $A extends MA {
  write(t) {
    if ((t = Ft(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? tp(this.toUint8Array(!0)) : this.toUint8Array(!1).then(tp);
  }
  toUint8Array(t = !1) {
    return t ? sr(this._values)[0] : (() => ct(this, void 0, void 0, function* () {
      var n, r;
      const i = [];
      let s = 0;
      try {
        for (var o = Qs(this), a; a = yield o.next(), !a.done; ) {
          const c = a.value;
          i.push(c), s += c.byteLength;
        }
      } catch (c) {
        n = { error: c };
      } finally {
        try {
          a && !a.done && (r = o.return) && (yield r.call(o));
        } finally {
          if (n)
            throw n.error;
        }
      }
      return sr(i, s)[0];
    }))();
  }
}
class pl {
  constructor(t) {
    t && (this.source = new AA(cn.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 Mo {
  constructor(t) {
    t instanceof Mo ? this.source = t.source : t instanceof $A ? this.source = new qi(cn.fromAsyncIterable(t)) : jw(t) ? this.source = new qi(cn.fromNodeStream(t)) : L0(t) ? this.source = new qi(cn.fromDOMStream(t)) : zw(t) ? this.source = new qi(cn.fromDOMStream(t.body)) : Df(t) ? this.source = new qi(cn.fromIterable(t)) : Va(t) ? this.source = new qi(cn.fromAsyncIterable(t)) : N0(t) && (this.source = new qi(cn.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 AA {
  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) || Jt);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || Jt);
  }
}
class qi {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return ct(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return ct(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return ct(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return ct(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return ct(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || Jt;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return ct(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || Jt;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}
class Lg extends pl {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Ft(t), this.size = typeof n > "u" ? 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 yl extends Mo {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = (() => ct(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    }))();
  }
  readInt32(t) {
    return ct(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 ct(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 ct(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 ct(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 ct(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return ct(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return ct(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
}
const IA = 65536;
function Hs(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const $o = 8, V0 = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
class cv {
  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 ? IA : 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 `${Hs(this.buffer[1])} ${Hs(this.buffer[0])}`;
  }
}
class Bt extends cv {
  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 = $o < r - s ? $o : r - s, a = new Bt(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Bt(new Uint32Array([V0[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 ke extends cv {
  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 ke.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return ke.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const r = t.startsWith("-"), i = t.length, s = new ke(n);
    for (let o = r ? 1 : 0; o < i; ) {
      const a = $o < i - o ? $o : i - o, c = new ke(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), u = new ke(new Uint32Array([V0[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; )
      ke.from(t[r], new Uint32Array(n.buffer, n.byteOffset + 2 * r * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new ke(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new ke(new Uint32Array(t.buffer)).plus(n);
  }
}
class qn {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new ke(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new ke(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 h = new Bt(new Uint32Array([l.high(), 0]));
    return l = Bt.multiply(i, u), h.plus(l), l = Bt.multiply(s, c), h.plus(l), this.buffer[1] = h.low(), this.buffer[3] = h.lessThan(l) ? 1 : 0, this.buffer[2] = h.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 `${Hs(this.buffer[3])} ${Hs(this.buffer[2])} ${Hs(this.buffer[1])} ${Hs(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new qn(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new qn(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return qn.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return qn.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const r = t.startsWith("-"), i = t.length, s = new qn(n);
    for (let o = r ? 1 : 0; o < i; ) {
      const a = $o < i - o ? $o : i - o, c = new qn(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), u = new qn(new Uint32Array([V0[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; )
      qn.from(t[r], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * r, 4));
    return n;
  }
}
class uv extends It {
  constructor(t, n, r, i) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = r, this.dictionaries = i;
  }
  visit(t) {
    return super.visit(t instanceof Gt ? 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) {
    return t.mode === En.Sparse ? this.visitSparseUnion(t) : this.visitDenseUnion(t);
  }
  visitDenseUnion(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return $t({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, 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, nullBitmap: this.readNullBitmap(t, 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) });
  }
  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 TA extends uv {
  constructor(t, n, r, i) {
    super(new Uint8Array(0), n, r, i), this.sources = t;
  }
  readNullBitmap(t, n, { offset: r } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : ip(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 mt.isTimestamp(t) || (mt.isInt(t) || mt.isTime(t)) && t.bitWidth === 64 || mt.isDate(t) && t.unit === jr.MILLISECOND ? Pt(Uint8Array, ke.convertArray(r[n])) : mt.isDecimal(t) ? Pt(Uint8Array, qn.convertArray(r[n])) : mt.isBinary(t) || mt.isFixedSizeBinary(t) ? EA(r[n]) : mt.isBool(t) ? ip(r[n]) : mt.isUtf8(t) ? E0(r[n].join("")) : Pt(Uint8Array, Pt(t.ArrayType, r[n].map((i) => +i)));
  }
}
function EA(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 ht extends It {
  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 Ye(e, t) {
  return t instanceof e.constructor;
}
function vc(e, t) {
  return e === t || Ye(e, t);
}
function Kr(e, t) {
  return e === t || Ye(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function Ff(e, t) {
  return e === t || Ye(e, t) && e.precision === t.precision;
}
function NA(e, t) {
  return e === t || Ye(e, t) && e.byteWidth === t.byteWidth;
}
function Y0(e, t) {
  return e === t || Ye(e, t) && e.unit === t.unit;
}
function _c(e, t) {
  return e === t || Ye(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function xc(e, t) {
  return e === t || Ye(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function LA(e, t) {
  return e === t || Ye(e, t) && e.children.length === t.children.length && _i.compareManyFields(e.children, t.children);
}
function DA(e, t) {
  return e === t || Ye(e, t) && e.children.length === t.children.length && _i.compareManyFields(e.children, t.children);
}
function W0(e, t) {
  return e === t || Ye(e, t) && e.mode === t.mode && e.typeIds.every((n, r) => n === t.typeIds[r]) && _i.compareManyFields(e.children, t.children);
}
function OA(e, t) {
  return e === t || Ye(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && _i.visit(e.indices, t.indices) && _i.visit(e.dictionary, t.dictionary);
}
function X0(e, t) {
  return e === t || Ye(e, t) && e.unit === t.unit;
}
function FA(e, t) {
  return e === t || Ye(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && _i.compareManyFields(e.children, t.children);
}
function kA(e, t) {
  return e === t || Ye(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && _i.compareManyFields(e.children, t.children);
}
ht.prototype.visitNull = vc;
ht.prototype.visitBool = vc;
ht.prototype.visitInt = Kr;
ht.prototype.visitInt8 = Kr;
ht.prototype.visitInt16 = Kr;
ht.prototype.visitInt32 = Kr;
ht.prototype.visitInt64 = Kr;
ht.prototype.visitUint8 = Kr;
ht.prototype.visitUint16 = Kr;
ht.prototype.visitUint32 = Kr;
ht.prototype.visitUint64 = Kr;
ht.prototype.visitFloat = Ff;
ht.prototype.visitFloat16 = Ff;
ht.prototype.visitFloat32 = Ff;
ht.prototype.visitFloat64 = Ff;
ht.prototype.visitUtf8 = vc;
ht.prototype.visitBinary = vc;
ht.prototype.visitFixedSizeBinary = NA;
ht.prototype.visitDate = Y0;
ht.prototype.visitDateDay = Y0;
ht.prototype.visitDateMillisecond = Y0;
ht.prototype.visitTimestamp = _c;
ht.prototype.visitTimestampSecond = _c;
ht.prototype.visitTimestampMillisecond = _c;
ht.prototype.visitTimestampMicrosecond = _c;
ht.prototype.visitTimestampNanosecond = _c;
ht.prototype.visitTime = xc;
ht.prototype.visitTimeSecond = xc;
ht.prototype.visitTimeMillisecond = xc;
ht.prototype.visitTimeMicrosecond = xc;
ht.prototype.visitTimeNanosecond = xc;
ht.prototype.visitDecimal = vc;
ht.prototype.visitList = LA;
ht.prototype.visitStruct = DA;
ht.prototype.visitUnion = W0;
ht.prototype.visitDenseUnion = W0;
ht.prototype.visitSparseUnion = W0;
ht.prototype.visitDictionary = OA;
ht.prototype.visitInterval = X0;
ht.prototype.visitIntervalDayTime = X0;
ht.prototype.visitIntervalYearMonth = X0;
ht.prototype.visitFixedSizeList = FA;
ht.prototype.visitMap = kA;
const _i = new ht();
function BA(e, t) {
  return _i.compareSchemas(e, t);
}
function Kh(e, t) {
  return RA(e, t.map((n) => n.data.concat()));
}
function RA(e, t) {
  const n = [...e.fields], r = [], i = { numBatches: t.reduce((h, f) => Math.max(h, f.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 = CA(n, o, l, t, i), o > 0 && (r[s++] = $t({
      type: new De(n),
      length: o,
      nullCount: 0,
      children: l.slice()
    })));
  }
  return [
    e = e.assign(n),
    r.map((h) => new xn(e, h))
  ];
}
function CA(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 h = e[a];
      e[a] = h.clone({ nullable: !0 }), n[a] = (s = u == null ? void 0 : u._changeLengthAndBackfillNullBitmap(t)) !== null && s !== void 0 ? s : $t({
        type: h.type,
        length: t,
        nullCount: t,
        nullBitmap: new Uint8Array(o)
      });
    }
  }
  return n;
}
var lv;
let Za = class Wi {
  constructor(...t) {
    var n, r;
    if (t.length === 0)
      return this.batches = [], this.schema = new kt([]), this._offsets = [0], this;
    let i, s;
    t[0] instanceof kt && (i = t.shift()), t[t.length - 1] instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof xn)
          return [c];
        if (c instanceof Wi)
          return c.batches;
        if (c instanceof Yt) {
          if (c.type instanceof De)
            return [new xn(new kt(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 re([c[d]])), h = new kt(u.map((d, p) => new Gt(String(d), l[p].type))), [, f] = Kh(h, l);
            return f.length === 0 ? [new xn(c)] : f;
          }
        }
      }
      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 kt([]), !(i instanceof kt))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof xn))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!BA(i, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = i, this.batches = a, this._offsets = s ?? G2(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 = X2(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 ? j0.visit(new re(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 Wi(n, r.map((i) => new xn(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] = Y2({ length: this.numRows }, t, n);
    const i = H2(this.data, this._offsets, t, n);
    return new Wi(r, i.map((s) => new xn(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 re(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 re([$t({ type: new wi(), 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] = Kh(r, a);
    }
    return new Wi(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 Wi(n, r);
  }
  assign(t) {
    const n = this.schema.fields, [r, i] = t.schema.fields.reduce((a, c, u) => {
      const [l, h] = a, f = n.findIndex((d) => d.name === c.name);
      return ~f ? h[f] = 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 Wi(...Kh(s, o));
  }
};
lv = Symbol.toStringTag;
Za[lv] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = io(U0), e.get = io(Ue.getVisitFn(B.Struct)), e.set = Z2(gn.getVisitFn(B.Struct)), e.indexOf = K2(al.getVisitFn(B.Struct)), e.getByteLength = io(or.getVisitFn(B.Struct)), "Table"))(Za.prototype);
var fv;
let xn = class Sa {
  constructor(...t) {
    switch (t.length) {
      case 2: {
        if ([this.schema] = t, !(this.schema instanceof kt))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = $t({
            nullCount: 0,
            type: new De(this.schema.fields),
            children: this.schema.fields.map((n) => $t({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof Yt))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = Dg(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] = Gt.new({ name: u, type: n[u].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new kt(r), a = $t({ type: new De(r), length: s, children: i, nullCount: 0 });
        [this.schema, this.data] = Dg(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 = hv(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 Ue.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 gn.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 al.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 or.visit(this.data, t);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return j0.visit(new re([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 Za(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 re([this.data]).slice(t, n).data;
    return new Sa(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 re([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 re([$t({ type: new wi(), 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 kt(s, new Map(this.schema.metadata)), i = $t({ type: new De(s), children: o });
    }
    return new Sa(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 De(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 Sa(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 De(n.fields), length: this.numRows, children: r });
    return new Sa(n, i);
  }
};
fv = Symbol.toStringTag;
xn[fv] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(xn.prototype);
function Dg(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 De(i), length: n, children: s })
  ];
}
function hv(e, t, n = /* @__PURE__ */ new Map()) {
  for (let r = -1, i = e.length; ++r < i; ) {
    const o = e[r].type, a = t[r];
    if (mt.isDictionary(o)) {
      if (!n.has(o.id))
        a.dictionary && n.set(o.id, a.dictionary);
      else if (n.get(o.id) !== a.dictionary)
        throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
    }
    o.children && o.children.length > 0 && hv(o.children, a.children, n);
  }
  return n;
}
class dv extends xn {
  constructor(t) {
    const n = t.fields.map((i) => $t({ type: i.type })), r = $t({ type: new De(t.fields), nullCount: 0, children: n });
    super(t, r);
  }
}
var ml;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(ml || (ml = {}));
var gl;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(gl || (gl = {}));
class oi {
  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 oi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + Ut), (n || new oi()).__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) : gl.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) : ml.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, gl.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, ml.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, r) {
    return oi.startBodyCompression(t), oi.addCodec(t, n), oi.addMethod(t, r), oi.endBodyCompression(t);
  }
}
class pv {
  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(r), t.writeInt64(n), t.offset();
  }
}
let yv = 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(r), t.writeInt64(n), t.offset();
  }
}, Ar = class lp {
  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 lp()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + Ut), (n || new lp()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * number of records / rows. The arrays in the batch should all have this
   * length
   */
  length() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : this.bb.createLong(0, 0);
  }
  /**
   * Nodes correspond to the pre-ordered flattened logical schema
   */
  nodes(t, n) {
    const r = this.bb.__offset(this.bb_pos, 6);
    return r ? (n || new yv()).__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 pv()).__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 oi()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  static startRecordBatch(t) {
    t.startObject(4);
  }
  static addLength(t, n) {
    t.addFieldInt64(0, n, t.createLong(0, 0));
  }
  static addNodes(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static startNodesVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addBuffers(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startBuffersVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addCompression(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static endRecordBatch(t) {
    return t.endObject();
  }
}, Xs = class fp {
  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 fp()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + Ut), (n || new fp()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : this.bb.createLong(0, 0);
  }
  data(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Ar()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * If isDelta is true the values in the dictionary are to be appended to a
   * dictionary with the indicated id. If isDelta is false this dictionary
   * should replace the existing dictionary.
   */
  isDelta() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startDictionaryBatch(t) {
    t.startObject(3);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, t.createLong(0, 0));
  }
  static addData(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsDelta(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static endDictionaryBatch(t) {
    return t.endObject();
  }
};
var bl;
(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";
})(bl || (bl = {}));
let ri = class Un {
  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 Un()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + Ut), (n || new Un()).__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) : vo.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : bl.NONE;
  }
  // @ts-ignore
  header(t) {
    const n = this.bb.__offset(this.bb_pos, 8);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  bodyLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.readInt64(this.bb_pos + t) : this.bb.createLong(0, 0);
  }
  customMetadata(t, n) {
    const r = this.bb.__offset(this.bb_pos, 12);
    return r ? (n || new oe()).__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, vo.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, bl.NONE);
  }
  static addHeader(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static addBodyLength(t, n) {
    t.addFieldInt64(3, n, t.createLong(0, 0));
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let 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 Un.startMessage(t), Un.addVersion(t, n), Un.addHeaderType(t, r), Un.addHeader(t, i), Un.addBodyLength(t, s), Un.addCustomMetadata(t, o), Un.endMessage(t);
  }
};
var PA = Br;
class zA extends It {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return ts.startNull(n), ts.endNull(n);
  }
  visitInt(t, n) {
    return He.startInt(n), He.addBitWidth(n, t.bitWidth), He.addIsSigned(n, t.isSigned), He.endInt(n);
  }
  visitFloat(t, n) {
    return Hn.startFloatingPoint(n), Hn.addPrecision(n, t.precision), Hn.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return Ki.startBinary(n), Ki.endBinary(n);
  }
  visitBool(t, n) {
    return Ji.startBool(n), Ji.endBool(n);
  }
  visitUtf8(t, n) {
    return ns.startUtf8(n), ns.endUtf8(n);
  }
  visitDecimal(t, n) {
    return Re.startDecimal(n), Re.addScale(n, t.scale), Re.addPrecision(n, t.precision), Re.addBitWidth(n, t.bitWidth), Re.endDecimal(n);
  }
  visitDate(t, n) {
    return Bu.startDate(n), Bu.addUnit(n, t.unit), Bu.endDate(n);
  }
  visitTime(t, n) {
    return un.startTime(n), un.addUnit(n, t.unit), un.addBitWidth(n, t.bitWidth), un.endTime(n);
  }
  visitTimestamp(t, n) {
    const r = t.timezone && n.createString(t.timezone) || void 0;
    return ln.startTimestamp(n), ln.addUnit(n, t.unit), r !== void 0 && ln.addTimezone(n, r), ln.endTimestamp(n);
  }
  visitInterval(t, n) {
    return Zn.startInterval(n), Zn.addUnit(n, t.unit), Zn.endInterval(n);
  }
  visitList(t, n) {
    return Qi.startList(n), Qi.endList(n);
  }
  visitStruct(t, n) {
    return es.startStruct_(n), es.endStruct_(n);
  }
  visitUnion(t, n) {
    Ce.startTypeIdsVector(n, t.typeIds.length);
    const r = Ce.createTypeIdsVector(n, t.typeIds);
    return Ce.startUnion(n), Ce.addMode(n, t.mode), Ce.addTypeIds(n, r), Ce.endUnion(n);
  }
  visitDictionary(t, n) {
    const r = this.visit(t.indices, n);
    return Er.startDictionaryEncoding(n), Er.addId(n, new PA(t.id, 0)), Er.addIsOrdered(n, t.isOrdered), r !== void 0 && Er.addIndexType(n, r), Er.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return Xn.startFixedSizeBinary(n), Xn.addByteWidth(n, t.byteWidth), Xn.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return Gn.startFixedSizeList(n), Gn.addListSize(n, t.listSize), Gn.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return Ru.startMap(n), Ru.addKeysSorted(n, t.keysSorted), Ru.endMap(n);
  }
}
const Jh = new zA();
function UA(e, t = /* @__PURE__ */ new Map()) {
  return new kt(qA(e, t), Pu(e.customMetadata), t);
}
function mv(e) {
  return new Nn(e.count, gv(e.columns), bv(e.columns));
}
function jA(e) {
  return new qr(mv(e.data), e.id, e.isDelta);
}
function qA(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => Gt.fromJSON(n, t));
}
function Og(e, t) {
  return (e.children || []).filter(Boolean).map((n) => Gt.fromJSON(n, t));
}
function gv(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new Wo(n.count, VA(n.VALIDITY)),
    ...gv(n.children)
  ], []);
}
function bv(e, t = []) {
  for (let n = -1, r = (e || []).length; ++n < r; ) {
    const i = e[n];
    i.VALIDITY && t.push(new Nr(t.length, i.VALIDITY.length)), i.TYPE && t.push(new Nr(t.length, i.TYPE.length)), i.OFFSET && t.push(new Nr(t.length, i.OFFSET.length)), i.DATA && t.push(new Nr(t.length, i.DATA.length)), t = bv(i.children, t);
  }
  return t;
}
function VA(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function YA(e, t) {
  let n, r, i, s, o, a;
  return !t || !(s = e.dictionary) ? (o = kg(e, Og(e, t)), i = new Gt(e.name, o, e.nullable, Pu(e.customMetadata))) : t.has(n = s.id) ? (r = (r = s.indexType) ? Fg(r) : new Xa(), a = new bo(t.get(n), r, n, s.isOrdered), i = new Gt(e.name, a, e.nullable, Pu(e.customMetadata))) : (r = (r = s.indexType) ? Fg(r) : new Xa(), t.set(n, o = kg(e, Og(e, t))), a = new bo(o, r, n, s.isOrdered), i = new Gt(e.name, a, e.nullable, Pu(e.customMetadata))), i || null;
}
function Pu(e) {
  return new Map(Object.entries(e || {}));
}
function Fg(e) {
  return new vi(e.isSigned, e.bitWidth);
}
function kg(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new wi();
    case "null":
      return new wi();
    case "binary":
      return new Hu();
    case "utf8":
      return new Zu();
    case "bool":
      return new Ku();
    case "list":
      return new nl((t || [])[0]);
    case "struct":
      return new De(t || []);
    case "struct_":
      return new De(t || []);
  }
  switch (n) {
    case "int": {
      const r = e.type;
      return new vi(r.isSigned, r.bitWidth);
    }
    case "floatingpoint": {
      const r = e.type;
      return new Ga(ze[r.precision]);
    }
    case "decimal": {
      const r = e.type;
      return new Ju(r.scale, r.precision, r.bitWidth);
    }
    case "date": {
      const r = e.type;
      return new Qu(jr[r.unit]);
    }
    case "time": {
      const r = e.type;
      return new Ha(Nt[r.unit], r.bitWidth);
    }
    case "timestamp": {
      const r = e.type;
      return new tl(Nt[r.unit], r.timezone);
    }
    case "interval": {
      const r = e.type;
      return new el(bi[r.unit]);
    }
    case "union": {
      const r = e.type;
      return new rl(En[r.mode], r.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const r = e.type;
      return new il(r.byteWidth);
    }
    case "fixedsizelist": {
      const r = e.type;
      return new sl(r.listSize, (t || [])[0]);
    }
    case "map": {
      const r = e.type;
      return new ol((t || [])[0], r.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var ds = Br, WA = sv, XA = wo;
class Sn {
  constructor(t, n, r, i) {
    this._version = n, this._headerType = r, this.body = new Uint8Array(0), i && (this._createHeader = () => i), this._bodyLength = typeof t == "number" ? t : t.low;
  }
  /** @nocollapse */
  static fromJSON(t, n) {
    const r = new Sn(0, fn.V4, n);
    return r._createHeader = GA(t, n), r;
  }
  /** @nocollapse */
  static decode(t) {
    t = new XA(Ft(t));
    const n = ri.getRootAsMessage(t), r = n.bodyLength(), i = n.version(), s = n.headerType(), o = new Sn(r, i, s);
    return o._createHeader = HA(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new WA();
    let r = -1;
    return t.isSchema() ? r = kt.encode(n, t.header()) : t.isRecordBatch() ? r = Nn.encode(n, t.header()) : t.isDictionaryBatch() && (r = qr.encode(n, t.header())), ri.startMessage(n), ri.addVersion(n, fn.V4), ri.addHeader(n, r), ri.addHeaderType(n, t.headerType), ri.addBodyLength(n, new ds(t.bodyLength, 0)), ri.finishMessageBuffer(n, ri.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof kt)
      return new Sn(0, fn.V4, Rt.Schema, t);
    if (t instanceof Nn)
      return new Sn(n, fn.V4, Rt.RecordBatch, t);
    if (t instanceof qr)
      return new Sn(n, fn.V4, Rt.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 === Rt.Schema;
  }
  isRecordBatch() {
    return this.headerType === Rt.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === Rt.DictionaryBatch;
  }
}
class Nn {
  constructor(t, n, r) {
    this._nodes = n, this._buffers = r, this._length = typeof t == "number" ? t : t.low;
  }
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
}
class qr {
  constructor(t, n, r = !1) {
    this._data = t, this._isDelta = r, this._id = typeof n == "number" ? n : n.low;
  }
  get id() {
    return this._id;
  }
  get data() {
    return this._data;
  }
  get isDelta() {
    return this._isDelta;
  }
  get length() {
    return this.data.length;
  }
  get nodes() {
    return this.data.nodes;
  }
  get buffers() {
    return this.data.buffers;
  }
}
class Nr {
  constructor(t, n) {
    this.offset = typeof t == "number" ? t : t.low, this.length = typeof n == "number" ? n : n.low;
  }
}
class Wo {
  constructor(t, n) {
    this.length = typeof t == "number" ? t : t.low, this.nullCount = typeof n == "number" ? n : n.low;
  }
}
function GA(e, t) {
  return () => {
    switch (t) {
      case Rt.Schema:
        return kt.fromJSON(e);
      case Rt.RecordBatch:
        return Nn.fromJSON(e);
      case Rt.DictionaryBatch:
        return qr.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Rt[t]}, type: ${t} }`);
  };
}
function HA(e, t) {
  return () => {
    switch (t) {
      case Rt.Schema:
        return kt.decode(e.header(new jn()));
      case Rt.RecordBatch:
        return Nn.decode(e.header(new Ar()), e.version());
      case Rt.DictionaryBatch:
        return qr.decode(e.header(new Xs()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Rt[t]}, type: ${t} }`);
  };
}
Gt.encode = o5;
Gt.decode = i5;
Gt.fromJSON = YA;
kt.encode = s5;
kt.decode = ZA;
kt.fromJSON = UA;
Nn.encode = a5;
Nn.decode = KA;
Nn.fromJSON = mv;
qr.encode = c5;
qr.decode = JA;
qr.fromJSON = jA;
Wo.encode = u5;
Wo.decode = t5;
Nr.encode = l5;
Nr.decode = QA;
function ZA(e, t = /* @__PURE__ */ new Map()) {
  const n = r5(e, t);
  return new kt(n, zu(e), t);
}
function KA(e, t = fn.V4) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new Nn(e.length(), e5(e), n5(e, t));
}
function JA(e, t = fn.V4) {
  return new qr(Nn.decode(e.data(), t), e.id(), e.isDelta());
}
function QA(e) {
  return new Nr(e.offset(), e.length());
}
function t5(e) {
  return new Wo(e.length(), e.nullCount());
}
function e5(e) {
  const t = [];
  for (let n, r = -1, i = -1, s = e.nodesLength(); ++r < s; )
    (n = e.nodes(r)) && (t[++i] = Wo.decode(n));
  return t;
}
function n5(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.buffersLength(); ++i < o; )
    (r = e.buffers(i)) && (t < fn.V4 && (r.bb_pos += 8 * (i + 1)), n[++s] = Nr.decode(r));
  return n;
}
function r5(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.fieldsLength(); ++i < o; )
    (r = e.fields(i)) && (n[++s] = Gt.decode(r, t));
  return n;
}
function Bg(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.childrenLength(); ++i < o; )
    (r = e.children(i)) && (n[++s] = Gt.decode(r, t));
  return n;
}
function i5(e, t) {
  let n, r, i, s, o, a;
  return !t || !(a = e.dictionary()) ? (i = Cg(e, Bg(e, t)), r = new Gt(e.name(), i, e.nullable(), zu(e))) : t.has(n = a.id().low) ? (s = (s = a.indexType()) ? Rg(s) : new Xa(), o = new bo(t.get(n), s, n, a.isOrdered()), r = new Gt(e.name(), o, e.nullable(), zu(e))) : (s = (s = a.indexType()) ? Rg(s) : new Xa(), t.set(n, i = Cg(e, Bg(e, t))), o = new bo(i, s, n, a.isOrdered()), r = new Gt(e.name(), o, e.nullable(), zu(e))), r || null;
}
function zu(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 Rg(e) {
  return new vi(e.isSigned(), e.bitWidth());
}
function Cg(e, t) {
  const n = e.typeType();
  switch (n) {
    case Kt.NONE:
      return new wi();
    case Kt.Null:
      return new wi();
    case Kt.Binary:
      return new Hu();
    case Kt.Utf8:
      return new Zu();
    case Kt.Bool:
      return new Ku();
    case Kt.List:
      return new nl((t || [])[0]);
    case Kt.Struct_:
      return new De(t || []);
  }
  switch (n) {
    case Kt.Int: {
      const r = e.type(new He());
      return new vi(r.isSigned(), r.bitWidth());
    }
    case Kt.FloatingPoint: {
      const r = e.type(new Hn());
      return new Ga(r.precision());
    }
    case Kt.Decimal: {
      const r = e.type(new Re());
      return new Ju(r.scale(), r.precision(), r.bitWidth());
    }
    case Kt.Date: {
      const r = e.type(new Bu());
      return new Qu(r.unit());
    }
    case Kt.Time: {
      const r = e.type(new un());
      return new Ha(r.unit(), r.bitWidth());
    }
    case Kt.Timestamp: {
      const r = e.type(new ln());
      return new tl(r.unit(), r.timezone());
    }
    case Kt.Interval: {
      const r = e.type(new Zn());
      return new el(r.unit());
    }
    case Kt.Union: {
      const r = e.type(new Ce());
      return new rl(r.mode(), r.typeIdsArray() || [], t || []);
    }
    case Kt.FixedSizeBinary: {
      const r = e.type(new Xn());
      return new il(r.byteWidth());
    }
    case Kt.FixedSizeList: {
      const r = e.type(new Gn());
      return new sl(r.listSize(), (t || [])[0]);
    }
    case Kt.Map: {
      const r = e.type(new Ru());
      return new ol((t || [])[0], r.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${Kt[n]}" (${n})`);
}
function s5(e, t) {
  const n = t.fields.map((s) => Gt.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 oe.startKeyValue(e), oe.addKey(e, a), oe.addValue(e, c), oe.endKeyValue(e);
  })) : -1;
  return jn.startSchema(e), jn.addFields(e, r), jn.addEndianness(e, f5 ? _o.Little : _o.Big), i !== -1 && jn.addCustomMetadata(e, i), jn.endSchema(e);
}
function o5(e, t) {
  let n = -1, r = -1, i = -1;
  const s = t.type;
  let o = t.typeId;
  mt.isDictionary(s) ? (o = s.dictionary.typeId, i = Jh.visit(s, e), r = Jh.visit(s.dictionary, e)) : r = Jh.visit(s, e);
  const a = (s.children || []).map((l) => Gt.encode(e, l)), c = an.createChildrenVector(e, a), u = t.metadata && t.metadata.size > 0 ? an.createCustomMetadataVector(e, [...t.metadata].map(([l, h]) => {
    const f = e.createString(`${l}`), d = e.createString(`${h}`);
    return oe.startKeyValue(e), oe.addKey(e, f), oe.addValue(e, d), oe.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), an.startField(e), an.addType(e, r), an.addTypeType(e, o), an.addChildren(e, c), an.addNullable(e, !!t.nullable), n !== -1 && an.addName(e, n), i !== -1 && an.addDictionary(e, i), u !== -1 && an.addCustomMetadata(e, u), an.endField(e);
}
function a5(e, t) {
  const n = t.nodes || [], r = t.buffers || [];
  Ar.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    Wo.encode(e, o);
  const i = e.endVector();
  Ar.startBuffersVector(e, r.length);
  for (const o of r.slice().reverse())
    Nr.encode(e, o);
  const s = e.endVector();
  return Ar.startRecordBatch(e), Ar.addLength(e, new ds(t.length, 0)), Ar.addNodes(e, i), Ar.addBuffers(e, s), Ar.endRecordBatch(e);
}
function c5(e, t) {
  const n = Nn.encode(e, t.data);
  return Xs.startDictionaryBatch(e), Xs.addId(e, new ds(t.id, 0)), Xs.addIsDelta(e, t.isDelta), Xs.addData(e, n), Xs.endDictionaryBatch(e);
}
function u5(e, t) {
  return yv.createFieldNode(e, new ds(t.length, 0), new ds(t.nullCount, 0));
}
function l5(e, t) {
  return pv.createBuffer(e, new ds(t.offset, 0), new ds(t.length, 0));
}
const f5 = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), G0 = (e) => `Expected ${Rt[e]} Message in stream, but was null or length 0.`, H0 = (e) => `Header pointer of flatbuffer-encoded ${Rt[e]} Message is null or length 0.`, wv = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, vv = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
class _v {
  constructor(t) {
    this.source = t instanceof pl ? t : new pl(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 ? Jt : 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(G0(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(vv(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 = Rt.Schema, r = this.readMessage(n), i = r == null ? void 0 : r.header();
    if (t && !i)
      throw new Error(H0(n));
    return i;
  }
  readMetadataLength() {
    const t = this.source.read(kf), n = t && new wo(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 Jt;
    if (n.byteLength < t)
      throw new Error(wv(t, n.byteLength));
    return { done: !1, value: Sn.decode(n) };
  }
}
class h5 {
  constructor(t, n) {
    this.source = t instanceof Mo ? t : Pw(t) ? new yl(t, n) : new Mo(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return ct(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 ? Jt : t;
    });
  }
  throw(t) {
    return ct(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return ct(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return ct(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(G0(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return ct(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(vv(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return ct(this, void 0, void 0, function* () {
      const n = Rt.Schema, r = yield this.readMessage(n), i = r == null ? void 0 : r.header();
      if (t && !i)
        throw new Error(H0(n));
      return i;
    });
  }
  readMetadataLength() {
    return ct(this, void 0, void 0, function* () {
      const t = yield this.source.read(kf), n = t && new wo(t), r = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: r === 0, value: r };
    });
  }
  readMetadata(t) {
    return ct(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return Jt;
      if (n.byteLength < t)
        throw new Error(wv(t, n.byteLength));
      return { done: !1, value: Sn.decode(n) };
    });
  }
}
class d5 extends _v {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof Ng ? t : new Ng(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: Sn.fromJSON(t.schema, Rt.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: Sn.fromJSON(n, Rt.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: Sn.fromJSON(n, Rt.RecordBatch) };
    }
    return this._body = [], Jt;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(r) {
      return (r || []).reduce((i, s) => [
        ...i,
        ...s.VALIDITY && [s.VALIDITY] || [],
        ...s.TYPE && [s.TYPE] || [],
        ...s.OFFSET && [s.OFFSET] || [],
        ...s.DATA && [s.DATA] || [],
        ...n(s.children)
      ], []);
    }
  }
  readMessage(t) {
    let n;
    if ((n = this.next()).done)
      return null;
    if (t != null && n.value.headerType !== t)
      throw new Error(G0(t));
    return n.value;
  }
  readSchema() {
    const t = Rt.Schema, n = this.readMessage(t), r = n == null ? void 0 : n.header();
    if (!n || !r)
      throw new Error(H0(t));
    return r;
  }
}
const kf = 4, hp = "ARROW1", wl = new Uint8Array(hp.length);
for (let e = 0; e < hp.length; e += 1)
  wl[e] = hp.codePointAt(e);
function Z0(e, t = 0) {
  for (let n = -1, r = wl.length; ++n < r; )
    if (wl[n] !== e[t + n])
      return !1;
  return !0;
}
const Sc = wl.length, xv = Sc + kf, p5 = Sc * 2 + kf;
class Rr extends av {
  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 Va(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 cn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return cn.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 Rr ? t : ep(t) ? b5(t) : Pw(t) ? _5(t) : Va(t) ? (() => ct(this, void 0, void 0, function* () {
      return yield Rr.from(yield t);
    }))() : zw(t) || L0(t) || jw(t) || N0(t) ? v5(new Mo(t)) : w5(new pl(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof Rr ? t.isSync() ? Pg(t) : zg(t) : ep(t) || ArrayBuffer.isView(t) || Df(t) || Cw(t) ? Pg(t) : zg(t);
  }
}
class vl extends Rr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return Qn(this, arguments, function* () {
      yield bt(yield* ku(Qs(this[Symbol.iterator]())));
    });
  }
}
class _l extends Rr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n;
    return ct(this, void 0, void 0, function* () {
      const r = new Array();
      try {
        for (var i = Qs(this), s; s = yield i.next(), !s.done; ) {
          const o = s.value;
          r.push(o);
        }
      } catch (o) {
        t = { error: o };
      } finally {
        try {
          s && !s.done && (n = i.return) && (yield n.call(i));
        } finally {
          if (t)
            throw t.error;
        }
      }
      return r;
    });
  }
  [Symbol.iterator]() {
    throw new Error("AsyncRecordBatchStreamReader is not Iterable");
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
}
class Sv extends vl {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class y5 extends _l {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class Mv {
  constructor(t = /* @__PURE__ */ new Map()) {
    this.closed = !1, this.autoDestroy = !0, this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.dictionaries = t;
  }
  get numDictionaries() {
    return this._dictionaryIndex;
  }
  get numRecordBatches() {
    return this._recordBatchIndex;
  }
  isSync() {
    return !1;
  }
  isAsync() {
    return !1;
  }
  isFile() {
    return !1;
  }
  isStream() {
    return !1;
  }
  reset(t) {
    return this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.schema = t, this.dictionaries = /* @__PURE__ */ new Map(), this;
  }
  _loadRecordBatch(t, n) {
    const r = this._loadVectors(t, n, this.schema.fields), i = $t({ type: new De(this.schema.fields), length: t.length, children: r });
    return new xn(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 re(u)) : new re(u)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, r) {
    return new uv(n, t.nodes, t.buffers, this.dictionaries).visitMany(r);
  }
}
class xl extends Mv {
  constructor(t, n) {
    super(n), this._reader = ep(t) ? new d5(this._handle = t) : new _v(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 = Av(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) : Jt;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : Jt;
  }
  next() {
    if (this.closed)
      return Jt;
    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 dv(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}
class Sl extends Mv {
  constructor(t, n) {
    super(n), this._reader = new h5(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return ct(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 ct(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = Av(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return ct(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : Jt;
    });
  }
  return(t) {
    return ct(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : Jt;
    });
  }
  next() {
    return ct(this, void 0, void 0, function* () {
      if (this.closed)
        return Jt;
      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 dv(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return ct(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}
class $v extends xl {
  constructor(t, n) {
    super(t instanceof Lg ? t : new Lg(t), n);
  }
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  isSync() {
    return !0;
  }
  isFile() {
    return !0;
  }
  open(t) {
    if (!this.closed && !this._footer) {
      this.schema = (this._footer = this._readFooter()).schema;
      for (const n of this._footer.dictionaryBatches())
        n && this._readDictionaryBatch(this._dictionaryIndex++);
    }
    return super.open(t);
  }
  readRecordBatch(t) {
    var n;
    if (this.closed)
      return null;
    this._footer || this.open();
    const 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(Rt.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(Rt.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 - xv, r = t.readInt32(n), i = t.readAt(n - r, r);
    return q0.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 m5 extends Sl {
  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 yl ? t : new yl(t, r), i);
  }
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return ct(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 ct(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(Rt.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 ct(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(Rt.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 ct(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - xv, r = yield t.readInt32(n), i = yield t.readAt(n - r, r);
      return q0.decode(i);
    });
  }
  _readNextMessageAndValidate(t) {
    return ct(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 g5 extends xl {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, r) {
    return new TA(n, t.nodes, t.buffers, this.dictionaries).visitMany(r);
  }
}
function Av(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* Pg(e) {
  const t = Rr.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function zg(e) {
  return Qn(this, arguments, function* () {
    const n = yield bt(Rr.from(e));
    try {
      if (!(yield bt(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield bt(n);
        while (!(yield bt(n.reset().open())).closed);
    } finally {
      yield bt(n.cancel());
    }
  });
}
function b5(e) {
  return new vl(new g5(e));
}
function w5(e) {
  const t = e.peek(Sc + 7 & -8);
  return t && t.byteLength >= 4 ? Z0(t) ? new Sv(new $v(e.read())) : new vl(new xl(e)) : new vl(new xl(function* () {
  }()));
}
function v5(e) {
  return ct(this, void 0, void 0, function* () {
    const t = yield e.peek(Sc + 7 & -8);
    return t && t.byteLength >= 4 ? Z0(t) ? new Sv(new $v(yield e.read())) : new _l(new Sl(e)) : new _l(new Sl(function() {
      return Qn(this, arguments, function* () {
      });
    }()));
  });
}
function _5(e) {
  return ct(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new yl(e, t);
    return t >= p5 && Z0(yield n.readAt(0, Sc + 7 & -8)) ? new y5(new m5(n)) : new _l(new Sl(n));
  });
}
function K0(e) {
  const t = Rr.from(e);
  return Va(t) ? t.then((n) => K0(n)) : t.isAsync() ? t.readAll().then((n) => new Za(n)) : new Za(t.readAll());
}
function x5(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: h, reject: f } = r;
        if (r = null, c(), typeof u == "string") {
          const d = JSON.parse(u);
          d.error ? f(d.error) : h(d);
        } else if (l.type === "exec")
          h();
        else if (l.type === "arrow")
          h(K0(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, h) {
    i == null && o(), t.push({ query: u, resolve: l, reject: h }), 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, h) => a(u, l, h)
      );
    }
  };
}
function S5(e) {
  switch (e) {
    case "BIGINT":
    case "HUGEINT":
    case "INTEGER":
    case "SMALLINT":
    case "TINYINT":
    case "UBIGINT":
    case "UINTEGER":
    case "USMALLINT":
    case "UTINYINT":
    case "DOUBLE":
    case "FLOAT":
    case "REAL":
    case "DECIMAL":
      return "number";
    case "DATE":
    case "TIMESTAMP":
    case "TIMESTAMPTZ":
    case "TIME":
      return "date";
    case "BOOLEAN":
      return "boolean";
    case "VARCHAR":
    case "UUID":
      return "string";
    case "LIST":
      return "array";
    case "BLOB":
    case "STRUCT":
    case "MAP":
      return "object";
    default:
      throw new Error(`Unsupported type: ${e}`);
  }
}
class xi {
  /**
   * 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 ? `"${t}".` : ""}${r}`;
    } else
      return t ? `"${t}"` : "NULL";
  }
}
function M5(e, t) {
  return e instanceof xi && e.column === t;
}
function Wt(e) {
  return typeof e == "string" ? J0(e) : e;
}
function Qh(e) {
  return typeof e == "string" ? $5(e) : e;
}
function $5(e) {
  return new xi(e);
}
function J0(e, t) {
  return arguments.length === 1 && (t = e, e = null), new xi(e, t);
}
function Mc(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 Ao = (e) => typeof (e == null ? void 0 : e.addEventListener) == "function";
function Iv(e) {
  return e instanceof Bf;
}
class Bf {
  /**
   * 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) => Ao(s));
    i.length > 0 ? (this._params = Array.from(new Set(i)), this._params.forEach((s) => {
      s.addEventListener("value", () => {
        var o;
        return A5(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) => Ao(t) && !Iv(t) ? Mc(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 A5(e, t) {
  if (t != null && t.size)
    return Promise.allSettled(Array.from(t, (n) => n(e)));
}
function Tv(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];
    Ao(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 : Mc(a));
    const c = e[++s];
    Ao(n[o]) ? n[++o] = c : n[o] += c;
  }
  return { spans: n, cols: Array.from(r) };
}
function q(e, ...t) {
  const { spans: n, cols: r } = Tv(e, t);
  return new Bf(n, r);
}
function I5(e) {
  const t = Wt(e);
  return q`${t} DESC NULLS LAST`.annotate({ label: t == null ? void 0 : t.label, desc: !0 });
}
const $c = (e) => ({
  value: e,
  toString: () => Mc(e)
});
function Rf(e) {
  var t;
  e(this.op, this), (t = this.children) == null || t.forEach((n) => n.visit(e));
}
function Ev(e, t) {
  const n = t.filter((i) => i != null).map(Wt), r = n.map((i, s) => s ? ` ${e} ` : "");
  return t.length && r.push(""), q(r, ...n).annotate({ op: e, children: n, visit: Rf });
}
const ps = (...e) => Ev("AND", e.flat()), Nv = (...e) => Ev("OR", e.flat()), Lv = (e) => (t) => q`(${Wt(t)} ${e})`.annotate({ op: e, a: t, visit: Rf }), Dv = Lv("IS NULL"), Ml = Lv("IS NOT NULL"), Ac = (e) => (t, n) => q`(${Wt(t)} ${e} ${Wt(n)})`.annotate({ op: e, a: t, b: n, visit: Rf }), Cf = Ac("="), T5 = Ac("<>"), $l = Ac("<"), Ov = Ac(">"), Al = Ac("<=");
function E5(e, t, n, r) {
  t = Wt(t);
  const i = e.startsWith("NOT ") ? "NOT " : "";
  return (n ? r ? q`${i}(${n[0]} <= ${t} AND ${t} < ${n[1]})` : q`(${t} ${e} ${n[0]} AND ${n[1]})` : q``).annotate({ op: e, visit: Rf, field: t, range: n });
}
const Qe = (e, t, n) => E5("BETWEEN", e, t, n);
function Il(e, t) {
  return Array.from({ length: e }, () => t);
}
function Ic(e, t) {
  return (...n) => {
    const r = n.map(Wt), i = t ? `::${t}` : "";
    return (r.length ? q([`${e}(`, ...Il(r.length - 1, ", "), `)${i}`], ...r) : q`${e}()${i}`).annotate({ func: e, args: r });
  };
}
const N5 = Ic("REGEXP_MATCHES"), L5 = Ic("CONTAINS"), D5 = Ic("PREFIX"), O5 = Ic("SUFFIX");
class ui extends Bf {
  constructor(t, n, r, i, s = "", o = "", a = "") {
    let c;
    if (i && !(s || o || a))
      c = i ? q`${n} OVER "${i}"` : q`${n} OVER ()`;
    else {
      const f = s && o ? " " : "", d = (s || o) && a ? " " : "";
      c = q`${n} OVER (${i ? `"${i}" ` : ""}${s}${f}${o}${d}${a})`;
    }
    r && (c = q`(${c})::${r}`);
    const { _expr: l, _deps: h } = c;
    super(l, h, { 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 ui(n, r, i, t, s, o, a);
  }
  partitionby(...t) {
    const n = t.flat().filter((l) => l).map(Wt), r = q(
      ["PARTITION BY ", Il(n.length - 1, ", "), ""],
      ...n
    ), { window: i, func: s, type: o, name: a, order: c, frame: u } = this;
    return new ui(i, s, o, a, r, c, u);
  }
  orderby(...t) {
    const n = t.flat().filter((l) => l).map(Wt), r = q(
      ["ORDER BY ", Il(n.length - 1, ", "), ""],
      ...n
    ), { window: i, func: s, type: o, name: a, group: c, frame: u } = this;
    return new ui(i, s, o, a, c, r, u);
  }
  rows(t) {
    const n = Ug("ROWS", t), { window: r, func: i, type: s, name: o, group: a, order: c } = this;
    return new ui(r, i, s, o, a, c, n);
  }
  range(t) {
    const n = Ug("RANGE", t), { window: r, func: i, type: s, name: o, group: a, order: c } = this;
    return new ui(r, i, s, o, a, c, n);
  }
}
function Ug(e, t) {
  if (Ao(t)) {
    const n = q`${t}`;
    return n.toString = () => `${e} ${jg(t.value)}`, n;
  }
  return `${e} ${jg(t)}`;
}
function jg(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 Rn(e, t) {
  return (...n) => {
    const r = Ic(e)(...n);
    return new ui(e, r, t);
  };
}
const F5 = Rn("ROW_NUMBER", "INTEGER"), k5 = Rn("RANK", "INTEGER"), B5 = Rn("DENSE_RANK", "INTEGER"), R5 = Rn("PERCENT_RANK"), C5 = Rn("CUME_DIST"), P5 = Rn("NTILE"), z5 = Rn("LAG"), U5 = Rn("LEAD"), j5 = Rn("FIRST_VALUE"), q5 = Rn("LAST_VALUE"), V5 = Rn("NTH_VALUE");
class Fa extends Bf {
  constructor(t, n, r, i, s) {
    n = (n || []).map(Wt);
    const { strings: o, exprs: a } = Y5(t, n, r, i, s), { spans: c, cols: u } = Tv(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(W5).join(", ")})` : "";
    return `${t.toLowerCase()}${s}`;
  }
  distinct() {
    const { aggregate: t, args: n, type: r, filter: i } = this;
    return new Fa(t, n, r, !0, i);
  }
  where(t) {
    const { aggregate: n, args: r, type: i, isDistinct: s } = this;
    return new Fa(n, r, i, s, t);
  }
  window() {
    const { aggregate: t, args: n, type: r, isDistinct: i } = this, s = new Fa(t, n, null, i);
    return new ui(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 Y5(e, t, n, r, i) {
  const s = `)${n ? `::${n}` : ""}`;
  let o = [`${e}(${r ? "DISTINCT " : ""}`], a = [];
  return t.length ? (o = o.concat([
    ...Il(t.length - 1, ", "),
    `${s}${i ? " FILTER (WHERE " : ""}`,
    ...i ? [")"] : []
  ]), a = [...t, ...i ? [i] : []]) : o[0] += "*" + s, { exprs: a, strings: o };
}
function W5(e) {
  const t = Mc(e);
  return t && t.startsWith('"') && t.endsWith('"') ? t.slice(1, -1) : t;
}
function $e(e, t) {
  return (...n) => new Fa(e, n, t);
}
const cs = $e("COUNT", "INTEGER"), X5 = $e("AVG"), Io = $e("MAX"), To = $e("MIN"), As = $e("SUM", "DOUBLE"), G5 = $e("MEDIAN"), H5 = $e("QUANTILE"), Z5 = $e("MODE"), K5 = $e("REGR_INTERCEPT"), J5 = $e("REGR_SLOPE"), Q5 = $e("REGR_COUNT"), tI = $e("REGR_SYY"), eI = $e("REGR_SXX"), nI = $e("REGR_AVGX"), qg = $e("ARG_MIN"), Vg = $e("ARG_MAX");
function rI(e, t) {
  const n = Wt(e), r = q`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 Yg = (e) => rI(e, "DOUBLE"), Fv = (e) => {
  const t = Wt(e);
  return q`(1000 * (epoch(${t}) - second(${t})) + millisecond(${t}))::DOUBLE`;
}, iI = (e) => {
  const t = Wt(e);
  return q`MAKE_DATE(2012, MONTH(${t}), 1)`.annotate({ label: "month" });
}, sI = (e) => {
  const t = Wt(e);
  return q`MAKE_DATE(2012, MONTH(${t}), DAY(${t}))`.annotate({ label: "date" });
}, oI = (e) => {
  const t = Wt(e);
  return q`MAKE_DATE(2012, 1, DAY(${t}))`.annotate({ label: "date" });
};
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 rs("UNION", t.flat());
  }
  static unionAll(...t) {
    return new rs("UNION ALL", t.flat());
  }
  static intersect(...t) {
    return new rs("INTERSECT", t.flat());
  }
  static except(...t) {
    return new rs("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: Wt(i) });
          else if (i instanceof xi)
            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: iu(s), expr: Wt(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: Qh(i) });
          else if (i instanceof xi)
            r.push({ as: i.table, from: i });
          else if (td(i) || Iv(i))
            r.push({ from: i });
          else if (Array.isArray(i))
            r.push({ as: iu(i[0]), from: Qh(i[1]) });
          else
            for (const s in i)
              r.push({ as: iu(s), from: Qh(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(Wt)
    ), 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: iu(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(Wt)
    ), 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 (td(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: h,
      offset: f,
      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 }) => M5(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 = td(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`, _ = b ? ` (${b}${w != null ? `, ${w}` : ""})` : "";
      p.push(`USING SAMPLE ${v}${_}`);
    }
    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(h) && p.push(`LIMIT ${h}`), Number.isFinite(f) && p.push(`OFFSET ${f}`), p.join(" ");
  }
}
class rs {
  constructor(t, n) {
    this.op = t, this.queries = n.map((r) => r.clone()), this.query = { orderby: [] };
  }
  clone() {
    const t = new rs(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(Wt)
    ), 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 td(e) {
  return e instanceof St || e instanceof rs;
}
function iu(e) {
  return aI(e) ? e.slice(1, -1) : e;
}
function aI(e) {
  return e[0] === '"' && e[e.length - 1] === '"';
}
function Q0(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 cI(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) => `${Mc(i[o])} AS "${t[o]}"`);
    r.push(`(SELECT ${s.join(", ")})`);
  }
  return r.join(" UNION ALL ");
}
function ty(e, t, n, r = {}, i = {}) {
  const { select: s = ["*"], where: o, view: a, temp: c, replace: u, ...l } = r, h = dI({ ...i, ...l }), f = `${e}('${n}'${h ? ", " + h : ""})`, d = o ? ` WHERE ${o}` : "", p = `SELECT ${s.join(", ")} FROM ${f}${d}`;
  return Q0(t, p, { view: a, temp: c, replace: u });
}
function uI(e, t, n) {
  return ty("read_csv", e, t, n, { auto_detect: !0, sample_size: -1 });
}
function lI(e, t, n) {
  return ty("read_json", e, t, n, { auto_detect: !0, json_format: "auto" });
}
function fI(e, t, n) {
  return ty("read_parquet", e, t, n);
}
function hI(e, t, n = {}) {
  const { select: r = ["*"], ...i } = n, s = cI(t), o = r.length === 1 && r[0] === "*" ? s : `SELECT ${r} FROM ${s}`;
  return Q0(e, o, i);
}
function dI(e) {
  return Object.entries(e).map(([t, n]) => {
    const r = typeof n, i = r === "boolean" ? String(n) : r === "string" ? `'${n}'` : n;
    return `${t}=${i}`;
  }).join(", ");
}
const pI = "count", yI = "nulls", mI = "max", gI = "min", bI = "distinct", wI = {
  [pI]: cs,
  [bI]: (e) => cs(e).distinct(),
  [mI]: Io,
  [gI]: To,
  [yI]: (e) => cs().where(Dv(e))
};
function vI({ table: e, column: t }, n) {
  return St.from(e).select(n.map((r) => [r, wI[r](t)]));
}
const kv = () => /* @__PURE__ */ Object.create(null);
class _I {
  constructor(t) {
    this.mc = t, this.clear();
  }
  clear() {
    this.tables = kv();
  }
  tableInfo(t) {
    const n = this.tables;
    if (n[t])
      return n[t];
    const r = xI(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(
      vI(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 SI(this, t);
    return (await Promise.all(n.map((i) => this.fieldInfo(i)))).filter((i) => i);
  }
}
async function xI(e, t) {
  const n = await e.query(
    `DESCRIBE "${t}"`,
    { type: "json", cache: !1 }
  ), r = kv();
  for (const i of n)
    r[i.column_name] = {
      table: t,
      column: i.column_name,
      sqlType: i.column_type,
      type: S5(i.column_type),
      nullable: i.null === "YES"
    };
  return r;
}
async function SI(e, t) {
  return t.length === 1 && t[0].column === "*" ? Object.values(await e.tableInfo(t[0].table)) : t;
}
function MI(e) {
  let t = 2166136261;
  for (let n = 0, r = e.length; n < r; ++n) {
    const i = e.charCodeAt(n), s = i & 65280;
    s && (t = Wg(t ^ s >> 8)), t = Wg(t ^ i & 255);
  }
  return $I(t);
}
function Wg(e) {
  return e + (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
}
function $I(e) {
  return e += e << 13, e ^= e >>> 7, e += e << 3, e ^= e >>> 17, e += e << 5, e & 4294967295;
}
const Bv = (e) => e;
class AI {
  constructor(t, n) {
    this.mc = t, this.selection = n, 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 a, c;
    if (this.clients !== t) {
      const u = Array.from(t, Gg), l = (a = u[0]) == null ? void 0 : a.from;
      this.enabled = u.every((h) => h && h.from === l), 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 === ((c = this.activeView) == null ? void 0 : c.source))
      return !0;
    if (this.clear(), !r)
      return !1;
    const i = this.activeView = II(n);
    if (!i)
      return !1;
    this.mc.logger().warn("DATA TILE INDEX CONSTRUCTION");
    const s = this.selection.remove(r), o = this.indices = /* @__PURE__ */ new Map();
    for (const u of t) {
      if (s.skip(u, n))
        continue;
      const l = Gg(u), h = u.query(s.predicate(u)).select({ ...i.columns, ...l.count }).groupby(Object.keys(i.columns)), [f] = h.subqueries;
      if (f) {
        const m = Object.values(i.columns).map((b) => b.columns[0]);
        LI(f, m);
      }
      const d = h.toString(), y = `tile_index_${(MI(d) >>> 0).toString(16)}`, g = NI(this.mc, y, d);
      o.set(u, { table: y, result: g, ...l });
    }
  }
  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 } = r, a = St.select(s, o).from(i).groupby(s).where(n);
    return this.mc.updateClient(t, a);
  }
}
function II(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) => TI(l, o));
    if (u.some((l) => l == null))
      return null;
    u.length === 1 ? (a = (l) => l ? Qe("active0", l.range.map(u[0])) : [], r = { active0: u[0](e.predicate.field) }) : (a = (l) => l ? ps(l.children.map(({ range: h }, f) => Qe(`active${f}`, h.map(u[f])))) : [], r = Object.fromEntries(
      e.predicate.children.map((l, h) => [`active${h}`, u[h](l.field)])
    ));
  } else if (i === "point")
    a = Bv, r = Object.fromEntries(r.map((u) => [u.toString(), u]));
  else
    return null;
  return { source: t, columns: r, predicate: a };
}
function TI(e, t) {
  const { type: n, domain: r, range: i } = e;
  let s, o;
  switch (n) {
    case "linear":
      s = Bv, o = Wt;
      break;
    case "log":
      s = Math.log, o = (a) => q`LN(${Wt(a)})`;
      break;
    case "symlog":
      s = (a) => Math.sign(a) * Math.log1p(Math.abs(a)), o = (a) => (a = Wt(a), q`SIGN(${a}) * LN(1 + ABS(${a}))`);
      break;
    case "sqrt":
      s = Math.sqrt, o = (a) => q`SQRT(${Wt(a)})`;
      break;
    case "utc":
    case "time":
      s = (a) => +a, o = (a) => a instanceof Date ? +a : Fv(Wt(a));
      break;
  }
  return s ? EI(r, i, t, s, o) : null;
}
function EI(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) => q`${c}FLOOR(${a}::DOUBLE * (${i(u)} - ${s}::DOUBLE))::INTEGER`;
}
function NI(e, t, n) {
  return e.exec(`CREATE TEMP TABLE IF NOT EXISTS ${t} AS ${n}`);
}
const Xg = { from: NaN };
function Gg(e) {
  if (!e.filterIndexable)
    return Xg;
  const t = e.query(), n = dp(t);
  if (!n || !t.groupby)
    return Xg;
  const r = new Set(t.groupby().map((a) => a.column)), i = [], s = [];
  let o;
  for (const { as: a, expr: { aggregate: c } } of t.select())
    switch (c == null ? void 0 : c.toUpperCase()) {
      case "COUNT":
      case "SUM":
        i.push({ [a]: q`SUM("${a}")::DOUBLE` });
        break;
      case "AVG":
        o = "_count_", i.push({ [a]: q`(SUM("${a}" * ${o}) / SUM(${o}))::DOUBLE` });
        break;
      case "MAX":
        i.push({ [a]: q`MAX("${a}")` });
        break;
      case "MIN":
        i.push({ [a]: q`MIN("${a}")` });
        break;
      default:
        if (r.has(a))
          s.push(a);
        else
          return null;
    }
  return {
    aggr: i,
    dims: s,
    count: o ? { [o]: q`COUNT(*)` } : {},
    from: n
  };
}
function dp(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 = dp(t[0]);
  for (let r = 1; r < t.length; ++r) {
    const i = dp(t[r]);
    if (i !== void 0 && i !== n)
      return NaN;
  }
  return n;
}
function LI(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 DI {
  constructor(t, n, r = !0) {
    this.mc = t, this.selection = n, this.clients = /* @__PURE__ */ new Set(), this.indexer = r ? new AI(this.mc, 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() : OI(t, r, i);
  }
}
function OI(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 Rv() {
  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 FI(e, t, n) {
  let r = [], i = 0;
  function s() {
    const o = kI(r, t);
    r = [], i = 0;
    for (const a of o)
      RI(a, e, n), zI(a, t);
  }
  return {
    add(o, a) {
      o.request.type === "arrow" ? (i = i || requestAnimationFrame(() => s()), r.push({ entry: o, priority: a, index: r.length })) : e(o, a);
    }
  };
}
function kI(e, t) {
  const n = [], r = /* @__PURE__ */ new Map();
  for (const i of e) {
    const { entry: { request: s } } = i, o = BI(s.query, t);
    if (!r.has(o)) {
      const a = [];
      n.push(a), r.set(o, a);
    }
    r.get(o).push(i);
  }
  return n;
}
function BI(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 xi && s[o.column] || o));
    }
    return `${r}`;
  } else
    return n;
}
function RI(e, t, n) {
  if (CI(e))
    t({
      request: {
        type: "arrow",
        cache: !1,
        record: !1,
        query: PI(e, n)
      },
      result: e.result = Rv()
    });
  else
    for (const { entry: r, priority: i } of e)
      t(r, i);
}
function CI(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 PI(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 h = `${l}`;
      r.has(h) || r.set(h, [`col${r.size}`, l]);
      const [f] = r.get(h);
      c.push([f, 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 xi && o[a.column] || a));
  }
  return i.$select(Array.from(r.values()));
}
async function zI(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 = UI(i, n[o]);
    a.cache && t.set(String(a.query), u), c.fulfill(u);
  });
}
function UI(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 jI = typeof requestIdleCallback < "u" ? requestIdleCallback : setTimeout, qI = () => ({
  get: () => {
  },
  set: (e, t) => t,
  clear: () => {
  }
});
function VI({
  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 && jI(r), s;
    },
    clear() {
      n = /* @__PURE__ */ new Map();
    }
  };
}
function YI(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 ai = { High: 0, Normal: 1, Low: 2 };
function WI() {
  const e = YI(3);
  let t, n, r, i = [], s = null, o;
  function a() {
    if (s || e.isEmpty())
      return;
    const { request: h, result: f } = e.next();
    s = l(h, f), s.finally(() => {
      s = null, a();
    });
  }
  function c(h, f = ai.Normal) {
    e.insert(h, f), a();
  }
  function u(h) {
    i.length && h && i.forEach((f) => f.add(h));
  }
  async function l(h, f) {
    try {
      const { query: d, type: p, cache: y = !1, record: g = !0, options: m } = h, b = d ? `${d}` : null;
      if (g && u(b), y) {
        const _ = n.get(b);
        if (_) {
          r.debug("Cache"), f.fulfill(_);
          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)}`), f.fulfill(v);
    } catch (d) {
      f.reject(d);
    }
  }
  return {
    cache(h) {
      return h !== void 0 ? n = h === !0 ? VI() : h || qI() : n;
    },
    logger(h) {
      return h ? r = h : r;
    },
    connector(h) {
      return h ? t = h : t;
    },
    consolidate(h) {
      h && !o ? o = FI(c, n, u) : !h && o && (o = null);
    },
    request(h, f = ai.Normal) {
      const d = Rv(), p = { request: h, result: d };
      return o ? o.add(p, f) : c(p, f), d;
    },
    cancel(h) {
      const f = new Set(h);
      e.remove(({ result: d }) => f.has(d));
    },
    clear() {
      e.remove(({ result: h }) => (h.reject("Cleared"), !0));
    },
    record() {
      let h = [];
      const f = {
        add(d) {
          h.push(d);
        },
        reset() {
          h = [];
        },
        snapshot() {
          return h.slice();
        },
        stop() {
          return i = i.filter((d) => d !== f), h;
        }
      };
      return i.push(f), f;
    }
  };
}
function XI() {
  return {
    debug() {
    },
    info() {
    },
    log() {
    },
    warn() {
    },
    error() {
    }
  };
}
let su;
function An(e) {
  return e ? su = e : su == null && (su = new GI()), su;
}
class GI {
  constructor(t = x5(), n = {}) {
    this.catalog = new _I(this), this.manager = n.manager || WI(), this.logger(n.logger || console), this.configure(n), this.databaseConnector(t), this.clear();
  }
  logger(t) {
    return arguments.length && (this._logger = t || XI(), 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 = ai.Normal } = {}) {
    return this.manager.request({ type: "exec", query: t }, n);
  }
  query(t, {
    type: n = "arrow",
    cache: r = !0,
    priority: i = ai.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: ai.Low });
  }
  createBundle(t, n, r = ai.Low) {
    const i = { name: t, queries: n };
    return this.manager.request({ type: "create-bundle", options: i }, r);
  }
  loadBundle(t, n = ai.High) {
    const r = { name: t };
    return this.manager.request({ type: "load-bundle", options: r }, n);
  }
  // -- Client Management ----
  updateClient(t, n, r = ai.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);
    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 DI(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));
  }
}
const Hg = {};
function Cv(e, t = !1) {
  let n, r, i = Hg;
  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 = Hg, a(l);
    }), i = u;
  }
  return t ? c : a;
}
class Tc {
  /**
   * 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 = Cv(() => this.requestQuery(), !0);
  }
  /**
   * Return this client's filter selection.
   */
  get filterBy() {
    return this._filterBy;
  }
  /**
   * Return a boolean indicating if the client query can be indexed. Should
   * return true if changes to the filterBy selection does not change the
   * groupby domain of the client query.
   */
  get filterIndexable() {
    return !0;
  }
  /**
   * Return an array of fields queried by this client.
   */
  fields() {
    return null;
  }
  /**
   * Called by the coordinator to set the field 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 An().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;
  }
}
class HI {
  /**
   * 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 ZI()
    }), 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 ZI {
  /**
   * 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 Pv(e, t) {
  return e === t ? !1 : e instanceof Date && t instanceof Date ? +e != +t : Array.isArray(e) && Array.isArray(t) ? KI(e, t) : !0;
}
function KI(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 mi(e) {
  return e instanceof Cr;
}
class Cr extends HI {
  /**
   * 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 Cr(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) => mi(n))) {
      const n = new Cr(), r = () => n.update(t.map((i) => mi(i) ? i.value : i));
      return r(), t.forEach((i) => mi(i) ? i.addEventListener("value", r) : 0), n;
    }
    return new Cr(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 Pv(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 ys(e) {
  return e instanceof di;
}
let di = class Gs extends Cr {
  /**
   * 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 Gs(new fa({ 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 Gs(new fa({ 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 Gs(new fa({ 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 Gs(new fa({ cross: !0 }));
  }
  /**
   * Create a new Selection instance.
   * @param {SelectionResolver} resolver The selection resolution
   *  strategy to apply.
   */
  constructor(t = new fa()) {
    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 Gs(this._resolver);
    return t._value = t._resolved = this._value, t;
  }
  /**
   * Create a clone of this Selection with clauses corresponding
   * to 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.
   * @returns {*} The query predicate for filtering client data,
   *  based on the current state of this selection.
   */
  predicate(t) {
    const { clauses: n } = this;
    return this._resolver.predicate(n, n.active, t);
  }
};
class fa {
  /**
   * 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 ? Nv(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 JI() {
  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;
    }
  };
}
function Pf(e, t) {
  const n = new e(t);
  return An().connect(n), n.element;
}
const QI = (e) => e && typeof e == "object" && !Array.isArray(e), tT = (e) => Pf(eT, e);
class eT extends Tc {
  constructor({
    element: t,
    filterBy: n,
    from: r,
    column: i,
    label: s = i,
    format: o = (l) => l,
    // TODO
    options: a,
    value: c,
    as: u
  } = {}) {
    var h, f, 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) => QI(y) ? y : { value: y }), this.update()), c = c ?? ((h = this.selection) == null ? void 0 : h.value) ?? ((d = (f = this.data) == null ? void 0 : f[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);
    }), ys(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;
    ys(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: t ? Cf(r, $c(t)) : null
    }) : mi(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 nT = { contains: L5, prefix: D5, suffix: O5, regexp: N5 };
let rT = 0;
const iT = (e) => Pf(sT, e);
class sT extends Tc {
  constructor({
    element: t,
    filterBy: n,
    from: r,
    column: i,
    label: s,
    type: o = "contains",
    as: a
  } = {}) {
    if (super(n), this.id = "search_" + ++rT, 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);
    }), ys(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;
    ys(n) ? n.update({
      source: this,
      schema: { type: i },
      value: t,
      predicate: t ? nT[i](r, $c(t)) : null
    }) : mi(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 oT = 0;
const aT = (e) => Pf(cT, e);
class cT extends Tc {
  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: h
  } = {}) {
    var f;
    if (super(n), this.id = "slider_" + ++oT, 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"), h != null && (this.slider.style.width = `${+h}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), ((f = this.selection) == null ? void 0 : f.value) === void 0 && this.publish(l)), this.element.appendChild(this.slider), this.selection && (this.slider.addEventListener("input", () => {
      this.publish(+this.slider.value);
    }), ys(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: To(r), max: Io(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;
    ys(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: Cf(r, $c(t))
    }) : mi(this.selection) && n.update(t);
  }
}
function zv(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 `${uT(e.getUTCFullYear())}-${Ir(e.getUTCMonth() + 1, 2)}-${Ir(e.getUTCDate(), 2)}${n || r || i || s ? `T${Ir(n, 2)}:${Ir(r, 2)}${i || s ? `:${Ir(i, 2)}${s ? `.${Ir(s, 3)}` : ""}` : ""}Z` : ""}`;
}
function uT(e) {
  return e < 0 ? `-${Ir(-e, 6)}` : e > 9999 ? `+${Ir(e, 6)}` : Ir(e, 4);
}
function Ir(e, t) {
  return `${e}`.padStart(t, "0");
}
const lT = /^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;
function ey(e, t) {
  return lT.test(e += "") ? new Date(e) : typeof t == "function" ? t(e) : t;
}
const Uv = ry((e) => {
  const t = ny(e);
  return (n) => n == null ? "" : typeof n == "number" ? t(n) : n instanceof Date ? jv(n) : `${n}`;
}), ny = ry((e) => (t) => t === 0 ? "0" : t.toLocaleString(e));
Uv();
ny();
function jv(e) {
  return zv(e, "Invalid Date");
}
function ry(e) {
  let t = ry, n;
  return (r = "en") => r === t ? n : n = e(t = r);
}
let fT = -1;
const hT = (e) => Pf(dT, e);
class dT extends Tc {
  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-${++fT}`, 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 h = -1;
    this.element.addEventListener("scroll", (f) => {
      const { pending: d, loaded: p } = this, { scrollHeight: y, scrollTop: g, clientHeight: m } = f.target, b = g < h;
      h = 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), An().prefetch(n.clone().offset(t + this.limit));
  }
  fields() {
    return this.columns.map((t) => J0(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 = pT(this.format, t), this.style.innerText = gT(
      this.id,
      yT(this.align, t),
      mT(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 ? I5(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 h = c[i[l].column], f = document.createElement("td");
        f.innerText = h == null ? "" : n[l](h), u.appendChild(f);
      }
      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 pT(e = {}, t, n) {
  return t.map(({ column: r, type: i }) => {
    if (r in e)
      return e[r];
    switch (i) {
      case "number":
        return ny(n);
      case "date":
        return jv;
      default:
        return Uv(n);
    }
  });
}
function yT(e = {}, t) {
  return t.map(({ column: n, type: r }) => n in e ? e[n] : r === "number" ? "right" : "left");
}
function mT(e = {}, t) {
  return t.map(({ column: n }) => e[n]);
}
function gT(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(" ");
}
const iy = Symbol("Fixed"), ms = Symbol("Transient"), qv = Symbol("Transform"), bT = [
  "rectY-x",
  "rectX-y",
  "rect-x",
  "rect-y"
];
function wT(e, t) {
  return bT.includes(`${t}-${e}`);
}
function Zg(e, t = { steps: 25 }) {
  const n = (r, i) => wT(i, r.type) ? {
    [`${i}1`]: ed(r, e, t),
    [`${i}2`]: ed(r, e, { ...t, offset: 1 })
  } : {
    [i]: ed(r, e, t)
  };
  return n[qv] = !0, n;
}
function ed(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 = vT(r, i, n), o = Wt(t), a = s.min === 0 ? o : `(${o} - ${s.min})`, c = `${(s.max - s.min) / s.steps}::DOUBLE`, u = n.offset ? `${n.offset} + ` : "";
      return `${r} + ${c} * (${u}FLOOR(${a} / ${c})::INTEGER)`;
    }
  };
}
function vT(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 h = [5, 2];
    let f;
    for (let y = 0, g = h.length; y < g; ++y)
      f = l / h[y], f >= i && o / f <= a && (l = f);
    f = Math.log(l);
    const d = f >= 0 ? 0 : ~~(-f / c) + 1, p = Math.pow(10, -d - 1);
    f = Math.floor(e / l + p) * l, e = e < f ? f - l : f, t = Math.ceil(t / l) * l, r = Math.round((t - e) / l);
  }
  return { min: e, max: t, steps: r };
}
function se(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Ec(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function sy(e) {
  let t, n, r;
  e.length !== 2 ? (t = se, n = (a, c) => se(e(a), c), r = (a, c) => e(a) - c) : (t = e === se || e === Ec ? e : _T, 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 h = u + l >>> 1;
        n(a[h], c) < 0 ? u = h + 1 : l = h;
      } 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 h = u + l >>> 1;
        n(a[h], c) <= 0 ? u = h + 1 : l = h;
      } while (u < l);
    }
    return u;
  }
  function o(a, c, u = 0, l = a.length) {
    const h = i(a, c, u, l - 1);
    return h > u && r(a[h - 1], c) > -r(a[h], c) ? h - 1 : h;
  }
  return { left: i, center: o, right: s };
}
function _T() {
  return 0;
}
function Vv(e) {
  return e === null ? NaN : +e;
}
function* xT(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 ST = sy(se), MT = ST.right;
sy(Vv).center;
const zf = MT, Yv = Wv(Xv), $T = Wv(AT);
function Wv(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 ? (Os(a, u, i, s, o), Os(a, i, u, s, o), Os(a, u, i, s, o), Fs(c, i, u, s, o), Fs(c, u, i, s, o), Fs(c, i, u, s, o)) : a ? (Os(a, i, u, s, o), Os(a, u, i, s, o), Os(a, i, u, s, o)) : c && (Fs(c, i, u, s, o), Fs(c, u, i, s, o), Fs(c, i, u, s, o)), t;
  };
}
function Os(e, t, n, r, i) {
  for (let s = 0, o = r * i; s < o; )
    e(t, n, s, s += r, 1);
}
function Fs(e, t, n, r, i) {
  for (let s = 0, o = r * i; s < r; ++s)
    e(t, n, s, s + o, r);
}
function AT(e) {
  const t = Xv(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 Xv(e) {
  const t = Math.floor(e);
  if (t === e)
    return IT(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, h = l + c;
    for (let f = o, d = o + l; f < d; f += c)
      u += s[Math.min(a, f)];
    for (let f = o, d = a; f <= d; f += c)
      u += s[Math.min(a, f + l)], i[f] = (u + n * (s[Math.max(o, f - h)] + s[Math.min(a, f + h)])) / r, u -= s[Math.max(o, f - l)];
  };
}
function IT(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 Uf(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 TT(e) {
  return e.length | 0;
}
function ET(e) {
  return !(e > 0);
}
function NT(e) {
  return typeof e != "object" || "length" in e ? e : Array.from(e);
}
function LT(e) {
  return (t) => e(...t);
}
function DT(...e) {
  const t = typeof e[e.length - 1] == "function" && LT(e.pop());
  e = e.map(NT);
  const n = e.map(TT), r = e.length - 1, i = new Array(r + 1).fill(0), s = [];
  if (r < 0 || n.some(ET))
    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 OT(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 oy(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 jf(e, t) {
  const n = oy(e, t);
  return n && Math.sqrt(n);
}
function Se(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 nr {
  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 gs extends Map {
  constructor(t, n = Zv) {
    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(pp(this, t));
  }
  has(t) {
    return super.has(pp(this, t));
  }
  set(t, n) {
    return super.set(Gv(this, t), n);
  }
  delete(t) {
    return super.delete(Hv(this, t));
  }
}
class qf extends Set {
  constructor(t, n = Zv) {
    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(pp(this, t));
  }
  add(t) {
    return super.add(Gv(this, t));
  }
  delete(t) {
    return super.delete(Hv(this, t));
  }
}
function pp({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) ? e.get(r) : n;
}
function Gv({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) ? e.get(r) : (e.set(r, n), n);
}
function Hv({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) && (n = e.get(r), e.delete(r)), n;
}
function Zv(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function yp(e) {
  return e;
}
function Jr(e, ...t) {
  return ay(e, yp, yp, t);
}
function so(e, t, ...n) {
  return ay(e, yp, t, n);
}
function FT(e, t, ...n) {
  return ay(e, Array.from, t, n);
}
function ay(e, t, n, r) {
  return function i(s, o) {
    if (o >= r.length)
      return n(s);
    const a = new gs(), c = r[o++];
    let u = -1;
    for (const l of s) {
      const h = c(l, ++u, s), f = a.get(h);
      f ? f.push(l) : a.set(h, [l]);
    }
    for (const [l, h] of a)
      a.set(l, i(h, o));
    return t(a);
  }(e, 0);
}
function kT(e, t) {
  return Array.from(t, (n) => e[n]);
}
function Ka(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 = Ja(o[i], o[s]);
        if (a)
          return a;
      }
    })) : (n = e.map(n), r.sort((i, s) => Ja(n[i], n[s]))), kT(e, r);
  }
  return e.sort(cy(n));
}
function cy(e = se) {
  if (e === se)
    return Ja;
  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 Ja(e, t) {
  return (e == null || !(e >= e)) - (t == null || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0);
}
function uy(e, t, n) {
  return (t.length !== 2 ? Ka(so(e, t, n), ([r, i], [s, o]) => se(i, o) || se(r, s)) : Ka(Jr(e, n), ([r, i], [s, o]) => t(i, o) || se(r, s))).map(([r]) => r);
}
const BT = Math.sqrt(50), RT = Math.sqrt(10), CT = Math.sqrt(2);
function Tl(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 >= BT ? 10 : s >= RT ? 5 : s >= CT ? 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 ? Tl(e, t, n * 2) : [a, c, u];
}
function Si(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 ? Tl(t, e, n) : Tl(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 Qa(e, t, n) {
  return t = +t, e = +e, n = +n, Tl(e, t, n)[2];
}
function mp(e, t, n) {
  t = +t, e = +e, n = +n;
  const r = t < e, i = r ? Qa(t, e, n) : Qa(e, t, n);
  return (r ? -1 : 1) * (i < 0 ? 1 / -i : i);
}
function Kv(e, t, n) {
  let r;
  for (; ; ) {
    const i = Qa(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 ly(e) {
  return Math.max(1, Math.ceil(Math.log(Uf(e)) / Math.LN2) + 1);
}
function te(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 PT(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 pe(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 zT(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 Jv(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 ? Ja : cy(i); r > n; ) {
    if (r - n > 600) {
      const c = r - n + 1, u = t - n + 1, l = Math.log(c), h = 0.5 * Math.exp(2 * l / 3), f = 0.5 * Math.sqrt(l * h * (c - h) / c) * (u - c / 2 < 0 ? -1 : 1), d = Math.max(n, Math.floor(t - u * h / c + f)), p = Math.min(r, Math.floor(t + (c - u) * h / c + f));
      Jv(e, t, d, p, i);
    }
    const s = e[t];
    let o = n, a = r;
    for (ha(e, n, t), i(e[r], s) > 0 && ha(e, n, r); o < a; ) {
      for (ha(e, o, a), ++o, --a; i(e[o], s) < 0; )
        ++o;
      for (; i(e[a], s) > 0; )
        --a;
    }
    i(e[n], s) === 0 ? ha(e, n, a) : (++a, ha(e, a, r)), a <= t && (n = a + 1), t <= a && (r = a - 1);
  }
  return e;
}
function ha(e, t, n) {
  const r = e[t];
  e[t] = e[n], e[n] = r;
}
function fy(e, t = se) {
  let n, r = !1;
  if (t.length === 1) {
    let i;
    for (const s of e) {
      const o = t(s);
      (r ? se(o, i) > 0 : se(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 Mi(e, t, n) {
  if (e = Float64Array.from(xT(e, n)), !(!(r = e.length) || isNaN(t = +t))) {
    if (t <= 0 || r < 2)
      return pe(e);
    if (t >= 1)
      return te(e);
    var r, i = (r - 1) * t, s = Math.floor(i), o = te(Jv(e, s).subarray(0, s + 1)), a = pe(e.subarray(s + 1));
    return o + (a - o) * (i - s);
  }
}
function UT(e, t, n = Vv) {
  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 jT(e, t, n) {
  const r = Uf(e), i = Mi(e, 0.75) - Mi(e, 0.25);
  return r && i ? Math.ceil((n - t) / (2 * i * Math.pow(r, -1 / 3))) : 1;
}
function Qv(e, t, n) {
  const r = Uf(e), i = jf(e);
  return r && i ? Math.ceil((n - t) * Math.cbrt(r) / (3.49 * i)) : 1;
}
function hy(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 tc(e, t) {
  return Mi(e, 0.5, t);
}
function* qT(e) {
  for (const t of e)
    yield* t;
}
function t_(e) {
  return Array.from(qT(e));
}
function e_(e, t) {
  const n = new gs();
  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 Ze(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 n_(e, t = se) {
  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 = se);
  const i = (a, c) => t(n[a], n[c]);
  let s, o;
  return e = Uint32Array.from(n, (a, c) => c), e.sort(t === se ? (a, c) => Ja(n[a], n[c]) : cy(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 VT(e, t = se) {
  let n, r = !1;
  if (t.length === 1) {
    let i;
    for (const s of e) {
      const o = t(s);
      (r ? se(o, i) < 0 : se(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 ar(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 El(e) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  return Array.from(e).reverse();
}
function YT(e) {
  return e;
}
var nd = 1, rd = 2, gp = 3, ou = 4, Kg = 1e-6;
function WT(e) {
  return "translate(" + e + ",0)";
}
function XT(e) {
  return "translate(0," + e + ")";
}
function GT(e) {
  return (t) => +e(t);
}
function HT(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (n) => +e(n) + t;
}
function ZT() {
  return !this.__axis;
}
function KT(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 === nd || e === ou ? -1 : 1, l = e === ou || e === rd ? "x" : "y", h = e === nd || e === gp ? WT : XT;
  function f(d) {
    var p = r ?? (t.ticks ? t.ticks.apply(t, n) : t.domain()), y = i ?? (t.tickFormat ? t.tickFormat.apply(t, n) : YT), g = Math.max(s, 0) + a, m = t.range(), b = +m[0] + c, w = +m[m.length - 1] + c, v = (t.bandwidth ? HT : GT)(t.copy(), c), _ = d.selection ? d.selection() : d, x = _.selectAll(".domain").data([null]), $ = _.selectAll(".tick").data(p, t).order(), T = $.exit(), D = $.enter().append("g").attr("class", "tick"), M = $.select("line"), A = $.select("text");
    x = x.merge(x.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), $ = $.merge(D), M = M.merge(D.append("line").attr("stroke", "currentColor").attr(l + "2", u * s)), A = A.merge(D.append("text").attr("fill", "currentColor").attr(l, u * g).attr("dy", e === nd ? "0em" : e === gp ? "0.71em" : "0.32em")), d !== _ && (x = x.transition(d), $ = $.transition(d), M = M.transition(d), A = A.transition(d), T = T.transition(d).attr("opacity", Kg).attr("transform", function(L) {
      return isFinite(L = v(L)) ? h(L + c) : this.getAttribute("transform");
    }), D.attr("opacity", Kg).attr("transform", function(L) {
      var k = this.parentNode.__axis;
      return h((k && isFinite(k = k(L)) ? k : v(L)) + c);
    })), T.remove(), x.attr("d", e === ou || e === rd ? 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), $.attr("opacity", 1).attr("transform", function(L) {
      return h(v(L) + c);
    }), M.attr(l + "2", u * s), A.attr(l, u * g).text(y), _.filter(ZT).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === rd ? "start" : e === ou ? "end" : "middle"), _.each(function() {
      this.__axis = v;
    });
  }
  return f.scale = function(d) {
    return arguments.length ? (t = d, f) : t;
  }, f.ticks = function() {
    return n = Array.from(arguments), f;
  }, f.tickArguments = function(d) {
    return arguments.length ? (n = d == null ? [] : Array.from(d), f) : n.slice();
  }, f.tickValues = function(d) {
    return arguments.length ? (r = d == null ? null : Array.from(d), f) : r && r.slice();
  }, f.tickFormat = function(d) {
    return arguments.length ? (i = d, f) : i;
  }, f.tickSize = function(d) {
    return arguments.length ? (s = o = +d, f) : s;
  }, f.tickSizeInner = function(d) {
    return arguments.length ? (s = +d, f) : s;
  }, f.tickSizeOuter = function(d) {
    return arguments.length ? (o = +d, f) : o;
  }, f.tickPadding = function(d) {
    return arguments.length ? (a = +d, f) : a;
  }, f.offset = function(d) {
    return arguments.length ? (c = +d, f) : c;
  }, f;
}
function JT(e) {
  return KT(gp, e);
}
var QT = { value: () => {
} };
function Vf() {
  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 Uu(n);
}
function Uu(e) {
  this._ = e;
}
function tE(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 };
  });
}
Uu.prototype = Vf.prototype = {
  constructor: Uu,
  on: function(e, t) {
    var n = this._, r = tE(e + "", n), i, s = -1, o = r.length;
    if (arguments.length < 2) {
      for (; ++s < o; )
        if ((i = (e = r[s]).type) && (i = eE(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] = Jg(n[i], e.name, t);
      else if (t == null)
        for (i in n)
          n[i] = Jg(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 Uu(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 eE(e, t) {
  for (var n = 0, r = e.length, i; n < r; ++n)
    if ((i = e[n]).name === t)
      return i.value;
}
function Jg(e, t, n) {
  for (var r = 0, i = e.length; r < i; ++r)
    if (e[r].name === t) {
      e[r] = QT, e = e.slice(0, r).concat(e.slice(r + 1));
      break;
    }
  return n != null && e.push({ name: t, value: n }), e;
}
var bp = "http://www.w3.org/1999/xhtml";
const bs = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: bp,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function Yf(e) {
  var t = e += "", n = t.indexOf(":");
  return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), bs.hasOwnProperty(t) ? { space: bs[t], local: e } : e;
}
function nE(e) {
  return function() {
    var t = this.ownerDocument, n = this.namespaceURI;
    return n === bp && t.documentElement.namespaceURI === bp ? t.createElement(e) : t.createElementNS(n, e);
  };
}
function rE(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function Wf(e) {
  var t = Yf(e);
  return (t.local ? rE : nE)(t);
}
function iE() {
}
function dy(e) {
  return e == null ? iE : function() {
    return this.querySelector(e);
  };
}
function sE(e) {
  typeof e != "function" && (e = dy(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 tn(r, this._parents);
}
function oE(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function aE() {
  return [];
}
function r_(e) {
  return e == null ? aE : function() {
    return this.querySelectorAll(e);
  };
}
function cE(e) {
  return function() {
    return oE(e.apply(this, arguments));
  };
}
function uE(e) {
  typeof e == "function" ? e = cE(e) : e = r_(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 tn(r, i);
}
function i_(e) {
  return function() {
    return this.matches(e);
  };
}
function s_(e) {
  return function(t) {
    return t.matches(e);
  };
}
var lE = Array.prototype.find;
function fE(e) {
  return function() {
    return lE.call(this.children, e);
  };
}
function hE() {
  return this.firstElementChild;
}
function dE(e) {
  return this.select(e == null ? hE : fE(typeof e == "function" ? e : s_(e)));
}
var pE = Array.prototype.filter;
function yE() {
  return Array.from(this.children);
}
function mE(e) {
  return function() {
    return pE.call(this.children, e);
  };
}
function gE(e) {
  return this.selectAll(e == null ? yE : mE(typeof e == "function" ? e : s_(e)));
}
function bE(e) {
  typeof e != "function" && (e = i_(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 tn(r, this._parents);
}
function o_(e) {
  return new Array(e.length);
}
function wE() {
  return new tn(this._enter || this._groups.map(o_), this._parents);
}
function Nl(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
Nl.prototype = {
  constructor: Nl,
  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 vE(e) {
  return function() {
    return e;
  };
}
function _E(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 Nl(e, s[o]);
  for (; o < c; ++o)
    (a = t[o]) && (i[o] = a);
}
function xE(e, t, n, r, i, s, o) {
  var a, c, u = /* @__PURE__ */ new Map(), l = t.length, h = s.length, f = new Array(l), d;
  for (a = 0; a < l; ++a)
    (c = t[a]) && (f[a] = d = o.call(c, c.__data__, a, t) + "", u.has(d) ? i[a] = c : u.set(d, c));
  for (a = 0; a < h; ++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 Nl(e, s[a]);
  for (a = 0; a < l; ++a)
    (c = t[a]) && u.get(f[a]) === c && (i[a] = c);
}
function SE(e) {
  return e.__data__;
}
function ME(e, t) {
  if (!arguments.length)
    return Array.from(this, SE);
  var n = t ? xE : _E, r = this._parents, i = this._groups;
  typeof e != "function" && (e = vE(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], h = i[u], f = h.length, d = $E(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(f);
    n(l, h, y, g, m, d, t);
    for (var b = 0, w = 0, v, _; b < p; ++b)
      if (v = y[b]) {
        for (b >= w && (w = b + 1); !(_ = g[w]) && ++w < p; )
          ;
        v._next = _ || null;
      }
  }
  return o = new tn(o, r), o._enter = a, o._exit = c, o;
}
function $E(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function AE() {
  return new tn(this._exit || this._groups.map(o_), this._parents);
}
function IE(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 TE(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], h = u.length, f = a[c] = new Array(h), d, p = 0; p < h; ++p)
      (d = u[p] || l[p]) && (f[p] = d);
  for (; c < i; ++c)
    a[c] = n[c];
  return new tn(a, this._parents);
}
function EE() {
  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 NE(e) {
  e || (e = LE);
  function t(h, f) {
    return h && f ? e(h.__data__, f.__data__) : !h - !f;
  }
  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 tn(i, this._parents).order();
}
function LE(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function DE() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function OE() {
  return Array.from(this);
}
function FE() {
  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 kE() {
  let e = 0;
  for (const t of this)
    ++e;
  return e;
}
function BE() {
  return !this.node();
}
function RE(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 CE(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function PE(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function zE(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function UE(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function jE(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
  };
}
function qE(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 VE(e, t) {
  var n = Yf(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 ? PE : CE : typeof t == "function" ? n.local ? qE : jE : n.local ? UE : zE)(n, t));
}
function a_(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function YE(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function WE(e, t, n) {
  return function() {
    this.style.setProperty(e, t, n);
  };
}
function XE(e, t, n) {
  return function() {
    var r = t.apply(this, arguments);
    r == null ? this.style.removeProperty(e) : this.style.setProperty(e, r, n);
  };
}
function GE(e, t, n) {
  return arguments.length > 1 ? this.each((t == null ? YE : typeof t == "function" ? XE : WE)(e, t, n ?? "")) : Eo(this.node(), e);
}
function Eo(e, t) {
  return e.style.getPropertyValue(t) || a_(e).getComputedStyle(e, null).getPropertyValue(t);
}
function HE(e) {
  return function() {
    delete this[e];
  };
}
function ZE(e, t) {
  return function() {
    this[e] = t;
  };
}
function KE(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? delete this[e] : this[e] = n;
  };
}
function JE(e, t) {
  return arguments.length > 1 ? this.each((t == null ? HE : typeof t == "function" ? KE : ZE)(e, t)) : this.node()[e];
}
function c_(e) {
  return e.trim().split(/^|\s+/);
}
function py(e) {
  return e.classList || new u_(e);
}
function u_(e) {
  this._node = e, this._names = c_(e.getAttribute("class") || "");
}
u_.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 l_(e, t) {
  for (var n = py(e), r = -1, i = t.length; ++r < i; )
    n.add(t[r]);
}
function f_(e, t) {
  for (var n = py(e), r = -1, i = t.length; ++r < i; )
    n.remove(t[r]);
}
function QE(e) {
  return function() {
    l_(this, e);
  };
}
function t7(e) {
  return function() {
    f_(this, e);
  };
}
function e7(e, t) {
  return function() {
    (t.apply(this, arguments) ? l_ : f_)(this, e);
  };
}
function n7(e, t) {
  var n = c_(e + "");
  if (arguments.length < 2) {
    for (var r = py(this.node()), i = -1, s = n.length; ++i < s; )
      if (!r.contains(n[i]))
        return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? e7 : t ? QE : t7)(n, t));
}
function r7() {
  this.textContent = "";
}
function i7(e) {
  return function() {
    this.textContent = e;
  };
}
function s7(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function o7(e) {
  return arguments.length ? this.each(e == null ? r7 : (typeof e == "function" ? s7 : i7)(e)) : this.node().textContent;
}
function a7() {
  this.innerHTML = "";
}
function c7(e) {
  return function() {
    this.innerHTML = e;
  };
}
function u7(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function l7(e) {
  return arguments.length ? this.each(e == null ? a7 : (typeof e == "function" ? u7 : c7)(e)) : this.node().innerHTML;
}
function f7() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function h7() {
  return this.each(f7);
}
function d7() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function p7() {
  return this.each(d7);
}
function y7(e) {
  var t = typeof e == "function" ? e : Wf(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function m7() {
  return null;
}
function g7(e, t) {
  var n = typeof e == "function" ? e : Wf(e), r = t == null ? m7 : typeof t == "function" ? t : dy(t);
  return this.select(function() {
    return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null);
  });
}
function b7() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function w7() {
  return this.each(b7);
}
function v7() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function _7() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function x7(e) {
  return this.select(e ? _7 : v7);
}
function S7(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function M7(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function $7(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 A7(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 I7(e, t, n) {
  return function() {
    var r = this.__on, i, s = M7(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 T7(e, t, n) {
  var r = $7(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 ? I7 : A7, i = 0; i < s; ++i)
    this.each(a(r[i], t, n));
  return this;
}
function h_(e, t, n) {
  var r = a_(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 E7(e, t) {
  return function() {
    return h_(this, e, t);
  };
}
function N7(e, t) {
  return function() {
    return h_(this, e, t.apply(this, arguments));
  };
}
function L7(e, t) {
  return this.each((typeof t == "function" ? N7 : E7)(e, t));
}
function* D7() {
  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 d_ = [null];
function tn(e, t) {
  this._groups = e, this._parents = t;
}
function Nc() {
  return new tn([[document.documentElement]], d_);
}
function O7() {
  return this;
}
tn.prototype = Nc.prototype = {
  constructor: tn,
  select: sE,
  selectAll: uE,
  selectChild: dE,
  selectChildren: gE,
  filter: bE,
  data: ME,
  enter: wE,
  exit: AE,
  join: IE,
  merge: TE,
  selection: O7,
  order: EE,
  sort: NE,
  call: DE,
  nodes: OE,
  node: FE,
  size: kE,
  empty: BE,
  each: RE,
  attr: VE,
  style: GE,
  property: JE,
  classed: n7,
  text: o7,
  html: l7,
  raise: h7,
  lower: p7,
  append: y7,
  insert: g7,
  remove: w7,
  clone: x7,
  datum: S7,
  on: T7,
  dispatch: L7,
  [Symbol.iterator]: D7
};
function zt(e) {
  return typeof e == "string" ? new tn([[document.querySelector(e)]], [document.documentElement]) : new tn([[e]], d_);
}
function F7(e) {
  let t;
  for (; t = e.sourceEvent; )
    e = t;
  return e;
}
function _n(e, t) {
  if (e = F7(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 wp = { capture: !0, passive: !1 };
function vp(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function p_(e) {
  var t = e.document.documentElement, n = zt(e).on("dragstart.drag", vp, wp);
  "onselectstart" in t ? n.on("selectstart.drag", vp, wp) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function y_(e, t) {
  var n = e.document.documentElement, r = zt(e).on("dragstart.drag", null);
  t && (r.on("click.drag", vp, wp), 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 Xo(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function Lc(e, t) {
  var n = Object.create(e.prototype);
  for (var r in t)
    n[r] = t[r];
  return n;
}
function Oi() {
}
var ws = 0.7, No = 1 / ws, oo = "\\s*([+-]?\\d+)\\s*", ec = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", rr = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", k7 = /^#([0-9a-f]{3,8})$/, B7 = new RegExp(`^rgb\\(${oo},${oo},${oo}\\)$`), R7 = new RegExp(`^rgb\\(${rr},${rr},${rr}\\)$`), C7 = new RegExp(`^rgba\\(${oo},${oo},${oo},${ec}\\)$`), P7 = new RegExp(`^rgba\\(${rr},${rr},${rr},${ec}\\)$`), z7 = new RegExp(`^hsl\\(${ec},${rr},${rr}\\)$`), U7 = new RegExp(`^hsla\\(${ec},${rr},${rr},${ec}\\)$`), Qg = {
  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
};
Xo(Oi, Vr, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: t1,
  // Deprecated! Use color.formatHex.
  formatHex: t1,
  formatHex8: j7,
  formatHsl: q7,
  formatRgb: e1,
  toString: e1
});
function t1() {
  return this.rgb().formatHex();
}
function j7() {
  return this.rgb().formatHex8();
}
function q7() {
  return m_(this).formatHsl();
}
function e1() {
  return this.rgb().formatRgb();
}
function Vr(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = k7.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? n1(t) : n === 3 ? new de(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? au(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? au(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 = B7.exec(e)) ? new de(t[1], t[2], t[3], 1) : (t = R7.exec(e)) ? new de(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = C7.exec(e)) ? au(t[1], t[2], t[3], t[4]) : (t = P7.exec(e)) ? au(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = z7.exec(e)) ? s1(t[1], t[2] / 100, t[3] / 100, 1) : (t = U7.exec(e)) ? s1(t[1], t[2] / 100, t[3] / 100, t[4]) : Qg.hasOwnProperty(e) ? n1(Qg[e]) : e === "transparent" ? new de(NaN, NaN, NaN, 0) : null;
}
function n1(e) {
  return new de(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function au(e, t, n, r) {
  return r <= 0 && (e = t = n = NaN), new de(e, t, n, r);
}
function yy(e) {
  return e instanceof Oi || (e = Vr(e)), e ? (e = e.rgb(), new de(e.r, e.g, e.b, e.opacity)) : new de();
}
function bn(e, t, n, r) {
  return arguments.length === 1 ? yy(e) : new de(e, t, n, r ?? 1);
}
function de(e, t, n, r) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +r;
}
Xo(de, bn, Lc(Oi, {
  brighter(e) {
    return e = e == null ? No : Math.pow(No, e), new de(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? ws : Math.pow(ws, e), new de(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new de(us(this.r), us(this.g), us(this.b), Ll(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: r1,
  // Deprecated! Use color.formatHex.
  formatHex: r1,
  formatHex8: V7,
  formatRgb: i1,
  toString: i1
}));
function r1() {
  return `#${is(this.r)}${is(this.g)}${is(this.b)}`;
}
function V7() {
  return `#${is(this.r)}${is(this.g)}${is(this.b)}${is((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function i1() {
  const e = Ll(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${us(this.r)}, ${us(this.g)}, ${us(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function Ll(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function us(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function is(e) {
  return e = us(e), (e < 16 ? "0" : "") + e.toString(16);
}
function s1(e, t, n, r) {
  return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new Mn(e, t, n, r);
}
function m_(e) {
  if (e instanceof Mn)
    return new Mn(e.h, e.s, e.l, e.opacity);
  if (e instanceof Oi || (e = Vr(e)), !e)
    return new Mn();
  if (e instanceof Mn)
    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 Mn(o, a, c, e.opacity);
}
function _p(e, t, n, r) {
  return arguments.length === 1 ? m_(e) : new Mn(e, t, n, r ?? 1);
}
function Mn(e, t, n, r) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
Xo(Mn, _p, Lc(Oi, {
  brighter(e) {
    return e = e == null ? No : Math.pow(No, e), new Mn(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? ws : Math.pow(ws, e), new Mn(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 de(
      id(e >= 240 ? e - 240 : e + 120, i, r),
      id(e, i, r),
      id(e < 120 ? e + 240 : e - 120, i, r),
      this.opacity
    );
  },
  clamp() {
    return new Mn(o1(this.h), cu(this.s), cu(this.l), Ll(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 = Ll(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${o1(this.h)}, ${cu(this.s) * 100}%, ${cu(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function o1(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function cu(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function id(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 g_ = Math.PI / 180, b_ = 180 / Math.PI, Dl = 18, w_ = 0.96422, v_ = 1, __ = 0.82521, x_ = 4 / 29, ao = 6 / 29, S_ = 3 * ao * ao, Y7 = ao * ao * ao;
function M_(e) {
  if (e instanceof ir)
    return new ir(e.l, e.a, e.b, e.opacity);
  if (e instanceof Lr)
    return $_(e);
  e instanceof de || (e = yy(e));
  var t = cd(e.r), n = cd(e.g), r = cd(e.b), i = sd((0.2225045 * t + 0.7168786 * n + 0.0606169 * r) / v_), s, o;
  return t === n && n === r ? s = o = i : (s = sd((0.4360747 * t + 0.3850649 * n + 0.1430804 * r) / w_), o = sd((0.0139322 * t + 0.0971045 * n + 0.7141733 * r) / __)), new ir(116 * i - 16, 500 * (s - i), 200 * (i - o), e.opacity);
}
function xp(e, t, n, r) {
  return arguments.length === 1 ? M_(e) : new ir(e, t, n, r ?? 1);
}
function ir(e, t, n, r) {
  this.l = +e, this.a = +t, this.b = +n, this.opacity = +r;
}
Xo(ir, xp, Lc(Oi, {
  brighter(e) {
    return new ir(this.l + Dl * (e ?? 1), this.a, this.b, this.opacity);
  },
  darker(e) {
    return new ir(this.l - Dl * (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 = w_ * od(t), e = v_ * od(e), n = __ * od(n), new de(
      ad(3.1338561 * t - 1.6168667 * e - 0.4906146 * n),
      ad(-0.9787684 * t + 1.9161415 * e + 0.033454 * n),
      ad(0.0719453 * t - 0.2289914 * e + 1.4052427 * n),
      this.opacity
    );
  }
}));
function sd(e) {
  return e > Y7 ? Math.pow(e, 1 / 3) : e / S_ + x_;
}
function od(e) {
  return e > ao ? e * e * e : S_ * (e - x_);
}
function ad(e) {
  return 255 * (e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055);
}
function cd(e) {
  return (e /= 255) <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function W7(e) {
  if (e instanceof Lr)
    return new Lr(e.h, e.c, e.l, e.opacity);
  if (e instanceof ir || (e = M_(e)), e.a === 0 && e.b === 0)
    return new Lr(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
  var t = Math.atan2(e.b, e.a) * b_;
  return new Lr(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function Sp(e, t, n, r) {
  return arguments.length === 1 ? W7(e) : new Lr(e, t, n, r ?? 1);
}
function Lr(e, t, n, r) {
  this.h = +e, this.c = +t, this.l = +n, this.opacity = +r;
}
function $_(e) {
  if (isNaN(e.h))
    return new ir(e.l, 0, 0, e.opacity);
  var t = e.h * g_;
  return new ir(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
Xo(Lr, Sp, Lc(Oi, {
  brighter(e) {
    return new Lr(this.h, this.c, this.l + Dl * (e ?? 1), this.opacity);
  },
  darker(e) {
    return new Lr(this.h, this.c, this.l - Dl * (e ?? 1), this.opacity);
  },
  rgb() {
    return $_(this).rgb();
  }
}));
var A_ = -0.14861, my = 1.78277, gy = -0.29227, Xf = -0.90649, nc = 1.97294, a1 = nc * Xf, c1 = nc * my, u1 = my * gy - Xf * A_;
function X7(e) {
  if (e instanceof ls)
    return new ls(e.h, e.s, e.l, e.opacity);
  e instanceof de || (e = yy(e));
  var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = (u1 * r + a1 * t - c1 * n) / (u1 + a1 - c1), s = r - i, o = (nc * (n - i) - gy * s) / Xf, a = Math.sqrt(o * o + s * s) / (nc * i * (1 - i)), c = a ? Math.atan2(o, s) * b_ - 120 : NaN;
  return new ls(c < 0 ? c + 360 : c, a, i, e.opacity);
}
function cr(e, t, n, r) {
  return arguments.length === 1 ? X7(e) : new ls(e, t, n, r ?? 1);
}
function ls(e, t, n, r) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
Xo(ls, cr, Lc(Oi, {
  brighter(e) {
    return e = e == null ? No : Math.pow(No, e), new ls(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? ws : Math.pow(ws, e), new ls(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = isNaN(this.h) ? 0 : (this.h + 120) * g_, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), r = Math.cos(e), i = Math.sin(e);
    return new de(
      255 * (t + n * (A_ * r + my * i)),
      255 * (t + n * (gy * r + Xf * i)),
      255 * (t + n * (nc * r)),
      this.opacity
    );
  }
}));
function G7(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 H7(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 G7((n - r / t) * t, o, i, s, a);
  };
}
const Gf = (e) => () => e;
function I_(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function Z7(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 by(e, t) {
  var n = t - e;
  return n ? I_(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : Gf(isNaN(e) ? t : e);
}
function K7(e) {
  return (e = +e) == 1 ? Me : function(t, n) {
    return n - t ? Z7(t, n, e) : Gf(isNaN(t) ? n : t);
  };
}
function Me(e, t) {
  var n = t - e;
  return n ? I_(e, n) : Gf(isNaN(e) ? t : e);
}
const vs = function e(t) {
  var n = K7(t);
  function r(i, s) {
    var o = n((i = bn(i)).r, (s = bn(s)).r), a = n(i.g, s.g), c = n(i.b, s.b), u = Me(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 J7(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 = bn(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 Q7 = J7(H7);
function tN(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 eN(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function nN(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] = Go(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 rN(e, t) {
  var n = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(r) {
    return n.setTime(e * (1 - r) + t * r), n;
  };
}
function xe(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function iN(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] = Go(e[i], t[i]) : r[i] = t[i];
  return function(s) {
    for (i in n)
      r[i] = n[i](s);
    return r;
  };
}
var Mp = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, ud = new RegExp(Mp.source, "g");
function sN(e) {
  return function() {
    return e;
  };
}
function oN(e) {
  return function(t) {
    return e(t) + "";
  };
}
function T_(e, t) {
  var n = Mp.lastIndex = ud.lastIndex = 0, r, i, s, o = -1, a = [], c = [];
  for (e = e + "", t = t + ""; (r = Mp.exec(e)) && (i = ud.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: xe(r, i) })), n = ud.lastIndex;
  return n < t.length && (s = t.slice(n), a[o] ? a[o] += s : a[++o] = s), a.length < 2 ? c[0] ? oN(c[0].x) : sN(t) : (t = c.length, function(u) {
    for (var l = 0, h; l < t; ++l)
      a[(h = c[l]).i] = h.x(u);
    return a.join("");
  });
}
function Go(e, t) {
  var n = typeof t, r;
  return t == null || n === "boolean" ? Gf(t) : (n === "number" ? xe : n === "string" ? (r = Vr(t)) ? (t = r, vs) : T_ : t instanceof Vr ? vs : t instanceof Date ? rN : eN(t) ? tN : Array.isArray(t) ? nN : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? iN : xe)(e, t);
}
function wy(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
var l1 = 180 / Math.PI, $p = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function E_(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) * l1,
    skewX: Math.atan(c) * l1,
    scaleX: o,
    scaleY: a
  };
}
var uu;
function aN(e) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
  return t.isIdentity ? $p : E_(t.a, t.b, t.c, t.d, t.e, t.f);
}
function cN(e) {
  return e == null || (uu || (uu = document.createElementNS("http://www.w3.org/2000/svg", "g")), uu.setAttribute("transform", e), !(e = uu.transform.baseVal.consolidate())) ? $p : (e = e.matrix, E_(e.a, e.b, e.c, e.d, e.e, e.f));
}
function N_(e, t, n, r) {
  function i(u) {
    return u.length ? u.pop() + " " : "";
  }
  function s(u, l, h, f, d, p) {
    if (u !== h || l !== f) {
      var y = d.push("translate(", null, t, null, n);
      p.push({ i: y - 4, x: xe(u, h) }, { i: y - 2, x: xe(l, f) });
    } else
      (h || f) && d.push("translate(" + h + t + f + n);
  }
  function o(u, l, h, f) {
    u !== l ? (u - l > 180 ? l += 360 : l - u > 180 && (u += 360), f.push({ i: h.push(i(h) + "rotate(", null, r) - 2, x: xe(u, l) })) : l && h.push(i(h) + "rotate(" + l + r);
  }
  function a(u, l, h, f) {
    u !== l ? f.push({ i: h.push(i(h) + "skewX(", null, r) - 2, x: xe(u, l) }) : l && h.push(i(h) + "skewX(" + l + r);
  }
  function c(u, l, h, f, d, p) {
    if (u !== h || l !== f) {
      var y = d.push(i(d) + "scale(", null, ",", null, ")");
      p.push({ i: y - 4, x: xe(u, h) }, { i: y - 2, x: xe(l, f) });
    } else
      (h !== 1 || f !== 1) && d.push(i(d) + "scale(" + h + "," + f + ")");
  }
  return function(u, l) {
    var h = [], f = [];
    return u = e(u), l = e(l), s(u.translateX, u.translateY, l.translateX, l.translateY, h, f), o(u.rotate, l.rotate, h, f), a(u.skewX, l.skewX, h, f), c(u.scaleX, u.scaleY, l.scaleX, l.scaleY, h, f), u = l = null, function(d) {
      for (var p = -1, y = f.length, g; ++p < y; )
        h[(g = f[p]).i] = g.x(d);
      return h.join("");
    };
  };
}
var uN = N_(aN, "px, ", "px)", "deg)"), lN = N_(cN, ", ", ")", ")"), fN = 1e-12;
function f1(e) {
  return ((e = Math.exp(e)) + 1 / e) / 2;
}
function hN(e) {
  return ((e = Math.exp(e)) - 1 / e) / 2;
}
function dN(e) {
  return ((e = Math.exp(2 * e)) - 1) / (e + 1);
}
const pN = function e(t, n, r) {
  function i(s, o) {
    var a = s[0], c = s[1], u = s[2], l = o[0], h = o[1], f = o[2], d = l - a, p = h - c, y = d * d + p * p, g, m;
    if (y < fN)
      m = Math.log(f / u) / t, g = function($) {
        return [
          a + $ * d,
          c + $ * p,
          u * Math.exp(t * $ * m)
        ];
      };
    else {
      var b = Math.sqrt(y), w = (f * f - u * u + r * y) / (2 * u * n * b), v = (f * f - u * u - r * y) / (2 * f * n * b), _ = Math.log(Math.sqrt(w * w + 1) - w), x = Math.log(Math.sqrt(v * v + 1) - v);
      m = (x - _) / t, g = function($) {
        var T = $ * m, D = f1(_), M = u / (n * b) * (D * dN(t * T + _) - hN(_));
        return [
          a + M * d,
          c + M * p,
          u * D / f1(t * T + _)
        ];
      };
    }
    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 yN(e) {
  return function(t, n) {
    var r = e((t = _p(t)).h, (n = _p(n)).h), i = Me(t.s, n.s), s = Me(t.l, n.l), o = Me(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 mN = yN(by);
function gN(e, t) {
  var n = Me((e = xp(e)).l, (t = xp(t)).l), r = Me(e.a, t.a), i = Me(e.b, t.b), s = Me(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 bN(e) {
  return function(t, n) {
    var r = e((t = Sp(t)).h, (n = Sp(n)).h), i = Me(t.c, n.c), s = Me(t.l, n.l), o = Me(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 wN = bN(by);
function L_(e) {
  return function t(n) {
    n = +n;
    function r(i, s) {
      var o = e((i = cr(i)).h, (s = cr(s)).h), a = Me(i.s, s.s), c = Me(i.l, s.l), u = Me(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);
}
L_(by);
var vy = L_(Me);
function _y(e, t) {
  t === void 0 && (t = e, e = Go);
  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 Ln(e, t) {
  for (var n = new Array(t), r = 0; r < t; ++r)
    n[r] = e(r / (t - 1));
  return n;
}
var Lo = 0, Ma = 0, da = 0, D_ = 1e3, Ol, $a, Fl = 0, _s = 0, Hf = 0, rc = typeof performance == "object" && performance.now ? performance : Date, O_ = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
  setTimeout(e, 17);
};
function xy() {
  return _s || (O_(vN), _s = rc.now() + Hf);
}
function vN() {
  _s = 0;
}
function kl() {
  this._call = this._time = this._next = null;
}
kl.prototype = F_.prototype = {
  constructor: kl,
  restart: function(e, t, n) {
    if (typeof e != "function")
      throw new TypeError("callback is not a function");
    n = (n == null ? xy() : +n) + (t == null ? 0 : +t), !this._next && $a !== this && ($a ? $a._next = this : Ol = this, $a = this), this._call = e, this._time = n, Ap();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, Ap());
  }
};
function F_(e, t, n) {
  var r = new kl();
  return r.restart(e, t, n), r;
}
function _N() {
  xy(), ++Lo;
  for (var e = Ol, t; e; )
    (t = _s - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
  --Lo;
}
function h1() {
  _s = (Fl = rc.now()) + Hf, Lo = Ma = 0;
  try {
    _N();
  } finally {
    Lo = 0, SN(), _s = 0;
  }
}
function xN() {
  var e = rc.now(), t = e - Fl;
  t > D_ && (Hf -= t, Fl = e);
}
function SN() {
  for (var e, t = Ol, 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 : Ol = n);
  $a = e, Ap(r);
}
function Ap(e) {
  if (!Lo) {
    Ma && (Ma = clearTimeout(Ma));
    var t = e - _s;
    t > 24 ? (e < 1 / 0 && (Ma = setTimeout(h1, e - rc.now() - Hf)), da && (da = clearInterval(da))) : (da || (Fl = rc.now(), da = setInterval(xN, D_)), Lo = 1, O_(h1));
  }
}
function d1(e, t, n) {
  var r = new kl();
  return t = t == null ? 0 : +t, r.restart((i) => {
    r.stop(), e(i + t);
  }, t, n), r;
}
var MN = Vf("start", "end", "cancel", "interrupt"), $N = [], k_ = 0, p1 = 1, Ip = 2, ju = 3, y1 = 4, Tp = 5, qu = 6;
function Zf(e, t, n, r, i, s) {
  var o = e.__transition;
  if (!o)
    e.__transition = {};
  else if (n in o)
    return;
  AN(e, n, {
    name: t,
    index: r,
    // For context during callback.
    group: i,
    // For context during callback.
    on: MN,
    tween: $N,
    time: s.time,
    delay: s.delay,
    duration: s.duration,
    ease: s.ease,
    timer: null,
    state: k_
  });
}
function Sy(e, t) {
  var n = Cn(e, t);
  if (n.state > k_)
    throw new Error("too late; already scheduled");
  return n;
}
function lr(e, t) {
  var n = Cn(e, t);
  if (n.state > ju)
    throw new Error("too late; already running");
  return n;
}
function Cn(e, t) {
  var n = e.__transition;
  if (!n || !(n = n[t]))
    throw new Error("transition not found");
  return n;
}
function AN(e, t, n) {
  var r = e.__transition, i;
  r[t] = n, n.timer = F_(s, 0, n.time);
  function s(u) {
    n.state = p1, n.timer.restart(o, n.delay, n.time), n.delay <= u && o(u - n.delay);
  }
  function o(u) {
    var l, h, f, d;
    if (n.state !== p1)
      return c();
    for (l in r)
      if (d = r[l], d.name === n.name) {
        if (d.state === ju)
          return d1(o);
        d.state === y1 ? (d.state = qu, d.timer.stop(), d.on.call("interrupt", e, e.__data__, d.index, d.group), delete r[l]) : +l < t && (d.state = qu, d.timer.stop(), d.on.call("cancel", e, e.__data__, d.index, d.group), delete r[l]);
      }
    if (d1(function() {
      n.state === ju && (n.state = y1, n.timer.restart(a, n.delay, n.time), a(u));
    }), n.state = Ip, n.on.call("start", e, e.__data__, n.index, n.group), n.state === Ip) {
      for (n.state = ju, i = new Array(f = n.tween.length), l = 0, h = -1; l < f; ++l)
        (d = n.tween[l].value.call(e, e.__data__, n.index, n.group)) && (i[++h] = d);
      i.length = h + 1;
    }
  }
  function a(u) {
    for (var l = u < n.duration ? n.ease.call(null, u / n.duration) : (n.timer.restart(c), n.state = Tp, 1), h = -1, f = i.length; ++h < f; )
      i[h].call(e, l);
    n.state === Tp && (n.on.call("end", e, e.__data__, n.index, n.group), c());
  }
  function c() {
    n.state = qu, n.timer.stop(), delete r[t];
    for (var u in r)
      return;
    delete e.__transition;
  }
}
function co(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 > Ip && r.state < Tp, r.state = qu, r.timer.stop(), r.on.call(i ? "interrupt" : "cancel", e, e.__data__, r.index, r.group), delete n[o];
    }
    s && delete e.__transition;
  }
}
function IN(e) {
  return this.each(function() {
    co(this, e);
  });
}
function TN(e, t) {
  var n, r;
  return function() {
    var i = lr(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 EN(e, t, n) {
  var r, i;
  if (typeof n != "function")
    throw new Error();
  return function() {
    var s = lr(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 NN(e, t) {
  var n = this._id;
  if (e += "", arguments.length < 2) {
    for (var r = Cn(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 ? TN : EN)(n, e, t));
}
function My(e, t, n) {
  var r = e._id;
  return e.each(function() {
    var i = lr(this, r);
    (i.value || (i.value = {}))[t] = n.apply(this, arguments);
  }), function(i) {
    return Cn(i, r).value[t];
  };
}
function B_(e, t) {
  var n;
  return (typeof t == "number" ? xe : t instanceof Vr ? vs : (n = Vr(t)) ? (t = n, vs) : T_)(e, t);
}
function LN(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function DN(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function ON(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 FN(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 kN(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 BN(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 RN(e, t) {
  var n = Yf(e), r = n === "transform" ? lN : B_;
  return this.attrTween(e, typeof t == "function" ? (n.local ? BN : kN)(n, r, My(this, "attr." + e, t)) : t == null ? (n.local ? DN : LN)(n) : (n.local ? FN : ON)(n, r, t));
}
function CN(e, t) {
  return function(n) {
    this.setAttribute(e, t.call(this, n));
  };
}
function PN(e, t) {
  return function(n) {
    this.setAttributeNS(e.space, e.local, t.call(this, n));
  };
}
function zN(e, t) {
  var n, r;
  function i() {
    var s = t.apply(this, arguments);
    return s !== r && (n = (r = s) && PN(e, s)), n;
  }
  return i._value = t, i;
}
function UN(e, t) {
  var n, r;
  function i() {
    var s = t.apply(this, arguments);
    return s !== r && (n = (r = s) && CN(e, s)), n;
  }
  return i._value = t, i;
}
function jN(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 = Yf(e);
  return this.tween(n, (r.local ? zN : UN)(r, t));
}
function qN(e, t) {
  return function() {
    Sy(this, e).delay = +t.apply(this, arguments);
  };
}
function VN(e, t) {
  return t = +t, function() {
    Sy(this, e).delay = t;
  };
}
function YN(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? qN : VN)(t, e)) : Cn(this.node(), t).delay;
}
function WN(e, t) {
  return function() {
    lr(this, e).duration = +t.apply(this, arguments);
  };
}
function XN(e, t) {
  return t = +t, function() {
    lr(this, e).duration = t;
  };
}
function GN(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? WN : XN)(t, e)) : Cn(this.node(), t).duration;
}
function HN(e, t) {
  if (typeof t != "function")
    throw new Error();
  return function() {
    lr(this, e).ease = t;
  };
}
function ZN(e) {
  var t = this._id;
  return arguments.length ? this.each(HN(t, e)) : Cn(this.node(), t).ease;
}
function KN(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    if (typeof n != "function")
      throw new Error();
    lr(this, e).ease = n;
  };
}
function JN(e) {
  if (typeof e != "function")
    throw new Error();
  return this.each(KN(this._id, e));
}
function QN(e) {
  typeof e != "function" && (e = i_(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 Yr(r, this._parents, this._name, this._id);
}
function t9(e) {
  if (e._id !== this._id)
    throw new Error();
  for (var t = this._groups, n = e._groups, 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, h = o[a] = new Array(l), f, d = 0; d < l; ++d)
      (f = c[d] || u[d]) && (h[d] = f);
  for (; a < r; ++a)
    o[a] = t[a];
  return new Yr(o, this._parents, this._name, this._id);
}
function e9(e) {
  return (e + "").trim().split(/^|\s+/).every(function(t) {
    var n = t.indexOf(".");
    return n >= 0 && (t = t.slice(0, n)), !t || t === "start";
  });
}
function n9(e, t, n) {
  var r, i, s = e9(t) ? Sy : lr;
  return function() {
    var o = s(this, e), a = o.on;
    a !== r && (i = (r = a).copy()).on(t, n), o.on = i;
  };
}
function r9(e, t) {
  var n = this._id;
  return arguments.length < 2 ? Cn(this.node(), n).on.on(e) : this.each(n9(n, e, t));
}
function i9(e) {
  return function() {
    var t = this.parentNode;
    for (var n in this.__transition)
      if (+n !== e)
        return;
    t && t.removeChild(this);
  };
}
function s9() {
  return this.on("end.remove", i9(this._id));
}
function o9(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = dy(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, h, f = 0; f < c; ++f)
      (l = a[f]) && (h = e.call(l, l.__data__, f, a)) && ("__data__" in l && (h.__data__ = l.__data__), u[f] = h, Zf(u[f], t, n, f, u, Cn(l, n)));
  return new Yr(s, this._parents, t, n);
}
function a9(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = r_(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, h = 0; h < u; ++h)
      if (l = c[h]) {
        for (var f = e.call(l, l.__data__, h, c), d, p = Cn(l, n), y = 0, g = f.length; y < g; ++y)
          (d = f[y]) && Zf(d, t, n, y, f, p);
        s.push(f), o.push(l);
      }
  return new Yr(s, o, t, n);
}
var c9 = Nc.prototype.constructor;
function u9() {
  return new c9(this._groups, this._parents);
}
function l9(e, t) {
  var n, r, i;
  return function() {
    var s = Eo(this, e), o = (this.style.removeProperty(e), Eo(this, e));
    return s === o ? null : s === n && o === r ? i : i = t(n = s, r = o);
  };
}
function R_(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function f9(e, t, n) {
  var r, i = n + "", s;
  return function() {
    var o = Eo(this, e);
    return o === i ? null : o === r ? s : s = t(r = o, n);
  };
}
function h9(e, t, n) {
  var r, i, s;
  return function() {
    var o = Eo(this, e), a = n(this), c = a + "";
    return a == null && (c = a = (this.style.removeProperty(e), Eo(this, e))), o === c ? null : o === r && c === i ? s : (i = c, s = t(r = o, a));
  };
}
function d9(e, t) {
  var n, r, i, s = "style." + t, o = "end." + s, a;
  return function() {
    var c = lr(this, e), u = c.on, l = c.value[s] == null ? a || (a = R_(t)) : void 0;
    (u !== n || i !== l) && (r = (n = u).copy()).on(o, i = l), c.on = r;
  };
}
function p9(e, t, n) {
  var r = (e += "") == "transform" ? uN : B_;
  return t == null ? this.styleTween(e, l9(e, r)).on("end.style." + e, R_(e)) : typeof t == "function" ? this.styleTween(e, h9(e, r, My(this, "style." + e, t))).each(d9(this._id, e)) : this.styleTween(e, f9(e, r, t), n).on("end.style." + e, null);
}
function y9(e, t, n) {
  return function(r) {
    this.style.setProperty(e, t.call(this, r), n);
  };
}
function m9(e, t, n) {
  var r, i;
  function s() {
    var o = t.apply(this, arguments);
    return o !== i && (r = (i = o) && y9(e, o, n)), r;
  }
  return s._value = t, s;
}
function g9(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, m9(e, t, n ?? ""));
}
function b9(e) {
  return function() {
    this.textContent = e;
  };
}
function w9(e) {
  return function() {
    var t = e(this);
    this.textContent = t ?? "";
  };
}
function v9(e) {
  return this.tween("text", typeof e == "function" ? w9(My(this, "text", e)) : b9(e == null ? "" : e + ""));
}
function _9(e) {
  return function(t) {
    this.textContent = e.call(this, t);
  };
}
function x9(e) {
  var t, n;
  function r() {
    var i = e.apply(this, arguments);
    return i !== n && (t = (n = i) && _9(i)), t;
  }
  return r._value = e, r;
}
function S9(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, x9(e));
}
function M9() {
  for (var e = this._name, t = this._id, n = C_(), 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 = Cn(c, t);
        Zf(c, e, n, u, o, {
          time: l.time + l.delay + l.duration,
          delay: 0,
          duration: l.duration,
          ease: l.ease
        });
      }
  return new Yr(r, this._parents, e, n);
}
function $9() {
  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 = lr(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 A9 = 0;
function Yr(e, t, n, r) {
  this._groups = e, this._parents = t, this._name = n, this._id = r;
}
function C_() {
  return ++A9;
}
var mr = Nc.prototype;
Yr.prototype = {
  constructor: Yr,
  select: o9,
  selectAll: a9,
  selectChild: mr.selectChild,
  selectChildren: mr.selectChildren,
  filter: QN,
  merge: t9,
  selection: u9,
  transition: M9,
  call: mr.call,
  nodes: mr.nodes,
  node: mr.node,
  size: mr.size,
  empty: mr.empty,
  each: mr.each,
  on: r9,
  attr: RN,
  attrTween: jN,
  style: p9,
  styleTween: g9,
  text: v9,
  textTween: S9,
  remove: s9,
  tween: NN,
  delay: YN,
  duration: GN,
  ease: ZN,
  easeVarying: JN,
  end: $9,
  [Symbol.iterator]: mr[Symbol.iterator]
};
function I9(e) {
  return ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2;
}
var T9 = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: I9
};
function E9(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 N9(e) {
  var t, n;
  e instanceof Yr ? (t = e._id, e = e._name) : (t = C_(), (n = T9).time = xy(), 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]) && Zf(c, e, t, u, o, n || E9(c, t));
  return new Yr(r, this._parents, e, t);
}
Nc.prototype.interrupt = IN;
Nc.prototype.transition = N9;
const ld = (e) => () => e;
function L9(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 D9(e) {
  e.stopImmediatePropagation();
}
function fd(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
var m1 = { name: "drag" }, hd = { name: "space" }, ks = { name: "handle" }, Bs = { name: "center" };
const { abs: g1, max: we, min: ve } = Math;
function b1(e) {
  return [+e[0], +e[1]];
}
function Ep(e) {
  return [b1(e[0]), b1(e[1])];
}
var Vu = {
  name: "x",
  handles: ["w", "e"].map(ic),
  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]];
  }
}, Yu = {
  name: "y",
  handles: ["n", "s"].map(ic),
  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]];
  }
}, O9 = {
  name: "xy",
  handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(ic),
  input: function(e) {
    return e == null ? null : Ep(e);
  },
  output: function(e) {
    return e;
  }
}, gr = {
  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"
}, w1 = {
  e: "w",
  w: "e",
  nw: "ne",
  ne: "nw",
  se: "sw",
  sw: "se"
}, v1 = {
  n: "s",
  s: "n",
  nw: "sw",
  ne: "se",
  se: "ne",
  sw: "nw"
}, F9 = {
  overlay: 1,
  selection: 1,
  n: null,
  e: 1,
  s: null,
  w: -1,
  nw: -1,
  ne: 1,
  se: 1,
  sw: -1
}, k9 = {
  overlay: 1,
  selection: 1,
  n: -1,
  e: null,
  s: 1,
  w: null,
  nw: -1,
  ne: -1,
  se: 1,
  sw: 1
};
function ic(e) {
  return { type: e };
}
function B9(e) {
  return !e.ctrlKey && !e.button;
}
function R9() {
  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 C9() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function dd(e) {
  for (; !e.__brush; )
    if (!(e = e.parentNode))
      return;
  return e.__brush;
}
function P9(e) {
  return e[0][0] === e[1][0] || e[0][1] === e[1][1];
}
function z9() {
  return $y(Vu);
}
function U9() {
  return $y(Yu);
}
function j9() {
  return $y(O9);
}
function $y(e) {
  var t = R9, n = B9, r = C9, i = !0, s = Vf("start", "brush", "end"), o = 6, a;
  function c(g) {
    var m = g.property("__brush", y).selectAll(".overlay").data([ic("overlay")]);
    m.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", gr.overlay).merge(m).each(function() {
      var w = dd(this).extent;
      zt(this).attr("x", w[0][0]).attr("y", w[0][1]).attr("width", w[1][0] - w[0][0]).attr("height", w[1][1] - w[0][1]);
    }), g.selectAll(".selection").data([ic("selection")]).enter().append("rect").attr("class", "selection").attr("cursor", gr.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 gr[w.type];
    }), g.each(u).attr("fill", "none").attr("pointer-events", "all").on("mousedown.brush", f).filter(r).on("touchstart.brush", f).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, _ = l(w, arguments), x = v.selection, $ = e.input(typeof m == "function" ? m.apply(this, arguments) : m, v.extent), T = Go(x, $);
      function D(M) {
        v.selection = M === 1 && $ === null ? null : T(M), u.call(w), _.brush();
      }
      return x !== null && $ !== null ? D : D(1);
    }) : g.each(function() {
      var w = this, v = arguments, _ = w.__brush, x = e.input(typeof m == "function" ? m.apply(w, v) : m, _.extent), $ = l(w, v).beforestart();
      co(w), _.selection = x === null ? null : x, u.call(w), $.start(b).brush(b).end(b);
    });
  }, c.clear = function(g, m) {
    c.move(g, null, m);
  };
  function u() {
    var g = zt(this), m = dd(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 h(g, m, b);
  }
  function h(g, m, b) {
    this.that = g, this.args = m, this.state = g.__brush, this.active = 0, this.clean = b;
  }
  h.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 = zt(this.that).datum();
      s.call(
        g,
        this.that,
        new L9(g, {
          sourceEvent: m,
          target: c,
          selection: e.output(this.state.selection),
          mode: b,
          dispatch: s
        }),
        w
      );
    }
  };
  function f(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" ? m1 : i && g.altKey ? Bs : ks, v = e === Yu ? null : F9[b], _ = e === Vu ? null : k9[b], x = dd(m), $ = x.extent, T = x.selection, D = $[0][0], M, A, L = $[0][1], k, S, I = $[1][0], E, N, O = $[1][1], R, C, j = 0, z = 0, X, H = v && _ && i && g.shiftKey, J, K, W = Array.from(g.touches || [g], (Z) => {
      const Ct = Z.identifier;
      return Z = _n(Z, m), Z.point0 = Z.slice(), Z.identifier = Ct, Z;
    });
    co(m);
    var Y = l(m, arguments, !0).beforestart();
    if (b === "overlay") {
      T && (X = !0);
      const Z = [W[0], W[1] || W[0]];
      x.selection = T = [[
        M = e === Yu ? D : ve(Z[0][0], Z[1][0]),
        k = e === Vu ? L : ve(Z[0][1], Z[1][1])
      ], [
        E = e === Yu ? I : we(Z[0][0], Z[1][0]),
        R = e === Vu ? O : we(Z[0][1], Z[1][1])
      ]], W.length > 1 && Q(g);
    } else
      M = T[0][0], k = T[0][1], E = T[1][0], R = T[1][1];
    A = M, S = k, N = E, C = R;
    var U = zt(m).attr("pointer-events", "none"), V = U.selectAll(".overlay").attr("cursor", gr[b]);
    if (g.touches)
      Y.moved = P, Y.ended = at;
    else {
      var G = zt(g.view).on("mousemove.brush", P, !0).on("mouseup.brush", at, !0);
      i && G.on("keydown.brush", Ot, !0).on("keyup.brush", xt, !0), p_(g.view);
    }
    u.call(m), Y.start(g, w.name);
    function P(Z) {
      for (const Ct of Z.changedTouches || [Z])
        for (const zn of W)
          zn.identifier === Ct.identifier && (zn.cur = _n(Ct, m));
      if (H && !J && !K && W.length === 1) {
        const Ct = W[0];
        g1(Ct.cur[0] - Ct[0]) > g1(Ct.cur[1] - Ct[1]) ? K = !0 : J = !0;
      }
      for (const Ct of W)
        Ct.cur && (Ct[0] = Ct.cur[0], Ct[1] = Ct.cur[1]);
      X = !0, fd(Z), Q(Z);
    }
    function Q(Z) {
      const Ct = W[0], zn = Ct.point0;
      var Xe;
      switch (j = Ct[0] - zn[0], z = Ct[1] - zn[1], w) {
        case hd:
        case m1: {
          v && (j = we(D - M, ve(I - E, j)), A = M + j, N = E + j), _ && (z = we(L - k, ve(O - R, z)), S = k + z, C = R + z);
          break;
        }
        case ks: {
          W[1] ? (v && (A = we(D, ve(I, W[0][0])), N = we(D, ve(I, W[1][0])), v = 1), _ && (S = we(L, ve(O, W[0][1])), C = we(L, ve(O, W[1][1])), _ = 1)) : (v < 0 ? (j = we(D - M, ve(I - M, j)), A = M + j, N = E) : v > 0 && (j = we(D - E, ve(I - E, j)), A = M, N = E + j), _ < 0 ? (z = we(L - k, ve(O - k, z)), S = k + z, C = R) : _ > 0 && (z = we(L - R, ve(O - R, z)), S = k, C = R + z));
          break;
        }
        case Bs: {
          v && (A = we(D, ve(I, M - j * v)), N = we(D, ve(I, E + j * v))), _ && (S = we(L, ve(O, k - z * _)), C = we(L, ve(O, R + z * _)));
          break;
        }
      }
      N < A && (v *= -1, Xe = M, M = E, E = Xe, Xe = A, A = N, N = Xe, b in w1 && V.attr("cursor", gr[b = w1[b]])), C < S && (_ *= -1, Xe = k, k = R, R = Xe, Xe = S, S = C, C = Xe, b in v1 && V.attr("cursor", gr[b = v1[b]])), x.selection && (T = x.selection), J && (A = T[0][0], N = T[1][0]), K && (S = T[0][1], C = T[1][1]), (T[0][0] !== A || T[0][1] !== S || T[1][0] !== N || T[1][1] !== C) && (x.selection = [[A, S], [N, C]], u.call(m), Y.brush(Z, w.name));
    }
    function at(Z) {
      if (D9(Z), Z.touches) {
        if (Z.touches.length)
          return;
        a && clearTimeout(a), a = setTimeout(function() {
          a = null;
        }, 500);
      } else
        y_(Z.view, X), G.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
      U.attr("pointer-events", "all"), V.attr("cursor", gr.overlay), x.selection && (T = x.selection), P9(T) && (x.selection = null, u.call(m)), Y.end(Z, w.name);
    }
    function Ot(Z) {
      switch (Z.keyCode) {
        case 16: {
          H = v && _;
          break;
        }
        case 18: {
          w === ks && (v && (E = N - j * v, M = A + j * v), _ && (R = C - z * _, k = S + z * _), w = Bs, Q(Z));
          break;
        }
        case 32: {
          (w === ks || w === Bs) && (v < 0 ? E = N - j : v > 0 && (M = A - j), _ < 0 ? R = C - z : _ > 0 && (k = S - z), w = hd, V.attr("cursor", gr.selection), Q(Z));
          break;
        }
        default:
          return;
      }
      fd(Z);
    }
    function xt(Z) {
      switch (Z.keyCode) {
        case 16: {
          H && (J = K = H = !1, Q(Z));
          break;
        }
        case 18: {
          w === Bs && (v < 0 ? E = N : v > 0 && (M = A), _ < 0 ? R = C : _ > 0 && (k = S), w = ks, Q(Z));
          break;
        }
        case 32: {
          w === hd && (Z.altKey ? (v && (E = N - j * v, M = A + j * v), _ && (R = C - z * _, k = S + z * _), w = Bs) : (v < 0 ? E = N : v > 0 && (M = A), _ < 0 ? R = C : _ > 0 && (k = S), w = ks), V.attr("cursor", gr[b]), Q(Z));
          break;
        }
        default:
          return;
      }
      fd(Z);
    }
  }
  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 = Ep(t.apply(this, arguments)), g.dim = e, g;
  }
  return c.extent = function(g) {
    return arguments.length ? (t = typeof g == "function" ? g : ld(Ep(g)), c) : t;
  }, c.filter = function(g) {
    return arguments.length ? (n = typeof g == "function" ? g : ld(!!g), c) : n;
  }, c.touchable = function(g) {
    return arguments.length ? (r = typeof g == "function" ? g : ld(!!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 Np = Math.PI, Lp = 2 * Np, Xi = 1e-6, q9 = Lp - Xi;
function P_(e) {
  this._ += e[0];
  for (let t = 1, n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function V9(e) {
  let t = Math.floor(e);
  if (!(t >= 0))
    throw new Error(`invalid digits: ${e}`);
  if (t > 15)
    return P_;
  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 z_ = class {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? P_ : V9(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, h = a - n, f = l * l + h * h;
    if (this._x1 === null)
      this._append`M${this._x1 = t},${this._y1 = n}`;
    else if (f > Xi)
      if (!(Math.abs(h * c - u * l) > Xi) || !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(f), w = s * Math.tan((Np - Math.acos((y + f - g) / (2 * m * b))) / 2), v = w / b, _ = w / m;
        Math.abs(v - 1) > Xi && this._append`L${t + v * l},${n + v * h}`, this._append`A${s},${s},0,0,${+(h * d > l * p)},${this._x1 = t + _ * c},${this._y1 = n + _ * 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, h = 1 ^ o, f = o ? i - s : s - i;
    this._x1 === null ? this._append`M${u},${l}` : (Math.abs(this._x1 - u) > Xi || Math.abs(this._y1 - l) > Xi) && this._append`L${u},${l}`, r && (f < 0 && (f = f % Lp + Lp), f > q9 ? this._append`A${r},${r},0,1,${h},${t - a},${n - c}A${r},${r},0,1,${h},${this._x1 = u},${this._y1 = l}` : f > Xi && this._append`A${r},${r},0,${+(f >= Np)},${h},${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 Dr(e = 3) {
  return new z_(+e);
}
var Y9 = Array.prototype, U_ = Y9.slice;
function W9(e, t) {
  return e - t;
}
function X9(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 ci = (e) => () => e;
function G9(e, t) {
  for (var n = -1, r = t.length, i; ++n < r; )
    if (i = H9(e, t[n]))
      return i;
  return 0;
}
function H9(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], h = e[a], f = h[0], d = h[1];
    if (Z9(c, h, t))
      return 0;
    l > r != d > r && n < (f - u) * (r - l) / (d - l) + u && (i = -i);
  }
  return i;
}
function Z9(e, t, n) {
  var r;
  return K9(e, t, n) && J9(e[r = +(e[0] === t[0])], n[r], t[r]);
}
function K9(e, t, n) {
  return (t[0] - e[0]) * (n[1] - e[1]) === (n[0] - e[0]) * (t[1] - e[1]);
}
function J9(e, t, n) {
  return e <= t && t <= n || n <= t && t <= e;
}
function Q9() {
}
var br = [
  [],
  [[[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 Bl() {
  var e = 1, t = 1, n = ly, r = c;
  function i(u) {
    var l = n(u);
    if (Array.isArray(l))
      l = l.slice().sort(W9);
    else {
      const h = Se(u, tL);
      for (l = Si(...Kv(h[0], h[1], l), l); l[l.length - 1] >= h[1]; )
        l.pop();
      for (; l[1] < h[0]; )
        l.shift();
    }
    return l.map((h) => s(u, h));
  }
  function s(u, l) {
    const h = l == null ? NaN : +l;
    if (isNaN(h))
      throw new Error(`invalid value: ${l}`);
    var f = [], d = [];
    return o(u, h, function(p) {
      r(p, u, h), X9(p) > 0 ? f.push([p]) : d.push(p);
    }), d.forEach(function(p) {
      for (var y = 0, g = f.length, m; y < g; ++y)
        if (G9((m = f[y])[0], p) !== -1) {
          m.push(p);
          return;
        }
    }), {
      type: "MultiPolygon",
      value: l,
      coordinates: f
    };
  }
  function o(u, l, h) {
    var f = new Array(), d = new Array(), p, y, g, m, b, w;
    for (p = y = -1, m = Vi(u[0], l), br[m << 1].forEach(v); ++p < e - 1; )
      g = m, m = Vi(u[p + 1], l), br[g | m << 1].forEach(v);
    for (br[m << 0].forEach(v); ++y < t - 1; ) {
      for (p = -1, m = Vi(u[y * e + e], l), b = Vi(u[y * e], l), br[m << 1 | b << 2].forEach(v); ++p < e - 1; )
        g = m, m = Vi(u[y * e + e + p + 1], l), w = b, b = Vi(u[y * e + p + 1], l), br[g | m << 1 | b << 2 | w << 3].forEach(v);
      br[m | b << 3].forEach(v);
    }
    for (p = -1, b = u[y * e] >= l, br[b << 2].forEach(v); ++p < e - 1; )
      w = b, b = Vi(u[y * e + p + 1], l), br[b << 2 | w << 3].forEach(v);
    br[b << 3].forEach(v);
    function v(_) {
      var x = [_[0][0] + p, _[0][1] + y], $ = [_[1][0] + p, _[1][1] + y], T = a(x), D = a($), M, A;
      (M = d[T]) ? (A = f[D]) ? (delete d[M.end], delete f[A.start], M === A ? (M.ring.push($), h(M.ring)) : f[M.start] = d[A.end] = { start: M.start, end: A.end, ring: M.ring.concat(A.ring) }) : (delete d[M.end], M.ring.push($), d[M.end = D] = M) : (M = f[D]) ? (A = d[T]) ? (delete f[M.start], delete d[A.end], M === A ? (M.ring.push($), h(M.ring)) : f[A.start] = d[M.end] = { start: A.start, end: M.end, ring: A.ring.concat(M.ring) }) : (delete f[M.start], M.ring.unshift(x), f[M.start = T] = M) : f[T] = d[D] = { start: T, end: D, ring: [x, $] };
    }
  }
  function a(u) {
    return u[0] * 2 + u[1] * (e + 1) * 4;
  }
  function c(u, l, h) {
    u.forEach(function(f) {
      var d = f[0], p = f[1], y = d | 0, g = p | 0, m = pd(l[g * e + y]);
      d > 0 && d < e && y === d && (f[0] = _1(d, pd(l[g * e + y - 1]), m, h)), p > 0 && p < t && g === p && (f[1] = _1(p, pd(l[(g - 1) * e + y]), m, h));
    });
  }
  return i.contour = s, i.size = function(u) {
    if (!arguments.length)
      return [e, t];
    var l = Math.floor(u[0]), h = Math.floor(u[1]);
    if (!(l >= 0 && h >= 0))
      throw new Error("invalid size");
    return e = l, t = h, i;
  }, i.thresholds = function(u) {
    return arguments.length ? (n = typeof u == "function" ? u : Array.isArray(u) ? ci(U_.call(u)) : ci(u), i) : n;
  }, i.smooth = function(u) {
    return arguments.length ? (r = u ? c : Q9, i) : r === c;
  }, i;
}
function tL(e) {
  return isFinite(e) ? e : NaN;
}
function Vi(e, t) {
  return e == null ? !1 : +e >= t;
}
function pd(e) {
  return e == null || isNaN(e = +e) ? -1 / 0 : e;
}
function _1(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 eL(e) {
  return e[0];
}
function nL(e) {
  return e[1];
}
function rL() {
  return 1;
}
function iL() {
  var e = eL, t = nL, n = rL, r = 960, i = 500, s = 20, o = 2, a = s * 3, c = r + a * 2 >> o, u = i + a * 2 >> o, l = ci(20);
  function h(b) {
    var w = new Float32Array(c * u), v = Math.pow(2, -o), _ = -1;
    for (const k of b) {
      var x = (e(k, ++_, b) + a) * v, $ = (t(k, _, b) + a) * v, T = +n(k, _, b);
      if (T && x >= 0 && x < c && $ >= 0 && $ < u) {
        var D = Math.floor(x), M = Math.floor($), A = x - D - 0.5, L = $ - M - 0.5;
        w[D + M * c] += (1 - A) * (1 - L) * T, w[D + 1 + M * c] += A * (1 - L) * T, w[D + 1 + (M + 1) * c] += A * L * T, w[D + (M + 1) * c] += (1 - A) * L * T;
      }
    }
    return Yv({ data: w, width: c, height: u }, s * v), w;
  }
  function f(b) {
    var w = h(b), v = l(w), _ = Math.pow(2, 2 * o);
    return Array.isArray(v) || (v = Si(Number.MIN_VALUE, te(w) / _, v)), Bl().size([c, u]).thresholds(v.map((x) => x * _))(w).map((x, $) => (x.value = +v[$], d(x)));
  }
  f.contours = function(b) {
    var w = h(b), v = Bl().size([c, u]), _ = Math.pow(2, 2 * o), x = ($) => {
      $ = +$;
      var T = d(v.contour(w, $ * _));
      return T.value = $, T;
    };
    return Object.defineProperty(x, "max", { get: () => te(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, f;
  }
  return f.x = function(b) {
    return arguments.length ? (e = typeof b == "function" ? b : ci(+b), f) : e;
  }, f.y = function(b) {
    return arguments.length ? (t = typeof b == "function" ? b : ci(+b), f) : t;
  }, f.weight = function(b) {
    return arguments.length ? (n = typeof b == "function" ? b : ci(+b), f) : n;
  }, f.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();
  }, f.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();
  }, f.thresholds = function(b) {
    return arguments.length ? (l = typeof b == "function" ? b : Array.isArray(b) ? ci(U_.call(b)) : ci(b), f) : l;
  }, f.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();
  }, f;
}
const Pr = 11102230246251565e-32, _e = 134217729, sL = (3 + 8 * Pr) * Pr;
function yd(e, t, n, r, i) {
  let s, o, a, c, u = t[0], l = r[0], h = 0, f = 0;
  l > u == l > -u ? (s = u, u = t[++h]) : (s = l, l = r[++f]);
  let d = 0;
  if (h < e && f < n)
    for (l > u == l > -u ? (o = u + s, a = s - (o - u), u = t[++h]) : (o = l + s, a = s - (o - l), l = r[++f]), s = o, a !== 0 && (i[d++] = a); h < e && f < n; )
      l > u == l > -u ? (o = s + u, c = o - s, a = s - (o - c) + (u - c), u = t[++h]) : (o = s + l, c = o - s, a = s - (o - c) + (l - c), l = r[++f]), s = o, a !== 0 && (i[d++] = a);
  for (; h < e; )
    o = s + u, c = o - s, a = s - (o - c) + (u - c), u = t[++h], s = o, a !== 0 && (i[d++] = a);
  for (; f < n; )
    o = s + l, c = o - s, a = s - (o - c) + (l - c), l = r[++f], s = o, a !== 0 && (i[d++] = a);
  return (s !== 0 || d === 0) && (i[d++] = s), d;
}
function oL(e, t) {
  let n = t[0];
  for (let r = 1; r < e; r++)
    n += t[r];
  return n;
}
function Dc(e) {
  return new Float64Array(e);
}
const aL = (3 + 16 * Pr) * Pr, cL = (2 + 12 * Pr) * Pr, uL = (9 + 64 * Pr) * Pr * Pr, Rs = Dc(4), x1 = Dc(8), S1 = Dc(12), M1 = Dc(16), Ae = Dc(4);
function lL(e, t, n, r, i, s, o) {
  let a, c, u, l, h, f, d, p, y, g, m, b, w, v, _, x, $, T;
  const D = e - i, M = n - i, A = t - s, L = r - s;
  v = D * L, f = _e * D, d = f - (f - D), p = D - d, f = _e * L, y = f - (f - L), g = L - y, _ = p * g - (v - d * y - p * y - d * g), x = A * M, f = _e * A, d = f - (f - A), p = A - d, f = _e * M, y = f - (f - M), g = M - y, $ = p * g - (x - d * y - p * y - d * g), m = _ - $, h = _ - m, Rs[0] = _ - (m + h) + (h - $), b = v + m, h = b - v, w = v - (b - h) + (m - h), m = w - x, h = w - m, Rs[1] = w - (m + h) + (h - x), T = b + m, h = T - b, Rs[2] = b - (T - h) + (m - h), Rs[3] = T;
  let k = oL(4, Rs), S = cL * o;
  if (k >= S || -k >= S || (h = e - D, a = e - (D + h) + (h - i), h = n - M, u = n - (M + h) + (h - i), h = t - A, c = t - (A + h) + (h - s), h = r - L, l = r - (L + h) + (h - s), a === 0 && c === 0 && u === 0 && l === 0) || (S = uL * o + sL * Math.abs(k), k += D * l + L * a - (A * u + M * c), k >= S || -k >= S))
    return k;
  v = a * L, f = _e * a, d = f - (f - a), p = a - d, f = _e * L, y = f - (f - L), g = L - y, _ = p * g - (v - d * y - p * y - d * g), x = c * M, f = _e * c, d = f - (f - c), p = c - d, f = _e * M, y = f - (f - M), g = M - y, $ = p * g - (x - d * y - p * y - d * g), m = _ - $, h = _ - m, Ae[0] = _ - (m + h) + (h - $), b = v + m, h = b - v, w = v - (b - h) + (m - h), m = w - x, h = w - m, Ae[1] = w - (m + h) + (h - x), T = b + m, h = T - b, Ae[2] = b - (T - h) + (m - h), Ae[3] = T;
  const I = yd(4, Rs, 4, Ae, x1);
  v = D * l, f = _e * D, d = f - (f - D), p = D - d, f = _e * l, y = f - (f - l), g = l - y, _ = p * g - (v - d * y - p * y - d * g), x = A * u, f = _e * A, d = f - (f - A), p = A - d, f = _e * u, y = f - (f - u), g = u - y, $ = p * g - (x - d * y - p * y - d * g), m = _ - $, h = _ - m, Ae[0] = _ - (m + h) + (h - $), b = v + m, h = b - v, w = v - (b - h) + (m - h), m = w - x, h = w - m, Ae[1] = w - (m + h) + (h - x), T = b + m, h = T - b, Ae[2] = b - (T - h) + (m - h), Ae[3] = T;
  const E = yd(I, x1, 4, Ae, S1);
  v = a * l, f = _e * a, d = f - (f - a), p = a - d, f = _e * l, y = f - (f - l), g = l - y, _ = p * g - (v - d * y - p * y - d * g), x = c * u, f = _e * c, d = f - (f - c), p = c - d, f = _e * u, y = f - (f - u), g = u - y, $ = p * g - (x - d * y - p * y - d * g), m = _ - $, h = _ - m, Ae[0] = _ - (m + h) + (h - $), b = v + m, h = b - v, w = v - (b - h) + (m - h), m = w - x, h = w - m, Ae[1] = w - (m + h) + (h - x), T = b + m, h = T - b, Ae[2] = b - (T - h) + (m - h), Ae[3] = T;
  const N = yd(E, S1, 4, Ae, M1);
  return M1[N - 1];
}
function lu(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) >= aL * u ? c : -lL(e, t, n, r, i, s, u);
}
const $1 = Math.pow(2, -52), fu = new Uint32Array(512);
class Rl {
  static from(t, n = yL, r = mL) {
    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 Rl(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 M = 0; M < o; M++) {
      const A = t[2 * M], L = t[2 * M + 1];
      A < a && (a = A), L < c && (c = L), A > u && (u = A), L > l && (l = L), this._ids[M] = M;
    }
    const h = (a + u) / 2, f = (c + l) / 2;
    let d = 1 / 0, p, y, g;
    for (let M = 0; M < o; M++) {
      const A = md(h, f, t[2 * M], t[2 * M + 1]);
      A < d && (p = M, d = A);
    }
    const m = t[2 * p], b = t[2 * p + 1];
    d = 1 / 0;
    for (let M = 0; M < o; M++) {
      if (M === p)
        continue;
      const A = md(m, b, t[2 * M], t[2 * M + 1]);
      A < d && A > 0 && (y = M, d = A);
    }
    let w = t[2 * y], v = t[2 * y + 1], _ = 1 / 0;
    for (let M = 0; M < o; M++) {
      if (M === p || M === y)
        continue;
      const A = dL(m, b, w, v, t[2 * M], t[2 * M + 1]);
      A < _ && (g = M, _ = A);
    }
    let x = t[2 * g], $ = t[2 * g + 1];
    if (_ === 1 / 0) {
      for (let L = 0; L < o; L++)
        this._dists[L] = t[2 * L] - t[0] || t[2 * L + 1] - t[1];
      Zs(this._ids, this._dists, 0, o - 1);
      const M = new Uint32Array(o);
      let A = 0;
      for (let L = 0, k = -1 / 0; L < o; L++) {
        const S = this._ids[L];
        this._dists[S] > k && (M[A++] = S, k = this._dists[S]);
      }
      this.hull = M.subarray(0, A), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
      return;
    }
    if (lu(m, b, w, v, x, $) < 0) {
      const M = y, A = w, L = v;
      y = g, w = x, v = $, g = M, x = A, $ = L;
    }
    const T = pL(m, b, w, v, x, $);
    this._cx = T.x, this._cy = T.y;
    for (let M = 0; M < o; M++)
      this._dists[M] = md(t[2 * M], t[2 * M + 1], T.x, T.y);
    Zs(this._ids, this._dists, 0, o - 1), this._hullStart = p;
    let D = 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(x, $)] = g, this.trianglesLen = 0, this._addTriangle(p, y, g, -1, -1, -1);
    for (let M = 0, A, L; M < this._ids.length; M++) {
      const k = this._ids[M], S = t[2 * k], I = t[2 * k + 1];
      if (M > 0 && Math.abs(S - A) <= $1 && Math.abs(I - L) <= $1 || (A = S, L = I, k === p || k === y || k === g))
        continue;
      let E = 0;
      for (let j = 0, z = this._hashKey(S, I); j < this._hashSize && (E = s[(z + j) % this._hashSize], !(E !== -1 && E !== r[E])); j++)
        ;
      E = n[E];
      let N = E, O;
      for (; O = r[N], lu(S, I, t[2 * N], t[2 * N + 1], t[2 * O], t[2 * O + 1]) >= 0; )
        if (N = O, N === E) {
          N = -1;
          break;
        }
      if (N === -1)
        continue;
      let R = this._addTriangle(N, k, r[N], -1, -1, i[N]);
      i[k] = this._legalize(R + 2), i[N] = R, D++;
      let C = r[N];
      for (; O = r[C], lu(S, I, t[2 * C], t[2 * C + 1], t[2 * O], t[2 * O + 1]) < 0; )
        R = this._addTriangle(C, k, O, i[k], -1, i[C]), i[k] = this._legalize(R + 2), r[C] = C, D--, C = O;
      if (N === E)
        for (; O = n[N], lu(S, I, t[2 * O], t[2 * O + 1], t[2 * N], t[2 * N + 1]) < 0; )
          R = this._addTriangle(O, k, N, -1, i[N], i[O]), this._legalize(R + 2), i[O] = R, r[N] = N, D--, N = O;
      this._hullStart = n[k] = N, r[N] = n[C] = k, r[k] = C, s[this._hashKey(S, I)] = k, s[this._hashKey(t[2 * N], t[2 * N + 1])] = N;
    }
    this.hull = new Uint32Array(D);
    for (let M = 0, A = this._hullStart; M < D; M++)
      this.hull[M] = A, A = r[A];
    this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
  }
  _hashKey(t, n) {
    return Math.floor(fL(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 = fu[--s];
        continue;
      }
      const u = a - a % 3, l = c + (t + 1) % 3, h = u + (a + 2) % 3, f = n[o], d = n[t], p = n[l], y = n[h];
      if (hL(
        i[2 * f],
        i[2 * f + 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] = f;
        const m = r[h];
        if (m === -1) {
          let w = this._hullStart;
          do {
            if (this._hullTri[w] === h) {
              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, h);
        const b = u + (a + 1) % 3;
        s < fu.length && (fu[s++] = b);
      } else {
        if (s === 0)
          break;
        t = fu[--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 fL(e, t) {
  const n = e / (Math.abs(e) + Math.abs(t));
  return (t > 0 ? 3 - n : 1 + n) / 4;
}
function md(e, t, n, r) {
  const i = e - n, s = t - r;
  return i * i + s * s;
}
function hL(e, t, n, r, i, s, o, a) {
  const c = e - o, u = t - a, l = n - o, h = r - a, f = i - o, d = s - a, p = c * c + u * u, y = l * l + h * h, g = f * f + d * d;
  return c * (h * g - y * d) - u * (l * g - y * f) + p * (l * d - h * f) < 0;
}
function dL(e, t, n, r, i, s) {
  const o = n - e, a = r - t, c = i - e, u = s - t, l = o * o + a * a, h = c * c + u * u, f = 0.5 / (o * u - a * c), d = (u * l - a * h) * f, p = (o * h - c * l) * f;
  return d * d + p * p;
}
function pL(e, t, n, r, i, s) {
  const o = n - e, a = r - t, c = i - e, u = s - t, l = o * o + a * a, h = c * c + u * u, f = 0.5 / (o * u - a * c), d = e + (u * l - a * h) * f, p = t + (o * h - c * l) * f;
  return { x: d, y: p };
}
function Zs(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;
    pa(e, i, s), t[e[n]] > t[e[r]] && pa(e, n, r), t[e[s]] > t[e[r]] && pa(e, s, r), t[e[n]] > t[e[s]] && pa(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;
      pa(e, s, o);
    }
    e[n + 1] = e[o], e[o] = a, r - s + 1 >= o - n ? (Zs(e, t, s, r), Zs(e, t, n, o - 1)) : (Zs(e, t, n, o - 1), Zs(e, t, s, r));
  }
}
function pa(e, t, n) {
  const r = e[t];
  e[t] = e[n], e[n] = r;
}
function yL(e) {
  return e[0];
}
function mL(e) {
  return e[1];
}
const A1 = 1e-6;
class ss {
  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) > A1 || Math.abs(this._y1 - s) > A1) && (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 Dp {
  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 gL = 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, _ = r[y + 1] * 2, x = r[y + 2] * 2, $ = t[v], T = t[v + 1], D = t[_], M = t[_ + 1], A = t[x], L = t[x + 1], k = D - $, S = M - T, I = A - $, E = L - T, N = (k * E - S * I) * 2;
      if (Math.abs(N) < 1e-9) {
        if (s === void 0) {
          s = o = 0;
          for (const R of n)
            s += t[R * 2], o += t[R * 2 + 1];
          s /= n.length, o /= n.length;
        }
        const O = 1e9 * Math.sign((s - $) * E - (o - T) * I);
        b = ($ + A) / 2 - O * E, w = (T + L) / 2 + O * I;
      } else {
        const O = 1 / N, R = k * k + S * S, C = I * I + E * E;
        b = $ + (E * R - S * C) * O, w = T + (k * C - I * R) * O;
      }
      a[g] = b, a[g + 1] = w;
    }
    let c = n[n.length - 1], u, l = c * 4, h, f = 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, h = f, d = p, l = c * 4, f = t[2 * c], p = t[2 * c + 1], i[u + 2] = i[l] = d - p, i[u + 3] = i[l + 1] = f - h;
  }
  render(t) {
    const n = t == null ? t = new ss() : void 0, { delaunay: { halfedges: r, inedges: i, hull: s }, circumcenters: o, vectors: a } = this;
    if (s.length <= 1)
      return null;
    for (let l = 0, h = r.length; l < h; ++l) {
      const f = r[l];
      if (f < l)
        continue;
      const d = Math.floor(l / 3) * 2, p = Math.floor(f / 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 h = Math.floor(i[u] / 3) * 2, f = o[h], d = o[h + 1], p = c * 4, y = this._project(f, d, a[p + 2], a[p + 3]);
      y && this._renderSegment(f, d, y[0], y[1], t);
    }
    return n && n.value();
  }
  renderBounds(t) {
    const n = t == null ? t = new ss() : 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 ss() : 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 Dp();
    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), h, f = 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)
        h = f, f = 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, h = f, f = this._edgecode(y, g), h && f && this._edge(t, h, f, i, i.length), i ? i.push(y, g) : i = [y, g];
        }
        h = f, f = this._edgecode(m, b), h && f && this._edge(t, h, f, i, i.length), i ? i.push(m, b) : i = [m, b];
      }
    if (i)
      h = f, f = this._edgecode(i[0], i[1]), h && f && this._edge(t, h, f, 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, h, f = this._edgecode(a[l - 2], a[l - 1]); u < l; u += 2)
        h = f, f = this._edgecode(a[u], a[u + 1]), h && f && (u = this._edge(t, h, f, 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 bL = 2 * Math.PI, Cs = Math.pow;
function wL(e) {
  return e[0];
}
function vL(e) {
  return e[1];
}
function _L(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 xL(e, t, n) {
  return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n];
}
class Wr {
  static from(t, n = wL, r = vL, i) {
    return new Wr("length" in t ? SL(t, n, r, i) : Float64Array.from(ML(t, n, r, i)));
  }
  constructor(t) {
    this._delaunator = new Rl(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 && _L(t)) {
      this.collinear = Int32Array.from({ length: n.length / 2 }, (f, d) => d).sort((f, d) => n[2 * f] - n[2 * d] || n[2 * f + 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]], h = 1e-8 * Math.hypot(l[3] - l[1], l[2] - l[0]);
      for (let f = 0, d = n.length / 2; f < d; ++f) {
        const p = xL(n[2 * f], n[2 * f + 1], h);
        n[2 * f] = p[0], n[2 * f + 1] = p[1];
      }
      this._delaunator = new Rl(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 gL(this, t);
  }
  *neighbors(t) {
    const { inedges: n, hull: r, _hullIndex: i, halfedges: s, triangles: o, collinear: a } = this;
    if (a) {
      const h = a.indexOf(t);
      h > 0 && (yield a[h - 1]), h < a.length - 1 && (yield a[h + 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 h = r[(i[t] + 1) % r.length];
        h !== l && (yield h);
        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, h = Cs(n - u[t * 2], 2) + Cs(r - u[t * 2 + 1], 2);
    const f = i[t];
    let d = f;
    do {
      let p = c[d];
      const y = Cs(n - u[p * 2], 2) + Cs(r - u[p * 2 + 1], 2);
      if (y < h && (h = 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 && Cs(n - u[d * 2], 2) + Cs(r - u[d * 2 + 1], 2) < h)
          return d;
        break;
      }
    } while (d !== f);
    return l;
  }
  render(t) {
    const n = t == null ? t = new ss() : 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 ss() : 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, bL);
    }
    return r && r.value();
  }
  renderHull(t) {
    const n = t == null ? t = new ss() : 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 Dp();
    return this.renderHull(t), t.value();
  }
  renderTriangle(t, n) {
    const r = n == null ? n = new ss() : 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 Dp();
    return this.renderTriangle(t, n), n.value();
  }
}
function SL(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* ML(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 $L(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function Cl(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 Do(e) {
  return e = Cl(Math.abs(e)), e ? e[1] : NaN;
}
function AL(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 IL(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var TL = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function sc(e) {
  if (!(t = TL.exec(e)))
    throw new Error("invalid format: " + e);
  var t;
  return new Ay({
    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]
  });
}
sc.prototype = Ay.prototype;
function Ay(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 + "";
}
Ay.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 EL(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 j_;
function NL(e, t) {
  var n = Cl(e, t);
  if (!n)
    return e + "";
  var r = n[0], i = n[1], s = i - (j_ = 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") + Cl(e, Math.max(0, t + s - 1))[0];
}
function I1(e, t) {
  var n = Cl(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 T1 = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: $L,
  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) => I1(e * 100, t),
  r: I1,
  s: NL,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function E1(e) {
  return e;
}
var N1 = Array.prototype.map, L1 = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function LL(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? E1 : AL(N1.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 ? E1 : IL(N1.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(h) {
    h = sc(h);
    var f = h.fill, d = h.align, p = h.sign, y = h.symbol, g = h.zero, m = h.width, b = h.comma, w = h.precision, v = h.trim, _ = h.type;
    _ === "n" ? (b = !0, _ = "g") : T1[_] || (w === void 0 && (w = 12), v = !0, _ = "g"), (g || f === "0" && d === "=") && (g = !0, f = "0", d = "=");
    var x = y === "$" ? n : y === "#" && /[boxX]/.test(_) ? "0" + _.toLowerCase() : "", $ = y === "$" ? r : /[%p]/.test(_) ? o : "", T = T1[_], D = /[defgprs%]/.test(_);
    w = w === void 0 ? 6 : /[gprs]/.test(_) ? Math.max(1, Math.min(21, w)) : Math.max(0, Math.min(20, w));
    function M(A) {
      var L = x, k = $, S, I, E;
      if (_ === "c")
        k = T(A) + k, A = "";
      else {
        A = +A;
        var N = A < 0 || 1 / A < 0;
        if (A = isNaN(A) ? c : T(Math.abs(A), w), v && (A = EL(A)), N && +A == 0 && p !== "+" && (N = !1), L = (N ? p === "(" ? p : a : p === "-" || p === "(" ? "" : p) + L, k = (_ === "s" ? L1[8 + j_ / 3] : "") + k + (N && p === "(" ? ")" : ""), D) {
          for (S = -1, I = A.length; ++S < I; )
            if (E = A.charCodeAt(S), 48 > E || E > 57) {
              k = (E === 46 ? i + A.slice(S + 1) : A.slice(S)) + k, A = A.slice(0, S);
              break;
            }
        }
      }
      b && !g && (A = t(A, 1 / 0));
      var O = L.length + A.length + k.length, R = O < m ? new Array(m - O + 1).join(f) : "";
      switch (b && g && (A = t(R + A, R.length ? m - k.length : 1 / 0), R = ""), d) {
        case "<":
          A = L + A + k + R;
          break;
        case "=":
          A = L + R + A + k;
          break;
        case "^":
          A = R.slice(0, O = R.length >> 1) + L + A + k + R.slice(O);
          break;
        default:
          A = R + L + A + k;
          break;
      }
      return s(A);
    }
    return M.toString = function() {
      return h + "";
    }, M;
  }
  function l(h, f) {
    var d = u((h = sc(h), h.type = "f", h)), p = Math.max(-8, Math.min(8, Math.floor(Do(f) / 3))) * 3, y = Math.pow(10, -p), g = L1[8 + p / 3];
    return function(m) {
      return d(y * m) + g;
    };
  }
  return {
    format: u,
    formatPrefix: l
  };
}
var hu, Ho, q_;
DL({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function DL(e) {
  return hu = LL(e), Ho = hu.format, q_ = hu.formatPrefix, hu;
}
function OL(e) {
  return Math.max(0, -Do(Math.abs(e)));
}
function FL(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Do(t) / 3))) * 3 - Do(Math.abs(e)));
}
function kL(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Do(t) - Do(e)) + 1;
}
var rt = 1e-6, Pl = 1e-12, _t = Math.PI, ne = _t / 2, D1 = _t / 4, en = _t * 2, me = 180 / _t, Tt = _t / 180, Lt = Math.abs, Zo = Math.atan, Dn = Math.atan2, st = Math.cos, du = Math.ceil, V_ = Math.exp, Op = Math.hypot, zl = Math.log, gd = Math.pow, tt = Math.sin, hn = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, Fe = Math.sqrt, Iy = Math.tan;
function Y_(e) {
  return e > 1 ? 0 : e < -1 ? _t : Math.acos(e);
}
function je(e) {
  return e > 1 ? ne : e < -1 ? -ne : Math.asin(e);
}
function Ke() {
}
function Ul(e, t) {
  e && F1.hasOwnProperty(e.type) && F1[e.type](e, t);
}
var O1 = {
  Feature: function(e, t) {
    Ul(e.geometry, t);
  },
  FeatureCollection: function(e, t) {
    for (var n = e.features, r = -1, i = n.length; ++r < i; )
      Ul(n[r].geometry, t);
  }
}, F1 = {
  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) {
    Fp(e.coordinates, t, 0);
  },
  MultiLineString: function(e, t) {
    for (var n = e.coordinates, r = -1, i = n.length; ++r < i; )
      Fp(n[r], t, 0);
  },
  Polygon: function(e, t) {
    k1(e.coordinates, t);
  },
  MultiPolygon: function(e, t) {
    for (var n = e.coordinates, r = -1, i = n.length; ++r < i; )
      k1(n[r], t);
  },
  GeometryCollection: function(e, t) {
    for (var n = e.geometries, r = -1, i = n.length; ++r < i; )
      Ul(n[r], t);
  }
};
function Fp(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 k1(e, t) {
  var n = -1, r = e.length;
  for (t.polygonStart(); ++n < r; )
    Fp(e[n], t, 1);
  t.polygonEnd();
}
function Hi(e, t) {
  e && O1.hasOwnProperty(e.type) ? O1[e.type](e, t) : Ul(e, t);
}
function kp(e) {
  return [Dn(e[1], e[0]), je(e[2])];
}
function Oo(e) {
  var t = e[0], n = e[1], r = st(n);
  return [r * st(t), r * tt(t), tt(n)];
}
function pu(e, t) {
  return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
}
function jl(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 bd(e, t) {
  e[0] += t[0], e[1] += t[1], e[2] += t[2];
}
function yu(e, t) {
  return [e[0] * t, e[1] * t, e[2] * t];
}
function Bp(e) {
  var t = Fe(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= t, e[1] /= t, e[2] /= t;
}
var Aa, ql, Vl, Yl, Wl, Xl, Gl, Hl, Rp, Cp, Pp, W_, X_, Ee, Ne, Le, In = {
  sphere: Ke,
  point: Ty,
  lineStart: B1,
  lineEnd: R1,
  polygonStart: function() {
    In.lineStart = CL, In.lineEnd = PL;
  },
  polygonEnd: function() {
    In.lineStart = B1, In.lineEnd = R1;
  }
};
function Ty(e, t) {
  e *= Tt, t *= Tt;
  var n = st(t);
  Oc(n * st(e), n * tt(e), tt(t));
}
function Oc(e, t, n) {
  ++Aa, Vl += (e - Vl) / Aa, Yl += (t - Yl) / Aa, Wl += (n - Wl) / Aa;
}
function B1() {
  In.point = BL;
}
function BL(e, t) {
  e *= Tt, t *= Tt;
  var n = st(t);
  Ee = n * st(e), Ne = n * tt(e), Le = tt(t), In.point = RL, Oc(Ee, Ne, Le);
}
function RL(e, t) {
  e *= Tt, t *= Tt;
  var n = st(t), r = n * st(e), i = n * tt(e), s = tt(t), o = Dn(Fe((o = Ne * s - Le * i) * o + (o = Le * r - Ee * s) * o + (o = Ee * i - Ne * r) * o), Ee * r + Ne * i + Le * s);
  ql += o, Xl += o * (Ee + (Ee = r)), Gl += o * (Ne + (Ne = i)), Hl += o * (Le + (Le = s)), Oc(Ee, Ne, Le);
}
function R1() {
  In.point = Ty;
}
function CL() {
  In.point = zL;
}
function PL() {
  G_(W_, X_), In.point = Ty;
}
function zL(e, t) {
  W_ = e, X_ = t, e *= Tt, t *= Tt, In.point = G_;
  var n = st(t);
  Ee = n * st(e), Ne = n * tt(e), Le = tt(t), Oc(Ee, Ne, Le);
}
function G_(e, t) {
  e *= Tt, t *= Tt;
  var n = st(t), r = n * st(e), i = n * tt(e), s = tt(t), o = Ne * s - Le * i, a = Le * r - Ee * s, c = Ee * i - Ne * r, u = Op(o, a, c), l = je(u), h = u && -l / u;
  Rp.add(h * o), Cp.add(h * a), Pp.add(h * c), ql += l, Xl += l * (Ee + (Ee = r)), Gl += l * (Ne + (Ne = i)), Hl += l * (Le + (Le = s)), Oc(Ee, Ne, Le);
}
function UL(e) {
  Aa = ql = Vl = Yl = Wl = Xl = Gl = Hl = 0, Rp = new nr(), Cp = new nr(), Pp = new nr(), Hi(e, In);
  var t = +Rp, n = +Cp, r = +Pp, i = Op(t, n, r);
  return i < Pl && (t = Xl, n = Gl, r = Hl, ql < rt && (t = Vl, n = Yl, r = Wl), i = Op(t, n, r), i < Pl) ? [NaN, NaN] : [Dn(n, t) * me, je(r / i) * me];
}
function zp(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 Up(e, t) {
  return Lt(e) > _t && (e -= Math.round(e / en) * en), [e, t];
}
Up.invert = Up;
function H_(e, t, n) {
  return (e %= en) ? t || n ? zp(P1(e), z1(t, n)) : P1(e) : t || n ? z1(t, n) : Up;
}
function C1(e) {
  return function(t, n) {
    return t += e, Lt(t) > _t && (t -= Math.round(t / en) * en), [t, n];
  };
}
function P1(e) {
  var t = C1(e);
  return t.invert = C1(-e), t;
}
function z1(e, t) {
  var n = st(e), r = tt(e), i = st(t), s = tt(t);
  function o(a, c) {
    var u = st(c), l = st(a) * u, h = tt(a) * u, f = tt(c), d = f * n + l * r;
    return [
      Dn(h * i - d * s, l * n - f * r),
      je(d * i + h * s)
    ];
  }
  return o.invert = function(a, c) {
    var u = st(c), l = st(a) * u, h = tt(a) * u, f = tt(c), d = f * i - h * s;
    return [
      Dn(h * i + f * s, l * n + d * r),
      je(d * n - l * r)
    ];
  }, o;
}
function jL(e) {
  e = H_(e[0] * Tt, e[1] * Tt, e.length > 2 ? e[2] * Tt : 0);
  function t(n) {
    return n = e(n[0] * Tt, n[1] * Tt), n[0] *= me, n[1] *= me, n;
  }
  return t.invert = function(n) {
    return n = e.invert(n[0] * Tt, n[1] * Tt), n[0] *= me, n[1] *= me, n;
  }, t;
}
function qL(e, t, n, r, i, s) {
  if (n) {
    var o = st(t), a = tt(t), c = r * n;
    i == null ? (i = t + r * en, s = t - c / 2) : (i = U1(o, i), s = U1(o, s), (r > 0 ? i < s : i > s) && (i += r * en));
    for (var u, l = i; r > 0 ? l > s : l < s; l -= c)
      u = kp([o, -a * st(l), -a * tt(l)]), e.point(u[0], u[1]);
  }
}
function U1(e, t) {
  t = Oo(t), t[0] -= e, Bp(t);
  var n = Y_(-t[1]);
  return ((-t[2] < 0 ? -n : n) + en - rt) % en;
}
function Z_() {
  var e = [], t;
  return {
    point: function(n, r, i) {
      t.push([n, r, i]);
    },
    lineStart: function() {
      e.push(t = []);
    },
    lineEnd: Ke,
    rejoin: function() {
      e.length > 1 && e.push(e.pop().concat(e.shift()));
    },
    result: function() {
      var n = e;
      return e = [], t = null, n;
    }
  };
}
function Wu(e, t) {
  return Lt(e[0] - t[0]) < rt && Lt(e[1] - t[1]) < rt;
}
function mu(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 K_(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 (Wu(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 * rt;
      }
      s.push(b = new mu(g, p, null, !0)), o.push(b.o = new mu(g, null, b, !1)), s.push(b = new mu(m, p, null, !1)), o.push(b.o = new mu(m, null, b, !0));
    }
  }), !!s.length) {
    for (o.sort(t), j1(s), j1(o), a = 0, c = o.length; a < c; ++a)
      o[a].e = n = !n;
    for (var u = s[0], l, h; ; ) {
      for (var f = u, d = !0; f.v; )
        if ((f = f.n) === u)
          return;
      l = f.z, i.lineStart();
      do {
        if (f.v = f.o.v = !0, f.e) {
          if (d)
            for (a = 0, c = l.length; a < c; ++a)
              i.point((h = l[a])[0], h[1]);
          else
            r(f.x, f.n.x, 1, i);
          f = f.n;
        } else {
          if (d)
            for (l = f.p.z, a = l.length - 1; a >= 0; --a)
              i.point((h = l[a])[0], h[1]);
          else
            r(f.x, f.p.x, -1, i);
          f = f.p;
        }
        f = f.o, l = f.z, d = !d;
      } while (!f.v);
      i.lineEnd();
    }
  }
}
function j1(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 wd(e) {
  return Lt(e[0]) <= _t ? e[0] : hn(e[0]) * ((Lt(e[0]) + _t) % en - _t);
}
function VL(e, t) {
  var n = wd(t), r = t[1], i = tt(r), s = [tt(n), -st(n), 0], o = 0, a = 0, c = new nr();
  i === 1 ? r = ne + rt : i === -1 && (r = -ne - rt);
  for (var u = 0, l = e.length; u < l; ++u)
    if (f = (h = e[u]).length)
      for (var h, f, d = h[f - 1], p = wd(d), y = d[1] / 2 + D1, g = tt(y), m = st(y), b = 0; b < f; ++b, p = v, g = x, m = $, d = w) {
        var w = h[b], v = wd(w), _ = w[1] / 2 + D1, x = tt(_), $ = st(_), T = v - p, D = T >= 0 ? 1 : -1, M = D * T, A = M > _t, L = g * x;
        if (c.add(Dn(L * D * tt(M), m * $ + L * st(M))), o += A ? T + D * en : T, A ^ p >= n ^ v >= n) {
          var k = jl(Oo(d), Oo(w));
          Bp(k);
          var S = jl(s, k);
          Bp(S);
          var I = (A ^ T >= 0 ? -1 : 1) * je(S[2]);
          (r > I || r === I && (k[0] || k[1])) && (a += A ^ T >= 0 ? 1 : -1);
        }
      }
  return (o < -rt || o < rt && c < -Pl) ^ a & 1;
}
function J_(e, t, n, r) {
  return function(i) {
    var s = t(i), o = Z_(), a = t(o), c = !1, u, l, h, f = {
      point: d,
      lineStart: y,
      lineEnd: g,
      polygonStart: function() {
        f.point = m, f.lineStart = b, f.lineEnd = w, l = [], u = [];
      },
      polygonEnd: function() {
        f.point = d, f.lineStart = y, f.lineEnd = g, l = t_(l);
        var v = VL(u, r);
        l.length ? (c || (i.polygonStart(), c = !0), K_(l, WL, 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, _) {
      e(v, _) && i.point(v, _);
    }
    function p(v, _) {
      s.point(v, _);
    }
    function y() {
      f.point = p, s.lineStart();
    }
    function g() {
      f.point = d, s.lineEnd();
    }
    function m(v, _) {
      h.push([v, _]), a.point(v, _);
    }
    function b() {
      a.lineStart(), h = [];
    }
    function w() {
      m(h[0][0], h[0][1]), a.lineEnd();
      var v = a.clean(), _ = o.result(), x, $ = _.length, T, D, M;
      if (h.pop(), u.push(h), h = null, !!$) {
        if (v & 1) {
          if (D = _[0], (T = D.length - 1) > 0) {
            for (c || (i.polygonStart(), c = !0), i.lineStart(), x = 0; x < T; ++x)
              i.point((M = D[x])[0], M[1]);
            i.lineEnd();
          }
          return;
        }
        $ > 1 && v & 2 && _.push(_.pop().concat(_.shift())), l.push(_.filter(YL));
      }
    }
    return f;
  };
}
function YL(e) {
  return e.length > 1;
}
function WL(e, t) {
  return ((e = e.x)[0] < 0 ? e[1] - ne - rt : ne - e[1]) - ((t = t.x)[0] < 0 ? t[1] - ne - rt : ne - t[1]);
}
const q1 = J_(
  function() {
    return !0;
  },
  XL,
  HL,
  [-_t, -ne]
);
function XL(e) {
  var t = NaN, n = NaN, r = NaN, i;
  return {
    lineStart: function() {
      e.lineStart(), i = 1;
    },
    point: function(s, o) {
      var a = s > 0 ? _t : -_t, c = Lt(s - t);
      Lt(c - _t) < rt ? (e.point(t, n = (n + o) / 2 > 0 ? ne : -ne), e.point(r, n), e.lineEnd(), e.lineStart(), e.point(a, n), e.point(s, n), i = 0) : r !== a && c >= _t && (Lt(t - r) < rt && (t -= r * rt), Lt(s - a) < rt && (s -= a * rt), n = GL(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 GL(e, t, n, r) {
  var i, s, o = tt(e - n);
  return Lt(o) > rt ? Zo((tt(t) * (s = st(r)) * tt(n) - tt(r) * (i = st(t)) * tt(e)) / (i * s * o)) : (t + r) / 2;
}
function HL(e, t, n, r) {
  var i;
  if (e == null)
    i = n * ne, r.point(-_t, i), r.point(0, i), r.point(_t, i), r.point(_t, 0), r.point(_t, -i), r.point(0, -i), r.point(-_t, -i), r.point(-_t, 0), r.point(-_t, i);
  else if (Lt(e[0] - t[0]) > rt) {
    var s = e[0] < t[0] ? _t : -_t;
    i = n * s / 2, r.point(-s, i), r.point(0, i), r.point(s, i);
  } else
    r.point(t[0], t[1]);
}
function ZL(e) {
  var t = st(e), n = 6 * Tt, r = t > 0, i = Lt(t) > rt;
  function s(l, h, f, d) {
    qL(d, e, n, f, l, h);
  }
  function o(l, h) {
    return st(l) * st(h) > t;
  }
  function a(l) {
    var h, f, d, p, y;
    return {
      lineStart: function() {
        p = d = !1, y = 1;
      },
      point: function(g, m) {
        var b = [g, m], w, v = o(g, m), _ = r ? v ? 0 : u(g, m) : v ? u(g + (g < 0 ? _t : -_t), m) : 0;
        if (!h && (p = d = v) && l.lineStart(), v !== d && (w = c(h, b), (!w || Wu(h, w) || Wu(b, w)) && (b[2] = 1)), v !== d)
          y = 0, v ? (l.lineStart(), w = c(b, h), l.point(w[0], w[1])) : (w = c(h, b), l.point(w[0], w[1], 2), l.lineEnd()), h = w;
        else if (i && h && r ^ v) {
          var x;
          !(_ & f) && (x = c(b, h, !0)) && (y = 0, r ? (l.lineStart(), l.point(x[0][0], x[0][1]), l.point(x[1][0], x[1][1]), l.lineEnd()) : (l.point(x[1][0], x[1][1]), l.lineEnd(), l.lineStart(), l.point(x[0][0], x[0][1], 3)));
        }
        v && (!h || !Wu(h, b)) && l.point(b[0], b[1]), h = b, d = v, f = _;
      },
      lineEnd: function() {
        d && l.lineEnd(), h = 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, h, f) {
    var d = Oo(l), p = Oo(h), y = [1, 0, 0], g = jl(d, p), m = pu(g, g), b = g[0], w = m - b * b;
    if (!w)
      return !f && l;
    var v = t * m / w, _ = -t * b / w, x = jl(y, g), $ = yu(y, v), T = yu(g, _);
    bd($, T);
    var D = x, M = pu($, D), A = pu(D, D), L = M * M - A * (pu($, $) - 1);
    if (!(L < 0)) {
      var k = Fe(L), S = yu(D, (-M - k) / A);
      if (bd(S, $), S = kp(S), !f)
        return S;
      var I = l[0], E = h[0], N = l[1], O = h[1], R;
      E < I && (R = I, I = E, E = R);
      var C = E - I, j = Lt(C - _t) < rt, z = j || C < rt;
      if (!j && O < N && (R = N, N = O, O = R), z ? j ? N + O > 0 ^ S[1] < (Lt(S[0] - I) < rt ? N : O) : N <= S[1] && S[1] <= O : C > _t ^ (I <= S[0] && S[0] <= E)) {
        var X = yu(D, (-M + k) / A);
        return bd(X, $), [S, kp(X)];
      }
    }
  }
  function u(l, h) {
    var f = r ? e : _t - e, d = 0;
    return l < -f ? d |= 1 : l > f && (d |= 2), h < -f ? d |= 4 : h > f && (d |= 8), d;
  }
  return J_(o, a, s, r ? [0, -e] : [-_t, e - _t]);
}
function KL(e, t, n, r, i, s) {
  var o = e[0], a = e[1], c = t[0], u = t[1], l = 0, h = 1, f = c - o, d = u - a, p;
  if (p = n - o, !(!f && p > 0)) {
    if (p /= f, f < 0) {
      if (p < l)
        return;
      p < h && (h = p);
    } else if (f > 0) {
      if (p > h)
        return;
      p > l && (l = p);
    }
    if (p = i - o, !(!f && p < 0)) {
      if (p /= f, f < 0) {
        if (p > h)
          return;
        p > l && (l = p);
      } else if (f > 0) {
        if (p < l)
          return;
        p < h && (h = p);
      }
      if (p = r - a, !(!d && p > 0)) {
        if (p /= d, d < 0) {
          if (p < l)
            return;
          p < h && (h = p);
        } else if (d > 0) {
          if (p > h)
            return;
          p > l && (l = p);
        }
        if (p = s - a, !(!d && p < 0)) {
          if (p /= d, d < 0) {
            if (p > h)
              return;
            p > l && (l = p);
          } else if (d > 0) {
            if (p < l)
              return;
            p < h && (h = p);
          }
          return l > 0 && (e[0] = o + l * f, e[1] = a + l * d), h < 1 && (t[0] = o + h * f, t[1] = a + h * d), !0;
        }
      }
    }
  }
}
var Ia = 1e9, gu = -Ia;
function Q_(e, t, n, r) {
  function i(u, l) {
    return e <= u && u <= n && t <= l && l <= r;
  }
  function s(u, l, h, f) {
    var d = 0, p = 0;
    if (u == null || (d = o(u, h)) !== (p = o(l, h)) || c(u, l) < 0 ^ h > 0)
      do
        f.point(d === 0 || d === 3 ? e : n, d > 1 ? r : t);
      while ((d = (d + h + 4) % 4) !== p);
    else
      f.point(l[0], l[1]);
  }
  function o(u, l) {
    return Lt(u[0] - e) < rt ? l > 0 ? 0 : 3 : Lt(u[0] - n) < rt ? l > 0 ? 2 : 1 : Lt(u[1] - t) < rt ? l > 0 ? 1 : 0 : l > 0 ? 3 : 2;
  }
  function a(u, l) {
    return c(u.x, l.x);
  }
  function c(u, l) {
    var h = o(u, 1), f = o(l, 1);
    return h !== f ? h - f : h === 0 ? l[1] - u[1] : h === 1 ? u[0] - l[0] : h === 2 ? u[1] - l[1] : l[0] - u[0];
  }
  return function(u) {
    var l = u, h = Z_(), f, d, p, y, g, m, b, w, v, _, x, $ = {
      point: T,
      lineStart: L,
      lineEnd: k,
      polygonStart: M,
      polygonEnd: A
    };
    function T(I, E) {
      i(I, E) && l.point(I, E);
    }
    function D() {
      for (var I = 0, E = 0, N = d.length; E < N; ++E)
        for (var O = d[E], R = 1, C = O.length, j = O[0], z, X, H = j[0], J = j[1]; R < C; ++R)
          z = H, X = J, j = O[R], H = j[0], J = j[1], X <= r ? J > r && (H - z) * (r - X) > (J - X) * (e - z) && ++I : J <= r && (H - z) * (r - X) < (J - X) * (e - z) && --I;
      return I;
    }
    function M() {
      l = h, f = [], d = [], x = !0;
    }
    function A() {
      var I = D(), E = x && I, N = (f = t_(f)).length;
      (E || N) && (u.polygonStart(), E && (u.lineStart(), s(null, null, 1, u), u.lineEnd()), N && K_(f, a, I, s, u), u.polygonEnd()), l = u, f = d = p = null;
    }
    function L() {
      $.point = S, d && d.push(p = []), _ = !0, v = !1, b = w = NaN;
    }
    function k() {
      f && (S(y, g), m && v && h.rejoin(), f.push(h.result())), $.point = T, v && l.lineEnd();
    }
    function S(I, E) {
      var N = i(I, E);
      if (d && p.push([I, E]), _)
        y = I, g = E, m = N, _ = !1, N && (l.lineStart(), l.point(I, E));
      else if (N && v)
        l.point(I, E);
      else {
        var O = [b = Math.max(gu, Math.min(Ia, b)), w = Math.max(gu, Math.min(Ia, w))], R = [I = Math.max(gu, Math.min(Ia, I)), E = Math.max(gu, Math.min(Ia, E))];
        KL(O, R, e, t, n, r) ? (v || (l.lineStart(), l.point(O[0], O[1])), l.point(R[0], R[1]), N || l.lineEnd(), x = !1) : N && (l.lineStart(), l.point(I, E), x = !1);
      }
      b = I, w = E, v = N;
    }
    return $;
  };
}
function V1(e, t, n) {
  var r = Ze(e, t - rt, n).concat(t);
  return function(i) {
    return r.map(function(s) {
      return [i, s];
    });
  };
}
function Y1(e, t, n) {
  var r = Ze(e, t - rt, n).concat(t);
  return function(i) {
    return r.map(function(s) {
      return [s, i];
    });
  };
}
function JL() {
  var e, t, n, r, i, s, o, a, c = 10, u = c, l = 90, h = 360, f, d, p, y, g = 2.5;
  function m() {
    return { type: "MultiLineString", coordinates: b() };
  }
  function b() {
    return Ze(du(r / l) * l, n, l).map(p).concat(Ze(du(a / h) * h, o, h).map(y)).concat(Ze(du(t / c) * c, e, c).filter(function(w) {
      return Lt(w % l) > rt;
    }).map(f)).concat(Ze(du(s / u) * u, i, u).filter(function(w) {
      return Lt(w % h) > rt;
    }).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], h = +w[1], m) : [l, h];
  }, 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, f = V1(s, i, 90), d = Y1(t, e, g), p = V1(a, o, 90), y = Y1(r, n, g), m) : g;
  }, m.extentMajor([[-180, -90 + rt], [180, 90 - rt]]).extentMinor([[-180, -80 - rt], [180, 80 + rt]]);
}
function QL() {
  return JL()();
}
const jp = (e) => e;
var vd = new nr(), qp = new nr(), tx, ex, Vp, Yp, li = {
  point: Ke,
  lineStart: Ke,
  lineEnd: Ke,
  polygonStart: function() {
    li.lineStart = tD, li.lineEnd = nD;
  },
  polygonEnd: function() {
    li.lineStart = li.lineEnd = li.point = Ke, vd.add(Lt(qp)), qp = new nr();
  },
  result: function() {
    var e = vd / 2;
    return vd = new nr(), e;
  }
};
function tD() {
  li.point = eD;
}
function eD(e, t) {
  li.point = nx, tx = Vp = e, ex = Yp = t;
}
function nx(e, t) {
  qp.add(Yp * e - Vp * t), Vp = e, Yp = t;
}
function nD() {
  nx(tx, ex);
}
const W1 = li;
var Fo = 1 / 0, Zl = Fo, oc = -Fo, Kl = oc, rD = {
  point: iD,
  lineStart: Ke,
  lineEnd: Ke,
  polygonStart: Ke,
  polygonEnd: Ke,
  result: function() {
    var e = [[Fo, Zl], [oc, Kl]];
    return oc = Kl = -(Zl = Fo = 1 / 0), e;
  }
};
function iD(e, t) {
  e < Fo && (Fo = e), e > oc && (oc = e), t < Zl && (Zl = t), t > Kl && (Kl = t);
}
const Jl = rD;
var Wp = 0, Xp = 0, Ta = 0, Ql = 0, tf = 0, Ks = 0, Gp = 0, Hp = 0, Ea = 0, rx, ix, Kn, Jn, $n = {
  point: xs,
  lineStart: X1,
  lineEnd: G1,
  polygonStart: function() {
    $n.lineStart = aD, $n.lineEnd = cD;
  },
  polygonEnd: function() {
    $n.point = xs, $n.lineStart = X1, $n.lineEnd = G1;
  },
  result: function() {
    var e = Ea ? [Gp / Ea, Hp / Ea] : Ks ? [Ql / Ks, tf / Ks] : Ta ? [Wp / Ta, Xp / Ta] : [NaN, NaN];
    return Wp = Xp = Ta = Ql = tf = Ks = Gp = Hp = Ea = 0, e;
  }
};
function xs(e, t) {
  Wp += e, Xp += t, ++Ta;
}
function X1() {
  $n.point = sD;
}
function sD(e, t) {
  $n.point = oD, xs(Kn = e, Jn = t);
}
function oD(e, t) {
  var n = e - Kn, r = t - Jn, i = Fe(n * n + r * r);
  Ql += i * (Kn + e) / 2, tf += i * (Jn + t) / 2, Ks += i, xs(Kn = e, Jn = t);
}
function G1() {
  $n.point = xs;
}
function aD() {
  $n.point = uD;
}
function cD() {
  sx(rx, ix);
}
function uD(e, t) {
  $n.point = sx, xs(rx = Kn = e, ix = Jn = t);
}
function sx(e, t) {
  var n = e - Kn, r = t - Jn, i = Fe(n * n + r * r);
  Ql += i * (Kn + e) / 2, tf += i * (Jn + t) / 2, Ks += i, i = Jn * e - Kn * t, Gp += i * (Kn + e), Hp += i * (Jn + t), Ea += i * 3, xs(Kn = e, Jn = t);
}
const H1 = $n;
function ox(e) {
  this._context = e;
}
ox.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, en);
        break;
      }
    }
  },
  result: Ke
};
var Zp = new nr(), _d, ax, cx, Na, La, ef = {
  point: Ke,
  lineStart: function() {
    ef.point = lD;
  },
  lineEnd: function() {
    _d && ux(ax, cx), ef.point = Ke;
  },
  polygonStart: function() {
    _d = !0;
  },
  polygonEnd: function() {
    _d = null;
  },
  result: function() {
    var e = +Zp;
    return Zp = new nr(), e;
  }
};
function lD(e, t) {
  ef.point = ux, ax = Na = e, cx = La = t;
}
function ux(e, t) {
  Na -= e, La -= t, Zp.add(Fe(Na * Na + La * La)), Na = e, La = t;
}
const Z1 = ef;
let K1, nf, J1, Q1;
class tb {
  constructor(t) {
    this._append = t == null ? lx : fD(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 !== J1 || this._append !== nf) {
          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`, J1 = r, nf = this._append, Q1 = this._, this._ = i;
        }
        this._ += Q1;
        break;
      }
    }
  }
  result() {
    const t = this._;
    return this._ = "", t.length ? t : null;
  }
}
function lx(e) {
  let t = 1;
  this._ += e[0];
  for (const n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function fD(e) {
  const t = Math.floor(e);
  if (!(t >= 0))
    throw new RangeError(`invalid digits: ${e}`);
  if (t > 15)
    return lx;
  if (t !== K1) {
    const n = 10 ** t;
    K1 = t, nf = 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 nf;
}
function Fi(e, t) {
  let n = 3, r = 4.5, i, s;
  function o(a) {
    return a && (typeof r == "function" && s.pointRadius(+r.apply(this, arguments)), Hi(a, i(s))), s.result();
  }
  return o.area = function(a) {
    return Hi(a, i(W1)), W1.result();
  }, o.measure = function(a) {
    return Hi(a, i(Z1)), Z1.result();
  }, o.bounds = function(a) {
    return Hi(a, i(Jl)), Jl.result();
  }, o.centroid = function(a) {
    return Hi(a, i(H1)), H1.result();
  }, o.projection = function(a) {
    return arguments.length ? (i = a == null ? (e = null, jp) : (e = a).stream, o) : e;
  }, o.context = function(a) {
    return arguments.length ? (s = a == null ? (t = null, new tb(n)) : new ox(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 tb(n)), o;
  }, o.projection(e).digits(n).context(t);
}
function rf(e) {
  return {
    stream: Kf(e)
  };
}
function Kf(e) {
  return function(t) {
    var n = new Kp();
    for (var r in e)
      n[r] = e[r];
    return n.stream = t, n;
  };
}
function Kp() {
}
Kp.prototype = {
  constructor: Kp,
  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 Ey(e, t, n) {
  var r = e.clipExtent && e.clipExtent();
  return e.scale(150).translate([0, 0]), r != null && e.clipExtent(null), Hi(n, e.stream(Jl)), t(Jl.result()), r != null && e.clipExtent(r), e;
}
function Ny(e, t, n) {
  return Ey(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 fx(e, t, n) {
  return Ny(e, [[0, 0], t], n);
}
function hx(e, t, n) {
  return Ey(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 dx(e, t, n) {
  return Ey(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 eb = 16, hD = st(30 * Tt);
function nb(e, t) {
  return +t ? pD(e, t) : dD(e);
}
function dD(e) {
  return Kf({
    point: function(t, n) {
      t = e(t, n), this.stream.point(t[0], t[1]);
    }
  });
}
function pD(e, t) {
  function n(r, i, s, o, a, c, u, l, h, f, d, p, y, g) {
    var m = u - r, b = l - i, w = m * m + b * b;
    if (w > 4 * t && y--) {
      var v = o + f, _ = a + d, x = c + p, $ = Fe(v * v + _ * _ + x * x), T = je(x /= $), D = Lt(Lt(x) - 1) < rt || Lt(s - h) < rt ? (s + h) / 2 : Dn(_, v), M = e(D, T), A = M[0], L = M[1], k = A - r, S = L - i, I = b * k - m * S;
      (I * I / w > t || Lt((m * k + b * S) / w - 0.5) > 0.3 || o * f + a * d + c * p < hD) && (n(r, i, s, o, a, c, A, L, D, v /= $, _ /= $, x, y, g), g.point(A, L), n(A, L, D, v, _, x, u, l, h, f, d, p, y, g));
    }
  }
  return function(r) {
    var i, s, o, a, c, u, l, h, f, d, p, y, g = {
      point: m,
      lineStart: b,
      lineEnd: v,
      polygonStart: function() {
        r.polygonStart(), g.lineStart = _;
      },
      polygonEnd: function() {
        r.polygonEnd(), g.lineStart = b;
      }
    };
    function m(T, D) {
      T = e(T, D), r.point(T[0], T[1]);
    }
    function b() {
      h = NaN, g.point = w, r.lineStart();
    }
    function w(T, D) {
      var M = Oo([T, D]), A = e(T, D);
      n(h, f, l, d, p, y, h = A[0], f = A[1], l = T, d = M[0], p = M[1], y = M[2], eb, r), r.point(h, f);
    }
    function v() {
      g.point = m, r.lineEnd();
    }
    function _() {
      b(), g.point = x, g.lineEnd = $;
    }
    function x(T, D) {
      w(i = T, D), s = h, o = f, a = d, c = p, u = y, g.point = w;
    }
    function $() {
      n(h, f, l, d, p, y, s, o, i, a, c, u, eb, r), g.lineEnd = v, v();
    }
    return g;
  };
}
var yD = Kf({
  point: function(e, t) {
    this.stream.point(e * Tt, t * Tt);
  }
});
function mD(e) {
  return Kf({
    point: function(t, n) {
      var r = e(t, n);
      return this.stream.point(r[0], r[1]);
    }
  });
}
function gD(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 rb(e, t, n, r, i, s) {
  if (!s)
    return gD(e, t, n, r, i);
  var o = st(s), a = tt(s), c = o * e, u = a * e, l = o / e, h = a / e, f = (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 - h * g + f), i * (d - h * y - l * g)];
  }, p;
}
function ki(e) {
  return px(function() {
    return e;
  })();
}
function px(e) {
  var t, n = 150, r = 480, i = 250, s = 0, o = 0, a = 0, c = 0, u = 0, l, h = 0, f = 1, d = 1, p = null, y = q1, g = null, m, b, w, v = jp, _ = 0.5, x, $, T, D, M;
  function A(I) {
    return T(I[0] * Tt, I[1] * Tt);
  }
  function L(I) {
    return I = T.invert(I[0], I[1]), I && [I[0] * me, I[1] * me];
  }
  A.stream = function(I) {
    return D && M === I ? D : D = yD(mD(l)(y(x(v(M = I)))));
  }, A.preclip = function(I) {
    return arguments.length ? (y = I, p = void 0, S()) : y;
  }, A.postclip = function(I) {
    return arguments.length ? (v = I, g = m = b = w = null, S()) : v;
  }, A.clipAngle = function(I) {
    return arguments.length ? (y = +I ? ZL(p = I * Tt) : (p = null, q1), S()) : p * me;
  }, A.clipExtent = function(I) {
    return arguments.length ? (v = I == null ? (g = m = b = w = null, jp) : Q_(g = +I[0][0], m = +I[0][1], b = +I[1][0], w = +I[1][1]), S()) : g == null ? null : [[g, m], [b, w]];
  }, A.scale = function(I) {
    return arguments.length ? (n = +I, k()) : n;
  }, A.translate = function(I) {
    return arguments.length ? (r = +I[0], i = +I[1], k()) : [r, i];
  }, A.center = function(I) {
    return arguments.length ? (s = I[0] % 360 * Tt, o = I[1] % 360 * Tt, k()) : [s * me, o * me];
  }, A.rotate = function(I) {
    return arguments.length ? (a = I[0] % 360 * Tt, c = I[1] % 360 * Tt, u = I.length > 2 ? I[2] % 360 * Tt : 0, k()) : [a * me, c * me, u * me];
  }, A.angle = function(I) {
    return arguments.length ? (h = I % 360 * Tt, k()) : h * me;
  }, A.reflectX = function(I) {
    return arguments.length ? (f = I ? -1 : 1, k()) : f < 0;
  }, A.reflectY = function(I) {
    return arguments.length ? (d = I ? -1 : 1, k()) : d < 0;
  }, A.precision = function(I) {
    return arguments.length ? (x = nb($, _ = I * I), S()) : Fe(_);
  }, A.fitExtent = function(I, E) {
    return Ny(A, I, E);
  }, A.fitSize = function(I, E) {
    return fx(A, I, E);
  }, A.fitWidth = function(I, E) {
    return hx(A, I, E);
  }, A.fitHeight = function(I, E) {
    return dx(A, I, E);
  };
  function k() {
    var I = rb(n, 0, 0, f, d, h).apply(null, t(s, o)), E = rb(n, r - I[0], i - I[1], f, d, h);
    return l = H_(a, c, u), $ = zp(t, E), T = zp(l, $), x = nb($, _), S();
  }
  function S() {
    return D = M = null, A;
  }
  return function() {
    return t = e.apply(this, arguments), A.invert = t.invert && L, k();
  };
}
function Ly(e) {
  var t = 0, n = _t / 3, r = px(e), i = r(t, n);
  return i.parallels = function(s) {
    return arguments.length ? r(t = s[0] * Tt, n = s[1] * Tt) : [t * me, n * me];
  }, i;
}
function bD(e) {
  var t = st(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 wD(e, t) {
  var n = tt(e), r = (n + tt(t)) / 2;
  if (Lt(r) < rt)
    return bD(e);
  var i = 1 + n * (2 * r - n), s = Fe(i) / r;
  function o(a, c) {
    var u = Fe(i - 2 * r * tt(c)) / r;
    return [u * tt(a *= r), s - u * st(a)];
  }
  return o.invert = function(a, c) {
    var u = s - c, l = Dn(a, Lt(u)) * hn(u);
    return u * r < 0 && (l -= _t * hn(a) * hn(u)), [l / r, je((i - (a * a + u * u) * r * r) / (2 * r))];
  }, o;
}
function sf() {
  return Ly(wD).scale(155.424).center([0, 33.6442]);
}
function yx() {
  return sf().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
}
function vD(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 _D() {
  var e, t, n = yx(), r, i = sf().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), s, o = sf().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), a, c, u = { point: function(f, d) {
    c = [f, d];
  } };
  function l(f) {
    var d = f[0], p = f[1];
    return c = null, r.point(d, p), c || (s.point(d, p), c) || (a.point(d, p), c);
  }
  l.invert = function(f) {
    var d = n.scale(), p = n.translate(), y = (f[0] - p[0]) / d, g = (f[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(f);
  }, l.stream = function(f) {
    return e && t === f ? e : e = vD([n.stream(t = f), i.stream(f), o.stream(f)]);
  }, l.precision = function(f) {
    return arguments.length ? (n.precision(f), i.precision(f), o.precision(f), h()) : n.precision();
  }, l.scale = function(f) {
    return arguments.length ? (n.scale(f), i.scale(f * 0.35), o.scale(f), l.translate(n.translate())) : n.scale();
  }, l.translate = function(f) {
    if (!arguments.length)
      return n.translate();
    var d = n.scale(), p = +f[0], y = +f[1];
    return r = n.translate(f).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 + rt, y + 0.12 * d + rt], [p - 0.214 * d - rt, y + 0.234 * d - rt]]).stream(u), a = o.translate([p - 0.205 * d, y + 0.212 * d]).clipExtent([[p - 0.214 * d + rt, y + 0.166 * d + rt], [p - 0.115 * d - rt, y + 0.234 * d - rt]]).stream(u), h();
  }, l.fitExtent = function(f, d) {
    return Ny(l, f, d);
  }, l.fitSize = function(f, d) {
    return fx(l, f, d);
  }, l.fitWidth = function(f, d) {
    return hx(l, f, d);
  }, l.fitHeight = function(f, d) {
    return dx(l, f, d);
  };
  function h() {
    return e = t = null, l;
  }
  return l.scale(1070);
}
function mx(e) {
  return function(t, n) {
    var r = st(t), i = st(n), s = e(r * i);
    return s === 1 / 0 ? [2, 0] : [
      s * i * tt(t),
      s * tt(n)
    ];
  };
}
function Fc(e) {
  return function(t, n) {
    var r = Fe(t * t + n * n), i = e(r), s = tt(i), o = st(i);
    return [
      Dn(t * s, r * o),
      je(r && n * s / r)
    ];
  };
}
var gx = mx(function(e) {
  return Fe(2 / (1 + e));
});
gx.invert = Fc(function(e) {
  return 2 * je(e / 2);
});
function xD() {
  return ki(gx).scale(124.75).clipAngle(180 - 1e-3);
}
var bx = mx(function(e) {
  return (e = Y_(e)) && e / tt(e);
});
bx.invert = Fc(function(e) {
  return e;
});
function SD() {
  return ki(bx).scale(79.4188).clipAngle(180 - 1e-3);
}
function Jf(e, t) {
  return [e, zl(Iy((ne + t) / 2))];
}
Jf.invert = function(e, t) {
  return [e, 2 * Zo(V_(t)) - ne];
};
function MD() {
  return wx(Jf).scale(961 / en);
}
function wx(e) {
  var t = ki(e), n = t.center, r = t.scale, i = t.translate, s = t.clipExtent, o = null, a, c, u;
  t.scale = function(h) {
    return arguments.length ? (r(h), l()) : r();
  }, t.translate = function(h) {
    return arguments.length ? (i(h), l()) : i();
  }, t.center = function(h) {
    return arguments.length ? (n(h), l()) : n();
  }, t.clipExtent = function(h) {
    return arguments.length ? (h == null ? o = a = c = u = null : (o = +h[0][0], a = +h[0][1], c = +h[1][0], u = +h[1][1]), l()) : o == null ? null : [[o, a], [c, u]];
  };
  function l() {
    var h = _t * r(), f = t(jL(t.rotate()).invert([0, 0]));
    return s(o == null ? [[f[0] - h, f[1] - h], [f[0] + h, f[1] + h]] : e === Jf ? [[Math.max(f[0] - h, o), a], [Math.min(f[0] + h, c), u]] : [[o, Math.max(f[1] - h, a)], [c, Math.min(f[1] + h, u)]]);
  }
  return l();
}
function bu(e) {
  return Iy((ne + e) / 2);
}
function $D(e, t) {
  var n = st(e), r = e === t ? tt(e) : zl(n / st(t)) / zl(bu(t) / bu(e)), i = n * gd(bu(e), r) / r;
  if (!r)
    return Jf;
  function s(o, a) {
    i > 0 ? a < -ne + rt && (a = -ne + rt) : a > ne - rt && (a = ne - rt);
    var c = i / gd(bu(a), r);
    return [c * tt(r * o), i - c * st(r * o)];
  }
  return s.invert = function(o, a) {
    var c = i - a, u = hn(r) * Fe(o * o + c * c), l = Dn(o, Lt(c)) * hn(c);
    return c * r < 0 && (l -= _t * hn(o) * hn(c)), [l / r, 2 * Zo(gd(i / u, 1 / r)) - ne];
  }, s;
}
function AD() {
  return Ly($D).scale(109.5).parallels([30, 30]);
}
function of(e, t) {
  return [e, t];
}
of.invert = of;
function ID() {
  return ki(of).scale(152.63);
}
function TD(e, t) {
  var n = st(e), r = e === t ? tt(e) : (n - st(t)) / (t - e), i = n / r + e;
  if (Lt(r) < rt)
    return of;
  function s(o, a) {
    var c = i - a, u = r * o;
    return [c * tt(u), i - c * st(u)];
  }
  return s.invert = function(o, a) {
    var c = i - a, u = Dn(o, Lt(c)) * hn(c);
    return c * r < 0 && (u -= _t * hn(o) * hn(c)), [u / r, i - hn(r) * Fe(o * o + c * c)];
  }, s;
}
function ED() {
  return Ly(TD).scale(131.154).center([0, 13.9389]);
}
var ka = 1.340264, Ba = -0.081106, Ra = 893e-6, Ca = 3796e-6, af = Fe(3) / 2, ND = 12;
function vx(e, t) {
  var n = je(af * tt(t)), r = n * n, i = r * r * r;
  return [
    e * st(n) / (af * (ka + 3 * Ba * r + i * (7 * Ra + 9 * Ca * r))),
    n * (ka + Ba * r + i * (Ra + Ca * r))
  ];
}
vx.invert = function(e, t) {
  for (var n = t, r = n * n, i = r * r * r, s = 0, o, a, c; s < ND && (a = n * (ka + Ba * r + i * (Ra + Ca * r)) - t, c = ka + 3 * Ba * r + i * (7 * Ra + 9 * Ca * r), n -= o = a / c, r = n * n, i = r * r * r, !(Lt(o) < Pl)); ++s)
    ;
  return [
    af * e * (ka + 3 * Ba * r + i * (7 * Ra + 9 * Ca * r)) / st(n),
    je(tt(n) / af)
  ];
};
function LD() {
  return ki(vx).scale(177.158);
}
function _x(e, t) {
  var n = st(t), r = st(e) * n;
  return [n * tt(e) / r, tt(t) / r];
}
_x.invert = Fc(Zo);
function DD() {
  return ki(_x).scale(144.049).clipAngle(60);
}
function xx(e, t) {
  return [st(t) * tt(e), tt(t)];
}
xx.invert = Fc(je);
function OD() {
  return ki(xx).scale(249.5).clipAngle(90 + rt);
}
function Sx(e, t) {
  var n = st(t), r = 1 + st(e) * n;
  return [n * tt(e) / r, tt(t) / r];
}
Sx.invert = Fc(function(e) {
  return 2 * Zo(e);
});
function FD() {
  return ki(Sx).scale(250).clipAngle(142);
}
function Mx(e, t) {
  return [zl(Iy((ne + t) / 2)), -e];
}
Mx.invert = function(e, t) {
  return [-t, 2 * Zo(V_(e)) - ne];
};
function kD() {
  var e = wx(Mx), 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 BD(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function RD(e) {
  return e.reduce(CD, 0) / e.length;
}
function CD(e, t) {
  return e + t.x;
}
function PD(e) {
  return 1 + e.reduce(zD, 0);
}
function zD(e, t) {
  return Math.max(e, t.y);
}
function UD(e) {
  for (var t; t = e.children; )
    e = t[0];
  return e;
}
function jD(e) {
  for (var t; t = e.children; )
    e = t[t.length - 1];
  return e;
}
function qD() {
  var e = BD, t = 1, n = 1, r = !1;
  function i(s) {
    var o, a = 0;
    s.eachAfter(function(f) {
      var d = f.children;
      d ? (f.x = RD(d), f.y = PD(d)) : (f.x = o ? a += e(f, o) : 0, f.y = 0, o = f);
    });
    var c = UD(s), u = jD(s), l = c.x - e(c, u) / 2, h = u.x + e(u, c) / 2;
    return s.eachAfter(r ? function(f) {
      f.x = (f.x - s.x) * t, f.y = (s.y - f.y) * n;
    } : function(f) {
      f.x = (f.x - l) / (h - l) * t, f.y = (1 - (s.y ? f.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 VD(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 YD() {
  return this.eachAfter(VD);
}
function WD(e, t) {
  let n = -1;
  for (const r of this)
    e.call(t, r, ++n, this);
  return this;
}
function XD(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 GD(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 HD(e, t) {
  let n = -1;
  for (const r of this)
    if (e.call(t, r, ++n, this))
      return r;
}
function ZD(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 KD(e) {
  return this.eachBefore(function(t) {
    t.children && t.children.sort(e);
  });
}
function JD(e) {
  for (var t = this, n = QD(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 QD(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 tO() {
  for (var e = this, t = [e]; e = e.parent; )
    t.push(e);
  return t;
}
function eO() {
  return Array.from(this);
}
function nO() {
  var e = [];
  return this.eachBefore(function(t) {
    t.children || e.push(t);
  }), e;
}
function rO() {
  var e = this, t = [];
  return e.each(function(n) {
    n !== e && t.push({ source: n.parent, target: n });
  }), t;
}
function* iO() {
  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 $x(e, t) {
  e instanceof Map ? (e = [void 0, e], t === void 0 && (t = aO)) : t === void 0 && (t = oO);
  for (var n = new ko(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 ko(o[a])), s.parent = r, s.depth = r.depth + 1;
  return n.eachBefore(Ax);
}
function sO() {
  return $x(this).eachBefore(cO);
}
function oO(e) {
  return e.children;
}
function aO(e) {
  return Array.isArray(e) ? e[1] : null;
}
function cO(e) {
  e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
}
function Ax(e) {
  var t = 0;
  do
    e.height = t;
  while ((e = e.parent) && e.height < ++t);
}
function ko(e) {
  this.data = e, this.depth = this.height = 0, this.parent = null;
}
ko.prototype = $x.prototype = {
  constructor: ko,
  count: YD,
  each: WD,
  eachAfter: GD,
  eachBefore: XD,
  find: HD,
  sum: ZD,
  sort: KD,
  path: JD,
  ancestors: tO,
  descendants: eO,
  leaves: nO,
  links: rO,
  copy: sO,
  [Symbol.iterator]: iO
};
function xd(e) {
  return e == null ? null : uO(e);
}
function uO(e) {
  if (typeof e != "function")
    throw new Error();
  return e;
}
var lO = { depth: -1 }, ib = {}, Sd = {};
function fO(e) {
  return e.id;
}
function hO(e) {
  return e.parentId;
}
function Ix() {
  var e = fO, t = hO, n;
  function r(i) {
    var s = Array.from(i), o = e, a = t, c, u, l, h, f, d, p, y, g = /* @__PURE__ */ new Map();
    if (n != null) {
      const m = s.map((v, _) => dO(n(v, _, i))), b = m.map(sb), w = new Set(m).add("");
      for (const v of b)
        w.has(v) || (w.add(v), m.push(v), b.push(sb(v)), s.push(Sd));
      o = (v, _) => m[_], a = (v, _) => b[_];
    }
    for (l = 0, c = s.length; l < c; ++l)
      u = s[l], d = s[l] = new ko(u), (p = o(u, l, i)) != null && (p += "") && (y = d.id = p, g.set(y, g.has(y) ? ib : 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 (f = g.get(p), !f)
          throw new Error("missing: " + p);
        if (f === ib)
          throw new Error("ambiguous: " + p);
        f.children ? f.children.push(d) : f.children = [d], d.parent = f;
      } else {
        if (h)
          throw new Error("multiple roots");
        h = d;
      }
    if (!h)
      throw new Error("no root");
    if (n != null) {
      for (; h.data === Sd && h.children.length === 1; )
        h = h.children[0], --c;
      for (let m = s.length - 1; m >= 0 && (d = s[m], d.data === Sd); --m)
        d.data = null;
    }
    if (h.parent = lO, h.eachBefore(function(m) {
      m.depth = m.parent.depth + 1, --c;
    }).eachBefore(Ax), h.parent = null, c > 0)
      throw new Error("cycle");
    return h;
  }
  return r.id = function(i) {
    return arguments.length ? (e = xd(i), r) : e;
  }, r.parentId = function(i) {
    return arguments.length ? (t = xd(i), r) : t;
  }, r.path = function(i) {
    return arguments.length ? (n = xd(i), r) : n;
  }, r;
}
function dO(e) {
  e = `${e}`;
  let t = e.length;
  return Jp(e, t - 1) && !Jp(e, t - 2) && (e = e.slice(0, -1)), e[0] === "/" ? e : `/${e}`;
}
function sb(e) {
  let t = e.length;
  if (t < 2)
    return "";
  for (; --t > 1 && !Jp(e, t); )
    ;
  return e.slice(0, t);
}
function Jp(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
function pO(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function Md(e) {
  var t = e.children;
  return t ? t[0] : e.t;
}
function $d(e) {
  var t = e.children;
  return t ? t[t.length - 1] : e.t;
}
function yO(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 mO(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 gO(e, t, n) {
  return e.a.parent === t.parent ? e.a : n;
}
function Xu(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;
}
Xu.prototype = Object.create(ko.prototype);
function bO(e) {
  for (var t = new Xu(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 Xu(s[o], o)), i.parent = n;
  return (t.parent = new Xu(null, 0)).children = [t], t;
}
function Tx() {
  var e = pO, t = 1, n = 1, r = null;
  function i(u) {
    var l = bO(u);
    if (l.eachAfter(s), l.parent.m = -l.z, l.eachBefore(o), r)
      u.eachBefore(c);
    else {
      var h = u, f = u, d = u;
      u.eachBefore(function(b) {
        b.x < h.x && (h = b), b.x > f.x && (f = b), b.depth > d.depth && (d = b);
      });
      var p = h === f ? 1 : e(h, f) / 2, y = p - h.x, g = t / (f.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, h = u.parent.children, f = u.i ? h[u.i - 1] : null;
    if (l) {
      mO(u);
      var d = (l[0].z + l[l.length - 1].z) / 2;
      f ? (u.z = f.z + e(u._, f._), u.m = u.z - d) : u.z = d;
    } else
      f && (u.z = f.z + e(u._, f._));
    u.parent.A = a(u, f, u.parent.A || h[0]);
  }
  function o(u) {
    u._.x = u.z + u.parent.m, u.m += u.parent.m;
  }
  function a(u, l, h) {
    if (l) {
      for (var f = u, d = u, p = l, y = f.parent.children[0], g = f.m, m = d.m, b = p.m, w = y.m, v; p = $d(p), f = Md(f), p && f; )
        y = Md(y), d = $d(d), d.a = u, v = p.z + b - f.z - g + e(p._, f._), v > 0 && (yO(gO(p, u, h), u, v), g += v, m += v), b += p.m, g += f.m, w += y.m, m += d.m;
      p && !$d(d) && (d.t = p, d.m += b - m), f && !Md(y) && (y.t = f, y.m += g - w, h = u);
    }
    return h;
  }
  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 wO = 1664525, vO = 1013904223, ob = 1 / 4294967296;
function Dy(e = Math.random()) {
  let t = (0 <= e && e < 1 ? e / ob : Math.abs(e)) | 0;
  return () => (t = wO * t + vO | 0, ob * (t >>> 0));
}
function fr(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
function Qf(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 Qp = Symbol("implicit");
function Oy() {
  var e = new gs(), t = [], n = [], r = Qp;
  function i(s) {
    let o = e.get(s);
    if (o === void 0) {
      if (r !== Qp)
        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 gs();
    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 Oy(t, n).unknown(r);
  }, fr.apply(i, arguments), i;
}
function th() {
  var e = Oy().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 h() {
    var f = t().length, d = i < r, p = d ? i : r, y = d ? r : i;
    s = (y - p) / Math.max(1, f - c + u * 2), a && (s = Math.floor(s)), p += (y - p - s * (f - c)) * l, o = s * (1 - c), a && (p = Math.round(p), o = Math.round(o));
    var g = Ze(f).map(function(m) {
      return p + s * m;
    });
    return n(d ? g.reverse() : g);
  }
  return e.domain = function(f) {
    return arguments.length ? (t(f), h()) : t();
  }, e.range = function(f) {
    return arguments.length ? ([r, i] = f, r = +r, i = +i, h()) : [r, i];
  }, e.rangeRound = function(f) {
    return [r, i] = f, r = +r, i = +i, a = !0, h();
  }, e.bandwidth = function() {
    return o;
  }, e.step = function() {
    return s;
  }, e.round = function(f) {
    return arguments.length ? (a = !!f, h()) : a;
  }, e.padding = function(f) {
    return arguments.length ? (c = Math.min(1, u = +f), h()) : c;
  }, e.paddingInner = function(f) {
    return arguments.length ? (c = Math.min(1, f), h()) : c;
  }, e.paddingOuter = function(f) {
    return arguments.length ? (u = +f, h()) : u;
  }, e.align = function(f) {
    return arguments.length ? (l = Math.max(0, Math.min(1, f)), h()) : l;
  }, e.copy = function() {
    return th(t(), [r, i]).round(a).paddingInner(c).paddingOuter(u).align(l);
  }, fr.apply(h(), arguments);
}
function Ex(e) {
  var t = e.copy;
  return e.padding = e.paddingOuter, delete e.paddingInner, delete e.paddingOuter, e.copy = function() {
    return Ex(t());
  }, e;
}
function _O() {
  return Ex(th.apply(null, arguments).paddingInner(1));
}
function xO(e) {
  return function() {
    return e;
  };
}
function t0(e) {
  return +e;
}
var ab = [0, 1];
function dn(e) {
  return e;
}
function e0(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : xO(isNaN(t) ? NaN : 0.5);
}
function SO(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(r) {
    return Math.max(e, Math.min(t, r));
  };
}
function MO(e, t, n) {
  var r = e[0], i = e[1], s = t[0], o = t[1];
  return i < r ? (r = e0(i, r), s = n(o, s)) : (r = e0(r, i), s = n(s, o)), function(a) {
    return s(r(a));
  };
}
function $O(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] = e0(e[o], e[o + 1]), s[o] = n(t[o], t[o + 1]);
  return function(a) {
    var c = zf(e, a, 1, r) - 1;
    return s[c](i[c](a));
  };
}
function kc(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function eh() {
  var e = ab, t = ab, n = Go, r, i, s, o = dn, a, c, u;
  function l() {
    var f = Math.min(e.length, t.length);
    return o !== dn && (o = SO(e[0], e[f - 1])), a = f > 2 ? $O : MO, c = u = null, h;
  }
  function h(f) {
    return f == null || isNaN(f = +f) ? s : (c || (c = a(e.map(r), t, n)))(r(o(f)));
  }
  return h.invert = function(f) {
    return o(i((u || (u = a(t, e.map(r), xe)))(f)));
  }, h.domain = function(f) {
    return arguments.length ? (e = Array.from(f, t0), l()) : e.slice();
  }, h.range = function(f) {
    return arguments.length ? (t = Array.from(f), l()) : t.slice();
  }, h.rangeRound = function(f) {
    return t = Array.from(f), n = wy, l();
  }, h.clamp = function(f) {
    return arguments.length ? (o = f ? !0 : dn, l()) : o !== dn;
  }, h.interpolate = function(f) {
    return arguments.length ? (n = f, l()) : n;
  }, h.unknown = function(f) {
    return arguments.length ? (s = f, h) : s;
  }, function(f, d) {
    return r = f, i = d, l();
  };
}
function Nx() {
  return eh()(dn, dn);
}
function AO(e, t, n, r) {
  var i = mp(e, t, n), s;
  switch (r = sc(r ?? ",f"), r.type) {
    case "s": {
      var o = Math.max(Math.abs(e), Math.abs(t));
      return r.precision == null && !isNaN(s = FL(i, o)) && (r.precision = s), q_(r, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      r.precision == null && !isNaN(s = kL(i, Math.max(Math.abs(e), Math.abs(t)))) && (r.precision = s - (r.type === "e"));
      break;
    }
    case "f":
    case "%": {
      r.precision == null && !isNaN(s = OL(i)) && (r.precision = s - (r.type === "%") * 2);
      break;
    }
  }
  return Ho(r);
}
function Bc(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var r = t();
    return Si(r[0], r[r.length - 1], n ?? 10);
  }, e.tickFormat = function(n, r) {
    var i = t();
    return AO(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 = Qa(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 nh() {
  var e = Nx();
  return e.copy = function() {
    return kc(e, nh());
  }, fr.apply(e, arguments), Bc(e);
}
function Lx(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, t0), n) : e.slice();
  }, n.unknown = function(r) {
    return arguments.length ? (t = r, n) : t;
  }, n.copy = function() {
    return Lx(e).unknown(t);
  }, e = arguments.length ? Array.from(e, t0) : [0, 1], Bc(n);
}
function Dx(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 cb(e) {
  return Math.log(e);
}
function ub(e) {
  return Math.exp(e);
}
function IO(e) {
  return -Math.log(-e);
}
function TO(e) {
  return -Math.exp(-e);
}
function EO(e) {
  return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e;
}
function NO(e) {
  return e === 10 ? EO : e === Math.E ? Math.exp : (t) => Math.pow(e, t);
}
function LO(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 lb(e) {
  return (t, n) => -e(-t, n);
}
function Ox(e) {
  const t = e(cb, ub), n = t.domain;
  let r = 10, i, s;
  function o() {
    return i = LO(r), s = NO(r), n()[0] < 0 ? (i = lb(i), s = lb(s), e(IO, TO)) : e(cb, ub), 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 h = l < u;
    h && ([u, l] = [l, u]);
    let f = i(u), d = i(l), p, y;
    const g = a == null ? 10 : +a;
    let m = [];
    if (!(r % 1) && d - f < g) {
      if (f = Math.floor(f), d = Math.ceil(d), u > 0) {
        for (; f <= d; ++f)
          for (p = 1; p < r; ++p)
            if (y = f < 0 ? p / s(-f) : p * s(f), !(y < u)) {
              if (y > l)
                break;
              m.push(y);
            }
      } else
        for (; f <= d; ++f)
          for (p = r - 1; p >= 1; --p)
            if (y = f > 0 ? p / s(-f) : p * s(f), !(y < u)) {
              if (y > l)
                break;
              m.push(y);
            }
      m.length * 2 < g && (m = Si(u, l, g));
    } else
      m = Si(f, d, Math.min(d - f, g)).map(s);
    return h ? m.reverse() : m;
  }, t.tickFormat = (a, c) => {
    if (a == null && (a = 10), c == null && (c = r === 10 ? "s" : ","), typeof c != "function" && (!(r % 1) && (c = sc(c)).precision == null && (c.trim = !0), c = Ho(c)), a === 1 / 0)
      return c;
    const u = Math.max(1, r * a / t.ticks().length);
    return (l) => {
      let h = l / s(Math.round(i(l)));
      return h * r < r - 0.5 && (h *= r), h <= u ? c(l) : "";
    };
  }, t.nice = () => n(Dx(n(), {
    floor: (a) => s(Math.floor(i(a))),
    ceil: (a) => s(Math.ceil(i(a)))
  })), t;
}
function Fx() {
  const e = Ox(eh()).domain([1, 10]);
  return e.copy = () => kc(e, Fx()).base(e.base()), fr.apply(e, arguments), e;
}
function fb(e) {
  return function(t) {
    return Math.sign(t) * Math.log1p(Math.abs(t / e));
  };
}
function hb(e) {
  return function(t) {
    return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
  };
}
function kx(e) {
  var t = 1, n = e(fb(t), hb(t));
  return n.constant = function(r) {
    return arguments.length ? e(fb(t = +r), hb(t)) : t;
  }, Bc(n);
}
function Bx() {
  var e = kx(eh());
  return e.copy = function() {
    return kc(e, Bx()).constant(e.constant());
  }, fr.apply(e, arguments);
}
function db(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function DO(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function OO(e) {
  return e < 0 ? -e * e : e * e;
}
function Rx(e) {
  var t = e(dn, dn), n = 1;
  function r() {
    return n === 1 ? e(dn, dn) : n === 0.5 ? e(DO, OO) : e(db(n), db(1 / n));
  }
  return t.exponent = function(i) {
    return arguments.length ? (n = +i, r()) : n;
  }, Bc(t);
}
function Cx() {
  var e = Rx(eh());
  return e.copy = function() {
    return kc(e, Cx()).exponent(e.exponent());
  }, fr.apply(e, arguments), e;
}
function Px() {
  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] = UT(e, o / a);
    return s;
  }
  function s(o) {
    return o == null || isNaN(o = +o) ? r : t[zf(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(se), 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 Px().domain(e).range(t).unknown(r);
  }, fr.apply(s, arguments);
}
function zx() {
  var e = [0.5], t = [0, 1], n, r = 1;
  function i(s) {
    return s != null && s <= s ? t[zf(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 zx().domain(e).range(t).unknown(n);
  }, fr.apply(i, arguments);
}
const Ad = /* @__PURE__ */ new Date(), Id = /* @__PURE__ */ new Date();
function ce(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) => ce((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) => (Ad.setTime(+s), Id.setTime(+o), e(Ad), e(Id), Math.floor(n(Ad, Id))), 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 cf = ce(() => {
}, (e, t) => {
  e.setTime(+e + t);
}, (e, t) => t - e);
cf.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? ce((t) => {
  t.setTime(Math.floor(t / e) * e);
}, (t, n) => {
  t.setTime(+t + n * e);
}, (t, n) => (n - t) / e) : cf);
cf.range;
const Or = 1e3, pn = Or * 60, Fr = pn * 60, Xr = Fr * 24, Fy = Xr * 7, pb = Xr * 30, Td = Xr * 365, kr = ce((e) => {
  e.setTime(e - e.getMilliseconds());
}, (e, t) => {
  e.setTime(+e + t * Or);
}, (e, t) => (t - e) / Or, (e) => e.getUTCSeconds());
kr.range;
const rh = ce((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Or);
}, (e, t) => {
  e.setTime(+e + t * pn);
}, (e, t) => (t - e) / pn, (e) => e.getMinutes());
rh.range;
const ih = ce((e) => {
  e.setUTCSeconds(0, 0);
}, (e, t) => {
  e.setTime(+e + t * pn);
}, (e, t) => (t - e) / pn, (e) => e.getUTCMinutes());
ih.range;
const sh = ce((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Or - e.getMinutes() * pn);
}, (e, t) => {
  e.setTime(+e + t * Fr);
}, (e, t) => (t - e) / Fr, (e) => e.getHours());
sh.range;
const oh = ce((e) => {
  e.setUTCMinutes(0, 0, 0);
}, (e, t) => {
  e.setTime(+e + t * Fr);
}, (e, t) => (t - e) / Fr, (e) => e.getUTCHours());
oh.range;
const Ko = ce(
  (e) => e.setHours(0, 0, 0, 0),
  (e, t) => e.setDate(e.getDate() + t),
  (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * pn) / Xr,
  (e) => e.getDate() - 1
);
Ko.range;
const ah = ce((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / Xr, (e) => e.getUTCDate() - 1);
ah.range;
const ky = ce((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / Xr, (e) => Math.floor(e / Xr));
ky.range;
function Is(e) {
  return ce((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()) * pn) / Fy);
}
const Bo = Is(0), ac = Is(1), Ux = Is(2), jx = Is(3), Ss = Is(4), qx = Is(5), Vx = Is(6);
Bo.range;
ac.range;
Ux.range;
jx.range;
Ss.range;
qx.range;
Vx.range;
function Ts(e) {
  return ce((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) / Fy);
}
const Ro = Ts(0), cc = Ts(1), Yx = Ts(2), Wx = Ts(3), Ms = Ts(4), Xx = Ts(5), Gx = Ts(6);
Ro.range;
cc.range;
Yx.range;
Wx.range;
Ms.range;
Xx.range;
Gx.range;
const ch = ce((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());
ch.range;
const uh = ce((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());
uh.range;
const On = ce((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());
On.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : ce((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);
});
On.range;
const Fn = ce((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());
Fn.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : ce((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);
});
Fn.range;
function Hx(e, t, n, r, i, s) {
  const o = [
    [kr, 1, Or],
    [kr, 5, 5 * Or],
    [kr, 15, 15 * Or],
    [kr, 30, 30 * Or],
    [s, 1, pn],
    [s, 5, 5 * pn],
    [s, 15, 15 * pn],
    [s, 30, 30 * pn],
    [i, 1, Fr],
    [i, 3, 3 * Fr],
    [i, 6, 6 * Fr],
    [i, 12, 12 * Fr],
    [r, 1, Xr],
    [r, 2, 2 * Xr],
    [n, 1, Fy],
    [t, 1, pb],
    [t, 3, 3 * pb],
    [e, 1, Td]
  ];
  function a(u, l, h) {
    const f = l < u;
    f && ([u, l] = [l, u]);
    const d = h && typeof h.range == "function" ? h : c(u, l, h), p = d ? d.range(u, +l + 1) : [];
    return f ? p.reverse() : p;
  }
  function c(u, l, h) {
    const f = Math.abs(l - u) / h, d = sy(([, , g]) => g).right(o, f);
    if (d === o.length)
      return e.every(mp(u / Td, l / Td, h));
    if (d === 0)
      return cf.every(Math.max(mp(u, l, h), 1));
    const [p, y] = o[f / o[d - 1][2] < o[d][2] / f ? d - 1 : d];
    return p.every(y);
  }
  return [a, c];
}
const [FO, Zx] = Hx(Fn, uh, Ro, ky, oh, ih), [kO, BO] = Hx(On, ch, Bo, Ko, sh, rh);
function Ed(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 Nd(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 ya(e, t, n) {
  return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 };
}
function RO(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 = ma(i), l = ga(i), h = ma(s), f = ga(s), d = ma(o), p = ga(o), y = ma(a), g = ga(a), m = ma(c), b = ga(c), w = {
    a: N,
    A: O,
    b: R,
    B: C,
    c: null,
    d: vb,
    e: vb,
    f: oF,
    g: mF,
    G: bF,
    H: rF,
    I: iF,
    j: sF,
    L: Kx,
    m: aF,
    M: cF,
    p: j,
    q: z,
    Q: Sb,
    s: Mb,
    S: uF,
    u: lF,
    U: fF,
    V: hF,
    w: dF,
    W: pF,
    x: null,
    X: null,
    y: yF,
    Y: gF,
    Z: wF,
    "%": xb
  }, v = {
    a: X,
    A: H,
    b: J,
    B: K,
    c: null,
    d: _b,
    e: _b,
    f: SF,
    g: OF,
    G: kF,
    H: vF,
    I: _F,
    j: xF,
    L: Qx,
    m: MF,
    M: $F,
    p: W,
    q: Y,
    Q: Sb,
    s: Mb,
    S: AF,
    u: IF,
    U: TF,
    V: EF,
    w: NF,
    W: LF,
    x: null,
    X: null,
    y: DF,
    Y: FF,
    Z: BF,
    "%": xb
  }, _ = {
    a: M,
    A,
    b: L,
    B: k,
    c: S,
    d: bb,
    e: bb,
    f: QO,
    g: gb,
    G: mb,
    H: wb,
    I: wb,
    j: HO,
    L: JO,
    m: GO,
    M: ZO,
    p: D,
    q: XO,
    Q: eF,
    s: nF,
    S: KO,
    u: jO,
    U: qO,
    V: VO,
    w: UO,
    W: YO,
    x: I,
    X: E,
    y: gb,
    Y: mb,
    Z: WO,
    "%": tF
  };
  w.x = x(n, w), w.X = x(r, w), w.c = x(t, w), v.x = x(n, v), v.X = x(r, v), v.c = x(t, v);
  function x(U, V) {
    return function(G) {
      var P = [], Q = -1, at = 0, Ot = U.length, xt, Z, Ct;
      for (G instanceof Date || (G = /* @__PURE__ */ new Date(+G)); ++Q < Ot; )
        U.charCodeAt(Q) === 37 && (P.push(U.slice(at, Q)), (Z = yb[xt = U.charAt(++Q)]) != null ? xt = U.charAt(++Q) : Z = xt === "e" ? " " : "0", (Ct = V[xt]) && (xt = Ct(G, Z)), P.push(xt), at = Q + 1);
      return P.push(U.slice(at, Q)), P.join("");
    };
  }
  function $(U, V) {
    return function(G) {
      var P = ya(1900, void 0, 1), Q = T(P, U, G += "", 0), at, Ot;
      if (Q != G.length)
        return null;
      if ("Q" in P)
        return new Date(P.Q);
      if ("s" in P)
        return new Date(P.s * 1e3 + ("L" in P ? P.L : 0));
      if (V && !("Z" in P) && (P.Z = 0), "p" in P && (P.H = P.H % 12 + P.p * 12), P.m === void 0 && (P.m = "q" in P ? P.q : 0), "V" in P) {
        if (P.V < 1 || P.V > 53)
          return null;
        "w" in P || (P.w = 1), "Z" in P ? (at = Nd(ya(P.y, 0, 1)), Ot = at.getUTCDay(), at = Ot > 4 || Ot === 0 ? cc.ceil(at) : cc(at), at = ah.offset(at, (P.V - 1) * 7), P.y = at.getUTCFullYear(), P.m = at.getUTCMonth(), P.d = at.getUTCDate() + (P.w + 6) % 7) : (at = Ed(ya(P.y, 0, 1)), Ot = at.getDay(), at = Ot > 4 || Ot === 0 ? ac.ceil(at) : ac(at), at = Ko.offset(at, (P.V - 1) * 7), P.y = at.getFullYear(), P.m = at.getMonth(), P.d = at.getDate() + (P.w + 6) % 7);
      } else
        ("W" in P || "U" in P) && ("w" in P || (P.w = "u" in P ? P.u % 7 : "W" in P ? 1 : 0), Ot = "Z" in P ? Nd(ya(P.y, 0, 1)).getUTCDay() : Ed(ya(P.y, 0, 1)).getDay(), P.m = 0, P.d = "W" in P ? (P.w + 6) % 7 + P.W * 7 - (Ot + 5) % 7 : P.w + P.U * 7 - (Ot + 6) % 7);
      return "Z" in P ? (P.H += P.Z / 100 | 0, P.M += P.Z % 100, Nd(P)) : Ed(P);
    };
  }
  function T(U, V, G, P) {
    for (var Q = 0, at = V.length, Ot = G.length, xt, Z; Q < at; ) {
      if (P >= Ot)
        return -1;
      if (xt = V.charCodeAt(Q++), xt === 37) {
        if (xt = V.charAt(Q++), Z = _[xt in yb ? V.charAt(Q++) : xt], !Z || (P = Z(U, G, P)) < 0)
          return -1;
      } else if (xt != G.charCodeAt(P++))
        return -1;
    }
    return P;
  }
  function D(U, V, G) {
    var P = u.exec(V.slice(G));
    return P ? (U.p = l.get(P[0].toLowerCase()), G + P[0].length) : -1;
  }
  function M(U, V, G) {
    var P = d.exec(V.slice(G));
    return P ? (U.w = p.get(P[0].toLowerCase()), G + P[0].length) : -1;
  }
  function A(U, V, G) {
    var P = h.exec(V.slice(G));
    return P ? (U.w = f.get(P[0].toLowerCase()), G + P[0].length) : -1;
  }
  function L(U, V, G) {
    var P = m.exec(V.slice(G));
    return P ? (U.m = b.get(P[0].toLowerCase()), G + P[0].length) : -1;
  }
  function k(U, V, G) {
    var P = y.exec(V.slice(G));
    return P ? (U.m = g.get(P[0].toLowerCase()), G + P[0].length) : -1;
  }
  function S(U, V, G) {
    return T(U, t, V, G);
  }
  function I(U, V, G) {
    return T(U, n, V, G);
  }
  function E(U, V, G) {
    return T(U, r, V, G);
  }
  function N(U) {
    return o[U.getDay()];
  }
  function O(U) {
    return s[U.getDay()];
  }
  function R(U) {
    return c[U.getMonth()];
  }
  function C(U) {
    return a[U.getMonth()];
  }
  function j(U) {
    return i[+(U.getHours() >= 12)];
  }
  function z(U) {
    return 1 + ~~(U.getMonth() / 3);
  }
  function X(U) {
    return o[U.getUTCDay()];
  }
  function H(U) {
    return s[U.getUTCDay()];
  }
  function J(U) {
    return c[U.getUTCMonth()];
  }
  function K(U) {
    return a[U.getUTCMonth()];
  }
  function W(U) {
    return i[+(U.getUTCHours() >= 12)];
  }
  function Y(U) {
    return 1 + ~~(U.getUTCMonth() / 3);
  }
  return {
    format: function(U) {
      var V = x(U += "", w);
      return V.toString = function() {
        return U;
      }, V;
    },
    parse: function(U) {
      var V = $(U += "", !1);
      return V.toString = function() {
        return U;
      }, V;
    },
    utcFormat: function(U) {
      var V = x(U += "", v);
      return V.toString = function() {
        return U;
      }, V;
    },
    utcParse: function(U) {
      var V = $(U += "", !0);
      return V.toString = function() {
        return U;
      }, V;
    }
  };
}
var yb = { "-": "", _: " ", 0: "0" }, ye = /^\s*\d+/, CO = /^%/, PO = /[\\^$*+?|[\]().{}]/g;
function Et(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 zO(e) {
  return e.replace(PO, "\\$&");
}
function ma(e) {
  return new RegExp("^(?:" + e.map(zO).join("|") + ")", "i");
}
function ga(e) {
  return new Map(e.map((t, n) => [t.toLowerCase(), n]));
}
function UO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 1));
  return r ? (e.w = +r[0], n + r[0].length) : -1;
}
function jO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 1));
  return r ? (e.u = +r[0], n + r[0].length) : -1;
}
function qO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.U = +r[0], n + r[0].length) : -1;
}
function VO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.V = +r[0], n + r[0].length) : -1;
}
function YO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.W = +r[0], n + r[0].length) : -1;
}
function mb(e, t, n) {
  var r = ye.exec(t.slice(n, n + 4));
  return r ? (e.y = +r[0], n + r[0].length) : -1;
}
function gb(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.y = +r[0] + (+r[0] > 68 ? 1900 : 2e3), n + r[0].length) : -1;
}
function WO(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 XO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 1));
  return r ? (e.q = r[0] * 3 - 3, n + r[0].length) : -1;
}
function GO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.m = r[0] - 1, n + r[0].length) : -1;
}
function bb(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.d = +r[0], n + r[0].length) : -1;
}
function HO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 3));
  return r ? (e.m = 0, e.d = +r[0], n + r[0].length) : -1;
}
function wb(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.H = +r[0], n + r[0].length) : -1;
}
function ZO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.M = +r[0], n + r[0].length) : -1;
}
function KO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 2));
  return r ? (e.S = +r[0], n + r[0].length) : -1;
}
function JO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 3));
  return r ? (e.L = +r[0], n + r[0].length) : -1;
}
function QO(e, t, n) {
  var r = ye.exec(t.slice(n, n + 6));
  return r ? (e.L = Math.floor(r[0] / 1e3), n + r[0].length) : -1;
}
function tF(e, t, n) {
  var r = CO.exec(t.slice(n, n + 1));
  return r ? n + r[0].length : -1;
}
function eF(e, t, n) {
  var r = ye.exec(t.slice(n));
  return r ? (e.Q = +r[0], n + r[0].length) : -1;
}
function nF(e, t, n) {
  var r = ye.exec(t.slice(n));
  return r ? (e.s = +r[0], n + r[0].length) : -1;
}
function vb(e, t) {
  return Et(e.getDate(), t, 2);
}
function rF(e, t) {
  return Et(e.getHours(), t, 2);
}
function iF(e, t) {
  return Et(e.getHours() % 12 || 12, t, 2);
}
function sF(e, t) {
  return Et(1 + Ko.count(On(e), e), t, 3);
}
function Kx(e, t) {
  return Et(e.getMilliseconds(), t, 3);
}
function oF(e, t) {
  return Kx(e, t) + "000";
}
function aF(e, t) {
  return Et(e.getMonth() + 1, t, 2);
}
function cF(e, t) {
  return Et(e.getMinutes(), t, 2);
}
function uF(e, t) {
  return Et(e.getSeconds(), t, 2);
}
function lF(e) {
  var t = e.getDay();
  return t === 0 ? 7 : t;
}
function fF(e, t) {
  return Et(Bo.count(On(e) - 1, e), t, 2);
}
function Jx(e) {
  var t = e.getDay();
  return t >= 4 || t === 0 ? Ss(e) : Ss.ceil(e);
}
function hF(e, t) {
  return e = Jx(e), Et(Ss.count(On(e), e) + (On(e).getDay() === 4), t, 2);
}
function dF(e) {
  return e.getDay();
}
function pF(e, t) {
  return Et(ac.count(On(e) - 1, e), t, 2);
}
function yF(e, t) {
  return Et(e.getFullYear() % 100, t, 2);
}
function mF(e, t) {
  return e = Jx(e), Et(e.getFullYear() % 100, t, 2);
}
function gF(e, t) {
  return Et(e.getFullYear() % 1e4, t, 4);
}
function bF(e, t) {
  var n = e.getDay();
  return e = n >= 4 || n === 0 ? Ss(e) : Ss.ceil(e), Et(e.getFullYear() % 1e4, t, 4);
}
function wF(e) {
  var t = e.getTimezoneOffset();
  return (t > 0 ? "-" : (t *= -1, "+")) + Et(t / 60 | 0, "0", 2) + Et(t % 60, "0", 2);
}
function _b(e, t) {
  return Et(e.getUTCDate(), t, 2);
}
function vF(e, t) {
  return Et(e.getUTCHours(), t, 2);
}
function _F(e, t) {
  return Et(e.getUTCHours() % 12 || 12, t, 2);
}
function xF(e, t) {
  return Et(1 + ah.count(Fn(e), e), t, 3);
}
function Qx(e, t) {
  return Et(e.getUTCMilliseconds(), t, 3);
}
function SF(e, t) {
  return Qx(e, t) + "000";
}
function MF(e, t) {
  return Et(e.getUTCMonth() + 1, t, 2);
}
function $F(e, t) {
  return Et(e.getUTCMinutes(), t, 2);
}
function AF(e, t) {
  return Et(e.getUTCSeconds(), t, 2);
}
function IF(e) {
  var t = e.getUTCDay();
  return t === 0 ? 7 : t;
}
function TF(e, t) {
  return Et(Ro.count(Fn(e) - 1, e), t, 2);
}
function t3(e) {
  var t = e.getUTCDay();
  return t >= 4 || t === 0 ? Ms(e) : Ms.ceil(e);
}
function EF(e, t) {
  return e = t3(e), Et(Ms.count(Fn(e), e) + (Fn(e).getUTCDay() === 4), t, 2);
}
function NF(e) {
  return e.getUTCDay();
}
function LF(e, t) {
  return Et(cc.count(Fn(e) - 1, e), t, 2);
}
function DF(e, t) {
  return Et(e.getUTCFullYear() % 100, t, 2);
}
function OF(e, t) {
  return e = t3(e), Et(e.getUTCFullYear() % 100, t, 2);
}
function FF(e, t) {
  return Et(e.getUTCFullYear() % 1e4, t, 4);
}
function kF(e, t) {
  var n = e.getUTCDay();
  return e = n >= 4 || n === 0 ? Ms(e) : Ms.ceil(e), Et(e.getUTCFullYear() % 1e4, t, 4);
}
function BF() {
  return "+0000";
}
function xb() {
  return "%";
}
function Sb(e) {
  return +e;
}
function Mb(e) {
  return Math.floor(+e / 1e3);
}
var Ps, By, uc;
RF({
  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 RF(e) {
  return Ps = RO(e), By = Ps.format, Ps.parse, uc = Ps.utcFormat, Ps.utcParse, Ps;
}
function CF(e) {
  return new Date(e);
}
function PF(e) {
  return e instanceof Date ? +e : +/* @__PURE__ */ new Date(+e);
}
function Ry(e, t, n, r, i, s, o, a, c, u) {
  var l = Nx(), h = l.invert, f = 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(x) < x ? d : a(x) < x ? p : o(x) < x ? y : s(x) < x ? g : r(x) < x ? i(x) < x ? m : b : n(x) < x ? w : v)(x);
  }
  return l.invert = function(x) {
    return new Date(h(x));
  }, l.domain = function(x) {
    return arguments.length ? f(Array.from(x, PF)) : f().map(CF);
  }, l.ticks = function(x) {
    var $ = f();
    return e($[0], $[$.length - 1], x ?? 10);
  }, l.tickFormat = function(x, $) {
    return $ == null ? _ : u($);
  }, l.nice = function(x) {
    var $ = f();
    return (!x || typeof x.range != "function") && (x = t($[0], $[$.length - 1], x ?? 10)), x ? f(Dx($, x)) : l;
  }, l.copy = function() {
    return kc(l, Ry(e, t, n, r, i, s, o, a, c, u));
  }, l;
}
function zF() {
  return fr.apply(Ry(kO, BO, On, ch, Bo, Ko, sh, rh, kr, By).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
function UF() {
  return fr.apply(Ry(FO, Zx, Fn, uh, Ro, ah, oh, ih, kr, uc).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
}
function lh(e, t) {
  return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown());
}
function fh() {
  var e = 0, t = 0.5, n = 1, r = 1, i, s, o, a, c, u = dn, l, h = !1, f;
  function d(y) {
    return isNaN(y = +y) ? f : (y = 0.5 + ((y = +l(y)) - s) * (r * y < r * s ? a : c), u(h ? 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 ? (h = !!y, d) : h;
  }, 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 = _y(y, [m, b, w]), d) : [u(0), u(0.5), u(1)];
    };
  }
  return d.range = p(Go), d.rangeRound = p(wy), d.unknown = function(y) {
    return arguments.length ? (f = y, d) : f;
  }, 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 e3() {
  var e = Bc(fh()(dn));
  return e.copy = function() {
    return lh(e, e3());
  }, Qf.apply(e, arguments);
}
function n3() {
  var e = Ox(fh()).domain([0.1, 1, 10]);
  return e.copy = function() {
    return lh(e, n3()).base(e.base());
  }, Qf.apply(e, arguments);
}
function r3() {
  var e = kx(fh());
  return e.copy = function() {
    return lh(e, r3()).constant(e.constant());
  }, Qf.apply(e, arguments);
}
function i3() {
  var e = Rx(fh());
  return e.copy = function() {
    return lh(e, i3()).exponent(e.exponent());
  }, Qf.apply(e, arguments);
}
function wt(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 jF = wt("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"), qF = wt("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"), VF = wt("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"), YF = wt("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"), WF = wt("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"), XF = wt("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"), GF = wt("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"), HF = wt("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"), ZF = wt("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"), KF = wt("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"), jt = (e) => Q7(e[e.length - 1]);
var s3 = new Array(3).concat(
  "d8b365f5f5f55ab4ac",
  "a6611adfc27d80cdc1018571",
  "a6611adfc27df5f5f580cdc1018571",
  "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
  "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
  "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
  "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
  "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
  "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
).map(wt);
const o3 = jt(s3);
var a3 = new Array(3).concat(
  "af8dc3f7f7f77fbf7b",
  "7b3294c2a5cfa6dba0008837",
  "7b3294c2a5cff7f7f7a6dba0008837",
  "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
  "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
  "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
  "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
  "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
  "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
).map(wt);
const c3 = jt(a3);
var u3 = new Array(3).concat(
  "e9a3c9f7f7f7a1d76a",
  "d01c8bf1b6dab8e1864dac26",
  "d01c8bf1b6daf7f7f7b8e1864dac26",
  "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
  "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
  "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
  "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
  "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
  "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
).map(wt);
const l3 = jt(u3);
var f3 = new Array(3).concat(
  "998ec3f7f7f7f1a340",
  "5e3c99b2abd2fdb863e66101",
  "5e3c99b2abd2f7f7f7fdb863e66101",
  "542788998ec3d8daebfee0b6f1a340b35806",
  "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
  "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
  "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
  "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
  "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
).map(wt);
const h3 = jt(f3);
var n0 = new Array(3).concat(
  "ef8a62f7f7f767a9cf",
  "ca0020f4a58292c5de0571b0",
  "ca0020f4a582f7f7f792c5de0571b0",
  "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
  "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
  "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
  "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
  "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
  "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
).map(wt);
const uf = jt(n0);
var d3 = new Array(3).concat(
  "ef8a62ffffff999999",
  "ca0020f4a582bababa404040",
  "ca0020f4a582ffffffbababa404040",
  "b2182bef8a62fddbc7e0e0e09999994d4d4d",
  "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
  "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
  "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
  "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
  "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
).map(wt);
const p3 = jt(d3);
var r0 = new Array(3).concat(
  "fc8d59ffffbf91bfdb",
  "d7191cfdae61abd9e92c7bb6",
  "d7191cfdae61ffffbfabd9e92c7bb6",
  "d73027fc8d59fee090e0f3f891bfdb4575b4",
  "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
  "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
  "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
  "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
  "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
).map(wt);
const lf = jt(r0);
var y3 = new Array(3).concat(
  "fc8d59ffffbf91cf60",
  "d7191cfdae61a6d96a1a9641",
  "d7191cfdae61ffffbfa6d96a1a9641",
  "d73027fc8d59fee08bd9ef8b91cf601a9850",
  "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
  "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
  "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
  "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
  "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
).map(wt);
const m3 = jt(y3);
var g3 = new Array(3).concat(
  "fc8d59ffffbf99d594",
  "d7191cfdae61abdda42b83ba",
  "d7191cfdae61ffffbfabdda42b83ba",
  "d53e4ffc8d59fee08be6f59899d5943288bd",
  "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
  "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
  "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
  "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
  "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
).map(wt);
const b3 = jt(g3);
var w3 = new Array(3).concat(
  "e5f5f999d8c92ca25f",
  "edf8fbb2e2e266c2a4238b45",
  "edf8fbb2e2e266c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
).map(wt);
const v3 = jt(w3);
var _3 = new Array(3).concat(
  "e0ecf49ebcda8856a7",
  "edf8fbb3cde38c96c688419d",
  "edf8fbb3cde38c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
).map(wt);
const x3 = jt(_3);
var S3 = new Array(3).concat(
  "e0f3dba8ddb543a2ca",
  "f0f9e8bae4bc7bccc42b8cbe",
  "f0f9e8bae4bc7bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
).map(wt);
const M3 = jt(S3);
var $3 = new Array(3).concat(
  "fee8c8fdbb84e34a33",
  "fef0d9fdcc8afc8d59d7301f",
  "fef0d9fdcc8afc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
).map(wt);
const A3 = jt($3);
var I3 = new Array(3).concat(
  "ece2f0a6bddb1c9099",
  "f6eff7bdc9e167a9cf02818a",
  "f6eff7bdc9e167a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
).map(wt);
const T3 = jt(I3);
var E3 = new Array(3).concat(
  "ece7f2a6bddb2b8cbe",
  "f1eef6bdc9e174a9cf0570b0",
  "f1eef6bdc9e174a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
).map(wt);
const N3 = jt(E3);
var L3 = new Array(3).concat(
  "e7e1efc994c7dd1c77",
  "f1eef6d7b5d8df65b0ce1256",
  "f1eef6d7b5d8df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
).map(wt);
const D3 = jt(L3);
var O3 = new Array(3).concat(
  "fde0ddfa9fb5c51b8a",
  "feebe2fbb4b9f768a1ae017e",
  "feebe2fbb4b9f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
).map(wt);
const F3 = jt(O3);
var k3 = new Array(3).concat(
  "edf8b17fcdbb2c7fb8",
  "ffffcca1dab441b6c4225ea8",
  "ffffcca1dab441b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
).map(wt);
const B3 = jt(k3);
var R3 = new Array(3).concat(
  "f7fcb9addd8e31a354",
  "ffffccc2e69978c679238443",
  "ffffccc2e69978c67931a354006837",
  "ffffccd9f0a3addd8e78c67931a354006837",
  "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
).map(wt);
const C3 = jt(R3);
var P3 = new Array(3).concat(
  "fff7bcfec44fd95f0e",
  "ffffd4fed98efe9929cc4c02",
  "ffffd4fed98efe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
).map(wt);
const z3 = jt(P3);
var U3 = new Array(3).concat(
  "ffeda0feb24cf03b20",
  "ffffb2fecc5cfd8d3ce31a1c",
  "ffffb2fecc5cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
).map(wt);
const j3 = jt(U3);
var q3 = new Array(3).concat(
  "deebf79ecae13182bd",
  "eff3ffbdd7e76baed62171b5",
  "eff3ffbdd7e76baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
).map(wt);
const V3 = jt(q3);
var Y3 = new Array(3).concat(
  "e5f5e0a1d99b31a354",
  "edf8e9bae4b374c476238b45",
  "edf8e9bae4b374c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
).map(wt);
const W3 = jt(Y3);
var X3 = new Array(3).concat(
  "f0f0f0bdbdbd636363",
  "f7f7f7cccccc969696525252",
  "f7f7f7cccccc969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
).map(wt);
const G3 = jt(X3);
var H3 = new Array(3).concat(
  "efedf5bcbddc756bb1",
  "f2f0f7cbc9e29e9ac86a51a3",
  "f2f0f7cbc9e29e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
).map(wt);
const Z3 = jt(H3);
var K3 = new Array(3).concat(
  "fee0d2fc9272de2d26",
  "fee5d9fcae91fb6a4acb181d",
  "fee5d9fcae91fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
).map(wt);
const J3 = jt(K3);
var Q3 = new Array(3).concat(
  "fee6cefdae6be6550d",
  "feeddefdbe85fd8d3cd94701",
  "feeddefdbe85fd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
).map(wt);
const tS = jt(Q3);
function eS(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 nS = vy(cr(300, 0.5, 0), cr(-240, 0.5, 1));
var rS = vy(cr(-100, 0.75, 0.35), cr(80, 1.5, 0.8)), iS = vy(cr(260, 0.75, 0.35), cr(80, 1.5, 0.8)), wu = cr();
function sS(e) {
  (e < 0 || e > 1) && (e -= Math.floor(e));
  var t = Math.abs(e - 0.5);
  return wu.h = 360 * e - 100, wu.s = 1.5 - 1.5 * t, wu.l = 0.8 - 0.9 * t, wu + "";
}
var vu = bn(), JF = Math.PI / 3, QF = Math.PI * 2 / 3;
function oS(e) {
  var t;
  return e = (0.5 - e) * Math.PI, vu.r = 255 * (t = Math.sin(e)) * t, vu.g = 255 * (t = Math.sin(e + JF)) * t, vu.b = 255 * (t = Math.sin(e + QF)) * t, vu + "";
}
function aS(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 hh(e) {
  var t = e.length;
  return function(n) {
    return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))];
  };
}
const cS = hh(wt("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
var uS = hh(wt("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")), lS = hh(wt("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")), fS = hh(wt("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
function he(e) {
  return function() {
    return e;
  };
}
const hS = Math.cos, Cy = Math.min, ff = Math.sin, ue = Math.sqrt, $b = 1e-12, hf = Math.PI, dh = 2 * hf;
function dS(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 z_(t);
}
function pS(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function yS(e) {
  this._context = e;
}
yS.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
      default:
        this._context.lineTo(e, t);
        break;
    }
  }
};
function Rc(e) {
  return new yS(e);
}
function mS(e) {
  return e[0];
}
function gS(e) {
  return e[1];
}
function bS(e, t) {
  var n = he(!0), r = null, i = Rc, s = null, o = dS(a);
  e = typeof e == "function" ? e : e === void 0 ? mS : he(e), t = typeof t == "function" ? t : t === void 0 ? gS : he(t);
  function a(c) {
    var u, l = (c = pS(c)).length, h, f = !1, d;
    for (r == null && (s = i(d = o())), u = 0; u <= l; ++u)
      !(u < l && n(h = c[u], u, c)) === f && ((f = !f) ? s.lineStart() : s.lineEnd()), f && s.point(+e(h, u, c), +t(h, u, c));
    if (d)
      return s = null, d + "" || null;
  }
  return a.x = function(c) {
    return arguments.length ? (e = typeof c == "function" ? c : he(+c), a) : e;
  }, a.y = function(c) {
    return arguments.length ? (t = typeof c == "function" ? c : he(+c), a) : t;
  }, a.defined = function(c) {
    return arguments.length ? (n = typeof c == "function" ? c : he(!!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 Py(e, t, n) {
  var r = null, i = he(!0), s = null, o = Rc, a = null, c = dS(u);
  e = typeof e == "function" ? e : e === void 0 ? mS : he(+e), t = typeof t == "function" ? t : he(t === void 0 ? 0 : +t), n = typeof n == "function" ? n : n === void 0 ? gS : he(+n);
  function u(h) {
    var f, d, p, y = (h = pS(h)).length, g, m = !1, b, w = new Array(y), v = new Array(y);
    for (s == null && (a = o(b = c())), f = 0; f <= y; ++f) {
      if (!(f < y && i(g = h[f], f, h)) === m)
        if (m = !m)
          d = f, a.areaStart(), a.lineStart();
        else {
          for (a.lineEnd(), a.lineStart(), p = f - 1; p >= d; --p)
            a.point(w[p], v[p]);
          a.lineEnd(), a.areaEnd();
        }
      m && (w[f] = +e(g, f, h), v[f] = +t(g, f, h), a.point(r ? +r(g, f, h) : w[f], n ? +n(g, f, h) : v[f]));
    }
    if (b)
      return a = null, b + "" || null;
  }
  function l() {
    return bS().defined(i).curve(o).context(s);
  }
  return u.x = function(h) {
    return arguments.length ? (e = typeof h == "function" ? h : he(+h), r = null, u) : e;
  }, u.x0 = function(h) {
    return arguments.length ? (e = typeof h == "function" ? h : he(+h), u) : e;
  }, u.x1 = function(h) {
    return arguments.length ? (r = h == null ? null : typeof h == "function" ? h : he(+h), u) : r;
  }, u.y = function(h) {
    return arguments.length ? (t = typeof h == "function" ? h : he(+h), n = null, u) : t;
  }, u.y0 = function(h) {
    return arguments.length ? (t = typeof h == "function" ? h : he(+h), u) : t;
  }, u.y1 = function(h) {
    return arguments.length ? (n = h == null ? null : typeof h == "function" ? h : he(+h), 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(h) {
    return arguments.length ? (i = typeof h == "function" ? h : he(!!h), u) : i;
  }, u.curve = function(h) {
    return arguments.length ? (o = h, s != null && (a = o(s)), u) : o;
  }, u.context = function(h) {
    return arguments.length ? (h == null ? s = a = null : a = o(s = h), u) : s;
  }, u;
}
class wS {
  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 tk(e) {
  return new wS(e, !0);
}
function ek(e) {
  return new wS(e, !1);
}
const nk = ue(3), vS = {
  draw(e, t) {
    const n = ue(t + Cy(t / 28, 0.75)) * 0.59436, r = n / 2, i = r * nk;
    e.moveTo(0, n), e.lineTo(0, -n), e.moveTo(-i, -r), e.lineTo(i, r), e.moveTo(-i, r), e.lineTo(i, -r);
  }
}, lc = {
  draw(e, t) {
    const n = ue(t / hf);
    e.moveTo(n, 0), e.arc(0, 0, n, 0, dh);
  }
}, _S = {
  draw(e, t) {
    const n = ue(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();
  }
}, xS = ue(1 / 3), rk = xS * 2, SS = {
  draw(e, t) {
    const n = ue(t / rk), r = n * xS;
    e.moveTo(0, -n), e.lineTo(r, 0), e.lineTo(0, n), e.lineTo(-r, 0), e.closePath();
  }
}, MS = {
  draw(e, t) {
    const n = ue(t) * 0.62625;
    e.moveTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.lineTo(-n, 0), e.closePath();
  }
}, $S = {
  draw(e, t) {
    const n = ue(t - Cy(t / 7, 2)) * 0.87559;
    e.moveTo(-n, 0), e.lineTo(n, 0), e.moveTo(0, n), e.lineTo(0, -n);
  }
}, AS = {
  draw(e, t) {
    const n = ue(t), r = -n / 2;
    e.rect(r, r, n, n);
  }
}, IS = {
  draw(e, t) {
    const n = ue(t) * 0.4431;
    e.moveTo(n, n), e.lineTo(n, -n), e.lineTo(-n, -n), e.lineTo(-n, n), e.closePath();
  }
}, ik = 0.8908130915292852, TS = ff(hf / 10) / ff(7 * hf / 10), sk = ff(dh / 10) * TS, ok = -hS(dh / 10) * TS, ES = {
  draw(e, t) {
    const n = ue(t * ik), r = sk * n, i = ok * n;
    e.moveTo(0, -n), e.lineTo(r, i);
    for (let s = 1; s < 5; ++s) {
      const o = dh * s / 5, a = hS(o), c = ff(o);
      e.lineTo(c * n, -a * n), e.lineTo(a * r - c * i, c * r + a * i);
    }
    e.closePath();
  }
}, Ld = ue(3), NS = {
  draw(e, t) {
    const n = -ue(t / (Ld * 3));
    e.moveTo(0, n * 2), e.lineTo(-Ld * n, -n), e.lineTo(Ld * n, -n), e.closePath();
  }
}, ak = ue(3), LS = {
  draw(e, t) {
    const n = ue(t) * 0.6824, r = n / 2, i = n * ak / 2;
    e.moveTo(0, -n), e.lineTo(i, r), e.lineTo(-i, r), e.closePath();
  }
}, sn = -0.5, on = ue(3) / 2, i0 = 1 / ue(12), ck = (i0 / 2 + 1) * 3, DS = {
  draw(e, t) {
    const n = ue(t / ck), r = n / 2, i = n * i0, s = r, o = n * i0 + n, a = -s, c = o;
    e.moveTo(r, i), e.lineTo(s, o), e.lineTo(a, c), e.lineTo(sn * r - on * i, on * r + sn * i), e.lineTo(sn * s - on * o, on * s + sn * o), e.lineTo(sn * a - on * c, on * a + sn * c), e.lineTo(sn * r + on * i, sn * i - on * r), e.lineTo(sn * s + on * o, sn * o - on * s), e.lineTo(sn * a + on * c, sn * c - on * a), e.closePath();
  }
}, OS = {
  draw(e, t) {
    const n = ue(t - Cy(t / 6, 1.7)) * 0.6189;
    e.moveTo(-n, -n), e.lineTo(n, n), e.moveTo(-n, n), e.lineTo(n, -n);
  }
}, uk = [
  lc,
  _S,
  SS,
  AS,
  ES,
  NS,
  DS
], lk = [
  lc,
  $S,
  OS,
  LS,
  vS,
  IS,
  MS
];
function $i() {
}
function df(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 ph(e) {
  this._context = e;
}
ph.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:
        df(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:
        df(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function fk(e) {
  return new ph(e);
}
function FS(e) {
  this._context = e;
}
FS.prototype = {
  areaStart: $i,
  areaEnd: $i,
  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:
        df(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function hk(e) {
  return new FS(e);
}
function kS(e) {
  this._context = e;
}
kS.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:
        df(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function dk(e) {
  return new kS(e);
}
function BS(e, t) {
  this._basis = new ph(e), this._beta = t;
}
BS.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 pk = function e(t) {
  function n(r) {
    return t === 1 ? new ph(r) : new BS(r, t);
  }
  return n.beta = function(r) {
    return e(+r);
  }, n;
}(0.85);
function pf(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 zy(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
zy.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:
        pf(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:
        pf(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 yk = function e(t) {
  function n(r) {
    return new zy(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function Uy(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Uy.prototype = {
  areaStart: $i,
  areaEnd: $i,
  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:
        pf(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 mk = function e(t) {
  function n(r) {
    return new Uy(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function jy(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
jy.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:
        pf(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 gk = function e(t) {
  function n(r) {
    return new jy(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function qy(e, t, n) {
  var r = e._x1, i = e._y1, s = e._x2, o = e._y2;
  if (e._l01_a > $b) {
    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 > $b) {
    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 RS(e, t) {
  this._context = e, this._alpha = t;
}
RS.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:
        qy(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 bk = function e(t) {
  function n(r) {
    return t ? new RS(r, t) : new zy(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function CS(e, t) {
  this._context = e, this._alpha = t;
}
CS.prototype = {
  areaStart: $i,
  areaEnd: $i,
  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:
        qy(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 wk = function e(t) {
  function n(r) {
    return t ? new CS(r, t) : new Uy(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function PS(e, t) {
  this._context = e, this._alpha = t;
}
PS.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:
        qy(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 vk = function e(t) {
  function n(r) {
    return t ? new PS(r, t) : new jy(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function zS(e) {
  this._context = e;
}
zS.prototype = {
  areaStart: $i,
  areaEnd: $i,
  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 _k(e) {
  return new zS(e);
}
function Ab(e) {
  return e < 0 ? -1 : 1;
}
function Ib(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 (Ab(s) + Ab(o)) * Math.min(Math.abs(s), Math.abs(o), 0.5 * Math.abs(a)) || 0;
}
function Tb(e, t) {
  var n = e._x1 - e._x0;
  return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
}
function Dd(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 yf(e) {
  this._context = e;
}
yf.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:
        Dd(this, this._t0, Tb(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, Dd(this, Tb(this, n = Ib(this, e, t)), n);
          break;
        default:
          Dd(this, this._t0, n = Ib(this, e, t));
          break;
      }
      this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
    }
  }
};
function US(e) {
  this._context = new jS(e);
}
(US.prototype = Object.create(yf.prototype)).point = function(e, t) {
  yf.prototype.point.call(this, t, e);
};
function jS(e) {
  this._context = e;
}
jS.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 xk(e) {
  return new yf(e);
}
function Sk(e) {
  return new US(e);
}
function qS(e) {
  this._context = e;
}
qS.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 = Eb(e), i = Eb(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 Eb(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 Mk(e) {
  return new qS(e);
}
function yh(e, t) {
  this._context = e, this._t = t;
}
yh.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 $k(e) {
  return new yh(e, 0.5);
}
function Ak(e) {
  return new yh(e, 0);
}
function Ik(e) {
  return new yh(e, 1);
}
const _u = (e) => () => e;
function Tk(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 tr(e, t, n) {
  this.k = e, this.x = t, this.y = n;
}
tr.prototype = {
  constructor: tr,
  scale: function(e) {
    return e === 1 ? this : new tr(this.k * e, this.x, this.y);
  },
  translate: function(e, t) {
    return e === 0 & t === 0 ? this : new tr(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 VS = new tr(1, 0, 0);
tr.prototype;
function Od(e) {
  e.stopImmediatePropagation();
}
function ba(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function Ek(e) {
  return (!e.ctrlKey || e.type === "wheel") && !e.button;
}
function Nk() {
  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 Nb() {
  return this.__zoom || VS;
}
function Lk(e) {
  return -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 2e-3) * (e.ctrlKey ? 10 : 1);
}
function Dk() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function Ok(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 Fk() {
  var e = Ek, t = Nk, n = Ok, r = Lk, i = Dk, s = [0, 1 / 0], o = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], a = 250, c = pN, u = Vf("start", "zoom", "end"), l, h, f, d = 500, p = 150, y = 0, g = 10;
  function m(S) {
    S.property("__zoom", Nb).on("wheel.zoom", T, { passive: !1 }).on("mousedown.zoom", D).on("dblclick.zoom", M).filter(i).on("touchstart.zoom", A).on("touchmove.zoom", L).on("touchend.zoom touchcancel.zoom", k).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  m.transform = function(S, I, E, N) {
    var O = S.selection ? S.selection() : S;
    O.property("__zoom", Nb), S !== O ? _(S, I, E, N) : O.interrupt().each(function() {
      x(this, arguments).event(N).start().zoom(null, typeof I == "function" ? I.apply(this, arguments) : I).end();
    });
  }, m.scaleBy = function(S, I, E, N) {
    m.scaleTo(S, function() {
      var O = this.__zoom.k, R = typeof I == "function" ? I.apply(this, arguments) : I;
      return O * R;
    }, E, N);
  }, m.scaleTo = function(S, I, E, N) {
    m.transform(S, function() {
      var O = t.apply(this, arguments), R = this.__zoom, C = E == null ? v(O) : typeof E == "function" ? E.apply(this, arguments) : E, j = R.invert(C), z = typeof I == "function" ? I.apply(this, arguments) : I;
      return n(w(b(R, z), C, j), O, o);
    }, E, N);
  }, m.translateBy = function(S, I, E, N) {
    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, N);
  }, m.translateTo = function(S, I, E, N, O) {
    m.transform(S, function() {
      var R = t.apply(this, arguments), C = this.__zoom, j = N == null ? v(R) : typeof N == "function" ? N.apply(this, arguments) : N;
      return n(VS.translate(j[0], j[1]).scale(C.k).translate(
        typeof I == "function" ? -I.apply(this, arguments) : -I,
        typeof E == "function" ? -E.apply(this, arguments) : -E
      ), R, o);
    }, N, O);
  };
  function b(S, I) {
    return I = Math.max(s[0], Math.min(s[1], I)), I === S.k ? S : new tr(I, S.x, S.y);
  }
  function w(S, I, E) {
    var N = I[0] - E[0] * S.k, O = I[1] - E[1] * S.k;
    return N === S.x && O === S.y ? S : new tr(S.k, N, O);
  }
  function v(S) {
    return [(+S[0][0] + +S[1][0]) / 2, (+S[0][1] + +S[1][1]) / 2];
  }
  function _(S, I, E, N) {
    S.on("start.zoom", function() {
      x(this, arguments).event(N).start();
    }).on("interrupt.zoom end.zoom", function() {
      x(this, arguments).event(N).end();
    }).tween("zoom", function() {
      var O = this, R = arguments, C = x(O, R).event(N), j = t.apply(O, R), z = E == null ? v(j) : typeof E == "function" ? E.apply(O, R) : E, X = Math.max(j[1][0] - j[0][0], j[1][1] - j[0][1]), H = O.__zoom, J = typeof I == "function" ? I.apply(O, R) : I, K = c(H.invert(z).concat(X / H.k), J.invert(z).concat(X / J.k));
      return function(W) {
        if (W === 1)
          W = J;
        else {
          var Y = K(W), U = X / Y[2];
          W = new tr(U, z[0] - Y[0] * U, z[1] - Y[1] * U);
        }
        C.zoom(null, W);
      };
    });
  }
  function x(S, I, E) {
    return !E && S.__zooming || new $(S, I);
  }
  function $(S, I) {
    this.that = S, this.args = I, this.active = 0, this.sourceEvent = null, this.extent = t.apply(S, I), this.taps = 0;
  }
  $.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 = zt(this.that).datum();
      u.call(
        S,
        this.that,
        new Tk(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 = x(this, I).event(S), N = this.__zoom, O = Math.max(s[0], Math.min(s[1], N.k * Math.pow(2, r.apply(this, arguments)))), R = _n(S);
    if (E.wheel)
      (E.mouse[0][0] !== R[0] || E.mouse[0][1] !== R[1]) && (E.mouse[1] = N.invert(E.mouse[0] = R)), clearTimeout(E.wheel);
    else {
      if (N.k === O)
        return;
      E.mouse = [R, N.invert(R)], co(this), E.start();
    }
    ba(S), E.wheel = setTimeout(C, p), E.zoom("mouse", n(w(b(N, O), E.mouse[0], E.mouse[1]), E.extent, o));
    function C() {
      E.wheel = null, E.end();
    }
  }
  function D(S, ...I) {
    if (f || !e.apply(this, arguments))
      return;
    var E = S.currentTarget, N = x(this, I, !0).event(S), O = zt(S.view).on("mousemove.zoom", z, !0).on("mouseup.zoom", X, !0), R = _n(S, E), C = S.clientX, j = S.clientY;
    p_(S.view), Od(S), N.mouse = [R, this.__zoom.invert(R)], co(this), N.start();
    function z(H) {
      if (ba(H), !N.moved) {
        var J = H.clientX - C, K = H.clientY - j;
        N.moved = J * J + K * K > y;
      }
      N.event(H).zoom("mouse", n(w(N.that.__zoom, N.mouse[0] = _n(H, E), N.mouse[1]), N.extent, o));
    }
    function X(H) {
      O.on("mousemove.zoom mouseup.zoom", null), y_(H.view, N.moved), ba(H), N.event(H).end();
    }
  }
  function M(S, ...I) {
    if (e.apply(this, arguments)) {
      var E = this.__zoom, N = _n(S.changedTouches ? S.changedTouches[0] : S, this), O = E.invert(N), R = E.k * (S.shiftKey ? 0.5 : 2), C = n(w(b(E, R), N, O), t.apply(this, I), o);
      ba(S), a > 0 ? zt(this).transition().duration(a).call(_, C, N, S) : zt(this).call(m.transform, C, N, S);
    }
  }
  function A(S, ...I) {
    if (e.apply(this, arguments)) {
      var E = S.touches, N = E.length, O = x(this, I, S.changedTouches.length === N).event(S), R, C, j, z;
      for (Od(S), C = 0; C < N; ++C)
        j = E[C], z = _n(j, this), z = [z, this.__zoom.invert(z), j.identifier], O.touch0 ? !O.touch1 && O.touch0[2] !== z[2] && (O.touch1 = z, O.taps = 0) : (O.touch0 = z, R = !0, O.taps = 1 + !!l);
      l && (l = clearTimeout(l)), R && (O.taps < 2 && (h = z[0], l = setTimeout(function() {
        l = null;
      }, d)), co(this), O.start());
    }
  }
  function L(S, ...I) {
    if (this.__zooming) {
      var E = x(this, I).event(S), N = S.changedTouches, O = N.length, R, C, j, z;
      for (ba(S), R = 0; R < O; ++R)
        C = N[R], j = _n(C, this), E.touch0 && E.touch0[2] === C.identifier ? E.touch0[0] = j : E.touch1 && E.touch1[2] === C.identifier && (E.touch1[0] = j);
      if (C = E.that.__zoom, E.touch1) {
        var X = E.touch0[0], H = E.touch0[1], J = E.touch1[0], K = E.touch1[1], W = (W = J[0] - X[0]) * W + (W = J[1] - X[1]) * W, Y = (Y = K[0] - H[0]) * Y + (Y = K[1] - H[1]) * Y;
        C = b(C, Math.sqrt(W / Y)), j = [(X[0] + J[0]) / 2, (X[1] + J[1]) / 2], z = [(H[0] + K[0]) / 2, (H[1] + K[1]) / 2];
      } else if (E.touch0)
        j = E.touch0[0], z = E.touch0[1];
      else
        return;
      E.zoom("touch", n(w(C, j, z), E.extent, o));
    }
  }
  function k(S, ...I) {
    if (this.__zooming) {
      var E = x(this, I).event(S), N = S.changedTouches, O = N.length, R, C;
      for (Od(S), f && clearTimeout(f), f = setTimeout(function() {
        f = null;
      }, d), R = 0; R < O; ++R)
        C = N[R], E.touch0 && E.touch0[2] === C.identifier ? delete E.touch0 : E.touch1 && E.touch1[2] === C.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 && (C = _n(C, this), Math.hypot(h[0] - C[0], h[1] - C[1]) < g)) {
        var j = zt(this).on("dblclick.zoom");
        j && j.apply(this, arguments);
      }
    }
  }
  return m.wheelDelta = function(S) {
    return arguments.length ? (r = typeof S == "function" ? S : _u(+S), m) : r;
  }, m.filter = function(S) {
    return arguments.length ? (e = typeof S == "function" ? S : _u(!!S), m) : e;
  }, m.touchable = function(S) {
    return arguments.length ? (i = typeof S == "function" ? S : _u(!!S), m) : i;
  }, m.extent = function(S) {
    return arguments.length ? (t = typeof S == "function" ? S : _u([[+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 Oe(e) {
  return e != null && !Number.isNaN(e);
}
function Gr(e, t) {
  return +Oe(t) - +Oe(e) || se(e, t);
}
function s0(e, t) {
  return +Oe(t) - +Oe(e) || Ec(e, t);
}
function Vy(e) {
  return e != null && `${e}` != "";
}
function mf(e) {
  return isFinite(e) ? e : NaN;
}
function zr(e) {
  return e > 0 && isFinite(e) ? e : NaN;
}
function mh(e) {
  return e < 0 && isFinite(e) ? e : NaN;
}
const kk = /* @__PURE__ */ new Map([
  ["second", kr],
  ["minute", rh],
  ["hour", sh],
  ["day", Ko],
  // TODO local time equivalent of unixDay?
  ["week", Bo],
  ["month", ch],
  ["year", On],
  ["monday", ac],
  ["tuesday", Ux],
  ["wednesday", jx],
  ["thursday", Ss],
  ["friday", qx],
  ["saturday", Vx],
  ["sunday", Bo]
]), Bk = /* @__PURE__ */ new Map([
  ["second", kr],
  ["minute", ih],
  ["hour", oh],
  ["day", ky],
  ["week", Ro],
  ["month", uh],
  ["year", Fn],
  ["monday", cc],
  ["tuesday", Yx],
  ["wednesday", Wx],
  ["thursday", Ms],
  ["friday", Xx],
  ["saturday", Gx],
  ["sunday", Ro]
]);
function YS(e, t) {
  let n = `${e}`.toLowerCase();
  n.endsWith("s") && (n = n.slice(0, -1));
  let r = 1;
  const i = /^(?:(\d+)\s+)/.exec(n);
  switch (i && (n = n.slice(i[0].length), r = +i[1]), n) {
    case "quarter":
      n = "month", r *= 3;
      break;
    case "half":
      n = "month", r *= 6;
      break;
  }
  let s = t.get(n);
  if (!s)
    throw new Error(`unknown interval: ${e}`);
  if (!(r > 1))
    return s;
  if (!s.every)
    throw new Error(`non-periodic interval: ${n}`);
  return s.every(r);
}
function Rk(e) {
  return YS(e, kk);
}
function WS(e) {
  return YS(e, Bk);
}
function Ck(e) {
  if (!e)
    return !1;
  const t = e.floor(new Date(Date.UTC(2e3, 11, 31)));
  return Fn(t) >= t;
}
function Pk(e) {
  if (!e)
    return !1;
  const t = e.floor(new Date(2e3, 11, 31));
  return On(t) >= t;
}
const Co = Object.getPrototypeOf(Uint8Array), zk = Object.prototype.toString;
function Mt(e, t, n) {
  const r = typeof t;
  return r === "string" ? Lb(e, XS(t), n) : r === "function" ? Lb(e, t, n) : r === "number" || t instanceof Date || r === "boolean" ? Xt(e, nn(t), n) : typeof (t == null ? void 0 : t.transform) == "function" ? Db(t.transform(e), n) : Db(t, n);
}
function Lb(e, t, n) {
  return Xt(e, (n == null ? void 0 : n.prototype) instanceof Co ? Uk(t) : t, n);
}
function Db(e, t) {
  return t === void 0 ? kn(e) : e instanceof t ? e : t.prototype instanceof Co && !(e instanceof Co) ? t.from(e, Xy) : t.from(e);
}
function Uk(e) {
  return (t, n) => Xy(e(t, n));
}
const Pa = [null], XS = (e) => (t) => t[e], We = { transform: ti }, ot = { transform: (e) => e }, Yy = () => 1, jk = () => !0, ge = (e) => e == null ? e : `${e}`, At = (e) => e == null ? e : +e, Cc = (e) => e ? e[0] : void 0, fc = (e) => e ? e[1] : void 0, qk = (e) => e ? e[2] : void 0, nn = (e) => () => e;
function Wy(e) {
  const t = +`${e}`.slice(1) / 100;
  return (n, r) => Mi(n, t, r);
}
function Pe(e) {
  return e instanceof Co ? e : Xt(e, Xy, Float64Array);
}
function Xy(e) {
  return e == null ? NaN : Number(e);
}
function Vk(e) {
  return Xt(e, GS);
}
function GS(e) {
  return e instanceof Date && !isNaN(e) ? e : typeof e == "string" ? ey(e) : e == null || isNaN(e = +e) ? void 0 : new Date(e);
}
function qe(e, t) {
  return e === void 0 && (e = t), e === null ? [void 0, "none"] : zc(e) ? [void 0, e] : [e, void 0];
}
function ie(e, t) {
  return e === void 0 && (e = t), e === null || typeof e == "number" ? [void 0, e] : [e, void 0];
}
function gh(e, t, n) {
  if (e != null)
    return Qr(e, t, n);
}
function Qr(e, t, n) {
  const r = `${e}`.toLowerCase();
  if (!n.includes(r))
    throw new Error(`invalid ${t}: ${e}`);
  return r;
}
function kn(e) {
  return e == null || e instanceof Array || e instanceof Co ? e : Array.from(e);
}
function Xt(e, t, n = Array) {
  return e == null ? e : e instanceof n ? e.map(t) : n.from(e, t);
}
function o0(e, t = Array) {
  return e instanceof t ? e.slice() : t.from(e);
}
function HS({ x: e, x1: t, x2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function ZS({ y: e, y1: t, y2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function bh(e) {
  return HS(e) || ZS(e) || e.interval !== void 0;
}
function hr(e) {
  return (e == null ? void 0 : e.toString) === zk;
}
function fs(e) {
  return hr(e) && (e.type !== void 0 || e.domain !== void 0);
}
function Vn(e) {
  return hr(e) && typeof e.transform != "function";
}
function Ai(e) {
  return Vn(e) && e.value === void 0 && e.channel === void 0;
}
function KS(e, t, n, r = ot) {
  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 Pn(e, t) {
  return e === void 0 && t === void 0 ? [Cc, fc] : [e, t];
}
function Bi({ z: e, fill: t, stroke: n } = {}) {
  return e === void 0 && ([e] = qe(t)), e === void 0 && ([e] = qe(n)), e;
}
function ti(e) {
  const t = e.length, n = new Uint32Array(t);
  for (let r = 0; r < t; ++r)
    n[r] = r;
  return n;
}
function wh(e, t) {
  return Xt(t, (n) => e[n]);
}
function Gy(e) {
  return e.length === 1 ? (t, n) => e(wh(n, t)) : e;
}
function os(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function JS(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 Je(e) {
  let t;
  return [
    {
      transform: () => t,
      label: ei(e)
    },
    (n) => t = n
  ];
}
function Be(e) {
  return e == null ? [e] : Je(e);
}
function ei(e, t) {
  return typeof e == "string" ? e : e && e.label !== void 0 ? e.label : t;
}
function gf(e, t) {
  return {
    transform(n) {
      const r = e.transform(n), i = t.transform(n);
      return Ve(r) || Ve(i) ? Xt(r, (s, o) => new Date((+r[o] + +i[o]) / 2)) : Xt(r, (s, o) => (+r[o] + +i[o]) / 2, Float64Array);
    },
    label: e.label
  };
}
function bf(e, t) {
  const n = QS(t == null ? void 0 : t.interval, t == null ? void 0 : t.type);
  return n ? Xt(e, n) : e;
}
function QS(e, t) {
  const n = Hy(e, t);
  return n && ((r) => Oe(r) ? n.floor(r) : r);
}
function Hy(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) => Ze(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) => Ze(Math.ceil(r / n), i / n).map((s) => s * n)
      };
    }
    if (typeof e == "string")
      return (t === "time" ? Rk : WS)(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 Jo(e, t) {
  if (e = Hy(e, t), e && typeof e.range != "function")
    throw new Error("invalid interval: missing range method");
  return e;
}
function Yk(e, t) {
  if (e = Jo(e, t), e && typeof e.ceil != "function")
    throw new Error("invalid interval: missing ceil method");
  return e;
}
function Pc(e) {
  return e === void 0 || Vn(e) ? e : { value: e };
}
function Wk(e) {
  return e == null ? null : {
    transform: (t) => Mt(t, e, Float64Array),
    label: ei(e)
  };
}
function Xk(e) {
  if (!dr(e))
    return !1;
  for (const t of e)
    if (t != null)
      return typeof t == "object" && "0" in t && "1" in t;
}
function dr(e) {
  return e && typeof e[Symbol.iterator] == "function";
}
function t6(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 Ve(e) {
  for (const t of e)
    if (t != null)
      return t instanceof Date;
}
function Gk(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "string" && isNaN(t) && ey(t);
}
function Hk(e) {
  for (const t of e)
    if (t != null) {
      if (typeof t != "string")
        return !1;
      if (t.trim())
        return !isNaN(t);
    }
}
function e6(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "number";
}
function Fd(e, t) {
  let n;
  for (const r of e)
    if (r != null) {
      if (!t(r))
        return !1;
      n = !0;
    }
  return n;
}
function zc(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
  Vr(e) !== null);
}
function Zk(e) {
  return typeof e == "number" && (0 <= e && e <= 1 || isNaN(e));
}
function ae(e) {
  return e == null || Po(e);
}
function Po(e) {
  return /^\s*none\s*$/i.test(e);
}
function Kk(e) {
  return /^\s*round\s*$/i.test(e);
}
function n6(e, t) {
  return gh(e, t, [
    "middle",
    "top-left",
    "top",
    "top-right",
    "right",
    "bottom-right",
    "bottom",
    "bottom-left",
    "left"
  ]);
}
function Uc(e = "middle") {
  return n6(e, "frameAnchor");
}
function hc(e) {
  if (e == null)
    return;
  const t = e[0], n = e[e.length - 1];
  return Ec(t, n);
}
function Jk(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 Qk(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 Zy(e) {
  return dr(e) ? Qk(e) : e;
}
const er = Symbol("position"), ni = Symbol("color"), vh = Symbol("radius"), _h = Symbol("length"), xh = Symbol("opacity"), Sh = Symbol("symbol"), Qt = /* @__PURE__ */ new Map([
  ["x", er],
  ["y", er],
  ["fx", er],
  ["fy", er],
  ["r", vh],
  ["color", ni],
  ["opacity", xh],
  ["symbol", Sh],
  ["length", _h]
]), r6 = Math.sqrt(3), i6 = 2 / r6, tB = {
  draw(e, t) {
    const n = Math.sqrt(t / Math.PI), r = n * i6, 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();
  }
}, Ky = /* @__PURE__ */ new Map([
  ["asterisk", vS],
  ["circle", lc],
  ["cross", _S],
  ["diamond", SS],
  ["diamond2", MS],
  ["hexagon", tB],
  ["plus", $S],
  ["square", AS],
  ["square2", IS],
  ["star", ES],
  ["times", OS],
  ["triangle", NS],
  ["triangle2", LS],
  ["wye", DS]
]);
function Jy(e) {
  return e && typeof e.draw == "function";
}
function eB(e) {
  return Jy(e) ? !0 : typeof e != "string" ? !1 : Ky.has(e.toLowerCase());
}
function Qy(e) {
  if (e == null || Jy(e))
    return e;
  const t = Ky.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid symbol: ${e}`);
}
function nB(e) {
  if (e == null || Jy(e))
    return [void 0, e];
  if (typeof e == "string") {
    const t = Ky.get(`${e}`.toLowerCase());
    if (t)
      return [void 0, t];
  }
  return [e, void 0];
}
function pr({ filter: e, sort: t, reverse: n, transform: r, initializer: i, ...s } = {}, o) {
  if (r === void 0 && (e != null && (r = tm(e)), t != null && !Ai(t) && (r = kd(r, nm(t))), n && (r = kd(r, em))), o != null && i != null)
    throw new Error("transforms cannot be applied after initializers");
  return {
    ...s,
    ...(t === null || Ai(t)) && { sort: t },
    transform: kd(r, o)
  };
}
function rn({ filter: e, sort: t, reverse: n, initializer: r, ...i } = {}, s) {
  return r === void 0 && (e != null && (r = tm(e)), t != null && !Ai(t) && (r = Bd(r, nm(t))), n && (r = Bd(r, em))), {
    ...i,
    ...(t === null || Ai(t)) && { sort: t },
    initializer: Bd(r, s)
  };
}
function kd(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, kn(n), r, i);
  };
}
function Bd(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, h;
    return { data: a = n, facets: c = r, channels: o } = e.call(this, n, r, i, ...s), { data: l = a, facets: h = c, channels: u } = t.call(this, a, c, { ...i, ...o }, ...s), { data: l, facets: h, channels: { ...o, ...u } };
  };
}
function Mh(e, t) {
  return (e.initializer != null ? rn : pr)(e, t);
}
function rB(e, t) {
  return Mh(t, tm(e));
}
function tm(e) {
  return (t, n) => {
    const r = Mt(t, e);
    return { data: t, facets: n.map((i) => i.filter((s) => r[s])) };
  };
}
function iB({ sort: e, ...t } = {}) {
  return {
    ...Mh(t, em),
    sort: Ai(e) ? e : null
  };
}
function em(e, t) {
  return { data: e, facets: t.map((n) => n.slice().reverse()) };
}
function sB({ seed: e, sort: t, ...n } = {}) {
  return {
    ...Mh(n, o6(e == null ? Math.random : Dy(e))),
    sort: Ai(t) ? t : null
  };
}
function s6(e, { sort: t, ...n } = {}) {
  return {
    ...(Vn(e) && e.channel !== void 0 ? rn : Mh)(n, nm(e)),
    sort: Ai(t) ? t : null
  };
}
function nm(e) {
  return (typeof e == "function" && e.length !== 1 ? oB : o6)(e);
}
function oB(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 o6(e) {
  let t, n;
  ({ channel: t, value: e, order: n } = { ...Pc(e) });
  const r = t == null ? void 0 : t.startsWith("-");
  if (r && (t = t.slice(1)), n === void 0 && (n = r ? s0 : Gr), typeof n != "function")
    switch (`${n}`.toLowerCase()) {
      case "ascending":
        n = Gr;
        break;
      case "descending":
        n = s0;
        break;
      default:
        throw new Error(`invalid order: ${n}`);
    }
  return (i, s, o) => {
    let a;
    if (t === void 0)
      a = Mt(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 rm(e, t) {
  return $h(null, null, e, t);
}
function dc(e = { y: "count" }, t = {}) {
  const { x: n = ot } = t;
  if (n == null)
    throw new Error("missing channel: x");
  return $h(n, null, e, t);
}
function pc(e = { x: "count" }, t = {}) {
  const { y: n = ot } = t;
  if (n == null)
    throw new Error("missing channel: y");
  return $h(null, n, e, t);
}
function im(e = { fill: "count" }, t = {}) {
  let { x: n, y: r } = t;
  if ([n, r] = Pn(n, r), n == null)
    throw new Error("missing channel: x");
  if (r == null)
    throw new Error("missing channel: y");
  return $h(n, r, e, t);
}
function $h(e, t, {
  data: n = um,
  filter: r,
  sort: i,
  reverse: s,
  ...o
  // output channel definitions
} = {}, a = {}) {
  o = sm(o, a), n = Ah(n, ot), i = i == null ? void 0 : om("sort", i, a), r = r == null ? void 0 : am("filter", r, a);
  const [c, u] = Be(e), [l, h] = Be(t), {
    z: f,
    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, _] = Be(f), [x] = qe(d), [$] = qe(p), [T, D] = Be(x), [M, A] = Be($);
  return {
    ..."z" in a && { z: v || f },
    ..."fill" in a && { fill: T || d },
    ..."stroke" in a && { stroke: M || p },
    ...pr(w, (L, k, S) => {
      const I = bf(Mt(L, e), S == null ? void 0 : S.x), E = bf(Mt(L, t), S == null ? void 0 : S.y), N = Mt(L, f), O = Mt(L, x), R = Mt(L, $), C = cm(o, { z: N, fill: O, stroke: R }), j = [], z = [], X = I && u([]), H = E && h([]), J = N && _([]), K = O && D([]), W = R && A([]);
      let Y = 0;
      for (const U of o)
        U.initialize(L);
      i && i.initialize(L), r && r.initialize(L);
      for (const U of k) {
        const V = [];
        for (const G of o)
          G.scope("facet", U);
        i && i.scope("facet", U), r && r.scope("facet", U);
        for (const [G, P] of uo(U, C))
          for (const [Q, at] of uo(P, E))
            for (const [Ot, xt] of uo(at, I))
              if (!(r && !r.reduce(xt))) {
                V.push(Y++), z.push(n.reduceIndex(xt, L)), I && X.push(Ot), E && H.push(Q), N && J.push(C === N ? G : N[xt[0]]), O && K.push(C === O ? G : O[xt[0]]), R && W.push(C === R ? G : R[xt[0]]);
                for (const Z of o)
                  Z.reduce(xt);
                i && i.reduce(xt);
              }
        j.push(V);
      }
      return a6(j, i, s), { data: z, facets: j };
    }),
    ...!pi(o, "x") && (c ? { x: c } : { x1: y, x2: g }),
    ...!pi(o, "y") && (l ? { y: l } : { y1: m, y2: b }),
    ...Object.fromEntries(o.map(({ name: L, output: k }) => [L, k]))
  };
}
function pi(e, ...t) {
  for (const { name: n } of e)
    if (t.includes(n))
      return !0;
  return !1;
}
function sm(e, t, n = om) {
  const r = Object.entries(e);
  return t.title != null && e.title === void 0 && r.push(["title", fB]), t.href != null && e.href === void 0 && r.push(["href", lm]), r.filter(([, i]) => i !== void 0).map(([i, s]) => s === null ? aB(i) : n(i, s, t));
}
function om(e, t, n, r = am) {
  let i;
  hr(t) && "reduce" in t && (i = t.scale, t = t.reduce);
  const s = r(e, t, n), [o, a] = Je(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 aB(e) {
  return { name: e, initialize() {
  }, scope() {
  }, reduce() {
  } };
}
function am(e, t, n, r = Ah) {
  const i = JS(e, n), s = r(t, i);
  let o, a;
  return {
    label: ei(s === wf ? null : i, s.label),
    initialize(c) {
      o = i === void 0 ? c : Mt(c, i), s.scope === "data" && (a = s.reduceIndex(ti(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 uo(e, t) {
  return t ? Ka(
    Jr(e, (n) => t[n]),
    Cc
  ) : [[, e]];
}
function Ah(e, t, n = cB) {
  if (e == null)
    return n(e);
  if (typeof e.reduceIndex == "function")
    return e;
  if (typeof e.reduce == "function" && hr(e))
    return uB(e);
  if (typeof e == "function")
    return lB(e);
  if (/^p\d{2}$/i.test(e))
    return Sr(Wy(e));
  switch (`${e}`.toLowerCase()) {
    case "first":
      return lm;
    case "last":
      return hB;
    case "identity":
      return um;
    case "count":
      return wf;
    case "distinct":
      return dB;
    case "sum":
      return t == null ? wf : pB;
    case "proportion":
      return Fb(t, "data");
    case "proportion-facet":
      return Fb(t, "facet");
    case "deviation":
      return Sr(jf);
    case "min":
      return Sr(pe);
    case "min-index":
      return Sr(zT);
    case "max":
      return Sr(te);
    case "max-index":
      return Sr(PT);
    case "mean":
      return Ob(hy);
    case "median":
      return Ob(tc);
    case "variance":
      return Sr(oy);
    case "mode":
      return Sr(e_);
  }
  return n(e);
}
function cB(e) {
  throw new Error(`invalid reduce: ${e}`);
}
function cm(e, t) {
  for (const n in t) {
    const r = t[n];
    if (r !== void 0 && !e.some((i) => i.name === n))
      return r;
  }
}
function a6(e, t, n) {
  if (t) {
    const r = t.output.transform(), i = (s, o) => Gr(r[s], r[o]);
    e.forEach((s) => s.sort(i));
  }
  n && e.forEach((r) => r.reverse());
}
function uB(e) {
  return console.warn("deprecated reduce interface; implement reduceIndex instead."), { ...e, reduceIndex: e.reduce.bind(e) };
}
function lB(e) {
  return {
    reduceIndex(t, n, r) {
      return e(wh(n, t), r);
    }
  };
}
function Sr(e) {
  return {
    reduceIndex(t, n) {
      return e(t, (r) => n[r]);
    }
  };
}
function Ob(e) {
  return {
    reduceIndex(t, n) {
      const r = e(t, (i) => n[i]);
      return Ve(n) ? new Date(r) : r;
    }
  };
}
const um = {
  reduceIndex(e, t) {
    return wh(t, e);
  }
}, lm = {
  reduceIndex(e, t) {
    return t[e[0]];
  }
}, fB = {
  reduceIndex(e, t) {
    const r = Ka(
      so(
        e,
        (s) => s.length,
        (s) => t[s]
      ),
      fc
    ), i = r.slice(-5).reverse();
    if (i.length < r.length) {
      const s = r.slice(0, -4);
      i[5 - 1] = [`… ${s.length.toLocaleString("en-US")} more`, ar(s, fc)];
    }
    return i.map(([s, o]) => `${s} (${o.toLocaleString("en-US")})`).join(`
`);
  }
}, hB = {
  reduceIndex(e, t) {
    return t[e[e.length - 1]];
  }
}, wf = {
  label: "Frequency",
  reduceIndex(e) {
    return e.length;
  }
}, dB = {
  label: "Distinct",
  reduceIndex(e, t) {
    const n = new qf();
    for (const r of e)
      n.add(t[r]);
    return n.size;
  }
}, pB = Sr(ar);
function Fb(e, t) {
  return e == null ? { scope: t, label: "Frequency", reduceIndex: (n, r, i = 1) => n.length / i } : { scope: t, reduceIndex: (n, r, i = 1) => ar(n, (s) => r[s]) / i };
}
function yc(e, { scale: t, type: n, value: r, filter: i, hint: s }, o) {
  return s === void 0 && typeof (r == null ? void 0 : r.transform) == "function" && (s = r.hint), u6(o, {
    scale: t,
    type: n,
    value: Mt(e, r),
    label: ei(r),
    filter: i,
    hint: s
  });
}
function c6(e, t) {
  return Object.fromEntries(
    Object.entries(e).map(([n, r]) => [n, yc(t, r, n)])
  );
}
function fm(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 : Xt(s, o)];
    })
  );
  return n.channels = e, n;
}
function u6(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 && Fd(r, zc) ? null : "color";
        break;
      case "fillOpacity":
      case "strokeOpacity":
      case "opacity":
        t.scale = n !== !0 && Fd(r, Zk) ? null : "opacity";
        break;
      case "symbol":
        n !== !0 && Fd(r, eB) ? (t.scale = null, t.value = Xt(r, Qy)) : t.scale = "symbol";
        break;
      default:
        t.scale = Qt.has(e) ? e : null;
        break;
    }
  else if (n === !1)
    t.scale = null;
  else if (n != null && !Qt.has(n))
    throw new Error(`unknown scale: ${n}`);
  return t;
}
function yB(e, t, n, r, i) {
  const { order: s, reverse: o, reduce: a = !0, limit: c } = i;
  for (const u in i) {
    if (!Qt.has(u))
      continue;
    let { value: l, order: h = s, reverse: f = o, reduce: d = a, limit: p = c } = Pc(i[u]);
    const y = l == null ? void 0 : l.startsWith("-");
    if (y && (l = l.slice(1)), h = h === void 0 ? y !== (l === "width" || l === "height") ? f6 : l6 : bB(h), d == null || d === !1)
      continue;
    const g = u === "fx" || u === "fy" ? gB(t, r[u]) : mB(n, u);
    if (!g)
      throw new Error(`missing channel for scale: ${u}`);
    const m = g.value, [b = 0, w = 1 / 0] = dr(p) ? p : p < 0 ? [p] : [0, p];
    if (l == null)
      g.domain = () => {
        let v = Array.from(new qf(m));
        return f && (v = v.reverse()), (b !== 0 || w !== 1 / 0) && (v = v.slice(b, w)), v;
      };
    else {
      const v = l === "data" ? e : l === "height" ? kb(n, "y1", "y2") : l === "width" ? kb(n, "x1", "x2") : a0(n, l, l === "y" ? "y2" : l === "x" ? "x2" : void 0), _ = Ah(d === !0 ? "max" : d, v);
      g.domain = () => {
        let x = FT(
          ti(m),
          ($) => _.reduceIndex($, v),
          ($) => m[$]
        );
        return h && x.sort(h), f && x.reverse(), (b !== 0 || w !== 1 / 0) && (x = x.slice(b, w)), x.map(Cc);
      };
    }
  }
}
function mB(e, t) {
  for (const n in e) {
    const r = e[n];
    if (r.scale === t)
      return r;
  }
}
function gB(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 kb(e, t, n) {
  const r = a0(e, t), i = a0(e, n);
  return Xt(i, (s, o) => Math.abs(s - r[o]), Float64Array);
}
function a0(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 bB(e) {
  if (e == null || typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "ascending":
      return l6;
    case "descending":
      return f6;
  }
  throw new Error(`invalid order: ${e}`);
}
function l6([e, t], [n, r]) {
  return Gr(t, r) || Gr(e, n);
}
function f6([e, t], [n, r]) {
  return s0(t, r) || Gr(e, n);
}
function h6(e, t) {
  let n = e[t];
  if (n) {
    for (; n.source; )
      n = n.source;
    return n.source === null ? null : n;
  }
}
function Ih(e = {}) {
  const { document: t = typeof window < "u" ? window.document : void 0 } = e;
  return { document: t };
}
function Dt(e, { document: t }) {
  return zt(Wf(e).call(t.documentElement));
}
let c0 = 0;
function wB() {
  const e = c0;
  return c0 = 0, e;
}
function hs(e) {
  console.warn(e), ++c0;
}
const d6 = Math.PI, wr = 2 * d6, Rd = 0.618;
function vB({
  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 (hr(e)) {
    let _;
    if ({
      type: e,
      domain: c,
      inset: _,
      insetTop: n = _ !== void 0 ? _ : n,
      insetRight: r = _ !== void 0 ? _ : r,
      insetBottom: i = _ !== void 0 ? _ : i,
      insetLeft: s = _ !== void 0 ? _ : s,
      clip: u = u,
      ...a
    } = e, e == null)
      return;
  }
  typeof e != "function" && ({ type: e } = p6(e));
  const { width: l, height: h, marginLeft: f, marginRight: d, marginTop: p, marginBottom: y } = o, g = l - f - d - s - r, m = h - p - y - n - i;
  if (e = e == null ? void 0 : e({ width: g, height: m, clip: u, ...a }), e == null)
    return;
  u = _B(u, f, p, l - d, h - y);
  let b = f + s, w = p + n, v;
  if (c != null) {
    const [[_, x], [$, T]] = Fi(e).bounds(c), D = Math.min(g / ($ - _), m / (T - x));
    D > 0 ? (b -= (D * (_ + $) - g) / 2, w -= (D * (x + T) - m) / 2, v = rf({
      point(M, A) {
        this.stream.point(M * D + b, A * D + w);
      }
    })) : hs("Warning: the projection could not be fit to the specified domain; using the default scale.");
  }
  return v ?? (v = b === 0 && w === 0 ? y6() : rf({
    point(_, x) {
      this.stream.point(_ + b, x + w);
    }
  })), { stream: (_) => e.stream(v.stream(u(_))) };
}
function p6(e) {
  switch (`${e}`.toLowerCase()) {
    case "albers-usa":
      return wn(_D, 0.7463, 0.4673);
    case "albers":
      return xu(yx, 0.7463, 0.4673);
    case "azimuthal-equal-area":
      return wn(xD, 4, 4);
    case "azimuthal-equidistant":
      return wn(SD, wr, wr);
    case "conic-conformal":
      return xu(AD, wr, wr);
    case "conic-equal-area":
      return xu(sf, 6.1702, 2.9781);
    case "conic-equidistant":
      return xu(ED, 7.312, 3.6282);
    case "equal-earth":
      return wn(LD, 5.4133, 2.6347);
    case "equirectangular":
      return wn(ID, wr, d6);
    case "gnomonic":
      return wn(DD, 3.4641, 3.4641);
    case "identity":
      return { type: y6 };
    case "reflect-y":
      return { type: xB };
    case "mercator":
      return wn(MD, wr, wr);
    case "orthographic":
      return wn(OD, 2, 2);
    case "stereographic":
      return wn(FD, 2, 2);
    case "transverse-mercator":
      return wn(kD, wr, wr);
    default:
      throw new Error(`unknown projection type: ${e}`);
  }
}
function _B(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 Q_(t, n, r, i);
    default:
      throw new Error(`unknown projection clip type: ${e}`);
  }
}
function wn(e, t, n) {
  return {
    type: ({ width: r, height: i, rotate: s, precision: o = 0.15, clip: a }) => {
      var u, l, h;
      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" && ((h = c.clipAngle) == null || h.call(c, a)), c.scale(Math.min(r / t, i / n)), c.translate([r / 2, i / 2]), c;
    },
    aspectRatio: n / t
  };
}
function xu(e, t, n) {
  const { type: r, aspectRatio: i } = wn(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 y6 = nn({ stream: (e) => e }), xB = nn(
  rf({
    point(e, t) {
      this.stream.point(e, -t);
    }
  })
);
function m6(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(h, f) {
      a[u] = h, c[u] = f;
    }
  });
  for (u = 0; u < o; ++u)
    l.point(i[u], s[u]);
}
function SB(e, t) {
  if (typeof (e == null ? void 0 : e.stream) == "function")
    return Rd;
  if (hr(e) && (e = e.type), e == null)
    return MB(t) ? Rd : void 0;
  if (typeof e != "function") {
    const { aspectRatio: n } = p6(e);
    if (n)
      return n;
  }
  return Rd;
}
function Th(e, t, { projection: n }) {
  const { x: r, y: i } = e;
  let s = {};
  return r && (s.x = r), i && (s.y = i), s = fm(s, t), n && (r == null ? void 0 : r.scale) === "x" && (i == null ? void 0 : i.scale) === "y" && m6("x", "y", s, n), r && (s.x = Pe(s.x)), i && (s.y = Pe(s.y)), s;
}
function MB(e) {
  for (const t of e)
    if (t.channels.geometry)
      return !0;
  return !1;
}
const g6 = /* @__PURE__ */ new Map([
  ["accent", qF],
  ["category10", jF],
  ["dark2", VF],
  ["paired", YF],
  ["pastel1", WF],
  ["pastel2", XF],
  ["set1", GF],
  ["set2", HF],
  ["set3", ZF],
  ["tableau10", KF]
]);
function $B(e) {
  return e != null && g6.has(`${e}`.toLowerCase());
}
const Bb = new Map([
  ...g6,
  // diverging
  ["brbg", vr(s3, o3)],
  ["prgn", vr(a3, c3)],
  ["piyg", vr(u3, l3)],
  ["puor", vr(f3, h3)],
  ["rdbu", vr(n0, uf)],
  ["rdgy", vr(d3, p3)],
  ["rdylbu", vr(r0, lf)],
  ["rdylgn", vr(y3, m3)],
  ["spectral", vr(g3, b3)],
  // reversed diverging (for temperature data)
  ["burd", Rb(n0, uf)],
  ["buylrd", Rb(r0, lf)],
  // sequential (single-hue)
  ["blues", fe(q3, V3)],
  ["greens", fe(Y3, W3)],
  ["greys", fe(X3, G3)],
  ["oranges", fe(Q3, tS)],
  ["purples", fe(H3, Z3)],
  ["reds", fe(K3, J3)],
  // sequential (multi-hue)
  ["turbo", _r(aS)],
  ["viridis", _r(cS)],
  ["magma", _r(uS)],
  ["inferno", _r(lS)],
  ["plasma", _r(fS)],
  ["cividis", _r(eS)],
  ["cubehelix", _r(nS)],
  ["warm", _r(rS)],
  ["cool", _r(iS)],
  ["bugn", fe(w3, v3)],
  ["bupu", fe(_3, x3)],
  ["gnbu", fe(S3, M3)],
  ["orrd", fe($3, A3)],
  ["pubu", fe(E3, N3)],
  ["pubugn", fe(I3, T3)],
  ["purd", fe(L3, D3)],
  ["rdpu", fe(O3, F3)],
  ["ylgn", fe(R3, C3)],
  ["ylgnbu", fe(k3, B3)],
  ["ylorbr", fe(P3, z3)],
  ["ylorrd", fe(U3, j3)],
  // cyclical
  ["rainbow", Cb(sS)],
  ["sinebow", Cb(oS)]
]);
function fe(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 ? Ln(t, n) : e[n]);
}
function vr(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][0], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 11 ? Ln(t, n) : e[n]);
}
function Rb(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][2], e[3][0]] : (n = Math.max(3, Math.floor(n)), n > 11 ? Ln((r) => t(1 - r), n) : e[n].slice().reverse());
}
function _r(e) {
  return ({ length: t }) => Ln(e, Math.max(2, Math.floor(t)));
}
function Cb(e) {
  return ({ length: t }) => Ln(e, Math.floor(t) + 1).slice(0, -1);
}
function b6(e) {
  const t = `${e}`.toLowerCase();
  if (!Bb.has(t))
    throw new Error(`unknown ordinal scheme: ${t}`);
  return Bb.get(t);
}
function Eh(e, t) {
  const n = b6(e), r = typeof n == "function" ? n({ length: t }) : n;
  return r.length !== t ? r.slice(0, t) : r;
}
function AB(e, t = "greys") {
  const n = /* @__PURE__ */ new Set(), [r, i] = Eh(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 Pb = /* @__PURE__ */ new Map([
  // diverging
  ["brbg", o3],
  ["prgn", c3],
  ["piyg", l3],
  ["puor", h3],
  ["rdbu", uf],
  ["rdgy", p3],
  ["rdylbu", lf],
  ["rdylgn", m3],
  ["spectral", b3],
  // reversed diverging (for temperature data)
  ["burd", (e) => uf(1 - e)],
  ["buylrd", (e) => lf(1 - e)],
  // sequential (single-hue)
  ["blues", V3],
  ["greens", W3],
  ["greys", G3],
  ["purples", Z3],
  ["reds", J3],
  ["oranges", tS],
  // sequential (multi-hue)
  ["turbo", aS],
  ["viridis", cS],
  ["magma", uS],
  ["inferno", lS],
  ["plasma", fS],
  ["cividis", eS],
  ["cubehelix", nS],
  ["warm", rS],
  ["cool", iS],
  ["bugn", v3],
  ["bupu", x3],
  ["gnbu", M3],
  ["orrd", A3],
  ["pubugn", T3],
  ["pubu", N3],
  ["purd", D3],
  ["rdpu", F3],
  ["ylgnbu", B3],
  ["ylgn", C3],
  ["ylorbr", z3],
  ["ylorrd", j3],
  // cyclical
  ["rainbow", sS],
  ["sinebow", oS]
]);
function hm(e) {
  const t = `${e}`.toLowerCase();
  if (!Pb.has(t))
    throw new Error(`unknown quantitative scheme: ${t}`);
  return Pb.get(t);
}
const IB = /* @__PURE__ */ new Set([
  "brbg",
  "prgn",
  "piyg",
  "puor",
  "rdbu",
  "rdgy",
  "rdylbu",
  "rdylgn",
  "spectral",
  "burd",
  "buylrd"
]);
function TB(e) {
  return e != null && IB.has(`${e}`.toLowerCase());
}
const w6 = (e) => (t) => e(1 - t), Cd = [0, 1], zb = /* @__PURE__ */ new Map([
  // numbers
  ["number", xe],
  // color spaces
  ["rgb", vs],
  ["hsl", mN],
  ["hcl", wN],
  ["lab", gN]
]);
function v6(e) {
  const t = `${e}`.toLowerCase();
  if (!zb.has(t))
    throw new Error(`unknown interpolator: ${t}`);
  return zb.get(t);
}
function jc(e, t, n, {
  type: r,
  nice: i,
  clamp: s,
  zero: o,
  domain: a = x6(e, n),
  unknown: c,
  round: u,
  scheme: l,
  interval: h,
  range: f = Qt.get(e) === vh ? PB(n, a) : Qt.get(e) === _h ? zB(n, a) : Qt.get(e) === xh ? Cd : void 0,
  interpolate: d = Qt.get(e) === ni ? l == null && f !== void 0 ? vs : hm(l !== void 0 ? l : r === "cyclical" ? "rainbow" : "turbo") : u ? wy : xe,
  reverse: p
}) {
  if (h = Jo(h, r), (r === "cyclical" || r === "sequential") && (r = "linear"), p = !!p, typeof d != "function" && (d = v6(d)), d.length === 1 ? (p && (d = w6(d), p = !1), f === void 0 && (f = Float64Array.from(a, (y, g) => g / (a.length - 1)), f.length === 2 && (f = Cd)), t.interpolate((f === Cd ? nn : pm)(d))) : t.interpolate(d), o) {
    const [y, g] = Se(a);
    (y > 0 || g < 0) && (a = o0(a), hc(a) !== Math.sign(y) ? a[a.length - 1] = 0 : a[0] = 0);
  }
  return p && (a = El(a)), t.domain(a).unknown(c), i && (t.nice(EB(i, r)), a = t.domain()), f !== void 0 && t.range(f), s && t.clamp(s), { type: r, domain: a, range: f, scale: t, interpolate: d, interval: h };
}
function EB(e, t) {
  return e === !0 ? void 0 : typeof e == "number" ? e : Yk(e, t);
}
function NB(e, t, n) {
  return jc(e, nh(), t, n);
}
function LB(e, t, n) {
  return _6(e, t, { ...n, exponent: 0.5 });
}
function _6(e, t, { exponent: n = 1, ...r }) {
  return jc(e, Cx().exponent(n), t, { ...r, type: "pow" });
}
function DB(e, t, { base: n = 10, domain: r = UB(t), ...i }) {
  return jc(e, Fx().base(n), t, { ...i, domain: r });
}
function OB(e, t, { constant: n = 1, ...r }) {
  return jc(e, Bx().constant(n), t, r);
}
function FB(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 = jB(t),
  unknown: a,
  interpolate: c,
  reverse: u
}) {
  return n === void 0 && (n = c !== void 0 ? Ln(c, i) : Qt.get(e) === ni ? Eh(s, i) : void 0), o.length > 0 && (o = Px(o, n === void 0 ? { length: i } : n).quantiles()), dm(e, t, { domain: o, range: n, reverse: u, unknown: a });
}
function kB(e, t, {
  range: n,
  n: r = n === void 0 ? 5 : (n = [...n]).length,
  scheme: i = "rdylbu",
  domain: s = x6(e, t),
  unknown: o,
  interpolate: a,
  reverse: c
}) {
  const [u, l] = Se(s);
  let h;
  return n === void 0 ? (h = Si(u, l, r), h[0] <= u && h.splice(0, 1), h[h.length - 1] >= l && h.pop(), r = h.length + 1, n = a !== void 0 ? Ln(a, r) : Qt.get(e) === ni ? Eh(i, r) : void 0) : (h = Ln(xe(u, l), r + 1).slice(1, -1), u instanceof Date && (h = h.map((f) => new Date(f)))), hc(kn(s)) < 0 && h.reverse(), dm(e, t, { domain: h, range: n, reverse: c, unknown: o });
}
function dm(e, t, {
  domain: n = [0],
  // explicit thresholds in ascending order
  unknown: r,
  scheme: i = "rdylbu",
  interpolate: s,
  range: o = s !== void 0 ? Ln(s, n.length + 1) : Qt.get(e) === ni ? Eh(i, n.length + 1) : void 0,
  reverse: a
}) {
  n = kn(n);
  const c = hc(n);
  if (!isNaN(c) && !BB(n, c))
    throw new Error(`the ${e} scale has a non-monotonic domain`);
  return a && (o = El(o)), {
    type: "threshold",
    scale: zx(c < 0 ? El(n) : n, o === void 0 ? [] : o).unknown(r),
    domain: n,
    range: o
  };
}
function BB(e, t) {
  for (let n = 1, r = e.length, i = e[0]; n < r; ++n) {
    const s = Ec(i, i = e[n]);
    if (s !== 0 && s !== t)
      return !1;
  }
  return !0;
}
function RB() {
  return { type: "identity", scale: Lx() };
}
function mc(e, t = mf) {
  return e.length ? [
    pe(e, ({ value: n }) => n === void 0 ? n : pe(n, t)),
    te(e, ({ value: n }) => n === void 0 ? n : te(n, t))
  ] : [0, 1];
}
function x6(e, t) {
  const n = Qt.get(e);
  return (n === vh || n === xh || n === _h ? CB : mc)(t);
}
function CB(e) {
  return [0, e.length ? te(e, ({ value: t }) => t === void 0 ? t : te(t, mf)) : 1];
}
function PB(e, t) {
  const n = e.find(({ radius: o }) => o !== void 0);
  if (n !== void 0)
    return [0, n.radius];
  const r = Mi(e, 0.5, ({ value: o }) => o === void 0 ? NaN : Mi(o, 0.25, zr)), i = t.map((o) => 3 * Math.sqrt(o / r)), s = 30 / te(i);
  return s < 1 ? i.map((o) => o * s) : i;
}
function zB(e, t) {
  const n = tc(e, ({ value: s }) => s === void 0 ? NaN : tc(s, Math.abs)), r = t.map((s) => 12 * s / n), i = 60 / te(r);
  return i < 1 ? r.map((s) => s * i) : r;
}
function UB(e) {
  for (const { value: t } of e)
    if (t !== void 0)
      for (let n of t) {
        if (n > 0)
          return mc(e, zr);
        if (n < 0)
          return mc(e, mh);
      }
  return [1, 10];
}
function jB(e) {
  const t = [];
  for (const { value: n } of e)
    if (n !== void 0)
      for (const r of n)
        t.push(r);
  return t;
}
function pm(e) {
  return (t, n) => (r) => e(t + r * (n - t));
}
function Nh(e, t, n, r, {
  type: i,
  nice: s,
  clamp: o,
  domain: a = mc(r),
  unknown: c,
  pivot: u = 0,
  scheme: l,
  range: h,
  symmetric: f = !0,
  interpolate: d = Qt.get(e) === ni ? l == null && h !== void 0 ? vs : hm(l !== void 0 ? l : "rdbu") : xe,
  reverse: p
}) {
  u = +u;
  let [y, g] = a;
  if (Ec(y, g) < 0 && ([y, g] = [g, y], p = !p), y = Math.min(y, u), g = Math.max(g, u), typeof d != "function" && (d = v6(d)), h !== void 0 && (d = d.length === 1 ? pm(d)(...h) : _y(d, h)), p && (d = w6(d)), f) {
    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 qB(e, t, n) {
  return Nh(e, e3(), XB, t, n);
}
function VB(e, t, n) {
  return S6(e, t, { ...n, exponent: 0.5 });
}
function S6(e, t, { exponent: n = 1, ...r }) {
  return Nh(e, i3().exponent(n = +n), ZB(n), t, {
    ...r,
    type: "diverging-pow"
  });
}
function YB(e, t, { base: n = 10, pivot: r = 1, domain: i = mc(t, r < 0 ? mh : zr), ...s }) {
  return Nh(e, n3().base(n = +n), GB, t, {
    domain: i,
    pivot: r,
    ...s
  });
}
function WB(e, t, { constant: n = 1, ...r }) {
  return Nh(
    e,
    r3().constant(n = +n),
    KB(n),
    t,
    r
  );
}
const XB = {
  apply(e) {
    return e;
  },
  invert(e) {
    return e;
  }
}, GB = {
  apply: Math.log,
  invert: Math.exp
}, HB = {
  apply(e) {
    return Math.sign(e) * Math.sqrt(Math.abs(e));
  },
  invert(e) {
    return Math.sign(e) * (e * e);
  }
};
function ZB(e) {
  return e === 0.5 ? HB : {
    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 KB(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 M6(e, t, n, r) {
  return jc(e, t, n, r);
}
function JB(e, t, n) {
  return M6(e, zF(), t, n);
}
function QB(e, t, n) {
  return M6(e, UF(), t, n);
}
const qc = Symbol("ordinal");
function $6(e, t, n, { type: r, interval: i, domain: s, range: o, reverse: a, hint: c }) {
  return i = Jo(i, r), s === void 0 && (s = I6(n, i, e)), (r === "categorical" || r === qc) && (r = "ordinal"), a && (s = El(s)), t.domain(s), 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 tR(e, t, { type: n, interval: r, domain: i, range: s, scheme: o, unknown: a, ...c }) {
  r = Jo(r, n), i === void 0 && (i = I6(t, r, e));
  let u;
  if (Qt.get(e) === Sh)
    u = rR(t), s = s === void 0 ? iR(u) : Xt(s, Qy);
  else if (Qt.get(e) === ni && (s === void 0 && (n === "ordinal" || n === qc) && (s = AB(i, o), s !== void 0 && (o = void 0)), o === void 0 && s === void 0 && (o = n === "ordinal" ? "turbo" : "tableau10"), o !== void 0))
    if (s !== void 0) {
      const l = hm(o), h = s[0], f = s[1] - s[0];
      s = ({ length: d }) => Ln((p) => l(h + f * p), d);
    } else
      s = b6(o);
  if (a === Qp)
    throw new Error(`implicit unknown on ${e} scale is not supported`);
  return $6(e, Oy().unknown(a), t, { ...c, type: n, domain: i, range: s, hint: u });
}
function eR(e, t, { align: n = 0.5, padding: r = 0.5, ...i }) {
  return A6(_O().align(n).padding(r), t, i, e);
}
function nR(e, t, {
  align: n = 0.5,
  padding: r = 0.1,
  paddingInner: i = r,
  paddingOuter: s = e === "fx" || e === "fy" ? 0 : r,
  ...o
}) {
  return A6(
    th().align(n).paddingInner(i).paddingOuter(s),
    t,
    o,
    e
  );
}
function A6(e, t, n, r) {
  let { round: i } = n;
  return i !== void 0 && e.round(i = !!i), e = $6(r, e, t, n), e.round = i, e;
}
function I6(e, t, n) {
  const r = new qf();
  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] = Se(r).map(t.floor, t);
    return t.range(i, t.offset(s));
  }
  if (r.size > 1e4 && Qt.get(n) === er)
    throw new Error(`implicit ordinal domain of ${n} scale has more than 10,000 values`);
  return Ka(r, Gr);
}
function Ub(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 rR(e) {
  return {
    fill: Ub(e, "fill"),
    stroke: Ub(e, "stroke")
  };
}
function iR(e) {
  return ae(e.fill) ? lk : uk;
}
function u0(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: h,
  padding: f,
  projection: d,
  facet: { label: p = t } = {},
  ...y
} = {}) {
  const g = {};
  for (const [m, b] of e) {
    const w = y[m], v = L6(m, b, {
      round: Qt.get(m) === er ? a : void 0,
      // only for position
      nice: c,
      clamp: u,
      zero: l,
      align: h,
      padding: f,
      projection: d,
      ...w
    });
    if (v) {
      let {
        label: _ = m === "fx" || m === "fy" ? p : t,
        percent: x,
        transform: $,
        inset: T,
        insetTop: D = T !== void 0 ? T : m === "y" ? r : 0,
        // not fy
        insetRight: M = T !== void 0 ? T : m === "x" ? i : 0,
        // not fx
        insetBottom: A = T !== void 0 ? T : m === "y" ? s : 0,
        // not fy
        insetLeft: L = T !== void 0 ? T : m === "x" ? o : 0
        // not fx
      } = w || {};
      if ($ == null)
        $ = void 0;
      else if (typeof $ != "function")
        throw new Error("invalid scale transform; not a function");
      v.percent = !!x, v.label = _ === void 0 ? oR(b, v) : _, v.transform = $, m === "x" || m === "fx" ? (v.insetLeft = +L, v.insetRight = +M) : (m === "y" || m === "fy") && (v.insetTop = +D, v.insetBottom = +A), g[m] = v;
    }
  }
  return g;
}
function jb(e) {
  return Object.fromEntries(
    Object.entries(e).filter(([, { scale: t }]) => t).map(([t, { scale: n, type: r, interval: i, label: s }]) => (n.type = r, i != null && (n.interval = i), s != null && (n.label = s), [t, n]))
  );
}
function sR(e, t) {
  const { x: n, y: r, fx: i, fy: s } = e, o = i || s ? ym(t) : t;
  i && qb(i, o), s && Vb(s, o);
  const a = i || s ? T6(e, t) : t;
  n && qb(n, a), r && Vb(r, a);
}
function oR(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 !Es(t) && t.percent && (n = `${n} (%)`), { inferred: !0, toString: () => n };
}
function ym(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 T6({ fx: e, fy: t }, n) {
  const { marginTop: r, marginRight: i, marginBottom: s, marginLeft: o, width: a, height: c } = ym(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 qb(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)], Es(e) || (e.range = N6(e)), e.scale.range(e.range);
  }
  E6(e);
}
function Vb(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], Es(e) ? e.range.reverse() : e.range = N6(e), e.scale.range(e.range);
  }
  E6(e);
}
function E6(e) {
  e.round === void 0 && uR(e) && aR(e) <= 30 && e.scale.round(!0);
}
function aR({ 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 N6(e) {
  const t = e.scale.domain().length + O6(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 l0(e, t, n) {
  return L6(e, n === void 0 ? void 0 : [{ hint: n }], { ...t });
}
function L6(e, t = [], n = {}) {
  const r = cR(e, t, n);
  if (n.type === void 0 && n.domain === void 0 && n.range === void 0 && n.interval == null && e !== "fx" && e !== "fy" && Es({ type: r })) {
    const i = t.map(({ value: s }) => s).filter((s) => s !== void 0);
    i.some(Ve) ? hs(
      `Warning: some data associated with the ${e} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${zs(
        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 "${zs(
        r
      )}".`
    ) : i.some(Gk) ? hs(
      `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 "${zs(
        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 "${zs(
        r
      )}".`
    ) : i.some(Hk) && hs(
      `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 "${zs(
        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 "${zs(
        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 = Su(t, n, Pe);
      break;
    case "identity":
      switch (Qt.get(e)) {
        case er:
          n = Su(t, n, Pe);
          break;
        case Sh:
          n = Su(t, n, lR);
          break;
      }
      break;
    case "utc":
    case "time":
      n = Su(t, n, Vk);
      break;
  }
  switch (r) {
    case "diverging":
      return qB(e, t, n);
    case "diverging-sqrt":
      return VB(e, t, n);
    case "diverging-pow":
      return S6(e, t, n);
    case "diverging-log":
      return YB(e, t, n);
    case "diverging-symlog":
      return WB(e, t, n);
    case "categorical":
    case "ordinal":
    case qc:
      return tR(e, t, n);
    case "cyclical":
    case "sequential":
    case "linear":
      return NB(e, t, n);
    case "sqrt":
      return LB(e, t, n);
    case "threshold":
      return dm(e, t, n);
    case "quantile":
      return FB(e, t, n);
    case "quantize":
      return kB(e, t, n);
    case "pow":
      return _6(e, t, n);
    case "log":
      return DB(e, t, n);
    case "symlog":
      return OB(e, t, n);
    case "utc":
      return QB(e, t, n);
    case "time":
      return JB(e, t, n);
    case "point":
      return eR(e, t, n);
    case "band":
      return nR(e, t, n);
    case "identity":
      return Qt.get(e) === er ? RB() : { type: "identity" };
    case void 0:
      return;
    default:
      throw new Error(`unknown scale type: ${r}`);
  }
}
function zs(e) {
  return typeof e == "symbol" ? e.description : e;
}
const Yb = { toString: () => "projection" };
function cR(e, t, { type: n, domain: r, range: i, scheme: s, pivot: o, projection: a }) {
  if (e === "fx" || e === "fy")
    return "band";
  (e === "x" || e === "y") && a != null && (n = Yb);
  for (const { type: u } of t)
    if (u !== void 0) {
      if (n === void 0)
        n = u;
      else if (n !== u)
        throw new Error(`scale incompatible with channel: ${n} !== ${u}`);
    }
  if (n === Yb)
    return;
  if (n !== void 0)
    return n;
  if (r === void 0 && !t.some(({ value: u }) => u !== void 0))
    return;
  const c = Qt.get(e);
  if (c === vh)
    return "sqrt";
  if (c === xh || c === _h)
    return "linear";
  if (c === Sh)
    return "ordinal";
  if ((r || i || []).length > 2)
    return Pd(c);
  if (r !== void 0) {
    if (Ie(r))
      return Pd(c);
    if (Ve(r))
      return "utc";
  } else {
    const u = t.map(({ value: l }) => l).filter((l) => l !== void 0);
    if (u.some(Ie))
      return Pd(c);
    if (u.some(Ve))
      return "utc";
  }
  if (c === ni) {
    if (o != null || TB(s))
      return "diverging";
    if ($B(s))
      return "categorical";
  }
  return "linear";
}
function Pd(e) {
  switch (e) {
    case er:
      return "point";
    case ni:
      return qc;
    default:
      return "ordinal";
  }
}
function D6({ type: e }) {
  return e === "time" || e === "utc";
}
function Es({ type: e }) {
  return e === "ordinal" || e === "point" || e === "band" || e === qc;
}
function O6({ type: e }) {
  return e === "threshold";
}
function uR({ type: e }) {
  return e === "point" || e === "band";
}
function yn(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 Su(e, { domain: t, ...n }, r) {
  for (const i of e)
    i.value !== void 0 && (i.value = r(i.value));
  return {
    domain: t === void 0 ? t : r(t),
    ...n
  };
}
function lR(e) {
  return Xt(e, Qy);
}
function $s(e = {}) {
  let t;
  for (const n in e)
    if (Qt.has(n) && fs(e[n])) {
      if (t !== void 0)
        throw new Error("ambiguous scale definition; multiple scales found");
      t = F6(l0(n, e[n]));
    }
  if (t === void 0)
    throw new Error("invalid scale definition; no scale found");
  return t;
}
function fR(e) {
  return (t) => {
    if (!Qt.has(t = `${t}`))
      throw new Error(`unknown scale: ${t}`);
    return t in e ? F6(e[t]) : void 0;
  };
}
function F6({ 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: o0(n),
    // defensive copy
    ...r !== void 0 && { range: o0(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 mm(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 hR = mm((e) => new Intl.NumberFormat(e)), dR = mm((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { month: t } })), pR = mm((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { weekday: t } }));
function yR(e = "en-US") {
  const t = hR(e);
  return (n) => n != null && !isNaN(n) ? t.format(n) : void 0;
}
function mR(e = "en-US", t = "short") {
  const n = dR(e, t);
  return (r) => r != null && !isNaN(r = +new Date(Date.UTC(2e3, +r))) ? n.format(r) : void 0;
}
function gR(e = "en-US", t = "short") {
  const n = pR(e, t);
  return (r) => r != null && !isNaN(r = +new Date(Date.UTC(2001, 0, +r))) ? n.format(r) : void 0;
}
function gm(e) {
  return zv(e, "Invalid Date");
}
function bR(e = "en-US") {
  const t = yR(e);
  return (n) => (n instanceof Date ? gm : typeof n == "number" ? t : ge)(n);
}
const Ur = bR(), be = (typeof window < "u" ? window.devicePixelRatio > 1 : typeof it > "u") ? 0 : 0.5;
let wR = 0;
function Wb() {
  return `plot-clip-${++wR}`;
}
function k6(e, {
  title: t,
  href: n,
  ariaLabel: r,
  ariaDescription: i,
  ariaHidden: s,
  target: o,
  fill: a,
  fillOpacity: c,
  stroke: u,
  strokeWidth: l,
  strokeOpacity: h,
  strokeLinejoin: f,
  strokeLinecap: d,
  strokeMiterlimit: p,
  strokeDasharray: y,
  strokeDashoffset: g,
  opacity: m,
  mixBlendMode: b,
  imageFilter: w,
  paintOrder: v,
  pointerEvents: _,
  shapeRendering: x
}, {
  ariaLabel: $,
  fill: T = "currentColor",
  fillOpacity: D,
  stroke: M = "none",
  strokeOpacity: A,
  strokeWidth: L,
  strokeLinecap: k,
  strokeLinejoin: S,
  strokeMiterlimit: I,
  paintOrder: E
}) {
  T === null && (a = null, c = null), M === null && (u = null, h = null), ae(T) ? !ae(M) && !ae(a) && (M = "none") : ae(M) && !ae(u) && (T = "none");
  const [N, O] = qe(a, T), [R, C] = ie(c, D), [j, z] = qe(u, M), [X, H] = ie(h, A), [J, K] = ie(m);
  Po(z) || (l === void 0 && (l = L), d === void 0 && (d = k), f === void 0 && (f = S), p === void 0 && !Kk(f) && (p = I), !Po(O) && v === void 0 && (v = E));
  const [W, Y] = ie(l);
  return T !== null && (e.fill = ee(O, "currentColor"), e.fillOpacity = wa(C, 1)), M !== null && (e.stroke = ee(z, "none"), e.strokeWidth = wa(Y, 1), e.strokeOpacity = wa(H, 1), e.strokeLinejoin = ee(f, "miter"), e.strokeLinecap = ee(d, "butt"), e.strokeMiterlimit = wa(p, 4), e.strokeDasharray = ee(y, "none"), e.strokeDashoffset = ee(g, "0")), e.target = ge(o), e.ariaLabel = ge($), e.ariaDescription = ge(i), e.ariaHidden = ge(s), e.opacity = wa(K, 1), e.mixBlendMode = ee(b, "normal"), e.imageFilter = ee(w, "none"), e.paintOrder = ee(v, "normal"), e.pointerEvents = ee(_, "auto"), e.shapeRendering = ee(x, "auto"), {
    title: { value: t, optional: !0 },
    href: { value: n, optional: !0 },
    ariaLabel: { value: r, optional: !0 },
    fill: { value: N, scale: "auto", optional: !0 },
    fillOpacity: { value: R, scale: "auto", optional: !0 },
    stroke: { value: j, scale: "auto", optional: !0 },
    strokeOpacity: { value: X, scale: "auto", optional: !0 },
    strokeWidth: { value: W, optional: !0 },
    opacity: { value: J, scale: "auto", optional: !0 }
  };
}
function vR(e, t) {
  t && e.filter((n) => Vy(t[n])).append("title").call(xR, t);
}
function _R(e, t) {
  t && e.filter(([n]) => Vy(t[n])).append("title").call(SR, t);
}
function xR(e, t) {
  t && e.text((n) => Ur(t[n]));
}
function SR(e, t) {
  t && e.text(([n]) => Ur(t[n]));
}
function le(e, { target: t, tip: n }, {
  ariaLabel: r,
  title: i,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: u,
  opacity: l,
  href: h
}) {
  r && nt(e, "aria-label", (f) => r[f]), s && nt(e, "fill", (f) => s[f]), o && nt(e, "fill-opacity", (f) => o[f]), a && nt(e, "stroke", (f) => a[f]), c && nt(e, "stroke-opacity", (f) => c[f]), u && nt(e, "stroke-width", (f) => u[f]), l && nt(e, "opacity", (f) => l[f]), h && R6(e, (f) => h[f], t), n || vR(e, i);
}
function vf(e, { target: t, tip: n }, {
  ariaLabel: r,
  title: i,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: u,
  opacity: l,
  href: h
}) {
  r && nt(e, "aria-label", ([f]) => r[f]), s && nt(e, "fill", ([f]) => s[f]), o && nt(e, "fill-opacity", ([f]) => o[f]), a && nt(e, "stroke", ([f]) => a[f]), c && nt(e, "stroke-opacity", ([f]) => c[f]), u && nt(e, "stroke-width", ([f]) => u[f]), l && nt(e, "opacity", ([f]) => l[f]), h && R6(e, ([f]) => h[f], t), n || _R(e, i);
}
function MR({
  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 bm(e, t, n) {
  const r = Jr(e, (i) => t[i]);
  return n === void 0 && r.size > e.length >> 1 && hs(
    "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* B6(e, t, n, r) {
  const { z: i } = n, { z: s } = r, o = MR(r, n), a = [...t, ...o];
  for (const c of s ? bm(e, s, i) : [e]) {
    let u, l;
    t:
      for (const h of c) {
        for (const f of a)
          if (!Oe(f[h])) {
            l && l.push(-1);
            continue t;
          }
        if (u === void 0) {
          l && (yield l), u = o.map((f) => os(f[h])), l = [h];
          continue;
        }
        l.push(h);
        for (let f = 0; f < o.length; ++f)
          if (os(o[f][h]) !== u[f]) {
            yield l, u = o.map((p) => os(p[h])), l = [h];
            continue t;
          }
      }
    l && (yield l);
  }
}
function $R(e) {
  return e === !0 ? e = "frame" : e === !1 && (e = null), gh(e, "clip", ["frame", "sphere"]);
}
function AR(e, t, n, r) {
  let i;
  switch (t.clip) {
    case "frame": {
      const { width: s, height: o, marginLeft: a, marginRight: c, marginTop: u, marginBottom: l } = n, h = Wb();
      i = `url(#${h})`, e = Dt("svg:g", r).call(
        (f) => f.append("svg:clipPath").attr("id", h).append("rect").attr("x", a).attr("y", u).attr("width", s - c - a).attr("height", o - u - l)
      ).each(function() {
        this.appendChild(e.node()), e.node = () => this;
      });
      break;
    }
    case "sphere": {
      const { projection: s } = r;
      if (!s)
        throw new Error('the "sphere" clip option requires a projection');
      const o = Wb();
      i = `url(#${o})`, e.append("clipPath").attr("id", o).append("path").attr("d", Fi(s)({ type: "Sphere" }));
      break;
    }
  }
  nt(e, "aria-label", t.ariaLabel), nt(e, "aria-description", t.ariaDescription), nt(e, "aria-hidden", t.ariaHidden), nt(e, "clip-path", i);
}
function Zt(e, t, n, r) {
  AR(e, t, n, r), nt(e, "fill", t.fill), nt(e, "fill-opacity", t.fillOpacity), nt(e, "stroke", t.stroke), nt(e, "stroke-width", t.strokeWidth), nt(e, "stroke-opacity", t.strokeOpacity), nt(e, "stroke-linejoin", t.strokeLinejoin), nt(e, "stroke-linecap", t.strokeLinecap), nt(e, "stroke-miterlimit", t.strokeMiterlimit), nt(e, "stroke-dasharray", t.strokeDasharray), nt(e, "stroke-dashoffset", t.strokeDashoffset), nt(e, "shape-rendering", t.shapeRendering), nt(e, "filter", t.imageFilter), nt(e, "paint-order", t.paintOrder), nt(e, "pointer-events", t.pointerEvents);
}
function Ht(e, t) {
  IR(e, "mix-blend-mode", t.mixBlendMode), nt(e, "opacity", t.opacity);
}
function R6(e, t, n) {
  e.each(function(r) {
    const i = t(r);
    if (i != null) {
      const s = this.ownerDocument.createElementNS(bs.svg, "a");
      s.setAttribute("fill", "inherit"), s.setAttributeNS(bs.xlink, "href", i), n != null && s.setAttribute("target", n), this.parentNode.insertBefore(s, this).appendChild(this);
    }
  });
}
function nt(e, t, n) {
  n != null && e.attr(t, n);
}
function IR(e, t, n) {
  n != null && e.style(t, n);
}
function qt(e, t, { x: n, y: r }, i = be, s = be) {
  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 ee(e, t) {
  if ((e = ge(e)) !== t)
    return e;
}
function wa(e, t) {
  if ((e = At(e)) !== t)
    return e;
}
const TR = /^-?([_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 wm(e) {
  if (e === void 0)
    return "plot-d6a7b5";
  if (e = `${e}`, !TR.test(e))
    throw new Error(`invalid class name: ${e}`);
  return e;
}
function vm(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 yr({ 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 ER(e, t, n = {}) {
  let r = 0.5 - be, i = 0.5 + be, s = 0.5 + be, o = 0.5 - be;
  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: h = a !== void 0 ? a : o
  } = n;
  c = +c, u = +u, l = +l, h = +h;
  let {
    width: f = 640,
    height: d = NR(e, t, n, {
      width: f,
      marginTopDefault: r,
      marginRightDefault: i,
      marginBottomDefault: s,
      marginLeftDefault: o
    }) + Math.max(0, c - r + l - s)
  } = n;
  f = +f, d = +d;
  const p = {
    width: f,
    height: d,
    marginTop: c,
    marginRight: u,
    marginBottom: l,
    marginLeft: h
  };
  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 : h
    } = n.facet ?? {};
    g = +g, m = +m, b = +b, w = +w, p.facet = {
      marginTop: g,
      marginRight: m,
      marginBottom: b,
      marginLeft: w
    };
  }
  return p;
}
function NR({ x: e, y: t, fy: n, fx: r }, i, { projection: s, aspectRatio: o }, { width: a, marginTopDefault: c, marginRightDefault: u, marginBottomDefault: l, marginLeftDefault: h }) {
  const f = n ? n.scale.domain().length : 1, d = SB(s, i);
  if (d) {
    const y = r ? r.scale.domain().length : 1, g = (1.1 * f - 0.1) / (1.1 * y - 0.1) * d, m = Math.max(0.1, Math.min(10, g));
    return Math.round((a - h - u) * m + c + l);
  }
  const p = t ? Es(t) ? t.scale.domain().length : Math.max(7, 17 / f) : 1;
  if (o != null) {
    if (o = +o, !(isFinite(o) && o > 0))
      throw new Error(`invalid aspectRatio: ${o}`);
    const y = Xb("y", t) / (Xb("x", e) * o), g = r ? r.scale.bandwidth() : 1, m = n ? n.scale.bandwidth() : 1, b = g * (a - h - u) - e.insetLeft - e.insetRight;
    return (y * b + t.insetTop + t.insetBottom) / m + c + l;
  }
  return !!(t || n) * Math.max(1, Math.min(60, p * f)) * 20 + !!r * 30 + 60;
}
function Xb(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] = Se(r);
  return Math.abs(i(o) - i(s));
}
function LR(e, t) {
  const { fx: n, fy: r } = u0(e, t), i = n == null ? void 0 : n.scale.domain(), s = r == null ? void 0 : r.scale.domain();
  return i && s ? DT(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 DR(e, { x: t, y: n }) {
  return t && (t = f0(t)), n && (n = f0(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 _m(e, { fx: t, fy: n }) {
  const r = ti(e), i = t == null ? void 0 : t.value, s = n == null ? void 0 : n.value;
  return t && n ? so(
    r,
    (o) => (o.fx = i[o[0]], o.fy = s[o[0]], o),
    (o) => i[o],
    (o) => s[o]
  ) : t ? so(
    r,
    (o) => (o.fx = i[o[0]], o),
    (o) => i[o]
  ) : so(
    r,
    (o) => (o.fy = s[o[0]], o),
    (o) => s[o]
  );
}
function OR(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 FR(e) {
  const t = [], n = new Uint32Array(ar(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 kR = /* @__PURE__ */ new Map([
  ["top", zd],
  ["right", qd],
  ["bottom", Ud],
  ["left", jd],
  ["top-left", Mu(zd, jd)],
  ["top-right", Mu(zd, qd)],
  ["bottom-left", Mu(Ud, jd)],
  ["bottom-right", Mu(Ud, qd)],
  ["top-empty", CR],
  ["right-empty", UR],
  ["bottom-empty", PR],
  ["left-empty", zR],
  ["empty", jR]
]);
function BR(e) {
  if (e == null)
    return null;
  const t = kR.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid facet anchor: ${e}`);
}
const Gb = /* @__PURE__ */ new WeakMap();
function f0(e) {
  let t = Gb.get(e);
  return t || Gb.set(e, t = new gs(Xt(e, (n, r) => [n, r]))), t;
}
function Ri(e, t) {
  return f0(e).get(t);
}
function RR(e, t, n) {
  return t = os(t), n = os(n), e.find((r) => Object.is(os(r.x), t) && Object.is(os(r.y), n));
}
function Lh(e, t, n) {
  var r;
  return (r = RR(e, t, n)) == null ? void 0 : r.empty;
}
function zd(e, { y: t }, { y: n }) {
  return t ? Ri(t, n) === 0 : !0;
}
function Ud(e, { y: t }, { y: n }) {
  return t ? Ri(t, n) === t.length - 1 : !0;
}
function jd(e, { x: t }, { x: n }) {
  return t ? Ri(t, n) === 0 : !0;
}
function qd(e, { x: t }, { x: n }) {
  return t ? Ri(t, n) === t.length - 1 : !0;
}
function CR(e, { y: t }, { x: n, y: r, empty: i }) {
  if (i)
    return !1;
  if (!t)
    return;
  const s = Ri(t, r);
  if (s > 0)
    return Lh(e, n, t[s - 1]);
}
function PR(e, { y: t }, { x: n, y: r, empty: i }) {
  if (i)
    return !1;
  if (!t)
    return;
  const s = Ri(t, r);
  if (s < t.length - 1)
    return Lh(e, n, t[s + 1]);
}
function zR(e, { x: t }, { x: n, y: r, empty: i }) {
  if (i)
    return !1;
  if (!t)
    return;
  const s = Ri(t, n);
  if (s > 0)
    return Lh(e, t[s - 1], r);
}
function UR(e, { x: t }, { x: n, y: r, empty: i }) {
  if (i)
    return !1;
  if (!t)
    return;
  const s = Ri(t, n);
  if (s < t.length - 1)
    return Lh(e, t[s + 1], r);
}
function jR(e, t, { empty: n }) {
  return n;
}
function Mu(e, t) {
  return function() {
    return e.apply(null, arguments) && t.apply(null, arguments);
  };
}
function Vd(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 Vt = class {
  constructor(t, n = {}, r = {}, i) {
    const {
      facet: s = "auto",
      facetAnchor: o,
      fx: a,
      fy: c,
      sort: u,
      dx: l = 0,
      dy: h = 0,
      margin: f = 0,
      marginTop: d = f,
      marginRight: p = f,
      marginBottom: y = f,
      marginLeft: g = f,
      clip: m,
      channels: b,
      tip: w,
      render: v
    } = r;
    if (this.data = t, this.sort = Ai(u) ? u : null, this.initializer = rn(r).initializer, this.transform = this.initializer ? r.transform : pr(r).transform, s === null || s === !1 ? this.facet = null : (this.facet = Qr(s === !0 ? "include" : s, "facet", ["auto", "include", "exclude", "super"]), this.fx = t === Pa && typeof a == "string" ? [a] : a, this.fy = t === Pa && typeof c == "string" ? [c] : c), this.facetAnchor = BR(o), n = Zy(n), b !== void 0 && (n = { ...qR(b), ...n }), i !== void 0 && (n = { ...k6(this, r, i), ...n }), this.channels = Object.fromEntries(
      Object.entries(n).map(([_, x]) => {
        if (Vn(x.value)) {
          const { value: $, scale: T = x.scale } = x.value;
          x = { ...x, scale: T, value: $ };
        }
        if (t === Pa && typeof x.value == "string") {
          const { value: $ } = x;
          x = { ...x, value: [$] };
        }
        return [_, x];
      }).filter(([_, { value: x, optional: $ }]) => {
        if (x != null)
          return !0;
        if ($)
          return !1;
        throw new Error(`missing channel value: ${_}`);
      })
    ), this.dx = +l, this.dy = +h, this.marginTop = +d, this.marginRight = +p, this.marginBottom = +y, this.marginLeft = +g, this.clip = $R(m), this.tip = VR(w), this.facet === "super") {
      if (a || c)
        throw new Error("super-faceting cannot use fx or fy");
      for (const _ in this.channels) {
        const { scale: x } = n[_];
        if (!(x !== "x" && x !== "y"))
          throw new Error("super-faceting cannot use x or y");
      }
    }
    v != null && (this.render = C6(v, this.render));
  }
  initialize(t, n, r) {
    let i = kn(this.data);
    t === void 0 && i != null && (t = [ti(i)]);
    const s = t;
    this.transform != null && ({ facets: t, data: i } = this.transform(i, t, r), i = kn(i)), t !== void 0 && (t.original = s);
    const o = c6(this.channels, i);
    return this.sort != null && yB(i, t, o, n, this.sort), { data: i, facets: t, channels: o };
  }
  filter(t, n, r) {
    for (const i in n) {
      const { filter: s = Oe } = 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" && m6(i, s, n, r.projection);
      }
  }
  scale(t, n, r) {
    const i = fm(t, n);
    return r.projection && this.project(t, i, r), i;
  }
};
function Hr(...e) {
  return e.plot = Vt.prototype.plot, e;
}
function C6(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, h, f) => t.call(this, c, u, l, h, f, a));
  };
}
function qR(e) {
  return Object.fromEntries(
    Object.entries(Zy(e)).map(([t, n]) => (n = Pc(n), n.filter === void 0 && n.scale == null && (n = { ...n, filter: null }), [t, n]))
  );
}
function VR(e) {
  return e === !0 ? "xy" : e === !1 ? null : gh(e, "tip", ["x", "y", "xy"]);
}
function Qo(e, t) {
  return (e == null ? void 0 : e.tip) === !0 ? { ...e, tip: t } : e;
}
const Hb = /* @__PURE__ */ new WeakMap();
function xm(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: C6(function(l, h, f, d, p, y) {
      const g = p.ownerSVGElement, { data: m } = p.getMarkState(this);
      let b = Hb.get(g);
      b || Hb.set(g, b = { sticky: !1, roots: [], renders: [] });
      let w = b.renders.push(z) - 1;
      const { x: v, y: _, fx: x, fy: $ } = h;
      let T = x ? x(l.fx) - d.marginLeft : 0, D = $ ? $(l.fy) - d.marginTop : 0;
      v != null && v.bandwidth && (T += v.bandwidth() / 2), _ != null && _.bandwidth && (D += _.bandwidth() / 2);
      const M = l.fi != null;
      let A;
      if (M) {
        let K = b.facetStates;
        K || (b.facetStates = K = /* @__PURE__ */ new Map()), A = K.get(this), A || K.set(this, A = /* @__PURE__ */ new Map());
      }
      const [L, k] = yr(this, d), { px: S, py: I } = f, E = S ? (K) => S[K] : P6(f, L), N = I ? (K) => I[K] : z6(f, k);
      let O, R, C;
      function j(K, W) {
        if (M)
          if (C && (C = cancelAnimationFrame(C)), K == null)
            A.delete(l.fi);
          else {
            A.set(l.fi, W), C = requestAnimationFrame(() => {
              C = null;
              for (const Y of A.values())
                if (Y < W) {
                  K = null;
                  break;
                }
              z(K);
            });
            return;
          }
        z(K);
      }
      function z(K) {
        if (O === K)
          return;
        O = K;
        const W = O == null ? [] : [O];
        M && (W.fx = l.fx, W.fy = l.fy, W.fi = l.fi);
        const Y = y(W, h, f, d, p);
        if (R) {
          if (M) {
            const U = R.parentNode, V = R.getAttribute("transform"), G = Y.getAttribute("transform");
            V ? Y.setAttribute("transform", V) : Y.removeAttribute("transform"), G ? U.setAttribute("transform", G) : U.removeAttribute("transform"), Y.removeAttribute("aria-label"), Y.removeAttribute("aria-description"), Y.removeAttribute("aria-hidden");
          }
          R.replaceWith(Y);
        }
        return b.roots[w] = R = Y, p.dispatchValue(O == null ? null : m[O]), Y;
      }
      function X(K) {
        if (b.sticky || K.pointerType === "mouse" && K.buttons === 1)
          return;
        let [W, Y] = _n(K);
        W -= T, Y -= D;
        let U = null, V = o * o;
        for (const G of l) {
          const P = e * (E(G) - W), Q = t * (N(G) - Y), at = P * P + Q * Q;
          at <= V && (U = G, V = at);
        }
        j(U, V);
      }
      function H(K) {
        K.pointerType === "mouse" && O != null && (b.sticky && b.roots.some((W) => W == null ? void 0 : W.contains(K.target)) || (b.sticky ? (b.sticky = !1, b.renders.forEach((W) => W(null))) : b.sticky = !0, K.stopImmediatePropagation()));
      }
      function J(K) {
        K.pointerType === "mouse" && (b.sticky || j(null));
      }
      return g.addEventListener("pointerenter", X), g.addEventListener("pointermove", X), g.addEventListener("pointerdown", H), g.addEventListener("pointerleave", J), z(null);
    }, c)
  };
}
function Sm(e) {
  return xm(1, 1, e);
}
function Mm(e) {
  return xm(1, 0.01, e);
}
function $m(e) {
  return xm(0.01, 1, e);
}
function P6({ x1: e, x2: t, x: n = e }, r) {
  return e && t ? (i) => (e[i] + t[i]) / 2 : n ? (i) => n[i] : () => r;
}
function z6({ y1: e, y2: t, y: n = e }, r) {
  return e && t ? (i) => (e[i] + t[i]) / 2 : n ? (i) => n[i] : () => r;
}
function U6(e) {
  return Es(e) && e.interval === void 0 ? void 0 : "tabular-nums";
}
function YR(e, t) {
  return e === void 0 ? Ve(t) ? gm : ge : typeof e == "function" ? e : (typeof e == "string" ? Ve(t) ? uc : Ho : nn)(e);
}
function WR(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: h = (i - u - a) / 64,
    tickFormat: f,
    fontVariant: d = U6(e),
    round: p = !0,
    opacity: y,
    className: g
  } = t;
  const m = Ih(t);
  g = wm(g), y = ie(y)[1], f === null && (f = () => null);
  const b = Dt("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(
    (L) => (
      // Warning: if you edit this, change defaultClassName.
      L.append("style").text(
        `.${g}-ramp {
  display: block;
  background: white;
  height: auto;
  height: intrinsic;
  max-width: 100%;
  overflow: visible;
}
.${g}-ramp text {
  white-space: pre;
}`
      )
    )
  ).call(vm, l);
  let w = (L) => L.selectAll(".tick line").attr("y1", o + c - s), v;
  const _ = p ? (L, k) => L.rangeRound(k) : (L, k) => L.range(k), { type: x, domain: $, range: T, interpolate: D, scale: M, pivot: A } = e;
  if (D) {
    const L = T === void 0 ? D : _y(D.length === 1 ? pm(D) : D, T);
    v = _(
      M.copy(),
      Ln(
        xe(u, i - a),
        Math.min($.length + (A !== void 0), T === void 0 ? 1 / 0 : T.length)
      )
    );
    const k = 256, S = m.document.createElement("canvas");
    S.width = k, S.height = 1;
    const I = S.getContext("2d");
    for (let E = 0, N = k - 1; E < k; ++E)
      I.fillStyle = L(E / N), 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 (x === "threshold") {
    const L = $, k = f === void 0 ? (S) => S : typeof f == "string" ? Ho(f) : f;
    v = _(nh().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), h = Xt(L, (S, I) => I), f = (S) => k(L[S], S);
  } else
    v = _(th().domain($), [u, i - a]), b.append("g").attr("fill-opacity", y).selectAll().data($).enter().append("rect").attr("x", v).attr("y", o).attr("width", Math.max(0, v.bandwidth() - 1)).attr("height", s - o - c).attr("fill", M), w = () => {
    };
  return b.append("g").attr("transform", `translate(0,${s - c})`).call(
    JT(v).ticks(Array.isArray(h) ? null : h, typeof f == "string" ? f : void 0).tickFormat(typeof f == "function" ? f : void 0).tickSize(r).tickValues(Array.isArray(h) ? h : null)
  ).attr("font-size", null).attr("font-family", null).attr("font-variant", ee(d, "normal")).call(w).call((L) => L.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();
}
function Zb(e, t) {
  if (t == null)
    return t;
  const n = e(t);
  if (!n)
    throw new Error(`scale not found: ${t}`);
  return n;
}
function XR(e, { opacity: t, ...n } = {}) {
  if (!Es(e) && !O6(e))
    throw new Error(`swatches legend requires ordinal or threshold color scale (not ${e.type})`);
  return j6(
    e,
    n,
    (r, i, s, o) => r.append("svg").attr("width", s).attr("height", o).attr("fill", i.scale).attr("fill-opacity", ie(t)[1]).append("rect").attr("width", "100%").attr("height", "100%")
  );
}
function GR(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 : ae(t) ? "currentColor" : "none",
  strokeOpacity: i = 1,
  strokeWidth: s = 1.5,
  r: o = 4.5,
  ...a
} = {}, c) {
  const [h, f] = qe(t), [d, p] = qe(r), y = Zb(c, h), g = Zb(c, d), m = o * o * Math.PI;
  return n = ie(n)[1], i = ie(i)[1], s = ie(s)[1], j6(
    e,
    a,
    (b, w, v, _) => b.append("svg").attr("viewBox", "-8 -8 16 16").attr("width", v).attr("height", _).attr("fill", h === "color" ? (x) => y.scale(x) : f).attr("fill-opacity", n).attr("stroke", d === "color" ? (x) => g.scale(x) : p).attr("stroke-opacity", i).attr("stroke-width", s).append("path").attr("d", (x) => {
      const $ = Dr();
      return e.scale(x).draw($, m), $;
    })
  );
}
function j6(e, t = {}, n) {
  let {
    columns: r,
    tickFormat: i,
    fontVariant: s = U6(e),
    // TODO label,
    swatchSize: o = 15,
    swatchWidth: a = o,
    swatchHeight: c = o,
    marginLeft: u = 0,
    className: l,
    style: h,
    width: f
  } = t;
  const d = Ih(t);
  l = wm(l), i = YR(i, e.domain);
  const p = Dt("div", d).attr(
    "class",
    `${l}-swatches ${l}-swatches-${r != null ? "columns" : "wrap"}`
  );
  let y;
  return r != null ? (y = `.${l}-swatches-columns .${l}-swatch {
  display: flex;
  align-items: center;
  break-inside: avoid;
  padding-bottom: 1px;
}
.${l}-swatches-columns .${l}-swatch::before {
  flex-shrink: 0;
}
.${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 = `.${l}-swatches-wrap {
  display: flex;
  align-items: center;
  min-height: 33px;
  flex-wrap: wrap;
}
.${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(
      `.${l}-swatches {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  margin-bottom: 0.5em;
}
.${l}-swatch > svg {
  margin-right: 0.5em;
  overflow: visible;
}
${y}`
    )
  ).style("margin-left", u ? `${+u}px` : null).style("width", f === void 0 ? null : `${+f}px`).style("font-variant", ee(s, "normal")).call(vm, h).node();
}
const _f = /* @__PURE__ */ new Map([
  ["symbol", GR],
  ["color", q6],
  ["opacity", KR]
]);
function HR(e = {}) {
  for (const [t, n] of _f) {
    const r = e[t];
    if (fs(r)) {
      const i = Ih(e);
      let s;
      if (t === "symbol") {
        const { fill: o, stroke: a = o === void 0 && fs(e.color) ? "color" : void 0 } = e;
        s = { fill: o, stroke: a };
      }
      return n(
        l0(t, r, s),
        Am(i, r, e),
        (o) => fs(e[o]) ? l0(o, e[o]) : null
      );
    }
  }
  throw new Error("unknown legend type; no scale found");
}
function ZR(e, t, n = {}) {
  return (r, i) => {
    if (!_f.has(r))
      throw new Error(`unknown legend type: ${r}`);
    if (r in e)
      return _f.get(r)(e[r], Am(t, n[r], i), (s) => e[s]);
  };
}
function Am({ className: e, ...t }, { label: n, ticks: r, tickFormat: i } = {}, s) {
  return Jk(s, { className: e, ...t }, { label: n, ticks: r, tickFormat: i });
}
function q6(e, { legend: t = !0, ...n }) {
  if (t === !0 && (t = e.type === "ordinal" ? "swatches" : "ramp"), e.domain !== void 0)
    switch (`${t}`.toLowerCase()) {
      case "swatches":
        return XR(e, n);
      case "ramp":
        return WR(e, n);
      default:
        throw new Error(`unknown legend type: ${t}`);
    }
}
function KR({ type: e, interpolate: t, ...n }, { legend: r = !0, color: i = bn(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 q6({ type: e, ...n, interpolate: JR(i) }, { legend: r, ...s });
}
function JR(e) {
  const { r: t, g: n, b: r } = bn(e) || bn(0, 0, 0);
  return (i) => `rgba(${t},${n},${r},${i})`;
}
function QR(e, t, n) {
  const r = [];
  for (const [i, s] of _f) {
    const o = n[i];
    if (o != null && o.legend && i in e) {
      const a = s(e[i], Am(t, e[i], o), (c) => e[c]);
      a != null && r.push(a);
    }
  }
  return r;
}
const xf = Math.PI / 180;
function ta(e, { marker: t, markerStart: n = t, markerMid: r = t, markerEnd: i = t } = {}) {
  e.markerStart = Yd(n), e.markerMid = Yd(r), e.markerEnd = Yd(i);
}
function Yd(e) {
  if (e == null || e === !1)
    return null;
  if (e === !0)
    return Jb;
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return null;
    case "arrow":
      return Kb("auto");
    case "arrow-reverse":
      return Kb("auto-start-reverse");
    case "dot":
      return tC;
    case "circle":
    case "circle-fill":
      return Jb;
    case "circle-stroke":
      return eC;
  }
  throw new Error(`invalid marker: ${e}`);
}
function Kb(e) {
  return (t, n) => Dt("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 tC(e, t) {
  return Dt("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 Jb(e, t) {
  return Dt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", e).attr("stroke", "white").attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
function eC(e, t) {
  return Dt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", "white").attr("stroke", e).attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
let nC = 0;
function Vc(e, t, { stroke: n }, r) {
  return V6(e, t, n && ((i) => n[i]), r);
}
function rC(e, t, { stroke: n }, r) {
  return V6(e, t, n && (([i]) => n[i]), r);
}
function V6(e, { markerStart: t, markerMid: n, markerEnd: r, stroke: i }, s = () => i, o) {
  const a = /* @__PURE__ */ new Map();
  function c(u) {
    return function(l) {
      const h = s(l);
      let f = a.get(u);
      f || a.set(u, f = /* @__PURE__ */ new Map());
      let d = f.get(h);
      if (!d) {
        const p = this.parentNode.insertBefore(u(h, o), this), y = `plot-marker-${++nC}`;
        p.setAttribute("id", y), f.set(h, 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 Yc({ inset: e, insetLeft: t, insetRight: n, ...r } = {}) {
  return [t, n] = Y6(e, t, n), { inset: e, insetLeft: t, insetRight: n, ...r };
}
function Wc({ inset: e, insetTop: t, insetBottom: n, ...r } = {}) {
  return [t, n] = Y6(e, t, n), { inset: e, insetTop: t, insetBottom: n, ...r };
}
function Y6(e, t, n) {
  return e === void 0 && t === void 0 && n === void 0 ? be ? [1, 0] : [0.5, 0.5] : [t, n];
}
function W6(e, { interval: t }) {
  return e = { ...Pc(e) }, e.interval = Hy(e.interval === void 0 ? t : e.interval), e;
}
function Dh(e, t, n, r) {
  const { [e]: i, [`${e}1`]: s, [`${e}2`]: o } = n, { value: a, interval: c } = W6(i, n);
  if (a == null || c == null && !r)
    return n;
  const u = ei(i);
  if (c == null) {
    let d;
    const p = { transform: (y) => d || (d = Mt(y, a)), label: u };
    return {
      ...n,
      [e]: void 0,
      [`${e}1`]: s === void 0 ? p : s,
      [`${e}2`]: o === void 0 ? p : o
    };
  }
  let l, h;
  function f(d) {
    return h !== void 0 && d === l ? h : h = Xt(Mt(l = d, a), (p) => c.floor(p));
  }
  return t({
    ...n,
    [e]: void 0,
    [`${e}1`]: s === void 0 ? { transform: f, label: u } : s,
    [`${e}2`]: o === void 0 ? { transform: (d) => f(d).map((p) => c.offset(p)), label: u } : o
  });
}
function X6(e, t, n) {
  const { [e]: r } = n, { value: i, interval: s } = W6(r, n);
  return i == null || s == null ? n : t({
    ...n,
    [e]: {
      label: ei(r),
      transform: (o) => {
        const a = Xt(Mt(o, i), (u) => s.floor(u)), c = a.map((u) => s.offset(u));
        return a.map(
          Ve(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 G6(e = {}) {
  return Dh("x", Yc, e, !0);
}
function H6(e = {}) {
  return Dh("y", Wc, e, !0);
}
function Z6(e = {}) {
  return Dh("x", Yc, e);
}
function K6(e = {}) {
  return Dh("y", Wc, e);
}
function J6(e = {}) {
  return X6("x", Yc, e);
}
function Q6(e = {}) {
  return X6("y", Wc, e);
}
const tM = {
  ariaLabel: "rule",
  fill: null,
  stroke: "currentColor"
};
class eM extends Vt {
  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 }
      },
      Qo(n, "x"),
      tM
    ), this.insetTop = At(a), this.insetBottom = At(c), ta(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y1: u, y2: l } = r, { width: h, height: f, marginTop: d, marginRight: p, marginLeft: y, marginBottom: g } = i, { insetTop: m, insetBottom: b } = this;
    return Dt("svg:g", s).call(Zt, this, i).call(qt, this, { x: c && o }, be, 0).call(
      (w) => w.selectAll().data(t).enter().append("line").call(Ht, this).attr("x1", c ? (v) => c[v] : (y + h - p) / 2).attr("x2", c ? (v) => c[v] : (y + h - p) / 2).attr("y1", u && !yn(a) ? (v) => u[v] + m : d + m).attr(
        "y2",
        l && !yn(a) ? a.bandwidth ? (v) => l[v] + a.bandwidth() - b : (v) => l[v] - b : f - g - b
      ).call(le, this, r).call(Vc, this, r, s)
    ).node();
  }
}
class nM extends Vt {
  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 }
      },
      Qo(n, "y"),
      tM
    ), this.insetRight = At(a), this.insetLeft = At(c), ta(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { y: c, x1: u, x2: l } = r, { width: h, height: f, marginTop: d, marginRight: p, marginLeft: y, marginBottom: g } = i, { insetLeft: m, insetRight: b } = this;
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, { y: c && a }, 0, be).call(
      (w) => w.selectAll().data(t).enter().append("line").call(Ht, this).attr("x1", u && !yn(o) ? (v) => u[v] + m : y + m).attr(
        "x2",
        l && !yn(o) ? o.bandwidth ? (v) => l[v] + o.bandwidth() - b : (v) => l[v] - b : h - p - b
      ).attr("y1", c ? (v) => c[v] : (d + f - g) / 2).attr("y2", c ? (v) => c[v] : (d + f - g) / 2).call(le, this, r).call(Vc, this, r, s)
    ).node();
  }
}
function Ii(e, t) {
  let { x: n = ot, y: r, y1: i, y2: s, ...o } = K6(t);
  return [i, s] = rM(r, i, s), new eM(e, { ...o, x: n, y1: i, y2: s });
}
function Ti(e, t) {
  let { y: n = ot, x: r, x1: i, x2: s, ...o } = Z6(t);
  return [i, s] = rM(r, i, s), new nM(e, { ...o, y: n, x1: i, x2: s });
}
function rM(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 Oh(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 iC = {
  ariaLabel: "text",
  strokeLinejoin: "round",
  strokeWidth: 3,
  paintOrder: "stroke"
}, iM = "­";
class Fh extends Vt {
  constructor(t, n = {}) {
    const {
      x: r,
      y: i,
      text: s = dr(t) && t6(t) ? ot : We,
      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: h,
      monospace: f,
      fontFamily: d = f ? "ui-monospace, monospace" : void 0,
      fontSize: p,
      fontStyle: y,
      fontVariant: g,
      fontWeight: m,
      rotate: b
    } = n, [w, v] = ie(b, 0), [_, x] = cC(p);
    if (super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        fontSize: { value: _, optional: !0 },
        rotate: { value: Wk(w), optional: !0 },
        text: { value: s, filter: Vy, optional: !0 }
      },
      n,
      iC
    ), this.rotate = v, this.textAnchor = ee(a, "middle"), this.lineAnchor = Qr(c, "lineAnchor", ["top", "middle", "bottom"]), this.lineHeight = +u, this.lineWidth = +l, this.textOverflow = sM(h), this.monospace = !!f, this.fontFamily = ge(d), this.fontSize = x, this.fontStyle = ge(y), this.fontVariant = ge(g), this.fontWeight = ge(m), this.frameAnchor = Uc(o), !(this.lineWidth >= 0))
      throw new Error(`invalid lineWidth: ${l}`);
    this.splitLines = uM(this), this.clipLine = lM(this);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, rotate: l, text: h, title: f, fontSize: d } = r, { rotate: p } = this, [y, g] = yr(this, i);
    return Dt("svg:g", s).call(Zt, this, i, s).call(cM, this, h, i).call(qt, this, { x: c && o, y: u && a }).call(
      (m) => m.selectAll().data(t).enter().append("text").call(Ht, this).call(sC, this, h, f).attr(
        "transform",
        Oh`translate(${c ? (b) => c[b] : y},${u ? (b) => u[b] : g})${l ? (b) => ` rotate(${l[b]})` : p ? ` rotate(${p})` : ""}`
      ).call(nt, "font-size", d && ((b) => d[b])).call(le, this, r)
    ).node();
  }
}
function sM(e) {
  return e == null ? null : Qr(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 sC(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(Ur(n[u]) ?? "").map(c), h = l.length, f = i === "top" ? 0.71 : i === "bottom" ? 1 - h : (164 - h * 100) / 200;
    if (h > 1) {
      let d = 0;
      for (let p = 0; p < h; ++p) {
        if (++d, !l[p])
          continue;
        const y = this.ownerDocument.createElementNS(bs.svg, "tspan");
        y.setAttribute("x", 0), p === d - 1 ? y.setAttribute("y", `${(f + p) * s}em`) : y.setAttribute("dy", `${d * s}em`), y.textContent = l[p], this.appendChild(y), d = 0;
      }
    } else
      f && this.setAttribute("y", `${f * s}em`), this.textContent = l[0];
    if (o && !r && l[0] !== n[u]) {
      const d = this.ownerDocument.createElementNS(bs.svg, "title");
      d.textContent = n[u], this.appendChild(d);
    }
  });
}
function zo(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Pn(t, n)), new Fh(e, { ...r, x: t, y: n });
}
function oM(e, { x: t = ot, ...n } = {}) {
  return new Fh(e, Q6({ ...n, x: t }));
}
function aM(e, { y: t = ot, ...n } = {}) {
  return new Fh(e, J6({ ...n, y: t }));
}
function cM(e, t, n) {
  nt(e, "text-anchor", t.textAnchor), nt(e, "font-family", t.fontFamily), nt(e, "font-size", t.fontSize), nt(e, "font-style", t.fontStyle), nt(e, "font-variant", t.fontVariant === void 0 ? oC(n) : t.fontVariant), nt(e, "font-weight", t.fontWeight);
}
function oC(e) {
  return e && (e6(e) || Ve(e)) ? "tabular-nums" : void 0;
}
const aC = /* @__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 cC(e) {
  return e == null || typeof e == "number" ? [void 0, e] : typeof e != "string" ? [e, void 0] : (e = e.trim().toLowerCase(), aC.has(e) || /^[+-]?\d*\.?\d+(e[+-]?\d+)?(\w*|%)$/.test(e) ? [void 0, e] : [e, void 0]);
}
function uC(e, t, n) {
  const r = [];
  let i, s = 0;
  for (const [o, a, c] of lC(e)) {
    if (i === void 0 && (i = o), s > i && n(e, i, a) > t && (r.push(e.slice(i, s) + (e[s - 1] === iM ? "-" : "")), i = o), c) {
      r.push(e.slice(i, a)), i = void 0;
      continue;
    }
    s = a;
  }
  return r;
}
function* lC(e) {
  let t = 0, n = 0;
  const r = e.length;
  for (; n < r; ) {
    let i = 1;
    switch (e[n]) {
      case iM:
      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 Qb = {
  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 Im(e, t = 0, n = e.length) {
  let r = 0;
  for (let i = t; i < n; i = ea(e, i))
    r += Qb[e[i]] ?? (hM(e, i) ? 120 : Qb.e);
  return r;
}
function Tm(e, t = 0, n = e.length) {
  let r = 0;
  for (let i = t; i < n; i = ea(e, i))
    r += hM(e, i) ? 200 : 100;
  return r;
}
function uM({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n != null || t == 1 / 0)
    return (s) => s.split(/\r\n?|\n/g);
  const r = e ? Tm : Im, i = t * 100;
  return (s) => uC(s, i, r);
}
function lM({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n == null || t == 1 / 0)
    return (s) => s;
  const r = e ? Tm : Im, i = t * 100;
  switch (n) {
    case "clip-start":
      return (s) => ew(s, i, r, "");
    case "clip-end":
      return (s) => tw(s, i, r, "");
    case "ellipsis-start":
      return (s) => ew(s, i, r, lo);
    case "ellipsis-middle":
      return (s) => fC(s, i, r, lo);
    case "ellipsis-end":
      return (s) => tw(s, i, r, lo);
  }
}
const lo = "…";
function Uo(e, t, n, r) {
  const i = [];
  let s = 0;
  for (let o = 0, a = 0, c = e.length; o < c; o = a) {
    a = ea(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 tw(e, t, n, r) {
  e = e.trim();
  const i = n(r), [s] = Uo(e, t, n, i);
  return s < 0 ? e : e.slice(0, s).trimEnd() + r;
}
function fC(e, t, n, r) {
  e = e.trim();
  const i = n(e);
  if (i <= t)
    return e;
  const s = n(r) / 2, [o, a] = Uo(e, t / 2, n, s), [c] = Uo(e, i - t / 2 - a + s, n, -s);
  return c < 0 ? r : e.slice(0, o).trimEnd() + r + e.slice(ea(e, c)).trimStart();
}
function ew(e, t, n, r) {
  e = e.trim();
  const i = n(e);
  if (i <= t)
    return e;
  const s = n(r), [o] = Uo(e, i - t + s, n, -s);
  return o < 0 ? r : r + e.slice(ea(e, o)).trimStart();
}
const h0 = /[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy, nw = /\p{Extended_Pictographic}/uy;
function ea(e, t) {
  return t += hC(e, t) ? 2 : 1, pC(e, t) && (t = h0.lastIndex), dC(e, t) ? ea(e, t + 1) : t;
}
function fM(e, t) {
  return e.charCodeAt(t) < 128;
}
function hC(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 dC(e, t) {
  return e.charCodeAt(t) === 8205;
}
function pC(e, t) {
  return fM(e, t) ? !1 : (h0.lastIndex = t, h0.test(e));
}
function hM(e, t) {
  return fM(e, t) ? !1 : (nw.lastIndex = t, nw.test(e));
}
const dM = {
  ariaLabel: "vector",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinejoin: "round",
  strokeLinecap: "round"
}, pM = 3.5, yC = pM * 5, yM = {
  draw(e, t, n) {
    const r = t * n / yC;
    e.moveTo(0, 0), e.lineTo(0, -t), e.moveTo(-r, r - t), e.lineTo(0, -t), e.lineTo(r, r - t);
  }
}, mM = {
  draw(e, t, n) {
    e.moveTo(-n, 0), e.lineTo(0, -t), e.lineTo(n, 0);
  }
}, mC = /* @__PURE__ */ new Map([
  ["arrow", yM],
  ["spike", mM]
]);
function gC(e) {
  return e && typeof e.draw == "function";
}
function bC(e) {
  if (gC(e))
    return e;
  const t = mC.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid shape: ${e}`);
}
class kh extends Vt {
  constructor(t, n = {}) {
    const { x: r, y: i, r: s = pM, length: o, rotate: a, shape: c = yM, anchor: u = "middle", frameAnchor: l } = n, [h, f] = ie(o, 12), [d, p] = ie(a, 0);
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        length: { value: h, scale: "length", optional: !0 },
        rotate: { value: d, optional: !0 }
      },
      n,
      dM
    ), this.r = +s, this.length = f, this.rotate = p, this.shape = bC(c), this.anchor = Qr(u, "anchor", ["start", "middle", "end"]), this.frameAnchor = Uc(l);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, length: l, rotate: h } = r, { length: f, rotate: d, anchor: p, shape: y, r: g } = this, [m, b] = yr(this, i);
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, { x: c && o, y: u && a }).call(
      (w) => w.selectAll().data(t).enter().append("path").call(Ht, this).attr(
        "transform",
        Oh`translate(${c ? (v) => c[v] : m},${u ? (v) => u[v] : b})${h ? (v) => ` rotate(${h[v]})` : d ? ` rotate(${d})` : ""}${p === "start" ? "" : p === "end" ? l ? (v) => ` translate(0,${l[v]})` : ` translate(0,${f})` : l ? (v) => ` translate(0,${l[v] / 2})` : ` translate(0,${f / 2})`}`
      ).attr(
        "d",
        l ? (v) => {
          const _ = Dr();
          return y.draw(_, l[v], g), _;
        } : (() => {
          const v = Dr();
          return y.draw(v, f, g), v;
        })()
      ).call(le, this, r)
    ).node();
  }
}
function gM(e, t = {}) {
  let { x: n, y: r, ...i } = t;
  return t.frameAnchor === void 0 && ([n, r] = Pn(n, r)), new kh(e, { ...i, x: n, y: r });
}
function bM(e, t = {}) {
  const { x: n = ot, ...r } = t;
  return new kh(e, { ...r, x: n });
}
function wM(e, t = {}) {
  const { y: n = ot, ...r } = t;
  return new kh(e, { ...r, y: n });
}
function wC(e, t = {}) {
  const {
    shape: n = mM,
    stroke: r = dM.stroke,
    strokeWidth: i = 1,
    fill: s = r,
    fillOpacity: o = 0.3,
    anchor: a = "start",
    ...c
  } = t;
  return gM(e, { ...c, shape: n, stroke: r, strokeWidth: i, fill: s, fillOpacity: o, anchor: a });
}
function Ci(e, t) {
  return arguments.length < 2 && !dr(e) && (t = e, e = null), t === void 0 && (t = {}), [e, t];
}
function Bh({ anchor: e } = {}, t) {
  return e === void 0 ? t[0] : Qr(e, "anchor", t);
}
function vM(e) {
  return Bh(e, ["left", "right"]);
}
function _M(e) {
  return Bh(e, ["right", "left"]);
}
function xM(e) {
  return Bh(e, ["bottom", "top"]);
}
function SM(e) {
  return Bh(e, ["top", "bottom"]);
}
function Em() {
  const [e, t] = Ci(...arguments);
  return AM("y", vM(t), e, t);
}
function MM() {
  const [e, t] = Ci(...arguments);
  return AM("fy", _M(t), e, t);
}
function Nm() {
  const [e, t] = Ci(...arguments);
  return IM("x", xM(t), e, t);
}
function $M() {
  const [e, t] = Ci(...arguments);
  return IM("fx", SM(t), e, t);
}
function AM(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: h,
  textStrokeOpacity: f,
  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: _ = b === void 0 ? 20 : b,
  marginLeft: x = b === void 0 ? t === "left" ? 40 : 0 : b,
  label: $,
  labelAnchor: T,
  labelArrow: D,
  labelOffset: M,
  ...A
}) {
  return p = At(p), y = At(y), g = At(g), T !== void 0 && (T = Qr(T, "labelAnchor", ["center", "top", "bottom"])), D = PM(D), Hr(
    p && !ae(s) ? vC(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      x: m,
      ...A
    }) : null,
    ae(c) ? null : xC(e, t, n, {
      fill: c,
      fillOpacity: u,
      stroke: h,
      strokeOpacity: f,
      strokeWidth: d,
      textAnchor: l,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      x: m,
      marginTop: w,
      marginRight: v,
      marginBottom: _,
      marginLeft: x,
      ...A
    }),
    !ae(c) && $ !== null ? zo(
      [],
      kM({ fill: c, fillOpacity: u, ...A }, function(L, k, S, I, E) {
        const N = I[e], { marginTop: O, marginRight: R, marginBottom: C, marginLeft: j } = e === "y" && E.inset || E, z = T ?? (N.bandwidth ? "center" : "top"), X = M ?? (t === "right" ? R : j) - 3;
        return z === "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 = z, this.frameAnchor = `${z}-${t}`, this.rotate = 0), this.dy = z === "top" ? 3 - O : z === "bottom" ? C - 3 : 0, this.dx = t === "right" ? X : -X, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [CM(e, N, { anchor: t, label: $, labelAnchor: z, labelArrow: D })] } }
        };
      })
    ) : null
  );
}
function IM(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: h,
  textStrokeOpacity: f,
  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: _ = b === void 0 ? t === "bottom" ? 30 : 0 : b,
  marginLeft: x = b === void 0 ? 20 : b,
  label: $,
  labelAnchor: T,
  labelArrow: D,
  labelOffset: M,
  ...A
}) {
  return p = At(p), y = At(y), g = At(g), T !== void 0 && (T = Qr(T, "labelAnchor", ["center", "left", "right"])), D = PM(D), Hr(
    p && !ae(s) ? _C(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      y: m,
      ...A
    }) : null,
    ae(c) ? null : SC(e, t, n, {
      fill: c,
      fillOpacity: u,
      stroke: h,
      strokeOpacity: f,
      strokeWidth: d,
      textAnchor: l,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      y: m,
      marginTop: w,
      marginRight: v,
      marginBottom: _,
      marginLeft: x,
      ...A
    }),
    !ae(c) && $ !== null ? zo(
      [],
      kM({ fill: c, fillOpacity: u, ...A }, function(L, k, S, I, E) {
        const N = I[e], { marginTop: O, marginRight: R, marginBottom: C, marginLeft: j } = e === "x" && E.inset || E, z = T ?? (N.bandwidth ? "center" : "right"), X = M ?? (t === "top" ? O : C) - 3;
        return z === "center" ? (this.frameAnchor = t, this.textAnchor = void 0) : (this.frameAnchor = `${t}-${z}`, this.textAnchor = z === "right" ? "end" : "start"), this.lineAnchor = t, this.dy = t === "top" ? -X : X, this.dx = z === "right" ? R - 3 : z === "left" ? 3 - j : 0, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [CM(e, N, { anchor: t, label: $, labelAnchor: z, labelArrow: D })] } }
        };
      })
    ) : null
  );
}
function vC(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: h = u,
  dx: f = 0,
  y: d = e === "y" ? void 0 : null,
  ...p
}) {
  return na(wM, e, `${e}-axis tick`, n, {
    strokeWidth: r,
    strokeLinecap: i,
    strokeLinejoin: s,
    facetAnchor: o,
    frameAnchor: a,
    y: d,
    ...p,
    dx: t === "left" ? +f - be + +l : +f + be - h,
    anchor: "start",
    length: c,
    shape: t === "left" ? AC : IC
  });
}
function _C(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: h = u,
  dy: f = 0,
  x: d = e === "x" ? void 0 : null,
  ...p
}) {
  return na(bM, e, `${e}-axis tick`, n, {
    strokeWidth: r,
    strokeLinejoin: s,
    strokeLinecap: i,
    facetAnchor: o,
    frameAnchor: a,
    x: d,
    ...p,
    dy: t === "bottom" ? +f - be - h : +f + be + +l,
    anchor: "start",
    length: c,
    shape: t === "bottom" ? MC : $C
  });
}
function xC(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 * xf) : 0),
  tickFormat: c,
  text: u = typeof c == "function" ? c : void 0,
  textAnchor: l = Math.abs(o) > 60 ? "middle" : t === "left" ? "end" : "start",
  lineAnchor: h = o > 60 ? "top" : o < -60 ? "bottom" : "middle",
  fontVariant: f,
  inset: d = 0,
  insetLeft: p = d,
  insetRight: y = d,
  dx: g = 0,
  y: m = e === "y" ? void 0 : null,
  ...b
}) {
  return na(
    aM,
    e,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: r,
      frameAnchor: i,
      text: u === void 0 ? null : u,
      textAnchor: l,
      lineAnchor: h,
      fontVariant: f,
      rotate: o,
      y: m,
      ...b,
      dx: t === "left" ? +g - s - a + +p : +g + +s + +a - y
    },
    function(w, v, _) {
      f === void 0 && (this.fontVariant = RM(w)), u === void 0 && (_.text = BM(w, v, c));
    }
  );
}
function SC(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 * xf) : 0),
  tickFormat: c,
  text: u = typeof c == "function" ? c : void 0,
  textAnchor: l = Math.abs(o) >= 10 ? o < 0 ^ t === "bottom" ? "start" : "end" : "middle",
  lineAnchor: h = Math.abs(o) >= 10 ? "middle" : t === "bottom" ? "top" : "bottom",
  fontVariant: f,
  inset: d = 0,
  insetTop: p = d,
  insetBottom: y = d,
  dy: g = 0,
  x: m = e === "x" ? void 0 : null,
  ...b
}) {
  return na(
    oM,
    e,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: r,
      frameAnchor: i,
      text: u === void 0 ? null : u,
      textAnchor: l,
      lineAnchor: h,
      fontVariant: f,
      rotate: o,
      x: m,
      ...b,
      dy: t === "bottom" ? +g + +s + +a - y : +g - s - a + +p
    },
    function(w, v, _) {
      f === void 0 && (this.fontVariant = RM(w)), u === void 0 && (_.text = BM(w, v, c));
    }
  );
}
function TM() {
  const [e, t] = Ci(...arguments);
  return DM("y", vM(t), e, t);
}
function EM() {
  const [e, t] = Ci(...arguments);
  return DM("fy", _M(t), e, t);
}
function NM() {
  const [e, t] = Ci(...arguments);
  return OM("x", xM(t), e, t);
}
function LM() {
  const [e, t] = Ci(...arguments);
  return OM("fx", SM(t), e, t);
}
function DM(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 na(Ti, e, `${e}-grid`, n, { y: r, x1: s, x2: o, ...FM(a) });
}
function OM(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 na(Ii, e, `${e}-grid`, n, { x: r, y1: s, y2: o, ...FM(a) });
}
function FM({
  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 kM({ fill: e, fillOpacity: t, fontFamily: n, fontSize: r, fontStyle: i, fontWeight: s, monospace: o, pointerEvents: a, shapeRendering: c }, u) {
  return [, e] = qe(e), [, t] = ie(t), {
    facet: "super",
    x: null,
    y: null,
    fill: e,
    fillOpacity: t,
    fontFamily: n,
    fontSize: r,
    fontStyle: i,
    fontWeight: s,
    monospace: o,
    pointerEvents: a,
    shapeRendering: c,
    initializer: u
  };
}
function na(e, t, n, r, i, s) {
  let o;
  const a = e(
    r,
    rn(i, function(c, u, l, h, f, d) {
      const p = c == null && (t === "fx" || t === "fy"), { [t]: y } = h;
      if (!y)
        throw new Error(`missing scale: ${t}`);
      let { ticks: g, tickSpacing: m, interval: b } = i;
      if (D6(y) && typeof g == "string" && (b = g, g = void 0), c == null) {
        if (dr(g))
          c = kn(g);
        else if (y.ticks)
          if (g !== void 0)
            c = y.ticks(g);
          else if (b = Jo(b === void 0 ? y.interval : b, y.type), b !== void 0) {
            const [v, _] = Se(y.domain());
            c = b.range(v, b.offset(b.floor(_)));
          } else {
            const [v, _] = Se(y.range());
            g = (_ - v) / (m === void 0 ? t === "x" ? 80 : 35 : m), c = y.ticks(g);
          }
        else
          c = y.domain();
        t === "y" || t === "x" ? u = [ti(c)] : o[t] = { scale: t, value: ot };
      }
      s == null || s.call(this, y, g, o);
      const w = Object.fromEntries(
        Object.entries(o).map(([v, _]) => [v, { ..._, value: Mt(c, _.value) }])
      );
      return p && (u = d.filterFacets(c, w)), { data: c, facets: u, channels: w };
    })
  );
  return r == null ? (o = a.channels, a.channels = {}) : o = {}, a.ariaLabel = n, a;
}
function BM(e, t, n) {
  return { value: d0(e, t, n) };
}
function d0(e, t, n) {
  return e.tickFormat ? e.tickFormat(dr(t) ? null : t, n) : n === void 0 ? Ck(e.interval) ? uc("%Y") : Pk(e.interval) ? By("%Y") : Ur : typeof n == "string" ? (Ve(e.domain()) ? uc : Ho)(n) : nn(n);
}
const MC = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, t);
  }
}, $C = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, -t);
  }
}, AC = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(-t, 0);
  }
}, IC = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(t, 0);
  }
};
function RM(e) {
  return e.bandwidth && !e.interval ? void 0 : "tabular-nums";
}
function TC(e) {
  return Math.sign(hc(e.domain())) * Math.sign(hc(e.range()));
}
function CM(e, t, { anchor: n, label: r = t.label, labelAnchor: i, labelArrow: s } = {}) {
  if (!(r == null || r.inferred && EC(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 = TC(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 PM(e = "auto") {
  return ae(e) ? !1 : typeof e == "boolean" ? e : Qr(e, "labelArrow", ["auto", "up", "right", "down", "left"]);
}
function EC(e) {
  return D6(e) || e.interval != null;
}
const NC = {
  ariaLabel: "frame",
  fill: "none",
  stroke: "currentColor"
}, LC = {
  ariaLabel: "frame",
  fill: null,
  stroke: "currentColor",
  strokeLinecap: "square"
};
class zM extends Vt {
  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(Pa, void 0, t, n == null ? NC : LC), this.anchor = gh(n, "anchor", ["top", "right", "bottom", "left"]), this.insetTop = At(i), this.insetRight = At(s), this.insetBottom = At(o), this.insetLeft = At(a), this.rx = At(c), this.ry = At(u);
  }
  render(t, n, r, i, s) {
    const { marginTop: o, marginRight: a, marginBottom: c, marginLeft: u, width: l, height: h } = i, { anchor: f, insetTop: d, insetRight: p, insetBottom: y, insetLeft: g, rx: m, ry: b } = this, w = u + g, v = l - a - p, _ = o + d, x = h - c - y;
    return Dt(f ? "svg:line" : "svg:rect", s).datum(0).call(Zt, this, i, s).call(Ht, this).call(le, this, r).call(qt, this, {}).call(
      f === "left" ? ($) => $.attr("x1", w).attr("x2", w).attr("y1", _).attr("y2", x) : f === "right" ? ($) => $.attr("x1", v).attr("x2", v).attr("y1", _).attr("y2", x) : f === "top" ? ($) => $.attr("x1", w).attr("x2", v).attr("y1", _).attr("y2", _) : f === "bottom" ? ($) => $.attr("x1", w).attr("x2", v).attr("y1", x).attr("y2", x) : ($) => $.attr("x", w).attr("y", _).attr("width", v - w).attr("height", x - _).attr("rx", m).attr("ry", b)
    ).node();
  }
}
function Lm(e) {
  return new zM(e);
}
const Wd = {
  ariaLabel: "tip",
  fill: "white",
  stroke: "currentColor"
}, DC = /* @__PURE__ */ new Set(["geometry", "href", "src", "ariaLabel"]);
class UM extends Vt {
  constructor(t, n = {}) {
    n.tip && (n = { ...n, tip: !1 }), n.title === void 0 && dr(t) && t6(t) && (n = { ...n, title: ot });
    const {
      x: r,
      y: i,
      x1: s,
      x2: o,
      y1: a,
      y2: c,
      anchor: u,
      monospace: l,
      fontFamily: h = l ? "ui-monospace, monospace" : void 0,
      fontSize: f,
      fontStyle: d,
      fontVariant: p,
      fontWeight: y,
      lineHeight: g = 1,
      lineWidth: m = 20,
      frameAnchor: b,
      textAnchor: w = "start",
      textOverflow: v,
      textPadding: _ = 8,
      pointerSize: x = 12,
      pathFilter: $ = "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 }
      },
      n,
      Wd
    ), this.anchor = n6(u, "anchor"), this.previousAnchor = this.anchor ?? "top-left", this.frameAnchor = Uc(b), this.textAnchor = ee(w, "middle"), this.textPadding = +_, this.pointerSize = +x, this.pathFilter = ge($), this.lineHeight = +g, this.lineWidth = +m, this.textOverflow = sM(v), this.monospace = !!l, this.fontFamily = ge(h), this.fontSize = At(f), this.fontStyle = ge(d), this.fontVariant = ge(p), this.fontWeight = ge(y);
    for (const T in Wd)
      T in this.channels && (this[T] = Wd[T]);
    this.splitLines = uM(this), this.clipLine = lM(this);
  }
  render(t, n, r, i, s) {
    const o = this, { x: a, y: c, fx: u, fy: l } = n, { ownerSVGElement: h, document: f } = s, { anchor: d, monospace: p, lineHeight: y, lineWidth: g } = this, { textPadding: m, pointerSize: b, pathFilter: w } = this, { marginTop: v, marginLeft: _ } = i, x = BC(r), { x1: $, y1: T, x2: D, y2: M, x: A = $ ?? D, y: L = T ?? M } = r, k = u ? u(t.fx) - _ : 0, S = l ? l(t.fy) - v : 0, [I, E] = yr(this, i), N = P6(r, I), O = z6(r, E), R = p ? Tm : Im, C = R(lo), j = u && d0(u), z = l && d0(l);
    function* X(W, Y) {
      if ("title" in W) {
        const U = W.title.value[Y];
        for (const V of o.splitLines(Ur(U)))
          yield { name: "", value: o.clipLine(V) };
        return;
      }
      for (const U in W) {
        if (U === "x1" && "x2" in W || U === "y1" && "y2" in W)
          continue;
        const V = W[U], G = V.value[Y];
        if (!(!Oe(G) && V.scale == null))
          if (U === "x2" && "x1" in W)
            yield { name: Xd(n, V, "x"), value: rw(W.x1, V, Y) };
          else if (U === "y2" && "y1" in W)
            yield { name: Xd(n, V, "y"), value: rw(W.y1, V, Y) };
          else {
            const P = V.scale, Q = { name: Xd(n, V, U), value: Ur(G) };
            (P === "color" || P === "opacity") && (Q[P] = r[U][Y]), yield Q;
          }
      }
      t.fi != null && u && (yield { name: String(u.label ?? "fx"), value: j(t.fx) }), t.fi != null && l && (yield { name: String(l.label ?? "fy"), value: z(t.fy) });
    }
    const H = Dt("svg:g", s).call(Zt, this, i, s).call(cM, this).call(qt, this, { x: A && a, y: L && c }).call(
      (W) => W.selectAll().data(t).enter().append("g").attr("transform", (Y) => `translate(${Math.round(N(Y))},${Math.round(O(Y))})`).call(Ht, this).call((Y) => Y.append("path").attr("filter", w)).call(
        (Y) => Y.append("text").each(function(U) {
          const V = zt(this);
          this.setAttribute("fill", "currentColor"), this.setAttribute("fill-opacity", 1), this.setAttribute("stroke", "none");
          const G = /* @__PURE__ */ new Set();
          for (const P of X(x, U)) {
            const Q = P.name;
            Q && G.has(Q) || (G.add(Q), J(V, P));
          }
        })
      )
    );
    function J(W, { name: Y, value: U, color: V, opacity: G }) {
      const P = V != null || G != null;
      let Q, at = g * 100;
      const [Ot] = Uo(Y, at, R, C);
      if (Ot >= 0)
        Y = Y.slice(0, Ot).trimEnd() + lo, Q = U.trim(), U = "";
      else {
        (Y || !U && !P) && (U = " " + U);
        const [Z] = Uo(U, at - R(Y), R, C);
        Z >= 0 && (U = U.slice(0, Z).trimEnd() + lo, Q = U.trim());
      }
      const xt = W.append("tspan").attr("x", 0).attr("dy", `${y}em`).text("​");
      Y && xt.append("tspan").attr("font-weight", "bold").text(Y), U && xt.append(() => f.createTextNode(U)), P && xt.append("tspan").text(" ■").attr("fill", V).attr("fill-opacity", G).style("user-select", "none"), Q && xt.append("title").text(Q);
    }
    function K() {
      const { width: W, height: Y } = i.facet ?? i;
      H.selectChildren().each(function(U) {
        let { x: V, width: G, height: P } = this.getBBox();
        G = Math.round(G), P = Math.round(P);
        let Q = d;
        if (Q === void 0) {
          Q = o.previousAnchor;
          const xt = N(U) + k, Z = O(U) + S, Ct = xt + G + m * 2 < W, zn = xt - G - m * 2 > 0, Xe = Z + P + b + m * 2 + 7 < Y, Qc = Z - P - b - m * 2 > 0, tu = (/-left$/.test(Q) ? Ct || !zn : Ct && !zn) ? "left" : "right", Wh = (/^top-/.test(Q) ? Xe || !Qc : Xe && !Qc) ? "top" : "bottom";
          Q = o.previousAnchor = `${Wh}-${tu}`;
        }
        const at = this.firstChild, Ot = this.lastChild;
        if (at.setAttribute("d", kC(Q, b, m, G, P)), V)
          for (const xt of Ot.childNodes)
            xt.setAttribute("x", -V);
        Ot.setAttribute("y", `${+OC(Q, Ot.childNodes.length, y).toFixed(6)}em`), Ot.setAttribute("transform", `translate(${FC(Q, b, m, G, P)})`);
      });
    }
    return h.isConnected ? Promise.resolve().then(K) : typeof requestAnimationFrame < "u" && requestAnimationFrame(K), H.node();
  }
}
function jM(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Pn(t, n)), new UM(e, { ...r, x: t, y: n });
}
function OC(e, t, n) {
  return /^top(?:-|$)/.test(e) ? 0.94 - n : -0.29 - t * n;
}
function FC(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 kC(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 BC({ channels: e }) {
  const t = {};
  for (const n in e) {
    if (DC.has(n))
      continue;
    const r = h6(e, n);
    r && (t[n] = r);
  }
  return t;
}
function rw(e, t, n) {
  var r;
  return (r = t.hint) != null && r.length ? `${Ur(t.value[n] - e.value[n])}` : `${Ur(e.value[n])}–${Ur(t.value[n])}`;
}
function Xd(e, t, n) {
  var r;
  return String(((r = e[t.scale]) == null ? void 0 : r.label) ?? (t == null ? void 0 : t.label) ?? n);
}
function Dm(e = {}) {
  var E;
  const { facet: t, style: n, caption: r, ariaLabel: i, ariaDescription: s } = e, o = wm(e.className), a = e.marks === void 0 ? [] : iw(e.marks);
  a.push(...qC(a));
  const c = UC(t, e), u = /* @__PURE__ */ new Map();
  for (const N of a) {
    const O = sw(N, c, e);
    O && u.set(N, O);
  }
  const l = /* @__PURE__ */ new Map();
  c && va(l, [c]), va(l, u);
  const h = iw(VC(a, l, e));
  for (const N of h) {
    const O = sw(N, c, e);
    O && u.set(N, O);
  }
  a.unshift(...h);
  let f = LR(l, e);
  if (f !== void 0) {
    const N = c ? Vd(f, c) : void 0;
    for (const R of a) {
      if (R.facet === null || R.facet === "super")
        continue;
      const C = u.get(R);
      C !== void 0 && (C.facetsIndex = R.fx != null || R.fy != null ? Vd(f, C) : N);
    }
    const O = /* @__PURE__ */ new Set();
    for (const { facetsIndex: R } of u.values())
      R == null || R.forEach((C, j) => {
        (C == null ? void 0 : C.length) > 0 && O.add(j);
      });
    f.forEach(
      0 < O.size && O.size < f.length ? (R, C) => R.empty = !O.has(C) : (R) => R.empty = !1
    );
    for (const R of a)
      if (R.facet === "exclude") {
        const C = u.get(R);
        C !== void 0 && (C.facetsIndex = FR(C.facetsIndex));
      }
  }
  for (const N of Qt.keys())
    fs(e[N]) && N !== "fx" && N !== "fy" && l.set(N, []);
  const d = /* @__PURE__ */ new Map();
  for (const N of a) {
    if (d.has(N))
      throw new Error("duplicate mark; each mark must be unique");
    const { facetsIndex: O, channels: R } = u.get(N) ?? {}, { data: C, facets: j, channels: z } = N.initialize(O, R, e);
    Om(z, e), d.set(N, { data: C, facets: j, channels: z });
  }
  const p = u0(va(l, d), e), y = jb(p), g = ER(p, a, e);
  sR(p, g);
  const { fx: m, fy: b } = y, w = m || b ? T6(p, g) : g, v = m || b ? KC(y, g) : g, _ = Ih(e), x = _.document, $ = Wf("svg").call(x.documentElement);
  let T = $;
  _.ownerSVGElement = $, _.className = o, _.projection = vB(e, w), _.filterFacets = (N, O) => Vd(f, { channels: O, groups: _m(N, O) }), _.getMarkState = (N) => {
    const O = d.get(N), R = u.get(N);
    return { ...O, channels: { ...O.channels, ...R == null ? void 0 : R.channels } };
  }, _.dispatchValue = (N) => {
    T.value !== N && (T.value = N, T.dispatchEvent(new Event("input", { bubbles: !0 })));
  };
  const D = /* @__PURE__ */ new Set();
  for (const [N, O] of d)
    if (N.initializer != null) {
      const R = N.facet === "super" ? v : w, C = N.initializer(O.data, O.facets, O.channels, y, R, _);
      if (C.data !== void 0 && (O.data = C.data), C.facets !== void 0 && (O.facets = C.facets), C.channels !== void 0) {
        const { fx: j, fy: z, ...X } = C.channels;
        zC(X), Object.assign(O.channels, X);
        for (const H of Object.values(X)) {
          const { scale: J } = H;
          J != null && Qt.get(J) !== er && (qM(H, e), D.add(J));
        }
        (j != null || z != null) && u.set(N, !0);
      }
    }
  if (D.size) {
    const N = /* @__PURE__ */ new Map();
    va(N, d, (C) => D.has(C)), va(l, d, (C) => D.has(C));
    const O = ZC(u0(N, e), p), R = jb(O);
    Object.assign(p, O), Object.assign(y, R);
  }
  let M, A;
  f !== void 0 && (M = { x: m == null ? void 0 : m.domain(), y: b == null ? void 0 : b.domain() }, f = DR(f, M), A = OR(m, b, g));
  for (const [N, O] of d)
    O.values = N.scale(O.channels, y, _);
  const { width: L, height: k } = g;
  zt($).attr("class", o).attr("fill", "currentColor").attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("text-anchor", "middle").attr("width", L).attr("height", k).attr("viewBox", `0 0 ${L} ${k}`).attr("aria-label", i).attr("aria-description", s).call(
    (N) => (
      // Warning: if you edit this, change defaultClassName.
      N.append("style").text(
        `.${o} {
  display: block;
  background: white;
  height: auto;
  height: intrinsic;
  max-width: 100%;
}
.${o} text,
.${o} tspan {
  white-space: pre;
}`
      )
    )
  ).call(vm, n);
  for (const N of a) {
    const { channels: O, values: R, facets: C } = d.get(N);
    if (f === void 0 || N.facet === "super") {
      let j = null;
      if (C && (j = C[0], j = N.filter(j, O, R), j.length === 0))
        continue;
      const z = N.render(j, y, R, v, _);
      if (z == null)
        continue;
      $.appendChild(z);
    } else {
      let j;
      for (const z of f) {
        if (!(((E = N.facetAnchor) == null ? void 0 : E.call(N, f, M, z)) ?? !z.empty))
          continue;
        let X = null;
        if (C) {
          const J = u.has(N);
          if (X = C[J ? z.i : 0], X = N.filter(X, O, R), X.length === 0)
            continue;
          J && (X.fx = z.x, X.fy = z.y, X.fi = z.i);
        }
        const H = N.render(X, y, R, w, _);
        if (H != null) {
          (j ?? (j = zt($).append("g"))).append(() => H).datum(z);
          for (const J of ["aria-label", "aria-description", "aria-hidden", "transform"])
            H.hasAttribute(J) && (j.attr(J, H.getAttribute(J)), H.removeAttribute(J));
        }
      }
      j == null || j.selectChildren().attr("transform", A);
    }
  }
  const S = QR(p, _, e);
  if (r != null || S.length > 0) {
    T = x.createElement("figure"), T.style.maxWidth = "initial";
    for (const N of S)
      T.appendChild(N);
    if (T.appendChild($), r != null) {
      const N = x.createElement("figcaption");
      N.appendChild(r != null && r.ownerDocument ? r : x.createTextNode(r)), T.appendChild(N);
    }
  }
  T.scale = fR(p), T.legend = ZR(p, _, e);
  const I = wB();
  return I > 0 && zt($).append("text").attr("x", L).attr("y", 20).attr("dy", "-1em").attr("text-anchor", "end").attr("font-family", "initial").text("⚠️").append("title").text(`${I.toLocaleString("en-US")} warning${I === 1 ? "" : "s"}. Please check the console.`), T;
}
function RC({ marks: e = [], ...t } = {}) {
  return Dm({ ...t, marks: [...e, this] });
}
Vt.prototype.plot = RC;
function iw(e) {
  return e.flat(1 / 0).filter((t) => t != null).map(CC);
}
function CC(e) {
  return typeof e.render == "function" ? e : new PC(e);
}
class PC extends Vt {
  constructor(t) {
    if (typeof t != "function")
      throw new TypeError("invalid mark; missing render function");
    super(), this.render = t;
  }
  render() {
  }
}
function Om(e, t) {
  for (const n in e)
    qM(e[n], t);
  return e;
}
function qM(e, t) {
  const { scale: n } = e;
  if (n == null)
    return;
  const {
    type: r,
    percent: i,
    interval: s,
    transform: o = i ? (a) => a * 100 : QS(s, r)
  } = t[n] ?? {};
  o != null && (e.value = Xt(e.value, o));
}
function zC(e) {
  for (const t in e)
    u6(t, e[t]);
}
function va(e, t, n = jk) {
  for (const { channels: r } of t.values())
    for (const i in r) {
      const s = r[i], { scale: o } = s;
      if (o != null && n(o)) {
        const a = e.get(o);
        a !== void 0 ? a.push(s) : e.set(o, [s]);
      }
    }
  return e;
}
function UC(e, t) {
  if (e == null)
    return;
  const { x: n, y: r } = e;
  if (n == null && r == null)
    return;
  const i = kn(e.data);
  if (i == null)
    throw new Error("missing facet data");
  const s = {};
  n != null && (s.fx = yc(i, { value: n, scale: "fx" })), r != null && (s.fy = yc(i, { value: r, scale: "fy" })), Om(s, t);
  const o = _m(i, s);
  return { channels: s, groups: o, data: e.data };
}
function sw(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 = kn(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 = yc(u, { value: r, scale: "fx" })), i != null && (l.fy = yc(u, { value: i, scale: "fy" })), Om(l, n), { channels: l, groups: _m(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 = kn(e.data)) == null ? void 0 : c.length) === a.length && hs(
    `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 jC(e, t = {}) {
  return rn({ ...t, x: null, y: null }, (n, r, i, s, o, a) => a.getMarkState(e));
}
function qC(e) {
  const t = [];
  for (const n of e) {
    const r = n.tip;
    if (r) {
      const i = r === "x" ? Mm : r === "y" ? $m : Sm;
      t.push(jM(n.data, i(jC(n))));
    }
  }
  return t;
}
function VC(e, t, n) {
  let {
    projection: r,
    x: i = {},
    y: s = {},
    fx: o = {},
    fy: a = {},
    axis: c,
    grid: u,
    facet: l = {},
    facet: { axis: h = c, grid: f } = 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 = h, grid: b = m === null ? null : f } = o,
    fy: { axis: w = h, grid: v = w === null ? null : f } = a
  } = n;
  (r || !fs(i) && !ow("x", e)) && (d = p = null), (r || !fs(s) && !ow("y", e)) && (y = g = null), t.has("fx") || (m = b = null), t.has("fy") || (w = v = null), d === void 0 && (d = !Iu(e, "x")), y === void 0 && (y = !Iu(e, "y")), m === void 0 && (m = !Iu(e, "fx")), w === void 0 && (w = !Iu(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 _ = [];
  return Au(_, v, EM, a), $u(_, w, MM, "right", "left", l, a), Au(_, b, LM, o), $u(_, m, $M, "top", "bottom", l, o), Au(_, g, TM, s), $u(_, y, Em, "left", "right", n, s), Au(_, p, NM, i), $u(_, d, Nm, "bottom", "top", n, i), _;
}
function $u(e, t, n, r, i, s, o) {
  if (!t)
    return;
  const a = YC(t);
  o = WC(a ? r : t, s, o);
  const { line: c } = o;
  (n === Em || n === Nm) && c && !Po(c) && e.push(Lm(XC(o))), e.push(n(o)), a && e.push(n({ ...o, anchor: i, label: null }));
}
function Au(e, t, n, r) {
  !t || Po(t) || e.push(n(GC(t, r)));
}
function YC(e) {
  return /^\s*both\s*$/i.test(e);
}
function WC(e, t, {
  line: n = t.line,
  ticks: r,
  tickSize: i,
  tickSpacing: s,
  tickPadding: o,
  tickFormat: a,
  tickRotate: c,
  fontVariant: u,
  ariaLabel: l,
  ariaDescription: h,
  label: f = 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: h,
    label: f,
    labelAnchor: d,
    labelArrow: p,
    labelOffset: y
  };
}
function XC(e) {
  const { anchor: t, line: n } = e;
  return { anchor: t, facetAnchor: t + "-empty", stroke: n === !0 ? void 0 : n };
}
function GC(e, {
  stroke: t = zc(e) ? e : void 0,
  ticks: n = HC(e) ? e : void 0,
  tickSpacing: r,
  ariaLabel: i,
  ariaDescription: s
}) {
  return {
    stroke: t,
    ticks: n,
    tickSpacing: r,
    ariaLabel: i,
    ariaDescription: s
  };
}
function HC(e) {
  switch (typeof e) {
    case "number":
      return !0;
    case "string":
      return !zc(e);
  }
  return dr(e) || typeof (e == null ? void 0 : e.range) == "function";
}
function Iu(e, t) {
  const n = `${t}-axis `;
  return e.some((r) => {
    var i;
    return (i = r.ariaLabel) == null ? void 0 : i.startsWith(n);
  });
}
function ow(e, t) {
  for (const n of t)
    for (const r in n.channels)
      if (n.channels[r].scale === e)
        return !0;
  return !1;
}
function ZC(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 KC({ fx: e, fy: t }, n) {
  const { marginTop: r, marginRight: i, marginBottom: s, marginLeft: o, width: a, height: c } = ym(n), u = e && aw(e), l = t && aw(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 aw(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 JC = /* @__PURE__ */ new Map([
  ["basis", fk],
  ["basis-closed", hk],
  ["basis-open", dk],
  ["bundle", pk],
  ["bump-x", tk],
  ["bump-y", ek],
  ["cardinal", yk],
  ["cardinal-closed", mk],
  ["cardinal-open", gk],
  ["catmull-rom", bk],
  ["catmull-rom-closed", wk],
  ["catmull-rom-open", vk],
  ["linear", Rc],
  ["linear-closed", _k],
  ["monotone-x", xk],
  ["monotone-y", Sk],
  ["natural", Mk],
  ["step", $k],
  ["step-after", Ik],
  ["step-before", Ak]
]);
function Fm(e = Rc, t) {
  if (typeof e == "function")
    return e;
  const n = JC.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 VM(e = jo, t) {
  return typeof e != "function" && `${e}`.toLowerCase() === "auto" ? jo : Fm(e, t);
}
function jo(e) {
  return Rc(e);
}
function fi(e = { y: "count" }, t = {}) {
  [e, t] = Cm(e, t);
  const { x: n, y: r } = t;
  return Rm(Sf(n, t, ot), null, null, r, e, Yc(t));
}
function hi(e = { x: "count" }, t = {}) {
  [e, t] = Cm(e, t);
  const { x: n, y: r } = t;
  return Rm(null, Sf(r, t, ot), n, null, e, Wc(t));
}
function Zi(e = { fill: "count" }, t = {}) {
  [e, t] = Cm(e, t);
  const { x: n, y: r } = QC(t);
  return Rm(n, r, null, null, e, Yc(Wc(t)));
}
function YM(e, t, n = {}) {
  return (n == null ? void 0 : n.interval) == null ? n : e({ [t]: (n == null ? void 0 : n.reduce) === void 0 ? lm : n.reduce, filter: null }, n);
}
function km(e = {}) {
  return YM(fi, "y", Qo(e, "x"));
}
function Bm(e = {}) {
  return YM(hi, "x", Qo(e, "y"));
}
function Rm(e, t, n, r, {
  data: i = um,
  // TODO avoid materializing when unused?
  filter: s = wf,
  // return only non-empty bins by default
  sort: o,
  reverse: a,
  ...c
  // output channel definitions
} = {}, u = {}) {
  e = cw(e), t = cw(t), c = tP(c, u), i = HM(i, ot), o = o == null ? void 0 : XM("sort", o, u), s = s == null ? void 0 : GM("filter", s, u), n != null && pi(c, "x", "x1", "x2") && (n = null), r != null && pi(c, "y", "y1", "y2") && (r = null);
  const [l, h] = Be(e), [f, d] = Be(e), [p, y] = Be(t), [g, m] = Be(t), [b, w] = n != null ? [n, "x"] : r != null ? [r, "y"] : [], [v, _] = Be(b), {
    x,
    y: $,
    z: T,
    fill: D,
    stroke: M,
    x1: A,
    x2: L,
    // consumed if x is an output
    y1: k,
    y2: S,
    // consumed if y is an output
    domain: I,
    cumulative: E,
    thresholds: N,
    interval: O,
    ...R
  } = u, [C, j] = Be(T), [z] = qe(D), [X] = qe(M), [H, J] = Be(z), [K, W] = Be(X);
  return {
    ..."z" in u && { z: C || T },
    ..."fill" in u && { fill: H || D },
    ..."stroke" in u && { stroke: K || M },
    ...pr(R, (Y, U, V) => {
      const G = bf(Mt(Y, b), V == null ? void 0 : V[w]), P = Mt(Y, T), Q = Mt(Y, z), at = Mt(Y, X), Ot = cm(c, { z: P, fill: Q, stroke: at }), xt = [], Z = [], Ct = G && _([]), zn = P && j([]), Xe = Q && J([]), Qc = at && W([]), tu = e && h([]), Wh = e && d([]), bg = t && y([]), L$ = t && m([]), D$ = iP(e == null ? void 0 : e(Y), t == null ? void 0 : t(Y));
      let O$ = 0;
      for (const Ls of c)
        Ls.initialize(Y);
      o && o.initialize(Y), s && s.initialize(Y);
      for (const Ls of U) {
        const wg = [];
        for (const ua of c)
          ua.scope("facet", Ls);
        o && o.scope("facet", Ls), s && s.scope("facet", Ls);
        for (const [ua, F$] of uo(Ls, Ot))
          for (const [k$, B$] of uo(F$, G))
            for (const [Ui, ji] of D$(B$))
              if (!(s && !s.reduce(Ui, ji))) {
                wg.push(O$++), Z.push(i.reduceIndex(Ui, Y, ji)), G && Ct.push(k$), P && zn.push(Ot === P ? ua : P[Ui[0]]), Q && Xe.push(Ot === Q ? ua : Q[Ui[0]]), at && Qc.push(Ot === at ? ua : at[Ui[0]]), tu && (tu.push(ji.x1), Wh.push(ji.x2)), bg && (bg.push(ji.y1), L$.push(ji.y2));
                for (const R$ of c)
                  R$.reduce(Ui, ji);
                o && o.reduce(Ui);
              }
        xt.push(wg);
      }
      return a6(xt, o, a), { data: Z, facets: xt };
    }),
    ...!pi(c, "x") && (l ? { x1: l, x2: f, x: gf(l, f) } : { x, x1: A, x2: L }),
    ...!pi(c, "y") && (p ? { y1: p, y2: g, y: gf(p, g) } : { y: $, y1: k, y2: S }),
    ...v && { [w]: v },
    ...Object.fromEntries(c.map(({ name: Y, output: U }) => [Y, U]))
  };
}
function Cm({ cumulative: e, domain: t, thresholds: n, interval: r, ...i }, s) {
  return [i, { cumulative: e, domain: t, thresholds: n, interval: r, ...s }];
}
function Sf(e, { cumulative: t, domain: n, thresholds: r, interval: i }, s) {
  return e = { ...Pc(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 = WM(e.thresholds, e.interval), e;
}
function QC(e) {
  let { x: t, y: n } = e;
  return t = Sf(t, e), n = Sf(n, e), [t.value, n.value] = Pn(t.value, n.value), { x: t, y: n };
}
function cw(e) {
  if (e == null)
    return;
  const { value: t, cumulative: n, domain: r = Se, thresholds: i } = e, s = (o) => {
    let a = Mt(o, t), c;
    if (Ve(a) || nP(i)) {
      a = Xt(a, GS, Float64Array);
      let [l, h] = typeof r == "function" ? r(a) : r, f = typeof i == "function" && !Da(i) ? i(a, l, h) : i;
      typeof f == "number" && (f = Zx(l, h, f)), Da(f) && (r === Se && (l = f.floor(l), h = f.offset(f.floor(h))), f = f.range(l, f.offset(h))), c = f;
    } else {
      a = Pe(a);
      let [l, h] = typeof r == "function" ? r(a) : r, f = typeof i == "function" && !Da(i) ? i(a, l, h) : i;
      if (typeof f == "number")
        if (r === Se) {
          let d = Qa(l, h, f);
          if (isFinite(d))
            if (d > 0) {
              let p = Math.round(l / d), y = Math.round(h / d);
              p * d <= l || --p, y * d > h || ++y;
              let g = y - p + 1;
              f = new Float64Array(g);
              for (let m = 0; m < g; ++m)
                f[m] = (p + m) * d;
            } else if (d < 0) {
              d = -d;
              let p = Math.round(l * d), y = Math.round(h * d);
              p / d <= l || --p, y / d > h || ++y;
              let g = y - p + 1;
              f = new Float64Array(g);
              for (let m = 0; m < g; ++m)
                f[m] = (p + m) / d;
            } else
              f = [l];
          else
            f = [l];
        } else
          f = Si(l, h, f);
      else
        Da(f) && (r === Se && (l = f.floor(l), h = f.offset(f.floor(h))), f = f.range(l, f.offset(h)));
      c = f;
    }
    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 ? oP : n > 0 ? sP : Pm)(u, c, a), u;
  };
  return s.label = ei(t), s;
}
function WM(e, t, n = uw) {
  if (e === void 0)
    return t === void 0 ? n : Jo(t);
  if (typeof e == "string") {
    switch (e.toLowerCase()) {
      case "freedman-diaconis":
        return jT;
      case "scott":
        return Qv;
      case "sturges":
        return ly;
      case "auto":
        return uw;
    }
    return WS(e);
  }
  return e;
}
function tP(e, t) {
  return sm(e, t, XM);
}
function XM(e, t, n) {
  return om(e, t, n, GM);
}
function GM(e, t, n) {
  return am(e, t, n, HM);
}
function HM(e, t) {
  return Ah(e, t, eP);
}
function eP(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return aP;
    case "x1":
      return uP;
    case "x2":
      return lP;
    case "y":
      return cP;
    case "y1":
      return fP;
    case "y2":
      return hP;
  }
  throw new Error(`invalid bin reduce: ${e}`);
}
function uw(e, t, n) {
  return Math.min(200, Qv(e, t, n));
}
function nP(e) {
  return rP(e) || dr(e) && Ve(e);
}
function rP(e) {
  return Da(e) && typeof e == "function" && e() instanceof Date;
}
function Da(e) {
  return typeof (e == null ? void 0 : e.range) == "function";
}
function iP(e, t) {
  return e && t ? function* (n) {
    const r = e.bin(n);
    for (const [i, [s, o]] of e.entries()) {
      const a = t.bin(r[i]);
      for (const [c, [u, l]] of t.entries())
        yield [a[c], { x1: s, y1: u, x2: o, y2: l }];
    }
  } : e ? function* (n) {
    const r = e.bin(n);
    for (const [i, [s, o]] of e.entries())
      yield [r[i], { x1: s, x2: o }];
  } : function* (n) {
    const r = t.bin(n);
    for (const [i, [s, o]] of t.entries())
      yield [r[i], { y1: s, y2: o }];
  };
}
function Pm(e, t, n) {
  return t = Pe(t), (r) => {
    var s;
    const i = e.map(() => []);
    for (const o of r)
      (s = i[zf(t, n[o]) - 1]) == null || s.push(o);
    return i;
  };
}
function sP(e, t, n) {
  const r = Pm(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 oP(e, t, n) {
  const r = Pm(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 ZM(e, t) {
  const n = (+e + +t) / 2;
  return e instanceof Date ? new Date(n) : n;
}
const aP = {
  reduceIndex(e, t, { x1: n, x2: r }) {
    return ZM(n, r);
  }
}, cP = {
  reduceIndex(e, t, { y1: n, y2: r }) {
    return ZM(n, r);
  }
}, uP = {
  reduceIndex(e, t, { x1: n }) {
    return n;
  }
}, lP = {
  reduceIndex(e, t, { x2: n }) {
    return n;
  }
}, fP = {
  reduceIndex(e, t, { y1: n }) {
    return n;
  }
}, hP = {
  reduceIndex(e, t, { y2: n }) {
    return n;
  }
};
function zm(e = {}) {
  return HS(e) ? e : { ...e, x: ot };
}
function Um(e = {}) {
  return ZS(e) ? e : { ...e, y: ot };
}
function KM(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ra(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: gf(c, u) };
}
function dP(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ra(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 pP(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ra(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 JM(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ra(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: gf(c, u) };
}
function yP(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ra(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 mP(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ra(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 jm({ x: e, x1: t, x2: n, ...r } = {}) {
  return r = Qo(r, "y"), t === void 0 && n === void 0 ? KM({ x: e, ...r }) : ([t, n] = KS(e, t, n), { ...r, x1: t, x2: n });
}
function qm({ y: e, y1: t, y2: n, ...r } = {}) {
  return r = Qo(r, "x"), t === void 0 && n === void 0 ? JM({ y: e, ...r }) : ([t, n] = KS(e, t, n), { ...r, y1: t, y2: n });
}
function ra(e) {
  const { offset: t, order: n, reverse: r, ...i } = e;
  return [{ offset: t, order: n, reverse: r }, i];
}
const gP = { length: !0 };
function ia(e, t = Yy, n, r, { offset: i, order: s, reverse: o }, a) {
  const c = Bi(a), [u, l] = Be(e), [h, f] = Je(t), [d, p] = Je(t);
  return h.hint = d.hint = gP, i = bP(i), s = _P(s, i, r), [
    pr(a, (y, g, m) => {
      const b = e == null ? void 0 : l(bf(Mt(y, e), m == null ? void 0 : m[n])), w = Mt(y, t, Float64Array), v = Mt(y, c), _ = s && s(y, b, w, v), x = y.length, $ = f(new Float64Array(x)), T = p(new Float64Array(x)), D = [];
      for (const M of g) {
        const A = b ? Array.from(Jr(M, (L) => b[L]).values()) : [M];
        _ && IP(A, _);
        for (const L of A) {
          let k = 0, S = 0;
          o && L.reverse();
          for (const I of L) {
            const E = w[I];
            E < 0 ? k = T[I] = ($[I] = k) + E : E > 0 ? S = T[I] = ($[I] = S) + E : T[I] = $[I] = S;
          }
        }
        D.push(A);
      }
      return i && i(D, $, T, v), { data: y, facets: g };
    }),
    u,
    h,
    d
  ];
}
function bP(e) {
  if (e != null) {
    if (typeof e == "function")
      return e;
    switch (`${e}`.toLowerCase()) {
      case "expand":
      case "normalize":
        return wP;
      case "center":
      case "silhouette":
        return vP;
      case "wiggle":
        return t4;
    }
    throw new Error(`unknown offset: ${e}`);
  }
}
function QM(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 wP(e, t, n) {
  for (const r of e)
    for (const i of r) {
      const [s, o] = QM(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 vP(e, t, n) {
  for (const r of e) {
    for (const i of r) {
      const [s, o] = QM(i, n);
      for (const a of i) {
        const c = (o + s) / 2;
        t[a] -= c, n[a] -= c;
      }
    }
    e4(r, t, n);
  }
  n4(e, t, n);
}
function t4(e, t, n, r) {
  for (const i of e) {
    const s = new gs();
    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;
      }), h = [0, ...OT(l)];
      for (const d of a)
        t[d] += o, n[d] += o;
      const f = ar(u);
      f && (o -= ar(u, (d, p) => (l[p] / 2 + h[p]) * d) / f);
    }
    e4(i, t, n);
  }
  n4(e, t, n);
}
function e4(e, t, n) {
  const r = pe(e, (i) => pe(i, (s) => t[s]));
  for (const i of e)
    for (const s of i)
      t[s] -= r, n[s] -= r;
}
function n4(e, t, n) {
  const r = e.length;
  if (r === 1)
    return;
  const i = e.map((a) => a.flat()), s = i.map((a) => (pe(a, (c) => t[c]) + te(a, (c) => n[c])) / 2), o = pe(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 _P(e, t, n) {
  if (e === void 0 && t === t4)
    return lw;
  if (e != null) {
    if (typeof e == "string") {
      switch (e.toLowerCase()) {
        case "value":
        case n:
          return xP;
        case "z":
          return SP;
        case "sum":
          return MP;
        case "appearance":
          return $P;
        case "inside-out":
          return lw;
      }
      return fw(XS(e));
    }
    if (typeof e == "function")
      return fw(e);
    if (Array.isArray(e))
      return AP(e);
    throw new Error(`invalid order: ${e}`);
  }
}
function xP(e, t, n) {
  return n;
}
function SP(e, t, n, r) {
  return r;
}
function MP(e, t, n, r) {
  return Rh(
    r,
    uy(
      ti(e),
      (i) => ar(i, (s) => n[s]),
      (i) => r[i]
    )
  );
}
function $P(e, t, n, r) {
  return Rh(
    r,
    uy(
      ti(e),
      (i) => t[fy(i, (s) => n[s])],
      (i) => r[i]
    )
  );
}
function lw(e, t, n, r) {
  const i = ti(e), s = uy(
    i,
    (l) => t[fy(l, (h) => n[h])],
    (l) => r[l]
  ), o = so(
    i,
    (l) => ar(l, (h) => n[h]),
    (l) => r[l]
  ), a = [], c = [];
  let u = 0;
  for (const l of s)
    u < 0 ? (u += o.get(l), a.push(l)) : (u -= o.get(l), c.push(l));
  return Rh(r, c.reverse().concat(a));
}
function fw(e) {
  return (t) => Mt(t, e);
}
function AP(e) {
  return (t, n, r, i) => Rh(i, e);
}
function Rh(e, t) {
  if (!e)
    throw new Error("missing channel: z");
  return t = new gs(t.map((n, r) => [n, r])), e.map((n) => t.get(n));
}
function IP(e, t) {
  for (const n of e)
    n.sort((r, i) => Gr(t[r], t[i]));
}
const TP = {
  ariaLabel: "area",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class Ch extends Vt {
  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: Bi(n), optional: !0 }
      },
      n,
      TP
    ), this.z = a, this.curve = Fm(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 Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, n, 0, 0).call(
      (l) => l.selectAll().data(B6(t, [o, a, c, u], this, r)).enter().append("path").call(Ht, this).call(vf, this, r).attr(
        "d",
        Py().curve(this.curve).defined((h) => h >= 0).x0((h) => o[h]).y0((h) => a[h]).x1((h) => c[h]).y1((h) => u[h])
      )
    ).node();
  }
}
function EP(e, t) {
  return t === void 0 ? gc(e, { x: Cc, y: fc }) : new Ch(e, t);
}
function Mf(e, t) {
  const { y: n = We, ...r } = Bm(t);
  return new Ch(e, jm(zm({ ...r, y1: n, y2: void 0 })));
}
function gc(e, t) {
  const { x: n = We, ...r } = km(t);
  return new Ch(e, qm(Um({ ...r, x1: n, x2: void 0 })));
}
const NP = {
  ariaLabel: "link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class r4 extends Vt {
  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,
      NP
    ), this.curve = VM(a, c), ta(this, n);
  }
  project(t, n, r) {
    this.curve !== jo && 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 Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, n).call(
      (h) => h.selectAll().data(t).enter().append("path").call(Ht, this).attr(
        "d",
        l === jo && s.projection ? LP(s.projection, o, a, c, u) : (f) => {
          const d = Dr(), p = l(d);
          return p.lineStart(), p.point(o[f], a[f]), p.point(c[f], u[f]), p.lineEnd(), d;
        }
      ).call(le, this, r).call(Vc, this, r, s)
    ).node();
  }
}
function LP(e, t, n, r, i) {
  const s = Fi(e);
  return t = Pe(t), n = Pe(n), r = Pe(r), i = Pe(i), (o) => s({
    type: "LineString",
    coordinates: [
      [t[o], n[o]],
      [r[o], i[o]]
    ]
  });
}
function i4(e, { x: t, x1: n, x2: r, y: i, y1: s, y2: o, ...a } = {}) {
  return [n, r] = $f(t, n, r), [s, o] = $f(i, s, o), new r4(e, { ...a, x1: n, x2: r, y1: s, y2: o });
}
function $f(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 DP = {
  ariaLabel: "arrow",
  fill: "none",
  stroke: "currentColor",
  strokeLinecap: "round",
  strokeMiterlimit: 1,
  strokeWidth: 1.5
};
class s4 extends Vt {
  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: h = l,
      insetEnd: f = l
    } = 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,
      DP
    ), this.bend = a === !0 ? 22.5 : Math.max(-90, Math.min(90, a)), this.headAngle = +c, this.headLength = +u, this.insetStart = +h, this.insetEnd = +f;
  }
  render(t, n, r, i, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a, SW: l } = r, { strokeWidth: h, bend: f, headAngle: d, headLength: p, insetStart: y, insetEnd: g } = this, m = l ? (_) => l[_] : nn(h === void 0 ? 1 : h), b = f * xf, w = d * xf / 2, v = p / 1.5;
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, n).call(
      (_) => _.selectAll().data(t).enter().append("path").call(Ht, this).attr("d", (x) => {
        let $ = o[x], T = a[x], D = c[x], M = u[x];
        const A = Math.hypot(D - $, M - T);
        if (A <= y + g)
          return null;
        let L = Math.atan2(M - T, D - $);
        const k = Math.min(v * m(x), A / 3), S = Math.hypot(A / Math.tan(b), A) / 2;
        if (y || g)
          if (S < 1e5) {
            const z = Math.sign(b), [X, H] = OP([$, T], [D, M], S, z);
            if (y && ([$, T] = hw([X, H, S], [$, T, y], -z * Math.sign(y))), g) {
              const [J, K] = hw([X, H, S], [D, M, g], z * Math.sign(g));
              L += Math.atan2(K - H, J - X) - Math.atan2(M - H, D - X), D = J, M = K;
            }
          } else {
            const z = D - $, X = M - T, H = Math.hypot(z, X);
            y && ($ += z / H * y, T += X / H * y), g && (D -= z / H * g, M -= X / H * g);
          }
        const I = L + b, E = I + w, N = I - w, O = D - k * Math.cos(E), R = M - k * Math.sin(E), C = D - k * Math.cos(N), j = M - k * Math.sin(N);
        return `M${$},${T}${S < 1e5 ? `A${S},${S} 0,0,${b > 0 ? 1 : 0} ` : "L"}${D},${M}M${O},${R}L${D},${M}L${C},${j}`;
      }).call(le, this, r)
    ).node();
  }
}
function OP([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 hw([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), h = o * Math.sqrt(n * n - l * l);
  return [e + (a * l + c * h) / u, t + (c * l - a * h) / u];
}
function FP(e, { x: t, x1: n, x2: r, y: i, y1: s, y2: o, ...a } = {}) {
  return [n, r] = $f(t, n, r), [s, o] = $f(i, s, o), new s4(e, { ...a, x1: n, x2: r, y1: s, y2: o });
}
class Vm extends Vt {
  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: h } = r;
    this.insetTop = At(o), this.insetRight = At(a), this.insetBottom = At(c), this.insetLeft = At(u), this.rx = ee(l, "auto"), this.ry = ee(h, "auto");
  }
  render(t, n, r, i, s) {
    const { rx: o, ry: a } = this;
    return Dt("svg:g", s).call(Zt, this, i, s).call(this._transform, this, n).call(
      (c) => c.selectAll().data(t).enter().append("rect").call(Ht, 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(nt, "rx", o).call(nt, "ry", a).call(le, 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 o4 = {
  ariaLabel: "bar"
};
class a4 extends Vm {
  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,
      o4
    );
  }
  _transform(t, n, { x: r }) {
    t.call(qt, n, { x: r }, 0, 0);
  }
  _x({ x: t }, { x1: n, x2: r }, { marginLeft: i }) {
    const { insetLeft: s } = this;
    return yn(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 yn(t) ? o - i - s - a - c : (u) => Math.max(0, Math.abs(r[u] - n[u]) - a - c);
  }
}
class c4 extends Vm {
  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,
      o4
    );
  }
  _transform(t, n, { y: r }) {
    t.call(qt, n, { y: r }, 0, 0);
  }
  _y({ y: t }, { y1: n, y2: r }, { marginTop: i }) {
    const { insetTop: s } = this;
    return yn(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 yn(t) ? o - i - s - a - c : (u) => Math.max(0, Math.abs(r[u] - n[u]) - a - c);
  }
}
function fo(e, t = {}) {
  return bh(t) || (t = { ...t, y: We, x2: ot }), new a4(e, jm(Z6(zm(t))));
}
function ho(e, t = {}) {
  return bh(t) || (t = { ...t, x: We, y2: ot }), new c4(e, qm(K6(Um(t))));
}
const kP = {
  ariaLabel: "cell"
};
class Ph extends Vm {
  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,
      kP
    );
  }
  _transform(t, n) {
    t.call(qt, n, {}, 0, 0);
  }
}
function Ym(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Pn(t, n), new Ph(e, { ...r, x: t, y: n });
}
function BP(e, { x: t = We, fill: n, stroke: r, ...i } = {}) {
  return n === void 0 && qe(r)[0] === void 0 && (n = ot), new Ph(e, { ...i, x: t, fill: n, stroke: r });
}
function RP(e, { y: t = We, fill: n, stroke: r, ...i } = {}) {
  return n === void 0 && qe(r)[0] === void 0 && (n = ot), new Ph(e, { ...i, y: t, fill: n, stroke: r });
}
const CP = {
  ariaLabel: "dot",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5
};
function Wm(e) {
  return e.sort === void 0 && e.reverse === void 0 ? s6({ channel: "-r" }, e) : e;
}
class zh extends Vt {
  constructor(t, n = {}) {
    const { x: r, y: i, r: s, rotate: o, symbol: a = lc, frameAnchor: c } = n, [u, l] = ie(o, 0), [h, f] = nB(a), [d, p] = ie(s, h == 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: zr, optional: !0 },
        rotate: { value: u, optional: !0 },
        symbol: { value: h, scale: "auto", optional: !0 }
      },
      Wm(n),
      CP
    ), this.r = p, this.rotate = l, this.symbol = f, this.frameAnchor = Uc(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,
        stroke: b ? b.value === g.value ? "color" : "currentColor" : this.stroke
      };
    }
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, r: l, rotate: h, symbol: f } = r, { r: d, rotate: p, symbol: y } = this, [g, m] = yr(this, i), b = y === lc, w = l ? void 0 : d * d * Math.PI;
    return mh(d) && (t = []), Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, { x: c && o, y: u && a }).call(
      (v) => v.selectAll().data(t).enter().append(b ? "circle" : "path").call(Ht, this).call(
        b ? (_) => {
          _.attr("cx", c ? (x) => c[x] : g).attr("cy", u ? (x) => u[x] : m).attr("r", l ? (x) => l[x] : d);
        } : (_) => {
          _.attr(
            "transform",
            Oh`translate(${c ? (x) => c[x] : g},${u ? (x) => u[x] : m})${h ? (x) => ` rotate(${h[x]})` : p ? ` rotate(${p})` : ""}`
          ).attr(
            "d",
            l && f ? (x) => {
              const $ = Dr();
              return f[x].draw($, l[x] * l[x] * Math.PI), $;
            } : l ? (x) => {
              const $ = Dr();
              return y.draw($, l[x] * l[x] * Math.PI), $;
            } : f ? (x) => {
              const $ = Dr();
              return f[x].draw($, w), $;
            } : (() => {
              const x = Dr();
              return y.draw(x, w), x;
            })()
          );
        }
      ).call(le, this, r)
    ).node();
  }
}
function Pi(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Pn(t, n)), new zh(e, { ...r, x: t, y: n });
}
function PP(e, { x: t = ot, ...n } = {}) {
  return new zh(e, Q6({ ...n, x: t }));
}
function zP(e, { y: t = ot, ...n } = {}) {
  return new zh(e, J6({ ...n, y: t }));
}
function UP(e, t) {
  return Pi(e, { ...t, symbol: "circle" });
}
function jP(e, t) {
  return Pi(e, { ...t, symbol: "hexagon" });
}
const qP = {
  ariaLabel: "line",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class Uh extends Vt {
  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: Bi(n), optional: !0 }
      },
      n,
      qP
    ), this.z = s, this.curve = VM(o, a), ta(this, n);
  }
  filter(t) {
    return t;
  }
  project(t, n, r) {
    this.curve !== jo && super.project(t, n, r);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = r, { curve: c } = this;
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, n).call(
      (u) => u.selectAll().data(B6(t, [o, a], this, r)).enter().append("path").call(Ht, this).call(vf, this, r).call(rC, this, r, s).attr(
        "d",
        c === jo && s.projection ? VP(s.projection, o, a) : bS().curve(c).defined((l) => l >= 0).x((l) => o[l]).y((l) => a[l])
      )
    ).node();
  }
}
function VP(e, t, n) {
  const r = Fi(e);
  return t = Pe(t), n = Pe(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 Xm(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Pn(t, n), new Uh(e, { ...r, x: t, y: n });
}
function Af(e, { x: t = ot, y: n = We, ...r } = {}) {
  return new Uh(e, Bm({ ...r, x: t, y: n }));
}
function If(e, { x: t = We, y: n = ot, ...r } = {}) {
  return new Uh(e, km({ ...r, x: t, y: n }));
}
const YP = {
  ariaLabel: "rect"
};
class jh extends Vt {
  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: h = a,
      rx: f,
      ry: d
    } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x", optional: !0 },
        y1: { value: i, scale: "y", optional: !0 },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      YP
    ), this.insetTop = At(c), this.insetRight = At(u), this.insetBottom = At(l), this.insetLeft = At(h), this.rx = ee(f, "auto"), this.ry = ee(d, "auto");
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x1: c, y1: u, x2: l, y2: h } = r, { marginTop: f, marginRight: d, marginBottom: p, marginLeft: y, width: g, height: m } = i, { projection: b } = s, { insetTop: w, insetRight: v, insetBottom: _, insetLeft: x, rx: $, ry: T } = this;
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, { x: c && l && o, y: u && h && a }, 0, 0).call(
      (D) => D.selectAll().data(t).enter().append("rect").call(Ht, this).attr(
        "x",
        c && l && (b || !yn(o)) ? (M) => Math.min(c[M], l[M]) + x : y + x
      ).attr(
        "y",
        u && h && (b || !yn(a)) ? (M) => Math.min(u[M], h[M]) + w : f + w
      ).attr(
        "width",
        c && l && (b || !yn(o)) ? (M) => Math.max(0, Math.abs(l[M] - c[M]) - x - v) : g - d - y - v - x
      ).attr(
        "height",
        u && h && (b || !yn(a)) ? (M) => Math.max(0, Math.abs(u[M] - h[M]) - w - _) : m - f - p - w - _
      ).call(nt, "rx", $).call(nt, "ry", T).call(le, this, r)
    ).node();
  }
}
function Gm(e, t) {
  return new jh(e, G6(H6(t)));
}
function za(e, t = {}) {
  return bh(t) || (t = { ...t, y: We, x2: ot, interval: 1 }), new jh(e, jm(H6(zm(t))));
}
function Ua(e, t = {}) {
  return bh(t) || (t = { ...t, x: We, y2: ot, interval: 1 }), new jh(e, qm(G6(Um(t))));
}
function u4(e, t) {
  t = XP(t);
  const { x: n, y: r, color: i, size: s } = t, o = Tu(e, n), a = Tu(e, r), c = Tu(e, i), u = Tu(e, s);
  let {
    fx: l,
    fy: h,
    x: { value: f, reduce: d, zero: p, ...y },
    y: { value: g, reduce: m, zero: b, ...w },
    color: { value: v, color: _, reduce: x },
    size: { value: $, reduce: T },
    // TODO constant radius?
    mark: D
  } = t;
  if (d === void 0 && (d = m == null && f == null && $ == null && g != null ? "count" : null), m === void 0 && (m = d == null && g == null && $ == null && f != null ? "count" : null), T === void 0 && $ == null && x == null && d == null && m == null && (f == null || Ie(o)) && (g == null || Ie(a)) && (T = "count"), p === void 0 && (p = Eu(d) ? !0 : void 0), b === void 0 && (b = Eu(m) ? !0 : void 0), f == 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 && f == null)
    throw new Error("reducing y requires x");
  D === void 0 && (D = $ != null || T != null ? "dot" : Eu(d) || Eu(m) || x != null ? "bar" : f != null && g != null ? Ie(o) || Ie(a) || d == null && m == null && !_a(o) && !_a(a) ? "dot" : "line" : f != null || g != null ? "rule" : null);
  let M, A, L;
  switch (D) {
    case "dot":
      L = Pi, A = "stroke";
      break;
    case "line":
      L = o && a || d != null || m != null ? b || m != null || o && _a(o) ? If : p || d != null || a && _a(a) ? Af : Xm : o ? Af : If, A = "stroke", dw(c) && (M = null);
      break;
    case "area":
      L = !(b || m != null) && (p || d != null || a && _a(a)) ? Mf : gc, A = "fill", dw(c) && (M = null);
      break;
    case "rule":
      L = o ? Ii : Ti, A = "stroke";
      break;
    case "bar":
      L = b ? js(d, o) ? ho : Ua : p ? js(m, a) ? fo : za : js(d, o) && js(m, a) ? Ym : js(d, o) ? ho : js(m, a) ? fo : d != null ? za : m != null ? Ua : Gm, A = "fill";
      break;
    default:
      throw new Error(`invalid mark: ${D}`);
  }
  let k = {
    fx: l,
    fy: h,
    x: o ?? void 0,
    // treat null x as undefined for implicit stack
    y: a ?? void 0,
    // treat null y as undefined for implicit stack
    [A]: c ?? _,
    z: M,
    r: u ?? void 0,
    // treat null size as undefined for default constant radius
    tip: !0
  }, S, I = { [A]: x ?? 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) ? dc : fi) : d != null ? (I.x = d, S = Ie(a) ? pc : hi) : (x != null || T != null) && (o && a ? S = Ie(o) && Ie(a) ? im : Ie(o) ? hi : Ie(a) ? fi : Zi : o ? S = Ie(o) ? dc : fi : a && (S = Ie(a) ? pc : hi)), (S === Zi || S === fi) && (k.x = { value: o, ...y }), (S === Zi || S === hi) && (k.y = { value: a, ...w }), p === void 0 && (p = o && !(S === Zi || S === fi) && (L === fo || L === Mf || L === za || L === Ti)), b === void 0 && (b = a && !(S === Zi || S === hi) && (L === ho || L === gc || L === Ua || L === Ii)), {
    fx: l ?? null,
    fy: h ?? null,
    x: {
      value: f ?? null,
      reduce: d ?? null,
      zero: !!p,
      ...y
    },
    y: {
      value: g ?? null,
      reduce: m ?? null,
      zero: !!b,
      ...w
    },
    color: {
      value: v ?? null,
      reduce: x ?? null,
      ..._ !== void 0 && { color: _ }
    },
    size: {
      value: $ ?? null,
      reduce: T ?? null
    },
    mark: D,
    markImpl: pw[L],
    markOptions: k,
    transformImpl: pw[S],
    transformOptions: I,
    colorMode: A
  };
}
function WP(e, t) {
  const n = u4(e, t), {
    fx: r,
    fy: i,
    x: { zero: s },
    y: { zero: o },
    markOptions: a,
    transformOptions: c,
    colorMode: u
  } = n, l = p0[n.markImpl], h = p0[n.transformImpl], f = r != null || i != null ? Lm({ strokeOpacity: 0.1 }) : null, d = [s ? Ii([0]) : null, o ? Ti([0]) : null], p = l(e, h ? h(c, a) : a);
  return u === "stroke" ? Hr(f, d, p) : Hr(f, p, d);
}
function _a(e) {
  let t, n;
  for (const r of e) {
    if (r == null)
      continue;
    if (t === void 0) {
      t = r;
      continue;
    }
    const i = Math.sign(se(t, r));
    if (i) {
      if (n !== void 0 && i !== n)
        return !1;
      t = r, n = i;
    }
  }
  return !0;
}
function XP({ x: e, y: t, color: n, size: r, fx: i, fy: s, mark: o } = {}) {
  return Vn(e) || (e = Us(e)), Vn(t) || (t = Us(t)), Vn(n) || (n = zc(n) ? { color: n } : Us(n)), Vn(r) || (r = Us(r)), Vn(i) && ({ value: i } = Us(i)), Vn(s) && ({ value: s } = Us(s)), o != null && (o = `${o}`.toLowerCase()), { x: e, y: t, color: n, size: r, fx: i, fy: s, mark: o };
}
function Tu(e, t) {
  const n = Mt(e, t.value);
  return n && (n.label = ei(t.value)), n;
}
function Us(e) {
  return HP(e) ? { reduce: e } : { value: e };
}
function Eu(e) {
  return /^(?:distinct|count|sum|proportion)$/i.test(e);
}
function GP(e) {
  return /^(?:first|last|mode)$/i.test(e);
}
function js(e, t) {
  return e != null && !GP(e) || !t ? !1 : Ie(t);
}
function HP(e) {
  if (e == null)
    return !1;
  if (typeof e.reduceIndex == "function" || typeof e.reduce == "function" && hr(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 dw(e) {
  return e ? new qf(e).size > e.length >> 1 : !1;
}
const p0 = {
  dot: Pi,
  line: Xm,
  lineX: Af,
  lineY: If,
  areaX: Mf,
  areaY: gc,
  ruleX: Ii,
  ruleY: Ti,
  barX: fo,
  barY: ho,
  rect: Gm,
  rectX: za,
  rectY: Ua,
  cell: Ym,
  bin: Zi,
  binX: fi,
  binY: hi,
  group: im,
  groupX: dc,
  groupY: pc
}, pw = Object.fromEntries(Object.entries(p0).map(([e, t]) => [t, e]));
function Hm(e, t = {}) {
  let { x: n, x1: r, x2: i } = t;
  n === void 0 && r === void 0 && i === void 0 && (t = { ...t, x: n = ot });
  const s = {};
  return n != null && (s.x = e), r != null && (s.x1 = e), i != null && (s.x2 = e), Xc(s, t);
}
function Zm(e, t = {}) {
  let { y: n, y1: r, y2: i } = t;
  n === void 0 && r === void 0 && i === void 0 && (t = { ...t, y: n = ot });
  const s = {};
  return n != null && (s.y = e), r != null && (s.y1 = e), i != null && (s.y2 = e), Xc(s, t);
}
function Xc(e = {}, t = {}) {
  const n = Bi(t), r = Object.entries(e).map(([i, s]) => {
    const o = JS(i, t);
    if (o == null)
      throw new Error(`missing channel: ${i}`);
    const [a, c] = Je(o);
    return { key: i, input: o, output: a, setOutput: c, map: ZP(s) };
  });
  return {
    ...pr(t, (i, s) => {
      const o = Mt(i, n), a = r.map(({ input: u }) => Mt(i, u)), c = r.map(({ setOutput: u }) => u(new Array(i.length)));
      for (const u of s)
        for (const l of o ? Jr(u, (h) => o[h]).values() : [u])
          r.forEach(({ map: h }, f) => h.mapIndex(l, a[f], c[f]));
      return { data: i, facets: s };
    }),
    ...Object.fromEntries(r.map(({ key: i, output: s }) => [i, s]))
  };
}
function ZP(e) {
  if (e == null)
    throw new Error("missing map");
  if (typeof e.mapIndex == "function")
    return e;
  if (typeof e.map == "function" && hr(e))
    return KP(e);
  if (typeof e == "function")
    return Gd(Gy(e));
  switch (`${e}`.toLowerCase()) {
    case "cumsum":
      return QP;
    case "rank":
      return Gd((t, n) => n_(t, (r) => n[r]));
    case "quantile":
      return Gd((t, n) => JP(t, (r) => n[r]));
  }
  throw new Error(`invalid map: ${e}`);
}
function KP(e) {
  return console.warn("deprecated map interface; implement mapIndex instead."), { mapIndex: e.map.bind(e) };
}
function JP(e, t) {
  const n = Uf(e, t) - 1;
  return n_(e, t).map((r) => r / n);
}
function Gd(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 QP = {
  mapIndex(e, t, n) {
    let r = 0;
    for (const i of e)
      n[i] = r += t[i];
  }
}, tz = {
  ariaLabel: "tick",
  fill: null,
  stroke: "currentColor"
};
class l4 extends Vt {
  constructor(t, n, r) {
    super(t, n, r, tz), ta(this, r);
  }
  render(t, n, r, i, s) {
    return Dt("svg:g", s).call(Zt, this, i, s).call(this._transform, this, n).call(
      (o) => o.selectAll().data(t).enter().append("line").call(Ht, 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(le, this, r).call(Vc, this, r, s)
    ).node();
  }
}
class f4 extends l4 {
  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 = At(o), this.insetBottom = At(a);
  }
  _transform(t, n, { x: r }) {
    t.call(qt, n, { x: r }, be, 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 h4 extends l4 {
  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 = At(o), this.insetLeft = At(a);
  }
  _transform(t, n, { y: r }) {
    t.call(qt, n, { y: r }, 0, be);
  }
  _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 d4(e, { x: t = ot, ...n } = {}) {
  return new f4(e, { ...n, x: t });
}
function p4(e, { y: t = ot, ...n } = {}) {
  return new h4(e, { ...n, y: t });
}
function ez(e, {
  x: t = ot,
  y: n = null,
  fill: r = "#ccc",
  fillOpacity: i,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...u
} = {}) {
  const l = n != null ? pc : rm;
  return Hr(
    Ti(e, l({ x1: Km, x2: Jm }, { x: t, y: n, stroke: s, strokeOpacity: o, ...u })),
    fo(e, l({ x1: "p25", x2: "p75" }, { x: t, y: n, fill: r, fillOpacity: i, ...u })),
    d4(e, l({ x: "p50" }, { x: t, y: n, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...u })),
    Pi(e, Xc({ x: y4 }, { x: t, y: n, z: n, stroke: s, strokeOpacity: o, ...u }))
  );
}
function nz(e, {
  y: t = ot,
  x: n = null,
  fill: r = "#ccc",
  fillOpacity: i,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...u
} = {}) {
  const l = n != null ? dc : rm;
  return Hr(
    Ii(e, l({ y1: Km, y2: Jm }, { x: n, y: t, stroke: s, strokeOpacity: o, ...u })),
    ho(e, l({ y1: "p25", y2: "p75" }, { x: n, y: t, fill: r, fillOpacity: i, ...u })),
    p4(e, l({ y: "p50" }, { x: n, y: t, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...u })),
    Pi(e, Xc({ y: y4 }, { x: n, y: t, z: n, stroke: s, strokeOpacity: o, ...u }))
  );
}
function y4(e) {
  const t = Km(e), n = Jm(e);
  return e.map((r) => r < t || r > n ? r : NaN);
}
function Km(e) {
  const t = m4(e) * 2.5 - g4(e) * 1.5;
  return pe(e, (n) => n >= t ? n : NaN);
}
function Jm(e) {
  const t = g4(e) * 2.5 - m4(e) * 1.5;
  return te(e, (n) => n <= t ? n : NaN);
}
function m4(e) {
  return Mi(e, 0.25);
}
function g4(e) {
  return Mi(e, 0.75);
}
const rz = {
  ariaLabel: "raster",
  stroke: null,
  pixelSize: 1
};
function qs(e, t) {
  const n = +e;
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
function yw(e, t) {
  const n = Math.floor(e);
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
class b4 extends Vt {
  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: h = a == null ? s : void 0,
      y2: f = c == null ? o : void 0,
      pixelSize: d = i.pixelSize,
      blur: p = 0,
      interpolate: y
    } = r;
    if (s != null && (s = yw(s, "width")), o != null && (o = yw(o, "height")), u != null && (u = qs(u, "x1")), l != null && (l = qs(l, "y1")), h != null && (h = qs(h, "x2")), f != null && (f = qs(f, "y2")), a == null && (u == null || h == null))
      throw new Error("missing x");
    if (c == null && (l == null || f == null))
      throw new Error("missing y");
    t != null && s != null && o != null && (a === void 0 && u != null && h != null && (a = uz(u, h, s)), c === void 0 && l != null && f != null && (c = lz(l, f, 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: h == null ? null : [h], scale: "x", optional: !0, filter: null },
        y2: { value: f == null ? null : [f], scale: "y", optional: !0, filter: null },
        ...n
      },
      r,
      i
    ), this.width = s, this.height = o, this.pixelSize = qs(d, "pixelSize"), this.blur = qs(p, "blur"), this.interpolate = a == null || c == null ? null : sz(y);
  }
}
class w4 extends b4 {
  constructor(t, n = {}) {
    const { imageRendering: r } = n;
    if (t == null) {
      const { fill: i, fillOpacity: s } = n;
      ie(s)[0] !== void 0 && (n = y0("fillOpacity", n)), qe(i)[0] !== void 0 && (n = y0("fill", n));
    }
    super(t, void 0, n, rz), this.imageRendering = ee(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, h, f, d] = _4(r, i, s), p = f - l, y = d - h, { 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: _ } = r, x = 0;
    if (this.interpolate) {
      const E = m / p, N = b / y, O = Xt(a, (C) => (C - l) * E, Float64Array), R = Xt(c, (C) => (C - h) * N, Float64Array);
      v && (v = this.interpolate(t, m, b, O, R, v)), _ && (_ = this.interpolate(t, m, b, O, R, _));
    } else
      this.data == null && t && (x = t.fi * w);
    const $ = u.createElement("canvas");
    $.width = m, $.height = b;
    const T = $.getContext("2d"), D = T.createImageData(m, b), M = D.data;
    let { r: A, g: L, b: k } = bn(this.fill) ?? { r: 0, g: 0, b: 0 }, S = (this.fillOpacity ?? 1) * 255;
    for (let E = 0; E < w; ++E) {
      const N = E << 2;
      if (v) {
        const O = o(v[E + x]);
        if (O == null) {
          M[N + 3] = 0;
          continue;
        }
        ({ r: A, g: L, b: k } = bn(O));
      }
      _ && (S = _[E + x] * 255), M[N + 0] = A, M[N + 1] = L, M[N + 2] = k, M[N + 3] = S;
    }
    return this.blur > 0 && $T(D, this.blur), T.putImageData(D, 0, 0), Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, n).call(
      (E) => E.append("image").attr("transform", `translate(${l},${h}) scale(${Math.sign(f - l)},${Math.sign(d - h)})`).attr("width", Math.abs(p)).attr("height", Math.abs(y)).attr("preserveAspectRatio", "none").call(nt, "image-rendering", this.imageRendering).call(Ht, this).attr("xlink:href", $.toDataURL())
    ).node();
  }
}
function v4(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 && Xk(t) && (r = Cc, i = fc, s === void 0 && (s = qk)), [t, { ...o, x: r, y: i, [e]: s }];
}
function iz() {
  const [e, t] = v4("fill", ...arguments);
  return new w4(
    e,
    e == null || t.fill !== void 0 || t.fillOpacity !== void 0 ? t : { ...t, fill: ot }
  );
}
function _4({ x1: e, y1: t, x2: n, y2: r }, i, { projection: s }) {
  const { width: o, height: a, marginTop: c, marginRight: u, marginBottom: l, marginLeft: h } = i;
  return [
    e && s == null ? e[0] : h,
    t && s == null ? t[0] : c,
    n && s == null ? n[0] : o - u,
    r && s == null ? r[0] : a - l
  ];
}
function x4({ 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), _4(fm(a, i), s, o);
}
function y0(e, t = {}) {
  const { [e]: n } = t;
  if (typeof n != "function")
    throw new Error(`invalid ${e}: not a function`);
  return rn({ ...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 [h, f, d, p] = x4(s, o, a, c), y = d - h, g = p - f, { 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)), _ = y / b, x = g / w;
    let $ = 0;
    for (const T of i ?? [void 0])
      for (let D = 0.5; D < w; ++D)
        for (let M = 0.5; M < b; ++M, ++$)
          v[$] = n(u.invert(h + M * _), l.invert(f + D * x), T);
    return { data: v, facets: i, channels: { [e]: { value: v, scale: "auto" } } };
  });
}
function sz(e) {
  if (typeof e == "function")
    return e;
  if (e == null)
    return m0;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return m0;
    case "nearest":
      return M4;
    case "barycentric":
      return S4();
    case "random-walk":
      return $4();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function m0(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 S4({ random: e = Dy(42) } = {}) {
  return (t, n, r, i, s, o) => {
    const a = t.length, c = n >> 2, u = (r >> 2) - 1, l = a + c * 2 + u * 2, h = new Float64Array(l * 2);
    for (let w = 0; w < a; ++w)
      h[w * 2] = i[t[w]], h[w * 2 + 1] = s[t[w]];
    let f = a;
    const d = (w, v) => (h[f * 2] = w, h[f * 2 + 1] = v, f++);
    for (let w = 0; w <= c; ++w)
      d(w / c * n, 0), d(w / c * n, r);
    for (let w = 0; w < u; ++w)
      d(n, w / u * r), d(0, w / u * r);
    o = wh(o, t);
    const p = new Wr(h.subarray(0, a * 2));
    for (let w = a, v; w < l; ++w)
      o[w] = o[v = p.find(h[w * 2], h[w * 2 + 1], v)];
    const { points: y, triangles: g } = new Wr(h), m = new o.constructor(n * r), b = cz(o, e);
    for (let w = 0; w < g.length; w += 3) {
      const v = g[w], _ = g[w + 1], x = g[w + 2], $ = y[2 * v], T = y[2 * _], D = y[2 * x], M = y[2 * v + 1], A = y[2 * _ + 1], L = y[2 * x + 1], k = Math.min($, T, D), S = Math.max($, T, D), I = Math.min(M, A, L), E = Math.max(M, A, L), N = (A - L) * ($ - D) + (M - L) * (D - T);
      if (!N)
        continue;
      const O = o[v], R = o[_], C = o[x];
      for (let j = Math.floor(k); j < S; ++j)
        for (let z = Math.floor(I); z < E; ++z) {
          if (j < 0 || j >= n || z < 0 || z >= r)
            continue;
          const X = j + 0.5, H = z + 0.5, J = ((A - L) * (X - D) + (H - L) * (D - T)) / N;
          if (J < 0)
            continue;
          const K = ((L - M) * (X - D) + (H - L) * ($ - D)) / N;
          if (K < 0)
            continue;
          const W = 1 - J - K;
          W < 0 || (m[j + n * z] = b(O, J, R, K, C, W, j, z));
        }
    }
    return m;
  };
}
function M4(e, t, n, r, i, s) {
  const o = new s.constructor(t * n), a = Wr.from(
    e,
    (l) => r[l],
    (l) => i[l]
  );
  let c, u;
  for (let l = 0.5, h = 0; l < n; ++l) {
    u = c;
    for (let f = 0.5; f < t; ++f, ++h)
      u = a.find(f, l, u), f === 0.5 && (c = u), o[h] = s[e[u]];
  }
  return o;
}
function $4({ random: e = Dy(42), minDistance: t = 0.5, maxSteps: n = 2 } = {}) {
  return (r, i, s, o, a, c) => {
    const u = new c.constructor(i * s), l = Wr.from(
      r,
      (p) => o[p],
      (p) => a[p]
    );
    let h, f, d;
    for (let p = 0.5, y = 0; p < s; ++p) {
      f = h;
      for (let g = 0.5; g < i; ++g, ++y) {
        let m = g, b = p;
        d = f = l.find(m, b, f), g === 0.5 && (h = f);
        let w, v = 0;
        for (; (w = Math.hypot(o[r[d]] - m, a[r[d]] - b)) > t && v < n; ) {
          const _ = e(g, p, v) * 2 * Math.PI;
          m += Math.cos(_) * w, b += Math.sin(_) * w, d = l.find(m, b, d), ++v;
        }
        u[y] = c[r[d]];
      }
    }
    return u;
  };
}
function oz(e, t, n, r, i, s) {
  return t * e + r * n + s * i;
}
function az(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 cz(e, t) {
  return e6(e) || Ve(e) ? oz : az(t);
}
function uz(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 lz(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 mw = {
  ariaLabel: "contour",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1,
  pixelSize: 2
};
class A4 extends b4 {
  constructor(t, { smooth: n = !0, value: r, ...i } = {}) {
    const s = k6({}, i, mw);
    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: ei(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 = y0("value", { value: r, ...i }), r = null;
    } else {
      let { interpolate: a } = i;
      r === void 0 && (r = ot), a === void 0 && (i.interpolate = "nearest");
    }
    super(t, { value: { value: r, optional: !0 } }, fz(i), mw);
    const o = { geometry: { value: ot } };
    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 = Fi();
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, n).call((c) => {
      c.selectAll().data(t).enter().append("path").call(Ht, this).attr("d", (u) => a(o[u])).call(le, this, r);
    }).node();
  }
}
function fz({ thresholds: e, interval: t, ...n }) {
  return e = WM(e, t, ly), rn(n, function(r, i, s, o, a, c) {
    const [u, l, h, f] = x4(s, o, a, c), d = h - u, p = f - 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, _ = [];
    if (this.interpolate) {
      const { x: M, y: A } = Th(s, o, c), L = Xt(M, (E) => (E - u) * b, Float64Array), k = Xt(A, (E) => (E - l) * w, Float64Array), S = [s.x, s.y, s.value], I = [L, k, v];
      for (const E of i) {
        const N = this.filter(E, S, I);
        _.push(this.interpolate(N, g, m, L, k, v));
      }
    } else if (i) {
      const M = g * m, A = i.length;
      for (let L = 0; L < A; ++L)
        _.push(v.slice(L * M, L * M + M));
    } else
      _.push(v);
    if (this.blur > 0)
      for (const M of _)
        Yv({ data: M, width: g, height: m }, this.blur);
    const x = hz(e, v, ...pz(_));
    if (x === null)
      throw new Error(`unsupported thresholds: ${e}`);
    const { contour: $ } = Bl().size([g, m]).smooth(this.smooth), T = [], D = [];
    for (const M of _)
      D.push(Ze(T.length, T.push(...Xt(x, (A) => $(M, A)))));
    for (const { coordinates: M } of T)
      for (const A of M)
        for (const L of A)
          for (const k of L)
            k[0] = k[0] / b + u, k[1] = k[1] / w + l;
    return {
      data: T,
      facets: D,
      channels: c6(this.contourChannels, T)
    };
  });
}
function hz(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 kn(e);
  const i = Si(...Kv(n, r, e), e);
  for (; i[i.length - 1] >= r; )
    i.pop();
  for (; i[1] < n; )
    i.shift();
  return i;
}
function dz() {
  return new A4(...v4("value", ...arguments));
}
function pz(e) {
  return [pe(e, (t) => pe(t, gw)), te(e, (t) => te(t, gw))];
}
function gw(e) {
  return isFinite(e) ? e : NaN;
}
function yz(e, t) {
  return Qm(Sm, e, t);
}
function mz(e, t = {}) {
  return Qm(Mm, e, t);
}
function gz(e, t = {}) {
  return Qm($m, e, t);
}
function Qm(e, t, n = {}) {
  const { x: r, y: i, maxRadius: s } = n, o = e({ px: r, py: i, maxRadius: s }), a = [];
  r != null && a.push(Ii(t, bw("x", { ...o, inset: -6 }, n))), i != null && a.push(Ti(t, bw("y", { ...o, inset: -6 }, n))), r != null && a.push(zo(t, ww("x", { ...o, dy: 9, frameAnchor: "bottom", lineAnchor: "top" }, n))), i != null && a.push(zo(t, ww("y", { ...o, dx: -9, frameAnchor: "left", textAnchor: "end" }, n)));
  for (const c of a)
    c.ariaLabel = `crosshair ${c.ariaLabel}`;
  return Hr(...a);
}
function I4(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: bz(e, l)
  };
}
function bz(e, t) {
  return t == null ? t : function(n, r, { x: i, y: s, px: o, py: a, ...c }, ...u) {
    const { channels: { x: l, y: h, ...f } = {}, ...d } = t.call(this, n, r, { ...c, x: o, y: a }, ...u);
    return {
      channels: {
        ...f,
        ...l && { px: l, ...e === "x" && { x: l } },
        ...h && { py: h, ...e === "y" && { y: h } }
      },
      ...d
    };
  };
}
function bw(e, t, n) {
  const {
    color: r = "currentColor",
    opacity: i = 0.2,
    ruleStroke: s = r,
    ruleStrokeOpacity: o = i,
    ruleStrokeWidth: a
  } = n;
  return {
    ...I4(e, t, n),
    stroke: s,
    strokeOpacity: o,
    strokeWidth: a
  };
}
function ww(e, t, n) {
  const {
    color: r = "currentColor",
    textFill: i = r,
    textFillOpacity: s,
    textStroke: o = "white",
    textStrokeOpacity: a,
    textStrokeWidth: c = 5
  } = n;
  return {
    ...I4(e, t, wz(e, n)),
    fill: i,
    fillOpacity: s,
    stroke: o,
    strokeOpacity: a,
    strokeWidth: c
  };
}
function wz(e, t) {
  return rn(t, (n, r, i) => {
    var s;
    return { channels: { text: { value: (s = h6(i, e)) == null ? void 0 : s.value } } };
  });
}
const vz = {
  ariaLabel: "delaunay link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, _z = {
  ariaLabel: "delaunay mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
}, xz = {
  ariaLabel: "hull",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeMiterlimit: 1
}, Sz = {
  ariaLabel: "voronoi",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, Mz = {
  ariaLabel: "voronoi mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
};
class $z extends Vt {
  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,
      vz
    ), this.curve = Fm(o, a), ta(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = r, { curve: h } = this, [f, d] = yr(this, i), p = c ? (b) => c[b] : nn(f), y = u ? (b) => u[b] : nn(d), g = this;
    function m(b) {
      let w = -1;
      const v = [], _ = {};
      for (const S in r)
        _[S] = [];
      const x = [], $ = [], T = [], D = [];
      function M(S, I) {
        S = b[S], I = b[I], v.push(++w), x[w] = p(S), T[w] = y(S), $[w] = p(I), D[w] = y(I);
        for (const E in r)
          _[E].push(r[E][I]);
      }
      const { halfedges: A, hull: L, triangles: k } = Wr.from(b, p, y);
      for (let S = 0; S < A.length; ++S) {
        const I = A[S];
        I > S && M(k[S], k[I]);
      }
      for (let S = 0; S < L.length; ++S)
        M(L[S], L[(S + 1) % L.length]);
      zt(this).selectAll().data(v).enter().append("path").call(Ht, g).attr("d", (S) => {
        const I = Dr(), E = h(I);
        return E.lineStart(), E.point(x[S], T[S]), E.point($[S], D[S]), E.lineEnd(), I;
      }).call(le, g, _).call(Vc, g, _, s);
    }
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, { x: c && o, y: u && a }).call(
      l ? (b) => b.selectAll().data(Jr(t, (w) => l[w]).values()).enter().append("g").each(m) : (b) => b.datum(t).each(m)
    ).node();
  }
}
class tg extends Vt {
  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, [h, f] = yr(this, i), d = c ? (m) => c[m] : nn(h), p = u ? (m) => u[m] : nn(f), y = this;
    function g(m) {
      const b = Wr.from(m, d, p);
      zt(this).append("path").datum(m[0]).call(Ht, y).attr("d", y._render(b, i)).call(le, y, r);
    }
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, { x: c && o, y: u && a }).call(
      l ? (m) => m.selectAll().data(Jr(t, (b) => l[b]).values()).enter().append("g").each(g) : (m) => m.datum(t).each(g)
    ).node();
  }
}
class Az extends tg {
  constructor(t, n = {}) {
    super(t, n, _z), this.fill = "none";
  }
  _render(t) {
    return t.render();
  }
}
class Iz extends tg {
  constructor(t, n = {}) {
    super(t, n, xz, Bi);
  }
  _render(t) {
    return t.renderHull();
  }
}
class Tz extends Vt {
  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,
      Sz
    );
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = r, [h, f] = yr(this, i), d = c ? (m) => c[m] : nn(h), p = u ? (m) => u[m] : nn(f), y = this;
    function g(m) {
      const b = Wr.from(m, d, p), w = T4(b, i);
      zt(this).selectAll().data(m).enter().append("path").call(Ht, y).attr("d", (v, _) => w.renderCell(_)).call(le, y, r);
    }
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, { x: c && o, y: u && a }).call(
      l ? (m) => m.selectAll().data(Jr(t, (b) => l[b]).values()).enter().append("g").each(g) : (m) => m.datum(t).each(g)
    ).node();
  }
}
class Ez extends tg {
  constructor(t, n) {
    super(t, n, Mz), this.fill = "none";
  }
  _render(t, n) {
    return T4(t, n).render();
  }
}
function T4(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 Gc(e, t, { x: n, y: r, ...i } = {}) {
  return [n, r] = Pn(n, r), new e(t, { ...i, x: n, y: r });
}
function Nz(e, t) {
  return Gc($z, e, t);
}
function Lz(e, t) {
  return Gc(Az, e, t);
}
function Dz(e, t) {
  return Gc(Iz, e, t);
}
function Oz(e, t) {
  return Gc(Tz, e, t);
}
function Fz(e, t) {
  return Gc(Ez, e, t);
}
const kz = {
  ariaLabel: "density",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class E4 extends Vt {
  constructor(t, { x: n, y: r, z: i, weight: s, fill: o, stroke: a, ...c } = {}) {
    const u = vw(o) && (o = "currentColor", !0), l = vw(a) && (a = "currentColor", !0);
    super(
      t,
      {
        x: { value: n, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        z: { value: Bi({ z: i, fill: o, stroke: a }), optional: !0 },
        weight: { value: s, optional: !0 }
      },
      Cz({ ...c, fill: o, stroke: a }, u, l),
      kz
    ), 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 = Fi();
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, {}).call(
      (c) => c.selectAll().data(t).enter().append("path").call(Ht, this).call(le, this, r).attr("d", (u) => a(o[u]))
    ).node();
  }
}
function Bz(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Pn(t, n), new E4(e, { ...r, x: t, y: n });
}
const Rz = /* @__PURE__ */ new Set(["x", "y", "z", "weight"]);
function Cz(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" ? Pe(s) : +s, rn(e, function(o, a, c, u, l, h) {
    var k;
    const f = c.weight ? Pe(c.weight.value) : null, d = (k = c.z) == null ? void 0 : k.value, { z: p } = this, [y, g] = yr(this, l), { width: m, height: b } = l, { x: w, y: v } = Th(c, u, h), _ = Object.fromEntries(
      Object.entries(c).filter(([S]) => !Rz.has(S)).map(([S, I]) => [S, { ...I, value: [] }])
    ), x = t && [], $ = n && [], T = iL().x(w ? (S) => w[S] : y).y(v ? (S) => v[S] : g).weight(f ? (S) => f[S] : 1).size([m, b]).bandwidth(i), D = [];
    for (const S of a) {
      const I = [];
      D.push(I);
      for (const E of d ? bm(S, d, p) : [S]) {
        const N = T.contours(E);
        I.push([E, N]);
      }
    }
    let M = s;
    if (!(M instanceof Co)) {
      let S = 0;
      for (const I of D)
        for (const [, E] of I) {
          const N = E.max;
          N > S && (S = N);
        }
      M = Float64Array.from({ length: s - 1 }, (I, E) => S * 100 * (E + 1) / s);
    }
    const A = [], L = [];
    for (const S of D) {
      const I = [];
      A.push(I);
      for (const [E, N] of S)
        for (const O of M) {
          I.push(L.length), L.push(N(O / 100)), x && x.push(O), $ && $.push(O);
          for (const R in _)
            _[R].value.push(c[R].value[E[0]]);
        }
    }
    return x && x.push(0), $ && $.push(0), {
      data: o,
      facets: A,
      channels: {
        ..._,
        ...x && { fill: { value: x, scale: "color" } },
        ...$ && { stroke: { value: $, scale: "color" } },
        contours: { value: L }
      }
    };
  });
}
function vw(e) {
  return /^density$/i.test(e);
}
const Pz = {
  ariaLabel: "geo",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class N4 extends Vt {
  constructor(t, n = {}) {
    const [r, i] = ie(n.r, 3);
    super(
      t,
      {
        geometry: { value: n.geometry },
        r: { value: r, scale: "r", filter: zr, optional: !0 }
      },
      Wm(n),
      Pz
    ), this.r = i;
  }
  render(t, n, r, i, s) {
    const { geometry: o, r: a } = r, c = Fi(s.projection ?? zz(n)), { r: u } = this;
    return mh(u) ? t = [] : u !== void 0 && c.pointRadius(u), Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, n).call((l) => {
      l.selectAll().data(t).enter().append("path").call(Ht, this).attr("d", a ? (h) => c.pointRadius(a[h])(o[h]) : (h) => c(o[h])).call(le, this, r);
    }).node();
  }
}
function zz({ x: e, y: t }) {
  if (e || t)
    return e ?? (e = (n) => n), t ?? (t = (n) => n), rf({
      point(n, r) {
        this.stream.point(e(n), t(r));
      }
    });
}
function eg(e, { geometry: t = ot, ...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 N4(e, { geometry: t, ...n });
}
function Uz({ strokeWidth: e = 1.5, ...t } = {}) {
  return eg({ type: "Sphere" }, { strokeWidth: e, ...t });
}
function jz({ strokeOpacity: e = 0.1, ...t } = {}) {
  return eg(QL(), { strokeOpacity: e, ...t });
}
const ja = 0.5, qa = 0;
function qz(e = { fill: "count" }, { binWidth: t, ...n } = {}) {
  t = t === void 0 ? 20 : At(t), e = sm(e, n);
  const { z: r, fill: i, stroke: s } = n;
  return s === void 0 && ae(i) && pi(e, "fill") && (n.stroke = "none"), n.symbol === void 0 && (n.symbol = "hexagon"), n.r === void 0 && !pi(e, "r") && (n.r = t / 2), rn(n, (o, a, c, u, l, h) => {
    let { x: f, y: d, z: p, fill: y, stroke: g, symbol: m } = c;
    if (f === void 0)
      throw new Error("missing channel: x");
    if (d === void 0)
      throw new Error("missing channel: y");
    ({ x: f, y: d } = Th(c, u, h)), p = p ? p.value : Mt(o, r), y = y == null ? void 0 : y.value, g = g == null ? void 0 : g.value, m = m == null ? void 0 : m.value;
    const b = cm(e, { z: p, fill: y, stroke: g, symbol: m }), w = p && [], v = y && [], _ = g && [], x = m && [], $ = [], T = [], D = [];
    let M = -1;
    for (const S of e)
      S.initialize(o);
    for (const S of a) {
      const I = [];
      for (const E of e)
        E.scope("facet", S);
      for (const [E, N] of uo(S, b))
        for (const O of Vz(N, f, d, t)) {
          I.push(++M), T.push(O.x), D.push(O.y), p && w.push(b === p ? E : p[O[0]]), y && v.push(b === y ? E : y[O[0]]), g && _.push(b === g ? E : g[O[0]]), m && x.push(b === m ? E : m[O[0]]);
          for (const R of e)
            R.reduce(O);
        }
      $.push(I);
    }
    const A = c.x.scale, L = c.y.scale, k = {
      x: { value: T, source: u[A] ? { value: Xt(T, u[A].invert), scale: A } : null },
      y: { value: D, source: u[L] ? { value: Xt(D, u[L].invert), scale: L } : null },
      ...p && { z: { value: w } },
      ...y && { fill: { value: v, scale: "auto" } },
      ...g && { stroke: { value: _, scale: "auto" } },
      ...m && { symbol: { value: x, scale: "auto" } },
      ...Object.fromEntries(
        e.map(({ name: S, output: I }) => [
          S,
          {
            scale: "auto",
            label: I.label,
            radius: S === "r" ? t / 2 : void 0,
            value: I.transform()
          }
        ])
      )
    };
    return { data: o, facets: $, channels: k };
  });
}
function Vz(e, t, n, r) {
  const i = r * (1.5 / r6), s = /* @__PURE__ */ new Map();
  for (const o of e) {
    let a = t[o], c = n[o];
    if (isNaN(a) || isNaN(c))
      continue;
    let u = Math.round(c = (c - qa) / i), l = Math.round(a = (a - ja) / r - (u & 1) / 2), h = c - u;
    if (Math.abs(h) * 3 > 1) {
      let p = a - l, y = l + (a < l ? -1 : 1) / 2, g = u + (c < u ? -1 : 1), m = a - y, b = c - g;
      p * p + h * h > m * m + b * b && (l = y + (u & 1 ? 1 : -1) / 2, u = g);
    }
    const f = `${l},${u}`;
    let d = s.get(f);
    d === void 0 && (s.set(f, d = []), d.x = (l + (u & 1) / 2) * r + ja, d.y = u * i + qa), d.push(o);
  }
  return s.values();
}
const Yz = {
  ariaLabel: "hexgrid",
  fill: "none",
  stroke: "currentColor",
  strokeOpacity: 0.1
};
function Wz(e) {
  return new L4(e);
}
class L4 extends Vt {
  constructor({ binWidth: t = 20, clip: n = !0, ...r } = {}) {
    super(Pa, void 0, { clip: n, ...r }, Yz), this.binWidth = At(t);
  }
  render(t, n, r, i, s) {
    const { binWidth: o } = this, { marginTop: a, marginRight: c, marginBottom: u, marginLeft: l, width: h, height: f } = i, d = l - ja, p = h - c - ja, y = a - qa, g = f - u - qa, m = o / 2, b = m * i6, w = b / 2, v = m * 2, _ = b * 1.5, x = Math.floor(d / v), $ = Math.ceil(p / v), T = Math.floor((y + w) / _), D = Math.ceil((g - w) / _) + 1, M = `m0,${ii(-b)}l${ii(m)},${ii(w)}v${ii(b)}l${ii(-m)},${ii(w)}`;
    let A = M;
    for (let L = T; L < D; ++L)
      for (let k = x; k < $; ++k)
        A += `M${ii(k * v + (L & 1) * m)},${ii(L * _)}${M}`;
    return Dt("svg:g", s).datum(0).call(Zt, this, i, s).call(qt, this, {}, be + ja, be + qa).call((L) => L.append("path").call(Ht, this).call(le, this, r).attr("d", A)).node();
  }
}
function ii(e) {
  return Math.round(e * 1e3) / 1e3;
}
const Xz = {
  ariaLabel: "image",
  fill: null,
  stroke: null
};
function Gz(e) {
  return /^\.*\//.test(e);
}
function Hz(e) {
  return /^(blob|data|file|http|https):/i.test(e);
}
function Zz(e) {
  return typeof e == "string" && (Gz(e) || Hz(e)) ? [void 0, e] : [e, void 0];
}
class D4 extends Vt {
  constructor(t, n = {}) {
    let { x: r, y: i, r: s, width: o, height: a, rotate: c, src: u, preserveAspectRatio: l, crossOrigin: h, frameAnchor: f, 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] = Zz(u), [g, m] = ie(s), [b, w] = ie(o, m !== void 0 ? m * 2 : void 0), [v, _] = ie(a, m !== void 0 ? m * 2 : void 0), [x, $] = ie(c, 0);
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        r: { value: g, scale: "r", filter: zr, optional: !0 },
        width: { value: b, filter: zr, optional: !0 },
        height: { value: v, filter: zr, optional: !0 },
        rotate: { value: x, optional: !0 },
        src: { value: p, optional: !0 }
      },
      Wm(n),
      Xz
    ), this.src = y, this.width = w, this.rotate = $, this.height = _, this.r = m, this.preserveAspectRatio = ee(l, "xMidYMid"), this.crossOrigin = ge(h), this.frameAnchor = Uc(f), this.imageRendering = ee(d, "auto");
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, width: l, height: h, r: f, rotate: d, src: p } = r, { r: y, width: g, height: m, rotate: b } = this, [w, v] = yr(this, i);
    return Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, { x: c && o, y: u && a }).call(
      (_) => _.selectAll().data(t).enter().append("image").call(Ht, this).attr("x", _w(c, l, f, w, g, y)).attr("y", _w(u, h, f, v, m, y)).attr("width", l ? (x) => l[x] : g !== void 0 ? g : f ? (x) => f[x] * 2 : y * 2).attr("height", h ? (x) => h[x] : m !== void 0 ? m : f ? (x) => f[x] * 2 : y * 2).attr("transform", d ? (x) => `rotate(${d[x]})` : b ? `rotate(${b})` : null).attr("transform-origin", d || b ? Oh`${c ? (x) => c[x] : w}px ${u ? (x) => u[x] : v}px` : null).call(nt, "href", p ? (x) => p[x] : this.src).call(nt, "preserveAspectRatio", this.preserveAspectRatio).call(nt, "crossorigin", this.crossOrigin).call(nt, "image-rendering", this.imageRendering).call(nt, "clip-path", f ? (x) => `circle(${f[x]}px)` : y !== void 0 ? `circle(${y}px)` : null).call(le, this, r)
    ).node();
  }
}
function _w(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 Kz(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Pn(t, n)), new D4(e, { ...r, x: t, y: n });
}
function Jz(e, t, n) {
  var r = 1e-8, i = t - 1, s = n - 1, o = 0, a, c, u, l, h, f, 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, h = Math.exp(n * c) / n, g = l + h, e < l / g ? d = Math.pow(t * g * e, 1 / t) : d = 1 - Math.pow(n * g * (1 - e), 1 / n)), m = -po(t) - po(n) + po(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (f = Qz(d, t, n) - e, l = Math.exp(i * Math.log(d) + s * Math.log(1 - d) + m), h = f / l, d -= l = h / (1 - 0.5 * Math.min(1, h * (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 Qz(e, t, n) {
  var r = e === 0 || e === 1 ? 0 : Math.exp(po(t + n) - po(t) - po(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? r * xw(e, t, n) / t : 1 - r * xw(1 - e, n, t) / n;
}
function xw(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, h, f, d;
  for (Math.abs(u) < r && (u = r), u = 1 / u, d = u; i <= 100 && (l = 2 * i, h = i * (n - i) * e / ((a + l) * (t + l)), u = 1 + h * u, Math.abs(u) < r && (u = r), c = 1 + h / c, Math.abs(c) < r && (c = r), u = 1 / u, d *= u * c, h = -(t + i) * (s + i) * e / ((t + l) * (o + l)), u = 1 + h * u, Math.abs(u) < r && (u = r), c = 1 + h / c, Math.abs(c) < r && (c = r), u = 1 / u, f = u * c, d *= f, !(Math.abs(f - 1) < 3e-7)); i++)
    ;
  return d;
}
function po(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 tU(e, t) {
  var n = Jz(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 eU = {
  ariaLabel: "linear-regression",
  fill: "currentColor",
  fillOpacity: 0.1,
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class O4 extends Vt {
  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: Bi(n), optional: !0 }
      },
      n,
      eU
    ), 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 Dt("svg:g", s).call(Zt, this, i, s).call(qt, this, n).call(
      (l) => l.selectAll().data(c ? bm(t, c, this.z) : [t]).enter().call(
        (h) => h.append("path").attr("fill", "none").call(Ht, this).call(vf, this, { ...r, fill: null, fillOpacity: null }).attr("d", (f) => this._renderLine(f, o, a)).call(
          u && !Po(this.fill) ? (f) => f.select(nU).attr("stroke", "none").call(Ht, this).call(vf, this, {
            ...r,
            stroke: null,
            strokeOpacity: null,
            strokeWidth: null
          }).attr("d", (d) => this._renderBand(d, o, a)) : () => {
          }
        )
      )
    ).node();
  }
}
function nU() {
  return this.parentNode.insertBefore(this.ownerDocument.createElementNS(bs.svg, "path"), this);
}
class rU extends O4 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, r) {
    const { ci: i, precision: s } = this, [o, a] = Se(t, (l) => r[l]), c = Tf(t, r, n), u = F4(t, r, n, (1 - i) / 2, c);
    return Py().y((l) => l).x0((l) => u(l, -1)).x1((l) => u(l, 1))(Ze(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, r) {
    const [i, s] = Se(t, (a) => r[a]), o = Tf(t, r, n);
    return `M${o(i)},${i}L${o(s)},${s}`;
  }
}
class iU extends O4 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, r) {
    const { ci: i, precision: s } = this, [o, a] = Se(t, (l) => n[l]), c = Tf(t, n, r), u = F4(t, n, r, (1 - i) / 2, c);
    return Py().x((l) => l).y0((l) => u(l, -1)).y1((l) => u(l, 1))(Ze(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, r) {
    const [i, s] = Se(t, (a) => n[a]), o = Tf(t, n, r);
    return `M${i},${o(i)}L${s},${o(s)}`;
  }
}
function sU(e, { y: t = We, x: n = ot, stroke: r, fill: i = ae(r) ? "currentColor" : r, ...s } = {}) {
  return new rU(e, Bm({ ...s, x: n, y: t, fill: i, stroke: r }));
}
function oU(e, { x: t = We, y: n = ot, stroke: r, fill: i = ae(r) ? "currentColor" : r, ...s } = {}) {
  return new iU(e, km({ ...s, x: t, y: n, fill: i, stroke: r }));
}
function Tf(e, t, n) {
  let r = 0, i = 0, s = 0, o = 0;
  for (const l of e) {
    const h = t[l], f = n[l];
    r += h, i += f, s += h * f, o += h * h;
  }
  const a = e.length, c = (a * s - r * i) / (a * o - r * r), u = (i - c * r) / a;
  return (l) => c * l + u;
}
function F4(e, t, n, r, i) {
  const s = ar(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 = tU(r, e.length - 2);
  return (l, h) => {
    const f = i(l), d = c * Math.sqrt(1 / e.length + (l - s) ** 2 / o);
    return f + h * u * d;
  };
}
function g0({
  path: e = ot,
  // the delimited path
  delimiter: t,
  // how the path is separated
  frameAnchor: n,
  treeLayout: r = Tx,
  treeSort: i,
  treeSeparation: s,
  treeAnchor: o,
  ...a
} = {}) {
  o = ng(o), i = B4(i), n === void 0 && (n = o.frameAnchor);
  const c = R4(t), u = q4(a, P4), [l, h] = Je(), [f, d] = Je();
  return {
    x: l,
    y: f,
    frameAnchor: n,
    ...pr(a, (p, y) => {
      const g = c(Mt(p, e)), m = h([]), b = d([]);
      let w = -1;
      const v = [], _ = [], x = Ix().path((T) => g[T]), $ = r();
      $.nodeSize && $.nodeSize([1, 1]), $.separation && s !== void 0 && $.separation(s ?? Yy);
      for (const T of u)
        T[Ef] = T[U4]([]);
      for (const T of y) {
        const D = [], M = x(T.filter((A) => g[A] != null)).each((A) => A.data = p[A.data]);
        i != null && M.sort(i), $(M);
        for (const A of M.descendants()) {
          D.push(++w), v[w] = A.data, o.position(A, w, m, b);
          for (const L of u)
            L[Ef][w] = L[j4](A);
        }
        _.push(D);
      }
      return { data: v, facets: _ };
    }),
    ...Object.fromEntries(u)
  };
}
function k4({
  path: e = ot,
  // 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 = Tx,
  treeSort: a,
  treeSeparation: c,
  treeAnchor: u,
  ...l
} = {}) {
  u = ng(u), a = B4(a), l = { curve: n, stroke: r, strokeWidth: i, strokeOpacity: s, ...l };
  const h = R4(t), f = q4(l, dU), [d, p] = Je(), [y, g] = Je(), [m, b] = Je(), [w, v] = Je();
  return {
    x1: d,
    x2: y,
    y1: m,
    y2: w,
    ...pr(l, (_, x) => {
      const $ = h(Mt(_, e)), T = p([]), D = g([]), M = b([]), A = v([]);
      let L = -1;
      const k = [], S = [], I = Ix().path((N) => $[N]), E = o();
      E.nodeSize && E.nodeSize([1, 1]), E.separation && c !== void 0 && E.separation(c ?? Yy);
      for (const N of f)
        N[Ef] = N[U4]([]);
      for (const N of x) {
        const O = [], R = I(N.filter((C) => $[C] != null)).each((C) => C.data = _[C.data]);
        a != null && R.sort(a), E(R);
        for (const { source: C, target: j } of R.links()) {
          O.push(++L), k[L] = j.data, u.position(C, L, T, M), u.position(j, L, D, A);
          for (const z of f)
            z[Ef][L] = z[j4](j, C);
        }
        S.push(O);
      }
      return { data: k, facets: S };
    }),
    ...Object.fromEntries(f)
  };
}
function ng(e = "left") {
  switch (`${e}`.trim().toLowerCase()) {
    case "left":
      return aU;
    case "right":
      return cU;
  }
  throw new Error(`invalid tree anchor: ${e}`);
}
const aU = {
  frameAnchor: "left",
  dx: 6,
  position({ x: e, y: t }, n, r, i) {
    r[n] = t, i[n] = -e;
  }
}, cU = {
  frameAnchor: "right",
  dx: -6,
  position({ x: e, y: t }, n, r, i) {
    r[n] = -t, i[n] = -e;
  }
};
function B4(e) {
  return e == null || typeof e == "function" ? e : `${e}`.trim().toLowerCase().startsWith("node:") ? Sw(P4(e)) : Sw(uU(e));
}
function Sw(e) {
  return (t, n) => Gr(e(t), e(n));
}
function uU(e) {
  return (t) => {
    var n;
    return (n = t.data) == null ? void 0 : n[e];
  };
}
function R4(e = "/") {
  return `${e}` == "/" ? (t) => t : (t) => t.map(lU(e, "/"));
}
function lU(e, t) {
  return e = new RegExp(fU(e), "g"), (n) => n == null ? null : `${n}`.replace(e, t);
}
function fU(e) {
  return `${e}`.replace(/[\\^$*+?.()|[\]{}]/g, "\\$&");
}
function C4(e) {
  return hr(e) && typeof e.node == "function";
}
function hU(e) {
  return hr(e) && typeof e.link == "function";
}
function P4(e) {
  if (C4(e))
    return e.node;
  if (e = `${e}`.trim().toLowerCase(), !!e.startsWith("node:")) {
    switch (e) {
      case "node:name":
        return w0;
      case "node:path":
        return b0;
      case "node:internal":
        return z4;
      case "node:depth":
        return v0;
      case "node:height":
        return _0;
    }
    throw new Error(`invalid node value: ${e}`);
  }
}
function dU(e) {
  if (C4(e))
    return e.node;
  if (hU(e))
    return e.link;
  if (e = `${e}`.trim().toLowerCase(), !(!e.startsWith("node:") && !e.startsWith("parent:"))) {
    switch (e) {
      case "parent:name":
        return Nu(w0);
      case "parent:path":
        return Nu(b0);
      case "parent:depth":
        return Nu(v0);
      case "parent:height":
        return Nu(_0);
      case "node:name":
        return w0;
      case "node:path":
        return b0;
      case "node:internal":
        return z4;
      case "node:depth":
        return v0;
      case "node:height":
        return _0;
    }
    throw new Error(`invalid link value: ${e}`);
  }
}
function b0(e) {
  return e.id;
}
function w0(e) {
  return pU(e.id);
}
function v0(e) {
  return e.depth;
}
function _0(e) {
  return e.height;
}
function z4(e) {
  return !!e.children;
}
function Nu(e) {
  return (t, n) => n == null ? void 0 : e(n);
}
function pU(e) {
  let t = e.length;
  for (; --t > 0 && !yU(e, t); )
    ;
  return e.slice(t + 1);
}
function yU(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
const U4 = 2, j4 = 3, Ef = 4;
function q4(e, t) {
  const n = [];
  for (const r in e) {
    const i = e[r], s = t(i);
    s !== void 0 && n.push([r, ...Je(i), s]);
  }
  return n;
}
function V4(e, {
  fill: t,
  stroke: n,
  strokeWidth: r,
  strokeOpacity: i,
  strokeLinejoin: s,
  strokeLinecap: o,
  strokeMiterlimit: a,
  strokeDasharray: c,
  strokeDashoffset: u,
  marker: l,
  markerStart: h = l,
  markerEnd: f = l,
  dot: d = ae(h) && ae(f),
  text: p = "node:name",
  textStroke: y = "white",
  title: g = "node:path",
  dx: m,
  dy: b,
  ...w
} = {}) {
  return m === void 0 && (m = ng(w.treeAnchor).dx), Hr(
    i4(
      e,
      k4({
        markerStart: h,
        markerEnd: f,
        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,
        ...w
      })
    ),
    d ? Pi(e, g0({ fill: t === void 0 ? "node:internal" : t, title: g, ...w })) : null,
    p != null ? zo(
      e,
      g0({
        text: p,
        fill: t === void 0 ? "currentColor" : t,
        stroke: y,
        dx: m,
        dy: b,
        title: g,
        ...w
      })
    ) : null
  );
}
function mU(e, t) {
  return V4(e, { ...t, treeLayout: qD });
}
function gU({ geometry: e = ot, ...t } = {}) {
  return rn({ ...t, x: null, y: null }, (n, r, i, s, o, { projection: a }) => {
    const c = Mt(n, e), u = c.length, l = new Float64Array(u), h = new Float64Array(u), f = Fi(a);
    for (let d = 0; d < u; ++d)
      [l[d], h[d]] = f.centroid(c[d]);
    return { data: n, facets: r, channels: { x: { value: l, source: null }, y: { value: h, source: null } } };
  });
}
function bU({ geometry: e = ot, ...t } = {}) {
  let n;
  return {
    ...t,
    x: { transform: (r) => Float64Array.from(n = Mt(Mt(r, e), UL), ([i]) => i) },
    y: { transform: () => Float64Array.from(n, ([, r]) => r) }
  };
}
function wU(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function vU(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 _U(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 xU(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 SU(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 MU(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 xa(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 $U = {
  ge: function(e, t, n, r, i) {
    return xa(e, t, n, r, i, vU);
  },
  gt: function(e, t, n, r, i) {
    return xa(e, t, n, r, i, _U);
  },
  lt: function(e, t, n, r, i) {
    return xa(e, t, n, r, i, xU);
  },
  le: function(e, t, n, r, i) {
    return xa(e, t, n, r, i, SU);
  },
  eq: function(e, t, n, r, i) {
    return xa(e, t, n, r, i, MU);
  }
}, Nf = $U, Js = 0, Gi = 1, Gu = 2, AU = TU;
function rg(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 Hc = rg.prototype;
function Hd(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 Y4(e, t) {
  var n = qo(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 Mw(e, t) {
  var n = e.intervals([]);
  n.push(t), Y4(e, n);
}
function $w(e, t) {
  var n = e.intervals([]), r = n.indexOf(t);
  return r < 0 ? Js : (n.splice(r, 1), Y4(e, n), Gi);
}
Hc.intervals = function(e) {
  return e.push.apply(e, this.leftPoints), this.left && this.left.intervals(e), this.right && this.right.intervals(e), e;
};
Hc.insert = function(e) {
  var t = this.count - this.leftPoints.length;
  if (this.count += 1, e[1] < this.mid)
    this.left ? 4 * (this.left.count + 1) > 3 * (t + 1) ? Mw(this, e) : this.left.insert(e) : this.left = qo([e]);
  else if (e[0] > this.mid)
    this.right ? 4 * (this.right.count + 1) > 3 * (t + 1) ? Mw(this, e) : this.right.insert(e) : this.right = qo([e]);
  else {
    var n = Nf.ge(this.leftPoints, e, ig), r = Nf.ge(this.rightPoints, e, sg);
    this.leftPoints.splice(n, 0, e), this.rightPoints.splice(r, 0, e);
  }
};
Hc.remove = function(e) {
  var t = this.count - this.leftPoints;
  if (e[1] < this.mid) {
    if (!this.left)
      return Js;
    var n = this.right ? this.right.count : 0;
    if (4 * n > 3 * (t - 1))
      return $w(this, e);
    var r = this.left.remove(e);
    return r === Gu ? (this.left = null, this.count -= 1, Gi) : (r === Gi && (this.count -= 1), r);
  } else if (e[0] > this.mid) {
    if (!this.right)
      return Js;
    var i = this.left ? this.left.count : 0;
    if (4 * i > 3 * (t - 1))
      return $w(this, e);
    var r = this.right.remove(e);
    return r === Gu ? (this.right = null, this.count -= 1, Gi) : (r === Gi && (this.count -= 1), r);
  } else {
    if (this.count === 1)
      return this.leftPoints[0] === e ? Gu : Js;
    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;
        }
        Hd(this, o), this.count = (this.left ? this.left.count : 0) + (this.right ? this.right.count : 0) + this.leftPoints.length;
      } else
        this.left ? Hd(this, this.left) : Hd(this, this.right);
      return Gi;
    }
    for (var a = Nf.ge(this.leftPoints, e, ig); 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 = Nf.ge(this.rightPoints, e, sg); r < this.rightPoints.length && this.rightPoints[r][1] === e[1]; ++r)
          if (this.rightPoints[r] === e)
            return this.rightPoints.splice(r, 1), Gi;
      }
    return Js;
  }
};
function W4(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 X4(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 G4(e, t) {
  for (var n = 0; n < e.length; ++n) {
    var r = t(e[n]);
    if (r)
      return r;
  }
}
Hc.queryPoint = function(e, t) {
  if (e < this.mid) {
    if (this.left) {
      var n = this.left.queryPoint(e, t);
      if (n)
        return n;
    }
    return W4(this.leftPoints, e, t);
  } else if (e > this.mid) {
    if (this.right) {
      var n = this.right.queryPoint(e, t);
      if (n)
        return n;
    }
    return X4(this.rightPoints, e, t);
  } else
    return G4(this.leftPoints, t);
};
Hc.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 ? W4(this.leftPoints, t, n) : e > this.mid ? X4(this.rightPoints, e, n) : G4(this.leftPoints, n);
};
function IU(e, t) {
  return e - t;
}
function ig(e, t) {
  var n = e[0] - t[0];
  return n || e[1] - t[1];
}
function sg(e, t) {
  var n = e[1] - t[1];
  return n || e[0] - t[0];
}
function qo(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(IU);
  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(ig), u.sort(sg), new rg(
    r,
    qo(i),
    qo(s),
    c,
    u
  );
}
function x0(e) {
  this.root = e;
}
var sa = x0.prototype;
sa.insert = function(e) {
  this.root ? this.root.insert(e) : this.root = new rg(e[0], null, null, [e], [e]);
};
sa.remove = function(e) {
  if (this.root) {
    var t = this.root.remove(e);
    return t === Gu && (this.root = null), t !== Js;
  }
  return !1;
};
sa.queryPoint = function(e, t) {
  if (this.root)
    return this.root.queryPoint(e, t);
};
sa.queryInterval = function(e, t, n) {
  if (e <= t && this.root)
    return this.root.queryInterval(e, t, n);
};
Object.defineProperty(sa, "count", {
  get: function() {
    return this.root ? this.root.count : 0;
  }
});
Object.defineProperty(sa, "intervals", {
  get: function() {
    return this.root ? this.root.intervals([]) : [];
  }
});
function TU(e) {
  return !e || e.length === 0 ? new x0(null) : new x0(qo(e));
}
const EU = /* @__PURE__ */ wU(AU), NU = ({ marginLeft: e }) => [1, e], LU = ({ width: e, marginRight: t }) => [-1, e - t], DU = ({ width: e, marginLeft: t, marginRight: n }) => [0, (t + e - n) / 2], OU = ({ marginTop: e }) => [1, e], FU = ({ height: e, marginBottom: t }) => [-1, e - t], kU = ({ height: e, marginTop: t, marginBottom: n }) => [0, (t + e - n) / 2];
function H4(e) {
  return typeof e == "string" ? { anchor: e } : e;
}
function BU(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Z4(e));
  let { anchor: n = "left", padding: r = 1, r: i = t.r } = H4(e);
  switch (`${n}`.toLowerCase()) {
    case "left":
      n = NU;
      break;
    case "right":
      n = LU;
      break;
    case "middle":
      n = DU;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return K4("x", "y", n, At(r), i, t);
}
function RU(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Z4(e));
  let { anchor: n = "bottom", padding: r = 1, r: i = t.r } = H4(e);
  switch (`${n}`.toLowerCase()) {
    case "top":
      n = OU;
      break;
    case "bottom":
      n = FU;
      break;
    case "middle":
      n = kU;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return K4("y", "x", n, At(r), i, t);
}
function Z4(e) {
  const { anchor: t, padding: n, ...r } = e, { r: i } = r;
  return [{ anchor: t, padding: n, r: i }, r];
}
function K4(e, t, n, r, i, s) {
  if (i != null && typeof i != "number") {
    let { channels: o, sort: a, reverse: c } = s;
    o = Zy(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 rn(s, function(o, a, c, u, l, h) {
    let { [t]: f, r: d } = c;
    if (!c[t])
      throw new Error(`missing channel: ${t}`);
    ({ [t]: f } = Th(c, u, h));
    const p = d ? void 0 : i !== void 0 ? At(i) : this.r !== void 0 ? this.r : 3;
    d && (d = Mt(d.value, u[d.scale] || ot, Float64Array));
    let [y, g] = n(l);
    const m = y ? PU : CU, b = new Float64Array(f.length), w = d ? (v) => d[v] : () => p;
    for (let v of a) {
      const _ = EU();
      v = v.filter(d ? ($) => mf(f[$]) && zr(d[$]) : ($) => mf(f[$]));
      const x = new Float64Array(2 * v.length + 2);
      for (const $ of v) {
        const T = w($), D = y ? T + r : 0, M = f[$] - T, A = f[$] + T;
        let L = 2;
        _.queryInterval(M - r, A + r, ([, , S]) => {
          const I = b[S] - D, E = f[$] - f[S], N = r + (d ? d[$] + d[S] : 2 * p), O = Math.sqrt(N * N - E * E);
          x[L++] = I - O, x[L++] = I + O;
        });
        let k = x.slice(0, L);
        y && (k = k.filter((S) => S >= 0));
        t:
          for (const S of k.sort(m)) {
            for (let I = 0; I < L; I += 2)
              if (x[I] + 1e-6 < S && S < x[I + 1] - 1e-6)
                continue t;
            b[$] = S + D;
            break;
          }
        _.insert([M, A, $]);
      }
    }
    y || (y = 1);
    for (const v of a)
      for (const _ of v)
        b[_] = b[_] * y + g;
    return {
      data: o,
      facets: a,
      channels: {
        [e]: { value: b, source: null },
        // don’t show in tooltip
        [t]: { value: f, source: c[t] },
        ...d && { r: { value: d, source: c.r } }
      }
    };
  });
}
function CU(e, t) {
  return Math.abs(e) - Math.abs(t);
}
function PU(e, t) {
  return e - t;
}
function zU(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), Hm(og(e), t);
}
function UU(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), Zm(og(e), t);
}
function og(e) {
  if (e === void 0)
    return Aw;
  if (typeof e == "function")
    return qh(Gy(e));
  if (/^p\d{2}$/i.test(e))
    return oa(Wy(e));
  switch (`${e}`.toLowerCase()) {
    case "deviation":
      return VU;
    case "first":
      return Aw;
    case "last":
      return qU;
    case "max":
      return YU;
    case "mean":
      return WU;
    case "median":
      return XU;
    case "min":
      return GU;
    case "sum":
      return HU;
    case "extent":
      return jU;
  }
  throw new Error(`invalid basis: ${e}`);
}
function qh(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 oa(e) {
  return qh((t, n) => e(t, (r) => n[r]));
}
const jU = {
  mapIndex(e, t, n) {
    const [r, i] = Se(e, (o) => t[o]), s = i - r;
    for (const o of e)
      n[o] = t[o] === null ? NaN : (t[o] - r) / s;
  }
}, Aw = qh((e, t) => {
  for (let n = 0; n < e.length; ++n) {
    const r = t[e[n]];
    if (Oe(r))
      return r;
  }
}), qU = qh((e, t) => {
  for (let n = e.length - 1; n >= 0; --n) {
    const r = t[e[n]];
    if (Oe(r))
      return r;
  }
}), VU = {
  mapIndex(e, t, n) {
    const r = hy(e, (s) => t[s]), i = jf(e, (s) => t[s]);
    for (const s of e)
      n[s] = t[s] === null ? NaN : i ? (t[s] - r) / i : 0;
  }
}, YU = oa(te), WU = oa(hy), XU = oa(tc), GU = oa(pe), HU = oa(ar);
function ZU(e = {}, t) {
  return arguments.length === 1 && (t = e), Hm(ag(e), t);
}
function KU(e = {}, t) {
  return arguments.length === 1 && (t = e), Zm(ag(e), t);
}
function ag(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 = QU(r), hs(`Warning: the shift option is deprecated; please use anchor "${i}" instead.`)), !((t = Math.floor(t)) > 0))
    throw new Error(`invalid k: ${t}`);
  return tj(n)(t, JU(i, t), s);
}
function JU(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 QU(e) {
  switch (`${e}`.toLowerCase()) {
    case "centered":
      return "middle";
    case "leading":
      return "start";
    case "trailing":
      return "end";
  }
  throw new Error(`invalid shift: ${e}`);
}
function tj(e = "mean") {
  if (typeof e == "string") {
    if (/^p\d{2}$/i.test(e))
      return Lu(Wy(e));
    switch (e.toLowerCase()) {
      case "deviation":
        return Lu(jf);
      case "max":
        return Du((t, n) => te(t, (r) => n[r]));
      case "mean":
        return ej;
      case "median":
        return Lu(tc);
      case "min":
        return Du((t, n) => pe(t, (r) => n[r]));
      case "mode":
        return Du((t, n) => e_(t, (r) => n[r]));
      case "sum":
        return J4;
      case "variance":
        return Lu(oy);
      case "difference":
        return ij;
      case "ratio":
        return sj;
      case "first":
        return oj;
      case "last":
        return aj;
    }
  }
  if (typeof e != "function")
    throw new Error(`invalid reduce: ${e}`);
  return Du(Gy(e));
}
function yo(e, t, n) {
  return e.subarray ? e.subarray(t, n) : e.slice(t, n);
}
function Lu(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 + a]] = c === 0 ? e(yo(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 = -a; c < 0; ++c)
        o[i[c + a]] = e(yo(i, 0, c + t), a);
      for (let c = 0, u = i.length - a; c < u; ++c)
        o[i[c + a]] = e(yo(i, c, c + t), a);
    }
  };
}
function Du(e) {
  return (t, n, r) => r ? {
    mapIndex(i, s, o) {
      let a = 0;
      for (let c = 0; c < t - 1; ++c)
        a += Oe(s[i[c]]);
      for (let c = 0, u = i.length - t + 1; c < u; ++c)
        a += Oe(s[i[c + t - 1]]), a === t && (o[i[c + n]] = e(yo(i, c, c + t), s)), a -= Oe(s[i[c]]);
    }
  } : {
    mapIndex(i, s, o) {
      for (let a = -n; a < 0; ++a)
        o[i[a + n]] = e(yo(i, 0, a + t), s);
      for (let a = 0, c = i.length - n; a < c; ++a)
        o[i[a + n]] = e(yo(i, a, a + t), s);
    }
  };
}
function J4(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]], h = i[r[c + e - 1]];
        h === null || isNaN(h) ? ++o : a += +h, 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 ej(e, t, n) {
  if (n) {
    const r = J4(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 h = i[r[u]];
          h !== null && !isNaN(h = +h) && (o += h, ++a);
        }
        for (let u = -t, l = c - t; u < l; ++u) {
          let h = i[r[u + e - 1]], f = i[r[u]];
          h !== null && !isNaN(h = +h) && (o += h, ++a), s[r[u + t]] = o / a, f !== null && !isNaN(f = +f) && (o -= f, --a);
        }
      }
    };
}
function nj(e, t, n, r) {
  for (let i = n + r; n < i; ++n) {
    const s = e[t[n]];
    if (Oe(s))
      return s;
  }
}
function rj(e, t, n, r) {
  for (let i = n + r - 1; i >= n; --i) {
    const s = e[t[i]];
    if (Oe(s))
      return s;
  }
}
function Q4(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 t$(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 ij(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]] = t$(i, r, o, e) - Q4(i, r, o, e);
    }
  };
}
function sj(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]] = t$(i, r, o, e) / Q4(i, r, o, e);
    }
  };
}
function oj(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]] = nj(i, r, o, e);
    }
  };
}
function aj(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]] = rj(i, r, o, e);
    }
  };
}
function cj(e, t = {}) {
  if (typeof e == "string")
    switch (e.toLowerCase()) {
      case "first":
        return e$(t);
      case "last":
        return n$(t);
    }
  if (typeof e == "function")
    return Ei(null, e, t);
  let n, r;
  for (n in e) {
    if (r !== void 0)
      throw new Error("ambiguous selector; multiple inputs");
    r = uj(e[n]);
  }
  if (r === void 0)
    throw new Error(`invalid selector: ${e}`);
  return Ei(n, r, t);
}
function uj(e) {
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "min":
      return cg;
    case "max":
      return ug;
  }
  throw new Error(`unknown selector: ${e}`);
}
function e$(e) {
  return Ei(null, pj, e);
}
function n$(e) {
  return Ei(null, yj, e);
}
function lj(e) {
  return Ei("x", cg, e);
}
function fj(e) {
  return Ei("y", cg, e);
}
function hj(e) {
  return Ei("x", ug, e);
}
function dj(e) {
  return Ei("y", ug, e);
}
function* pj(e) {
  yield e[0];
}
function* yj(e) {
  yield e[e.length - 1];
}
function* cg(e, t) {
  yield VT(e, (n) => t[n]);
}
function* ug(e, t) {
  yield fy(e, (n) => t[n]);
}
function Ei(e, t, n) {
  if (e != null) {
    if (n[e] == null)
      throw new Error(`missing channel: ${e}`);
    e = n[e];
  }
  const r = Bi(n);
  return pr(n, (i, s) => {
    const o = Mt(i, r), a = Mt(i, e), c = [];
    for (const u of s) {
      const l = [];
      for (const h of o ? Jr(u, (f) => o[f]).values() : [u])
        for (const f of t(h, a))
          l.push(f);
      c.push(l);
    }
    return { data: i, facets: c };
  });
}
const Iw = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Area: Ch,
  Arrow: s4,
  BarX: a4,
  BarY: c4,
  Cell: Ph,
  Contour: A4,
  Density: E4,
  Dot: zh,
  Frame: zM,
  Geo: N4,
  Hexgrid: L4,
  Image: D4,
  Line: Uh,
  Link: r4,
  Mark: Vt,
  Raster: w4,
  Rect: jh,
  RuleX: eM,
  RuleY: nM,
  Text: Fh,
  TickX: f4,
  TickY: h4,
  Tip: UM,
  Vector: kh,
  area: EP,
  areaX: Mf,
  areaY: gc,
  arrow: FP,
  auto: WP,
  autoSpec: u4,
  axisFx: $M,
  axisFy: MM,
  axisX: Nm,
  axisY: Em,
  barX: fo,
  barY: ho,
  bin: Zi,
  binX: fi,
  binY: hi,
  boxX: ez,
  boxY: nz,
  cell: Ym,
  cellX: BP,
  cellY: RP,
  centroid: gU,
  circle: UP,
  cluster: mU,
  column: Je,
  contour: dz,
  crosshair: yz,
  crosshairX: mz,
  crosshairY: gz,
  delaunayLink: Nz,
  delaunayMesh: Lz,
  density: Bz,
  dodgeX: BU,
  dodgeY: RU,
  dot: Pi,
  dotX: PP,
  dotY: zP,
  filter: rB,
  formatIsoDate: gm,
  formatMonth: mR,
  formatWeekday: gR,
  frame: Lm,
  geo: eg,
  geoCentroid: bU,
  graticule: jz,
  gridFx: LM,
  gridFy: EM,
  gridX: NM,
  gridY: TM,
  group: im,
  groupX: dc,
  groupY: pc,
  groupZ: rm,
  hexagon: jP,
  hexbin: qz,
  hexgrid: Wz,
  hull: Dz,
  identity: ot,
  image: Kz,
  indexOf: We,
  initializer: rn,
  interpolateNearest: M4,
  interpolateNone: m0,
  interpolatorBarycentric: S4,
  interpolatorRandomWalk: $4,
  legend: HR,
  line: Xm,
  lineX: Af,
  lineY: If,
  linearRegressionX: sU,
  linearRegressionY: oU,
  link: i4,
  map: Xc,
  mapX: Hm,
  mapY: Zm,
  marks: Hr,
  normalize: og,
  normalizeX: zU,
  normalizeY: UU,
  plot: Dm,
  pointer: Sm,
  pointerX: Mm,
  pointerY: $m,
  raster: iz,
  rect: Gm,
  rectX: za,
  rectY: Ua,
  reverse: iB,
  ruleX: Ii,
  ruleY: Ti,
  scale: $s,
  select: cj,
  selectFirst: e$,
  selectLast: n$,
  selectMaxX: hj,
  selectMaxY: dj,
  selectMinX: lj,
  selectMinY: fj,
  shuffle: sB,
  sort: s6,
  sphere: Uz,
  spike: wC,
  stackX: KM,
  stackX1: dP,
  stackX2: pP,
  stackY: JM,
  stackY1: yP,
  stackY2: mP,
  text: zo,
  textX: oM,
  textY: aM,
  tickX: d4,
  tickY: p4,
  tip: jM,
  transform: pr,
  tree: V4,
  treeLink: k4,
  treeNode: g0,
  valueof: Mt,
  vector: gM,
  vectorX: bM,
  vectorY: wM,
  voronoi: Oz,
  voronoiMesh: Fz,
  window: ag,
  windowX: ZU,
  windowY: KU
}, Symbol.toStringTag, { value: "Module" })), mj = /* @__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"],
  ["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"]
]), gj = /* @__PURE__ */ new Set([
  "frame",
  "hexgrid",
  "sphere",
  "graticule"
]);
function bj(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] = {});
  }
}
async function wj(e) {
  const t = { marks: [] }, n = [], { attributes: r, marks: i } = e;
  for (const a in r) {
    const c = mj.get(a);
    if (c == null)
      throw new Error(`Unrecognized plot attribute: ${a}`);
    const u = r[a];
    typeof u == "symbol" ? n.push(a) : u !== void 0 && bj(t, c.split("."), u);
  }
  const s = [];
  for (const a of i)
    for (const { type: c, data: u, options: l } of a.plotSpecs())
      gj.has(c) ? t.marks.push(Iw[c](l)) : t.marks.push(Iw[c](u, l)), s.push(a.index);
  _j(t, e);
  const o = Dm(t);
  xj(o, s), vj(e, o, r, n);
  for (const a of e.interactors)
    await a.init(o);
  return o;
}
function vj(e, t, n, r) {
  r.forEach((i) => {
    const s = n[i];
    if (s === iy) {
      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 _j(e, t) {
  const { marks: n } = t;
  Ou("x", e, n, ["x", "x1", "x2"]), Ou("y", e, n, ["y", "y1", "y2"]), Ou("fx", e, n), Ou("fy", e, n);
}
function Ou(e, t, n, r = [e]) {
  const i = t[e] || {};
  if (i.axis === null || i.label !== void 0)
    return;
  const s = n.map((l) => {
    var h;
    return (h = l.channelField(r)) == null ? void 0 : h.field;
  });
  if (s.every((l) => l == null))
    return;
  let o, a, c;
  for (let l = 0; l < s.length; ++l) {
    const { column: h, label: f } = s[l] || {};
    h === void 0 && f === void 0 || (o === void 0 && a === void 0 ? (o = h, a = f, c = Sj(n[l].data, r) || "number") : a !== f ? a = void 0 : o !== h && (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 xj(e, t) {
  const n = e.querySelectorAll('g[aria-label="facet"]');
  if (n.length)
    for (const r of n)
      Tw(r, t);
  else
    Tw(e, t);
}
function Tw(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 Sj(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 Mj = {
  width: 640,
  marginLeft: 40,
  marginRight: 20,
  marginTop: 20,
  marginBottom: 30
};
class $j {
  constructor(t) {
    this.attributes = { ...Mj }, 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 = JI();
  }
  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 wj(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 Pv(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 Aj(...e) {
  const t = new $j();
  return e.flat().forEach((n) => n(t)), t.marks.forEach((n) => An().connect(n)), t.element;
}
class Ij 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 lg = new Ij();
function Tj(e) {
  return (t) => lg.set(e, t);
}
function r$(e, t, n) {
  mi(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 i$(e, t) {
  return (n) => {
    r$(n, e, t);
  };
}
function fg(e) {
  return (t) => {
    for (const [n, r] of Object.entries(e))
      r$(t, n, r);
  };
}
function Ej(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), fg(s);
}
function Nj(e) {
  return fg({ xDomain: e, yDomain: e });
}
const F = (e) => (t) => i$(e, t), Lj = F("style"), Dj = F("width"), Oj = F("height"), Fj = F("margin"), kj = F("marginLeft"), Bj = F("marginRight"), Rj = F("marginTop"), Cj = F("marginBottom"), Pj = F("align"), zj = F("aspectRatio"), Uj = F("axis"), jj = F("inset"), qj = F("grid"), Vj = F("label"), Yj = F("padding"), Wj = F("round"), Xj = F("xScale"), Gj = F("xDomain"), Hj = F("xRange"), Zj = F("xNice"), Kj = F("xInset"), Jj = F("xInsetLeft"), Qj = F("xInsetRight"), tq = F("xClamp"), eq = F("xRound"), nq = F("xAlign"), rq = F("xPadding"), iq = F("xPaddingInner"), sq = F("xPaddingOuter"), oq = F("xAxis"), aq = F("xTicks"), cq = F("xTickSize"), uq = F("xTickSpacing"), lq = F("xTickPadding"), fq = F("xTickFormat"), hq = F("xTickRotate"), dq = F("xGrid"), pq = F("xLine"), yq = F("xLabel"), mq = F("xLabelAnchor"), gq = F("xLabelOffset"), bq = F("xFontVariant"), wq = F("xAriaLabel"), vq = F("xAriaDescription"), _q = F("xReverse"), xq = F("xZero"), Sq = F("yScale"), Mq = F("yDomain"), $q = F("yRange"), Aq = F("yNice"), Iq = F("yInset"), Tq = F("yInsetTop"), Eq = F("yInsetBottom"), Nq = F("yClamp"), Lq = F("yRound"), Dq = F("yAlign"), Oq = F("yPadding"), Fq = F("yPaddingInner"), kq = F("yPaddingOuter"), Bq = F("yAxis"), Rq = F("yTicks"), Cq = F("yTickSize"), Pq = F("yTickSpacing"), zq = F("yTickPadding"), Uq = F("yTickFormat"), jq = F("yTickRotate"), qq = F("yGrid"), Vq = F("yLine"), Yq = F("yLabel"), Wq = F("yLabelAnchor"), Xq = F("yLabelOffset"), Gq = F("yFontVariant"), Hq = F("yAriaLabel"), Zq = F("yAriaDescription"), Kq = F("yReverse"), Jq = F("yZero"), Qq = F("facetMargin"), tV = F("facetMarginTop"), eV = F("facetMarginBottom"), nV = F("facetMarginLeft"), rV = F("facetMarginRight"), iV = F("facetGrid"), sV = F("facetLabel"), oV = F("fxDomain"), aV = F("fxRange"), cV = F("fxNice"), uV = F("fxInset"), lV = F("fxInsetLeft"), fV = F("fxInsetRight"), hV = F("fxRound"), dV = F("fxAlign"), pV = F("fxPadding"), yV = F("fxPaddingInner"), mV = F("fxPaddingOuter"), gV = F("fxAxis"), bV = F("fxTicks"), wV = F("fxTickSize"), vV = F("fxTickSpacing"), _V = F("fxTickPadding"), xV = F("fxTickFormat"), SV = F("fxTickRotate"), MV = F("fxGrid"), $V = F("fxLine"), AV = F("fxLabel"), IV = F("fxLabelAnchor"), TV = F("fxLabelOffset"), EV = F("fxFontVariant"), NV = F("fxAriaLabel"), LV = F("fxAriaDescription"), DV = F("fxReverse"), OV = F("fyDomain"), FV = F("fyRange"), kV = F("fyNice"), BV = F("fyInset"), RV = F("fyInsetTop"), CV = F("fyInsetBottom"), PV = F("fyRound"), zV = F("fyAlign"), UV = F("fyPadding"), jV = F("fyPaddingInner"), qV = F("fyPaddingOuter"), VV = F("fyAxis"), YV = F("fyTicks"), WV = F("fyTickSize"), XV = F("fyTickSpacing"), GV = F("fyTickPadding"), HV = F("fyTickFormat"), ZV = F("fyTickRotate"), KV = F("fyGrid"), JV = F("fyLine"), QV = F("fyLabel"), tY = F("fyLabelAnchor"), eY = F("fyLabelOffset"), nY = F("fyFontVariant"), rY = F("fyAriaLabel"), iY = F("fyAriaDescription"), sY = F("fyReverse"), oY = F("colorScale"), aY = F("colorDomain"), cY = F("colorRange"), uY = F("colorClamp"), lY = F("colorNice"), fY = F("colorScheme"), hY = F("colorInterpolate"), dY = F("colorPivot"), pY = F("colorSymmetric"), yY = F("colorLabel"), mY = F("colorReverse"), gY = F("colorZero"), bY = F("colorTickFormat"), wY = F("opacityScale"), vY = F("opacityDomain"), _Y = F("opacityRange"), xY = F("opacityClamp"), SY = F("opacityNice"), MY = F("opacityLabel"), $Y = F("opacityReverse"), AY = F("opacityZero"), IY = F("opacityTickFormat"), TY = F("rScale"), EY = F("rDomain"), NY = F("rRange"), LY = F("rClamp"), DY = F("rNice"), OY = F("rZero"), FY = F("lengthScale"), kY = F("lengthDomain"), BY = F("lengthRange"), RY = F("lengthClamp"), CY = F("lengthNice"), PY = F("lengthZero"), zY = F("projectionType"), UY = F("projectionParallels"), jY = F("projectionPrecision"), qY = F("projectionRotate"), VY = F("projectionDomain"), YY = F("projectionInset"), WY = F("projectionInsetLeft"), XY = F("projectionInsetRight"), GY = F("projectionInsetTop"), HY = F("projectionInsetBottom"), ZY = F("projectionClip"), KY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  align: Pj,
  aspectRatio: zj,
  attribute: i$,
  attributes: fg,
  axis: Uj,
  colorClamp: uY,
  colorDomain: aY,
  colorInterpolate: hY,
  colorLabel: yY,
  colorNice: lY,
  colorPivot: dY,
  colorRange: cY,
  colorReverse: mY,
  colorScale: oY,
  colorScheme: fY,
  colorSymmetric: pY,
  colorTickFormat: bY,
  colorZero: gY,
  facetGrid: iV,
  facetLabel: sV,
  facetMargin: Qq,
  facetMarginBottom: eV,
  facetMarginLeft: nV,
  facetMarginRight: rV,
  facetMarginTop: tV,
  fxAlign: dV,
  fxAriaDescription: LV,
  fxAriaLabel: NV,
  fxAxis: gV,
  fxDomain: oV,
  fxFontVariant: EV,
  fxGrid: MV,
  fxInset: uV,
  fxInsetLeft: lV,
  fxInsetRight: fV,
  fxLabel: AV,
  fxLabelAnchor: IV,
  fxLabelOffset: TV,
  fxLine: $V,
  fxNice: cV,
  fxPadding: pV,
  fxPaddingInner: yV,
  fxPaddingOuter: mV,
  fxRange: aV,
  fxReverse: DV,
  fxRound: hV,
  fxTickFormat: xV,
  fxTickPadding: _V,
  fxTickRotate: SV,
  fxTickSize: wV,
  fxTickSpacing: vV,
  fxTicks: bV,
  fyAlign: zV,
  fyAriaDescription: iY,
  fyAriaLabel: rY,
  fyAxis: VV,
  fyDomain: OV,
  fyFontVariant: nY,
  fyGrid: KV,
  fyInset: BV,
  fyInsetBottom: CV,
  fyInsetTop: RV,
  fyLabel: QV,
  fyLabelAnchor: tY,
  fyLabelOffset: eY,
  fyLine: JV,
  fyNice: kV,
  fyPadding: UV,
  fyPaddingInner: jV,
  fyPaddingOuter: qV,
  fyRange: FV,
  fyReverse: sY,
  fyRound: PV,
  fyTickFormat: HV,
  fyTickPadding: GV,
  fyTickRotate: ZV,
  fyTickSize: WV,
  fyTickSpacing: XV,
  fyTicks: YV,
  grid: qj,
  height: Oj,
  inset: jj,
  label: Vj,
  lengthClamp: RY,
  lengthDomain: kY,
  lengthNice: CY,
  lengthRange: BY,
  lengthScale: FY,
  lengthZero: PY,
  margin: Fj,
  marginBottom: Cj,
  marginLeft: kj,
  marginRight: Bj,
  marginTop: Rj,
  margins: Ej,
  name: Tj,
  opacityClamp: xY,
  opacityDomain: vY,
  opacityLabel: MY,
  opacityNice: SY,
  opacityRange: _Y,
  opacityReverse: $Y,
  opacityScale: wY,
  opacityTickFormat: IY,
  opacityZero: AY,
  padding: Yj,
  projectionClip: ZY,
  projectionDomain: VY,
  projectionInset: YY,
  projectionInsetBottom: HY,
  projectionInsetLeft: WY,
  projectionInsetRight: XY,
  projectionInsetTop: GY,
  projectionParallels: UY,
  projectionPrecision: jY,
  projectionRotate: qY,
  projectionType: zY,
  rClamp: LY,
  rDomain: EY,
  rNice: DY,
  rRange: NY,
  rScale: TY,
  rZero: OY,
  round: Wj,
  style: Lj,
  width: Dj,
  xAlign: nq,
  xAriaDescription: vq,
  xAriaLabel: wq,
  xAxis: oq,
  xClamp: tq,
  xDomain: Gj,
  xFontVariant: bq,
  xGrid: dq,
  xInset: Kj,
  xInsetLeft: Jj,
  xInsetRight: Qj,
  xLabel: yq,
  xLabelAnchor: mq,
  xLabelOffset: gq,
  xLine: pq,
  xNice: Zj,
  xPadding: rq,
  xPaddingInner: iq,
  xPaddingOuter: sq,
  xRange: Hj,
  xReverse: _q,
  xRound: eq,
  xScale: Xj,
  xTickFormat: fq,
  xTickPadding: lq,
  xTickRotate: hq,
  xTickSize: cq,
  xTickSpacing: uq,
  xTicks: aq,
  xZero: xq,
  xyDomain: Nj,
  yAlign: Dq,
  yAriaDescription: Zq,
  yAriaLabel: Hq,
  yAxis: Bq,
  yClamp: Nq,
  yDomain: Mq,
  yFontVariant: Gq,
  yGrid: qq,
  yInset: Iq,
  yInsetBottom: Eq,
  yInsetTop: Tq,
  yLabel: Yq,
  yLabelAnchor: Wq,
  yLabelOffset: Xq,
  yLine: Vq,
  yNice: Aq,
  yPadding: Oq,
  yPaddingInner: Fq,
  yPaddingOuter: kq,
  yRange: $q,
  yReverse: Kq,
  yRound: Lq,
  yScale: Sq,
  yTickFormat: Uq,
  yTickPadding: zq,
  yTickRotate: jq,
  yTickSize: Cq,
  yTickSpacing: Pq,
  yTicks: Rq,
  yZero: Jq
}, Symbol.toStringTag, { value: "Module" }));
function JY(e, t) {
  return { table: e, options: t };
}
function hg(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
  Vr(e) !== null);
}
const QY = /* @__PURE__ */ new Set([
  "order",
  "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"
]);
function tW(e) {
  return QY.has(e);
}
const eW = /* @__PURE__ */ new Set([
  "asterisk",
  "circle",
  "cross",
  "diamond",
  "diamond2",
  "hexagon",
  "plus",
  "square",
  "square2",
  "star",
  "times",
  "triangle",
  "triangle2",
  "wye"
]);
function nW(e) {
  return eW.has(`${e}`.toLowerCase());
}
const s$ = (e) => e === "stroke" || e === "fill", rW = (e) => e === "symbol", Zd = (e, t) => ({
  channel: e,
  field: t,
  as: t instanceof xi ? t.column : e
}), Kd = (e, t) => ({ channel: e, value: t });
class aa extends Tc {
  constructor(t, n, r, i = {}) {
    var c;
    super((c = n == null ? void 0 : n.options) == null ? void 0 : c.filterBy), this.type = t, this.reqs = i, this.source = n, Array.isArray(this.source) && (this.data = this.source);
    const s = this.channels = [], o = this.params = /* @__PURE__ */ new Set(), a = (u, l) => {
      const h = typeof l;
      if (h === "function" && l[qv]) {
        const f = l(this, u);
        for (const d in f)
          a(d, f[d]);
      } else if (h === "string")
        tW(u) || s$(u) && hg(l) || rW(u) && nW(l) ? s.push(Kd(u, l)) : s.push(Zd(u, J0(l)));
      else if (Ao(l))
        if (Array.isArray(l.columns))
          s.push(Zd(u, l)), o.add(l);
        else {
          const f = Kd(u, l.value);
          s.push(f), l.addEventListener("value", (d) => (f.value = d, this.update()));
        }
      else
        h === "object" && !Array.isArray(l) && l != null ? s.push(Zd(u, l)) : l !== void 0 && s.push(Kd(u, l));
    };
    for (const u in r)
      a(u, r[u]);
  }
  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 || Array.isArray(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 h = i.get(l);
          (o = r[c]) == null || o.forEach((f) => h.add(f)), (a = u.stats) == null || a.forEach((f) => h.add(f));
        }
      } 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 o$(n, r).where(t);
  }
  queryPending() {
    return this.plot.pending(this), this;
  }
  queryResult(t) {
    return this.data = Array.from(t), this;
  }
  update() {
    return this.plot.update(this);
  }
  plotSpecs() {
    const { type: t, data: n, channels: r } = this, i = {};
    for (const s of r)
      i[s.channel] = yi(s);
    return [{ type: t, data: n, options: i }];
  }
}
function yi(e) {
  return Object.hasOwn(e, "value") ? e.value : s$(e.channel) ? { value: e.as, scale: "color" } : e.as;
}
function o$(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 === "order")
        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 Ni(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" ? Fv(n) : n;
}
function S0(e, t, n, r, i = !1, s = 1) {
  const o = (r - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return i ? q`(${+n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${+t})${a}`;
}
const a$ = { x: ["min", "max"] }, c$ = { y: ["min", "max"] }, u$ = { ...a$, ...c$ };
function l$(e, t, n, r, i) {
  const { plot: s, stats: o } = e, a = s.getAttribute(r), c = s.getAttribute(i);
  if (Array.isArray(a) && !a[ms])
    return a;
  {
    const { field: u } = e.channelField(n), { column: l } = u, { min: h, max: f } = o[l], d = f$(t, l) || (c ? nh().domain([h, f]).nice().domain() : [h, f]);
    return a !== iy && (d[ms] = !0), s.setAttribute(r, d, { silent: !0 }), d;
  }
}
function Zc(e, t) {
  return l$(e, t, "x", "xDomain", "xNice");
}
function Kc(e, t) {
  return l$(e, t, "y", "yDomain", "yNice");
}
function f$(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 iW extends aa {
  constructor(t, n, r) {
    const i = t.endsWith("X") ? "y" : "x", 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 || {}, { field: a, as: c } = this.channelField(r), u = super.query(t);
    if (o) {
      const { column: l } = a, { count: h, max: f, min: d } = s[l], p = r === "x" ? n.innerWidth() : n.innerHeight(), [y, g] = f$(t, l) || [d, f], m = (g - y) / (f - d);
      if (h * m > p * 4) {
        const b = Ni(this, r, c), w = this.channelField(r === "x" ? "y" : "x").as, v = u.select().map((_) => _.as).filter((_) => _ !== c && _ !== w);
        return sW(u, b, c, w, y, g, p, v);
      }
    }
    return u.orderby(c);
  }
}
function sW(e, t, n, r, i, s, o, a = []) {
  const c = q`FLOOR(${o / (s - i)}::DOUBLE * (${t} - ${+i}::DOUBLE))::INTEGER`, u = (l) => St.from(e).select(l).groupby(c, a);
  return St.union(
    u([{ [n]: To(n), [r]: qg(r, n) }, ...a]),
    u([{ [n]: Io(n), [r]: Vg(r, n) }, ...a]),
    u([{ [n]: qg(n, r), [r]: To(r) }, ...a]),
    u([{ [n]: Vg(n, r), [r]: Io(r) }, ...a])
  ).orderby(a, n);
}
function M0(e, t = !1) {
  const n = new Float64Array(5), r = new Float64Array(4);
  oW(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 oW(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, h = Float64Array.of(i[0], i[1], 0, 0, 0, 0, 0, 0), f = 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 (h[p] = u[p] * h[p - 2] - u[p + 1] * h[p - 1], h[p + 1] = u[p] * h[p - 1] + u[p + 1] * h[p - 2], d = p - 2; 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 (d = 0; d <= p; d += 2)
      h[d] += i[p] * f[d] - i[p + 1] * f[d + 1], h[d + 1] += i[p] * f[d + 1] + i[p + 1] * f[d];
    for (f[p + 2] = u[p] * f[p] - u[p + 1] * f[p + 1], f[p + 3] = u[p] * f[p + 1] + u[p + 1] * f[p], d = p; 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 (p = 0; p < 4; ++p)
    d = p << 1, t[p] = h[d] / l, e[p + 1] = f[d + 2];
}
function aW(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 h = c.subarray(l);
    $0(e, n.subarray(l), r, 1, s, o, a, h);
  }
  for (let u = 0; u < r; ++u) {
    const l = c.subarray(u);
    $0(t, l, i, r, s, o, a, l);
  }
  return c;
}
function $0(e, t, n, r = 1, i = new Float64Array(n), s = new Float64Array(n), o = new Float64Array(5), a = i, c = cW) {
  const u = r * 2, l = r * 3, h = r * 4, f = 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 = h; 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 = f - 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 + h] - 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 cW(e, t, n, r, i, s, o, a, c, u) {
  const l = Math.abs(r) * n, h = r < 0 ? l + r : 0;
  let f, 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)
      f = h + r * d, f >= 0 && f < l && (e[p] += u[p - d] * t[f]);
  const y = t[h];
  if (y > 0)
    for (p = 0; p < a; ++p)
      e[p] += u[p] * y;
}
function uW(e, t) {
  return d$(new Float64Array(e), t);
}
function lW(e, t, n, r = []) {
  return r.length ? Object.values(fW(e * t, n, r)) : [{ grid: d$(new Float64Array(e * t), n) }];
}
function h$(e) {
  return typeof e.getChild == "function";
}
function d$(e, t) {
  if (h$(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 fW(e, t, n) {
  const r = {}, i = (s) => (r[s] || (r[s] = { key: s, grid: new Float64Array(e) })).grid;
  if (h$(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((h) => h.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;
}
function mn(e, t, n, r) {
  mi(n) ? (r = r || (() => e.requestUpdate()), n.addEventListener("value", (i) => (e[t] = i, r())), e[t] = n.value) : e[t] = n;
}
class p$ extends aa {
  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" ? a$ : c$), this.dim = a, mn(this, "bins", i), mn(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[ms];
  }
  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" ? Zc : Kc)(this, t), c = Ni(this, i);
    return hW(
      o$(r, s, [i]).where(t.concat(Qe(c, [o, a]))),
      S0(c, o, a, n),
      this.channelField("weight") ? "weight" : null
    );
  }
  queryResult(t) {
    return this.grid = uW(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 = M0(n * (t - 1) / u, c), h = $0(l, i, t), f = 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)
      f.push({
        [p]: y + b * g,
        [d]: h[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] = yi(o);
    return [{ type: t, data: n, options: s }];
  }
}
function hW(e, t, n) {
  const r = n ? `* ${n}` : "", i = e.clone().select({
    p: t,
    i: q`FLOOR(p)::INTEGER`,
    w: q`(FLOOR(p) + 1 - p)${r}`
  }), s = e.clone().select({
    p: t,
    i: q`FLOOR(p)::INTEGER + 1`,
    w: q`(p - FLOOR(p))${r}`
  });
  return St.from(St.unionAll(i, s)).select({ index: "i", value: As("w") }).groupby("index").having(Ov("value", 0));
}
class Vh extends aa {
  constructor(t, n, r) {
    const {
      bandwidth: i = 20,
      binType: s = "linear",
      binWidth: o = 2,
      binPad: a = 1,
      ...c
    } = r, u = dW(c);
    super(t, n, c, u$), this.densityMap = u, mn(this, "bandwidth", i, () => this.grids ? this.convolve().update() : null), mn(this, "binWidth", o), mn(this, "binType", s), mn(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[ms] && !n[ms];
  }
  query(t = []) {
    const { plot: n, binType: r, binPad: i, channels: s, densityMap: o, source: a } = this, [c, u] = this.extentX = Zc(this, t), [l, h] = this.extentY = Kc(this, t), [f, d] = this.bins = this.binDimensions(this), p = Ni(this, "x"), y = Ni(this, "y"), g = !!n.getAttribute("xReverse"), m = !!n.getAttribute("yReverse"), b = Ew(p, c, u, f, g, this.binPad), w = Ew(y, l, h, d, m, this.binPad), v = i ? [Qe(p, [c, u]), Qe(y, [l, h])] : [Al(c, p), $l(p, u), Al(l, y), $l(y, h)], _ = St.from(a.table).where(t.concat(v)), x = this.groupby = [];
    let $ = cs();
    for (const T of s)
      if (Object.hasOwn(T, "field")) {
        const { as: D, channel: M, field: A } = T;
        A.aggregate ? ($ = A, o[M] = !0) : M === "weight" ? $ = As(A) : M !== "x" && M !== "y" && (_.select({ [D]: A }), x.push(D));
      }
    return r === "linear" ? yW(_, b, w, $, f, x) : pW(_, b, w, $, f, x);
  }
  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 = lW(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: f }) => f.some((d) => d < 0)), l = M0(t * (a - 1) / s, u), h = M0(t * (c - 1) / o, u);
      this.kde = this.grids.map(({ key: f, grid: d }) => {
        const p = aW(l, h, d, n);
        return p.key = f, p;
      });
    }
    return this;
  }
  plotSpecs() {
    throw new Error("Unimplemented. Use a Grid2D mark subclass.");
  }
}
function dW(e) {
  const t = {};
  for (const n in e)
    e[n] === "density" && (delete e[n], t[n] = !0);
  return t;
}
function Ew(e, t, n, r, i, s) {
  const o = (r - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return i ? q`(${n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${t})${a}`;
}
function pW(e, t, n, r, i, s) {
  return e.select({
    index: q`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${i}`,
    value: r
  }).groupby("index", s);
}
function yW(e, t, n, r, i, s) {
  const o = r.column ? `* ${r.column}` : "", a = (f, d) => e.clone().select({ xp: t, yp: n, i: f, w: d }), c = a(
    q`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${i}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), u = a(
    q`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), l = a(
    q`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${i}`,
    q`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), h = a(
    q`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    q`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return St.from(St.unionAll(c, u, l, h)).select({ index: "i", value: As("w") }, s).groupby("index", s).having(Ov("value", 0));
}
class mW extends Vh {
  constructor(t, n) {
    const { type: r = "dot", binsX: i, binsY: s, ...o } = n;
    o.binPad = o.binPad ?? 0, super(r, t, o), mn(this, "binsX", i), mn(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, h = (c - a) / (s - n), f = (l - u) / (o - n), d = n ? 0 : 0.5;
    return this.data = gW(this.kde, t, a, u, h, f, 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 : yi(o);
    }
    for (const o in r)
      r[o] && (s[o] = "density");
    return [{ type: t, data: i, options: s }];
  }
}
function gW(e, t, n, r, i, s, o) {
  const a = 1 / (i * s), [c, u] = t, l = [];
  for (const h of e)
    for (let f = 0, d = 0; d < u; ++d)
      for (let p = 0; p < c; ++p, ++f)
        l.push({
          x: n + (p + o) * i,
          y: r + (d + o) * s,
          density: h[f] * a
        });
  return l;
}
function y$(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 h = o * i(e[u + l]) << 2;
      t[c + 0] = s[h + 0], t[c + 1] = s[h + 1], t[c + 2] = s[h + 2], t[c + 3] = s[h + 3];
    }
}
function Lf(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" ? bn(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 m$(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 g$(e = "black") {
  const { r: t, g: n, b: r } = bn(e);
  return (i) => ({ r: t, g: n, b: r, opacity: i });
}
class b$ extends Vh {
  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 f;
    const { bins: t, kde: n, groupby: r } = this, [i, s] = t, { canvas: o, ctx: a, img: c } = bW(this, i, s), u = wW(this), l = r.indexOf((f = this.channelField("fill")) == null ? void 0 : f.as), h = l < 0 ? [] : n.map(({ key: d }) => d[l]);
    return this.data = n.map((d) => {
      var y;
      const p = vW(this, h, (y = d.key) == null ? void 0 : y[l]);
      return y$(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 bW(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const r = m$(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 wW(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 $s({ x: { type: s, domain: i, range: [0, 1] } }).apply;
}
function vW(e, t, n, r = 1024) {
  const { densityMap: i, plot: s } = e, o = s.getAttribute("colorScheme");
  let a;
  if (i.fill) {
    if (o)
      try {
        return Lf(
          r,
          $s({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (c) {
        console.warn(c);
      }
  } else if (t.length) {
    const c = s.getAttribute("colorRange");
    a = $s({ color: {
      domain: t,
      range: c,
      scheme: o || (c ? void 0 : "tableau10")
    } }).apply(n);
  } else {
    const c = e.channelField("fill");
    a = hg(c == null ? void 0 : c.value) ? c.value : void 0;
  }
  return Lf(r, g$(a));
}
class _W extends b$ {
  constructor(t, n) {
    const { normalize: r = !0, ...i } = n;
    super(t, { bandwidth: 0, ...i }), mn(this, "normalize", r);
  }
  query(t = []) {
    const { plot: n, channels: r, normalize: i, source: s } = this, [o, a] = Zc(this, t), [c, u] = Kc(this, t), [l, h] = this.bins = this.binDimensions(this), f = Ni(this, "x"), d = Ni(this, "y"), p = !!n.getAttribute("xReverse"), y = !!n.getAttribute("yReverse"), g = S0(f, o, a, l, p, this.binPad), m = S0(d, c, u, h, y, this.binPad), b = St.from(s.table).where(xW(this, t)), w = this.groupby = [], v = [];
    for (const _ of r)
      if (Object.hasOwn(_, "field")) {
        const { channel: x, field: $ } = _;
        x === "z" ? (b.select({ [x]: $ }), v.push("z")) : x !== "x" && x !== "y" && (b.select({ [x]: $ }), w.push(x));
      }
    return SW(b, g, m, v, l, h, w, i);
  }
}
function xW(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" ? ps(o.children.filter((a) => i(a))) : o;
  return Array.isArray(t) ? t.filter((o) => i(o)).map((o) => s(o)) : s(t);
}
function SW(e, t, n, r, i, s, o = [], a = !0) {
  e.select({
    x: q`FLOOR(${t})::INTEGER`,
    y: q`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: q`(lead(x) OVER sw - x)`,
    dy: q`(lead(y) OVER sw - y)`
  }).window({ sw: q`${u}ORDER BY x ASC` }).qualify(ps(
    q`(x0 < ${i} OR x0 + dx < ${i})`,
    q`(y0 < ${s} OR y0 + dy < ${s})`,
    q`(x0 > 0 OR x0 + dx > 0)`,
    q`(y0 > 0 OR y0 + dy > 0)`
  )), h = St.select({ x: q`GREATEST(MAX(ABS(dx)), MAX(ABS(dy)))` }).from("pairs"), f = St.select({ i: q`UNNEST(range((${h})))::INTEGER` }), d = St.unionAll(
    St.select(c, {
      x: q`x0 + i`,
      y: q`y0 + ROUND(i * dy / dx::FLOAT)::INTEGER`
    }).from("pairs", "indices").where(q`ABS(dy) <= ABS(dx) AND i < ABS(dx)`),
    St.select(c, {
      x: q`x0 + ROUND(SIGN(dy) * i * dx / dy::FLOAT)::INTEGER`,
      y: q`y0 + SIGN(dy) * i`
    }).from("pairs", "indices").where(q`ABS(dy) > ABS(dx) AND i < ABS(dy)`),
    St.select(c, { x: "x0", y: "y0" }).from("pairs").where(Dv("dx"))
  ), p = ["x"].concat(c).join(", "), y = St.from("raster").select(
    c,
    "x",
    "y",
    a ? { w: q`1.0 / COUNT(*) OVER (PARTITION BY ${p})` } : null
  ).where(ps(Qe("x", [0, i]), Qe("y", [0, s])));
  return St.with({ pairs: l, indices: f, raster: d, points: y }).from("points").select(o, {
    index: q`x + y * ${i}::INTEGER`,
    value: a ? As("w") : cs()
  }).groupby("index", o);
}
class MW extends Vh {
  constructor(t, n) {
    const { thresholds: r = 10, ...i } = n;
    super("geo", t, i), mn(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 _ = te(r.map((x) => te(x)));
      a = Array.from({ length: a - 1 }, (x, $) => _ * ($ + 1) / a);
    }
    (n.fill || n.stroke) && this.plot.getAttribute("colorScale") !== "log" && this.plot.setAttribute("colorZero", !0);
    const [c, u] = t, [l, h] = o.getAttribute("xDomain"), [f, d] = o.getAttribute("yDomain"), p = (h - l) / c, y = (d - f) / u, g = +l, m = +f, b = (_) => g + _ * p, w = (_) => m + _ * y, v = Bl().size(t);
    return this.data = r.flatMap((_) => a.map((x) => {
      const $ = $W(v.contour(_, x), b, w);
      return s.forEach((T, D) => $[T] = _.key[D]), $.density = x, $;
    })), 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] = yi(o));
    }
    return r.fill && (s.fill = "density"), r.stroke && (s.stroke = "density"), [{ type: t, data: i, options: s }];
  }
}
function $W(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;
}
class AW extends aa {
  constructor(t, n) {
    const { type: r = "hexagon", binWidth: i = 20, ...s } = n;
    super(r, t, { r: i / 2, clip: !0, ...s }, u$), this.binWidth = i;
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[ms] && !n[ms];
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { plot: n, binWidth: r, channels: i, source: s } = this, [o, a] = Zc(this, t), [c, u] = Kc(this, t), l = 0.5 - n.getAttribute("marginLeft"), h = 0 - n.getAttribute("marginTop"), f = `${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 === "order" ? 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((D) => b.add(D)));
    const v = St.select({
      [g.as]: q`${o}::DOUBLE + ((x + 0.5 * (y & 1)) * ${f} + ${l})::DOUBLE / ${p}`,
      [m.as]: q`${u}::DOUBLE - (y * ${d} + ${h})::DOUBLE / ${y}`,
      ...w
    }).groupby("x", "y"), _ = `${p} * (${g.field} - ${o}::DOUBLE)`, x = `${y} * (${u}::DOUBLE - ${m.field})`, $ = St.select({
      py: q`(${x} - ${h}) / ${d}`,
      pj: q`ROUND(py)::INTEGER`,
      px: q`(${_} - ${l}) / ${f} - 0.5 * (pj & 1)`,
      pi: q`ROUND(px)::INTEGER`,
      tt: q`ABS(py-pj) * 3 > 1 AND (px-pi)**2 + (py-pj)**2 > (px - pi - 0.5 * CASE WHEN px < pi THEN -1 ELSE 1 END)**2 + (py - pj - CASE WHEN py < pj THEN -1 ELSE 1 END)**2`,
      x: q`CASE WHEN tt THEN (pi + (CASE WHEN px < pi THEN -0.5 ELSE 0.5 END) + (CASE WHEN pj & 1 <> 0 THEN 0.5 ELSE -0.5 END))::INTEGER ELSE pi END`,
      y: q`CASE WHEN tt THEN (pj + CASE WHEN py < pj THEN -1 ELSE 1 END)::INTEGER ELSE pj END`
    }).select(Array.from(b)).from(s.table).where(Ml(g.field), Ml(m.field), t);
    return v.from($);
  }
}
class IW extends Vh {
  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, h]] = t, [f, d] = this.bins, p = Ni(this, "x"), y = Ni(this, "y"), g = !!n.getAttribute("xReverse"), m = !!n.getAttribute("yReverse"), b = Nw(p, c, u, f, g, i), w = Nw(y, l, h, d, m, i), v = i ? [Qe(p, [c, u]), Qe(y, [l, h])] : [Al(c, p), $l(p, u), Al(l, y), $l(y, h)], _ = St.from(a.table).where(v), x = this.groupby = [];
    let $ = cs();
    for (const T of s)
      if (Object.hasOwn(T, "field")) {
        const { channel: D, field: M } = T;
        M.aggregate ? ($ = M, o[D] = !0) : D === "weight" ? $ = As(M) : D !== "x" && D !== "y" && (_.select({ [D]: M }), x.push(D));
      }
    return r === "linear" ? FW(_, b, w, $, f, x) : OW(_, b, w, $, f, x);
  }
  async requestTiles() {
    const t = An();
    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] = Zc(this, this._filter), [h, f] = Kc(this, this._filter), d = l - u, p = f - h, y = Math.floor((u - s) * (a - n) / d), g = Math.floor((h - o) * (c - n) / p), m = (M, A) => [
      [s + M * d, s + (M + 1) * d],
      [o + A * p, o + (A + 1) * p]
    ], b = Math.floor((u - s) / d), w = r ? Lw((l - s) / d) : b, v = Math.floor((h - o) / p), _ = i ? Lw((f - o) / p) : v, x = [];
    for (let M = b; M <= w; ++M)
      for (let A = v; A <= _; ++A)
        x.push([M, A]);
    const $ = x.map(
      ([M, A]) => t.query(this.tileQuery(m(M, A)))
    ), T = [];
    if (r)
      for (let M = v; M <= _; ++M)
        T.push([w + 1, M]), T.push([b - 1, M]);
    if (i) {
      const M = r ? b - 1 : b, A = r ? w + 1 : w;
      for (let L = M; L <= A; ++L)
        T.push([L, _ + 1]), T.push([L, v - 1]);
    }
    this.prefetch = T.map(
      ([M, A]) => t.prefetch(this.tileQuery(m(M, A)))
    );
    const D = await Promise.all($);
    this.grids = [{ grid: TW(a, c, y, g, x, D) }], this.convolve().update();
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var f;
    const { bins: t, kde: n, groupby: r } = this, [i, s] = t, { canvas: o, ctx: a, img: c } = NW(this, i, s), u = LW(this), l = r.indexOf((f = this.channelField("fill")) == null ? void 0 : f.as), h = l < 0 ? [] : n.map(({ key: d }) => d[l]);
    return this.data = n.map((d) => {
      var y;
      const p = DW(this, h, (y = d.key) == null ? void 0 : y[l]);
      return y$(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 TW(e, t, n, r, i, s) {
  const o = new Float64Array(e * t);
  return s.forEach((a, c) => {
    const [u, l] = i[c], h = u * e - n, f = l * t - r;
    EW(e, t, o, a, h, f);
  }), o;
}
function EW(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], h = i + l % e, f = s + Math.floor(l / e);
    0 <= h && h < e && 0 <= f && f < t && (n[h + f * e] = c[u]);
  }
}
function NW(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const r = m$(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 LW(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 $s({ x: { type: s, domain: i, range: [0, 1] } }).apply;
}
function DW(e, t, n, r = 1024) {
  const { densityMap: i, plot: s } = e, o = s.getAttribute("colorScheme");
  let a;
  if (i.fill) {
    if (o)
      try {
        return Lf(
          r,
          $s({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (c) {
        console.warn(c);
      }
  } else if (t.length) {
    const c = s.getAttribute("colorRange");
    a = $s({ color: {
      domain: t,
      range: c,
      scheme: o || (c ? void 0 : "tableau10")
    } }).apply(n);
  } else {
    const c = e.channelField("fill");
    a = hg(c == null ? void 0 : c.value) ? c.value : void 0;
  }
  return Lf(r, g$(a));
}
function Nw(e, t, n, r, i, s) {
  const o = (r - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return i ? q`(${n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${t})${a}`;
}
function OW(e, t, n, r, i, s) {
  return e.select({
    index: q`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${i}`,
    value: r
  }).groupby("index", s);
}
function FW(e, t, n, r, i, s) {
  const o = r.column ? `* ${r.column}` : "", a = (f, d) => e.clone().select({ xp: t, yp: n, i: f, w: d }), c = a(
    q`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${i}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), u = a(
    q`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), l = a(
    q`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${i}`,
    q`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), h = a(
    q`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    q`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return St.from(St.unionAll(c, u, l, h)).select({ index: "i", value: As("w") }, s).groupby("index", s).having(T5("value", 0));
}
function Lw(e) {
  const t = Math.floor(e);
  return t === e ? t - 1 : t;
}
function kW(e, t, n) {
  var r = 1e-8, i = t - 1, s = n - 1, o = 0, a, c, u, l, h, f, 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, h = Math.exp(n * c) / n, g = l + h, e < l / g ? d = Math.pow(t * g * e, 1 / t) : d = 1 - Math.pow(n * g * (1 - e), 1 / n)), m = -mo(t) - mo(n) + mo(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (f = BW(d, t, n) - e, l = Math.exp(i * Math.log(d) + s * Math.log(1 - d) + m), h = f / l, d -= l = h / (1 - 0.5 * Math.min(1, h * (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 BW(e, t, n) {
  var r = e === 0 || e === 1 ? 0 : Math.exp(mo(t + n) - mo(t) - mo(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? r * Dw(e, t, n) / t : 1 - r * Dw(1 - e, n, t) / n;
}
function Dw(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, h, f, d;
  for (Math.abs(u) < r && (u = r), u = 1 / u, d = u; i <= 100 && (l = 2 * i, h = i * (n - i) * e / ((a + l) * (t + l)), u = 1 + h * u, Math.abs(u) < r && (u = r), c = 1 + h / c, Math.abs(c) < r && (c = r), u = 1 / u, d *= u * c, h = -(t + i) * (s + i) * e / ((t + l) * (o + l)), u = 1 + h * u, Math.abs(u) < r && (u = r), c = 1 + h / c, Math.abs(c) < r && (c = r), u = 1 / u, f = u * c, d *= f, !(Math.abs(f - 1) < 3e-7)); i++)
    ;
  return d;
}
function mo(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 RW(e, t) {
  var n = kW(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 CW extends aa {
  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;
    mn(this, "ci", r, o), mn(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: K5(r, n),
      slope: J5(r, n),
      n: Q5(r, n),
      ssy: tI(r, n),
      ssx: eI(r, n),
      xm: nI(r, n),
      x0: Yg(To(n).where(Ml(r))),
      x1: Yg(Io(n).where(Ml(r)))
    }).select(i).groupby(i);
  }
  queryResult(t) {
    return this.modelFit = Array.from(t), this.lineData = this.modelFit.flatMap((n) => PW(n)), this.confidenceBand();
  }
  confidenceBand() {
    const { ci: t, modelFit: n, precision: r, plot: i } = this, s = i.innerWidth();
    return this.areaData = t ? n.flatMap((o) => zW(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 = yi(a);
          break;
        case "strokeOpacity":
          s.strokeOpacity = yi(a);
          break;
        case "fillOpacity":
          o.fillOpacity = yi(a);
          break;
        default:
          s[a.channel] = o[a.channel] = yi(a);
          break;
      }
    return [
      ...i ? [{ type: "areaY", data: n, options: o }] : [],
      { type: "line", data: t, options: s }
    ];
  }
}
function PW(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 zW(e, t, n, r) {
  const { x0: i, x1: s, xm: o, intercept: a, slope: c, n: u, ssx: l, ssy: h, ...f } = n, d = t * (s - i) / r, p = RW((1 - e) / 2, u - 2) * Math.sqrt(h / (u - 2));
  return Ze(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, ...f };
  });
}
const UW = /* @__PURE__ */ new Set([
  "frame",
  "axisX",
  "axisY",
  "axisFx",
  "axisFy",
  "gridX",
  "gridY",
  "gridFx",
  "gridFy",
  "hexgrid",
  "graticule",
  "sphere"
]);
function et(e, t, n) {
  arguments.length === 2 && (n = t, t = UW.has(e) ? null : [{}]);
  const r = e.startsWith("area") || e.startsWith("line") ? iW : aa;
  return dg(r, e, t, n);
}
function dg(e, t, n, r) {
  return (i) => {
    i.addMark(new e(t, n, r));
  };
}
function Ns(e, t, n) {
  return (r) => {
    r.addMark(new e(t, n));
  };
}
const jW = (...e) => et("area", ...e), qW = (...e) => et("areaX", ...e), VW = (...e) => et("areaY", ...e), YW = (...e) => et("line", ...e), WW = (...e) => et("lineX", ...e), XW = (...e) => et("lineY", ...e), GW = (...e) => et("barX", ...e), HW = (...e) => et("barY", ...e), ZW = (...e) => et("cell", ...e), KW = (...e) => et("cellX", ...e), JW = (...e) => et("cellY", ...e), QW = (...e) => et("rect", ...e), tX = (...e) => et("rectX", ...e), eX = (...e) => et("rectY", ...e), nX = (...e) => et("dot", ...e), rX = (...e) => et("dotX", ...e), iX = (...e) => et("dotY", ...e), sX = (...e) => et("circle", ...e), oX = (...e) => et("hexagon", ...e), aX = (...e) => et("text", ...e), cX = (...e) => et("textX", ...e), uX = (...e) => et("textY", ...e), lX = (...e) => et("ruleX", ...e), fX = (...e) => et("ruleY", ...e), hX = (...e) => et("tickX", ...e), dX = (...e) => et("tickY", ...e), pX = (...e) => et("vector", ...e), yX = (...e) => et("vectoX", ...e), mX = (...e) => et("vectorY", ...e), gX = (...e) => et("spike", ...e), bX = (...e) => et("image", ...e), wX = (...e) => dg(p$, "areaX", ...e), vX = (...e) => dg(p$, "areaY", ...e), _X = (...e) => Ns(mW, ...e), xX = (...e) => Ns(_W, ...e), SX = (...e) => Ns(MW, ...e), MX = (...e) => Ns(b$, ...e), $X = (...e) => Ns(IW, ...e), AX = (...e) => Ns(AW, ...e), IX = (...e) => et("hexgrid", ...e), TX = (...e) => Ns(CW, ...e), EX = (...e) => et("voronoi", ...e), NX = (...e) => et("voronoiMesh", ...e), LX = (...e) => et("delaunayLink", ...e), DX = (...e) => et("delaunayMesh", ...e), OX = (...e) => et("hull", ...e), FX = (...e) => et("arrow", ...e), kX = (...e) => et("link", ...e), BX = (...e) => et("frame", ...e), RX = (...e) => et("axisX", ...e), CX = (...e) => et("axisY", ...e), PX = (...e) => et("axisFx", ...e), zX = (...e) => et("axisFy", ...e), UX = (...e) => et("gridX", ...e), jX = (...e) => et("gridY", ...e), qX = (...e) => et("gridFx", ...e), VX = (...e) => et("gridFy", ...e), YX = (...e) => et("geo", ...e), WX = (...e) => et("sphere", ...e), XX = (...e) => et("graticule", ...e), GX = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  area: jW,
  areaX: qW,
  areaY: VW,
  arrow: FX,
  axisFx: PX,
  axisFy: zX,
  axisX: RX,
  axisY: CX,
  barX: GW,
  barY: HW,
  cell: ZW,
  cellX: KW,
  cellY: JW,
  circle: sX,
  contour: SX,
  delaunayLink: LX,
  delaunayMesh: DX,
  denseLine: xX,
  density: _X,
  densityX: wX,
  densityY: vX,
  dot: nX,
  dotX: rX,
  dotY: iX,
  frame: BX,
  geo: YX,
  graticule: XX,
  gridFx: qX,
  gridFy: VX,
  gridX: UX,
  gridY: jX,
  hexagon: oX,
  hexbin: AX,
  hexgrid: IX,
  hull: OX,
  image: bX,
  line: YW,
  lineX: WW,
  lineY: XW,
  link: kX,
  raster: MX,
  rasterTile: $X,
  rect: QW,
  rectX: tX,
  rectY: eX,
  regressionY: TX,
  ruleX: lX,
  ruleY: fX,
  sphere: WX,
  spike: gX,
  text: aX,
  textX: cX,
  textY: uX,
  tickX: hX,
  tickY: dX,
  vector: pX,
  vectorX: yX,
  vectorY: mX,
  voronoi: EX,
  voronoiMesh: NX
}, Symbol.toStringTag, { value: "Module" }));
function HX(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 pg(e) {
  const t = {};
  for (const n in e)
    t[HX(n)] = e[n];
  return t;
}
class ZX {
  constructor(t, {
    selection: n,
    channels: r = {}
  }) {
    this.mark = t, this.selection = n;
    const i = Object.entries(pg(r));
    this.channels = i.length ? i : [["opacity", 0.2]], this.selection.addEventListener("value", Cv(() => 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 KX(s, o);
    for (let c = 0; c < n.length; ++c) {
      const u = n[c], l = i[c], h = a(u.__data__);
      for (let f = 0; f < r.length; ++f) {
        const [d, p] = r[f];
        u.setAttribute(d, h ? l[f] : p);
      }
    }
  }
}
async function KX(e, t) {
  var c, u;
  const n = t == null ? void 0 : t.predicate(e);
  if (!n || n.length === 0)
    return () => !0;
  const r = { __: ps(n) }, i = e.query((c = e.filterBy) == null ? void 0 : c.predicate(e)), s = i.groupby().length ? i.select(r) : i.$select(r), o = await An().query(s), a = (u = o.getChild) == null ? void 0 : u.call(o, "__");
  return a ? (l) => a.get(l) : (l) => o[l].__;
}
class w$ {
  constructor(t, {
    selection: n,
    channels: r
  }) {
    this.value = null, this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.channels = r.map((i) => {
      var o;
      const s = i === "color" ? ["fill", "stroke"] : i === "x" ? ["x", "x1", "x2"] : i === "y" ? ["y", "y1", "y2"] : [i];
      for (let a = 0; a < s.length; ++a) {
        const c = t.channelField(s[a]);
        if (c)
          return {
            field: ((o = c.field) == null ? void 0 : o.basis) || c.field,
            as: c.as
          };
      }
      throw new Error(`Missing channel: ${i}`);
    });
  }
  clause(t) {
    const { channels: n, clients: r } = this;
    let i = null;
    if (t) {
      const s = t.map((o) => {
        const a = o.map((c, u) => Cf(n[u].field, $c(c)));
        return a.length > 1 ? ps(a) : a[0];
      });
      i = s.length > 1 ? Nv(s) : s[0];
    }
    return {
      source: this,
      schema: { type: "point" },
      clients: 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((h) => l[h.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, h = u.target;
      let f = null;
      if (JX(c, h)) {
        const d = r(h);
        u.shiftKey && (l != null && l.length) ? (f = l.filter((p) => A0(p, d)), f.length === l.length && f.push(d)) : (l == null ? void 0 : l.length) === 1 && !A0(l[0], d) ? f = null : f = [d];
      }
      this.value = f, QX(l, f) && o.update(this.clause(f));
    }), t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause([this.channels.map(() => 0)]));
    });
  }
}
function JX(e, t) {
  var n;
  return e.has(t) || e.has(t.parentNode) || e.has((n = t.parentNode) == null ? void 0 : n.parentNode);
}
function QX(e, t) {
  return e == null || t == null ? e != null || t != null : e.length !== t.length || e.some((n, r) => A0(n, t[r]));
}
function A0(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;
}
function yg(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 tG() {
  return yg(j9());
}
function eG() {
  return yg(z9());
}
function nG() {
  return yg(U9());
}
const Ow = 1e-12;
function I0(e, t) {
  return e === t || e && t && Math.abs(e[0] - t[0]) < Ow && Math.abs(e[1] - t[1]) < Ow || !1;
}
function Vo(e, t) {
  var r;
  const n = (r = e.channelField(t)) == null ? void 0 : r.field;
  return (n == null ? void 0 : n.basis) || n;
}
function T0(e, t, n = 1) {
  return t.invert(n * Math.floor(e / n));
}
function v$() {
  const e = this, t = e.getScreenCTM;
  let n;
  e.getScreenCTM = () => e.isConnected ? n = t.call(e) : n;
}
class _$ {
  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 || Vo(t, [n, n + "1", n + "2"]), this.style = a && pg(a), this.brush = n === "y" ? nG() : eG(), 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) => T0(r, this.scale, this.pixelSize)).sort((r, i) => r - i)), I0(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 ? Qe(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([[pe(s), pe(o)], [te(s), te(o)]]);
    const a = zt(t).selectAll('g[aria-label="facet"]'), c = a.size() ? a : zt(t);
    if (this.g = c.append("g").attr("class", `interval-${r}`).each(v$).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 h in i)
        l.attr(h, i[h]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
const Fu = (e, t) => e - t;
class rG {
  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 || Vo(t, ["x", "x1", "x2"]), this.yfield = i || Vo(t, ["y", "y1", "y2"]), this.style = a && pg(a), this.brush = tG(), 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) => T0(l, i, r)).sort(Fu), a = [c[1], u[1]].map((l) => T0(l, s, r)).sort(Fu);
    }
    (!I0(o, n == null ? void 0 : n[0]) || !I0(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 ? ps(Qe(i, t[0]), Qe(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([[pe(o), pe(a)], [te(o), te(a)]]);
    const c = zt(t).selectAll('g[aria-label="facet"]'), u = c.size() ? c : zt(t);
    if (this.g = u.append("g").attr("class", "interval-xy").each(v$).call(n), r) {
      const l = this.g.selectAll("rect.selection");
      for (const h in r)
        l.attr(h, r[h]);
    }
    if (this.value) {
      const [l, h] = this.value[0].map(i.apply).sort(Fu), [f, d] = this.value[1].map(s.apply).sort(Fu);
      this.g.call(n.moveSilent, [[l, f], [h, d]]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
const Fw = (e, t) => e - t;
class iG {
  constructor(t, {
    x: n = new di(),
    y: r = new di(),
    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 || Vo(t, ["x", "x1", "x2"]), this.yfield = s || Vo(t, ["y", "y1", "y2"]), this.zoom = Jd(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 = sG(t, this.xscale);
      this.xsel.update(this.clause(n, this.xfield, this.xscale));
    }
    if (this.pany) {
      const n = oG(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 ? Qe(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(Fw), c = this.yscale.range.slice().sort(Fw), u = Jd(n, [-1 / 0, 1 / 0], a), l = Jd(r, [-1 / 0, 1 / 0], c), h = Fk().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 tr(1, 0, 0)).on("zoom", ({ transform: f }) => this.publish(f));
    if (zt(i).call(h), n || r) {
      let f = !1;
      i.addEventListener("mouseenter", () => {
        if (!f) {
          if (f = !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", () => f = !1);
    }
  }
}
function Jd(e, t, n) {
  return e ? Array.isArray(e) ? e : t : n;
}
function sG(e, t) {
  return t.range.map(e.invertX, e).map(t.invert, t);
}
function oG(e, t) {
  return t.range.map(e.invertY, e).map(t.invert, t);
}
class x$ {
  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 || Vo(t, [r]);
  }
  clause(t) {
    const { clients: n, field: r } = this, i = t ? Cf(r, $c(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 = zt(t).selectAll('g[aria-label="facet"]'), u = c.size() ? c : zt(t), l = t.scale(i), h = !ys(s);
    u.on("pointerdown pointermove", function(f) {
      const [d, p] = _n(f, this), y = aG(o, a, l.invert(i === "x" ? d : p));
      s.update(h ? y : n.clause(y));
    }), !h && t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause(0));
    });
  }
}
function aG(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;
}
function zi(e, t) {
  return (n) => {
    const r = n.marks[n.marks.length - 1];
    n.addInteractor(new e(r, t));
  };
}
function cG({ by: e, ...t }) {
  return zi(ZX, { selection: e, channels: t });
}
function Yh({ as: e, ...t }) {
  return zi(w$, { ...t, selection: e });
}
function uG({ as: e }) {
  return Yh({ as: e, channels: ["x"] });
}
function lG({ as: e }) {
  return Yh({ as: e, channels: ["y"] });
}
function fG({ as: e }) {
  return Yh({ as: e, channels: ["color"] });
}
function hG({ as: e, ...t }) {
  return zi(x$, { ...t, selection: e, channel: "x" });
}
function dG({ as: e, ...t }) {
  return zi(x$, { ...t, selection: e, channel: "y" });
}
function pG({ as: e, ...t }) {
  return zi(_$, { ...t, selection: e, channel: "x" });
}
function yG({ as: e, ...t }) {
  return zi(_$, { ...t, selection: e, channel: "y" });
}
function mG({ as: e, ...t }) {
  return zi(rG, { ...t, selection: e });
}
function ca(e) {
  return zi(iG, e);
}
function gG(e = {}) {
  return ca({ ...e, zoom: !1 });
}
function bG(e = {}) {
  return ca({ ...e, zoom: !1, pany: !1 });
}
function wG(e = {}) {
  return ca({ ...e, zoom: !1, panx: !1 });
}
function vG(e = {}) {
  return ca(e);
}
function _G(e = {}) {
  return ca({ ...e, pany: !1 });
}
function xG(e = {}) {
  return ca({ ...e, panx: !1 });
}
const SG = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  highlight: cG,
  intervalX: pG,
  intervalXY: mG,
  intervalY: yG,
  nearestX: hG,
  nearestY: dG,
  pan: gG,
  panX: bG,
  panY: wG,
  panZoom: vG,
  panZoomX: _G,
  panZoomY: xG,
  toggle: Yh,
  toggleColor: fG,
  toggleX: uG,
  toggleY: lG
}, Symbol.toStringTag, { value: "Module" }));
class kw {
  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 = MG(t, n);
    this.selection && i && (this.handler = new w$(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 MG({ 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;
}
function mg(e, t = {}) {
  if (t.for) {
    const { for: n, ...r } = t, i = new kw(e, r), s = typeof n, o = (a) => a.addLegend(i, !1);
    return s === "string" ? lg.request(n, o) : n.value && o(n.value), i.element;
  } else
    return (n) => n.addLegend(new kw(e, t));
}
const $G = (e) => mg("color", e), AG = (e) => mg("opacity", e), IG = (e) => mg("symbol", e), TG = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  colorLegend: $G,
  opacityLegend: AG,
  symbolLegend: IG
}, Symbol.toStringTag, { value: "Module" }));
function S$({ 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 EG(...e) {
  return S$({ direction: "vertical" }, e.flat());
}
function NG(...e) {
  return S$({ direction: "horizontal" }, e.flat());
}
function M$({ 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 LG(e) {
  return M$({ dim: "height", size: e });
}
function DG(e) {
  return M$({ dim: "width", size: e });
}
function OG(e) {
  return e;
}
function FG(e) {
  if (e == null)
    return OG;
  var t, n, r = e.scale[0], i = e.scale[1], s = e.translate[0], o = e.translate[1];
  return function(a, c) {
    c || (t = n = 0);
    var u = 2, l = a.length, h = new Array(l);
    for (h[0] = (t += a[0]) * r + s, h[1] = (n += a[1]) * i + o; u < l; )
      h[u] = a[u], ++u;
    return h;
  };
}
function kG(e, t) {
  for (var n, r = e.length, i = r - t; i < --r; )
    n = e[i], e[i++] = e[r], e[r] = n;
}
function BG(e, t) {
  return typeof t == "string" && (t = e.objects[t]), t.type === "GeometryCollection" ? { type: "FeatureCollection", features: t.geometries.map(function(n) {
    return Bw(e, n);
  }) } : Bw(e, t);
}
function Bw(e, t) {
  var n = t.id, r = t.bbox, i = t.properties == null ? {} : t.properties, s = $$(e, t);
  return n == null && r == null ? { type: "Feature", properties: i, geometry: s } : r == null ? { type: "Feature", id: n, properties: i, geometry: s } : { type: "Feature", id: n, bbox: r, properties: i, geometry: s };
}
function $$(e, t) {
  var n = FG(e.transform), r = e.arcs;
  function i(l, h) {
    h.length && h.pop();
    for (var f = r[l < 0 ? ~l : l], d = 0, p = f.length; d < p; ++d)
      h.push(n(f[d], d));
    l < 0 && kG(h, p);
  }
  function s(l) {
    return n(l);
  }
  function o(l) {
    for (var h = [], f = 0, d = l.length; f < d; ++f)
      i(l[f], h);
    return h.length < 2 && h.push(h[0]), h;
  }
  function a(l) {
    for (var h = o(l); h.length < 4; )
      h.push(h[0]);
    return h;
  }
  function c(l) {
    return l.map(a);
  }
  function u(l) {
    var h = l.type, f;
    switch (h) {
      case "GeometryCollection":
        return { type: h, geometries: l.geometries.map(u) };
      case "Point":
        f = s(l.coordinates);
        break;
      case "MultiPoint":
        f = l.coordinates.map(s);
        break;
      case "LineString":
        f = o(l.arcs);
        break;
      case "MultiLineString":
        f = l.arcs.map(o);
        break;
      case "Polygon":
        f = c(l.arcs);
        break;
      case "MultiPolygon":
        f = l.arcs.map(c);
        break;
      default:
        return null;
    }
    return { type: h, coordinates: f };
  }
  return u(t);
}
function RG(e, t) {
  var n = {}, r = {}, i = {}, s = [], o = -1;
  t.forEach(function(u, l) {
    var h = e.arcs[u < 0 ? ~u : u], f;
    h.length < 3 && !h[1][0] && !h[1][1] && (f = t[++o], t[o] = u, t[l] = f);
  }), t.forEach(function(u) {
    var l = a(u), h = l[0], f = l[1], d, p;
    if (d = i[h])
      if (delete i[d.end], d.push(u), d.end = f, p = r[f]) {
        delete r[p.start];
        var y = p === d ? d : d.concat(p);
        r[y.start = d.start] = i[y.end = p.end] = y;
      } else
        r[d.start] = i[d.end] = d;
    else if (d = r[f])
      if (delete r[d.start], d.unshift(u), d.start = h, p = i[h]) {
        delete i[p.end];
        var g = p === d ? d : p.concat(d);
        r[g.start = p.start] = i[g.end = d.end] = g;
      } else
        r[d.start] = i[d.end] = d;
    else
      d = [u], r[d.start = h] = i[d.end = f] = d;
  });
  function a(u) {
    var l = e.arcs[u < 0 ? ~u : u], h = l[0], f;
    return e.transform ? (f = [0, 0], l.forEach(function(d) {
      f[0] += d[0], f[1] += d[1];
    })) : f = l[l.length - 1], u < 0 ? [f, h] : [h, f];
  }
  function c(u, l) {
    for (var h in u) {
      var f = u[h];
      delete l[f.start], delete f.start, delete f.end, f.forEach(function(d) {
        n[d < 0 ? ~d : d] = 1;
      }), s.push(f);
    }
  }
  return c(i, r), c(r, i), t.forEach(function(u) {
    n[u < 0 ? ~u : u] || s.push([u]);
  }), s;
}
function CG(e) {
  return $$(e, PG.apply(this, arguments));
}
function PG(e, t, n) {
  var r, i, s;
  if (arguments.length > 1)
    r = zG(e, t, n);
  else
    for (i = 0, r = new Array(s = e.arcs.length); i < s; ++i)
      r[i] = i;
  return { type: "MultiLineString", arcs: RG(e, r) };
}
function zG(e, t, n) {
  var r = [], i = [], s;
  function o(h) {
    var f = h < 0 ? ~h : h;
    (i[f] || (i[f] = [])).push({ i: h, g: s });
  }
  function a(h) {
    h.forEach(o);
  }
  function c(h) {
    h.forEach(a);
  }
  function u(h) {
    h.forEach(c);
  }
  function l(h) {
    switch (s = h, h.type) {
      case "GeometryCollection":
        h.geometries.forEach(l);
        break;
      case "LineString":
        a(h.arcs);
        break;
      case "MultiLineString":
      case "Polygon":
        c(h.arcs);
        break;
      case "MultiPolygon":
        u(h.arcs);
        break;
    }
  }
  return l(t), i.forEach(n == null ? function(h) {
    r.push(h[0].i);
  } : function(h) {
    n(h[0].g, h[h.length - 1].g) && r.push(h[0].i);
  }), r;
}
function UG(e) {
  const t = typeof e;
  return t === "object" ? e == null ? void 0 : e.param : t === "string" ? jG(e) : null;
}
function jG(e) {
  return (e == null ? void 0 : e[0]) === "$" ? e.slice(1) : null;
}
function Qd(e) {
  return [e].flat();
}
function go(e) {
  return Array.isArray(e);
}
function A$(e) {
  return e !== null && typeof e == "object" && !go(e);
}
function Rw(e) {
  const t = typeof e;
  return t === "number" || t === "string";
}
function gi(e) {
  return typeof e == "string";
}
function Jc(e) {
  return typeof e == "function";
}
function ur(e, t) {
  throw Object.assign(Error(e), { data: t });
}
function qG(e, t, n) {
  t = VG(t, n);
  const r = n.dataFormats.get(t.type);
  if (r)
    return r(e, t, n);
  ur("Unrecognized data format type.", t);
}
function VG(e, t) {
  return go(e) && (e = { type: "json", data: e }), gi(e) && (e = { type: "table", query: e }), {
    ...e,
    type: YG(e),
    file: XG(e, t)
  };
}
function YG(e) {
  return e.type || WG(e.file) || "table";
}
function WG(e) {
  const t = e == null ? void 0 : e.lastIndexOf(".");
  return t > 0 ? e.slice(t + 1) : null;
}
function XG({ file: e }, t) {
  return e && t.baseURL ? new URL(e, t.baseURL).toString() : e;
}
function GG(e, t) {
  const { query: n, type: r, ...i } = t;
  if (n)
    return Q0(e, n, i);
}
function HG(e, t) {
  const { file: n, type: r, ...i } = t;
  return fI(e, n, i);
}
function ZG(e, t) {
  const { file: n, type: r, ...i } = t;
  return uI(e, n, i);
}
function KG(e, t) {
  const { data: n, file: r, type: i, ...s } = t;
  return n ? hI(e, n, s) : lI(e, r, s);
}
const JG = { menu: tT, search: iT, slider: aT, table: hT }, QG = /* @__PURE__ */ new Map([
  ["intersect", () => di.intersect()],
  ["crossfilter", () => di.crossfilter()],
  ["union", () => di.union()],
  ["single", () => di.single()],
  ["value", ({ date: e, value: t }, n) => Array.isArray(t) ? Cr.array(t.map((r) => n.maybeParam(r))) : Cr.value(ey(e, t))]
]), tH = /* @__PURE__ */ new Map([
  ["plot", { type: go, parse: T$ }],
  ["mark", { type: gi, parse: bH }],
  ["legend", { type: gi, parse: E$ }],
  ["hconcat", { type: go, parse: gH }],
  ["vconcat", { type: go, parse: mH }],
  ["hspace", { type: Rw, parse: dH }],
  ["vspace", { type: Rw, parse: pH }],
  ["input", { type: gi, parse: yH }]
]), eH = /* @__PURE__ */ new Map([
  ["csv", ZG],
  ["json", KG],
  ["geojson", lH],
  ["topojson", fH],
  ["parquet", HG],
  ["table", GG]
]), nH = /* @__PURE__ */ new Map([
  ["avg", X5],
  ["bin", Zg],
  ["count", cs],
  ["dateMonth", iI],
  ["dateMonthDay", sI],
  ["dateDay", oI],
  ["bin", Zg],
  ["max", Io],
  ["median", G5],
  ["min", To],
  ["mode", Z5],
  ["quantile", H5],
  ["sum", As],
  ["row_number", F5],
  ["rank", k5],
  ["dense_rank", B5],
  ["percent_rank", R5],
  ["cume_dist", C5],
  ["ntile", P5],
  ["lag", z5],
  ["lead", U5],
  ["first_value", j5],
  ["last_value", q5],
  ["nth_value", V5]
]), rH = new Map(Object.entries(GX)), iH = new Map(Object.entries(JG)), sH = new Map(Object.entries(TG)), oH = new Map(Object.entries(KY)), aH = new Map(Object.entries(SG));
function cH(e, t) {
  return e = gi(e) ? JSON.parse(e) : e, new uH(t).parse(e);
}
class uH {
  constructor({
    specParsers: t = tH,
    paramParsers: n = QG,
    dataFormats: r = eH,
    transforms: i = nH,
    attributes: s = oH,
    interactors: o = aH,
    legends: a = sH,
    inputs: c = iH,
    marks: u = rH,
    params: l = [],
    datasets: h = [],
    baseURL: f = null
  } = {}) {
    this.specParsers = t, this.paramParsers = n, this.dataFormats = r, this.transforms = i, this.attributes = s, this.interactors = o, this.legends = a, this.inputs = c, this.marks = u, this.params = new Map(l), this.datasets = new Map(h), this.baseURL = f, this.postQueue = [];
  }
  after(t) {
    this.postQueue.push(t);
  }
  maybeParam(t, n = () => Cr.value()) {
    const { params: r } = this, i = UG(t);
    if (i) {
      if (r.has(i))
        return r.get(i);
      {
        const s = n();
        return r.set(i, s), s;
      }
    }
    return t;
  }
  maybeSelection(t) {
    return this.maybeParam(t, () => di.intersect());
  }
  maybeTransform(t) {
    if (A$(t))
      return t.expr ? MH(t, this) : $H(t, this);
  }
  async parse(t) {
    const { meta: n, data: r = {}, plotDefaults: i = {}, params: s, ...o } = t;
    for (const c in r) {
      const u = await qG(c, r[c], this);
      u != null && u.data ? this.datasets.set(c, u.data) : u && await An().exec(u);
    }
    this.plotDefaults = Object.keys(i).map((c) => N$(i, c, this));
    for (const c in s)
      this.params.set(c, hH(s[c], this));
    const a = gg(o, this);
    return this.postQueue.forEach((c) => c()), this.postQueue = [], this.plotDefaults = {}, a;
  }
}
async function I$(e) {
  const { data: t, file: n } = e;
  return t || await fetch(n).then((r) => r.json());
}
async function lH(e, t) {
  return { data: await I$(t) };
}
async function fH(e, t) {
  const n = await I$(t);
  let r;
  if (t.feature)
    r = BG(n, n.objects[t.feature]);
  else {
    const i = t.mesh ? n.objects[t.mesh] : void 0, s = {
      interior: (o, a) => o !== a,
      exterior: (o, a) => o === a
    }[t.filter];
    r = CG(n, i, s);
  }
  return { data: r && r.features || [r] };
}
function hH(e, t) {
  e = A$(e) ? e : { value: e };
  const { select: n = "value" } = e, r = t.paramParsers.get(n);
  return r || ur(`Unrecognized param type: ${n}`, e), r(e, t);
}
function gg(e, t) {
  for (const [n, { type: r, parse: i }] of t.specParsers) {
    const s = e[n];
    if (s != null) {
      if (r(s))
        return i(e, t);
      ur(`Invalid property type: ${n}`, e);
    }
  }
  ur("Invalid specification.", e);
}
function dH(e) {
  return DG(e.hspace);
}
function pH(e) {
  return LG(e.vspace);
}
function yH(e, t) {
  const { input: n, ...r } = e, i = t.inputs.get(n);
  Jc(i) || ur(`Unrecognized input: ${n}`, e);
  for (const s in r)
    r[s] = t.maybeSelection(r[s]);
  return i(r);
}
function mH(e, t) {
  return EG(e.vconcat.map((n) => gg(n, t)));
}
function gH(e, t) {
  return NG(e.hconcat.map((n) => gg(n, t)));
}
function T$(e, t) {
  const { plot: n, ...r } = e, i = t.plotDefaults.concat(
    Object.keys(r).map((o) => N$(e, o, t))
  ), s = n.map((o) => wH(o, t));
  return Aj(i, s);
}
function bH(e, t) {
  return T$({ plot: [e] }, t);
}
function E$(e, t) {
  const { legend: n, ...r } = e, i = `${n}Legend`, s = t.legends.get(i);
  Jc(s) || ur(`Unrecognized legend type: ${n}`, e);
  for (const o in r)
    r[o] = t.maybeSelection(r[o]);
  return s(r);
}
function N$(e, t, n) {
  const r = n.attributes.get(t);
  Jc(r) || ur(`Unrecognized attribute: ${t}`, e);
  const i = e[t], s = i === "Fixed" ? iy : n.maybeParam(i);
  return r(s);
}
function wH(e, t) {
  return gi(e.mark) ? vH(e, t) : gi(e.legend) ? E$(e, t) : gi(e.select) ? SH(e, t) : ur("Invalid plot entry.", e);
}
function vH(e, t) {
  const { mark: n, data: r, ...i } = e, s = t.marks.get(n);
  Jc(s) || ur(`Unrecognized mark type: ${n}`, e);
  const o = _H(r, t);
  for (const a in i)
    i[a] = xH(i[a], t);
  return o ? s(o, i) : s(i);
}
function _H(e, t) {
  if (!e)
    return null;
  if (go(e))
    return e;
  const { from: n, ...r } = e;
  if (t.datasets.has(n))
    return t.datasets.get(n);
  for (const i in r)
    r[i] = t.maybeSelection(r[i]);
  return JY(n, r);
}
function xH(e, t) {
  return t.maybeTransform(e) || t.maybeParam(e);
}
function SH(e, t) {
  const { select: n, ...r } = e, i = t.interactors.get(n);
  Jc(i) || ur(`Unrecognized interactor type: ${n}`, e);
  for (const s in r)
    r[s] = t.maybeSelection(r[s]);
  return i(r);
}
function MH(e, t) {
  const { expr: n, label: r } = e, i = n.split(/(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\$\w+)/g), s = [""], o = [];
  for (let a = 0, c = 0; a < i.length; ++a) {
    const u = i[a];
    u.startsWith("$") ? (o[c] = t.maybeParam(u), s[++c] = "") : s[c] += u;
  }
  return q(s, ...o).annotate({ label: r });
}
function $H(e, t) {
  const { transforms: n } = t;
  let r;
  for (const a in e)
    n.has(a) && (r = a);
  if (!r)
    return;
  const i = n.get(r), s = r === "count" || r == null ? [] : Qd(e[r]);
  let o = i(...s);
  if (e.distinct && (o = o.distinct()), e.order) {
    const a = Qd(e.order).map((c) => t.maybeParam(c));
    o = o.orderby(a);
  }
  if (e.partition) {
    const a = Qd(e.partition).map((c) => t.maybeParam(c));
    o = o.partitionby(a);
  }
  return e.rows ? o = o.rows(t.maybeParam(e.rows)) : e.range && (o = o.range(t.maybeParam(e.range))), o;
}
async function UH(e) {
  e.el.classList.add("mosaic-widget");
  const t = () => e.model.get("spec"), n = An().logger(), r = /* @__PURE__ */ new Map();
  function i(c, u, l) {
    const h = globalThis.crypto.randomUUID();
    r.set(h, { query: c, startTime: performance.now(), resolve: u, reject: l }), e.model.send({ ...c, uuid: h });
  }
  const s = {
    query(c) {
      return new Promise((u, l) => i(c, u, l));
    }
  };
  function o() {
    An().clear(), lg.clear();
  }
  async function a() {
    const c = t();
    o(), n.log("Setting spec:", c), e.el.replaceChildren(await cH(c));
    const u = An(), l = new Set([...u.clients].flatMap((h) => h.filterBy).filter((h) => h));
    for (const h of l)
      h.addEventListener("value", () => {
        const f = [...l].map(
          (d) => d.clauses.map(
            (p) => ({
              value: p.value,
              sql: String(p.predicate)
            })
          )
        );
        e.model.set("selections", f), e.model.save_changes();
      });
  }
  return e.model.on("change:spec", () => a()), e.model.on("msg:custom", (c, u) => {
    n.group(`query ${c.uuid}`), n.log("received message", c, u);
    const l = r.get(c.uuid);
    if (r.delete(c.uuid), n.log(l.query.sql, (performance.now() - l.startTime).toFixed(1)), c.error)
      l.reject(c.error), n.error(c.error);
    else
      switch (c.type) {
        case "arrow": {
          const h = K0(u[0].buffer);
          n.log("table", h), l.resolve(h);
          break;
        }
        case "json": {
          n.log("json", c.result), l.resolve(c.result);
          break;
        }
        default: {
          l.resolve({});
          break;
        }
      }
    n.groupEnd("query");
  }), An().databaseConnector(s), a(), () => {
    o();
  };
}
export {
  UH as render
};
