function Y(e, t, n, i) {
  function r(s) {
    return s instanceof n ? s : new n(function(o) {
      o(s);
    });
  }
  return new (n || (n = Promise))(function(s, o) {
    function a(u) {
      try {
        l(i.next(u));
      } catch (f) {
        o(f);
      }
    }
    function c(u) {
      try {
        l(i.throw(u));
      } catch (f) {
        o(f);
      }
    }
    function l(u) {
      u.done ? s(u.value) : r(u.value).then(a, c);
    }
    l((i = i.apply(e, t || [])).next());
  });
}
function Sw(e) {
  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], i = 0;
  if (n)
    return n.call(e);
  if (e && typeof e.length == "number")
    return {
      next: function() {
        return e && i >= e.length && (e = void 0), { value: e && e[i++], done: !e };
      }
    };
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function W(e) {
  return this instanceof W ? (this.v = e, this) : new W(e);
}
function Fe(e, t, n) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var i = n.apply(e, t || []), r, s = [];
  return r = {}, o("next"), o("throw"), o("return"), r[Symbol.asyncIterator] = function() {
    return this;
  }, r;
  function o(h) {
    i[h] && (r[h] = function(d) {
      return new Promise(function(p, y) {
        s.push([h, d, p, y]) > 1 || a(h, d);
      });
    });
  }
  function a(h, d) {
    try {
      c(i[h](d));
    } catch (p) {
      f(s[0][3], p);
    }
  }
  function c(h) {
    h.value instanceof W ? Promise.resolve(h.value.v).then(l, u) : f(s[0][2], h);
  }
  function l(h) {
    a("next", h);
  }
  function u(h) {
    a("throw", h);
  }
  function f(h, d) {
    h(d), s.shift(), s.length && a(s[0][0], s[0][1]);
  }
}
function Fs(e) {
  var t, n;
  return t = {}, i("next"), i("throw", function(r) {
    throw r;
  }), i("return"), t[Symbol.iterator] = function() {
    return this;
  }, t;
  function i(r, s) {
    t[r] = e[r] ? function(o) {
      return (n = !n) ? { value: W(e[r](o)), done: !1 } : s ? s(o) : o;
    } : s;
  }
}
function ti(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 Sw == "function" ? Sw(e) : e[Symbol.iterator](), n = {}, i("next"), i("throw"), i("return"), n[Symbol.asyncIterator] = function() {
    return this;
  }, n);
  function i(s) {
    n[s] = e[s] && function(o) {
      return new Promise(function(a, c) {
        o = e[s](o), r(a, c, o.done, o.value);
      });
    };
  }
  function r(s, o, a, c) {
    Promise.resolve(c).then(function(l) {
      s({ value: l, done: a });
    }, o);
  }
}
const uF = new TextDecoder("utf-8"), Im = (e) => uF.decode(e), fF = new TextEncoder(), h1 = (e) => fF.encode(e), [Lu, Vrt] = (() => {
  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];
})(), [Ru, jrt] = (() => {
  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];
})(), hF = (e) => typeof e == "number", dF = (e) => typeof e == "boolean", tn = (e) => typeof e == "function", mi = (e) => e != null && Object(e) === e, eu = (e) => mi(e) && tn(e.then), Xp = (e) => mi(e) && tn(e[Symbol.iterator]), d1 = (e) => mi(e) && tn(e[Symbol.asyncIterator]), $m = (e) => mi(e) && mi(e.schema), dS = (e) => mi(e) && "done" in e && "value" in e, pS = (e) => mi(e) && tn(e.stat) && hF(e.fd), yS = (e) => mi(e) && p1(e.body), mS = (e) => "_getDOMStream" in e && "_getNodeStream" in e, p1 = (e) => mi(e) && tn(e.cancel) && tn(e.getReader) && !mS(e), gS = (e) => mi(e) && tn(e.read) && tn(e.pipe) && dF(e.readable) && !mS(e), pF = (e) => mi(e) && tn(e.clear) && tn(e.bytes) && tn(e.position) && tn(e.setPosition) && tn(e.capacity) && tn(e.getBufferIdentifier) && tn(e.createLong), y1 = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function yF(e) {
  const t = e[0] ? [e[0]] : [];
  let n, i, r, s;
  for (let o, a, c = 0, l = 0, u = e.length; ++c < u; ) {
    if (o = t[l], a = e[c], !o || !a || o.buffer !== a.buffer || a.byteOffset < o.byteOffset) {
      a && (t[++l] = a);
      continue;
    }
    if ({ byteOffset: n, byteLength: r } = o, { byteOffset: i, byteLength: s } = a, n + r < i || i + s < n) {
      a && (t[++l] = a);
      continue;
    }
    t[l] = new Uint8Array(o.buffer, n, i - n + s);
  }
  return t;
}
function Iw(e, t, n = 0, i = t.byteLength) {
  const r = e.byteLength, s = new Uint8Array(e.buffer, e.byteOffset, r), o = new Uint8Array(t.buffer, t.byteOffset, Math.min(i, r));
  return s.set(o, n), e;
}
function rr(e, t) {
  const n = yF(e), i = n.reduce((u, f) => u + f.byteLength, 0);
  let r, s, o, a = 0, c = -1;
  const l = Math.min(t || Number.POSITIVE_INFINITY, i);
  for (const u = n.length; ++c < u; ) {
    if (r = n[c], s = r.subarray(0, Math.min(r.length, l - a)), l <= a + s.length) {
      s.length < r.length ? n[c] = r.subarray(s.length) : s.length === r.length && c++, o ? Iw(o, s, a) : o = s;
      break;
    }
    Iw(o || (o = new Uint8Array(l)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), i - (o ? o.byteLength : 0)];
}
function ne(e, t) {
  let n = dS(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = h1(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof y1 ? new e(n) : pF(n) ? ne(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 ll = (e) => ne(Int32Array, e), Xt = (e) => ne(Uint8Array, e), Am = (e) => (e.next(), e);
function* mF(e, t) {
  const n = function* (r) {
    yield r;
  }, i = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof y1 ? n(t) : Xp(t) ? t : n(t);
  return yield* Am(function* (r) {
    let s = null;
    do
      s = r.next(yield ne(e, s));
    while (!s.done);
  }(i[Symbol.iterator]())), new e();
}
const gF = (e) => mF(Uint8Array, e);
function bS(e, t) {
  return Fe(this, arguments, function* () {
    if (eu(t))
      return yield W(yield W(yield* Fs(ti(bS(e, yield W(t))))));
    const i = function(o) {
      return Fe(this, arguments, function* () {
        yield yield W(yield W(o));
      });
    }, r = function(o) {
      return Fe(this, arguments, function* () {
        yield W(yield* Fs(ti(Am(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 y1 ? i(t) : Xp(t) ? r(t) : d1(t) ? t : i(t);
    return yield W(
      // otherwise if AsyncIterable, use it
      yield* Fs(ti(Am(function(o) {
        return Fe(this, arguments, function* () {
          let a = null;
          do
            a = yield W(o.next(yield yield W(ne(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield W(new e());
  });
}
const bF = (e) => bS(Uint8Array, e);
function _F(e, t) {
  let n = 0;
  const i = e.length;
  if (i !== t.length)
    return !1;
  if (i > 0)
    do
      if (e[n] !== t[n])
        return !1;
    while (++n < i);
  return !0;
}
const Pn = {
  fromIterable(e) {
    return Af(wF(e));
  },
  fromAsyncIterable(e) {
    return Af(vF(e));
  },
  fromDOMStream(e) {
    return Af(xF(e));
  },
  fromNodeStream(e) {
    return Af(IF(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');
  }
}, Af = (e) => (e.next(), e);
function* wF(e) {
  let t, n = !1, i = [], r, s, o, a = 0;
  function c() {
    return s === "peek" ? rr(i, o)[0] : ([r, i, a] = rr(i, o), r);
  }
  ({ cmd: s, size: o } = yield null);
  const l = gF(e)[Symbol.iterator]();
  try {
    do
      if ({ done: t, value: r } = Number.isNaN(o - a) ? l.next() : l.next(o - a), !t && r.byteLength > 0 && (i.push(r), a += r.byteLength), t || o <= a)
        do
          ({ cmd: s, size: o } = yield c());
        while (o < a);
    while (!t);
  } catch (u) {
    (n = !0) && typeof l.throw == "function" && l.throw(u);
  } finally {
    n === !1 && typeof l.return == "function" && l.return(null);
  }
  return null;
}
function vF(e) {
  return Fe(this, arguments, function* () {
    let n, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? rr(r, a)[0] : ([s, r, c] = rr(r, a), s);
    }
    ({ cmd: o, size: a } = yield yield W(null));
    const u = bF(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield W(u.next()) : yield W(u.next(a - c)), !n && s.byteLength > 0 && (r.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield W(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && typeof u.throw == "function" && (yield W(u.throw(f)));
    } finally {
      i === !1 && typeof u.return == "function" && (yield W(u.return(new Uint8Array(0))));
    }
    return yield W(null);
  });
}
function xF(e) {
  return Fe(this, arguments, function* () {
    let n = !1, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? rr(r, a)[0] : ([s, r, c] = rr(r, a), s);
    }
    ({ cmd: o, size: a } = yield yield W(null));
    const u = new SF(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield W(u.read()) : yield W(u.read(a - c)), !n && s.byteLength > 0 && (r.push(Xt(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield W(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && (yield W(u.cancel(f)));
    } finally {
      i === !1 ? yield W(u.cancel()) : e.locked && u.releaseLock();
    }
    return yield W(null);
  });
}
let SF = class {
  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 Y(this, void 0, void 0, function* () {
      const { reader: n, source: i } = this;
      n && (yield n.cancel(t).catch(() => {
      })), i && i.locked && this.releaseLock();
    });
  }
  read(t) {
    return Y(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 = Xt(n)), n;
    });
  }
};
const d0 = (e, t) => {
  const n = (r) => i([t, r]);
  let i;
  return [t, n, new Promise((r) => (i = r) && e.once(t, n))];
};
function IF(e) {
  return Fe(this, arguments, function* () {
    const n = [];
    let i = "error", r = !1, s = null, o, a, c = 0, l = [], u;
    function f() {
      return o === "peek" ? rr(l, a)[0] : ([u, l, c] = rr(l, a), u);
    }
    if ({ cmd: o, size: a } = yield yield W(null), e.isTTY)
      return yield yield W(new Uint8Array(0)), yield W(null);
    try {
      n[0] = d0(e, "end"), n[1] = d0(e, "error");
      do {
        if (n[2] = d0(e, "readable"), [i, s] = yield W(Promise.race(n.map((d) => d[2]))), i === "error")
          break;
        if ((r = i === "end") || (Number.isFinite(a - c) ? (u = Xt(e.read(a - c)), u.byteLength < a - c && (u = Xt(e.read()))) : u = Xt(e.read()), u.byteLength > 0 && (l.push(u), c += u.byteLength)), r || a <= c)
          do
            ({ cmd: o, size: a } = yield yield W(f()));
          while (a < c);
      } while (!r);
    } finally {
      yield W(h(n, i === "error" ? s : null));
    }
    return yield W(null);
    function h(d, p) {
      return u = l = 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 Wn;
(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";
})(Wn || (Wn = {}));
var gi;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(gi || (gi = {}));
var yn;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(yn || (yn = {}));
var Kr;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Kr || (Kr = {}));
var jt;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(jt || (jt = {}));
var Es;
(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";
})(Es || (Es = {}));
var Zt;
(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";
})(Zt || (Zt = {}));
var R;
(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";
})(R || (R = {}));
var Tr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(Tr || (Tr = {}));
const $F = void 0;
function nu(e) {
  if (e === null)
    return "null";
  if (e === $F)
    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 Lu || e instanceof Ru ? `[${[...e].map((t) => nu(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const AF = Symbol.for("isArrowBigNum");
function Ti(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(ne(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
Ti.prototype[AF] = !0;
Ti.prototype.toJSON = function() {
  return `"${Oh(this)}"`;
};
Ti.prototype.valueOf = function() {
  return _S(this);
};
Ti.prototype.toString = function() {
  return Oh(this);
};
Ti.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return _S(this);
    case "string":
      return Oh(this);
    case "default":
      return MF(this);
  }
  return Oh(this);
};
function Pa(...e) {
  return Ti.apply(this, e);
}
function Va(...e) {
  return Ti.apply(this, e);
}
function iu(...e) {
  return Ti.apply(this, e);
}
Object.setPrototypeOf(Pa.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(Va.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(iu.prototype, Object.create(Uint32Array.prototype));
Object.assign(Pa.prototype, Ti.prototype, { constructor: Pa, signed: !0, TypedArray: Int32Array, BigIntArray: Lu });
Object.assign(Va.prototype, Ti.prototype, { constructor: Va, signed: !1, TypedArray: Uint32Array, BigIntArray: Ru });
Object.assign(iu.prototype, Ti.prototype, { constructor: iu, signed: !0, TypedArray: Uint32Array, BigIntArray: Ru });
function _S(e) {
  const { buffer: t, byteOffset: n, length: i, signed: r } = e, s = new Ru(t, n, i), o = r && s[s.length - 1] & BigInt(1) << BigInt(63);
  let a = BigInt(o ? 1 : 0), c = BigInt(0);
  if (o) {
    for (const l of s)
      a += ~l * (BigInt(1) << BigInt(32) * c++);
    a *= BigInt(-1);
  } else
    for (const l of s)
      a += l * (BigInt(1) << BigInt(32) * c++);
  return a;
}
const Oh = (e) => e.byteLength === 8 ? `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}` : wS(e), MF = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : wS(e);
function wS(e) {
  let t = "";
  const n = new Uint32Array(2);
  let i = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  const r = new Uint32Array((i = new Uint16Array(i).reverse()).buffer);
  let s = -1;
  const o = i.length - 1;
  do {
    for (n[0] = i[s = 0]; s < o; )
      i[s++] = n[1] = n[0] / 10, n[0] = (n[0] - n[1] * 10 << 16) + i[s];
    i[s] = n[1] = n[0] / 10, n[0] = n[0] - n[1] * 10, t = `${n[0]}${t}`;
  } while (r[0] || r[1] || r[2] || r[3]);
  return t ?? "0";
}
let TF = class vS {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new Pa(t);
      case !1:
        return new Va(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case Lu:
        return new Pa(t);
    }
    return t.byteLength === 16 ? new iu(t) : new Va(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new Pa(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new Va(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new iu(t);
  }
  constructor(t, n) {
    return vS.new(t, n);
  }
};
function bi(e) {
  if (typeof e == "bigint" && (e < Number.MIN_SAFE_INTEGER || e > Number.MAX_SAFE_INTEGER))
    throw new TypeError(`${e} is not safe to convert to a number.`);
  return Number(e);
}
var xS, SS, IS, $S, AS, MS, TS, BS, NS, FS, DS, OS, ES, LS, RS, CS, kS, US, zS;
let Ft = class Mm {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === R.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === R.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === R.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === R.Binary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === R.Utf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === R.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === R.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === R.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === R.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === R.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === R.Interval;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === R.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === R.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === R.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === R.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === R.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === R.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === R.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return Mm.isUnion(t) && t.mode === gi.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return Mm.isUnion(t) && t.mode === gi.Sparse;
  }
  get typeId() {
    return R.NONE;
  }
};
xS = Symbol.toStringTag;
Ft[xS] = ((e) => (e.children = null, e.ArrayType = Array, e[Symbol.toStringTag] = "DataType"))(Ft.prototype);
let Ls = class extends Ft {
  toString() {
    return "Null";
  }
  get typeId() {
    return R.Null;
  }
};
SS = Symbol.toStringTag;
Ls[SS] = ((e) => e[Symbol.toStringTag] = "Null")(Ls.prototype);
let Rs = class extends Ft {
  constructor(t, n) {
    super(), this.isSigned = t, this.bitWidth = n;
  }
  get typeId() {
    return R.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 ? Lu : Ru;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
};
IS = Symbol.toStringTag;
Rs[IS] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(Rs.prototype);
let ru = class extends Rs {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
};
Object.defineProperty(ru.prototype, "ArrayType", { value: Int32Array });
let su = class extends Ft {
  constructor(t) {
    super(), this.precision = t;
  }
  get typeId() {
    return R.Float;
  }
  get ArrayType() {
    switch (this.precision) {
      case yn.HALF:
        return Uint16Array;
      case yn.SINGLE:
        return Float32Array;
      case yn.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
};
$S = Symbol.toStringTag;
su[$S] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(su.prototype);
let Eh = class extends Ft {
  constructor() {
    super();
  }
  get typeId() {
    return R.Binary;
  }
  toString() {
    return "Binary";
  }
};
AS = Symbol.toStringTag;
Eh[AS] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(Eh.prototype);
let Lh = class extends Ft {
  constructor() {
    super();
  }
  get typeId() {
    return R.Utf8;
  }
  toString() {
    return "Utf8";
  }
};
MS = Symbol.toStringTag;
Lh[MS] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(Lh.prototype);
let Rh = class extends Ft {
  constructor() {
    super();
  }
  get typeId() {
    return R.Bool;
  }
  toString() {
    return "Bool";
  }
};
TS = Symbol.toStringTag;
Rh[TS] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(Rh.prototype);
let Ch = class extends Ft {
  constructor(t, n, i = 128) {
    super(), this.scale = t, this.precision = n, this.bitWidth = i;
  }
  get typeId() {
    return R.Decimal;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
};
BS = Symbol.toStringTag;
Ch[BS] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(Ch.prototype);
let kh = class extends Ft {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return R.Date;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${Kr[this.unit]}>`;
  }
};
NS = Symbol.toStringTag;
kh[NS] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(kh.prototype);
let ou = class extends Ft {
  constructor(t, n) {
    super(), this.unit = t, this.bitWidth = n;
  }
  get typeId() {
    return R.Time;
  }
  toString() {
    return `Time${this.bitWidth}<${jt[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return Lu;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
};
FS = Symbol.toStringTag;
ou[FS] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(ou.prototype);
let Uh = class extends Ft {
  constructor(t, n) {
    super(), this.unit = t, this.timezone = n;
  }
  get typeId() {
    return R.Timestamp;
  }
  toString() {
    return `Timestamp<${jt[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
};
DS = Symbol.toStringTag;
Uh[DS] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(Uh.prototype);
let zh = class extends Ft {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return R.Interval;
  }
  toString() {
    return `Interval<${Es[this.unit]}>`;
  }
};
OS = Symbol.toStringTag;
zh[OS] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(zh.prototype);
let Ph = class extends Ft {
  constructor(t) {
    super(), this.children = [t];
  }
  get typeId() {
    return R.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;
  }
};
ES = Symbol.toStringTag;
Ph[ES] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(Ph.prototype);
let on = class extends Ft {
  constructor(t) {
    super(), this.children = t;
  }
  get typeId() {
    return R.Struct;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
};
LS = Symbol.toStringTag;
on[LS] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(on.prototype);
let Vh = class extends Ft {
  constructor(t, n, i) {
    super(), this.mode = t, this.children = i, this.typeIds = n = Int32Array.from(n), this.typeIdToChildIndex = n.reduce((r, s, o) => (r[s] = o) && r || r, /* @__PURE__ */ Object.create(null));
  }
  get typeId() {
    return R.Union;
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
};
RS = Symbol.toStringTag;
Vh[RS] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(Vh.prototype);
let jh = class extends Ft {
  constructor(t) {
    super(), this.byteWidth = t;
  }
  get typeId() {
    return R.FixedSizeBinary;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
};
CS = Symbol.toStringTag;
jh[CS] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(jh.prototype);
let Yh = class extends Ft {
  constructor(t, n) {
    super(), this.listSize = t, this.children = [n];
  }
  get typeId() {
    return R.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}>`;
  }
};
kS = Symbol.toStringTag;
Yh[kS] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(Yh.prototype);
let qh = class extends Ft {
  constructor(t, n = !1) {
    super(), this.children = [t], this.keysSorted = n;
  }
  get typeId() {
    return R.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(", ")}}>`;
  }
};
US = Symbol.toStringTag;
qh[US] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(qh.prototype);
const BF = ((e) => () => ++e)(-1);
let lc = class extends Ft {
  constructor(t, n, i, r) {
    super(), this.indices = n, this.dictionary = t, this.isOrdered = r || !1, this.id = i == null ? BF() : bi(i);
  }
  get typeId() {
    return R.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}>`;
  }
};
zS = Symbol.toStringTag;
lc[zS] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(lc.prototype);
function Br(e) {
  const t = e;
  switch (e.typeId) {
    case R.Decimal:
      return e.bitWidth / 32;
    case R.Timestamp:
      return 2;
    case R.Date:
      return 1 + t.unit;
    case R.Interval:
      return 1 + t.unit;
    case R.FixedSizeList:
      return t.listSize;
    case R.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
let Ut = class {
  visitMany(t, ...n) {
    return t.map((i, r) => this.visit(i, ...n.map((s) => s[r])));
  }
  visit(...t) {
    return this.getVisitFn(t[0], !1).apply(this, t);
  }
  getVisitFn(t, n = !0) {
    return NF(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return _a(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 NF(e, t, n = !0) {
  return typeof t == "number" ? _a(e, t, n) : typeof t == "string" && t in R ? _a(e, R[t], n) : t && t instanceof Ft ? _a(e, $w(t), n) : t != null && t.type && t.type instanceof Ft ? _a(e, $w(t.type), n) : _a(e, R.NONE, n);
}
function _a(e, t, n = !0) {
  let i = null;
  switch (t) {
    case R.Null:
      i = e.visitNull;
      break;
    case R.Bool:
      i = e.visitBool;
      break;
    case R.Int:
      i = e.visitInt;
      break;
    case R.Int8:
      i = e.visitInt8 || e.visitInt;
      break;
    case R.Int16:
      i = e.visitInt16 || e.visitInt;
      break;
    case R.Int32:
      i = e.visitInt32 || e.visitInt;
      break;
    case R.Int64:
      i = e.visitInt64 || e.visitInt;
      break;
    case R.Uint8:
      i = e.visitUint8 || e.visitInt;
      break;
    case R.Uint16:
      i = e.visitUint16 || e.visitInt;
      break;
    case R.Uint32:
      i = e.visitUint32 || e.visitInt;
      break;
    case R.Uint64:
      i = e.visitUint64 || e.visitInt;
      break;
    case R.Float:
      i = e.visitFloat;
      break;
    case R.Float16:
      i = e.visitFloat16 || e.visitFloat;
      break;
    case R.Float32:
      i = e.visitFloat32 || e.visitFloat;
      break;
    case R.Float64:
      i = e.visitFloat64 || e.visitFloat;
      break;
    case R.Utf8:
      i = e.visitUtf8;
      break;
    case R.Binary:
      i = e.visitBinary;
      break;
    case R.FixedSizeBinary:
      i = e.visitFixedSizeBinary;
      break;
    case R.Date:
      i = e.visitDate;
      break;
    case R.DateDay:
      i = e.visitDateDay || e.visitDate;
      break;
    case R.DateMillisecond:
      i = e.visitDateMillisecond || e.visitDate;
      break;
    case R.Timestamp:
      i = e.visitTimestamp;
      break;
    case R.TimestampSecond:
      i = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case R.TimestampMillisecond:
      i = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case R.TimestampMicrosecond:
      i = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case R.TimestampNanosecond:
      i = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case R.Time:
      i = e.visitTime;
      break;
    case R.TimeSecond:
      i = e.visitTimeSecond || e.visitTime;
      break;
    case R.TimeMillisecond:
      i = e.visitTimeMillisecond || e.visitTime;
      break;
    case R.TimeMicrosecond:
      i = e.visitTimeMicrosecond || e.visitTime;
      break;
    case R.TimeNanosecond:
      i = e.visitTimeNanosecond || e.visitTime;
      break;
    case R.Decimal:
      i = e.visitDecimal;
      break;
    case R.List:
      i = e.visitList;
      break;
    case R.Struct:
      i = e.visitStruct;
      break;
    case R.Union:
      i = e.visitUnion;
      break;
    case R.DenseUnion:
      i = e.visitDenseUnion || e.visitUnion;
      break;
    case R.SparseUnion:
      i = e.visitSparseUnion || e.visitUnion;
      break;
    case R.Dictionary:
      i = e.visitDictionary;
      break;
    case R.Interval:
      i = e.visitInterval;
      break;
    case R.IntervalDayTime:
      i = e.visitIntervalDayTime || e.visitInterval;
      break;
    case R.IntervalYearMonth:
      i = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case R.FixedSizeList:
      i = e.visitFixedSizeList;
      break;
    case R.Map:
      i = e.visitMap;
      break;
  }
  if (typeof i == "function")
    return i;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${R[t]}'`);
}
function $w(e) {
  switch (e.typeId) {
    case R.Null:
      return R.Null;
    case R.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? R.Int8 : R.Uint8;
        case 16:
          return n ? R.Int16 : R.Uint16;
        case 32:
          return n ? R.Int32 : R.Uint32;
        case 64:
          return n ? R.Int64 : R.Uint64;
      }
      return R.Int;
    }
    case R.Float:
      switch (e.precision) {
        case yn.HALF:
          return R.Float16;
        case yn.SINGLE:
          return R.Float32;
        case yn.DOUBLE:
          return R.Float64;
      }
      return R.Float;
    case R.Binary:
      return R.Binary;
    case R.Utf8:
      return R.Utf8;
    case R.Bool:
      return R.Bool;
    case R.Decimal:
      return R.Decimal;
    case R.Time:
      switch (e.unit) {
        case jt.SECOND:
          return R.TimeSecond;
        case jt.MILLISECOND:
          return R.TimeMillisecond;
        case jt.MICROSECOND:
          return R.TimeMicrosecond;
        case jt.NANOSECOND:
          return R.TimeNanosecond;
      }
      return R.Time;
    case R.Timestamp:
      switch (e.unit) {
        case jt.SECOND:
          return R.TimestampSecond;
        case jt.MILLISECOND:
          return R.TimestampMillisecond;
        case jt.MICROSECOND:
          return R.TimestampMicrosecond;
        case jt.NANOSECOND:
          return R.TimestampNanosecond;
      }
      return R.Timestamp;
    case R.Date:
      switch (e.unit) {
        case Kr.DAY:
          return R.DateDay;
        case Kr.MILLISECOND:
          return R.DateMillisecond;
      }
      return R.Date;
    case R.Interval:
      switch (e.unit) {
        case Es.DAY_TIME:
          return R.IntervalDayTime;
        case Es.YEAR_MONTH:
          return R.IntervalYearMonth;
      }
      return R.Interval;
    case R.Map:
      return R.Map;
    case R.List:
      return R.List;
    case R.Struct:
      return R.Struct;
    case R.Union:
      switch (e.mode) {
        case gi.Dense:
          return R.DenseUnion;
        case gi.Sparse:
          return R.SparseUnion;
      }
      return R.Union;
    case R.FixedSizeBinary:
      return R.FixedSizeBinary;
    case R.FixedSizeList:
      return R.FixedSizeList;
    case R.Dictionary:
      return R.Dictionary;
  }
  throw new Error(`Unrecognized type '${R[e.typeId]}'`);
}
Ut.prototype.visitInt8 = null;
Ut.prototype.visitInt16 = null;
Ut.prototype.visitInt32 = null;
Ut.prototype.visitInt64 = null;
Ut.prototype.visitUint8 = null;
Ut.prototype.visitUint16 = null;
Ut.prototype.visitUint32 = null;
Ut.prototype.visitUint64 = null;
Ut.prototype.visitFloat16 = null;
Ut.prototype.visitFloat32 = null;
Ut.prototype.visitFloat64 = null;
Ut.prototype.visitDateDay = null;
Ut.prototype.visitDateMillisecond = null;
Ut.prototype.visitTimestampSecond = null;
Ut.prototype.visitTimestampMillisecond = null;
Ut.prototype.visitTimestampMicrosecond = null;
Ut.prototype.visitTimestampNanosecond = null;
Ut.prototype.visitTimeSecond = null;
Ut.prototype.visitTimeMillisecond = null;
Ut.prototype.visitTimeMicrosecond = null;
Ut.prototype.visitTimeNanosecond = null;
Ut.prototype.visitDenseUnion = null;
Ut.prototype.visitSparseUnion = null;
Ut.prototype.visitIntervalDayTime = null;
Ut.prototype.visitIntervalYearMonth = null;
const PS = new Float64Array(1), oa = new Uint32Array(PS.buffer);
function VS(e) {
  const t = (e & 31744) >> 10, n = (e & 1023) / 1024, i = Math.pow(-1, (e & 32768) >> 15);
  switch (t) {
    case 31:
      return i * (n ? Number.NaN : 1 / 0);
    case 0:
      return i * (n ? 6103515625e-14 * n : 0);
  }
  return i * Math.pow(2, t - 15) * (1 + n);
}
function FF(e) {
  if (e !== e)
    return 32256;
  PS[0] = e;
  const t = (oa[1] & 2147483648) >> 16 & 65535;
  let n = oa[1] & 2146435072, i = 0;
  return n >= 1089470464 ? oa[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, i = (oa[1] & 1048575) >> 10) : n <= 1056964608 ? (i = 1048576 + (oa[1] & 1048575), i = 1048576 + (i << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, i = (oa[1] & 1048575) + 512 >> 10), t | n | i & 65535;
}
let _t = class extends Ut {
};
function At(e) {
  return (t, n, i) => {
    if (t.setValid(n, i != null))
      return e(t, n, i);
  };
}
const DF = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, m1 = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, OF = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, EF = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, jS = (e, t, n, i) => {
  if (n + 1 < t.length) {
    const { [n]: r, [n + 1]: s } = t;
    e.set(i.subarray(0, s - r), r);
  }
}, LF = ({ offset: e, values: t }, n, i) => {
  const r = e + n;
  i ? t[r >> 3] |= 1 << r % 8 : t[r >> 3] &= ~(1 << r % 8);
}, ss = ({ values: e }, t, n) => {
  e[t] = n;
}, g1 = ({ values: e }, t, n) => {
  e[t] = n;
}, YS = ({ values: e }, t, n) => {
  e[t] = FF(n);
}, RF = (e, t, n) => {
  switch (e.type.precision) {
    case yn.HALF:
      return YS(e, t, n);
    case yn.SINGLE:
    case yn.DOUBLE:
      return g1(e, t, n);
  }
}, qS = ({ values: e }, t, n) => {
  DF(e, t, n.valueOf());
}, WS = ({ values: e }, t, n) => {
  m1(e, t * 2, n.valueOf());
}, CF = ({ stride: e, values: t }, n, i) => {
  t.set(i.subarray(0, e), e * n);
}, kF = ({ values: e, valueOffsets: t }, n, i) => jS(e, t, n, i), UF = ({ values: e, valueOffsets: t }, n, i) => {
  jS(e, t, n, h1(i));
}, zF = (e, t, n) => {
  e.type.unit === Kr.DAY ? qS(e, t, n) : WS(e, t, n);
}, GS = ({ values: e }, t, n) => m1(e, t * 2, n / 1e3), XS = ({ values: e }, t, n) => m1(e, t * 2, n), HS = ({ values: e }, t, n) => OF(e, t * 2, n), KS = ({ values: e }, t, n) => EF(e, t * 2, n), PF = (e, t, n) => {
  switch (e.type.unit) {
    case jt.SECOND:
      return GS(e, t, n);
    case jt.MILLISECOND:
      return XS(e, t, n);
    case jt.MICROSECOND:
      return HS(e, t, n);
    case jt.NANOSECOND:
      return KS(e, t, n);
  }
}, JS = ({ values: e }, t, n) => {
  e[t] = n;
}, ZS = ({ values: e }, t, n) => {
  e[t] = n;
}, QS = ({ values: e }, t, n) => {
  e[t] = n;
}, tI = ({ values: e }, t, n) => {
  e[t] = n;
}, VF = (e, t, n) => {
  switch (e.type.unit) {
    case jt.SECOND:
      return JS(e, t, n);
    case jt.MILLISECOND:
      return ZS(e, t, n);
    case jt.MICROSECOND:
      return QS(e, t, n);
    case jt.NANOSECOND:
      return tI(e, t, n);
  }
}, jF = ({ values: e, stride: t }, n, i) => {
  e.set(i.subarray(0, t), t * n);
}, YF = (e, t, n) => {
  const i = e.children[0], r = e.valueOffsets, s = ei.getVisitFn(i);
  if (Array.isArray(n))
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n[++o]);
  else
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n.get(++o));
}, qF = (e, t, n) => {
  const i = e.children[0], { valueOffsets: r } = e, s = ei.getVisitFn(i);
  let { [t]: o, [t + 1]: a } = r;
  const c = n instanceof Map ? n.entries() : Object.entries(n);
  for (const l of c)
    if (s(i, o, l), ++o >= a)
      break;
}, WF = (e, t) => (n, i, r, s) => i && n(i, e, t[s]), GF = (e, t) => (n, i, r, s) => i && n(i, e, t.get(s)), XF = (e, t) => (n, i, r, s) => i && n(i, e, t.get(r.name)), HF = (e, t) => (n, i, r, s) => i && n(i, e, t[r.name]), KF = (e, t, n) => {
  const i = e.type.children.map((s) => ei.getVisitFn(s.type)), r = n instanceof Map ? XF(t, n) : n instanceof Me ? GF(t, n) : Array.isArray(n) ? WF(t, n) : HF(t, n);
  e.type.children.forEach((s, o) => r(i[o], e.children[o], s, o));
}, JF = (e, t, n) => {
  e.type.mode === gi.Dense ? eI(e, t, n) : nI(e, t, n);
}, eI = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  ei.visit(r, e.valueOffsets[t], n);
}, nI = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  ei.visit(r, t, n);
}, ZF = (e, t, n) => {
  var i;
  (i = e.dictionary) === null || i === void 0 || i.set(e.values[t], n);
}, QF = (e, t, n) => {
  e.type.unit === Es.DAY_TIME ? iI(e, t, n) : rI(e, t, n);
}, iI = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, rI = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, tD = (e, t, n) => {
  const { stride: i } = e, r = e.children[0], s = ei.getVisitFn(r);
  if (Array.isArray(n))
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n[o]);
  else
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n.get(o));
};
_t.prototype.visitBool = At(LF);
_t.prototype.visitInt = At(ss);
_t.prototype.visitInt8 = At(ss);
_t.prototype.visitInt16 = At(ss);
_t.prototype.visitInt32 = At(ss);
_t.prototype.visitInt64 = At(ss);
_t.prototype.visitUint8 = At(ss);
_t.prototype.visitUint16 = At(ss);
_t.prototype.visitUint32 = At(ss);
_t.prototype.visitUint64 = At(ss);
_t.prototype.visitFloat = At(RF);
_t.prototype.visitFloat16 = At(YS);
_t.prototype.visitFloat32 = At(g1);
_t.prototype.visitFloat64 = At(g1);
_t.prototype.visitUtf8 = At(UF);
_t.prototype.visitBinary = At(kF);
_t.prototype.visitFixedSizeBinary = At(CF);
_t.prototype.visitDate = At(zF);
_t.prototype.visitDateDay = At(qS);
_t.prototype.visitDateMillisecond = At(WS);
_t.prototype.visitTimestamp = At(PF);
_t.prototype.visitTimestampSecond = At(GS);
_t.prototype.visitTimestampMillisecond = At(XS);
_t.prototype.visitTimestampMicrosecond = At(HS);
_t.prototype.visitTimestampNanosecond = At(KS);
_t.prototype.visitTime = At(VF);
_t.prototype.visitTimeSecond = At(JS);
_t.prototype.visitTimeMillisecond = At(ZS);
_t.prototype.visitTimeMicrosecond = At(QS);
_t.prototype.visitTimeNanosecond = At(tI);
_t.prototype.visitDecimal = At(jF);
_t.prototype.visitList = At(YF);
_t.prototype.visitStruct = At(KF);
_t.prototype.visitUnion = At(JF);
_t.prototype.visitDenseUnion = At(eI);
_t.prototype.visitSparseUnion = At(nI);
_t.prototype.visitDictionary = At(ZF);
_t.prototype.visitInterval = At(QF);
_t.prototype.visitIntervalDayTime = At(iI);
_t.prototype.visitIntervalYearMonth = At(rI);
_t.prototype.visitFixedSizeList = At(tD);
_t.prototype.visitMap = At(qF);
const ei = new _t(), oi = Symbol.for("parent"), ja = Symbol.for("rowIndex");
let b1 = class {
  constructor(t, n) {
    return this[oi] = t, this[ja] = n, new Proxy(this, new nD());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[ja], n = this[oi], i = n.type.children, r = {};
    for (let s = -1, o = i.length; ++s < o; )
      r[i[s].name] = gn.visit(n.children[s], t);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${nu(t)}: ${nu(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new eD(this[oi], this[ja]);
  }
}, eD = class {
  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,
        gn.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
};
Object.defineProperties(b1.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [oi]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [ja]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
let nD = class {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[oi].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[oi].type.children.findIndex((i) => i.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[oi].type.children.findIndex((i) => i.name === n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[oi].type.children.findIndex((r) => r.name === n);
    if (i !== -1) {
      const r = gn.visit(t[oi].children[i], t[ja]);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[oi].type.children.findIndex((s) => s.name === n);
    return r !== -1 ? (ei.visit(t[oi].children[r], t[ja], i), Reflect.set(t, n, i)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, i) : !1;
  }
}, ft = class extends Ut {
};
function wt(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const iD = (e, t) => 864e5 * e[t], _1 = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), rD = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, sD = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, sI = (e) => new Date(e), oD = (e, t) => sI(iD(e, t)), aD = (e, t) => sI(_1(e, t)), cD = (e, t) => null, oI = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const i = t[n], r = t[n + 1];
  return e.subarray(i, r);
}, lD = ({ offset: e, values: t }, n) => {
  const i = e + n;
  return (t[i >> 3] & 1 << i % 8) !== 0;
}, aI = ({ values: e }, t) => oD(e, t), cI = ({ values: e }, t) => aD(e, t * 2), Js = ({ stride: e, values: t }, n) => t[e * n], uD = ({ stride: e, values: t }, n) => VS(t[e * n]), lI = ({ values: e }, t) => e[t], fD = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), hD = ({ values: e, valueOffsets: t }, n) => oI(e, t, n), dD = ({ values: e, valueOffsets: t }, n) => {
  const i = oI(e, t, n);
  return i !== null ? Im(i) : null;
}, pD = ({ values: e }, t) => e[t], yD = ({ type: e, values: t }, n) => e.precision !== yn.HALF ? t[n] : VS(t[n]), mD = (e, t) => e.type.unit === Kr.DAY ? aI(e, t) : cI(e, t), uI = ({ values: e }, t) => 1e3 * _1(e, t * 2), fI = ({ values: e }, t) => _1(e, t * 2), hI = ({ values: e }, t) => rD(e, t * 2), dI = ({ values: e }, t) => sD(e, t * 2), gD = (e, t) => {
  switch (e.type.unit) {
    case jt.SECOND:
      return uI(e, t);
    case jt.MILLISECOND:
      return fI(e, t);
    case jt.MICROSECOND:
      return hI(e, t);
    case jt.NANOSECOND:
      return dI(e, t);
  }
}, pI = ({ values: e }, t) => e[t], yI = ({ values: e }, t) => e[t], mI = ({ values: e }, t) => e[t], gI = ({ values: e }, t) => e[t], bD = (e, t) => {
  switch (e.type.unit) {
    case jt.SECOND:
      return pI(e, t);
    case jt.MILLISECOND:
      return yI(e, t);
    case jt.MICROSECOND:
      return mI(e, t);
    case jt.NANOSECOND:
      return gI(e, t);
  }
}, _D = ({ values: e, stride: t }, n) => TF.decimal(e.subarray(t * n, t * (n + 1))), wD = (e, t) => {
  const { valueOffsets: n, stride: i, children: r } = e, { [t * i]: s, [t * i + 1]: o } = n, c = r[0].slice(s, o - s);
  return new Me([c]);
}, vD = (e, t) => {
  const { valueOffsets: n, children: i } = e, { [t]: r, [t + 1]: s } = n, o = i[0];
  return new w1(o.slice(r, s - r));
}, xD = (e, t) => new b1(e, t), SD = (e, t) => e.type.mode === gi.Dense ? bI(e, t) : _I(e, t), bI = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return gn.visit(i, e.valueOffsets[t]);
}, _I = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return gn.visit(i, t);
}, ID = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, $D = (e, t) => e.type.unit === Es.DAY_TIME ? wI(e, t) : vI(e, t), wI = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), vI = ({ values: e }, t) => {
  const n = e[t], i = new Int32Array(2);
  return i[0] = Math.trunc(n / 12), i[1] = Math.trunc(n % 12), i;
}, AD = (e, t) => {
  const { stride: n, children: i } = e, s = i[0].slice(t * n, n);
  return new Me([s]);
};
ft.prototype.visitNull = wt(cD);
ft.prototype.visitBool = wt(lD);
ft.prototype.visitInt = wt(pD);
ft.prototype.visitInt8 = wt(Js);
ft.prototype.visitInt16 = wt(Js);
ft.prototype.visitInt32 = wt(Js);
ft.prototype.visitInt64 = wt(lI);
ft.prototype.visitUint8 = wt(Js);
ft.prototype.visitUint16 = wt(Js);
ft.prototype.visitUint32 = wt(Js);
ft.prototype.visitUint64 = wt(lI);
ft.prototype.visitFloat = wt(yD);
ft.prototype.visitFloat16 = wt(uD);
ft.prototype.visitFloat32 = wt(Js);
ft.prototype.visitFloat64 = wt(Js);
ft.prototype.visitUtf8 = wt(dD);
ft.prototype.visitBinary = wt(hD);
ft.prototype.visitFixedSizeBinary = wt(fD);
ft.prototype.visitDate = wt(mD);
ft.prototype.visitDateDay = wt(aI);
ft.prototype.visitDateMillisecond = wt(cI);
ft.prototype.visitTimestamp = wt(gD);
ft.prototype.visitTimestampSecond = wt(uI);
ft.prototype.visitTimestampMillisecond = wt(fI);
ft.prototype.visitTimestampMicrosecond = wt(hI);
ft.prototype.visitTimestampNanosecond = wt(dI);
ft.prototype.visitTime = wt(bD);
ft.prototype.visitTimeSecond = wt(pI);
ft.prototype.visitTimeMillisecond = wt(yI);
ft.prototype.visitTimeMicrosecond = wt(mI);
ft.prototype.visitTimeNanosecond = wt(gI);
ft.prototype.visitDecimal = wt(_D);
ft.prototype.visitList = wt(wD);
ft.prototype.visitStruct = wt(xD);
ft.prototype.visitUnion = wt(SD);
ft.prototype.visitDenseUnion = wt(bI);
ft.prototype.visitSparseUnion = wt(_I);
ft.prototype.visitDictionary = wt(ID);
ft.prototype.visitInterval = wt($D);
ft.prototype.visitIntervalDayTime = wt(wI);
ft.prototype.visitIntervalYearMonth = wt(vI);
ft.prototype.visitFixedSizeList = wt(AD);
ft.prototype.visitMap = wt(vD);
const gn = new ft(), Vi = Symbol.for("keys"), Ya = Symbol.for("vals");
let w1 = class {
  constructor(t) {
    return this[Vi] = new Me([t.children[0]]).memoize(), this[Ya] = t.children[1], new Proxy(this, new TD());
  }
  [Symbol.iterator]() {
    return new MD(this[Vi], this[Ya]);
  }
  get size() {
    return this[Vi].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[Vi], n = this[Ya], i = {};
    for (let r = -1, s = t.length; ++r < s; )
      i[t.get(r)] = gn.visit(n, r);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${nu(t)}: ${nu(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}, MD = class {
  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),
        gn.visit(this.vals, t)
      ]
    });
  }
}, TD = class {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[Vi].toArray().map(String);
  }
  has(t, n) {
    return t[Vi].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[Vi].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[Vi].indexOf(n);
    if (i !== -1) {
      const r = gn.visit(Reflect.get(t, Ya), i);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[Vi].indexOf(n);
    return r !== -1 ? (ei.visit(Reflect.get(t, Ya), r, i), Reflect.set(t, n, i)) : Reflect.has(t, n) ? Reflect.set(t, n, i) : !1;
  }
};
Object.defineProperties(w1.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [Vi]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [Ya]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let Aw;
function xI(e, t, n, i) {
  const { length: r = 0 } = e;
  let s = typeof t != "number" ? 0 : t, o = typeof n != "number" ? r : n;
  return s < 0 && (s = (s % r + r) % r), o < 0 && (o = (o % r + r) % r), o < s && (Aw = s, s = o, o = Aw), o > r && (o = r), i ? i(e, s, o) : [s, o];
}
const Mw = (e) => e !== e;
function Vc(e) {
  if (typeof e !== "object" || e === null)
    return Mw(e) ? Mw : (n) => n === e;
  if (e instanceof Date) {
    const n = e.valueOf();
    return (i) => i instanceof Date ? i.valueOf() === n : !1;
  }
  return ArrayBuffer.isView(e) ? (n) => n ? _F(e, n) : !1 : e instanceof Map ? ND(e) : Array.isArray(e) ? BD(e) : e instanceof Me ? FD(e) : DD(e, !0);
}
function BD(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = Vc(e[n]);
  return Hp(t);
}
function ND(e) {
  let t = -1;
  const n = [];
  for (const i of e.values())
    n[++t] = Vc(i);
  return Hp(n);
}
function FD(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = Vc(e.get(n));
  return Hp(t);
}
function DD(e, t = !1) {
  const n = Object.keys(e);
  if (!t && n.length === 0)
    return () => !1;
  const i = [];
  for (let r = -1, s = n.length; ++r < s; )
    i[r] = Vc(e[n[r]]);
  return Hp(i, n);
}
function Hp(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return OD(e, n);
      case Map:
        return Tw(e, n, n.keys());
      case w1:
      case b1:
      case Object:
      case void 0:
        return Tw(e, n, t || Object.keys(n));
    }
    return n instanceof Me ? ED(e, n) : !1;
  };
}
function OD(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t[i]))
      return !1;
  return !0;
}
function ED(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t.get(i)))
      return !1;
  return !0;
}
function Tw(e, t, n) {
  const i = n[Symbol.iterator](), r = t instanceof Map ? t.keys() : Object.keys(t)[Symbol.iterator](), s = t instanceof Map ? t.values() : Object.values(t)[Symbol.iterator]();
  let o = 0;
  const a = e.length;
  let c = s.next(), l = i.next(), u = r.next();
  for (; o < a && !l.done && !u.done && !c.done && !(l.value !== u.value || !e[o](c.value)); ++o, l = i.next(), u = r.next(), c = s.next())
    ;
  return o === a && l.done && u.done && c.done ? !0 : (i.return && i.return(), r.return && r.return(), s.return && s.return(), !1);
}
function SI(e, t, n, i) {
  return (n & 1 << i) !== 0;
}
function LD(e, t, n, i) {
  return (n & 1 << i) >> i;
}
function RD(e, t, n) {
  const i = n.byteLength + 7 & -8;
  if (e > 0 || n.byteLength < i) {
    const r = new Uint8Array(i);
    return r.set(e % 8 === 0 ? n.subarray(e >> 3) : (
      // Otherwise iterate each bit from the offset and return a new one
      Tm(new v1(n, e, t, null, SI)).subarray(0, i)
    )), r;
  }
  return n;
}
function Tm(e) {
  const t = [];
  let n = 0, i = 0, r = 0;
  for (const o of e)
    o && (r |= 1 << i), ++i === 8 && (t[n++] = r, r = i = 0);
  (n === 0 || i > 0) && (t[n++] = r);
  const s = new Uint8Array(t.length + 7 & -8);
  return s.set(t), s;
}
let v1 = class {
  constructor(t, n, i, r, s) {
    this.bytes = t, this.length = i, this.context = r, this.get = s, this.bit = n % 8, this.byteIndex = n >> 3, this.byte = t[this.byteIndex++], this.index = 0;
  }
  next() {
    return this.index < this.length ? (this.bit === 8 && (this.bit = 0, this.byte = this.bytes[this.byteIndex++]), {
      value: this.get(this.context, this.index++, this.byte, this.bit++)
    }) : { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
};
function Bm(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new v1(e, t, n - t, e, LD))
      s += o;
    return s;
  }
  const i = n >> 3 << 3, r = t + (t % 8 === 0 ? 0 : 8 - t % 8);
  return (
    // Get the popcnt of bits between the left hand side, and the next highest multiple of 8
    Bm(e, t, r) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    Bm(e, i, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    CD(e, r >> 3, i - r >> 3)
  );
}
function CD(e, t, n) {
  let i = 0, r = Math.trunc(t);
  const s = new DataView(e.buffer, e.byteOffset, e.byteLength), o = n === void 0 ? e.byteLength : r + n;
  for (; o - r >= 4; )
    i += p0(s.getUint32(r)), r += 4;
  for (; o - r >= 2; )
    i += p0(s.getUint16(r)), r += 2;
  for (; o - r >= 1; )
    i += p0(s.getUint8(r)), r += 1;
  return i;
}
function p0(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 kD = -1;
let me = class Nm {
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  get byteLength() {
    let t = 0;
    const { valueOffsets: n, values: i, nullBitmap: r, typeIds: s } = this;
    return n && (t += n.byteLength), i && (t += i.byteLength), r && (t += r.byteLength), s && (t += s.byteLength), this.children.reduce((o, a) => o + a.byteLength, t);
  }
  get nullCount() {
    let t = this._nullCount, n;
    return t <= kD && (n = this.nullBitmap) && (this._nullCount = t = this.length - Bm(n, this.offset, this.offset + this.length)), t;
  }
  constructor(t, n, i, r, s, o = [], a) {
    this.type = t, this.children = o, this.dictionary = a, this.offset = Math.floor(Math.max(n || 0, 0)), this.length = Math.floor(Math.max(i || 0, 0)), this._nullCount = Math.floor(Math.max(r || 0, -1));
    let c;
    s instanceof Nm ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = Br(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;
  }
  getValid(t) {
    if (this.nullable && this.nullCount > 0) {
      const n = this.offset + t;
      return (this.nullBitmap[n >> 3] & 1 << n % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    if (!this.nullable)
      return n;
    if (!this.nullBitmap || this.nullBitmap.byteLength <= t >> 3) {
      const { nullBitmap: c } = this._changeLengthAndBackfillNullBitmap(this.length);
      Object.assign(this, { nullBitmap: c, _nullCount: 0 });
    }
    const { nullBitmap: i, offset: r } = this, s = r + t >> 3, o = (r + t) % 8, a = i[s] >> o & 1;
    return n ? a === 0 && (i[s] |= 1 << o, this._nullCount = this.nullCount + 1) : a === 1 && (i[s] &= ~(1 << o), this._nullCount = this.nullCount - 1), n;
  }
  clone(t = this.type, n = this.offset, i = this.length, r = this._nullCount, s = this, o = this.children) {
    return new Nm(t, n, i, r, s, o, this.dictionary);
  }
  slice(t, n) {
    const { stride: i, typeId: r, children: s } = this, o = +(this._nullCount === 0) - 1, a = r === 16 ? i : 1, c = this._sliceBuffers(t, n, i, r);
    return this.clone(
      this.type,
      this.offset + t,
      n,
      o,
      c,
      // Don't slice children if we have value offsets (the variable-width types)
      s.length === 0 || this.valueOffsets ? s : this._sliceChildren(s, a * t, a * n)
    );
  }
  _changeLengthAndBackfillNullBitmap(t) {
    if (this.typeId === R.Null)
      return this.clone(this.type, 0, t, 0);
    const { length: n, nullCount: i } = this, r = new Uint8Array((t + 63 & -64) >> 3).fill(255, 0, n >> 3);
    r[n >> 3] = (1 << n - (n & -8)) - 1, i > 0 && r.set(RD(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[Tr.VALIDITY] = r, this.clone(this.type, 0, t, i + (t - n), s);
  }
  _sliceBuffers(t, n, i, r) {
    let s;
    const { buffers: o } = this;
    return (s = o[Tr.TYPE]) && (o[Tr.TYPE] = s.subarray(t, t + n)), (s = o[Tr.OFFSET]) && (o[Tr.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[Tr.DATA]) && (o[Tr.DATA] = r === 6 ? s : s.subarray(i * t, i * (t + n))), o;
  }
  _sliceChildren(t, n, i) {
    return t.map((r) => r.slice(n, i));
  }
};
me.prototype.children = Object.freeze([]);
let UD = class lh extends Ut {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["length"]: r = 0 } = t;
    return new me(n, i, r, 0);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.data), s = Xt(t.nullBitmap), o = ll(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [o, r, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.data), s = Xt(t.nullBitmap), o = ll(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [o, r, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r } = t, s = Xt(t.nullBitmap), o = ll(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [o, void 0, s], [r]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Xt(t.nullBitmap), { length: o = r.reduce((c, { length: l }) => Math.max(c, l), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, void 0, s], r);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Xt(t.nullBitmap), o = ne(n.ArrayType, t.typeIds), { ["length"]: a = o.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    if (Ft.isSparseUnion(n))
      return new me(n, i, a, c, [void 0, void 0, s, o], r);
    const l = ll(t.valueOffsets);
    return new me(n, i, a, c, [l, void 0, s, o], r);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.indices.ArrayType, t.data), { ["dictionary"]: o = new Me([new lh().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [void 0, s, r], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new lh().visit({ type: n.valueType }) } = t, s = Xt(t.nullBitmap), { ["length"]: o = r.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, void 0, s], [r]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new lh().visit({ type: n.childType }) } = t, s = Xt(t.nullBitmap), o = ll(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [o, void 0, s], [r]);
  }
};
function Rt(e) {
  return new UD().visit(e);
}
let Bw = class {
  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 II(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function $I(e) {
  return e.reduce((t, n, i) => (t[i + 1] = t[i] + n.length, t), new Uint32Array(e.length + 1));
}
function AI(e, t, n, i) {
  const r = [];
  for (let s = -1, o = e.length; ++s < o; ) {
    const a = e[s], c = t[s], { length: l } = a;
    if (c >= i)
      break;
    if (n >= c + l)
      continue;
    if (c >= n && c + l <= i) {
      r.push(a);
      continue;
    }
    const u = Math.max(0, n - c), f = Math.min(i - c, l);
    r.push(a.slice(u, f - u));
  }
  return r.length === 0 && r.push(e[0].slice(0, 0)), r;
}
function x1(e, t, n, i) {
  let r = 0, s = 0, o = t.length - 1;
  do {
    if (r >= o - 1)
      return n < t[o] ? i(e, r, n - t[r]) : null;
    s = r + Math.trunc((o - r) * 0.5), n < t[s] ? o = s : r = s;
  } while (r < o);
}
function S1(e, t) {
  return e.getValid(t);
}
function qa(e) {
  function t(n, i, r) {
    return e(n[i], r);
  }
  return function(n) {
    const i = this.data;
    return x1(i, this._offsets, n, t);
  };
}
function MI(e) {
  let t;
  function n(i, r, s) {
    return e(i[r], s, t);
  }
  return function(i, r) {
    const s = this.data;
    t = r;
    const o = x1(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
function TI(e) {
  let t;
  function n(i, r, s) {
    let o = s, a = 0, c = 0;
    for (let l = r - 1, u = i.length; ++l < u; ) {
      const f = i[l];
      if (~(a = e(f, t, o)))
        return c + a;
      o = 0, c += f.length;
    }
    return -1;
  }
  return function(i, r) {
    t = i;
    const s = this.data, o = typeof r != "number" ? n(s, 0, 0) : x1(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
let ht = class extends Ut {
};
function zD(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function PD(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let i = 0;
  for (const r of new v1(n, e.offset + (t || 0), e.length, n, SI)) {
    if (!r)
      return i;
    ++i;
  }
  return -1;
}
function Bt(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    return PD(e, n);
  const i = gn.getVisitFn(e), r = Vc(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
function BI(e, t, n) {
  const i = gn.getVisitFn(e), r = Vc(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
ht.prototype.visitNull = zD;
ht.prototype.visitBool = Bt;
ht.prototype.visitInt = Bt;
ht.prototype.visitInt8 = Bt;
ht.prototype.visitInt16 = Bt;
ht.prototype.visitInt32 = Bt;
ht.prototype.visitInt64 = Bt;
ht.prototype.visitUint8 = Bt;
ht.prototype.visitUint16 = Bt;
ht.prototype.visitUint32 = Bt;
ht.prototype.visitUint64 = Bt;
ht.prototype.visitFloat = Bt;
ht.prototype.visitFloat16 = Bt;
ht.prototype.visitFloat32 = Bt;
ht.prototype.visitFloat64 = Bt;
ht.prototype.visitUtf8 = Bt;
ht.prototype.visitBinary = Bt;
ht.prototype.visitFixedSizeBinary = Bt;
ht.prototype.visitDate = Bt;
ht.prototype.visitDateDay = Bt;
ht.prototype.visitDateMillisecond = Bt;
ht.prototype.visitTimestamp = Bt;
ht.prototype.visitTimestampSecond = Bt;
ht.prototype.visitTimestampMillisecond = Bt;
ht.prototype.visitTimestampMicrosecond = Bt;
ht.prototype.visitTimestampNanosecond = Bt;
ht.prototype.visitTime = Bt;
ht.prototype.visitTimeSecond = Bt;
ht.prototype.visitTimeMillisecond = Bt;
ht.prototype.visitTimeMicrosecond = Bt;
ht.prototype.visitTimeNanosecond = Bt;
ht.prototype.visitDecimal = Bt;
ht.prototype.visitList = Bt;
ht.prototype.visitStruct = Bt;
ht.prototype.visitUnion = Bt;
ht.prototype.visitDenseUnion = BI;
ht.prototype.visitSparseUnion = BI;
ht.prototype.visitDictionary = Bt;
ht.prototype.visitInterval = Bt;
ht.prototype.visitIntervalDayTime = Bt;
ht.prototype.visitIntervalYearMonth = Bt;
ht.prototype.visitFixedSizeList = Bt;
ht.prototype.visitMap = Bt;
const Wh = new ht();
let dt = class extends Ut {
};
function vt(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === R.Timestamp || t instanceof Rs && t.bitWidth !== 64 || t instanceof ou && t.bitWidth !== 64 || t instanceof su && t.precision !== yn.HALF))
    return new Bw(e.data.length, (i) => {
      const r = e.data[i];
      return r.values.subarray(0, r.length)[Symbol.iterator]();
    });
  let n = 0;
  return new Bw(e.data.length, (i) => {
    const s = e.data[i].length, o = e.slice(n, n + s);
    return n += s, new VD(o);
  });
}
let VD = class {
  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;
  }
};
dt.prototype.visitNull = vt;
dt.prototype.visitBool = vt;
dt.prototype.visitInt = vt;
dt.prototype.visitInt8 = vt;
dt.prototype.visitInt16 = vt;
dt.prototype.visitInt32 = vt;
dt.prototype.visitInt64 = vt;
dt.prototype.visitUint8 = vt;
dt.prototype.visitUint16 = vt;
dt.prototype.visitUint32 = vt;
dt.prototype.visitUint64 = vt;
dt.prototype.visitFloat = vt;
dt.prototype.visitFloat16 = vt;
dt.prototype.visitFloat32 = vt;
dt.prototype.visitFloat64 = vt;
dt.prototype.visitUtf8 = vt;
dt.prototype.visitBinary = vt;
dt.prototype.visitFixedSizeBinary = vt;
dt.prototype.visitDate = vt;
dt.prototype.visitDateDay = vt;
dt.prototype.visitDateMillisecond = vt;
dt.prototype.visitTimestamp = vt;
dt.prototype.visitTimestampSecond = vt;
dt.prototype.visitTimestampMillisecond = vt;
dt.prototype.visitTimestampMicrosecond = vt;
dt.prototype.visitTimestampNanosecond = vt;
dt.prototype.visitTime = vt;
dt.prototype.visitTimeSecond = vt;
dt.prototype.visitTimeMillisecond = vt;
dt.prototype.visitTimeMicrosecond = vt;
dt.prototype.visitTimeNanosecond = vt;
dt.prototype.visitDecimal = vt;
dt.prototype.visitList = vt;
dt.prototype.visitStruct = vt;
dt.prototype.visitUnion = vt;
dt.prototype.visitDenseUnion = vt;
dt.prototype.visitSparseUnion = vt;
dt.prototype.visitDictionary = vt;
dt.prototype.visitInterval = vt;
dt.prototype.visitIntervalDayTime = vt;
dt.prototype.visitIntervalYearMonth = vt;
dt.prototype.visitFixedSizeList = vt;
dt.prototype.visitMap = vt;
const I1 = new dt(), jD = (e, t) => e + t;
let Zs = class extends Ut {
  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 === jt.SECOND ? 4 : 8;
  }
  visitInterval(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitStruct(t, n) {
    return t.children.reduce((i, r) => i + sr.visit(r, n), 0);
  }
  visitFixedSizeBinary(t, n) {
    return t.type.byteWidth;
  }
  visitMap(t, n) {
    return 8 + t.children.reduce((i, r) => i + sr.visit(r, n), 0);
  }
  visitDictionary(t, n) {
    var i;
    return t.type.indices.bitWidth / 8 + (((i = t.dictionary) === null || i === void 0 ? void 0 : i.getByteLength(t.values[n])) || 0);
  }
};
const YD = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), qD = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), WD = ({ valueOffsets: e, stride: t, children: n }, i) => {
  const r = n[0], { [i * t]: s } = e, { [i * t + 1]: o } = e, a = sr.getVisitFn(r.type), c = r.slice(s, o - s);
  let l = 8;
  for (let u = -1, f = o - s; ++u < f; )
    l += a(c, u);
  return l;
}, GD = ({ stride: e, children: t }, n) => {
  const i = t[0], r = i.slice(n * e, e), s = sr.getVisitFn(i.type);
  let o = 0;
  for (let a = -1, c = r.length; ++a < c; )
    o += s(r, a);
  return o;
}, XD = (e, t) => e.type.mode === gi.Dense ? NI(e, t) : FI(e, t), NI = ({ type: e, children: t, typeIds: n, valueOffsets: i }, r) => {
  const s = e.typeIdToChildIndex[n[r]];
  return 8 + sr.visit(t[s], i[r]);
}, FI = ({ children: e }, t) => 4 + sr.visitMany(e, e.map(() => t)).reduce(jD, 0);
Zs.prototype.visitUtf8 = YD;
Zs.prototype.visitBinary = qD;
Zs.prototype.visitList = WD;
Zs.prototype.visitFixedSizeList = GD;
Zs.prototype.visitUnion = XD;
Zs.prototype.visitDenseUnion = NI;
Zs.prototype.visitSparseUnion = FI;
const sr = new Zs();
var DI;
const OI = {}, EI = {};
let Me = class yo {
  constructor(t) {
    var n, i, r;
    const s = t[0] instanceof yo ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof me)))
      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: l, byteLength: u } = OI[o.typeId], f = s[0];
        this.isValid = (h) => S1(f, h), this.get = (h) => a(f, h), this.set = (h, d) => c(f, h, d), this.indexOf = (h) => l(f, h), this.getByteLength = (h) => u(f, h), this._offsets = [0, f.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, EI[o.typeId]), this._offsets = $I(s);
        break;
    }
    this.data = s, this.type = o, this.stride = Br(o), this.numChildren = (r = (i = o.children) === null || i === void 0 ? void 0 : i.length) !== null && r !== void 0 ? r : 0, this.length = this._offsets[this._offsets.length - 1];
  }
  /**
   * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
   */
  get byteLength() {
    return this._byteLength === -1 && (this._byteLength = this.data.reduce((t, n) => t + n.byteLength, 0)), this._byteLength;
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return this._nullCount === -1 && (this._nullCount = II(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 `${R[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 I1.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 yo(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 yo(xI(this, t, n, ({ data: i, _offsets: r }, s, o) => AI(i, r, s, o)));
  }
  toJSON() {
    return [...this];
  }
  /**
   * Return a JavaScript Array or TypedArray of the Vector's elements.
   *
   * @note If this Vector contains a single Data chunk and the Vector's type is a
   *  primitive numeric type corresponding to one of the JavaScript TypedArrays, this
   *  method returns a zero-copy slice of the underlying TypedArray values. If there's
   *  more than one chunk, the resulting TypedArray will be a copy of the data from each
   *  chunk's underlying TypedArray values.
   *
   * @returns An Array or TypedArray of the Vector's elements, based on the Vector's DataType.
   */
  toArray() {
    const { type: t, data: n, length: i, stride: r, ArrayType: s } = this;
    switch (t.typeId) {
      case R.Int:
      case R.Float:
      case R.Decimal:
      case R.Time:
      case R.Timestamp:
        switch (n.length) {
          case 0:
            return new s();
          case 1:
            return n[0].values.subarray(0, i * r);
          default:
            return n.reduce((o, { values: a, length: c }) => (o.array.set(a.subarray(0, c * r), o.offset), o.offset += c * r, o), { array: new s(i * r), offset: 0 }).array;
        }
    }
    return [...this];
  }
  /**
   * Returns a string representation of the Vector.
   *
   * @returns A string representation of the Vector.
   */
  toString() {
    return `[${[...this].join(",")}]`;
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    var n;
    return this.getChildAt((n = this.type.children) === null || n === void 0 ? void 0 : n.findIndex((i) => i.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    return t > -1 && t < this.numChildren ? new yo(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return Ft.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 (Ft.isDictionary(this.type)) {
      const t = new Nw(this.data[0].dictionary), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new yo(n);
    }
    return new Nw(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 (Ft.isDictionary(this.type) && this.isMemoized) {
      const t = this.data[0].dictionary.unmemoize(), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new yo(n);
    }
    return this;
  }
};
DI = Symbol.toStringTag;
Me[DI] = ((e) => {
  e.type = Ft.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(R).map((n) => R[n]).filter((n) => typeof n == "number" && n !== R.NONE);
  for (const n of t) {
    const i = gn.getVisitFnByTypeId(n), r = ei.getVisitFnByTypeId(n), s = Wh.getVisitFnByTypeId(n), o = sr.getVisitFnByTypeId(n);
    OI[n] = { get: i, set: r, indexOf: s, byteLength: o }, EI[n] = Object.create(e, {
      isValid: { value: qa(S1) },
      get: { value: qa(gn.getVisitFnByTypeId(n)) },
      set: { value: MI(ei.getVisitFnByTypeId(n)) },
      indexOf: { value: TI(Wh.getVisitFnByTypeId(n)) },
      getByteLength: { value: qa(sr.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(Me.prototype);
let Nw = class LI extends Me {
  constructor(t) {
    super(t.data);
    const n = this.get, i = this.set, r = this.slice, s = new Array(this.length);
    Object.defineProperty(this, "get", {
      value(o) {
        const a = s[o];
        if (a !== void 0)
          return a;
        const c = n.call(this, o);
        return s[o] = c, c;
      }
    }), Object.defineProperty(this, "set", {
      value(o, a) {
        i.call(this, o, a), s[o] = a;
      }
    }), Object.defineProperty(this, "slice", {
      value: (o, a) => new LI(r.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new Me(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}, Fm = class {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * Index to the start of the RecordBlock (note this is past the Message header)
   */
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * Length of the metadata
   */
  metaDataLength() {
    return this.bb.readInt32(this.bb_pos + 8);
  }
  /**
   * Length of the data (this is aligned so there can be a gap between this and
   * the metadata).
   */
  bodyLength() {
    return this.bb.readInt64(this.bb_pos + 16);
  }
  static sizeOf() {
    return 24;
  }
  static createBlock(t, n, i, r) {
    return t.prep(8, 24), t.writeInt64(BigInt(r ?? 0)), t.pad(4), t.writeInt32(i), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
};
const y0 = 2, ji = 4, Lr = 4, se = 4, bs = new Int32Array(2), Fw = new Float32Array(bs.buffer), Dw = new Float64Array(bs.buffer), Mf = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
var Dm;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(Dm || (Dm = {}));
let uc = class RI {
  /**
   * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
   */
  constructor(t) {
    this.bytes_ = t, this.position_ = 0, this.text_decoder_ = new TextDecoder();
  }
  /**
   * Create and allocate a new ByteBuffer with a given size.
   */
  static allocate(t) {
    return new RI(new Uint8Array(t));
  }
  clear() {
    this.position_ = 0;
  }
  /**
   * Get the underlying `Uint8Array`.
   */
  bytes() {
    return this.bytes_;
  }
  /**
   * Get the buffer's position.
   */
  position() {
    return this.position_;
  }
  /**
   * Set the buffer's position.
   */
  setPosition(t) {
    this.position_ = t;
  }
  /**
   * Get the buffer's capacity.
   */
  capacity() {
    return this.bytes_.length;
  }
  readInt8(t) {
    return this.readUint8(t) << 24 >> 24;
  }
  readUint8(t) {
    return this.bytes_[t];
  }
  readInt16(t) {
    return this.readUint16(t) << 16 >> 16;
  }
  readUint16(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8;
  }
  readInt32(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8 | this.bytes_[t + 2] << 16 | this.bytes_[t + 3] << 24;
  }
  readUint32(t) {
    return this.readInt32(t) >>> 0;
  }
  readInt64(t) {
    return BigInt.asIntN(64, BigInt(this.readUint32(t)) + (BigInt(this.readUint32(t + 4)) << BigInt(32)));
  }
  readUint64(t) {
    return BigInt.asUintN(64, BigInt(this.readUint32(t)) + (BigInt(this.readUint32(t + 4)) << BigInt(32)));
  }
  readFloat32(t) {
    return bs[0] = this.readInt32(t), Fw[0];
  }
  readFloat64(t) {
    return bs[Mf ? 0 : 1] = this.readInt32(t), bs[Mf ? 1 : 0] = this.readInt32(t + 4), Dw[0];
  }
  writeInt8(t, n) {
    this.bytes_[t] = n;
  }
  writeUint8(t, n) {
    this.bytes_[t] = n;
  }
  writeInt16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeUint16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeInt32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeUint32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeInt64(t, n) {
    this.writeInt32(t, Number(BigInt.asIntN(32, n))), this.writeInt32(t + 4, Number(BigInt.asIntN(32, n >> BigInt(32))));
  }
  writeUint64(t, n) {
    this.writeUint32(t, Number(BigInt.asUintN(32, n))), this.writeUint32(t + 4, Number(BigInt.asUintN(32, n >> BigInt(32))));
  }
  writeFloat32(t, n) {
    Fw[0] = n, this.writeInt32(t, bs[0]);
  }
  writeFloat64(t, n) {
    Dw[0] = n, this.writeInt32(t, bs[Mf ? 0 : 1]), this.writeInt32(t + 4, bs[Mf ? 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_ + ji + Lr)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < Lr; n++)
      t += String.fromCharCode(this.readInt8(this.position_ + ji + n));
    return t;
  }
  /**
   * Look up a field in the vtable, return an offset into the object, or 0 if the
   * field is not present.
   */
  __offset(t, n) {
    const i = t - this.readInt32(t);
    return n < this.readInt16(i) ? this.readInt16(i + n) : 0;
  }
  /**
   * Initialize any Table-derived type to point to the union at the given offset.
   */
  __union(t, n) {
    return t.bb_pos = n + this.readInt32(n), t.bb = this, t;
  }
  /**
   * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.
   * This allocates a new string and converts to wide chars upon each access.
   *
   * To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
   * "optionalEncoding" argument. This is useful for avoiding conversion when
   * the data will just be packaged back up in another FlatBuffer later on.
   *
   * @param offset
   * @param opt_encoding Defaults to UTF16_STRING
   */
  __string(t, n) {
    t += this.readInt32(t);
    const i = this.readInt32(t);
    t += ji;
    const r = this.bytes_.subarray(t, t + i);
    return n === Dm.UTF8_BYTES ? r : this.text_decoder_.decode(r);
  }
  /**
   * Handle unions that can contain string as its member, if a Table-derived type then initialize it,
   * if a string then return a new one
   *
   * WARNING: strings are immutable in JS so we can't change the string that the user gave us, this
   * makes the behaviour of __union_with_string different compared to __union
   */
  __union_with_string(t, n) {
    return typeof t == "string" ? this.__string(n) : this.__union(t, n);
  }
  /**
   * Retrieve the relative offset stored at "offset"
   */
  __indirect(t) {
    return t + this.readInt32(t);
  }
  /**
   * Get the start of data of a vector whose offset is stored at "offset" in this object.
   */
  __vector(t) {
    return t + this.readInt32(t) + ji;
  }
  /**
   * 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 != Lr)
      throw new Error("FlatBuffers: file identifier must be length " + Lr);
    for (let n = 0; n < Lr; n++)
      if (t.charCodeAt(n) != this.readInt8(this.position() + ji + n))
        return !1;
    return !0;
  }
  /**
   * A helper function for generating list for obj api
   */
  createScalarList(t, n) {
    const i = [];
    for (let r = 0; r < n; ++r) {
      const s = t(r);
      s !== null && i.push(s);
    }
    return i;
  }
  /**
   * A helper function for generating list for obj api
   * @param listAccessor function that accepts an index and return data at that index
   * @param listLength listLength
   * @param res result list
   */
  createObjList(t, n) {
    const i = [];
    for (let r = 0; r < n; ++r) {
      const s = t(r);
      s !== null && i.push(s.unpack());
    }
    return i;
  }
}, CI = class kI {
  /**
   * Create a FlatBufferBuilder.
   */
  constructor(t) {
    this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null, this.text_encoder = new TextEncoder();
    let n;
    t ? n = t : n = 1024, this.bb = uc.allocate(n), this.space = n;
  }
  clear() {
    this.bb.clear(), this.space = this.bb.capacity(), this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null;
  }
  /**
   * In order to save space, fields that are set to their default value
   * don't get serialized into the buffer. Forcing defaults provides a
   * way to manually disable this optimization.
   *
   * @param forceDefaults true always serializes default values
   */
  forceDefaults(t) {
    this.force_defaults = t;
  }
  /**
   * Get the ByteBuffer representing the FlatBuffer. Only call this after you've
   * called finish(). The actual data starts at the ByteBuffer's current position,
   * not necessarily at 0.
   */
  dataBuffer() {
    return this.bb;
  }
  /**
   * Get the bytes representing the FlatBuffer. Only call this after you've
   * called finish().
   */
  asUint8Array() {
    return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());
  }
  /**
   * Prepare to write an element of `size` after `additional_bytes` have been
   * written, e.g. if you write a string, you need to align such the int length
   * field is aligned to 4 bytes, and the string data follows it directly. If all
   * you need to do is alignment, `additional_bytes` will be 0.
   *
   * @param size This is the of the new element to write
   * @param additional_bytes The padding size
   */
  prep(t, n) {
    t > this.minalign && (this.minalign = t);
    const i = ~(this.bb.capacity() - this.space + n) + 1 & t - 1;
    for (; this.space < i + t + n; ) {
      const r = this.bb.capacity();
      this.bb = kI.growByteBuffer(this.bb), this.space += this.bb.capacity() - r;
    }
    this.pad(i);
  }
  pad(t) {
    for (let n = 0; n < t; n++)
      this.bb.writeInt8(--this.space, 0);
  }
  writeInt8(t) {
    this.bb.writeInt8(this.space -= 1, t);
  }
  writeInt16(t) {
    this.bb.writeInt16(this.space -= 2, t);
  }
  writeInt32(t) {
    this.bb.writeInt32(this.space -= 4, t);
  }
  writeInt64(t) {
    this.bb.writeInt64(this.space -= 8, t);
  }
  writeFloat32(t) {
    this.bb.writeFloat32(this.space -= 4, t);
  }
  writeFloat64(t) {
    this.bb.writeFloat64(this.space -= 8, t);
  }
  /**
   * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int8` to add the buffer.
   */
  addInt8(t) {
    this.prep(1, 0), this.writeInt8(t);
  }
  /**
   * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int16` to add the buffer.
   */
  addInt16(t) {
    this.prep(2, 0), this.writeInt16(t);
  }
  /**
   * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int32` to add the buffer.
   */
  addInt32(t) {
    this.prep(4, 0), this.writeInt32(t);
  }
  /**
   * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int64` to add the buffer.
   */
  addInt64(t) {
    this.prep(8, 0), this.writeInt64(t);
  }
  /**
   * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float32` to add the buffer.
   */
  addFloat32(t) {
    this.prep(4, 0), this.writeFloat32(t);
  }
  /**
   * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float64` to add the buffer.
   */
  addFloat64(t) {
    this.prep(8, 0), this.writeFloat64(t);
  }
  addFieldInt8(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt8(n), this.slot(t));
  }
  addFieldInt16(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt16(n), this.slot(t));
  }
  addFieldInt32(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt32(n), this.slot(t));
  }
  addFieldInt64(t, n, i) {
    (this.force_defaults || n !== i) && (this.addInt64(n), this.slot(t));
  }
  addFieldFloat32(t, n, i) {
    (this.force_defaults || n != i) && (this.addFloat32(n), this.slot(t));
  }
  addFieldFloat64(t, n, i) {
    (this.force_defaults || n != i) && (this.addFloat64(n), this.slot(t));
  }
  addFieldOffset(t, n, i) {
    (this.force_defaults || n != i) && (this.addOffset(n), this.slot(t));
  }
  /**
   * Structs are stored inline, so nothing additional is being added. `d` is always 0.
   */
  addFieldStruct(t, n, i) {
    n != i && (this.nested(n), this.slot(t));
  }
  /**
   * Structures are always stored inline, they need to be created right
   * where they're used.  You'll get this assertion failure if you
   * created it elsewhere.
   */
  nested(t) {
    if (t != this.offset())
      throw new Error("FlatBuffers: struct must be serialized inline.");
  }
  /**
   * Should not be creating any other object, string or vector
   * while an object is being constructed
   */
  notNested() {
    if (this.isNested)
      throw new Error("FlatBuffers: object serialization must not be nested.");
  }
  /**
   * Set the current vtable at `voffset` to the current location in the buffer.
   */
  slot(t) {
    this.vtable !== null && (this.vtable[t] = this.offset());
  }
  /**
   * @returns Offset relative to the end of the buffer.
   */
  offset() {
    return this.bb.capacity() - this.space;
  }
  /**
   * Doubles the size of the backing ByteBuffer and copies the old data towards
   * the end of the new buffer (since we build the buffer backwards).
   *
   * @param bb The current buffer with the existing data
   * @returns A new byte buffer with the old data copied
   * to it. The data is located at the end of the buffer.
   *
   * uint8Array.set() formally takes {Array<number>|ArrayBufferView}, so to pass
   * it a uint8Array we need to suppress the type check:
   * @suppress {checkTypes}
   */
  static growByteBuffer(t) {
    const n = t.capacity();
    if (n & 3221225472)
      throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
    const i = n << 1, r = uc.allocate(i);
    return r.setPosition(i - n), r.bytes().set(t.bytes(), i - n), r;
  }
  /**
   * Adds on offset, relative to where it will be written.
   *
   * @param offset The offset to add.
   */
  addOffset(t) {
    this.prep(ji, 0), this.writeInt32(this.offset() - t + ji);
  }
  /**
   * Start encoding a new object in the buffer.  Users will not usually need to
   * call this directly. The FlatBuffers compiler will generate helper methods
   * that call this method internally.
   */
  startObject(t) {
    this.notNested(), this.vtable == null && (this.vtable = []), this.vtable_in_use = t;
    for (let n = 0; n < t; n++)
      this.vtable[n] = 0;
    this.isNested = !0, this.object_start = this.offset();
  }
  /**
   * Finish off writing the object that is under construction.
   *
   * @returns The offset to the object inside `dataBuffer`
   */
  endObject() {
    if (this.vtable == null || !this.isNested)
      throw new Error("FlatBuffers: endObject called without startObject");
    this.addInt32(0);
    const t = this.offset();
    let n = this.vtable_in_use - 1;
    for (; n >= 0 && this.vtable[n] == 0; n--)
      ;
    const i = n + 1;
    for (; n >= 0; n--)
      this.addInt16(this.vtable[n] != 0 ? t - this.vtable[n] : 0);
    const r = 2;
    this.addInt16(t - this.object_start);
    const s = (i + r) * y0;
    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 l = y0; l < s; l += y0)
            if (this.bb.readInt16(a + l) != this.bb.readInt16(c + l))
              continue t;
          o = this.vtables[n];
          break;
        }
      }
    return o ? (this.space = this.bb.capacity() - t, this.bb.writeInt32(this.space, o - t)) : (this.vtables.push(this.offset()), this.bb.writeInt32(this.bb.capacity() - t, this.offset() - t)), this.isNested = !1, t;
  }
  /**
   * Finalize a buffer, poiting to the given `root_table`.
   */
  finish(t, n, i) {
    const r = i ? se : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, ji + Lr + r), s.length != Lr)
        throw new Error("FlatBuffers: file identifier must be length " + Lr);
      for (let o = Lr - 1; o >= 0; o--)
        this.writeInt8(s.charCodeAt(o));
    }
    this.prep(this.minalign, ji + r), this.addOffset(t), r && this.addInt32(this.bb.capacity() - this.space), this.bb.setPosition(this.space);
  }
  /**
   * Finalize a size prefixed buffer, pointing to the given `root_table`.
   */
  finishSizePrefixed(t, n) {
    this.finish(t, n, !0);
  }
  /**
   * This checks a required field has been set in a given table that has
   * just been constructed.
   */
  requiredField(t, n) {
    const i = this.bb.capacity() - t, r = i - this.bb.readInt32(i);
    if (!(n < this.bb.readInt16(r) && this.bb.readInt16(r + n) != 0))
      throw new Error("FlatBuffers: field " + n + " must be set");
  }
  /**
   * Start a new array/vector of objects.  Users usually will not call
   * this directly. The FlatBuffers compiler will create a start/end
   * method for vector types in generated code.
   *
   * @param elem_size The size of each element in the array
   * @param num_elems The number of elements in the array
   * @param alignment The alignment of the array
   */
  startVector(t, n, i) {
    this.notNested(), this.vector_num_elems = n, this.prep(ji, t * n), this.prep(i, t * n);
  }
  /**
   * Finish off the creation of an array and all its elements. The array must be
   * created with `startVector`.
   *
   * @returns The offset at which the newly created array
   * starts.
   */
  endVector() {
    return this.writeInt32(this.vector_num_elems), this.offset();
  }
  /**
   * Encode the string `s` in the buffer using UTF-8. If the string passed has
   * already been seen, we return the offset of the already written string
   *
   * @param s The string to encode
   * @return The offset in the buffer where the encoded string starts
   */
  createSharedString(t) {
    if (!t)
      return 0;
    if (this.string_maps || (this.string_maps = /* @__PURE__ */ new Map()), this.string_maps.has(t))
      return this.string_maps.get(t);
    const n = this.createString(t);
    return this.string_maps.set(t, n), n;
  }
  /**
   * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed
   * instead of a string, it is assumed to contain valid UTF-8 encoded data.
   *
   * @param s The string to encode
   * @return The offset in the buffer where the encoded string starts
   */
  createString(t) {
    if (t == null)
      return 0;
    let n;
    t instanceof Uint8Array ? n = t : n = this.text_encoder.encode(t), this.addInt8(0), this.startVector(1, n.length, 1), this.bb.setPosition(this.space -= n.length);
    for (let i = 0, r = this.space, s = this.bb.bytes(); i < n.length; i++)
      s[r++] = n[i];
    return this.endVector();
  }
  /**
   * A helper function to pack an object
   *
   * @returns offset of obj
   */
  createObjectOffset(t) {
    return t === null ? 0 : typeof t == "string" ? this.createString(t) : t.pack(this);
  }
  /**
   * A helper function to pack a list of object
   *
   * @returns list of offsets of each non null object
   */
  createObjectOffsetList(t) {
    const n = [];
    for (let i = 0; i < t.length; ++i) {
      const r = t[i];
      if (r !== null)
        n.push(this.createObjectOffset(r));
      else
        throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return n;
  }
  createStructOffsetList(t, n) {
    return n(this, t.length), this.createObjectOffsetList(t.slice().reverse()), this.endVector();
  }
}, Xn = class mo {
  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 mo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + se), (n || new mo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  key(t) {
    const n = this.bb.__offset(this.bb_pos, 4);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  value(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  static startKeyValue(t) {
    t.startObject(2);
  }
  static addKey(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addValue(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endKeyValue(t) {
    return t.endObject();
  }
  static createKeyValue(t, n, i) {
    return mo.startKeyValue(t), mo.addKey(t, n), mo.addValue(t, i), mo.endKeyValue(t);
  }
};
var fc;
(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";
})(fc || (fc = {}));
var hc;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(hc || (hc = {}));
var Gh;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(Gh || (Gh = {}));
let La = class go {
  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 go()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + se), (n || new go()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  isSigned() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startInt(t) {
    t.startObject(2);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static addIsSigned(t, n) {
    t.addFieldInt8(1, +n, 0);
  }
  static endInt(t) {
    return t.endObject();
  }
  static createInt(t, n, i) {
    return go.startInt(t), go.addBitWidth(t, n), go.addIsSigned(t, i), go.endInt(t);
  }
}, wa = class Om {
  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 Om()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + se), (n || new Om()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * The known dictionary id in the application where this data is used. In
   * the file or streaming formats, the dictionary ids are found in the
   * DictionaryBatch messages
   */
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  /**
   * The dictionary indices are constrained to be non-negative integers. If
   * this field is null, the indices must be signed int32. To maximize
   * cross-language compatibility and performance, implementations are
   * recommended to prefer signed integer types over unsigned integer types
   * and to avoid uint64 indices unless they are required by an application.
   */
  indexType(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new La()).__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) : Gh.DenseArray;
  }
  static startDictionaryEncoding(t) {
    t.startObject(4);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addIndexType(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsOrdered(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static addDictionaryKind(t, n) {
    t.addFieldInt16(3, n, Gh.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}, Ow = class Sl {
  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 Sl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + se), (n || new Sl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return Sl.startBinary(t), Sl.endBinary(t);
  }
}, Ew = class Il {
  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 Il()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + se), (n || new Il()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return Il.startBool(t), Il.endBool(t);
  }
};
var Xh;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Xh || (Xh = {}));
let uh = class va {
  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 va()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + se), (n || new va()).__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) : Xh.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Xh.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return va.startDate(t), va.addUnit(t, n), va.endDate(t);
  }
}, xa = class gs {
  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 gs()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + se), (n || new gs()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Total number of decimal digits
   */
  precision() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  /**
   * Number of digits after the decimal point "."
   */
  scale() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  /**
   * Number of bits per value. The only accepted widths are 128 and 256.
   * We use bitWidth for consistency with Int::bitWidth.
   */
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.readInt32(this.bb_pos + t) : 128;
  }
  static startDecimal(t) {
    t.startObject(3);
  }
  static addPrecision(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static addScale(t, n) {
    t.addFieldInt32(1, n, 0);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(2, n, 128);
  }
  static endDecimal(t) {
    return t.endObject();
  }
  static createDecimal(t, n, i, r) {
    return gs.startDecimal(t), gs.addPrecision(t, n), gs.addScale(t, i), gs.addBitWidth(t, r), gs.endDecimal(t);
  }
};
var dc;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(dc || (dc = {}));
let fh = class Sa {
  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 Sa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + se), (n || new Sa()).__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 Sa.startFixedSizeBinary(t), Sa.addByteWidth(t, n), Sa.endFixedSizeBinary(t);
  }
}, hh = class Ia {
  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 Ia()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + se), (n || new Ia()).__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 Ia.startFixedSizeList(t), Ia.addListSize(t, n), Ia.endFixedSizeList(t);
  }
};
var Hh;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(Hh || (Hh = {}));
let dh = class $a {
  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 $a()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + se), (n || new $a()).__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) : Hh.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, Hh.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return $a.startFloatingPoint(t), $a.addPrecision(t, n), $a.endFloatingPoint(t);
  }
};
var Kh;
(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";
})(Kh || (Kh = {}));
let ph = class Aa {
  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 Aa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + se), (n || new Aa()).__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) : Kh.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Kh.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return Aa.startInterval(t), Aa.addUnit(t, n), Aa.endInterval(t);
  }
}, Lw = class $l {
  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 $l()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + se), (n || new $l()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return $l.startList(t), $l.endList(t);
  }
}, yh = class Ma {
  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 Ma()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + se), (n || new Ma()).__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 Ma.startMap(t), Ma.addKeysSorted(t, n), Ma.endMap(t);
  }
}, Rw = class Al {
  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 Al()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + se), (n || new Al()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return Al.startNull(t), Al.endNull(t);
  }
}, Cw = class Ml {
  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 Ml()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + se), (n || new Ml()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return Ml.startStruct_(t), Ml.endStruct_(t);
  }
}, Tl = class bo {
  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 bo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + se), (n || new bo()).__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) : dc.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, dc.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, i) {
    return bo.startTime(t), bo.addUnit(t, n), bo.addBitWidth(t, i), bo.endTime(t);
  }
}, Bl = class _o {
  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 _o()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + se), (n || new _o()).__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) : dc.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, dc.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, i) {
    return _o.startTimestamp(t), _o.addUnit(t, n), _o.addTimezone(t, i), _o.endTimestamp(t);
  }
};
var Jh;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(Jh || (Jh = {}));
let wo = class vo {
  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 vo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + se), (n || new vo()).__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) : Jh.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, Jh.Sparse);
  }
  static addTypeIds(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createTypeIdsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addInt32(n[i]);
    return t.endVector();
  }
  static startTypeIdsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endUnion(t) {
    return t.endObject();
  }
  static createUnion(t, n, i) {
    return vo.startUnion(t), vo.addMode(t, n), vo.addTypeIds(t, i), vo.endUnion(t);
  }
}, kw = class Nl {
  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 Nl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + se), (n || new Nl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return Nl.startUtf8(t), Nl.endUtf8(t);
  }
};
var ge;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Null = 1] = "Null", e[e.Int = 2] = "Int", e[e.FloatingPoint = 3] = "FloatingPoint", e[e.Binary = 4] = "Binary", e[e.Utf8 = 5] = "Utf8", e[e.Bool = 6] = "Bool", e[e.Decimal = 7] = "Decimal", e[e.Date = 8] = "Date", e[e.Time = 9] = "Time", e[e.Timestamp = 10] = "Timestamp", e[e.Interval = 11] = "Interval", e[e.List = 12] = "List", e[e.Struct_ = 13] = "Struct_", e[e.Union = 14] = "Union", e[e.FixedSizeBinary = 15] = "FixedSizeBinary", e[e.FixedSizeList = 16] = "FixedSizeList", e[e.Map = 17] = "Map", e[e.Duration = 18] = "Duration", e[e.LargeBinary = 19] = "LargeBinary", e[e.LargeUtf8 = 20] = "LargeUtf8", e[e.LargeList = 21] = "LargeList", e[e.RunEndEncoded = 22] = "RunEndEncoded";
})(ge || (ge = {}));
let Un = class mh {
  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 mh()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + se), (n || new mh()).__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) : ge.NONE;
  }
  /**
   * This is the type of the decoded value if the field is dictionary encoded.
   */
  type(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  /**
   * Present only if the field is dictionary encoded.
   */
  dictionary(t) {
    const n = this.bb.__offset(this.bb_pos, 12);
    return n ? (t || new wa()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * children apply only to nested data types like Struct, List and Union. For
   * primitive types children will have length 0.
   */
  children(t, n) {
    const i = this.bb.__offset(this.bb_pos, 14);
    return i ? (n || new mh()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  childrenLength() {
    const t = this.bb.__offset(this.bb_pos, 14);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * User-defined metadata
   */
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 16);
    return i ? (n || new Xn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 16);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startField(t) {
    t.startObject(7);
  }
  static addName(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addNullable(t, n) {
    t.addFieldInt8(1, +n, 0);
  }
  static addTypeType(t, n) {
    t.addFieldInt8(2, n, ge.NONE);
  }
  static addType(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static addDictionary(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static addChildren(t, n) {
    t.addFieldOffset(5, n, 0);
  }
  static createChildrenVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startChildrenVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(6, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endField(t) {
    return t.endObject();
  }
}, ki = 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() + se), (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) : hc.Little;
  }
  fields(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new Un()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  fieldsLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new Xn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Features used in the stream/file.
   */
  features(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.readInt64(this.bb.__vector(this.bb_pos + n) + t * 8) : BigInt(0);
  }
  featuresLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startSchema(t) {
    t.startObject(4);
  }
  static addEndianness(t, n) {
    t.addFieldInt16(0, n, hc.Little);
  }
  static addFields(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createFieldsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startFieldsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addFeatures(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static createFeaturesVector(t, n) {
    t.startVector(8, n.length, 8);
    for (let i = n.length - 1; i >= 0; i--)
      t.addInt64(n[i]);
    return t.endVector();
  }
  static startFeaturesVector(t, n) {
    t.startVector(8, n, 8);
  }
  static endSchema(t) {
    return t.endObject();
  }
  static finishSchemaBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedSchemaBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
  static createSchema(t, n, i, r, s) {
    return xr.startSchema(t), xr.addEndianness(t, n), xr.addFields(t, i), xr.addCustomMetadata(t, r), xr.addFeatures(t, s), xr.endSchema(t);
  }
}, Li = class Em {
  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 Em()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + se), (n || new Em()).__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) : fc.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new ki()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  dictionaries(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new Fm()).__init(this.bb.__vector(this.bb_pos + i) + t * 24, this.bb) : null;
  }
  dictionariesLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  recordBatches(t, n) {
    const i = this.bb.__offset(this.bb_pos, 10);
    return i ? (n || new Fm()).__init(this.bb.__vector(this.bb_pos + i) + t * 24, this.bb) : null;
  }
  recordBatchesLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * User-defined metadata
   */
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new Xn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 12);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startFooter(t) {
    t.startObject(5);
  }
  static addVersion(t, n) {
    t.addFieldInt16(0, n, fc.V1);
  }
  static addSchema(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addDictionaries(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startDictionariesVector(t, n) {
    t.startVector(24, n, 8);
  }
  static addRecordBatches(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static startRecordBatchesVector(t, n) {
    t.startVector(24, n, 8);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endFooter(t) {
    return t.endObject();
  }
  static finishFooterBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedFooterBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
}, _e = class xo {
  constructor(t = [], n, i) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), i || (i = Rm(t)), this.dictionaries = i;
  }
  get [Symbol.toStringTag]() {
    return "Schema";
  }
  get names() {
    return this.fields.map((t) => t.name);
  }
  toString() {
    return `Schema<{ ${this.fields.map((t, n) => `${n}: ${t}`).join(", ")} }>`;
  }
  /**
   * Construct a new Schema containing only specified fields.
   *
   * @param fieldNames Names of fields to keep.
   * @returns A new Schema of fields matching the specified names.
   */
  select(t) {
    const n = new Set(t), i = this.fields.filter((r) => n.has(r.name));
    return new xo(i, this.metadata);
  }
  /**
   * Construct a new Schema containing only fields at the specified indices.
   *
   * @param fieldIndices Indices of fields to keep.
   * @returns A new Schema of fields at the specified indices.
   */
  selectAt(t) {
    const n = t.map((i) => this.fields[i]).filter(Boolean);
    return new xo(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof xo ? t[0] : Array.isArray(t[0]) ? new xo(t[0]) : new xo(t), i = [...this.fields], r = Tf(Tf(/* @__PURE__ */ new Map(), this.metadata), n.metadata), s = n.fields.filter((a) => {
      const c = i.findIndex((l) => l.name === a.name);
      return ~c ? (i[c] = a.clone({
        metadata: Tf(Tf(/* @__PURE__ */ new Map(), i[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = Rm(s, /* @__PURE__ */ new Map());
    return new xo([...i, ...s], r, new Map([...this.dictionaries, ...o]));
  }
};
_e.prototype.fields = null;
_e.prototype.metadata = null;
_e.prototype.dictionaries = null;
let Ae = class Lm {
  /** @nocollapse */
  static new(...t) {
    let [n, i, r, s] = t;
    return t[0] && typeof t[0] == "object" && ({ name: n } = t[0], i === void 0 && (i = t[0].type), r === void 0 && (r = t[0].nullable), s === void 0 && (s = t[0].metadata)), new Lm(`${n}`, i, r, s);
  }
  constructor(t, n, i = !1, r) {
    this.name = t, this.type = n, this.nullable = i, this.metadata = r || /* @__PURE__ */ new Map();
  }
  get typeId() {
    return this.type.typeId;
  }
  get [Symbol.toStringTag]() {
    return "Field";
  }
  toString() {
    return `${this.name}: ${this.type}`;
  }
  clone(...t) {
    let [n, i, r, s] = t;
    return !t[0] || typeof t[0] != "object" ? [n = this.name, i = this.type, r = this.nullable, s = this.metadata] = t : { name: n = this.name, type: i = this.type, nullable: r = this.nullable, metadata: s = this.metadata } = t[0], Lm.new(n, i, r, s);
  }
};
Ae.prototype.type = null;
Ae.prototype.name = null;
Ae.prototype.nullable = null;
Ae.prototype.metadata = null;
function Tf(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function Rm(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, i = e.length; ++n < i; ) {
    const s = e[n].type;
    if (Ft.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 && Rm(s.children, t);
  }
  return t;
}
var HD = CI, KD = uc;
let $1 = class {
  /** @nocollapse */
  static decode(t) {
    t = new KD(Xt(t));
    const n = Li.getRootAsFooter(t), i = _e.decode(n.schema());
    return new JD(i, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new HD(), i = _e.encode(n, t.schema);
    Li.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      Zh.encode(n, o);
    const r = n.endVector();
    Li.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      Zh.encode(n, o);
    const s = n.endVector();
    return Li.startFooter(n), Li.addSchema(n, i), Li.addVersion(n, Wn.V4), Li.addRecordBatches(n, r), Li.addDictionaries(n, s), Li.finishFooterBuffer(n, Li.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  constructor(t, n = Wn.V4, i, r) {
    this.schema = t, this.version = n, i && (this._recordBatches = i), r && (this._dictionaryBatches = r);
  }
  *recordBatches() {
    for (let t, n = -1, i = this.numRecordBatches; ++n < i; )
      (t = this.getRecordBatch(n)) && (yield t);
  }
  *dictionaryBatches() {
    for (let t, n = -1, i = this.numDictionaries; ++n < i; )
      (t = this.getDictionaryBatch(n)) && (yield t);
  }
  getRecordBatch(t) {
    return t >= 0 && t < this.numRecordBatches && this._recordBatches[t] || null;
  }
  getDictionaryBatch(t) {
    return t >= 0 && t < this.numDictionaries && this._dictionaryBatches[t] || null;
  }
}, JD = class extends $1 {
  get numRecordBatches() {
    return this._footer.recordBatchesLength();
  }
  get numDictionaries() {
    return this._footer.dictionariesLength();
  }
  constructor(t, n) {
    super(t, n.version()), this._footer = n;
  }
  getRecordBatch(t) {
    if (t >= 0 && t < this.numRecordBatches) {
      const n = this._footer.recordBatches(t);
      if (n)
        return Zh.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return Zh.decode(n);
    }
    return null;
  }
}, Zh = class UI {
  /** @nocollapse */
  static decode(t) {
    return new UI(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: i } = n, r = BigInt(n.offset), s = BigInt(n.bodyLength);
    return Fm.createBlock(t, r, i, s);
  }
  constructor(t, n, i) {
    this.metaDataLength = t, this.offset = bi(i), this.bodyLength = bi(n);
  }
};
const we = Object.freeze({ done: !0, value: void 0 });
let Uw = class {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}, zI = class {
  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());
  }
}, ZD = class extends zI {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return Y(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(we);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return Pn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return Pn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.abort(t), we;
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), we;
    });
  }
  read(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(...t) {
    return this._values.length > 0 ? Promise.resolve({ done: !1, value: this._values.shift() }) : this._error ? Promise.reject({ done: !0, value: this._error.error }) : this._closedPromiseResolve ? new Promise((n, i) => {
      this.resolvers.push({ resolve: n, reject: i });
    }) : Promise.resolve(we);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}, QD = class extends ZD {
  write(t) {
    if ((t = Xt(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? Im(this.toUint8Array(!0)) : this.toUint8Array(!1).then(Im);
  }
  toUint8Array(t = !1) {
    return t ? rr(this._values)[0] : (() => Y(this, void 0, void 0, function* () {
      var n, i, r, s;
      const o = [];
      let a = 0;
      try {
        for (var c = !0, l = ti(this), u; u = yield l.next(), n = u.done, !n; ) {
          s = u.value, c = !1;
          try {
            const f = s;
            o.push(f), a += f.byteLength;
          } finally {
            c = !0;
          }
        }
      } catch (f) {
        i = { error: f };
      } finally {
        try {
          !c && !n && (r = l.return) && (yield r.call(l));
        } finally {
          if (i)
            throw i.error;
        }
      }
      return rr(o, a)[0];
    }))();
  }
}, Qh = class {
  constructor(t) {
    t && (this.source = new tO(Pn.fromIterable(t)));
  }
  [Symbol.iterator]() {
    return this;
  }
  next(t) {
    return this.source.next(t);
  }
  throw(t) {
    return this.source.throw(t);
  }
  return(t) {
    return this.source.return(t);
  }
  peek(t) {
    return this.source.peek(t);
  }
  read(t) {
    return this.source.read(t);
  }
}, td = class PI {
  constructor(t) {
    t instanceof PI ? this.source = t.source : t instanceof QD ? this.source = new fo(Pn.fromAsyncIterable(t)) : gS(t) ? this.source = new fo(Pn.fromNodeStream(t)) : p1(t) ? this.source = new fo(Pn.fromDOMStream(t)) : yS(t) ? this.source = new fo(Pn.fromDOMStream(t.body)) : Xp(t) ? this.source = new fo(Pn.fromIterable(t)) : eu(t) ? this.source = new fo(Pn.fromAsyncIterable(t)) : d1(t) && (this.source = new fo(Pn.fromAsyncIterable(t)));
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next(t) {
    return this.source.next(t);
  }
  throw(t) {
    return this.source.throw(t);
  }
  return(t) {
    return this.source.return(t);
  }
  get closed() {
    return this.source.closed;
  }
  cancel(t) {
    return this.source.cancel(t);
  }
  peek(t) {
    return this.source.peek(t);
  }
  read(t) {
    return this.source.read(t);
  }
}, tO = class {
  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) || we);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || we);
  }
}, fo = class {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return Y(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || we;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || we;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}, zw = class extends Qh {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Xt(t), this.size = n === void 0 ? this.buffer.byteLength : n;
  }
  readInt32(t) {
    const { buffer: n, byteOffset: i } = this.readAt(t, 4);
    return new DataView(n, i).getInt32(0, !0);
  }
  seek(t) {
    return this.position = Math.min(t, this.size), t < this.size;
  }
  read(t) {
    const { buffer: n, size: i, position: r } = this;
    return n && r < i ? (typeof t != "number" && (t = Number.POSITIVE_INFINITY), this.position = Math.min(i, r + Math.min(i - r, t)), n.subarray(r, this.position)) : null;
  }
  readAt(t, n) {
    const i = this.buffer, r = Math.min(this.size, t + n);
    return i ? i.subarray(t, r) : new Uint8Array(n);
  }
  close() {
    this.buffer && (this.buffer = null);
  }
  throw(t) {
    return this.close(), { done: !0, value: t };
  }
  return(t) {
    return this.close(), { done: !0, value: t };
  }
}, ed = class extends td {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = (() => Y(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    }))();
  }
  readInt32(t) {
    return Y(this, void 0, void 0, function* () {
      const { buffer: n, byteOffset: i } = yield this.readAt(t, 4);
      return new DataView(n, i).getInt32(0, !0);
    });
  }
  seek(t) {
    return Y(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 Y(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: n, size: i, position: r } = this;
      if (n && r < i) {
        typeof t != "number" && (t = Number.POSITIVE_INFINITY);
        let s = r, o = 0, a = 0;
        const c = Math.min(i, s + Math.min(i - s, t)), l = new Uint8Array(Math.max(0, (this.position = c) - s));
        for (; (s += a) < c && (o += a) < l.byteLength; )
          ({ bytesRead: a } = yield n.read(l, o, l.byteLength - o, s));
        return l;
      }
      return null;
    });
  }
  readAt(t, n) {
    return Y(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: i, size: r } = this;
      if (i && t + n < r) {
        const s = Math.min(r, t + n), o = new Uint8Array(s - t);
        return (yield i.read(o, 0, n, t)).buffer;
      }
      return new Uint8Array(n);
    });
  }
  close() {
    return Y(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
};
const eO = 65536;
function Ra(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const pc = 8, A1 = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
let VI = class {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return this.buffer[1];
  }
  low() {
    return this.buffer[0];
  }
  _times(t) {
    const n = new Uint32Array([
      this.buffer[1] >>> 16,
      this.buffer[1] & 65535,
      this.buffer[0] >>> 16,
      this.buffer[0] & 65535
    ]), i = new Uint32Array([
      t.buffer[1] >>> 16,
      t.buffer[1] & 65535,
      t.buffer[0] >>> 16,
      t.buffer[0] & 65535
    ]);
    let r = n[3] * i[3];
    this.buffer[0] = r & 65535;
    let s = r >>> 16;
    return r = n[2] * i[3], s += r, r = n[3] * i[2] >>> 0, s += r, this.buffer[0] += s << 16, this.buffer[1] = s >>> 0 < r ? eO : 0, this.buffer[1] += s >>> 16, this.buffer[1] += n[1] * i[3] + n[2] * i[2] + n[3] * i[1], this.buffer[1] += n[0] * i[3] + n[1] * i[2] + n[2] * i[1] + n[3] * i[0] << 16, this;
  }
  _plus(t) {
    const n = this.buffer[0] + t.buffer[0] >>> 0;
    this.buffer[1] += t.buffer[1], n < this.buffer[0] >>> 0 && ++this.buffer[1], this.buffer[0] = n;
  }
  lessThan(t) {
    return this.buffer[1] < t.buffer[1] || this.buffer[1] === t.buffer[1] && this.buffer[0] < t.buffer[0];
  }
  equals(t) {
    return this.buffer[1] === t.buffer[1] && this.buffer[0] == t.buffer[0];
  }
  greaterThan(t) {
    return t.lessThan(this);
  }
  hex() {
    return `${Ra(this.buffer[1])} ${Ra(this.buffer[0])}`;
  }
}, Ne = class Sr extends VI {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Sr.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Sr.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.length, r = new Sr(n);
    for (let s = 0; s < i; ) {
      const o = pc < i - s ? pc : i - s, a = new Sr(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Sr(new Uint32Array([A1[o], 0]));
      r.times(c), r.plus(a), s += o;
    }
    return r;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      Sr.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Sr(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Sr(new Uint32Array(t.buffer)).plus(n);
  }
}, Vl = class Ir extends VI {
  negate() {
    return this.buffer[0] = ~this.buffer[0] + 1, this.buffer[1] = ~this.buffer[1], this.buffer[0] == 0 && ++this.buffer[1], this;
  }
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  lessThan(t) {
    const n = this.buffer[1] << 0, i = t.buffer[1] << 0;
    return n < i || n === i && this.buffer[0] < t.buffer[0];
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Ir.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Ir.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.startsWith("-"), r = t.length, s = new Ir(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = pc < r - o ? pc : r - o, c = new Ir(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), l = new Ir(new Uint32Array([A1[a], 0]));
      s.times(l), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      Ir.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Ir(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Ir(new Uint32Array(t.buffer)).plus(n);
  }
}, nO = class $r {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new Vl(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new Vl(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 Ne(new Uint32Array([this.buffer[3], 0])), i = new Ne(new Uint32Array([this.buffer[2], 0])), r = new Ne(new Uint32Array([this.buffer[1], 0])), s = new Ne(new Uint32Array([this.buffer[0], 0])), o = new Ne(new Uint32Array([t.buffer[3], 0])), a = new Ne(new Uint32Array([t.buffer[2], 0])), c = new Ne(new Uint32Array([t.buffer[1], 0])), l = new Ne(new Uint32Array([t.buffer[0], 0]));
    let u = Ne.multiply(s, l);
    this.buffer[0] = u.low();
    const f = new Ne(new Uint32Array([u.high(), 0]));
    return u = Ne.multiply(r, l), f.plus(u), u = Ne.multiply(s, c), f.plus(u), this.buffer[1] = f.low(), this.buffer[3] = f.lessThan(u) ? 1 : 0, this.buffer[2] = f.high(), new Ne(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(Ne.multiply(i, l)).plus(Ne.multiply(r, c)).plus(Ne.multiply(s, a)), this.buffer[3] += Ne.multiply(n, l).plus(Ne.multiply(i, c)).plus(Ne.multiply(r, a)).plus(Ne.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 `${Ra(this.buffer[3])} ${Ra(this.buffer[2])} ${Ra(this.buffer[1])} ${Ra(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new $r(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new $r(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return $r.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return $r.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const i = t.startsWith("-"), r = t.length, s = new $r(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = pc < r - o ? pc : r - o, c = new $r(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), l = new $r(new Uint32Array([A1[a], 0, 0, 0]));
      s.times(l), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 4);
    for (let i = -1, r = t.length; ++i < r; )
      $r.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * i, 4));
    return n;
  }
}, jI = class extends Ut {
  constructor(t, n, i, r) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = i, this.dictionaries = r;
  }
  visit(t) {
    return super.visit(t instanceof Ae ? t.type : t);
  }
  visitNull(t, { length: n } = this.nextFieldNode()) {
    return Rt({ type: t, length: n });
  }
  visitBool(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitInt(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFloat(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitUtf8(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitFixedSizeBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDate(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTimestamp(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTime(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDecimal(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  visitStruct(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), children: this.visitMany(t.children) });
  }
  visitUnion(t) {
    return t.mode === gi.Sparse ? this.visitSparseUnion(t) : this.visitDenseUnion(t);
  }
  visitDenseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), typeIds: this.readTypeIds(t), valueOffsets: this.readOffsets(t), children: this.visitMany(t.children) });
  }
  visitSparseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), typeIds: this.readTypeIds(t), children: this.visitMany(t.children) });
  }
  visitDictionary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t.indices), dictionary: this.readDictionary(t) });
  }
  visitInterval(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFixedSizeList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), child: this.visit(t.children[0]) });
  }
  visitMap(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  nextFieldNode() {
    return this.nodes[++this.nodesIndex];
  }
  nextBufferRange() {
    return this.buffers[++this.buffersIndex];
  }
  readNullBitmap(t, n, i = this.nextBufferRange()) {
    return n > 0 && this.readData(t, i) || new Uint8Array(0);
  }
  readOffsets(t, n) {
    return this.readData(t, n);
  }
  readTypeIds(t, n) {
    return this.readData(t, n);
  }
  readData(t, { length: n, offset: i } = this.nextBufferRange()) {
    return this.bytes.subarray(i, i + n);
  }
  readDictionary(t) {
    return this.dictionaries.get(t.id);
  }
}, iO = class extends jI {
  constructor(t, n, i, r) {
    super(new Uint8Array(0), n, i, r), this.sources = t;
  }
  readNullBitmap(t, n, { offset: i } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : Tm(this.sources[i]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return ne(Uint8Array, ne(Int32Array, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return ne(Uint8Array, ne(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: i } = this;
    return Ft.isTimestamp(t) || (Ft.isInt(t) || Ft.isTime(t)) && t.bitWidth === 64 || Ft.isDate(t) && t.unit === Kr.MILLISECOND ? ne(Uint8Array, Vl.convertArray(i[n])) : Ft.isDecimal(t) ? ne(Uint8Array, nO.convertArray(i[n])) : Ft.isBinary(t) || Ft.isFixedSizeBinary(t) ? rO(i[n]) : Ft.isBool(t) ? Tm(i[n]) : Ft.isUtf8(t) ? h1(i[n].join("")) : ne(Uint8Array, ne(t.ArrayType, i[n].map((r) => +r)));
  }
};
function rO(e) {
  const t = e.join(""), n = new Uint8Array(t.length / 2);
  for (let i = 0; i < t.length; i += 2)
    n[i >> 1] = Number.parseInt(t.slice(i, i + 2), 16);
  return n;
}
let pt = class extends Ut {
  compareSchemas(t, n) {
    return t === n || n instanceof t.constructor && this.compareManyFields(t.fields, n.fields);
  }
  compareManyFields(t, n) {
    return t === n || Array.isArray(t) && Array.isArray(n) && t.length === n.length && t.every((i, r) => this.compareFields(i, n[r]));
  }
  compareFields(t, n) {
    return t === n || n instanceof t.constructor && t.name === n.name && t.nullable === n.nullable && this.visit(t.type, n.type);
  }
};
function Sn(e, t) {
  return t instanceof e.constructor;
}
function Cu(e, t) {
  return e === t || Sn(e, t);
}
function os(e, t) {
  return e === t || Sn(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function Kp(e, t) {
  return e === t || Sn(e, t) && e.precision === t.precision;
}
function sO(e, t) {
  return e === t || Sn(e, t) && e.byteWidth === t.byteWidth;
}
function M1(e, t) {
  return e === t || Sn(e, t) && e.unit === t.unit;
}
function ku(e, t) {
  return e === t || Sn(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function Uu(e, t) {
  return e === t || Sn(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function oO(e, t) {
  return e === t || Sn(e, t) && e.children.length === t.children.length && Cs.compareManyFields(e.children, t.children);
}
function aO(e, t) {
  return e === t || Sn(e, t) && e.children.length === t.children.length && Cs.compareManyFields(e.children, t.children);
}
function T1(e, t) {
  return e === t || Sn(e, t) && e.mode === t.mode && e.typeIds.every((n, i) => n === t.typeIds[i]) && Cs.compareManyFields(e.children, t.children);
}
function cO(e, t) {
  return e === t || Sn(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && Cs.visit(e.indices, t.indices) && Cs.visit(e.dictionary, t.dictionary);
}
function B1(e, t) {
  return e === t || Sn(e, t) && e.unit === t.unit;
}
function lO(e, t) {
  return e === t || Sn(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && Cs.compareManyFields(e.children, t.children);
}
function uO(e, t) {
  return e === t || Sn(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && Cs.compareManyFields(e.children, t.children);
}
pt.prototype.visitNull = Cu;
pt.prototype.visitBool = Cu;
pt.prototype.visitInt = os;
pt.prototype.visitInt8 = os;
pt.prototype.visitInt16 = os;
pt.prototype.visitInt32 = os;
pt.prototype.visitInt64 = os;
pt.prototype.visitUint8 = os;
pt.prototype.visitUint16 = os;
pt.prototype.visitUint32 = os;
pt.prototype.visitUint64 = os;
pt.prototype.visitFloat = Kp;
pt.prototype.visitFloat16 = Kp;
pt.prototype.visitFloat32 = Kp;
pt.prototype.visitFloat64 = Kp;
pt.prototype.visitUtf8 = Cu;
pt.prototype.visitBinary = Cu;
pt.prototype.visitFixedSizeBinary = sO;
pt.prototype.visitDate = M1;
pt.prototype.visitDateDay = M1;
pt.prototype.visitDateMillisecond = M1;
pt.prototype.visitTimestamp = ku;
pt.prototype.visitTimestampSecond = ku;
pt.prototype.visitTimestampMillisecond = ku;
pt.prototype.visitTimestampMicrosecond = ku;
pt.prototype.visitTimestampNanosecond = ku;
pt.prototype.visitTime = Uu;
pt.prototype.visitTimeSecond = Uu;
pt.prototype.visitTimeMillisecond = Uu;
pt.prototype.visitTimeMicrosecond = Uu;
pt.prototype.visitTimeNanosecond = Uu;
pt.prototype.visitDecimal = Cu;
pt.prototype.visitList = oO;
pt.prototype.visitStruct = aO;
pt.prototype.visitUnion = T1;
pt.prototype.visitDenseUnion = T1;
pt.prototype.visitSparseUnion = T1;
pt.prototype.visitDictionary = cO;
pt.prototype.visitInterval = B1;
pt.prototype.visitIntervalDayTime = B1;
pt.prototype.visitIntervalYearMonth = B1;
pt.prototype.visitFixedSizeList = lO;
pt.prototype.visitMap = uO;
const Cs = new pt();
function fO(e, t) {
  return Cs.compareSchemas(e, t);
}
function m0(e, t) {
  return hO(e, t.map((n) => n.data.concat()));
}
function hO(e, t) {
  const n = [...e.fields], i = [], r = { numBatches: t.reduce((f, h) => Math.max(f, h.length), 0) };
  let s = 0, o = 0, a = -1;
  const c = t.length;
  let l, u = [];
  for (; r.numBatches-- > 0; ) {
    for (o = Number.POSITIVE_INFINITY, a = -1; ++a < c; )
      u[a] = l = t[a].shift(), o = Math.min(o, l ? l.length : o);
    Number.isFinite(o) && (u = dO(n, o, u, t, r), o > 0 && (i[s++] = Rt({
      type: new on(n),
      length: o,
      nullCount: 0,
      children: u.slice()
    })));
  }
  return [
    e = e.assign(n),
    i.map((f) => new li(e, f))
  ];
}
function dO(e, t, n, i, r) {
  var s;
  const o = (t + 63 & -64) >> 3;
  for (let a = -1, c = i.length; ++a < c; ) {
    const l = n[a], u = l == null ? void 0 : l.length;
    if (u >= t)
      u === t ? n[a] = l : (n[a] = l.slice(0, t), r.numBatches = Math.max(r.numBatches, i[a].unshift(l.slice(t, u - t))));
    else {
      const f = e[a];
      e[a] = f.clone({ nullable: !0 }), n[a] = (s = l == null ? void 0 : l._changeLengthAndBackfillNullBitmap(t)) !== null && s !== void 0 ? s : Rt({
        type: f.type,
        length: t,
        nullCount: t,
        nullBitmap: new Uint8Array(o)
      });
    }
  }
  return n;
}
var YI;
let au = class So {
  constructor(...t) {
    var n, i;
    if (t.length === 0)
      return this.batches = [], this.schema = new _e([]), this._offsets = [0], this;
    let r, s;
    t[0] instanceof _e && (r = t.shift()), t[t.length - 1] instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof li)
          return [c];
        if (c instanceof So)
          return c.batches;
        if (c instanceof me) {
          if (c.type instanceof on)
            return [new li(new _e(c.type.children), c)];
        } else {
          if (Array.isArray(c))
            return c.flatMap((l) => o(l));
          if (typeof c[Symbol.iterator] == "function")
            return [...c].flatMap((l) => o(l));
          if (typeof c == "object") {
            const l = Object.keys(c), u = l.map((d) => new Me([c[d]])), f = new _e(l.map((d, p) => new Ae(String(d), u[p].type))), [, h] = m0(f, u);
            return h.length === 0 ? [new li(c)] : h;
          }
        }
      }
      return [];
    }, a = t.flatMap((c) => o(c));
    if (r = (i = r ?? ((n = a[0]) === null || n === void 0 ? void 0 : n.schema)) !== null && i !== void 0 ? i : new _e([]), !(r instanceof _e))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof li))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!fO(r, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = r, this.batches = a, this._offsets = s ?? $I(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 = II(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 ? I1.visit(new Me(this.data)) : new Array(0)[Symbol.iterator]();
  }
  /**
   * Return a JavaScript Array of the Table rows.
   *
   * @returns An Array of Table rows.
   */
  toArray() {
    return [...this];
  }
  /**
   * Returns a string representation of the Table rows.
   *
   * @returns A string representation of the Table rows.
   */
  toString() {
    return `[
  ${this.toArray().join(`,
  `)}
]`;
  }
  /**
   * Combines two or more Tables of the same schema.
   *
   * @param others Additional Tables to add to the end of this Tables.
   */
  concat(...t) {
    const n = this.schema, i = this.data.concat(t.flatMap(({ data: r }) => r));
    return new So(n, i.map((r) => new li(n, r)));
  }
  /**
   * Return a zero-copy sub-section of this Table.
   *
   * @param begin The beginning of the specified portion of the Table.
   * @param end The end of the specified portion of the Table. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    const i = this.schema;
    [t, n] = xI({ length: this.numRows }, t, n);
    const r = AI(this.data, this._offsets, t, n);
    return new So(i, r.map((s) => new li(i, s)));
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   *
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    return this.getChildAt(this.schema.fields.findIndex((n) => n.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   *
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    if (t > -1 && t < this.schema.fields.length) {
      const n = this.data.map((i) => i.children[t]);
      if (n.length === 0) {
        const { type: i } = this.schema.fields[t], r = Rt({ type: i, length: 0, nullCount: 0 });
        n.push(r._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new Me(n);
    }
    return null;
  }
  /**
   * Sets a child Vector by name.
   *
   * @param name The name of the child to overwrite.
   * @returns A new Table with the supplied child for the specified name.
   */
  setChild(t, n) {
    var i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = [...this.batches];
    if (t > -1 && t < this.numCols) {
      n || (n = new Me([Rt({ type: new Ls(), length: this.numRows })]));
      const s = i.fields.slice(), o = s[t].clone({ type: n.type }), a = this.schema.fields.map((c, l) => this.getChildAt(l));
      [s[t], a[t]] = [o, n], [i, r] = m0(i, a);
    }
    return new So(i, r);
  }
  /**
   * Construct a new Table containing only specified columns.
   *
   * @param columnNames Names of columns to keep.
   * @returns A new Table of columns matching the specified names.
   */
  select(t) {
    const n = this.schema.fields.reduce((i, r, s) => i.set(r.name, s), /* @__PURE__ */ new Map());
    return this.selectAt(t.map((i) => n.get(i)).filter((i) => i > -1));
  }
  /**
   * Construct a new Table containing only columns at the specified indices.
   *
   * @param columnIndices Indices of columns to keep.
   * @returns A new Table of columns at the specified indices.
   */
  selectAt(t) {
    const n = this.schema.selectAt(t), i = this.batches.map((r) => r.selectAt(t));
    return new So(n, i);
  }
  assign(t) {
    const n = this.schema.fields, [i, r] = t.schema.fields.reduce((a, c, l) => {
      const [u, f] = a, h = n.findIndex((d) => d.name === c.name);
      return ~h ? f[h] = l : u.push(l), a;
    }, [[], []]), s = this.schema.assign(t.schema), o = [
      ...n.map((a, c) => [c, r[c]]).map(([a, c]) => c === void 0 ? this.getChildAt(a) : t.getChildAt(c)),
      ...i.map((a) => t.getChildAt(a))
    ].filter(Boolean);
    return new So(...m0(s, o));
  }
};
YI = Symbol.toStringTag;
au[YI] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = qa(S1), e.get = qa(gn.getVisitFn(R.Struct)), e.set = MI(ei.getVisitFn(R.Struct)), e.indexOf = TI(Wh.getVisitFn(R.Struct)), e.getByteLength = qa(sr.getVisitFn(R.Struct)), "Table"))(au.prototype);
var qI;
let li = class Fl {
  constructor(...t) {
    switch (t.length) {
      case 2: {
        if ([this.schema] = t, !(this.schema instanceof _e))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = Rt({
            nullCount: 0,
            type: new on(this.schema.fields),
            children: this.schema.fields.map((n) => Rt({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof me))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = Pw(this.schema, this.data.children);
        break;
      }
      case 1: {
        const [n] = t, { fields: i, children: r, length: s } = Object.keys(n).reduce((c, l, u) => (c.children[u] = n[l], c.length = Math.max(c.length, n[l].length), c.fields[u] = Ae.new({ name: l, type: n[l].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new _e(i), a = Rt({ type: new on(i), length: s, children: r, nullCount: 0 });
        [this.schema, this.data] = Pw(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 = WI(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 gn.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 ei.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 Wh.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 sr.visit(this.data, t);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return I1.visit(new Me([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 au(this.schema, [this, ...t]);
  }
  /**
   * Return a zero-copy sub-section of this RecordBatch.
   * @param start The beginning of the specified portion of the RecordBatch.
   * @param end The end of the specified portion of the RecordBatch. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    const [i] = new Me([this.data]).slice(t, n).data;
    return new Fl(this.schema, i);
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    var n;
    return this.getChildAt((n = this.schema.fields) === null || n === void 0 ? void 0 : n.findIndex((i) => i.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    return t > -1 && t < this.schema.fields.length ? new Me([this.data.children[t]]) : null;
  }
  /**
   * Sets a child Vector by name.
   * @param name The name of the child to overwrite.
   * @returns A new RecordBatch with the new child for the specified name.
   */
  setChild(t, n) {
    var i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = this.data;
    if (t > -1 && t < this.numCols) {
      n || (n = new Me([Rt({ type: new Ls(), length: this.numRows })]));
      const s = i.fields.slice(), o = r.children.slice(), a = s[t].clone({ type: n.type });
      [s[t], o[t]] = [a, n.data[0]], i = new _e(s, new Map(this.schema.metadata)), r = Rt({ type: new on(s), children: o });
    }
    return new Fl(i, r);
  }
  /**
   * Construct a new RecordBatch containing only specified columns.
   *
   * @param columnNames Names of columns to keep.
   * @returns A new RecordBatch of columns matching the specified names.
   */
  select(t) {
    const n = this.schema.select(t), i = new on(n.fields), r = [];
    for (const s of t) {
      const o = this.schema.fields.findIndex((a) => a.name === s);
      ~o && (r[o] = this.data.children[o]);
    }
    return new Fl(n, Rt({ type: i, length: this.numRows, children: r }));
  }
  /**
   * Construct a new RecordBatch containing only columns at the specified indices.
   *
   * @param columnIndices Indices of columns to keep.
   * @returns A new RecordBatch of columns matching at the specified indices.
   */
  selectAt(t) {
    const n = this.schema.selectAt(t), i = t.map((s) => this.data.children[s]).filter(Boolean), r = Rt({ type: new on(n.fields), length: this.numRows, children: i });
    return new Fl(n, r);
  }
};
qI = Symbol.toStringTag;
li[qI] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(li.prototype);
function Pw(e, t, n = t.reduce((i, r) => Math.max(i, r.length), 0)) {
  var i;
  const r = [...e.fields], s = [...t], o = (n + 63 & -64) >> 3;
  for (const [a, c] of e.fields.entries()) {
    const l = t[a];
    (!l || l.length !== n) && (r[a] = c.clone({ nullable: !0 }), s[a] = (i = l == null ? void 0 : l._changeLengthAndBackfillNullBitmap(n)) !== null && i !== void 0 ? i : Rt({
      type: c.type,
      length: n,
      nullCount: n,
      nullBitmap: new Uint8Array(o)
    }));
  }
  return [
    e.assign(r),
    Rt({ type: new on(r), length: n, children: s })
  ];
}
function WI(e, t, n = /* @__PURE__ */ new Map()) {
  for (let i = -1, r = e.length; ++i < r; ) {
    const o = e[i].type, a = t[i];
    if (Ft.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 && WI(o.children, a.children, n);
  }
  return n;
}
let GI = class extends li {
  constructor(t) {
    const n = t.fields.map((r) => Rt({ type: r.type })), i = Rt({ type: new on(t.fields), nullCount: 0, children: n });
    super(t, i);
  }
};
var nd;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(nd || (nd = {}));
var id;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(id || (id = {}));
let pO = class Io {
  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 Io()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + se), (n || new Io()).__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) : id.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) : nd.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, id.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, nd.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, i) {
    return Io.startBodyCompression(t), Io.addCodec(t, n), Io.addMethod(t, i), Io.endBodyCompression(t);
  }
}, XI = class {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * The relative offset into the shared memory page where the bytes for this
   * buffer starts
   */
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * The absolute length (in bytes) of the memory buffer. The memory is found
   * from offset (inclusive) to offset + length (non-inclusive). When building
   * messages using the encapsulated IPC message, padding bytes may be written
   * after a buffer, but such padding bytes do not need to be accounted for in
   * the size here.
   */
  length() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createBuffer(t, n, i) {
    return t.prep(8, 16), t.writeInt64(BigInt(i ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, HI = class {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * The number of value slots in the Arrow array at this level of a nested
   * tree
   */
  length() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * The number of observed nulls. Fields with null_count == 0 may choose not
   * to write their physical validity bitmap out as a materialized buffer,
   * instead setting the length of the bitmap buffer to 0.
   */
  nullCount() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createFieldNode(t, n, i) {
    return t.prep(8, 16), t.writeInt64(BigInt(i ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, Nr = class Cm {
  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 Cm()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + se), (n || new Cm()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * number of records / rows. The arrays in the batch should all have this
   * length
   */
  length() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  /**
   * Nodes correspond to the pre-ordered flattened logical schema
   */
  nodes(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new HI()).__init(this.bb.__vector(this.bb_pos + i) + t * 16, this.bb) : null;
  }
  nodesLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Buffers correspond to the pre-ordered flattened buffer tree
   *
   * The number of buffers appended to this list depends on the schema. For
   * example, most primitive arrays will have 2 buffers, 1 for the validity
   * bitmap and 1 for the values. For struct arrays, there will only be a
   * single buffer for the validity (nulls) bitmap
   */
  buffers(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new XI()).__init(this.bb.__vector(this.bb_pos + i) + t * 16, this.bb) : null;
  }
  buffersLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Optional compression of the message body
   */
  compression(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? (t || new pO()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  static startRecordBatch(t) {
    t.startObject(4);
  }
  static addLength(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addNodes(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static startNodesVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addBuffers(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startBuffersVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addCompression(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static endRecordBatch(t) {
    return t.endObject();
  }
}, Ta = class km {
  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 km()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + se), (n || new km()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  data(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Nr()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * If isDelta is true the values in the dictionary are to be appended to a
   * dictionary with the indicated id. If isDelta is false this dictionary
   * should replace the existing dictionary.
   */
  isDelta() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startDictionaryBatch(t) {
    t.startObject(3);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addData(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsDelta(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static endDictionaryBatch(t) {
    return t.endObject();
  }
};
var rd;
(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";
})(rd || (rd = {}));
let ps = class Ri {
  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 Ri()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + se), (n || new Ri()).__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) : fc.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : rd.NONE;
  }
  header(t) {
    const n = this.bb.__offset(this.bb_pos, 8);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  bodyLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new Xn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 12);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startMessage(t) {
    t.startObject(5);
  }
  static addVersion(t, n) {
    t.addFieldInt16(0, n, fc.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, rd.NONE);
  }
  static addHeader(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static addBodyLength(t, n) {
    t.addFieldInt64(3, n, BigInt("0"));
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endMessage(t) {
    return t.endObject();
  }
  static finishMessageBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedMessageBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
  static createMessage(t, n, i, r, s, o) {
    return Ri.startMessage(t), Ri.addVersion(t, n), Ri.addHeaderType(t, i), Ri.addHeader(t, r), Ri.addBodyLength(t, s), Ri.addCustomMetadata(t, o), Ri.endMessage(t);
  }
}, yO = class extends Ut {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return Rw.startNull(n), Rw.endNull(n);
  }
  visitInt(t, n) {
    return La.startInt(n), La.addBitWidth(n, t.bitWidth), La.addIsSigned(n, t.isSigned), La.endInt(n);
  }
  visitFloat(t, n) {
    return dh.startFloatingPoint(n), dh.addPrecision(n, t.precision), dh.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return Ow.startBinary(n), Ow.endBinary(n);
  }
  visitBool(t, n) {
    return Ew.startBool(n), Ew.endBool(n);
  }
  visitUtf8(t, n) {
    return kw.startUtf8(n), kw.endUtf8(n);
  }
  visitDecimal(t, n) {
    return xa.startDecimal(n), xa.addScale(n, t.scale), xa.addPrecision(n, t.precision), xa.addBitWidth(n, t.bitWidth), xa.endDecimal(n);
  }
  visitDate(t, n) {
    return uh.startDate(n), uh.addUnit(n, t.unit), uh.endDate(n);
  }
  visitTime(t, n) {
    return Tl.startTime(n), Tl.addUnit(n, t.unit), Tl.addBitWidth(n, t.bitWidth), Tl.endTime(n);
  }
  visitTimestamp(t, n) {
    const i = t.timezone && n.createString(t.timezone) || void 0;
    return Bl.startTimestamp(n), Bl.addUnit(n, t.unit), i !== void 0 && Bl.addTimezone(n, i), Bl.endTimestamp(n);
  }
  visitInterval(t, n) {
    return ph.startInterval(n), ph.addUnit(n, t.unit), ph.endInterval(n);
  }
  visitList(t, n) {
    return Lw.startList(n), Lw.endList(n);
  }
  visitStruct(t, n) {
    return Cw.startStruct_(n), Cw.endStruct_(n);
  }
  visitUnion(t, n) {
    wo.startTypeIdsVector(n, t.typeIds.length);
    const i = wo.createTypeIdsVector(n, t.typeIds);
    return wo.startUnion(n), wo.addMode(n, t.mode), wo.addTypeIds(n, i), wo.endUnion(n);
  }
  visitDictionary(t, n) {
    const i = this.visit(t.indices, n);
    return wa.startDictionaryEncoding(n), wa.addId(n, BigInt(t.id)), wa.addIsOrdered(n, t.isOrdered), i !== void 0 && wa.addIndexType(n, i), wa.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return fh.startFixedSizeBinary(n), fh.addByteWidth(n, t.byteWidth), fh.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return hh.startFixedSizeList(n), hh.addListSize(n, t.listSize), hh.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return yh.startMap(n), yh.addKeysSorted(n, t.keysSorted), yh.endMap(n);
  }
};
const g0 = new yO();
function mO(e, t = /* @__PURE__ */ new Map()) {
  return new _e(bO(e, t), gh(e.customMetadata), t);
}
function KI(e) {
  return new _i(e.count, JI(e.columns), ZI(e.columns));
}
function gO(e) {
  return new Jr(KI(e.data), e.id, e.isDelta);
}
function bO(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => Ae.fromJSON(n, t));
}
function Vw(e, t) {
  return (e.children || []).filter(Boolean).map((n) => Ae.fromJSON(n, t));
}
function JI(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new jc(n.count, _O(n.VALIDITY)),
    ...JI(n.children)
  ], []);
}
function ZI(e, t = []) {
  for (let n = -1, i = (e || []).length; ++n < i; ) {
    const r = e[n];
    r.VALIDITY && t.push(new kr(t.length, r.VALIDITY.length)), r.TYPE && t.push(new kr(t.length, r.TYPE.length)), r.OFFSET && t.push(new kr(t.length, r.OFFSET.length)), r.DATA && t.push(new kr(t.length, r.DATA.length)), t = ZI(r.children, t);
  }
  return t;
}
function _O(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function wO(e, t) {
  let n, i, r, s, o, a;
  return !t || !(s = e.dictionary) ? (o = Yw(e, Vw(e, t)), r = new Ae(e.name, o, e.nullable, gh(e.customMetadata))) : t.has(n = s.id) ? (i = (i = s.indexType) ? jw(i) : new ru(), a = new lc(t.get(n), i, n, s.isOrdered), r = new Ae(e.name, a, e.nullable, gh(e.customMetadata))) : (i = (i = s.indexType) ? jw(i) : new ru(), t.set(n, o = Yw(e, Vw(e, t))), a = new lc(o, i, n, s.isOrdered), r = new Ae(e.name, a, e.nullable, gh(e.customMetadata))), r || null;
}
function gh(e) {
  return new Map(Object.entries(e || {}));
}
function jw(e) {
  return new Rs(e.isSigned, e.bitWidth);
}
function Yw(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new Ls();
    case "null":
      return new Ls();
    case "binary":
      return new Eh();
    case "utf8":
      return new Lh();
    case "bool":
      return new Rh();
    case "list":
      return new Ph((t || [])[0]);
    case "struct":
      return new on(t || []);
    case "struct_":
      return new on(t || []);
  }
  switch (n) {
    case "int": {
      const i = e.type;
      return new Rs(i.isSigned, i.bitWidth);
    }
    case "floatingpoint": {
      const i = e.type;
      return new su(yn[i.precision]);
    }
    case "decimal": {
      const i = e.type;
      return new Ch(i.scale, i.precision, i.bitWidth);
    }
    case "date": {
      const i = e.type;
      return new kh(Kr[i.unit]);
    }
    case "time": {
      const i = e.type;
      return new ou(jt[i.unit], i.bitWidth);
    }
    case "timestamp": {
      const i = e.type;
      return new Uh(jt[i.unit], i.timezone);
    }
    case "interval": {
      const i = e.type;
      return new zh(Es[i.unit]);
    }
    case "union": {
      const i = e.type;
      return new Vh(gi[i.mode], i.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const i = e.type;
      return new jh(i.byteWidth);
    }
    case "fixedsizelist": {
      const i = e.type;
      return new Yh(i.listSize, (t || [])[0]);
    }
    case "map": {
      const i = e.type;
      return new qh((t || [])[0], i.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var vO = CI, xO = uc;
let jl = class Ba {
  /** @nocollapse */
  static fromJSON(t, n) {
    const i = new Ba(0, Wn.V4, n);
    return i._createHeader = SO(t, n), i;
  }
  /** @nocollapse */
  static decode(t) {
    t = new xO(Xt(t));
    const n = ps.getRootAsMessage(t), i = n.bodyLength(), r = n.version(), s = n.headerType(), o = new Ba(i, r, s);
    return o._createHeader = IO(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new vO();
    let i = -1;
    return t.isSchema() ? i = _e.encode(n, t.header()) : t.isRecordBatch() ? i = _i.encode(n, t.header()) : t.isDictionaryBatch() && (i = Jr.encode(n, t.header())), ps.startMessage(n), ps.addVersion(n, Wn.V4), ps.addHeader(n, i), ps.addHeaderType(n, t.headerType), ps.addBodyLength(n, BigInt(t.bodyLength)), ps.finishMessageBuffer(n, ps.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof _e)
      return new Ba(0, Wn.V4, Zt.Schema, t);
    if (t instanceof _i)
      return new Ba(n, Wn.V4, Zt.RecordBatch, t);
    if (t instanceof Jr)
      return new Ba(n, Wn.V4, Zt.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 === Zt.Schema;
  }
  isRecordBatch() {
    return this.headerType === Zt.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === Zt.DictionaryBatch;
  }
  constructor(t, n, i, r) {
    this._version = n, this._headerType = i, this.body = new Uint8Array(0), r && (this._createHeader = () => r), this._bodyLength = bi(t);
  }
}, _i = class {
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
  constructor(t, n, i) {
    this._nodes = n, this._buffers = i, this._length = bi(t);
  }
}, Jr = class {
  get id() {
    return this._id;
  }
  get data() {
    return this._data;
  }
  get isDelta() {
    return this._isDelta;
  }
  get length() {
    return this.data.length;
  }
  get nodes() {
    return this.data.nodes;
  }
  get buffers() {
    return this.data.buffers;
  }
  constructor(t, n, i = !1) {
    this._data = t, this._isDelta = i, this._id = bi(n);
  }
}, kr = class {
  constructor(t, n) {
    this.offset = bi(t), this.length = bi(n);
  }
}, jc = class {
  constructor(t, n) {
    this.length = bi(t), this.nullCount = bi(n);
  }
};
function SO(e, t) {
  return () => {
    switch (t) {
      case Zt.Schema:
        return _e.fromJSON(e);
      case Zt.RecordBatch:
        return _i.fromJSON(e);
      case Zt.DictionaryBatch:
        return Jr.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Zt[t]}, type: ${t} }`);
  };
}
function IO(e, t) {
  return () => {
    switch (t) {
      case Zt.Schema:
        return _e.decode(e.header(new ki()));
      case Zt.RecordBatch:
        return _i.decode(e.header(new Nr()), e.version());
      case Zt.DictionaryBatch:
        return Jr.decode(e.header(new Ta()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Zt[t]}, type: ${t} }`);
  };
}
Ae.encode = LO;
Ae.decode = OO;
Ae.fromJSON = wO;
_e.encode = EO;
_e.decode = $O;
_e.fromJSON = mO;
_i.encode = RO;
_i.decode = AO;
_i.fromJSON = KI;
Jr.encode = CO;
Jr.decode = MO;
Jr.fromJSON = gO;
jc.encode = kO;
jc.decode = BO;
kr.encode = UO;
kr.decode = TO;
function $O(e, t = /* @__PURE__ */ new Map()) {
  const n = DO(e, t);
  return new _e(n, bh(e), t);
}
function AO(e, t = Wn.V4) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new _i(e.length(), NO(e), FO(e, t));
}
function MO(e, t = Wn.V4) {
  return new Jr(_i.decode(e.data(), t), e.id(), e.isDelta());
}
function TO(e) {
  return new kr(e.offset(), e.length());
}
function BO(e) {
  return new jc(e.length(), e.nullCount());
}
function NO(e) {
  const t = [];
  for (let n, i = -1, r = -1, s = e.nodesLength(); ++i < s; )
    (n = e.nodes(i)) && (t[++r] = jc.decode(n));
  return t;
}
function FO(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.buffersLength(); ++r < o; )
    (i = e.buffers(r)) && (t < Wn.V4 && (i.bb_pos += 8 * (r + 1)), n[++s] = kr.decode(i));
  return n;
}
function DO(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.fieldsLength(); ++r < o; )
    (i = e.fields(r)) && (n[++s] = Ae.decode(i, t));
  return n;
}
function qw(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.childrenLength(); ++r < o; )
    (i = e.children(r)) && (n[++s] = Ae.decode(i, t));
  return n;
}
function OO(e, t) {
  let n, i, r, s, o, a;
  return !t || !(a = e.dictionary()) ? (r = Gw(e, qw(e, t)), i = new Ae(e.name(), r, e.nullable(), bh(e))) : t.has(n = bi(a.id())) ? (s = (s = a.indexType()) ? Ww(s) : new ru(), o = new lc(t.get(n), s, n, a.isOrdered()), i = new Ae(e.name(), o, e.nullable(), bh(e))) : (s = (s = a.indexType()) ? Ww(s) : new ru(), t.set(n, r = Gw(e, qw(e, t))), o = new lc(r, s, n, a.isOrdered()), i = new Ae(e.name(), o, e.nullable(), bh(e))), i || null;
}
function bh(e) {
  const t = /* @__PURE__ */ new Map();
  if (e)
    for (let n, i, r = -1, s = Math.trunc(e.customMetadataLength()); ++r < s; )
      (n = e.customMetadata(r)) && (i = n.key()) != null && t.set(i, n.value());
  return t;
}
function Ww(e) {
  return new Rs(e.isSigned(), e.bitWidth());
}
function Gw(e, t) {
  const n = e.typeType();
  switch (n) {
    case ge.NONE:
      return new Ls();
    case ge.Null:
      return new Ls();
    case ge.Binary:
      return new Eh();
    case ge.Utf8:
      return new Lh();
    case ge.Bool:
      return new Rh();
    case ge.List:
      return new Ph((t || [])[0]);
    case ge.Struct_:
      return new on(t || []);
  }
  switch (n) {
    case ge.Int: {
      const i = e.type(new La());
      return new Rs(i.isSigned(), i.bitWidth());
    }
    case ge.FloatingPoint: {
      const i = e.type(new dh());
      return new su(i.precision());
    }
    case ge.Decimal: {
      const i = e.type(new xa());
      return new Ch(i.scale(), i.precision(), i.bitWidth());
    }
    case ge.Date: {
      const i = e.type(new uh());
      return new kh(i.unit());
    }
    case ge.Time: {
      const i = e.type(new Tl());
      return new ou(i.unit(), i.bitWidth());
    }
    case ge.Timestamp: {
      const i = e.type(new Bl());
      return new Uh(i.unit(), i.timezone());
    }
    case ge.Interval: {
      const i = e.type(new ph());
      return new zh(i.unit());
    }
    case ge.Union: {
      const i = e.type(new wo());
      return new Vh(i.mode(), i.typeIdsArray() || [], t || []);
    }
    case ge.FixedSizeBinary: {
      const i = e.type(new fh());
      return new jh(i.byteWidth());
    }
    case ge.FixedSizeList: {
      const i = e.type(new hh());
      return new Yh(i.listSize(), (t || [])[0]);
    }
    case ge.Map: {
      const i = e.type(new yh());
      return new qh((t || [])[0], i.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${ge[n]}" (${n})`);
}
function EO(e, t) {
  const n = t.fields.map((s) => Ae.encode(e, s));
  ki.startFieldsVector(e, n.length);
  const i = ki.createFieldsVector(e, n), r = t.metadata && t.metadata.size > 0 ? ki.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return Xn.startKeyValue(e), Xn.addKey(e, a), Xn.addValue(e, c), Xn.endKeyValue(e);
  })) : -1;
  return ki.startSchema(e), ki.addFields(e, i), ki.addEndianness(e, zO ? hc.Little : hc.Big), r !== -1 && ki.addCustomMetadata(e, r), ki.endSchema(e);
}
function LO(e, t) {
  let n = -1, i = -1, r = -1;
  const s = t.type;
  let o = t.typeId;
  Ft.isDictionary(s) ? (o = s.dictionary.typeId, r = g0.visit(s, e), i = g0.visit(s.dictionary, e)) : i = g0.visit(s, e);
  const a = (s.children || []).map((u) => Ae.encode(e, u)), c = Un.createChildrenVector(e, a), l = t.metadata && t.metadata.size > 0 ? Un.createCustomMetadataVector(e, [...t.metadata].map(([u, f]) => {
    const h = e.createString(`${u}`), d = e.createString(`${f}`);
    return Xn.startKeyValue(e), Xn.addKey(e, h), Xn.addValue(e, d), Xn.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), Un.startField(e), Un.addType(e, i), Un.addTypeType(e, o), Un.addChildren(e, c), Un.addNullable(e, !!t.nullable), n !== -1 && Un.addName(e, n), r !== -1 && Un.addDictionary(e, r), l !== -1 && Un.addCustomMetadata(e, l), Un.endField(e);
}
function RO(e, t) {
  const n = t.nodes || [], i = t.buffers || [];
  Nr.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    jc.encode(e, o);
  const r = e.endVector();
  Nr.startBuffersVector(e, i.length);
  for (const o of i.slice().reverse())
    kr.encode(e, o);
  const s = e.endVector();
  return Nr.startRecordBatch(e), Nr.addLength(e, BigInt(t.length)), Nr.addNodes(e, r), Nr.addBuffers(e, s), Nr.endRecordBatch(e);
}
function CO(e, t) {
  const n = _i.encode(e, t.data);
  return Ta.startDictionaryBatch(e), Ta.addId(e, BigInt(t.id)), Ta.addIsDelta(e, t.isDelta), Ta.addData(e, n), Ta.endDictionaryBatch(e);
}
function kO(e, t) {
  return HI.createFieldNode(e, BigInt(t.length), BigInt(t.nullCount));
}
function UO(e, t) {
  return XI.createBuffer(e, BigInt(t.offset), BigInt(t.length));
}
const zO = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), N1 = (e) => `Expected ${Zt[e]} Message in stream, but was null or length 0.`, F1 = (e) => `Header pointer of flatbuffer-encoded ${Zt[e]} Message is null or length 0.`, QI = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, t3 = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
let e3 = class {
  constructor(t) {
    this.source = t instanceof Qh ? t : new Qh(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 ? we : 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(N1(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Xt(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(t3(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 = Zt.Schema, i = this.readMessage(n), r = i == null ? void 0 : i.header();
    if (t && !r)
      throw new Error(F1(n));
    return r;
  }
  readMetadataLength() {
    const t = this.source.read(Jp), n = t && new uc(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
    return { done: i === 0, value: i };
  }
  readMetadata(t) {
    const n = this.source.read(t);
    if (!n)
      return we;
    if (n.byteLength < t)
      throw new Error(QI(t, n.byteLength));
    return { done: !1, value: jl.decode(n) };
  }
}, PO = class {
  constructor(t, n) {
    this.source = t instanceof td ? t : pS(t) ? new ed(t, n) : new td(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return Y(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 ? we : t;
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return Y(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(N1(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return Y(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Xt(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(t3(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return Y(this, void 0, void 0, function* () {
      const n = Zt.Schema, i = yield this.readMessage(n), r = i == null ? void 0 : i.header();
      if (t && !r)
        throw new Error(F1(n));
      return r;
    });
  }
  readMetadataLength() {
    return Y(this, void 0, void 0, function* () {
      const t = yield this.source.read(Jp), n = t && new uc(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: i === 0, value: i };
    });
  }
  readMetadata(t) {
    return Y(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return we;
      if (n.byteLength < t)
        throw new Error(QI(t, n.byteLength));
      return { done: !1, value: jl.decode(n) };
    });
  }
}, VO = class extends e3 {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof Uw ? t : new Uw(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: jl.fromJSON(t.schema, Zt.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: jl.fromJSON(n, Zt.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: jl.fromJSON(n, Zt.RecordBatch) };
    }
    return this._body = [], we;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(i) {
      return (i || []).reduce((r, s) => [
        ...r,
        ...s.VALIDITY && [s.VALIDITY] || [],
        ...s.TYPE && [s.TYPE] || [],
        ...s.OFFSET && [s.OFFSET] || [],
        ...s.DATA && [s.DATA] || [],
        ...n(s.children)
      ], []);
    }
  }
  readMessage(t) {
    let n;
    if ((n = this.next()).done)
      return null;
    if (t != null && n.value.headerType !== t)
      throw new Error(N1(t));
    return n.value;
  }
  readSchema() {
    const t = Zt.Schema, n = this.readMessage(t), i = n == null ? void 0 : n.header();
    if (!n || !i)
      throw new Error(F1(t));
    return i;
  }
};
const Jp = 4, Um = "ARROW1", sd = new Uint8Array(Um.length);
for (let e = 0; e < Um.length; e += 1)
  sd[e] = Um.codePointAt(e);
function D1(e, t = 0) {
  for (let n = -1, i = sd.length; ++n < i; )
    if (sd[n] !== e[t + n])
      return !1;
  return !0;
}
const zu = sd.length, n3 = zu + Jp, jO = zu * 2 + Jp;
let Pu = class _h extends zI {
  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 eu(n) ? n.then(() => this) : this;
  }
  readRecordBatch(t) {
    return this._impl.isFile() ? this._impl.readRecordBatch(t) : null;
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
  toDOMStream() {
    return Pn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return Pn.toNodeStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this }, { objectMode: !0 });
  }
  /** @nocollapse */
  // @ts-ignore
  static throughNode(t) {
    throw new Error('"throughNode" not available in this environment');
  }
  /** @nocollapse */
  static throughDOM(t, n) {
    throw new Error('"throughDOM" not available in this environment');
  }
  /** @nocollapse */
  static from(t) {
    return t instanceof _h ? t : $m(t) ? GO(t) : pS(t) ? KO(t) : eu(t) ? (() => Y(this, void 0, void 0, function* () {
      return yield _h.from(yield t);
    }))() : yS(t) || p1(t) || gS(t) || d1(t) ? HO(new td(t)) : XO(new Qh(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof _h ? t.isSync() ? Xw(t) : Hw(t) : $m(t) || ArrayBuffer.isView(t) || Xp(t) || dS(t) ? Xw(t) : Hw(t);
  }
}, od = class extends Pu {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return Fe(this, arguments, function* () {
      yield W(yield* Fs(ti(this[Symbol.iterator]())));
    });
  }
}, ad = class extends Pu {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n, i, r;
    return Y(this, void 0, void 0, function* () {
      const s = new Array();
      try {
        for (var o = !0, a = ti(this), c; c = yield a.next(), t = c.done, !t; ) {
          r = c.value, o = !1;
          try {
            const l = r;
            s.push(l);
          } finally {
            o = !0;
          }
        }
      } catch (l) {
        n = { error: l };
      } finally {
        try {
          !o && !t && (i = a.return) && (yield i.call(a));
        } finally {
          if (n)
            throw n.error;
        }
      }
      return s;
    });
  }
  [Symbol.iterator]() {
    throw new Error("AsyncRecordBatchStreamReader is not Iterable");
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
}, i3 = class extends od {
  constructor(t) {
    super(t), this._impl = t;
  }
}, YO = class extends ad {
  constructor(t) {
    super(t), this._impl = t;
  }
}, r3 = class {
  get numDictionaries() {
    return this._dictionaryIndex;
  }
  get numRecordBatches() {
    return this._recordBatchIndex;
  }
  constructor(t = /* @__PURE__ */ new Map()) {
    this.closed = !1, this.autoDestroy = !0, this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.dictionaries = t;
  }
  isSync() {
    return !1;
  }
  isAsync() {
    return !1;
  }
  isFile() {
    return !1;
  }
  isStream() {
    return !1;
  }
  reset(t) {
    return this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.schema = t, this.dictionaries = /* @__PURE__ */ new Map(), this;
  }
  _loadRecordBatch(t, n) {
    const i = this._loadVectors(t, n, this.schema.fields), r = Rt({ type: new on(this.schema.fields), length: t.length, children: i });
    return new li(this.schema, r);
  }
  _loadDictionaryBatch(t, n) {
    const { id: i, isDelta: r } = t, { dictionaries: s, schema: o } = this, a = s.get(i);
    if (r || !a) {
      const c = o.dictionaries.get(i), l = this._loadVectors(t.data, n, [c]);
      return (a && r ? a.concat(new Me(l)) : new Me(l)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, i) {
    return new jI(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
}, cd = class extends r3 {
  constructor(t, n) {
    super(n), this._reader = $m(t) ? new VO(this._handle = t) : new e3(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 = o3(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) : we;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : we;
  }
  next() {
    if (this.closed)
      return we;
    let t;
    const { _reader: n } = this;
    for (; t = this._readNextMessageAndValidate(); )
      if (t.isSchema())
        this.reset(t.header());
      else if (t.isRecordBatch()) {
        this._recordBatchIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength);
        return { done: !1, value: this._loadRecordBatch(i, r) };
      } else if (t.isDictionaryBatch()) {
        this._dictionaryIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
        this.dictionaries.set(i.id, s);
      }
    return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new GI(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}, ld = class extends r3 {
  constructor(t, n) {
    super(n), this._reader = new PO(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return Y(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 Y(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = o3(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : we;
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : we;
    });
  }
  next() {
    return Y(this, void 0, void 0, function* () {
      if (this.closed)
        return we;
      let t;
      const { _reader: n } = this;
      for (; t = yield this._readNextMessageAndValidate(); )
        if (t.isSchema())
          yield this.reset(t.header());
        else if (t.isRecordBatch()) {
          this._recordBatchIndex++;
          const i = t.header(), r = yield n.readMessageBody(t.bodyLength);
          return { done: !1, value: this._loadRecordBatch(i, r) };
        } else if (t.isDictionaryBatch()) {
          this._dictionaryIndex++;
          const i = t.header(), r = yield n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
          this.dictionaries.set(i.id, s);
        }
      return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new GI(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}, s3 = class extends cd {
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  constructor(t, n) {
    super(t instanceof zw ? t : new zw(t), n);
  }
  isSync() {
    return !0;
  }
  isFile() {
    return !0;
  }
  open(t) {
    if (!this.closed && !this._footer) {
      this.schema = (this._footer = this._readFooter()).schema;
      for (const n of this._footer.dictionaryBatches())
        n && this._readDictionaryBatch(this._dictionaryIndex++);
    }
    return super.open(t);
  }
  readRecordBatch(t) {
    var n;
    if (this.closed)
      return null;
    this._footer || this.open();
    const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(Zt.RecordBatch);
      if (r != null && r.isRecordBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength);
        return this._loadRecordBatch(s, o);
      }
    }
    return null;
  }
  _readDictionaryBatch(t) {
    var n;
    const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(Zt.DictionaryBatch);
      if (r != null && r.isDictionaryBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
        this.dictionaries.set(s.id, a);
      }
    }
  }
  _readFooter() {
    const { _handle: t } = this, n = t.size - n3, i = t.readInt32(n), r = t.readAt(n - i, i);
    return $1.decode(r);
  }
  _readNextMessageAndValidate(t) {
    var n;
    if (this._footer || this.open(), this._footer && this._recordBatchIndex < this.numRecordBatches) {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(this._recordBatchIndex);
      if (i && this._handle.seek(i.offset))
        return this._reader.readMessage(t);
    }
    return null;
  }
}, qO = class extends ld {
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  constructor(t, ...n) {
    const i = typeof n[0] != "number" ? n.shift() : void 0, r = n[0] instanceof Map ? n.shift() : void 0;
    super(t instanceof ed ? t : new ed(t, i), r);
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return Y(this, void 0, void 0, function* () {
      if (!this.closed && !this._footer) {
        this.schema = (this._footer = yield this._readFooter()).schema;
        for (const i of this._footer.dictionaryBatches())
          i && (yield this._readDictionaryBatch(this._dictionaryIndex++));
      }
      return yield n.open.call(this, t);
    });
  }
  readRecordBatch(t) {
    var n;
    return Y(this, void 0, void 0, function* () {
      if (this.closed)
        return null;
      this._footer || (yield this.open());
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(Zt.RecordBatch);
        if (r != null && r.isRecordBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength);
          return this._loadRecordBatch(s, o);
        }
      }
      return null;
    });
  }
  _readDictionaryBatch(t) {
    var n;
    return Y(this, void 0, void 0, function* () {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(Zt.DictionaryBatch);
        if (r != null && r.isDictionaryBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
          this.dictionaries.set(s.id, a);
        }
      }
    });
  }
  _readFooter() {
    return Y(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - n3, i = yield t.readInt32(n), r = yield t.readAt(n - i, i);
      return $1.decode(r);
    });
  }
  _readNextMessageAndValidate(t) {
    return Y(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;
    });
  }
}, WO = class extends cd {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, i) {
    return new iO(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
};
function o3(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* Xw(e) {
  const t = Pu.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function Hw(e) {
  return Fe(this, arguments, function* () {
    const n = yield W(Pu.from(e));
    try {
      if (!(yield W(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield W(n);
        while (!(yield W(n.reset().open())).closed);
    } finally {
      yield W(n.cancel());
    }
  });
}
function GO(e) {
  return new od(new WO(e));
}
function XO(e) {
  const t = e.peek(zu + 7 & -8);
  return t && t.byteLength >= 4 ? D1(t) ? new i3(new s3(e.read())) : new od(new cd(e)) : new od(new cd(function* () {
  }()));
}
function HO(e) {
  return Y(this, void 0, void 0, function* () {
    const t = yield e.peek(zu + 7 & -8);
    return t && t.byteLength >= 4 ? D1(t) ? new i3(new s3(yield e.read())) : new ad(new ld(e)) : new ad(new ld(function() {
      return Fe(this, arguments, function* () {
      });
    }()));
  });
}
function KO(e) {
  return Y(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new ed(e, t);
    return t >= jO && D1(yield n.readAt(0, zu + 7 & -8)) ? new YO(new qO(n)) : new ad(new ld(n));
  });
}
function a3(e) {
  const t = Pu.from(e);
  return eu(t) ? t.then((n) => a3(n)) : t.isAsync() ? t.readAll().then((n) => new au(n)) : new au(t.readAll());
}
function JO(e = "ws://localhost:3000/") {
  const t = [];
  let n = !1, i = null, r;
  const s = {
    open() {
      n = !0, c();
    },
    close() {
      for (n = !1, i = null, r = null; t.length; )
        t.shift().reject("Socket closed");
    },
    error(l) {
      if (i) {
        const { reject: u } = i;
        i = null, c(), u(l);
      } else
        console.error("WebSocket error: ", l);
    },
    message({ data: l }) {
      if (i) {
        const { query: u, resolve: f, reject: h } = i;
        if (i = null, c(), typeof l == "string") {
          const d = JSON.parse(l);
          d.error ? h(d.error) : f(d);
        } else if (u.type === "exec")
          f();
        else if (u.type === "arrow")
          f(a3(l.arrayBuffer()));
        else
          throw new Error(`Unexpected socket data: ${l}`);
      } else
        console.log("WebSocket message: ", l);
    }
  };
  function o() {
    r = new WebSocket(e);
    for (const l in s)
      r.addEventListener(l, s[l]);
  }
  function a(l, u, f) {
    r == null && o(), t.push({ query: l, resolve: u, reject: f }), n && !i && c();
  }
  function c() {
    t.length && (i = t.shift(), r.send(JSON.stringify(i.query)));
  }
  return {
    get connected() {
      return n;
    },
    query(l) {
      return new Promise(
        (u, f) => a(l, u, f)
      );
    }
  };
}
function ZO(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 ks {
  /**
   * 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 i = n.startsWith("*") ? n : `"${n}"`;
      return `${t ? `"${t}".` : ""}${i}`;
    } else
      return t ? `"${t}"` : "NULL";
  }
}
function QO(e, t) {
  return e instanceof ks && e.column === t;
}
function fe(e) {
  return typeof e == "string" ? O1(e) : e;
}
function b0(e) {
  return typeof e == "string" ? tE(e) : e;
}
function tE(e) {
  return new ks(e);
}
function O1(e, t) {
  return arguments.length === 1 && (t = e, e = null), new ks(e, t);
}
function Vu(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(), i = e.getUTCMonth(), r = e.getUTCDate();
        return t === Date.UTC(n, i, r) ? `MAKE_DATE(${n}, ${i + 1}, ${r})` : `EPOCH_MS(${t})`;
      } else
        return e instanceof RegExp ? `'${e.source}'` : String(e);
  }
}
const yc = (e) => typeof (e == null ? void 0 : e.addEventListener) == "function";
function c3(e) {
  return e instanceof Zp;
}
class Zp {
  /**
   * 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, i) {
    this._expr = Array.isArray(t) ? t : [t], this._deps = n || [], this.annotate(i);
    const r = this._expr.filter((s) => yc(s));
    r.length > 0 ? (this._params = Array.from(new Set(r)), this._params.forEach((s) => {
      s.addEventListener("value", () => {
        var o;
        return eE(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 i = new Set(t.flatMap((r) => {
        var o;
        const s = (o = r.value) == null ? void 0 : o.columns;
        return Array.isArray(s) ? s : [];
      }));
      if (i.size) {
        const r = new Set(n);
        return i.forEach((s) => r.add(s)), Array.from(r);
      }
    }
    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) => yc(t) && !c3(t) ? Vu(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 i = this.map || (this.map = /* @__PURE__ */ new Map());
    (i.get(t) || (i.set(t, /* @__PURE__ */ new Set()), i.get(t))).add(n);
  }
}
function eE(e, t) {
  if (t != null && t.size)
    return Promise.allSettled(Array.from(t, (n) => n(e)));
}
function l3(e, t) {
  const n = [e[0]], i = /* @__PURE__ */ new Set(), r = t.length;
  for (let s = 0, o = 0; s < r; ) {
    const a = t[s];
    yc(a) ? n[++o] = a : (Array.isArray(a == null ? void 0 : a.columns) && a.columns.forEach((l) => i.add(l)), n[o] += typeof a == "string" ? a : Vu(a));
    const c = e[++s];
    yc(n[o]) ? n[++o] = c : n[o] += c;
  }
  return { spans: n, cols: Array.from(i) };
}
function q(e, ...t) {
  const { spans: n, cols: i } = l3(e, t);
  return new Zp(n, i);
}
function nE(e) {
  const t = fe(e);
  return q`${t} DESC NULLS LAST`.annotate({ label: t == null ? void 0 : t.label, desc: !0 });
}
const ju = (e) => ({
  value: e,
  toString: () => Vu(e)
});
function Qp(e) {
  var t;
  e(this.op, this), (t = this.children) == null || t.forEach((n) => n.visit(e));
}
function u3(e, t) {
  const n = t.filter((r) => r != null).map(fe), i = n.map((r, s) => s ? ` ${e} ` : "");
  return t.length && i.push(""), q(i, ...n).annotate({ op: e, children: n, visit: Qp });
}
const Vo = (...e) => u3("AND", e.flat()), f3 = (...e) => u3("OR", e.flat()), h3 = (e) => (t) => q`(${fe(t)} ${e})`.annotate({ op: e, a: t, visit: Qp }), d3 = h3("IS NULL"), ud = h3("IS NOT NULL"), Yu = (e) => (t, n) => q`(${fe(t)} ${e} ${fe(n)})`.annotate({ op: e, a: t, b: n, visit: Qp }), ty = Yu("="), iE = Yu("<>"), fd = Yu("<"), p3 = Yu(">"), hd = Yu("<=");
function rE(e, t, n, i) {
  t = fe(t);
  const r = e.startsWith("NOT ") ? "NOT " : "";
  return (n ? i ? q`${r}(${n[0]} <= ${t} AND ${t} < ${n[1]})` : q`(${t} ${e} ${n[0]} AND ${n[1]})` : q``).annotate({ op: e, visit: Qp, field: t, range: n });
}
const Dn = (e, t, n) => rE("BETWEEN", e, t, n);
function dd(e, t) {
  return Array.from({ length: e }, () => t);
}
function qu(e, t) {
  return (...n) => {
    const i = n.map(fe), r = t ? `::${t}` : "";
    return (i.length ? q([`${e}(`, ...dd(i.length - 1, ", "), `)${r}`], ...i) : q`${e}()${r}`).annotate({ func: e, args: i });
  };
}
const sE = qu("REGEXP_MATCHES"), oE = qu("CONTAINS"), aE = qu("PREFIX"), cE = qu("SUFFIX");
class Ss extends Zp {
  constructor(t, n, i, r, s = "", o = "", a = "") {
    let c;
    if (r && !(s || o || a))
      c = r ? q`${n} OVER "${r}"` : q`${n} OVER ()`;
    else {
      const h = s && o ? " " : "", d = (s || o) && a ? " " : "";
      c = q`${n} OVER (${r ? `"${r}" ` : ""}${s}${h}${o}${d}${a})`;
    }
    i && (c = q`(${c})::${i}`);
    const { _expr: u, _deps: f } = c;
    super(u, f, { window: t, func: n, type: i, name: r, 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: i, type: r, group: s, order: o, frame: a } = this;
    return new Ss(n, i, r, t, s, o, a);
  }
  partitionby(...t) {
    const n = t.flat().filter((u) => u).map(fe), i = q(
      ["PARTITION BY ", dd(n.length - 1, ", "), ""],
      ...n
    ), { window: r, func: s, type: o, name: a, order: c, frame: l } = this;
    return new Ss(r, s, o, a, i, c, l);
  }
  orderby(...t) {
    const n = t.flat().filter((u) => u).map(fe), i = q(
      ["ORDER BY ", dd(n.length - 1, ", "), ""],
      ...n
    ), { window: r, func: s, type: o, name: a, group: c, frame: l } = this;
    return new Ss(r, s, o, a, c, i, l);
  }
  rows(t) {
    const n = Kw("ROWS", t), { window: i, func: r, type: s, name: o, group: a, order: c } = this;
    return new Ss(i, r, s, o, a, c, n);
  }
  range(t) {
    const n = Kw("RANGE", t), { window: i, func: r, type: s, name: o, group: a, order: c } = this;
    return new Ss(i, r, s, o, a, c, n);
  }
}
function Kw(e, t) {
  if (yc(t)) {
    const n = q`${t}`;
    return n.toString = () => `${e} ${Jw(t.value)}`, n;
  }
  return `${e} ${Jw(t)}`;
}
function Jw(e) {
  const [t, n] = e, i = t === 0 ? "CURRENT ROW" : Number.isFinite(t) ? `${Math.abs(t)} PRECEDING` : "UNBOUNDED PRECEDING", r = n === 0 ? "CURRENT ROW" : Number.isFinite(n) ? `${Math.abs(n)} FOLLOWING` : "UNBOUNDED FOLLOWING";
  return `BETWEEN ${i} AND ${r}`;
}
function Bi(e, t) {
  return (...n) => {
    const i = qu(e)(...n);
    return new Ss(e, i, t);
  };
}
const lE = Bi("ROW_NUMBER", "INTEGER"), uE = Bi("RANK", "INTEGER"), fE = Bi("DENSE_RANK", "INTEGER"), hE = Bi("PERCENT_RANK"), dE = Bi("CUME_DIST"), pE = Bi("NTILE"), yE = Bi("LAG"), mE = Bi("LEAD"), gE = Bi("FIRST_VALUE"), bE = Bi("LAST_VALUE"), _E = Bi("NTH_VALUE");
class Yl extends Zp {
  constructor(t, n, i, r, s) {
    n = (n || []).map(fe);
    const { strings: o, exprs: a } = wE(t, n, i, r, s), { spans: c, cols: l } = l3(o, a);
    super(c, l, { aggregate: t, args: n, type: i, isDistinct: r, filter: s });
  }
  get basis() {
    return this.column;
  }
  get label() {
    const { aggregate: t, args: n, isDistinct: i } = this, r = i ? "DISTINCT" + (n.length ? " " : "") : "", s = n.length ? `(${r}${n.map(vE).join(", ")})` : "";
    return `${t.toLowerCase()}${s}`;
  }
  distinct() {
    const { aggregate: t, args: n, type: i, filter: r } = this;
    return new Yl(t, n, i, !0, r);
  }
  where(t) {
    const { aggregate: n, args: i, type: r, isDistinct: s } = this;
    return new Yl(n, i, r, s, t);
  }
  window() {
    const { aggregate: t, args: n, type: i, isDistinct: r } = this, s = new Yl(t, n, null, r);
    return new Ss(t, s, i);
  }
  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 wE(e, t, n, i, r) {
  const s = `)${n ? `::${n}` : ""}`;
  let o = [`${e}(${i ? "DISTINCT " : ""}`], a = [];
  return t.length ? (o = o.concat([
    ...dd(t.length - 1, ", "),
    `${s}${r ? " FILTER (WHERE " : ""}`,
    ...r ? [")"] : []
  ]), a = [...t, ...r ? [r] : []]) : o[0] += "*" + s, { exprs: a, strings: o };
}
function vE(e) {
  const t = Vu(e);
  return t && t.startsWith('"') && t.endsWith('"') ? t.slice(1, -1) : t;
}
function Je(e, t) {
  return (...n) => new Yl(e, n, t);
}
const ko = Je("COUNT", "INTEGER"), xE = Je("AVG"), mc = Je("MAX"), gc = Je("MIN"), ta = Je("SUM", "DOUBLE"), SE = Je("MEDIAN"), IE = Je("QUANTILE"), $E = Je("MODE"), AE = Je("REGR_INTERCEPT"), ME = Je("REGR_SLOPE"), TE = Je("REGR_COUNT"), BE = Je("REGR_SYY"), NE = Je("REGR_SXX"), FE = Je("REGR_AVGX"), Zw = Je("ARG_MIN"), Qw = Je("ARG_MAX");
function DE(e, t) {
  const n = fe(e), i = q`CAST(${n} AS ${t})`;
  return Object.defineProperty(i, "label", {
    enumerable: !0,
    get() {
      return e.label;
    }
  }), Object.defineProperty(i, "aggregate", {
    enumerable: !0,
    get() {
      return e.aggregate || !1;
    }
  }), i;
}
const tv = (e) => DE(e, "DOUBLE"), y3 = (e) => {
  const t = fe(e);
  return q`(1000 * (epoch(${t}) - second(${t})) + millisecond(${t}))::DOUBLE`;
}, OE = (e) => {
  const t = fe(e);
  return q`MAKE_DATE(2012, MONTH(${t}), 1)`.annotate({ label: "month" });
}, EE = (e) => {
  const t = fe(e);
  return q`MAKE_DATE(2012, MONTH(${t}), DAY(${t}))`.annotate({ label: "date" });
}, LE = (e) => {
  const t = fe(e);
  return q`MAKE_DATE(2012, 1, DAY(${t}))`.annotate({ label: "date" });
};
class Et {
  static select(...t) {
    return new Et().select(...t);
  }
  static from(...t) {
    return new Et().from(...t);
  }
  static with(...t) {
    return new Et().with(...t);
  }
  static union(...t) {
    return new To("UNION", t.flat());
  }
  static unionAll(...t) {
    return new To("UNION ALL", t.flat());
  }
  static intersect(...t) {
    return new To("INTERSECT", t.flat());
  }
  static except(...t) {
    return new To("EXCEPT", t.flat());
  }
  constructor() {
    this.query = {
      with: [],
      select: [],
      from: [],
      where: [],
      groupby: [],
      having: [],
      window: [],
      qualify: [],
      orderby: []
    };
  }
  clone() {
    const t = new Et();
    return t.query = { ...this.query }, t;
  }
  with(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.with;
    {
      const i = [], r = (s, o) => {
        const a = o.clone();
        a.cteFor = this, i.push({ as: s, query: a });
      };
      return t.flat().forEach((s) => {
        if (s != null)
          if (s.as && s.query)
            r(s.as, s.query);
          else
            for (const o in s)
              r(o, s[o]);
      }), n.with = n.with.concat(i), this;
    }
  }
  select(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.select;
    {
      const i = [];
      for (const r of t.flat())
        if (r != null)
          if (typeof r == "string")
            i.push({ as: r, expr: fe(r) });
          else if (r instanceof ks)
            i.push({ as: r.column, expr: r });
          else if (Array.isArray(r))
            i.push({ as: r[0], expr: r[1] });
          else
            for (const s in r)
              i.push({ as: Bf(s), expr: fe(r[s]) });
      return n.select = n.select.concat(i), this;
    }
  }
  $select(...t) {
    return this.query.select = [], this.select(...t);
  }
  distinct(t = !0) {
    return this.query.distinct = !!t, this;
  }
  from(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.from;
    {
      const i = [];
      return t.flat().forEach((r) => {
        if (r != null)
          if (typeof r == "string")
            i.push({ as: r, from: b0(r) });
          else if (r instanceof ks)
            i.push({ as: r.table, from: r });
          else if (_0(r) || c3(r))
            i.push({ from: r });
          else if (Array.isArray(r))
            i.push({ as: Bf(r[0]), from: b0(r[1]) });
          else
            for (const s in r)
              i.push({ as: Bf(s), from: b0(r[s]) });
      }), n.from = n.from.concat(i), this;
    }
  }
  $from(...t) {
    return this.query.from = [], this.from(...t);
  }
  sample(t, n) {
    const { query: i } = this;
    if (arguments.length === 0)
      return i.sample;
    {
      let r = t;
      return typeof t == "number" && (r = t > 0 && t < 1 ? { perc: 100 * t, method: n } : { rows: Math.round(t), method: n }), i.sample = r, this;
    }
  }
  where(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.where : (n.where = n.where.concat(
      t.flat().filter((i) => i)
    ), this);
  }
  $where(...t) {
    return this.query.where = [], this.where(...t);
  }
  groupby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.groupby : (n.groupby = n.groupby.concat(
      t.flat().filter((i) => i).map(fe)
    ), 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((i) => i)
    ), this);
  }
  window(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.window;
    {
      const i = [];
      return t.flat().forEach((r) => {
        if (r != null)
          for (const s in r)
            i.push({ as: Bf(s), expr: r[s] });
      }), n.window = n.window.concat(i), this;
    }
  }
  qualify(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.qualify : (n.qualify = n.qualify.concat(
      t.flat().filter((i) => i)
    ), this);
  }
  orderby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.orderby : (n.orderby = n.orderby.concat(
      t.flat().filter((i) => i).map(fe)
    ), this);
  }
  limit(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.limit : (n.limit = Number.isFinite(t) ? t : void 0, this);
  }
  offset(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.offset : (n.offset = Number.isFinite(t) ? t : void 0, this);
  }
  get subqueries() {
    const { query: t, cteFor: n } = this, i = ((n == null ? void 0 : n.query) || t).with, r = i == null ? void 0 : i.reduce((o, { as: a, query: c }) => (o[a] = c, o), {}), s = [];
    return t.from.forEach(({ from: o }) => {
      if (_0(o))
        s.push(o);
      else if (r[o.table]) {
        const a = r[o.table];
        s.push(a);
      }
    }), s;
  }
  toString() {
    const {
      select: t,
      distinct: n,
      from: i,
      sample: r,
      where: s,
      groupby: o,
      having: a,
      window: c,
      qualify: l,
      orderby: u,
      limit: f,
      offset: h,
      with: d
    } = this.query, p = [];
    if (d.length) {
      const g = d.map(({ as: m, query: b }) => `"${m}" AS (${b})`);
      p.push(`WITH ${g.join(", ")}`);
    }
    const y = t.map(
      ({ as: g, expr: m }) => QO(m, g) && !m.table ? `${m}` : `${m} AS "${g}"`
    );
    if (p.push(`SELECT${n ? " DISTINCT" : ""} ${y.join(", ")}`), i.length) {
      const g = i.map(({ as: m, from: b }) => {
        const _ = _0(b) ? `(${b})` : `${b}`;
        return !m || m === b.table ? _ : `${_} 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 (r) {
      const { rows: g, perc: m, method: b, seed: _ } = r, w = g ? `${g} ROWS` : `${m} PERCENT`, v = b ? ` (${b}${_ != null ? `, ${_}` : ""})` : "";
      p.push(`USING SAMPLE ${w}${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 (l.length) {
      const g = l.map(String).filter((m) => m).join(" AND ");
      g && p.push(`QUALIFY ${g}`);
    }
    return u.length && p.push(`ORDER BY ${u.join(", ")}`), Number.isFinite(f) && p.push(`LIMIT ${f}`), Number.isFinite(h) && p.push(`OFFSET ${h}`), p.join(" ");
  }
}
class To {
  constructor(t, n) {
    this.op = t, this.queries = n.map((i) => i.clone()), this.query = { orderby: [] };
  }
  clone() {
    const t = new To(this.op, this.queries);
    return t.query = { ...this.query }, t;
  }
  orderby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.orderby : (n.orderby = n.orderby.concat(
      t.flat().filter((i) => i).map(fe)
    ), this);
  }
  limit(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.limit : (n.limit = Number.isFinite(t) ? t : void 0, this);
  }
  offset(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.offset : (n.offset = Number.isFinite(t) ? t : void 0, this);
  }
  get subqueries() {
    const { queries: t, cteFor: n } = this;
    return n && t.forEach((i) => i.cteFor = n), t;
  }
  toString() {
    const { op: t, queries: n, query: { orderby: i, limit: r, offset: s } } = this, o = [n.join(` ${t} `)];
    return i.length && o.push(`ORDER BY ${i.join(", ")}`), Number.isFinite(r) && o.push(`LIMIT ${r}`), Number.isFinite(s) && o.push(`OFFSET ${s}`), o.join(" ");
  }
}
function _0(e) {
  return e instanceof Et || e instanceof To;
}
function Bf(e) {
  return RE(e) ? e.slice(1, -1) : e;
}
function RE(e) {
  return e[0] === '"' && e[e.length - 1] === '"';
}
function E1(e, t, {
  replace: n = !1,
  temp: i = !0,
  view: r = !1
} = {}) {
  return "CREATE" + (n ? " OR REPLACE " : " ") + (i ? "TEMP " : "") + (r ? "VIEW" : "TABLE") + (n ? " " : " IF NOT EXISTS ") + e + " AS " + t;
}
function CE(e, {
  columns: t = Object.keys((e == null ? void 0 : e[0]) || {})
} = {}) {
  let n = [];
  if (Array.isArray(t) ? (n = t, t = n.reduce((r, s) => (r[s] = s, r), {})) : t && (n = Object.keys(t)), !n.length)
    throw new Error("Can not create table from empty column set.");
  const i = [];
  for (const r of e) {
    const s = n.map((o) => `${Vu(r[o])} AS "${t[o]}"`);
    i.push(`(SELECT ${s.join(", ")})`);
  }
  return i.join(" UNION ALL ");
}
function L1(e, t, n, i = {}, r = {}) {
  const { select: s = ["*"], where: o, view: a, temp: c, replace: l, ...u } = i, f = VE({ ...r, ...u }), h = `${e}('${n}'${f ? ", " + f : ""})`, d = o ? ` WHERE ${o}` : "", p = `SELECT ${s.join(", ")} FROM ${h}${d}`;
  return E1(t, p, { view: a, temp: c, replace: l });
}
function kE(e, t, n) {
  return L1("read_csv", e, t, n, { auto_detect: !0, sample_size: -1 });
}
function UE(e, t, n) {
  return L1("read_json", e, t, n, { auto_detect: !0, json_format: "auto" });
}
function zE(e, t, n) {
  return L1("read_parquet", e, t, n);
}
function PE(e, t, n = {}) {
  const { select: i = ["*"], ...r } = n, s = CE(t), o = i.length === 1 && i[0] === "*" ? s : `SELECT ${i} FROM ${s}`;
  return E1(e, o, r);
}
function VE(e) {
  return Object.entries(e).map(([t, n]) => {
    const i = typeof n, r = i === "boolean" ? String(n) : i === "string" ? `'${n}'` : n;
    return `${t}=${r}`;
  }).join(", ");
}
const jE = "count", YE = "nulls", qE = "max", WE = "min", GE = "distinct", XE = {
  [jE]: ko,
  [GE]: (e) => ko(e).distinct(),
  [qE]: mc,
  [WE]: gc,
  [YE]: (e) => ko().where(d3(e))
};
function HE({ table: e, column: t }, n) {
  return Et.from(e).select(n.map((i) => [i, XE[i](t)]));
}
const m3 = () => /* @__PURE__ */ Object.create(null);
class KE {
  constructor(t) {
    this.mc = t, this.clear();
  }
  clear() {
    this.tables = m3();
  }
  tableInfo(t) {
    const n = this.tables;
    if (n[t])
      return n[t];
    const i = JE(this.mc, t).catch((r) => {
      throw n[t] = null, r;
    });
    return n[t] = i;
  }
  async fieldInfo({ table: t, column: n, stats: i }) {
    const s = (await this.tableInfo(t))[n];
    if (s == null)
      return;
    if (!(i != null && i.length))
      return s;
    const o = await this.mc.query(
      HE(s, i),
      { persist: !0 }
    ), a = { ...s, ...Array.from(o)[0] };
    for (const c in a) {
      const l = a[c];
      typeof l == "bigint" && (a[c] = Number(l));
    }
    return a;
  }
  async queryFields(t) {
    const n = await ZE(this, t);
    return (await Promise.all(n.map((r) => this.fieldInfo(r)))).filter((r) => r);
  }
}
async function JE(e, t) {
  const n = await e.query(
    `DESCRIBE "${t}"`,
    { type: "json", cache: !1 }
  ), i = m3();
  for (const r of n)
    i[r.column_name] = {
      table: t,
      column: r.column_name,
      sqlType: r.column_type,
      type: ZO(r.column_type),
      nullable: r.null === "YES"
    };
  return i;
}
async function ZE(e, t) {
  return t.length === 1 && t[0].column === "*" ? Object.values(await e.tableInfo(t[0].table)) : t;
}
function QE(e) {
  let t = 2166136261;
  for (let n = 0, i = e.length; n < i; ++n) {
    const r = e.charCodeAt(n), s = r & 65280;
    s && (t = ev(t ^ s >> 8)), t = ev(t ^ r & 255);
  }
  return t5(t);
}
function ev(e) {
  return e + (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
}
function t5(e) {
  return e += e << 13, e ^= e >>> 7, e += e << 3, e ^= e >>> 17, e += e << 5, e & 4294967295;
}
const g3 = (e) => e;
class e5 {
  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 l = Array.from(t, iv), u = (a = l[0]) == null ? void 0 : a.from;
      this.enabled = l.every((f) => f && f.from === u), this.clients = t, this.activeView = null, this.clear();
    }
    if (!this.enabled)
      return !1;
    n = n || this.selection.active;
    const { source: i } = n;
    if (i && i === ((c = this.activeView) == null ? void 0 : c.source))
      return !0;
    if (this.clear(), !i)
      return !1;
    const r = this.activeView = n5(n);
    if (!r)
      return !1;
    this.mc.logger().warn("DATA TILE INDEX CONSTRUCTION");
    const s = this.selection.remove(i), o = this.indices = /* @__PURE__ */ new Map();
    for (const l of t) {
      if (s.skip(l, n))
        continue;
      const u = iv(l), f = l.query(s.predicate(l)).select({ ...r.columns, ...u.count }).groupby(Object.keys(r.columns)), [h] = f.subqueries;
      if (h) {
        const m = Object.values(r.columns).map((b) => b.columns[0]);
        o5(h, m);
      }
      const d = f.toString(), y = `tile_index_${(QE(d) >>> 0).toString(16)}`, g = s5(this.mc, y, d);
      o.set(l, { table: y, result: g, ...u });
    }
  }
  async update() {
    const { clients: t, selection: n, activeView: i } = this, r = i.predicate(n.active.predicate);
    return Promise.all(
      Array.from(t).map((s) => this.updateClient(s, r))
    );
  }
  async updateClient(t, n) {
    const i = this.indices.get(t);
    if (!i)
      return;
    n || (n = this.activeView.predicate(this.selection.active.predicate));
    const { table: r, dims: s, aggr: o } = i, a = Et.select(s, o).from(r).groupby(s).where(n);
    return this.mc.updateClient(t, a);
  }
}
function n5(e) {
  var c;
  const { source: t, schema: n } = e;
  let i = (c = e.predicate) == null ? void 0 : c.columns;
  if (!n || !i)
    return null;
  const { type: r, scales: s, pixelSize: o = 1 } = n;
  let a;
  if (r === "interval" && s) {
    const l = s.map((u) => i5(u, o));
    if (l.some((u) => u == null))
      return null;
    l.length === 1 ? (a = (u) => u ? Dn("active0", u.range.map(l[0])) : [], i = { active0: l[0](e.predicate.field) }) : (a = (u) => u ? Vo(u.children.map(({ range: f }, h) => Dn(`active${h}`, f.map(l[h])))) : [], i = Object.fromEntries(
      e.predicate.children.map((u, f) => [`active${f}`, l[f](u.field)])
    ));
  } else if (r === "point")
    a = g3, i = Object.fromEntries(i.map((l) => [l.toString(), l]));
  else
    return null;
  return { source: t, columns: i, predicate: a };
}
function i5(e, t) {
  const { type: n, domain: i, range: r } = e;
  let s, o;
  switch (n) {
    case "linear":
      s = g3, o = fe;
      break;
    case "log":
      s = Math.log, o = (a) => q`LN(${fe(a)})`;
      break;
    case "symlog":
      s = (a) => Math.sign(a) * Math.log1p(Math.abs(a)), o = (a) => (a = fe(a), q`SIGN(${a}) * LN(1 + ABS(${a}))`);
      break;
    case "sqrt":
      s = Math.sqrt, o = (a) => q`SQRT(${fe(a)})`;
      break;
    case "utc":
    case "time":
      s = (a) => +a, o = (a) => a instanceof Date ? +a : y3(fe(a));
      break;
  }
  return s ? r5(i, r, t, s, o) : null;
}
function r5(e, t, n, i, r) {
  const s = i(Math.min(e[0], e[1])), o = i(Math.max(e[0], e[1])), a = Math.abs(i(t[1]) - i(t[0])) / (o - s) / n, c = n === 1 ? "" : `${n}::INTEGER * `;
  return (l) => q`${c}FLOOR(${a}::DOUBLE * (${r(l)} - ${s}::DOUBLE))::INTEGER`;
}
function s5(e, t, n) {
  return e.exec(`CREATE TEMP TABLE IF NOT EXISTS ${t} AS ${n}`);
}
const nv = { from: NaN };
function iv(e) {
  if (!e.filterIndexable)
    return nv;
  const t = e.query(), n = zm(t);
  if (!n || !t.groupby)
    return nv;
  const i = new Set(t.groupby().map((a) => a.column)), r = [], s = [];
  let o;
  for (const { as: a, expr: { aggregate: c } } of t.select())
    switch (c == null ? void 0 : c.toUpperCase()) {
      case "COUNT":
      case "SUM":
        r.push({ [a]: q`SUM("${a}")::DOUBLE` });
        break;
      case "AVG":
        o = "_count_", r.push({ [a]: q`(SUM("${a}" * ${o}) / SUM(${o}))::DOUBLE` });
        break;
      case "MAX":
        r.push({ [a]: q`MAX("${a}")` });
        break;
      case "MIN":
        r.push({ [a]: q`MIN("${a}")` });
        break;
      default:
        if (i.has(a))
          s.push(a);
        else
          return null;
    }
  return {
    aggr: r,
    dims: s,
    count: o ? { [o]: q`COUNT(*)` } : {},
    from: n
  };
}
function zm(e) {
  const t = e.subqueries;
  if (e.select) {
    const i = e.from();
    if (!i.length)
      return;
    if (t.length === 0)
      return i[0].from.table;
  }
  const n = zm(t[0]);
  for (let i = 1; i < t.length; ++i) {
    const r = zm(t[i]);
    if (r !== void 0 && r !== n)
      return NaN;
  }
  return n;
}
function o5(e, t) {
  const n = /* @__PURE__ */ new Set(), i = (r) => {
    n.has(r) || (n.add(r), r.select && r.from().length && r.select(t), r.subqueries.forEach(i));
  };
  i(e);
}
class a5 {
  constructor(t, n, i = !0) {
    this.mc = t, this.selection = n, this.clients = /* @__PURE__ */ new Set(), this.indexer = i ? new e5(this.mc, n) : null;
    const { value: r, 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", r), n.addEventListener("activate", s);
  }
  finalize() {
    const { value: t, activate: n } = this.handlers;
    this.selection.removeEventListener("value", t), this.selection.removeEventListener("activate", n);
  }
  reset() {
    var t;
    (t = this.indexer) == null || t.reset();
  }
  add(t) {
    return (this.clients = new Set(this.clients)).add(t), this;
  }
  remove(t) {
    return this.clients.has(t) && (this.clients = new Set(this.clients)).delete(t), this;
  }
  update() {
    const { mc: t, indexer: n, clients: i, selection: r } = this;
    return n != null && n.index(i) ? n.update() : c5(t, i, r);
  }
}
function c5(e, t, n) {
  return Promise.all(Array.from(t).map((i) => {
    const r = n.predicate(i);
    if (r != null)
      return e.updateClient(i, i.query(r));
  }));
}
function b3() {
  let e, t;
  const n = new Promise((i, r) => {
    e = i, t = r;
  });
  return n.fulfill = (i) => (e(i), n), n.reject = (i) => (t(i), n), n;
}
function l5(e, t, n) {
  let i = [], r = 0;
  function s() {
    const o = u5(i, t);
    i = [], r = 0;
    for (const a of o)
      h5(a, e, n), y5(a, t);
  }
  return {
    add(o, a) {
      o.request.type === "arrow" ? (r = r || requestAnimationFrame(() => s()), i.push({ entry: o, priority: a, index: i.length })) : e(o, a);
    }
  };
}
function u5(e, t) {
  const n = [], i = /* @__PURE__ */ new Map();
  for (const r of e) {
    const { entry: { request: s } } = r, o = f5(s.query, t);
    if (!i.has(o)) {
      const a = [];
      n.push(a), i.set(o, a);
    }
    i.get(o).push(r);
  }
  return n;
}
function f5(e, t) {
  const n = `${e}`;
  if (e instanceof Et && !t.get(n)) {
    if (e.orderby().length || e.where().length || e.qualify().length || e.having().length)
      return n;
    const i = e.clone().$select("*"), r = e.groupby();
    if (r.length) {
      const s = {};
      e.select().forEach(({ as: o, expr: a }) => s[o] = a), i.$groupby(r.map((o) => o instanceof ks && s[o.column] || o));
    }
    return `${i}`;
  } else
    return n;
}
function h5(e, t, n) {
  if (d5(e))
    t({
      request: {
        type: "arrow",
        cache: !1,
        record: !1,
        query: p5(e, n)
      },
      result: e.result = b3()
    });
  else
    for (const { entry: i, priority: r } of e)
      t(i, r);
}
function d5(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 p5(e, t) {
  const n = e.maps = [], i = /* @__PURE__ */ new Map();
  for (const o of e) {
    const { query: a } = o.entry.request, c = [];
    n.push(c);
    for (const { as: l, expr: u } of a.select()) {
      const f = `${u}`;
      i.has(f) || i.set(f, [`col${i.size}`, u]);
      const [h] = i.get(f);
      c.push([h, l]);
    }
    t(`${a}`);
  }
  const r = e[0].entry.request.query.clone(), s = r.groupby();
  if (s.length) {
    const o = {};
    e.maps[0].forEach(([a, c]) => o[c] = a), r.$groupby(s.map((a) => a instanceof ks && o[a.column] || a));
  }
  return r.$select(Array.from(i.values()));
}
async function y5(e, t) {
  const { maps: n, result: i } = e;
  if (!n)
    return;
  let r;
  try {
    r = await i;
  } catch (s) {
    for (const { entry: o } of e)
      o.result.reject(s);
    return;
  }
  e.forEach(({ entry: s }, o) => {
    const { request: a, result: c } = s, l = m5(r, n[o]);
    a.cache && t.set(String(a.query), l), c.fulfill(l);
  });
}
function m5(e, t) {
  if (t) {
    const n = {};
    for (const [i, r] of t)
      n[r] = e.getChild(i);
    return new e.constructor(n);
  } else
    return e;
}
const g5 = typeof requestIdleCallback < "u" ? requestIdleCallback : setTimeout, b5 = () => ({
  get: () => {
  },
  set: (e, t) => t,
  clear: () => {
  }
});
function _5({
  max: e = 1e3,
  // max entries
  ttl: t = 3 * 60 * 60 * 1e3
  // time-to-live, default 3 hours
} = {}) {
  let n = /* @__PURE__ */ new Map();
  function i() {
    const r = performance.now() - t;
    let s = null, o = 1 / 0;
    for (const [a, c] of n) {
      const { last: l } = c;
      l < o && (s = a, o = l), r > l && n.delete(a);
    }
    s && n.delete(s);
  }
  return {
    get(r) {
      const s = n.get(r);
      if (s)
        return s.last = performance.now(), s.value;
    },
    set(r, s) {
      return n.set(r, { last: performance.now(), value: s }), n.size > e && g5(i), s;
    },
    clear() {
      n = /* @__PURE__ */ new Map();
    }
  };
}
function w5(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, i) {
      const r = t[i];
      if (!r)
        throw new Error(`Invalid queue priority rank: ${i}`);
      const s = { item: n, next: null };
      r.head === null ? r.head = r.tail = s : r.tail = r.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 i of t) {
        let { head: r, tail: s } = i;
        for (let o = null, a = r; a; o = a, a = a.next)
          n(a.item) && (a === r ? r = a.next : o.next = a.next, a === s && (s = o || r));
        i.head = r, i.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: i } = n;
        if (i !== null)
          return n.head = i.next, n.tail === i && (n.tail = null), i.item;
      }
    }
  };
}
const _s = { High: 0, Normal: 1, Low: 2 };
function v5() {
  const e = w5(3);
  let t, n, i, r = [], s = null, o;
  function a() {
    if (s || e.isEmpty())
      return;
    const { request: f, result: h } = e.next();
    s = u(f, h), s.finally(() => {
      s = null, a();
    });
  }
  function c(f, h = _s.Normal) {
    e.insert(f, h), a();
  }
  function l(f) {
    r.length && f && r.forEach((h) => h.add(f));
  }
  async function u(f, h) {
    try {
      const { query: d, type: p, cache: y = !1, record: g = !0, options: m } = f, b = d ? `${d}` : null;
      if (g && l(b), y) {
        const v = n.get(b);
        if (v) {
          i.debug("Cache"), h.fulfill(v);
          return;
        }
      }
      const _ = performance.now(), w = await t.query({ type: p, sql: b, ...m });
      y && n.set(b, w), i.debug(`Request: ${(performance.now() - _).toFixed(1)}`), h.fulfill(w);
    } catch (d) {
      h.reject(d);
    }
  }
  return {
    cache(f) {
      return f !== void 0 ? n = f === !0 ? _5() : f || b5() : n;
    },
    logger(f) {
      return f ? i = f : i;
    },
    connector(f) {
      return f ? t = f : t;
    },
    consolidate(f) {
      f && !o ? o = l5(c, n, l) : !f && o && (o = null);
    },
    request(f, h = _s.Normal) {
      const d = b3(), p = { request: f, result: d };
      return o ? o.add(p, h) : c(p, h), d;
    },
    cancel(f) {
      const h = new Set(f);
      e.remove(({ result: d }) => h.has(d));
    },
    clear() {
      e.remove(({ result: f }) => (f.reject("Cleared"), !0));
    },
    record() {
      let f = [];
      const h = {
        add(d) {
          f.push(d);
        },
        reset() {
          f = [];
        },
        snapshot() {
          return f.slice();
        },
        stop() {
          return r = r.filter((d) => d !== h), f;
        }
      };
      return r.push(h), h;
    }
  };
}
function x5() {
  return {
    debug() {
    },
    info() {
    },
    log() {
    },
    warn() {
    },
    error() {
    }
  };
}
let Nf;
function pi(e) {
  return e ? Nf = e : Nf == null && (Nf = new S5()), Nf;
}
class S5 {
  constructor(t = JO(), n = {}) {
    this.catalog = new KE(this), this.manager = n.manager || v5(), this.logger(n.logger || console), this.configure(n), this.databaseConnector(t), this.clear();
  }
  logger(t) {
    return arguments.length && (this._logger = t || x5(), this.manager.logger(this._logger)), this._logger;
  }
  configure({ cache: t = !0, consolidate: n = !0, indexes: i = !0 }) {
    this.manager.cache(t), this.manager.consolidate(n), this.indexes = i;
  }
  clear({ clients: t = !0, cache: n = !0, catalog: i = !1 } = {}) {
    var r, s;
    this.manager.clear(), t && ((r = this.clients) == null || r.forEach((o) => this.disconnect(o)), (s = this.filterGroups) == null || s.forEach((o) => o.finalize()), this.clients = /* @__PURE__ */ new Set(), this.filterGroups = /* @__PURE__ */ new Map()), n && this.manager.cache().clear(), i && this.catalog.clear();
  }
  databaseConnector(t) {
    return this.manager.connector(t);
  }
  // -- Query Management ----
  cancel(t) {
    this.manager.cancel(t);
  }
  exec(t, { priority: n = _s.Normal } = {}) {
    return this.manager.request({ type: "exec", query: t }, n);
  }
  query(t, {
    type: n = "arrow",
    cache: i = !0,
    priority: r = _s.Normal,
    ...s
  } = {}) {
    return this.manager.request({ type: n, query: t, cache: i, options: s }, r);
  }
  prefetch(t, n = {}) {
    return this.query(t, { ...n, cache: !0, priority: _s.Low });
  }
  createBundle(t, n, i = _s.Low) {
    const r = { name: t, queries: n };
    return this.manager.request({ type: "create-bundle", options: r }, i);
  }
  loadBundle(t, n = _s.High) {
    const i = { name: t };
    return this.manager.request({ type: "load-bundle", options: i }, n);
  }
  // -- Client Management ----
  updateClient(t, n, i = _s.Normal) {
    return t.queryPending(), this.query(n, { priority: i }).then(
      (r) => t.queryResult(r).update(),
      (r) => {
        t.queryError(r), this._logger.error(r);
      }
    );
  }
  requestQuery(t, n) {
    var i;
    return (i = this.filterGroups.get(t.filterBy)) == null || i.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: i, filterGroups: r, indexes: s } = this;
    if (i.has(t))
      throw new Error("Client already connected.");
    i.add(t);
    const o = t.fields();
    o != null && o.length && t.fieldInfo(await n.queryFields(o));
    const a = t.filterBy;
    if (a)
      if (r.has(a))
        r.get(a).add(t);
      else {
        const c = new a5(this, a, s);
        r.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 r;
    const { clients: n, filterGroups: i } = this;
    n.has(t) && (n.delete(t), (r = i.get(t.filterBy)) == null || r.remove(t));
  }
}
const rv = {};
function _3(e, t = !1) {
  let n, i, r = rv;
  function s(l) {
    n = e(l).then(() => {
      if (i) {
        const { value: u } = i;
        i = null, s(u);
      } else
        n = null;
    });
  }
  function o(l) {
    i = { event: l };
  }
  function a(l) {
    n ? o(l) : s(l);
  }
  function c(l) {
    r !== l && requestAnimationFrame(() => {
      const u = r;
      r = rv, a(u);
    }), r = l;
  }
  return t ? c : a;
}
class Wu {
  /**
   * 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 = _3(() => 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 i;
    const n = t || this.query((i = this.filterBy) == null ? void 0 : i.predicate(this));
    return pi().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 I5 {
  /**
   * 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 $5()
    }), 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 i = this._callbacks.get(t);
    i && i.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 i = this._callbacks.get(t) || {};
    if (i.pending)
      i.queue.enqueue(n, this.emitQueueFilter(t, n));
    else {
      const r = this.willEmit(t, n), { callbacks: s, queue: o } = i;
      if (s != null && s.size) {
        const a = Promise.allSettled(Array.from(s, (c) => c(r))).then(() => {
          i.pending = null, o.isEmpty() || this.emit(t, o.dequeue());
        });
        i.pending = a;
      }
    }
  }
}
class $5 {
  /**
   * 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 i = { value: t };
    if (n && this.next) {
      let r = this;
      for (; r.next; )
        n(r.next.value) ? r = r.next : r.next = r.next.next;
      r.next = i;
    } else
      this.next = i;
  }
  /**
   * 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 w3(e, t) {
  return e === t ? !1 : e instanceof Date && t instanceof Date ? +e != +t : Array.isArray(e) && Array.isArray(t) ? A5(e, t) : !0;
}
function A5(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 Ds(e) {
  return e instanceof qr;
}
class qr extends I5 {
  /**
   * 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 qr(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) => Ds(n))) {
      const n = new qr(), i = () => n.update(t.map((r) => Ds(r) ? r.value : r));
      return i(), t.forEach((r) => Ds(r) ? r.addEventListener("value", i) : 0), n;
    }
    return new qr(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 w3(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 jo(e) {
  return e instanceof Ts;
}
let Ts = class Na extends qr {
  /**
   * 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 Na(new ul({ 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 Na(new ul({ 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 Na(new ul({ 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 Na(new ul({ cross: !0 }));
  }
  /**
   * Create a new Selection instance.
   * @param {SelectionResolver} resolver The selection resolution
   *  strategy to apply.
   */
  constructor(t = new ul()) {
    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 Na(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 ul {
  /**
   * 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: i } = {}) {
    this.union = !!t, this.cross = !!n, this.single = !!i;
  }
  /**
   * 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, i = !1) {
    const { source: r, predicate: s } = n, o = t.filter((c) => r !== c.source), a = this.single ? [] : o;
    return this.single && i && o.forEach((c) => {
      var l, u;
      return (u = (l = c.source) == null ? void 0 : l.reset) == null ? void 0 : u.call(l);
    }), 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 i;
    return this.cross && ((i = n == null ? void 0 : n.clients) == null ? void 0 : i.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, i) {
    const { union: r } = this;
    if (this.skip(i, n))
      return;
    const s = t.filter((o) => !this.skip(i, o)).map((o) => o.predicate);
    return r && s.length > 1 ? f3(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 i = (n = t.active) == null ? void 0 : n.source;
      return (r) => {
        var s;
        return ((s = r.active) == null ? void 0 : s.source) !== i;
      };
    }
  }
}
function M5() {
  const e = /* @__PURE__ */ new Set();
  let t, n = new Promise((i) => t = i);
  return {
    /**
     * Mark an item as pending.
     * @param {*} item An item to synchronize on.
     */
    pending(i) {
      e.add(i);
    },
    /**
     * 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(i) {
      return e.delete(i), e.size === 0;
    },
    /**
     * Resolve the current synchronization cycle, causing the synchronize
     * promise to resolve and thereby trigger downstream updates.
     */
    resolve() {
      n = new Promise((i) => {
        t(), t = i;
      });
    },
    /**
     * The promise for the current synchronization cycle.
     * @return {Promise} The synchronization promise.
     */
    get promise() {
      return n;
    }
  };
}
function ey(e, t) {
  const n = new e(t);
  return pi().connect(n), n.element;
}
const T5 = (e) => e && typeof e == "object" && !Array.isArray(e), B5 = (e) => ey(N5, e);
class N5 extends Wu {
  constructor({
    element: t,
    filterBy: n,
    from: i,
    column: r,
    label: s = r,
    format: o = (u) => u,
    // TODO
    options: a,
    value: c,
    as: l
  } = {}) {
    var f, h, d, p;
    super(n), this.from = i, this.column = r, this.selection = l, this.format = o, this.element = t ?? document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this;
    const u = document.createElement("label");
    u.innerText = s || r, this.element.appendChild(u), this.select = document.createElement("select"), a && (this.data = a.map((y) => T5(y) ? y : { value: y }), this.update()), c = c ?? ((f = this.selection) == null ? void 0 : f.value) ?? ((d = (h = this.data) == null ? void 0 : h[0]) == null ? void 0 : d.value), ((p = this.selection) == null ? void 0 : p.value) === void 0 && this.publish(c), this.element.appendChild(this.select), this.selection && (this.select.addEventListener("input", () => {
      this.publish(this.selectedValue() ?? null);
    }), jo(this.selection) || this.selection.addEventListener("value", (y) => {
      y !== this.select.value && this.selectedValue(y);
    }));
  }
  selectedValue(t) {
    var n;
    if (arguments.length === 0) {
      const i = this.select.selectedIndex;
      return this.data[i].value;
    } else {
      const i = (n = this.data) == null ? void 0 : n.findIndex((r) => r.value === t);
      i >= 0 ? this.select.selectedIndex = i : this.select.value = String(t);
    }
  }
  reset() {
    this.select.selectedIndex = this.from ? 0 : -1;
  }
  publish(t) {
    const { selection: n, column: i } = this;
    jo(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: t ? ty(i, ju(t)) : null
    }) : Ds(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return n ? Et.from(n).select({ value: i }).distinct().where(t).orderby(i) : null;
  }
  queryResult(t) {
    return this.data = [{ value: "", label: "All" }, ...t], this;
  }
  update() {
    var r;
    const { data: t, format: n, select: i } = this;
    i.replaceChildren();
    for (const { value: s, label: o } of t) {
      const a = document.createElement("option");
      a.setAttribute("value", s), a.innerText = o ?? n(s), this.select.appendChild(a);
    }
    return this.selection && this.selectedValue(((r = this.selection) == null ? void 0 : r.value) ?? ""), this;
  }
}
const F5 = { contains: oE, prefix: aE, suffix: cE, regexp: sE };
let D5 = 0;
const O5 = (e) => ey(E5, e);
class E5 extends Wu {
  constructor({
    element: t,
    filterBy: n,
    from: i,
    column: r,
    label: s,
    type: o = "contains",
    as: a
  } = {}) {
    if (super(n), this.id = "search_" + ++D5, this.type = o, this.from = i, this.column = r, 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);
    }), jo(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: i, type: r } = this;
    jo(n) ? n.update({
      source: this,
      schema: { type: r },
      value: t,
      predicate: t ? F5[r](i, ju(t)) : null
    }) : Ds(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return n ? Et.from(n).select({ list: i }).distinct().where(t) : null;
  }
  queryResult(t) {
    return this.data = t, this;
  }
  update() {
    const t = document.createElement("datalist"), n = `${this.id}_list`;
    t.setAttribute("id", n);
    for (const i of this.data) {
      const r = document.createElement("option");
      r.setAttribute("value", i.list), t.append(r);
    }
    return this.datalist && this.datalist.remove(), this.element.appendChild(this.datalist = t), this.searchbox.setAttribute("list", n), this;
  }
}
let L5 = 0;
const R5 = (e) => ey(C5, e);
class C5 extends Wu {
  constructor({
    element: t,
    filterBy: n,
    as: i,
    min: r,
    max: s,
    step: o,
    from: a,
    column: c,
    label: l = c,
    value: u = i == null ? void 0 : i.value,
    width: f
  } = {}) {
    var h;
    if (super(n), this.id = "slider_" + ++L5, this.from = a, this.column = c || "value", this.selection = i, this.min = r, this.max = s, this.step = o, this.element = t || document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this, l) {
      const d = document.createElement("label");
      d.setAttribute("for", this.id), d.innerText = l, this.element.appendChild(d);
    }
    this.slider = document.createElement("input"), this.slider.setAttribute("id", this.id), this.slider.setAttribute("type", "range"), f != null && (this.slider.style.width = `${+f}px`), r != null && this.slider.setAttribute("min", r), s != null && this.slider.setAttribute("max", s), o != null && this.slider.setAttribute("step", o), u != null && (this.slider.setAttribute("value", u), ((h = this.selection) == null ? void 0 : h.value) === void 0 && this.publish(u)), this.element.appendChild(this.slider), this.selection && (this.slider.addEventListener("input", () => {
      this.publish(+this.slider.value);
    }), jo(this.selection) || this.selection.addEventListener("value", (d) => {
      d !== +this.slider.value && (this.slider.value = d);
    }));
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return !n || this.min != null && this.max != null ? null : Et.select({ min: gc(i), max: mc(i) }).from(n).where(t);
  }
  queryResult(t) {
    const { min: n, max: i } = Array.from(t)[0];
    return this.min == null && this.slider.setAttribute("min", n), this.max == null && this.slider.setAttribute("max", i), this.step == null && this.slider.setAttribute("step", (i - n) / 500), this;
  }
  publish(t) {
    const { selection: n, column: i } = this;
    jo(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: ty(i, ju(t))
    }) : Ds(this.selection) && n.update(t);
  }
}
function v3(e, t) {
  if (e instanceof Date || (e = /* @__PURE__ */ new Date(+e)), isNaN(e))
    return typeof t == "function" ? t(e) : t;
  const n = e.getUTCHours(), i = e.getUTCMinutes(), r = e.getUTCSeconds(), s = e.getUTCMilliseconds();
  return `${k5(e.getUTCFullYear())}-${Er(e.getUTCMonth() + 1, 2)}-${Er(e.getUTCDate(), 2)}${n || i || r || s ? `T${Er(n, 2)}:${Er(i, 2)}${r || s ? `:${Er(r, 2)}${s ? `.${Er(s, 3)}` : ""}` : ""}Z` : ""}`;
}
function k5(e) {
  return e < 0 ? `-${Er(-e, 6)}` : e > 9999 ? `+${Er(e, 6)}` : Er(e, 4);
}
function Er(e, t) {
  return `${e}`.padStart(t, "0");
}
const U5 = /^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;
function R1(e, t) {
  return U5.test(e += "") ? new Date(e) : typeof t == "function" ? t(e) : t;
}
const x3 = k1((e) => {
  const t = C1(e);
  return (n) => n == null ? "" : typeof n == "number" ? t(n) : n instanceof Date ? S3(n) : `${n}`;
}), C1 = k1((e) => (t) => t === 0 ? "0" : t.toLocaleString(e));
x3();
C1();
function S3(e) {
  return v3(e, "Invalid Date");
}
function k1(e) {
  let t = k1, n;
  return (i = "en") => i === t ? n : n = e(t = i);
}
let z5 = -1;
const P5 = (e) => ey(V5, e);
let V5 = class extends Wu {
  constructor({
    element: t,
    filterBy: n,
    from: i,
    columns: r = ["*"],
    align: s = {},
    format: o,
    width: a,
    maxWidth: c,
    height: l = 500,
    rowBatch: u = 100
  } = {}) {
    super(n), this.id = `table-${++z5}`, this.from = i, this.columns = r, this.format = o, this.align = s, this.widths = typeof a == "object" ? a : {}, this.offset = 0, this.limit = +u, 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 = `${l}px`, this.element.style.overflow = "auto";
    let f = -1;
    this.element.addEventListener("scroll", (h) => {
      const { pending: d, loaded: p } = this, { scrollHeight: y, scrollTop: g, clientHeight: m } = h.target, b = g < f;
      f = g, !(b || d || p) && y - g < 2 * m && (this.pending = !0, this.requestData(this.offset + this.limit));
    }), this.tbl = document.createElement("table"), this.element.appendChild(this.tbl), this.head = document.createElement("thead"), this.tbl.appendChild(this.head), this.body = document.createElement("tbody"), this.tbl.appendChild(this.body), this.style = document.createElement("style"), this.element.appendChild(this.style);
  }
  requestData(t = 0) {
    var i;
    this.offset = t;
    const n = this.query((i = this.filterBy) == null ? void 0 : i.predicate(this));
    this.requestQuery(n), pi().prefetch(n.clone().offset(t + this.limit));
  }
  fields() {
    return this.columns.map((t) => O1(this.from, t));
  }
  fieldInfo(t) {
    this.schema = t;
    const n = this.head;
    n.innerHTML = "";
    const i = document.createElement("tr");
    for (const { column: r } of t) {
      const s = document.createElement("th");
      s.addEventListener("click", (o) => this.sort(o, r)), s.appendChild(document.createElement("span")), s.appendChild(document.createTextNode(r)), i.appendChild(s);
    }
    return n.appendChild(i), this.formats = j5(this.format, t), this.style.innerText = W5(
      this.id,
      Y5(this.align, t),
      q5(this.widths, t)
    ), this;
  }
  query(t = []) {
    const { from: n, limit: i, offset: r, schema: s, sortColumn: o, sortDesc: a } = this;
    return Et.from(n).select(s.map((c) => c.column)).where(t).orderby(o ? a ? nE(o) : o : []).limit(i).offset(r);
  }
  queryResult(t) {
    return this.pending || (this.loaded = !1, this.body.replaceChildren()), this.data = t, this;
  }
  update() {
    const { body: t, formats: n, data: i, schema: r, limit: s } = this, o = r.length;
    let a = 0;
    for (const c of i) {
      ++a;
      const l = document.createElement("tr");
      for (let u = 0; u < o; ++u) {
        const f = c[r[u].column], h = document.createElement("td");
        h.innerText = f == null ? "" : n[u](f), l.appendChild(h);
      }
      t.appendChild(l);
    }
    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 i = t.currentTarget, r = this.sortHeader;
    r === i && t.metaKey ? (r.firstChild.textContent = "", this.sortHeader = null, this.sortColumn = null) : (r && (r.firstChild.textContent = ""), this.sortHeader = i, i.firstChild.textContent = this.sortDesc ? "▾" : "▴"), this.requestData();
  }
};
function j5(e = {}, t, n) {
  return t.map(({ column: i, type: r }) => {
    if (i in e)
      return e[i];
    switch (r) {
      case "number":
        return C1(n);
      case "date":
        return S3;
      default:
        return x3(n);
    }
  });
}
function Y5(e = {}, t) {
  return t.map(({ column: n, type: i }) => n in e ? e[n] : i === "number" ? "right" : "left");
}
function q5(e = {}, t) {
  return t.map(({ column: n }) => e[n]);
}
function W5(e, t, n) {
  const i = [];
  return t.forEach((r, s) => {
    const o = +n[s];
    if (r !== "left" || o) {
      const a = r !== "left" ? `text-align:${r};` : "", c = o ? `width:${o}px;max-width:${o}px;` : "";
      i.push(`#${e} tr>:nth-child(${s + 1}) {${a}${c}}`);
    }
  }), i.join(" ");
}
const U1 = Symbol("Fixed"), Yo = Symbol("Transient"), I3 = Symbol("Transform"), G5 = [
  "rectY-x",
  "rectX-y",
  "rect-x",
  "rect-y"
];
function X5(e, t) {
  return G5.includes(`${t}-${e}`);
}
function sv(e, t = { steps: 25 }) {
  const n = (i, r) => X5(r, i.type) ? {
    [`${r}1`]: w0(i, e, t),
    [`${r}2`]: w0(i, e, { ...t, offset: 1 })
  } : {
    [r]: w0(i, e, t)
  };
  return n[I3] = !0, n;
}
function w0(e, t, n) {
  return {
    column: t,
    label: t,
    get stats() {
      return ["min", "max"];
    },
    get columns() {
      return [t];
    },
    get basis() {
      return t;
    },
    toString() {
      const { min: i, max: r } = e.stats[t], s = H5(i, r, n), o = fe(t), a = s.min === 0 ? o : `(${o} - ${s.min})`, c = `${(s.max - s.min) / s.steps}::DOUBLE`, l = n.offset ? `${n.offset} + ` : "";
      return `${i} + ${c} * (${l}FLOOR(${a} / ${c})::INTEGER)`;
    }
  };
}
function H5(e, t, n) {
  let { steps: i = 25, minstep: r = 0, nice: s = !0 } = n;
  if (s !== !1) {
    const o = t - e, a = i, c = Math.LN10, l = Math.ceil(Math.log(a) / c);
    let u = Math.max(
      r,
      Math.pow(10, Math.round(Math.log(o) / c) - l)
    );
    for (; Math.ceil(o / u) > a; )
      u *= 10;
    const f = [5, 2];
    let h;
    for (let y = 0, g = f.length; y < g; ++y)
      h = u / f[y], h >= r && o / h <= a && (u = h);
    h = Math.log(u);
    const d = h >= 0 ? 0 : ~~(-h / c) + 1, p = Math.pow(10, -d - 1);
    h = Math.floor(e / u + p) * u, e = e < h ? h - u : h, t = Math.ceil(t / u) * u, i = Math.round((t - e) / u);
  }
  return { min: e, max: t, steps: i };
}
function Be(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Gu(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function z1(e) {
  let t, n, i;
  e.length !== 2 ? (t = Be, n = (a, c) => Be(e(a), c), i = (a, c) => e(a) - c) : (t = e === Be || e === Gu ? e : K5, n = e, i = e);
  function r(a, c, l = 0, u = a.length) {
    if (l < u) {
      if (t(c, c) !== 0)
        return u;
      do {
        const f = l + u >>> 1;
        n(a[f], c) < 0 ? l = f + 1 : u = f;
      } while (l < u);
    }
    return l;
  }
  function s(a, c, l = 0, u = a.length) {
    if (l < u) {
      if (t(c, c) !== 0)
        return u;
      do {
        const f = l + u >>> 1;
        n(a[f], c) <= 0 ? l = f + 1 : u = f;
      } while (l < u);
    }
    return l;
  }
  function o(a, c, l = 0, u = a.length) {
    const f = r(a, c, l, u - 1);
    return f > l && i(a[f - 1], c) > -i(a[f], c) ? f - 1 : f;
  }
  return { left: r, center: o, right: s };
}
function K5() {
  return 0;
}
function $3(e) {
  return e === null ? NaN : +e;
}
function* J5(e, t) {
  if (t === void 0)
    for (let n of e)
      n != null && (n = +n) >= n && (yield n);
  else {
    let n = -1;
    for (let i of e)
      (i = t(i, ++n, e)) != null && (i = +i) >= i && (yield i);
  }
}
const Z5 = z1(Be), Q5 = Z5.right;
z1($3).center;
const ny = Q5, A3 = M3(T3), tL = M3(eL);
function M3(e) {
  return function(t, n, i = n) {
    if (!((n = +n) >= 0))
      throw new RangeError("invalid rx");
    if (!((i = +i) >= 0))
      throw new RangeError("invalid ry");
    let { data: r, width: s, height: o } = t;
    if (!((s = Math.floor(s)) >= 0))
      throw new RangeError("invalid width");
    if (!((o = Math.floor(o !== void 0 ? o : r.length / s)) >= 0))
      throw new RangeError("invalid height");
    if (!s || !o || !n && !i)
      return t;
    const a = n && e(n), c = i && e(i), l = r.slice();
    return a && c ? (aa(a, l, r, s, o), aa(a, r, l, s, o), aa(a, l, r, s, o), ca(c, r, l, s, o), ca(c, l, r, s, o), ca(c, r, l, s, o)) : a ? (aa(a, r, l, s, o), aa(a, l, r, s, o), aa(a, r, l, s, o)) : c && (ca(c, r, l, s, o), ca(c, l, r, s, o), ca(c, r, l, s, o)), t;
  };
}
function aa(e, t, n, i, r) {
  for (let s = 0, o = i * r; s < o; )
    e(t, n, s, s += i, 1);
}
function ca(e, t, n, i, r) {
  for (let s = 0, o = i * r; s < i; ++s)
    e(t, n, s, s + o, i);
}
function eL(e) {
  const t = T3(e);
  return (n, i, r, s, o) => {
    r <<= 2, s <<= 2, o <<= 2, t(n, i, r + 0, s + 0, o), t(n, i, r + 1, s + 1, o), t(n, i, r + 2, s + 2, o), t(n, i, r + 3, s + 3, o);
  };
}
function T3(e) {
  const t = Math.floor(e);
  if (t === e)
    return nL(e);
  const n = e - t, i = 2 * e + 1;
  return (r, s, o, a, c) => {
    if (!((a -= c) >= o))
      return;
    let l = t * s[o];
    const u = c * t, f = u + c;
    for (let h = o, d = o + u; h < d; h += c)
      l += s[Math.min(a, h)];
    for (let h = o, d = a; h <= d; h += c)
      l += s[Math.min(a, h + u)], r[h] = (l + n * (s[Math.max(o, h - f)] + s[Math.min(a, h + f)])) / i, l -= s[Math.max(o, h - u)];
  };
}
function nL(e) {
  const t = 2 * e + 1;
  return (n, i, r, s, o) => {
    if (!((s -= o) >= r))
      return;
    let a = e * i[r];
    const c = o * e;
    for (let l = r, u = r + c; l < u; l += o)
      a += i[Math.min(s, l)];
    for (let l = r, u = s; l <= u; l += o)
      a += i[Math.min(s, l + c)], n[l] = a / t, a -= i[Math.max(r, l - c)];
  };
}
function iy(e, t) {
  let n = 0;
  if (t === void 0)
    for (let i of e)
      i != null && (i = +i) >= i && ++n;
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (r = +r) >= r && ++n;
  }
  return n;
}
function iL(e) {
  return e.length | 0;
}
function rL(e) {
  return !(e > 0);
}
function sL(e) {
  return typeof e != "object" || "length" in e ? e : Array.from(e);
}
function oL(e) {
  return (t) => e(...t);
}
function aL(...e) {
  const t = typeof e[e.length - 1] == "function" && oL(e.pop());
  e = e.map(sL);
  const n = e.map(iL), i = e.length - 1, r = new Array(i + 1).fill(0), s = [];
  if (i < 0 || n.some(rL))
    return s;
  for (; ; ) {
    s.push(r.map((a, c) => e[c][a]));
    let o = i;
    for (; ++r[o] === n[o]; ) {
      if (o === 0)
        return t ? s.map(t) : s;
      r[o--] = 0;
    }
  }
}
function cL(e, t) {
  var n = 0, i = 0;
  return Float64Array.from(e, t === void 0 ? (r) => n += +r || 0 : (r) => n += +t(r, i++, e) || 0);
}
function P1(e, t) {
  let n = 0, i, r = 0, s = 0;
  if (t === void 0)
    for (let o of e)
      o != null && (o = +o) >= o && (i = o - r, r += i / ++n, s += i * (o - r));
  else {
    let o = -1;
    for (let a of e)
      (a = t(a, ++o, e)) != null && (a = +a) >= a && (i = a - r, r += i / ++n, s += i * (a - r));
  }
  if (n > 1)
    return s / (n - 1);
}
function ry(e, t) {
  const n = P1(e, t);
  return n && Math.sqrt(n);
}
function He(e, t) {
  let n, i;
  if (t === void 0)
    for (const r of e)
      r != null && (n === void 0 ? r >= r && (n = i = r) : (n > r && (n = r), i < r && (i = r)));
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n === void 0 ? s >= s && (n = i = s) : (n > s && (n = s), i < s && (i = s)));
  }
  return [n, i];
}
class tr {
  constructor() {
    this._partials = new Float64Array(32), this._n = 0;
  }
  add(t) {
    const n = this._partials;
    let i = 0;
    for (let r = 0; r < this._n && r < 32; r++) {
      const s = n[r], o = t + s, a = Math.abs(t) < Math.abs(s) ? t - (o - s) : s - (o - t);
      a && (n[i++] = a), t = o;
    }
    return n[i] = t, this._n = i + 1, this;
  }
  valueOf() {
    const t = this._partials;
    let n = this._n, i, r, s, o = 0;
    if (n > 0) {
      for (o = t[--n]; n > 0 && (i = o, r = t[--n], o = i + r, s = r - (o - i), !s); )
        ;
      n > 0 && (s < 0 && t[n - 1] < 0 || s > 0 && t[n - 1] > 0) && (r = s * 2, i = o + r, r == i - o && (o = i));
    }
    return o;
  }
}
class qo extends Map {
  constructor(t, n = F3) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const [i, r] of t)
        this.set(i, r);
  }
  get(t) {
    return super.get(Pm(this, t));
  }
  has(t) {
    return super.has(Pm(this, t));
  }
  set(t, n) {
    return super.set(B3(this, t), n);
  }
  delete(t) {
    return super.delete(N3(this, t));
  }
}
class sy extends Set {
  constructor(t, n = F3) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const i of t)
        this.add(i);
  }
  has(t) {
    return super.has(Pm(this, t));
  }
  add(t) {
    return super.add(B3(this, t));
  }
  delete(t) {
    return super.delete(N3(this, t));
  }
}
function Pm({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : n;
}
function B3({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : (e.set(i, n), n);
}
function N3({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) && (n = e.get(i), e.delete(i)), n;
}
function F3(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function Vm(e) {
  return e;
}
function as(e, ...t) {
  return V1(e, Vm, Vm, t);
}
function Wa(e, t, ...n) {
  return V1(e, Vm, t, n);
}
function lL(e, t, ...n) {
  return V1(e, Array.from, t, n);
}
function V1(e, t, n, i) {
  return function r(s, o) {
    if (o >= i.length)
      return n(s);
    const a = new qo(), c = i[o++];
    let l = -1;
    for (const u of s) {
      const f = c(u, ++l, s), h = a.get(f);
      h ? h.push(u) : a.set(f, [u]);
    }
    for (const [u, f] of a)
      a.set(u, r(f, o));
    return t(a);
  }(e, 0);
}
function uL(e, t) {
  return Array.from(t, (n) => e[n]);
}
function cu(e, ...t) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  e = Array.from(e);
  let [n] = t;
  if (n && n.length !== 2 || t.length > 1) {
    const i = Uint32Array.from(e, (r, s) => s);
    return t.length > 1 ? (t = t.map((r) => e.map(r)), i.sort((r, s) => {
      for (const o of t) {
        const a = lu(o[r], o[s]);
        if (a)
          return a;
      }
    })) : (n = e.map(n), i.sort((r, s) => lu(n[r], n[s]))), uL(e, i);
  }
  return e.sort(j1(n));
}
function j1(e = Be) {
  if (e === Be)
    return lu;
  if (typeof e != "function")
    throw new TypeError("compare is not a function");
  return (t, n) => {
    const i = e(t, n);
    return i || i === 0 ? i : (e(n, n) === 0) - (e(t, t) === 0);
  };
}
function lu(e, t) {
  return (e == null || !(e >= e)) - (t == null || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0);
}
function Y1(e, t, n) {
  return (t.length !== 2 ? cu(Wa(e, t, n), ([i, r], [s, o]) => Be(r, o) || Be(i, s)) : cu(as(e, n), ([i, r], [s, o]) => t(r, o) || Be(i, s))).map(([i]) => i);
}
const fL = Math.sqrt(50), hL = Math.sqrt(10), dL = Math.sqrt(2);
function pd(e, t, n) {
  const i = (t - e) / Math.max(0, n), r = Math.floor(Math.log10(i)), s = i / Math.pow(10, r), o = s >= fL ? 10 : s >= hL ? 5 : s >= dL ? 2 : 1;
  let a, c, l;
  return r < 0 ? (l = Math.pow(10, -r) / o, a = Math.round(e * l), c = Math.round(t * l), a / l < e && ++a, c / l > t && --c, l = -l) : (l = Math.pow(10, r) * o, a = Math.round(e / l), c = Math.round(t / l), a * l < e && ++a, c * l > t && --c), c < a && 0.5 <= n && n < 2 ? pd(e, t, n * 2) : [a, c, l];
}
function Us(e, t, n) {
  if (t = +t, e = +e, n = +n, !(n > 0))
    return [];
  if (e === t)
    return [e];
  const i = t < e, [r, s, o] = i ? pd(t, e, n) : pd(e, t, n);
  if (!(s >= r))
    return [];
  const a = s - r + 1, c = new Array(a);
  if (i)
    if (o < 0)
      for (let l = 0; l < a; ++l)
        c[l] = (s - l) / -o;
    else
      for (let l = 0; l < a; ++l)
        c[l] = (s - l) * o;
  else if (o < 0)
    for (let l = 0; l < a; ++l)
      c[l] = (r + l) / -o;
  else
    for (let l = 0; l < a; ++l)
      c[l] = (r + l) * o;
  return c;
}
function uu(e, t, n) {
  return t = +t, e = +e, n = +n, pd(e, t, n)[2];
}
function jm(e, t, n) {
  t = +t, e = +e, n = +n;
  const i = t < e, r = i ? uu(t, e, n) : uu(e, t, n);
  return (i ? -1 : 1) * (r < 0 ? 1 / -r : r);
}
function D3(e, t, n) {
  let i;
  for (; ; ) {
    const r = uu(e, t, n);
    if (r === i || r === 0 || !isFinite(r))
      return [e, t];
    r > 0 ? (e = Math.floor(e / r) * r, t = Math.ceil(t / r) * r) : r < 0 && (e = Math.ceil(e * r) / r, t = Math.floor(t * r) / r), i = r;
  }
}
function q1(e) {
  return Math.max(1, Math.ceil(Math.log(iy(e)) / Math.LN2) + 1);
}
function Se(e, t) {
  let n;
  if (t === void 0)
    for (const i of e)
      i != null && (n < i || n === void 0 && i >= i) && (n = i);
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (n < r || n === void 0 && r >= r) && (n = r);
  }
  return n;
}
function pL(e, t) {
  let n, i = -1, r = -1;
  if (t === void 0)
    for (const s of e)
      ++r, s != null && (n < s || n === void 0 && s >= s) && (n = s, i = r);
  else
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n < s || n === void 0 && s >= s) && (n = s, i = r);
  return i;
}
function ze(e, t) {
  let n;
  if (t === void 0)
    for (const i of e)
      i != null && (n > i || n === void 0 && i >= i) && (n = i);
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (n > r || n === void 0 && r >= r) && (n = r);
  }
  return n;
}
function yL(e, t) {
  let n, i = -1, r = -1;
  if (t === void 0)
    for (const s of e)
      ++r, s != null && (n > s || n === void 0 && s >= s) && (n = s, i = r);
  else
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n > s || n === void 0 && s >= s) && (n = s, i = r);
  return i;
}
function O3(e, t, n = 0, i = 1 / 0, r) {
  if (t = Math.floor(t), n = Math.floor(Math.max(0, n)), i = Math.floor(Math.min(e.length - 1, i)), !(n <= t && t <= i))
    return e;
  for (r = r === void 0 ? lu : j1(r); i > n; ) {
    if (i - n > 600) {
      const c = i - n + 1, l = t - n + 1, u = Math.log(c), f = 0.5 * Math.exp(2 * u / 3), h = 0.5 * Math.sqrt(u * f * (c - f) / c) * (l - c / 2 < 0 ? -1 : 1), d = Math.max(n, Math.floor(t - l * f / c + h)), p = Math.min(i, Math.floor(t + (c - l) * f / c + h));
      O3(e, t, d, p, r);
    }
    const s = e[t];
    let o = n, a = i;
    for (fl(e, n, t), r(e[i], s) > 0 && fl(e, n, i); o < a; ) {
      for (fl(e, o, a), ++o, --a; r(e[o], s) < 0; )
        ++o;
      for (; r(e[a], s) > 0; )
        --a;
    }
    r(e[n], s) === 0 ? fl(e, n, a) : (++a, fl(e, a, i)), a <= t && (n = a + 1), t <= a && (i = a - 1);
  }
  return e;
}
function fl(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function W1(e, t = Be) {
  let n, i = !1;
  if (t.length === 1) {
    let r;
    for (const s of e) {
      const o = t(s);
      (i ? Be(o, r) > 0 : Be(o, o) === 0) && (n = s, r = o, i = !0);
    }
  } else
    for (const r of e)
      (i ? t(r, n) > 0 : t(r, r) === 0) && (n = r, i = !0);
  return n;
}
function zs(e, t, n) {
  if (e = Float64Array.from(J5(e, n)), !(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return ze(e);
    if (t >= 1)
      return Se(e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = Se(O3(e, s).subarray(0, s + 1)), a = ze(e.subarray(s + 1));
    return o + (a - o) * (r - s);
  }
}
function mL(e, t, n = $3) {
  if (!(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return +n(e[0], 0, e);
    if (t >= 1)
      return +n(e[i - 1], i - 1, e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = +n(e[s], s, e), a = +n(e[s + 1], s + 1, e);
    return o + (a - o) * (r - s);
  }
}
function gL(e, t, n) {
  const i = iy(e), r = zs(e, 0.75) - zs(e, 0.25);
  return i && r ? Math.ceil((n - t) / (2 * r * Math.pow(i, -1 / 3))) : 1;
}
function E3(e, t, n) {
  const i = iy(e), r = ry(e);
  return i && r ? Math.ceil((n - t) * Math.cbrt(i) / (3.49 * r)) : 1;
}
function G1(e, t) {
  let n = 0, i = 0;
  if (t === void 0)
    for (let r of e)
      r != null && (r = +r) >= r && (++n, i += r);
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (s = +s) >= s && (++n, i += s);
  }
  if (n)
    return i / n;
}
function fu(e, t) {
  return zs(e, 0.5, t);
}
function* bL(e) {
  for (const t of e)
    yield* t;
}
function L3(e) {
  return Array.from(bL(e));
}
function R3(e, t) {
  const n = new qo();
  if (t === void 0)
    for (let s of e)
      s != null && s >= s && n.set(s, (n.get(s) || 0) + 1);
  else {
    let s = -1;
    for (let o of e)
      (o = t(o, ++s, e)) != null && o >= o && n.set(o, (n.get(o) || 0) + 1);
  }
  let i, r = 0;
  for (const [s, o] of n)
    o > r && (r = o, i = s);
  return i;
}
function Bn(e, t, n) {
  e = +e, t = +t, n = (r = arguments.length) < 2 ? (t = e, e = 0, 1) : r < 3 ? 1 : +n;
  for (var i = -1, r = Math.max(0, Math.ceil((t - e) / n)) | 0, s = new Array(r); ++i < r; )
    s[i] = e + i * n;
  return s;
}
function C3(e, t = Be) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  let n = Array.from(e);
  const i = new Float64Array(n.length);
  t.length !== 2 && (n = n.map(t), t = Be);
  const r = (a, c) => t(n[a], n[c]);
  let s, o;
  return e = Uint32Array.from(n, (a, c) => c), e.sort(t === Be ? (a, c) => lu(n[a], n[c]) : j1(r)), e.forEach((a, c) => {
    const l = r(a, s === void 0 ? a : s);
    l >= 0 ? ((s === void 0 || l > 0) && (s = a, o = c), i[a] = o) : i[a] = NaN;
  }), i;
}
function _L(e, t = Be) {
  let n, i = !1;
  if (t.length === 1) {
    let r;
    for (const s of e) {
      const o = t(s);
      (i ? Be(o, r) < 0 : Be(o, o) === 0) && (n = s, r = o, i = !0);
    }
  } else
    for (const r of e)
      (i ? t(r, n) < 0 : t(r, r) === 0) && (n = r, i = !0);
  return n;
}
function or(e, t) {
  let n = 0;
  if (t === void 0)
    for (let i of e)
      (i = +i) && (n += i);
  else {
    let i = -1;
    for (let r of e)
      (r = +t(r, ++i, e)) && (n += r);
  }
  return n;
}
function yd(e) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  return Array.from(e).reverse();
}
function wL(e) {
  return e;
}
var v0 = 1, x0 = 2, Ym = 3, Ff = 4, ov = 1e-6;
function vL(e) {
  return "translate(" + e + ",0)";
}
function xL(e) {
  return "translate(0," + e + ")";
}
function SL(e) {
  return (t) => +e(t);
}
function IL(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (n) => +e(n) + t;
}
function $L() {
  return !this.__axis;
}
function AL(e, t) {
  var n = [], i = null, r = null, s = 6, o = 6, a = 3, c = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, l = e === v0 || e === Ff ? -1 : 1, u = e === Ff || e === x0 ? "x" : "y", f = e === v0 || e === Ym ? vL : xL;
  function h(d) {
    var p = i ?? (t.ticks ? t.ticks.apply(t, n) : t.domain()), y = r ?? (t.tickFormat ? t.tickFormat.apply(t, n) : wL), g = Math.max(s, 0) + a, m = t.range(), b = +m[0] + c, _ = +m[m.length - 1] + c, w = (t.bandwidth ? IL : SL)(t.copy(), c), v = d.selection ? d.selection() : d, x = v.selectAll(".domain").data([null]), I = v.selectAll(".tick").data(p, t).order(), T = I.exit(), D = I.enter().append("g").attr("class", "tick"), $ = I.select("line"), A = I.select("text");
    x = x.merge(x.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), I = I.merge(D), $ = $.merge(D.append("line").attr("stroke", "currentColor").attr(u + "2", l * s)), A = A.merge(D.append("text").attr("fill", "currentColor").attr(u, l * g).attr("dy", e === v0 ? "0em" : e === Ym ? "0.71em" : "0.32em")), d !== v && (x = x.transition(d), I = I.transition(d), $ = $.transition(d), A = A.transition(d), T = T.transition(d).attr("opacity", ov).attr("transform", function(F) {
      return isFinite(F = w(F)) ? f(F + c) : this.getAttribute("transform");
    }), D.attr("opacity", ov).attr("transform", function(F) {
      var E = this.parentNode.__axis;
      return f((E && isFinite(E = E(F)) ? E : w(F)) + c);
    })), T.remove(), x.attr("d", e === Ff || e === x0 ? o ? "M" + l * o + "," + b + "H" + c + "V" + _ + "H" + l * o : "M" + c + "," + b + "V" + _ : o ? "M" + b + "," + l * o + "V" + c + "H" + _ + "V" + l * o : "M" + b + "," + c + "H" + _), I.attr("opacity", 1).attr("transform", function(F) {
      return f(w(F) + c);
    }), $.attr(u + "2", l * s), A.attr(u, l * g).text(y), v.filter($L).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === x0 ? "start" : e === Ff ? "end" : "middle"), v.each(function() {
      this.__axis = w;
    });
  }
  return h.scale = function(d) {
    return arguments.length ? (t = d, h) : t;
  }, h.ticks = function() {
    return n = Array.from(arguments), h;
  }, h.tickArguments = function(d) {
    return arguments.length ? (n = d == null ? [] : Array.from(d), h) : n.slice();
  }, h.tickValues = function(d) {
    return arguments.length ? (i = d == null ? null : Array.from(d), h) : i && i.slice();
  }, h.tickFormat = function(d) {
    return arguments.length ? (r = d, h) : r;
  }, h.tickSize = function(d) {
    return arguments.length ? (s = o = +d, h) : s;
  }, h.tickSizeInner = function(d) {
    return arguments.length ? (s = +d, h) : s;
  }, h.tickSizeOuter = function(d) {
    return arguments.length ? (o = +d, h) : o;
  }, h.tickPadding = function(d) {
    return arguments.length ? (a = +d, h) : a;
  }, h.offset = function(d) {
    return arguments.length ? (c = +d, h) : c;
  }, h;
}
function ML(e) {
  return AL(Ym, e);
}
var TL = { value: () => {
} };
function oy() {
  for (var e = 0, t = arguments.length, n = {}, i; e < t; ++e) {
    if (!(i = arguments[e] + "") || i in n || /[\s.]/.test(i))
      throw new Error("illegal type: " + i);
    n[i] = [];
  }
  return new wh(n);
}
function wh(e) {
  this._ = e;
}
function BL(e, t) {
  return e.trim().split(/^|\s+/).map(function(n) {
    var i = "", r = n.indexOf(".");
    if (r >= 0 && (i = n.slice(r + 1), n = n.slice(0, r)), n && !t.hasOwnProperty(n))
      throw new Error("unknown type: " + n);
    return { type: n, name: i };
  });
}
wh.prototype = oy.prototype = {
  constructor: wh,
  on: function(e, t) {
    var n = this._, i = BL(e + "", n), r, s = -1, o = i.length;
    if (arguments.length < 2) {
      for (; ++s < o; )
        if ((r = (e = i[s]).type) && (r = NL(n[r], e.name)))
          return r;
      return;
    }
    if (t != null && typeof t != "function")
      throw new Error("invalid callback: " + t);
    for (; ++s < o; )
      if (r = (e = i[s]).type)
        n[r] = av(n[r], e.name, t);
      else if (t == null)
        for (r in n)
          n[r] = av(n[r], e.name, null);
    return this;
  },
  copy: function() {
    var e = {}, t = this._;
    for (var n in t)
      e[n] = t[n].slice();
    return new wh(e);
  },
  call: function(e, t) {
    if ((r = arguments.length - 2) > 0)
      for (var n = new Array(r), i = 0, r, s; i < r; ++i)
        n[i] = arguments[i + 2];
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (s = this._[e], i = 0, r = s.length; i < r; ++i)
      s[i].value.apply(t, n);
  },
  apply: function(e, t, n) {
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (var i = this._[e], r = 0, s = i.length; r < s; ++r)
      i[r].value.apply(t, n);
  }
};
function NL(e, t) {
  for (var n = 0, i = e.length, r; n < i; ++n)
    if ((r = e[n]).name === t)
      return r.value;
}
function av(e, t, n) {
  for (var i = 0, r = e.length; i < r; ++i)
    if (e[i].name === t) {
      e[i] = TL, e = e.slice(0, i).concat(e.slice(i + 1));
      break;
    }
  return n != null && e.push({ name: t, value: n }), e;
}
var qm = "http://www.w3.org/1999/xhtml";
const Wo = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: qm,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function ay(e) {
  var t = e += "", n = t.indexOf(":");
  return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), Wo.hasOwnProperty(t) ? { space: Wo[t], local: e } : e;
}
function FL(e) {
  return function() {
    var t = this.ownerDocument, n = this.namespaceURI;
    return n === qm && t.documentElement.namespaceURI === qm ? t.createElement(e) : t.createElementNS(n, e);
  };
}
function DL(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function cy(e) {
  var t = ay(e);
  return (t.local ? DL : FL)(t);
}
function OL() {
}
function X1(e) {
  return e == null ? OL : function() {
    return this.querySelector(e);
  };
}
function EL(e) {
  typeof e != "function" && (e = X1(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = new Array(o), c, l, u = 0; u < o; ++u)
      (c = s[u]) && (l = e.call(c, c.__data__, u, s)) && ("__data__" in c && (l.__data__ = c.__data__), a[u] = l);
  return new On(i, this._parents);
}
function LL(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function RL() {
  return [];
}
function k3(e) {
  return e == null ? RL : function() {
    return this.querySelectorAll(e);
  };
}
function CL(e) {
  return function() {
    return LL(e.apply(this, arguments));
  };
}
function kL(e) {
  typeof e == "function" ? e = CL(e) : e = k3(e);
  for (var t = this._groups, n = t.length, i = [], r = [], s = 0; s < n; ++s)
    for (var o = t[s], a = o.length, c, l = 0; l < a; ++l)
      (c = o[l]) && (i.push(e.call(c, c.__data__, l, o)), r.push(c));
  return new On(i, r);
}
function U3(e) {
  return function() {
    return this.matches(e);
  };
}
function z3(e) {
  return function(t) {
    return t.matches(e);
  };
}
var UL = Array.prototype.find;
function zL(e) {
  return function() {
    return UL.call(this.children, e);
  };
}
function PL() {
  return this.firstElementChild;
}
function VL(e) {
  return this.select(e == null ? PL : zL(typeof e == "function" ? e : z3(e)));
}
var jL = Array.prototype.filter;
function YL() {
  return Array.from(this.children);
}
function qL(e) {
  return function() {
    return jL.call(this.children, e);
  };
}
function WL(e) {
  return this.selectAll(e == null ? YL : qL(typeof e == "function" ? e : z3(e)));
}
function GL(e) {
  typeof e != "function" && (e = U3(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = [], c, l = 0; l < o; ++l)
      (c = s[l]) && e.call(c, c.__data__, l, s) && a.push(c);
  return new On(i, this._parents);
}
function P3(e) {
  return new Array(e.length);
}
function XL() {
  return new On(this._enter || this._groups.map(P3), this._parents);
}
function md(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
md.prototype = {
  constructor: md,
  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 HL(e) {
  return function() {
    return e;
  };
}
function KL(e, t, n, i, r, s) {
  for (var o = 0, a, c = t.length, l = s.length; o < l; ++o)
    (a = t[o]) ? (a.__data__ = s[o], i[o] = a) : n[o] = new md(e, s[o]);
  for (; o < c; ++o)
    (a = t[o]) && (r[o] = a);
}
function JL(e, t, n, i, r, s, o) {
  var a, c, l = /* @__PURE__ */ new Map(), u = t.length, f = s.length, h = new Array(u), d;
  for (a = 0; a < u; ++a)
    (c = t[a]) && (h[a] = d = o.call(c, c.__data__, a, t) + "", l.has(d) ? r[a] = c : l.set(d, c));
  for (a = 0; a < f; ++a)
    d = o.call(e, s[a], a, s) + "", (c = l.get(d)) ? (i[a] = c, c.__data__ = s[a], l.delete(d)) : n[a] = new md(e, s[a]);
  for (a = 0; a < u; ++a)
    (c = t[a]) && l.get(h[a]) === c && (r[a] = c);
}
function ZL(e) {
  return e.__data__;
}
function QL(e, t) {
  if (!arguments.length)
    return Array.from(this, ZL);
  var n = t ? JL : KL, i = this._parents, r = this._groups;
  typeof e != "function" && (e = HL(e));
  for (var s = r.length, o = new Array(s), a = new Array(s), c = new Array(s), l = 0; l < s; ++l) {
    var u = i[l], f = r[l], h = f.length, d = tR(e.call(u, u && u.__data__, l, i)), p = d.length, y = a[l] = new Array(p), g = o[l] = new Array(p), m = c[l] = new Array(h);
    n(u, f, y, g, m, d, t);
    for (var b = 0, _ = 0, w, v; b < p; ++b)
      if (w = y[b]) {
        for (b >= _ && (_ = b + 1); !(v = g[_]) && ++_ < p; )
          ;
        w._next = v || null;
      }
  }
  return o = new On(o, i), o._enter = a, o._exit = c, o;
}
function tR(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function eR() {
  return new On(this._exit || this._groups.map(P3), this._parents);
}
function nR(e, t, n) {
  var i = this.enter(), r = this, s = this.exit();
  return typeof e == "function" ? (i = e(i), i && (i = i.selection())) : i = i.append(e + ""), t != null && (r = t(r), r && (r = r.selection())), n == null ? s.remove() : n(s), i && r ? i.merge(r).order() : r;
}
function iR(e) {
  for (var t = e.selection ? e.selection() : e, n = this._groups, i = t._groups, r = n.length, s = i.length, o = Math.min(r, s), a = new Array(r), c = 0; c < o; ++c)
    for (var l = n[c], u = i[c], f = l.length, h = a[c] = new Array(f), d, p = 0; p < f; ++p)
      (d = l[p] || u[p]) && (h[p] = d);
  for (; c < r; ++c)
    a[c] = n[c];
  return new On(a, this._parents);
}
function rR() {
  for (var e = this._groups, t = -1, n = e.length; ++t < n; )
    for (var i = e[t], r = i.length - 1, s = i[r], o; --r >= 0; )
      (o = i[r]) && (s && o.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(o, s), s = o);
  return this;
}
function sR(e) {
  e || (e = oR);
  function t(f, h) {
    return f && h ? e(f.__data__, h.__data__) : !f - !h;
  }
  for (var n = this._groups, i = n.length, r = new Array(i), s = 0; s < i; ++s) {
    for (var o = n[s], a = o.length, c = r[s] = new Array(a), l, u = 0; u < a; ++u)
      (l = o[u]) && (c[u] = l);
    c.sort(t);
  }
  return new On(r, this._parents).order();
}
function oR(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function aR() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function cR() {
  return Array.from(this);
}
function lR() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var i = e[t], r = 0, s = i.length; r < s; ++r) {
      var o = i[r];
      if (o)
        return o;
    }
  return null;
}
function uR() {
  let e = 0;
  for (const t of this)
    ++e;
  return e;
}
function fR() {
  return !this.node();
}
function hR(e) {
  for (var t = this._groups, n = 0, i = t.length; n < i; ++n)
    for (var r = t[n], s = 0, o = r.length, a; s < o; ++s)
      (a = r[s]) && e.call(a, a.__data__, s, r);
  return this;
}
function dR(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function pR(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function yR(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function mR(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function gR(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
  };
}
function bR(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 _R(e, t) {
  var n = ay(e);
  if (arguments.length < 2) {
    var i = this.node();
    return n.local ? i.getAttributeNS(n.space, n.local) : i.getAttribute(n);
  }
  return this.each((t == null ? n.local ? pR : dR : typeof t == "function" ? n.local ? bR : gR : n.local ? mR : yR)(n, t));
}
function V3(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function wR(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function vR(e, t, n) {
  return function() {
    this.style.setProperty(e, t, n);
  };
}
function xR(e, t, n) {
  return function() {
    var i = t.apply(this, arguments);
    i == null ? this.style.removeProperty(e) : this.style.setProperty(e, i, n);
  };
}
function SR(e, t, n) {
  return arguments.length > 1 ? this.each((t == null ? wR : typeof t == "function" ? xR : vR)(e, t, n ?? "")) : bc(this.node(), e);
}
function bc(e, t) {
  return e.style.getPropertyValue(t) || V3(e).getComputedStyle(e, null).getPropertyValue(t);
}
function IR(e) {
  return function() {
    delete this[e];
  };
}
function $R(e, t) {
  return function() {
    this[e] = t;
  };
}
function AR(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? delete this[e] : this[e] = n;
  };
}
function MR(e, t) {
  return arguments.length > 1 ? this.each((t == null ? IR : typeof t == "function" ? AR : $R)(e, t)) : this.node()[e];
}
function j3(e) {
  return e.trim().split(/^|\s+/);
}
function H1(e) {
  return e.classList || new Y3(e);
}
function Y3(e) {
  this._node = e, this._names = j3(e.getAttribute("class") || "");
}
Y3.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 q3(e, t) {
  for (var n = H1(e), i = -1, r = t.length; ++i < r; )
    n.add(t[i]);
}
function W3(e, t) {
  for (var n = H1(e), i = -1, r = t.length; ++i < r; )
    n.remove(t[i]);
}
function TR(e) {
  return function() {
    q3(this, e);
  };
}
function BR(e) {
  return function() {
    W3(this, e);
  };
}
function NR(e, t) {
  return function() {
    (t.apply(this, arguments) ? q3 : W3)(this, e);
  };
}
function FR(e, t) {
  var n = j3(e + "");
  if (arguments.length < 2) {
    for (var i = H1(this.node()), r = -1, s = n.length; ++r < s; )
      if (!i.contains(n[r]))
        return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? NR : t ? TR : BR)(n, t));
}
function DR() {
  this.textContent = "";
}
function OR(e) {
  return function() {
    this.textContent = e;
  };
}
function ER(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function LR(e) {
  return arguments.length ? this.each(e == null ? DR : (typeof e == "function" ? ER : OR)(e)) : this.node().textContent;
}
function RR() {
  this.innerHTML = "";
}
function CR(e) {
  return function() {
    this.innerHTML = e;
  };
}
function kR(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function UR(e) {
  return arguments.length ? this.each(e == null ? RR : (typeof e == "function" ? kR : CR)(e)) : this.node().innerHTML;
}
function zR() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function PR() {
  return this.each(zR);
}
function VR() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function jR() {
  return this.each(VR);
}
function YR(e) {
  var t = typeof e == "function" ? e : cy(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function qR() {
  return null;
}
function WR(e, t) {
  var n = typeof e == "function" ? e : cy(e), i = t == null ? qR : typeof t == "function" ? t : X1(t);
  return this.select(function() {
    return this.insertBefore(n.apply(this, arguments), i.apply(this, arguments) || null);
  });
}
function GR() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function XR() {
  return this.each(GR);
}
function HR() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function KR() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function JR(e) {
  return this.select(e ? KR : HR);
}
function ZR(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function QR(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function t7(e) {
  return e.trim().split(/^|\s+/).map(function(t) {
    var n = "", i = t.indexOf(".");
    return i >= 0 && (n = t.slice(i + 1), t = t.slice(0, i)), { type: t, name: n };
  });
}
function e7(e) {
  return function() {
    var t = this.__on;
    if (t) {
      for (var n = 0, i = -1, r = t.length, s; n < r; ++n)
        s = t[n], (!e.type || s.type === e.type) && s.name === e.name ? this.removeEventListener(s.type, s.listener, s.options) : t[++i] = s;
      ++i ? t.length = i : delete this.__on;
    }
  };
}
function n7(e, t, n) {
  return function() {
    var i = this.__on, r, s = QR(t);
    if (i) {
      for (var o = 0, a = i.length; o < a; ++o)
        if ((r = i[o]).type === e.type && r.name === e.name) {
          this.removeEventListener(r.type, r.listener, r.options), this.addEventListener(r.type, r.listener = s, r.options = n), r.value = t;
          return;
        }
    }
    this.addEventListener(e.type, s, n), r = { type: e.type, name: e.name, value: t, listener: s, options: n }, i ? i.push(r) : this.__on = [r];
  };
}
function i7(e, t, n) {
  var i = t7(e + ""), r, s = i.length, o;
  if (arguments.length < 2) {
    var a = this.node().__on;
    if (a) {
      for (var c = 0, l = a.length, u; c < l; ++c)
        for (r = 0, u = a[c]; r < s; ++r)
          if ((o = i[r]).type === u.type && o.name === u.name)
            return u.value;
    }
    return;
  }
  for (a = t ? n7 : e7, r = 0; r < s; ++r)
    this.each(a(i[r], t, n));
  return this;
}
function G3(e, t, n) {
  var i = V3(e), r = i.CustomEvent;
  typeof r == "function" ? r = new r(t, n) : (r = i.document.createEvent("Event"), n ? (r.initEvent(t, n.bubbles, n.cancelable), r.detail = n.detail) : r.initEvent(t, !1, !1)), e.dispatchEvent(r);
}
function r7(e, t) {
  return function() {
    return G3(this, e, t);
  };
}
function s7(e, t) {
  return function() {
    return G3(this, e, t.apply(this, arguments));
  };
}
function o7(e, t) {
  return this.each((typeof t == "function" ? s7 : r7)(e, t));
}
function* a7() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var i = e[t], r = 0, s = i.length, o; r < s; ++r)
      (o = i[r]) && (yield o);
}
var X3 = [null];
function On(e, t) {
  this._groups = e, this._parents = t;
}
function Xu() {
  return new On([[document.documentElement]], X3);
}
function c7() {
  return this;
}
On.prototype = Xu.prototype = {
  constructor: On,
  select: EL,
  selectAll: kL,
  selectChild: VL,
  selectChildren: WL,
  filter: GL,
  data: QL,
  enter: XL,
  exit: eR,
  join: nR,
  merge: iR,
  selection: c7,
  order: rR,
  sort: sR,
  call: aR,
  nodes: cR,
  node: lR,
  size: uR,
  empty: fR,
  each: hR,
  attr: _R,
  style: SR,
  property: MR,
  classed: FR,
  text: LR,
  html: UR,
  raise: PR,
  lower: jR,
  append: YR,
  insert: WR,
  remove: XR,
  clone: JR,
  datum: ZR,
  on: i7,
  dispatch: o7,
  [Symbol.iterator]: a7
};
function re(e) {
  return typeof e == "string" ? new On([[document.querySelector(e)]], [document.documentElement]) : new On([[e]], X3);
}
function l7(e) {
  let t;
  for (; t = e.sourceEvent; )
    e = t;
  return e;
}
function ai(e, t) {
  if (e = l7(e), t === void 0 && (t = e.currentTarget), t) {
    var n = t.ownerSVGElement || t;
    if (n.createSVGPoint) {
      var i = n.createSVGPoint();
      return i.x = e.clientX, i.y = e.clientY, i = i.matrixTransform(t.getScreenCTM().inverse()), [i.x, i.y];
    }
    if (t.getBoundingClientRect) {
      var r = t.getBoundingClientRect();
      return [e.clientX - r.left - t.clientLeft, e.clientY - r.top - t.clientTop];
    }
  }
  return [e.pageX, e.pageY];
}
const Wm = { capture: !0, passive: !1 };
function Gm(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function H3(e) {
  var t = e.document.documentElement, n = re(e).on("dragstart.drag", Gm, Wm);
  "onselectstart" in t ? n.on("selectstart.drag", Gm, Wm) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function K3(e, t) {
  var n = e.document.documentElement, i = re(e).on("dragstart.drag", null);
  t && (i.on("click.drag", Gm, Wm), setTimeout(function() {
    i.on("click.drag", null);
  }, 0)), "onselectstart" in n ? i.on("selectstart.drag", null) : (n.style.MozUserSelect = n.__noselect, delete n.__noselect);
}
function Yc(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function Hu(e, t) {
  var n = Object.create(e.prototype);
  for (var i in t)
    n[i] = t[i];
  return n;
}
function Qs() {
}
var Go = 0.7, _c = 1 / Go, Ga = "\\s*([+-]?\\d+)\\s*", hu = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", er = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", u7 = /^#([0-9a-f]{3,8})$/, f7 = new RegExp(`^rgb\\(${Ga},${Ga},${Ga}\\)$`), h7 = new RegExp(`^rgb\\(${er},${er},${er}\\)$`), d7 = new RegExp(`^rgba\\(${Ga},${Ga},${Ga},${hu}\\)$`), p7 = new RegExp(`^rgba\\(${er},${er},${er},${hu}\\)$`), y7 = new RegExp(`^hsl\\(${hu},${er},${er}\\)$`), m7 = new RegExp(`^hsla\\(${hu},${er},${er},${hu}\\)$`), cv = {
  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
};
Yc(Qs, Zr, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: lv,
  // Deprecated! Use color.formatHex.
  formatHex: lv,
  formatHex8: g7,
  formatHsl: b7,
  formatRgb: uv,
  toString: uv
});
function lv() {
  return this.rgb().formatHex();
}
function g7() {
  return this.rgb().formatHex8();
}
function b7() {
  return J3(this).formatHsl();
}
function uv() {
  return this.rgb().formatRgb();
}
function Zr(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = u7.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? fv(t) : n === 3 ? new Ue(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? Df(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? Df(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 = f7.exec(e)) ? new Ue(t[1], t[2], t[3], 1) : (t = h7.exec(e)) ? new Ue(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = d7.exec(e)) ? Df(t[1], t[2], t[3], t[4]) : (t = p7.exec(e)) ? Df(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = y7.exec(e)) ? pv(t[1], t[2] / 100, t[3] / 100, 1) : (t = m7.exec(e)) ? pv(t[1], t[2] / 100, t[3] / 100, t[4]) : cv.hasOwnProperty(e) ? fv(cv[e]) : e === "transparent" ? new Ue(NaN, NaN, NaN, 0) : null;
}
function fv(e) {
  return new Ue(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function Df(e, t, n, i) {
  return i <= 0 && (e = t = n = NaN), new Ue(e, t, n, i);
}
function K1(e) {
  return e instanceof Qs || (e = Zr(e)), e ? (e = e.rgb(), new Ue(e.r, e.g, e.b, e.opacity)) : new Ue();
}
function ni(e, t, n, i) {
  return arguments.length === 1 ? K1(e) : new Ue(e, t, n, i ?? 1);
}
function Ue(e, t, n, i) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +i;
}
Yc(Ue, ni, Hu(Qs, {
  brighter(e) {
    return e = e == null ? _c : Math.pow(_c, e), new Ue(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Go : Math.pow(Go, e), new Ue(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new Ue(Uo(this.r), Uo(this.g), Uo(this.b), gd(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: hv,
  // Deprecated! Use color.formatHex.
  formatHex: hv,
  formatHex8: _7,
  formatRgb: dv,
  toString: dv
}));
function hv() {
  return `#${Bo(this.r)}${Bo(this.g)}${Bo(this.b)}`;
}
function _7() {
  return `#${Bo(this.r)}${Bo(this.g)}${Bo(this.b)}${Bo((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function dv() {
  const e = gd(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${Uo(this.r)}, ${Uo(this.g)}, ${Uo(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function gd(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function Uo(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function Bo(e) {
  return e = Uo(e), (e < 16 ? "0" : "") + e.toString(16);
}
function pv(e, t, n, i) {
  return i <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new fi(e, t, n, i);
}
function J3(e) {
  if (e instanceof fi)
    return new fi(e.h, e.s, e.l, e.opacity);
  if (e instanceof Qs || (e = Zr(e)), !e)
    return new fi();
  if (e instanceof fi)
    return e;
  e = e.rgb();
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = Math.min(t, n, i), s = Math.max(t, n, i), o = NaN, a = s - r, c = (s + r) / 2;
  return a ? (t === s ? o = (n - i) / a + (n < i) * 6 : n === s ? o = (i - t) / a + 2 : o = (t - n) / a + 4, a /= c < 0.5 ? s + r : 2 - s - r, o *= 60) : a = c > 0 && c < 1 ? 0 : o, new fi(o, a, c, e.opacity);
}
function Xm(e, t, n, i) {
  return arguments.length === 1 ? J3(e) : new fi(e, t, n, i ?? 1);
}
function fi(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
Yc(fi, Xm, Hu(Qs, {
  brighter(e) {
    return e = e == null ? _c : Math.pow(_c, e), new fi(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Go : Math.pow(Go, e), new fi(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, i = n + (n < 0.5 ? n : 1 - n) * t, r = 2 * n - i;
    return new Ue(
      S0(e >= 240 ? e - 240 : e + 120, r, i),
      S0(e, r, i),
      S0(e < 120 ? e + 240 : e - 120, r, i),
      this.opacity
    );
  },
  clamp() {
    return new fi(yv(this.h), Of(this.s), Of(this.l), gd(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 = gd(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${yv(this.h)}, ${Of(this.s) * 100}%, ${Of(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function yv(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function Of(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function S0(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 Z3 = Math.PI / 180, Q3 = 180 / Math.PI, bd = 18, t$ = 0.96422, e$ = 1, n$ = 0.82521, i$ = 4 / 29, Xa = 6 / 29, r$ = 3 * Xa * Xa, w7 = Xa * Xa * Xa;
function s$(e) {
  if (e instanceof nr)
    return new nr(e.l, e.a, e.b, e.opacity);
  if (e instanceof Ur)
    return o$(e);
  e instanceof Ue || (e = K1(e));
  var t = M0(e.r), n = M0(e.g), i = M0(e.b), r = I0((0.2225045 * t + 0.7168786 * n + 0.0606169 * i) / e$), s, o;
  return t === n && n === i ? s = o = r : (s = I0((0.4360747 * t + 0.3850649 * n + 0.1430804 * i) / t$), o = I0((0.0139322 * t + 0.0971045 * n + 0.7141733 * i) / n$)), new nr(116 * r - 16, 500 * (s - r), 200 * (r - o), e.opacity);
}
function Hm(e, t, n, i) {
  return arguments.length === 1 ? s$(e) : new nr(e, t, n, i ?? 1);
}
function nr(e, t, n, i) {
  this.l = +e, this.a = +t, this.b = +n, this.opacity = +i;
}
Yc(nr, Hm, Hu(Qs, {
  brighter(e) {
    return new nr(this.l + bd * (e ?? 1), this.a, this.b, this.opacity);
  },
  darker(e) {
    return new nr(this.l - bd * (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 = t$ * $0(t), e = e$ * $0(e), n = n$ * $0(n), new Ue(
      A0(3.1338561 * t - 1.6168667 * e - 0.4906146 * n),
      A0(-0.9787684 * t + 1.9161415 * e + 0.033454 * n),
      A0(0.0719453 * t - 0.2289914 * e + 1.4052427 * n),
      this.opacity
    );
  }
}));
function I0(e) {
  return e > w7 ? Math.pow(e, 1 / 3) : e / r$ + i$;
}
function $0(e) {
  return e > Xa ? e * e * e : r$ * (e - i$);
}
function A0(e) {
  return 255 * (e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055);
}
function M0(e) {
  return (e /= 255) <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function v7(e) {
  if (e instanceof Ur)
    return new Ur(e.h, e.c, e.l, e.opacity);
  if (e instanceof nr || (e = s$(e)), e.a === 0 && e.b === 0)
    return new Ur(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
  var t = Math.atan2(e.b, e.a) * Q3;
  return new Ur(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function Km(e, t, n, i) {
  return arguments.length === 1 ? v7(e) : new Ur(e, t, n, i ?? 1);
}
function Ur(e, t, n, i) {
  this.h = +e, this.c = +t, this.l = +n, this.opacity = +i;
}
function o$(e) {
  if (isNaN(e.h))
    return new nr(e.l, 0, 0, e.opacity);
  var t = e.h * Z3;
  return new nr(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
Yc(Ur, Km, Hu(Qs, {
  brighter(e) {
    return new Ur(this.h, this.c, this.l + bd * (e ?? 1), this.opacity);
  },
  darker(e) {
    return new Ur(this.h, this.c, this.l - bd * (e ?? 1), this.opacity);
  },
  rgb() {
    return o$(this).rgb();
  }
}));
var a$ = -0.14861, J1 = 1.78277, Z1 = -0.29227, ly = -0.90649, du = 1.97294, mv = du * ly, gv = du * J1, bv = J1 * Z1 - ly * a$;
function x7(e) {
  if (e instanceof zo)
    return new zo(e.h, e.s, e.l, e.opacity);
  e instanceof Ue || (e = K1(e));
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = (bv * i + mv * t - gv * n) / (bv + mv - gv), s = i - r, o = (du * (n - r) - Z1 * s) / ly, a = Math.sqrt(o * o + s * s) / (du * r * (1 - r)), c = a ? Math.atan2(o, s) * Q3 - 120 : NaN;
  return new zo(c < 0 ? c + 360 : c, a, r, e.opacity);
}
function ar(e, t, n, i) {
  return arguments.length === 1 ? x7(e) : new zo(e, t, n, i ?? 1);
}
function zo(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
Yc(zo, ar, Hu(Qs, {
  brighter(e) {
    return e = e == null ? _c : Math.pow(_c, e), new zo(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Go : Math.pow(Go, e), new zo(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = isNaN(this.h) ? 0 : (this.h + 120) * Z3, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), i = Math.cos(e), r = Math.sin(e);
    return new Ue(
      255 * (t + n * (a$ * i + J1 * r)),
      255 * (t + n * (Z1 * i + ly * r)),
      255 * (t + n * (du * i)),
      this.opacity
    );
  }
}));
function S7(e, t, n, i, r) {
  var s = e * e, o = s * e;
  return ((1 - 3 * e + 3 * s - o) * t + (4 - 6 * s + 3 * o) * n + (1 + 3 * e + 3 * s - 3 * o) * i + o * r) / 6;
}
function I7(e) {
  var t = e.length - 1;
  return function(n) {
    var i = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), r = e[i], s = e[i + 1], o = i > 0 ? e[i - 1] : 2 * r - s, a = i < t - 1 ? e[i + 2] : 2 * s - r;
    return S7((n - i / t) * t, o, r, s, a);
  };
}
const uy = (e) => () => e;
function c$(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function $7(e, t, n) {
  return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function(i) {
    return Math.pow(e + i * t, n);
  };
}
function Q1(e, t) {
  var n = t - e;
  return n ? c$(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : uy(isNaN(e) ? t : e);
}
function A7(e) {
  return (e = +e) == 1 ? Ke : function(t, n) {
    return n - t ? $7(t, n, e) : uy(isNaN(t) ? n : t);
  };
}
function Ke(e, t) {
  var n = t - e;
  return n ? c$(e, n) : uy(isNaN(e) ? t : e);
}
const Xo = function e(t) {
  var n = A7(t);
  function i(r, s) {
    var o = n((r = ni(r)).r, (s = ni(s)).r), a = n(r.g, s.g), c = n(r.b, s.b), l = Ke(r.opacity, s.opacity);
    return function(u) {
      return r.r = o(u), r.g = a(u), r.b = c(u), r.opacity = l(u), r + "";
    };
  }
  return i.gamma = e, i;
}(1);
function M7(e) {
  return function(t) {
    var n = t.length, i = new Array(n), r = new Array(n), s = new Array(n), o, a;
    for (o = 0; o < n; ++o)
      a = ni(t[o]), i[o] = a.r || 0, r[o] = a.g || 0, s[o] = a.b || 0;
    return i = e(i), r = e(r), s = e(s), a.opacity = 1, function(c) {
      return a.r = i(c), a.g = r(c), a.b = s(c), a + "";
    };
  };
}
var T7 = M7(I7);
function B7(e, t) {
  t || (t = []);
  var n = e ? Math.min(t.length, e.length) : 0, i = t.slice(), r;
  return function(s) {
    for (r = 0; r < n; ++r)
      i[r] = e[r] * (1 - s) + t[r] * s;
    return i;
  };
}
function N7(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function F7(e, t) {
  var n = t ? t.length : 0, i = e ? Math.min(n, e.length) : 0, r = new Array(i), s = new Array(n), o;
  for (o = 0; o < i; ++o)
    r[o] = qc(e[o], t[o]);
  for (; o < n; ++o)
    s[o] = t[o];
  return function(a) {
    for (o = 0; o < i; ++o)
      s[o] = r[o](a);
    return s;
  };
}
function D7(e, t) {
  var n = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(i) {
    return n.setTime(e * (1 - i) + t * i), n;
  };
}
function Xe(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function O7(e, t) {
  var n = {}, i = {}, r;
  (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
  for (r in t)
    r in e ? n[r] = qc(e[r], t[r]) : i[r] = t[r];
  return function(s) {
    for (r in n)
      i[r] = n[r](s);
    return i;
  };
}
var Jm = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, T0 = new RegExp(Jm.source, "g");
function E7(e) {
  return function() {
    return e;
  };
}
function L7(e) {
  return function(t) {
    return e(t) + "";
  };
}
function l$(e, t) {
  var n = Jm.lastIndex = T0.lastIndex = 0, i, r, s, o = -1, a = [], c = [];
  for (e = e + "", t = t + ""; (i = Jm.exec(e)) && (r = T0.exec(t)); )
    (s = r.index) > n && (s = t.slice(n, s), a[o] ? a[o] += s : a[++o] = s), (i = i[0]) === (r = r[0]) ? a[o] ? a[o] += r : a[++o] = r : (a[++o] = null, c.push({ i: o, x: Xe(i, r) })), n = T0.lastIndex;
  return n < t.length && (s = t.slice(n), a[o] ? a[o] += s : a[++o] = s), a.length < 2 ? c[0] ? L7(c[0].x) : E7(t) : (t = c.length, function(l) {
    for (var u = 0, f; u < t; ++u)
      a[(f = c[u]).i] = f.x(l);
    return a.join("");
  });
}
function qc(e, t) {
  var n = typeof t, i;
  return t == null || n === "boolean" ? uy(t) : (n === "number" ? Xe : n === "string" ? (i = Zr(t)) ? (t = i, Xo) : l$ : t instanceof Zr ? Xo : t instanceof Date ? D7 : N7(t) ? B7 : Array.isArray(t) ? F7 : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? O7 : Xe)(e, t);
}
function tb(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
var _v = 180 / Math.PI, Zm = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function u$(e, t, n, i, r, s) {
  var o, a, c;
  return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (c = e * n + t * i) && (n -= e * c, i -= t * c), (a = Math.sqrt(n * n + i * i)) && (n /= a, i /= a, c /= a), e * i < t * n && (e = -e, t = -t, c = -c, o = -o), {
    translateX: r,
    translateY: s,
    rotate: Math.atan2(t, e) * _v,
    skewX: Math.atan(c) * _v,
    scaleX: o,
    scaleY: a
  };
}
var Ef;
function R7(e) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
  return t.isIdentity ? Zm : u$(t.a, t.b, t.c, t.d, t.e, t.f);
}
function C7(e) {
  return e == null || (Ef || (Ef = document.createElementNS("http://www.w3.org/2000/svg", "g")), Ef.setAttribute("transform", e), !(e = Ef.transform.baseVal.consolidate())) ? Zm : (e = e.matrix, u$(e.a, e.b, e.c, e.d, e.e, e.f));
}
function f$(e, t, n, i) {
  function r(l) {
    return l.length ? l.pop() + " " : "";
  }
  function s(l, u, f, h, d, p) {
    if (l !== f || u !== h) {
      var y = d.push("translate(", null, t, null, n);
      p.push({ i: y - 4, x: Xe(l, f) }, { i: y - 2, x: Xe(u, h) });
    } else
      (f || h) && d.push("translate(" + f + t + h + n);
  }
  function o(l, u, f, h) {
    l !== u ? (l - u > 180 ? u += 360 : u - l > 180 && (l += 360), h.push({ i: f.push(r(f) + "rotate(", null, i) - 2, x: Xe(l, u) })) : u && f.push(r(f) + "rotate(" + u + i);
  }
  function a(l, u, f, h) {
    l !== u ? h.push({ i: f.push(r(f) + "skewX(", null, i) - 2, x: Xe(l, u) }) : u && f.push(r(f) + "skewX(" + u + i);
  }
  function c(l, u, f, h, d, p) {
    if (l !== f || u !== h) {
      var y = d.push(r(d) + "scale(", null, ",", null, ")");
      p.push({ i: y - 4, x: Xe(l, f) }, { i: y - 2, x: Xe(u, h) });
    } else
      (f !== 1 || h !== 1) && d.push(r(d) + "scale(" + f + "," + h + ")");
  }
  return function(l, u) {
    var f = [], h = [];
    return l = e(l), u = e(u), s(l.translateX, l.translateY, u.translateX, u.translateY, f, h), o(l.rotate, u.rotate, f, h), a(l.skewX, u.skewX, f, h), c(l.scaleX, l.scaleY, u.scaleX, u.scaleY, f, h), l = u = null, function(d) {
      for (var p = -1, y = h.length, g; ++p < y; )
        f[(g = h[p]).i] = g.x(d);
      return f.join("");
    };
  };
}
var k7 = f$(R7, "px, ", "px)", "deg)"), U7 = f$(C7, ", ", ")", ")"), z7 = 1e-12;
function wv(e) {
  return ((e = Math.exp(e)) + 1 / e) / 2;
}
function P7(e) {
  return ((e = Math.exp(e)) - 1 / e) / 2;
}
function V7(e) {
  return ((e = Math.exp(2 * e)) - 1) / (e + 1);
}
const j7 = function e(t, n, i) {
  function r(s, o) {
    var a = s[0], c = s[1], l = s[2], u = o[0], f = o[1], h = o[2], d = u - a, p = f - c, y = d * d + p * p, g, m;
    if (y < z7)
      m = Math.log(h / l) / t, g = function(I) {
        return [
          a + I * d,
          c + I * p,
          l * Math.exp(t * I * m)
        ];
      };
    else {
      var b = Math.sqrt(y), _ = (h * h - l * l + i * y) / (2 * l * n * b), w = (h * h - l * l - i * y) / (2 * h * n * b), v = Math.log(Math.sqrt(_ * _ + 1) - _), x = Math.log(Math.sqrt(w * w + 1) - w);
      m = (x - v) / t, g = function(I) {
        var T = I * m, D = wv(v), $ = l / (n * b) * (D * V7(t * T + v) - P7(v));
        return [
          a + $ * d,
          c + $ * p,
          l * D / wv(t * T + v)
        ];
      };
    }
    return g.duration = m * 1e3 * t / Math.SQRT2, g;
  }
  return r.rho = function(s) {
    var o = Math.max(1e-3, +s), a = o * o, c = a * a;
    return e(o, a, c);
  }, r;
}(Math.SQRT2, 2, 4);
function Y7(e) {
  return function(t, n) {
    var i = e((t = Xm(t)).h, (n = Xm(n)).h), r = Ke(t.s, n.s), s = Ke(t.l, n.l), o = Ke(t.opacity, n.opacity);
    return function(a) {
      return t.h = i(a), t.s = r(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const q7 = Y7(Q1);
function W7(e, t) {
  var n = Ke((e = Hm(e)).l, (t = Hm(t)).l), i = Ke(e.a, t.a), r = Ke(e.b, t.b), s = Ke(e.opacity, t.opacity);
  return function(o) {
    return e.l = n(o), e.a = i(o), e.b = r(o), e.opacity = s(o), e + "";
  };
}
function G7(e) {
  return function(t, n) {
    var i = e((t = Km(t)).h, (n = Km(n)).h), r = Ke(t.c, n.c), s = Ke(t.l, n.l), o = Ke(t.opacity, n.opacity);
    return function(a) {
      return t.h = i(a), t.c = r(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const X7 = G7(Q1);
function h$(e) {
  return function t(n) {
    n = +n;
    function i(r, s) {
      var o = e((r = ar(r)).h, (s = ar(s)).h), a = Ke(r.s, s.s), c = Ke(r.l, s.l), l = Ke(r.opacity, s.opacity);
      return function(u) {
        return r.h = o(u), r.s = a(u), r.l = c(Math.pow(u, n)), r.opacity = l(u), r + "";
      };
    }
    return i.gamma = t, i;
  }(1);
}
h$(Q1);
var eb = h$(Ke);
function nb(e, t) {
  t === void 0 && (t = e, e = qc);
  for (var n = 0, i = t.length - 1, r = t[0], s = new Array(i < 0 ? 0 : i); n < i; )
    s[n] = e(r, r = t[++n]);
  return function(o) {
    var a = Math.max(0, Math.min(i - 1, Math.floor(o *= i)));
    return s[a](o - a);
  };
}
function wi(e, t) {
  for (var n = new Array(t), i = 0; i < t; ++i)
    n[i] = e(i / (t - 1));
  return n;
}
var wc = 0, Dl = 0, hl = 0, d$ = 1e3, _d, Ol, wd = 0, Ho = 0, fy = 0, pu = typeof performance == "object" && performance.now ? performance : Date, p$ = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
  setTimeout(e, 17);
};
function ib() {
  return Ho || (p$(H7), Ho = pu.now() + fy);
}
function H7() {
  Ho = 0;
}
function vd() {
  this._call = this._time = this._next = null;
}
vd.prototype = y$.prototype = {
  constructor: vd,
  restart: function(e, t, n) {
    if (typeof e != "function")
      throw new TypeError("callback is not a function");
    n = (n == null ? ib() : +n) + (t == null ? 0 : +t), !this._next && Ol !== this && (Ol ? Ol._next = this : _d = this, Ol = this), this._call = e, this._time = n, Qm();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, Qm());
  }
};
function y$(e, t, n) {
  var i = new vd();
  return i.restart(e, t, n), i;
}
function K7() {
  ib(), ++wc;
  for (var e = _d, t; e; )
    (t = Ho - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
  --wc;
}
function vv() {
  Ho = (wd = pu.now()) + fy, wc = Dl = 0;
  try {
    K7();
  } finally {
    wc = 0, Z7(), Ho = 0;
  }
}
function J7() {
  var e = pu.now(), t = e - wd;
  t > d$ && (fy -= t, wd = e);
}
function Z7() {
  for (var e, t = _d, n, i = 1 / 0; t; )
    t._call ? (i > t._time && (i = t._time), e = t, t = t._next) : (n = t._next, t._next = null, t = e ? e._next = n : _d = n);
  Ol = e, Qm(i);
}
function Qm(e) {
  if (!wc) {
    Dl && (Dl = clearTimeout(Dl));
    var t = e - Ho;
    t > 24 ? (e < 1 / 0 && (Dl = setTimeout(vv, e - pu.now() - fy)), hl && (hl = clearInterval(hl))) : (hl || (wd = pu.now(), hl = setInterval(J7, d$)), wc = 1, p$(vv));
  }
}
function xv(e, t, n) {
  var i = new vd();
  return t = t == null ? 0 : +t, i.restart((r) => {
    i.stop(), e(r + t);
  }, t, n), i;
}
var Q7 = oy("start", "end", "cancel", "interrupt"), tC = [], m$ = 0, Sv = 1, tg = 2, vh = 3, Iv = 4, eg = 5, xh = 6;
function hy(e, t, n, i, r, s) {
  var o = e.__transition;
  if (!o)
    e.__transition = {};
  else if (n in o)
    return;
  eC(e, n, {
    name: t,
    index: i,
    // For context during callback.
    group: r,
    // For context during callback.
    on: Q7,
    tween: tC,
    time: s.time,
    delay: s.delay,
    duration: s.duration,
    ease: s.ease,
    timer: null,
    state: m$
  });
}
function rb(e, t) {
  var n = Ni(e, t);
  if (n.state > m$)
    throw new Error("too late; already scheduled");
  return n;
}
function fr(e, t) {
  var n = Ni(e, t);
  if (n.state > vh)
    throw new Error("too late; already running");
  return n;
}
function Ni(e, t) {
  var n = e.__transition;
  if (!n || !(n = n[t]))
    throw new Error("transition not found");
  return n;
}
function eC(e, t, n) {
  var i = e.__transition, r;
  i[t] = n, n.timer = y$(s, 0, n.time);
  function s(l) {
    n.state = Sv, n.timer.restart(o, n.delay, n.time), n.delay <= l && o(l - n.delay);
  }
  function o(l) {
    var u, f, h, d;
    if (n.state !== Sv)
      return c();
    for (u in i)
      if (d = i[u], d.name === n.name) {
        if (d.state === vh)
          return xv(o);
        d.state === Iv ? (d.state = xh, d.timer.stop(), d.on.call("interrupt", e, e.__data__, d.index, d.group), delete i[u]) : +u < t && (d.state = xh, d.timer.stop(), d.on.call("cancel", e, e.__data__, d.index, d.group), delete i[u]);
      }
    if (xv(function() {
      n.state === vh && (n.state = Iv, n.timer.restart(a, n.delay, n.time), a(l));
    }), n.state = tg, n.on.call("start", e, e.__data__, n.index, n.group), n.state === tg) {
      for (n.state = vh, r = new Array(h = n.tween.length), u = 0, f = -1; u < h; ++u)
        (d = n.tween[u].value.call(e, e.__data__, n.index, n.group)) && (r[++f] = d);
      r.length = f + 1;
    }
  }
  function a(l) {
    for (var u = l < n.duration ? n.ease.call(null, l / n.duration) : (n.timer.restart(c), n.state = eg, 1), f = -1, h = r.length; ++f < h; )
      r[f].call(e, u);
    n.state === eg && (n.on.call("end", e, e.__data__, n.index, n.group), c());
  }
  function c() {
    n.state = xh, n.timer.stop(), delete i[t];
    for (var l in i)
      return;
    delete e.__transition;
  }
}
function Ha(e, t) {
  var n = e.__transition, i, r, s = !0, o;
  if (n) {
    t = t == null ? null : t + "";
    for (o in n) {
      if ((i = n[o]).name !== t) {
        s = !1;
        continue;
      }
      r = i.state > tg && i.state < eg, i.state = xh, i.timer.stop(), i.on.call(r ? "interrupt" : "cancel", e, e.__data__, i.index, i.group), delete n[o];
    }
    s && delete e.__transition;
  }
}
function nC(e) {
  return this.each(function() {
    Ha(this, e);
  });
}
function iC(e, t) {
  var n, i;
  return function() {
    var r = fr(this, e), s = r.tween;
    if (s !== n) {
      i = n = s;
      for (var o = 0, a = i.length; o < a; ++o)
        if (i[o].name === t) {
          i = i.slice(), i.splice(o, 1);
          break;
        }
    }
    r.tween = i;
  };
}
function rC(e, t, n) {
  var i, r;
  if (typeof n != "function")
    throw new Error();
  return function() {
    var s = fr(this, e), o = s.tween;
    if (o !== i) {
      r = (i = o).slice();
      for (var a = { name: t, value: n }, c = 0, l = r.length; c < l; ++c)
        if (r[c].name === t) {
          r[c] = a;
          break;
        }
      c === l && r.push(a);
    }
    s.tween = r;
  };
}
function sC(e, t) {
  var n = this._id;
  if (e += "", arguments.length < 2) {
    for (var i = Ni(this.node(), n).tween, r = 0, s = i.length, o; r < s; ++r)
      if ((o = i[r]).name === e)
        return o.value;
    return null;
  }
  return this.each((t == null ? iC : rC)(n, e, t));
}
function sb(e, t, n) {
  var i = e._id;
  return e.each(function() {
    var r = fr(this, i);
    (r.value || (r.value = {}))[t] = n.apply(this, arguments);
  }), function(r) {
    return Ni(r, i).value[t];
  };
}
function g$(e, t) {
  var n;
  return (typeof t == "number" ? Xe : t instanceof Zr ? Xo : (n = Zr(t)) ? (t = n, Xo) : l$)(e, t);
}
function oC(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function aC(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function cC(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = this.getAttribute(e);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function lC(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = this.getAttributeNS(e.space, e.local);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function uC(e, t, n) {
  var i, r, s;
  return function() {
    var o, a = n(this), c;
    return a == null ? void this.removeAttribute(e) : (o = this.getAttribute(e), c = a + "", o === c ? null : o === i && c === r ? s : (r = c, s = t(i = o, a)));
  };
}
function fC(e, t, n) {
  var i, r, s;
  return function() {
    var o, a = n(this), c;
    return a == null ? void this.removeAttributeNS(e.space, e.local) : (o = this.getAttributeNS(e.space, e.local), c = a + "", o === c ? null : o === i && c === r ? s : (r = c, s = t(i = o, a)));
  };
}
function hC(e, t) {
  var n = ay(e), i = n === "transform" ? U7 : g$;
  return this.attrTween(e, typeof t == "function" ? (n.local ? fC : uC)(n, i, sb(this, "attr." + e, t)) : t == null ? (n.local ? aC : oC)(n) : (n.local ? lC : cC)(n, i, t));
}
function dC(e, t) {
  return function(n) {
    this.setAttribute(e, t.call(this, n));
  };
}
function pC(e, t) {
  return function(n) {
    this.setAttributeNS(e.space, e.local, t.call(this, n));
  };
}
function yC(e, t) {
  var n, i;
  function r() {
    var s = t.apply(this, arguments);
    return s !== i && (n = (i = s) && pC(e, s)), n;
  }
  return r._value = t, r;
}
function mC(e, t) {
  var n, i;
  function r() {
    var s = t.apply(this, arguments);
    return s !== i && (n = (i = s) && dC(e, s)), n;
  }
  return r._value = t, r;
}
function gC(e, t) {
  var n = "attr." + e;
  if (arguments.length < 2)
    return (n = this.tween(n)) && n._value;
  if (t == null)
    return this.tween(n, null);
  if (typeof t != "function")
    throw new Error();
  var i = ay(e);
  return this.tween(n, (i.local ? yC : mC)(i, t));
}
function bC(e, t) {
  return function() {
    rb(this, e).delay = +t.apply(this, arguments);
  };
}
function _C(e, t) {
  return t = +t, function() {
    rb(this, e).delay = t;
  };
}
function wC(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? bC : _C)(t, e)) : Ni(this.node(), t).delay;
}
function vC(e, t) {
  return function() {
    fr(this, e).duration = +t.apply(this, arguments);
  };
}
function xC(e, t) {
  return t = +t, function() {
    fr(this, e).duration = t;
  };
}
function SC(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? vC : xC)(t, e)) : Ni(this.node(), t).duration;
}
function IC(e, t) {
  if (typeof t != "function")
    throw new Error();
  return function() {
    fr(this, e).ease = t;
  };
}
function $C(e) {
  var t = this._id;
  return arguments.length ? this.each(IC(t, e)) : Ni(this.node(), t).ease;
}
function AC(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    if (typeof n != "function")
      throw new Error();
    fr(this, e).ease = n;
  };
}
function MC(e) {
  if (typeof e != "function")
    throw new Error();
  return this.each(AC(this._id, e));
}
function TC(e) {
  typeof e != "function" && (e = U3(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = [], c, l = 0; l < o; ++l)
      (c = s[l]) && e.call(c, c.__data__, l, s) && a.push(c);
  return new Qr(i, this._parents, this._name, this._id);
}
function BC(e) {
  if (e._id !== this._id)
    throw new Error();
  for (var t = this._groups, n = e._groups, i = t.length, r = n.length, s = Math.min(i, r), o = new Array(i), a = 0; a < s; ++a)
    for (var c = t[a], l = n[a], u = c.length, f = o[a] = new Array(u), h, d = 0; d < u; ++d)
      (h = c[d] || l[d]) && (f[d] = h);
  for (; a < i; ++a)
    o[a] = t[a];
  return new Qr(o, this._parents, this._name, this._id);
}
function NC(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 FC(e, t, n) {
  var i, r, s = NC(t) ? rb : fr;
  return function() {
    var o = s(this, e), a = o.on;
    a !== i && (r = (i = a).copy()).on(t, n), o.on = r;
  };
}
function DC(e, t) {
  var n = this._id;
  return arguments.length < 2 ? Ni(this.node(), n).on.on(e) : this.each(FC(n, e, t));
}
function OC(e) {
  return function() {
    var t = this.parentNode;
    for (var n in this.__transition)
      if (+n !== e)
        return;
    t && t.removeChild(this);
  };
}
function EC() {
  return this.on("end.remove", OC(this._id));
}
function LC(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = X1(e));
  for (var i = this._groups, r = i.length, s = new Array(r), o = 0; o < r; ++o)
    for (var a = i[o], c = a.length, l = s[o] = new Array(c), u, f, h = 0; h < c; ++h)
      (u = a[h]) && (f = e.call(u, u.__data__, h, a)) && ("__data__" in u && (f.__data__ = u.__data__), l[h] = f, hy(l[h], t, n, h, l, Ni(u, n)));
  return new Qr(s, this._parents, t, n);
}
function RC(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = k3(e));
  for (var i = this._groups, r = i.length, s = [], o = [], a = 0; a < r; ++a)
    for (var c = i[a], l = c.length, u, f = 0; f < l; ++f)
      if (u = c[f]) {
        for (var h = e.call(u, u.__data__, f, c), d, p = Ni(u, n), y = 0, g = h.length; y < g; ++y)
          (d = h[y]) && hy(d, t, n, y, h, p);
        s.push(h), o.push(u);
      }
  return new Qr(s, o, t, n);
}
var CC = Xu.prototype.constructor;
function kC() {
  return new CC(this._groups, this._parents);
}
function UC(e, t) {
  var n, i, r;
  return function() {
    var s = bc(this, e), o = (this.style.removeProperty(e), bc(this, e));
    return s === o ? null : s === n && o === i ? r : r = t(n = s, i = o);
  };
}
function b$(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function zC(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = bc(this, e);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function PC(e, t, n) {
  var i, r, s;
  return function() {
    var o = bc(this, e), a = n(this), c = a + "";
    return a == null && (c = a = (this.style.removeProperty(e), bc(this, e))), o === c ? null : o === i && c === r ? s : (r = c, s = t(i = o, a));
  };
}
function VC(e, t) {
  var n, i, r, s = "style." + t, o = "end." + s, a;
  return function() {
    var c = fr(this, e), l = c.on, u = c.value[s] == null ? a || (a = b$(t)) : void 0;
    (l !== n || r !== u) && (i = (n = l).copy()).on(o, r = u), c.on = i;
  };
}
function jC(e, t, n) {
  var i = (e += "") == "transform" ? k7 : g$;
  return t == null ? this.styleTween(e, UC(e, i)).on("end.style." + e, b$(e)) : typeof t == "function" ? this.styleTween(e, PC(e, i, sb(this, "style." + e, t))).each(VC(this._id, e)) : this.styleTween(e, zC(e, i, t), n).on("end.style." + e, null);
}
function YC(e, t, n) {
  return function(i) {
    this.style.setProperty(e, t.call(this, i), n);
  };
}
function qC(e, t, n) {
  var i, r;
  function s() {
    var o = t.apply(this, arguments);
    return o !== r && (i = (r = o) && YC(e, o, n)), i;
  }
  return s._value = t, s;
}
function WC(e, t, n) {
  var i = "style." + (e += "");
  if (arguments.length < 2)
    return (i = this.tween(i)) && i._value;
  if (t == null)
    return this.tween(i, null);
  if (typeof t != "function")
    throw new Error();
  return this.tween(i, qC(e, t, n ?? ""));
}
function GC(e) {
  return function() {
    this.textContent = e;
  };
}
function XC(e) {
  return function() {
    var t = e(this);
    this.textContent = t ?? "";
  };
}
function HC(e) {
  return this.tween("text", typeof e == "function" ? XC(sb(this, "text", e)) : GC(e == null ? "" : e + ""));
}
function KC(e) {
  return function(t) {
    this.textContent = e.call(this, t);
  };
}
function JC(e) {
  var t, n;
  function i() {
    var r = e.apply(this, arguments);
    return r !== n && (t = (n = r) && KC(r)), t;
  }
  return i._value = e, i;
}
function ZC(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, JC(e));
}
function QC() {
  for (var e = this._name, t = this._id, n = _$(), i = this._groups, r = i.length, s = 0; s < r; ++s)
    for (var o = i[s], a = o.length, c, l = 0; l < a; ++l)
      if (c = o[l]) {
        var u = Ni(c, t);
        hy(c, e, n, l, o, {
          time: u.time + u.delay + u.duration,
          delay: 0,
          duration: u.duration,
          ease: u.ease
        });
      }
  return new Qr(i, this._parents, e, n);
}
function tk() {
  var e, t, n = this, i = n._id, r = n.size();
  return new Promise(function(s, o) {
    var a = { value: o }, c = { value: function() {
      --r === 0 && s();
    } };
    n.each(function() {
      var l = fr(this, i), u = l.on;
      u !== e && (t = (e = u).copy(), t._.cancel.push(a), t._.interrupt.push(a), t._.end.push(c)), l.on = t;
    }), r === 0 && s();
  });
}
var ek = 0;
function Qr(e, t, n, i) {
  this._groups = e, this._parents = t, this._name = n, this._id = i;
}
function _$() {
  return ++ek;
}
var mr = Xu.prototype;
Qr.prototype = {
  constructor: Qr,
  select: LC,
  selectAll: RC,
  selectChild: mr.selectChild,
  selectChildren: mr.selectChildren,
  filter: TC,
  merge: BC,
  selection: kC,
  transition: QC,
  call: mr.call,
  nodes: mr.nodes,
  node: mr.node,
  size: mr.size,
  empty: mr.empty,
  each: mr.each,
  on: DC,
  attr: hC,
  attrTween: gC,
  style: jC,
  styleTween: WC,
  text: HC,
  textTween: ZC,
  remove: EC,
  tween: sC,
  delay: wC,
  duration: SC,
  ease: $C,
  easeVarying: MC,
  end: tk,
  [Symbol.iterator]: mr[Symbol.iterator]
};
function nk(e) {
  return ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2;
}
var ik = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: nk
};
function rk(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 sk(e) {
  var t, n;
  e instanceof Qr ? (t = e._id, e = e._name) : (t = _$(), (n = ik).time = ib(), e = e == null ? null : e + "");
  for (var i = this._groups, r = i.length, s = 0; s < r; ++s)
    for (var o = i[s], a = o.length, c, l = 0; l < a; ++l)
      (c = o[l]) && hy(c, e, t, l, o, n || rk(c, t));
  return new Qr(i, this._parents, e, t);
}
Xu.prototype.interrupt = nC;
Xu.prototype.transition = sk;
const B0 = (e) => () => e;
function ok(e, {
  sourceEvent: t,
  target: n,
  selection: i,
  mode: r,
  dispatch: s
}) {
  Object.defineProperties(this, {
    type: { value: e, enumerable: !0, configurable: !0 },
    sourceEvent: { value: t, enumerable: !0, configurable: !0 },
    target: { value: n, enumerable: !0, configurable: !0 },
    selection: { value: i, enumerable: !0, configurable: !0 },
    mode: { value: r, enumerable: !0, configurable: !0 },
    _: { value: s }
  });
}
function ak(e) {
  e.stopImmediatePropagation();
}
function N0(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
var $v = { name: "drag" }, F0 = { name: "space" }, la = { name: "handle" }, ua = { name: "center" };
const { abs: Av, max: qe, min: We } = Math;
function Mv(e) {
  return [+e[0], +e[1]];
}
function ng(e) {
  return [Mv(e[0]), Mv(e[1])];
}
var Sh = {
  name: "x",
  handles: ["w", "e"].map(yu),
  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]];
  }
}, Ih = {
  name: "y",
  handles: ["n", "s"].map(yu),
  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]];
  }
}, ck = {
  name: "xy",
  handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(yu),
  input: function(e) {
    return e == null ? null : ng(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"
}, Tv = {
  e: "w",
  w: "e",
  nw: "ne",
  ne: "nw",
  se: "sw",
  sw: "se"
}, Bv = {
  n: "s",
  s: "n",
  nw: "sw",
  ne: "se",
  se: "ne",
  sw: "nw"
}, lk = {
  overlay: 1,
  selection: 1,
  n: null,
  e: 1,
  s: null,
  w: -1,
  nw: -1,
  ne: 1,
  se: 1,
  sw: -1
}, uk = {
  overlay: 1,
  selection: 1,
  n: -1,
  e: null,
  s: 1,
  w: null,
  nw: -1,
  ne: -1,
  se: 1,
  sw: 1
};
function yu(e) {
  return { type: e };
}
function fk(e) {
  return !e.ctrlKey && !e.button;
}
function hk() {
  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 dk() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function D0(e) {
  for (; !e.__brush; )
    if (!(e = e.parentNode))
      return;
  return e.__brush;
}
function pk(e) {
  return e[0][0] === e[1][0] || e[0][1] === e[1][1];
}
function yk() {
  return ob(Sh);
}
function mk() {
  return ob(Ih);
}
function gk() {
  return ob(ck);
}
function ob(e) {
  var t = hk, n = fk, i = dk, r = !0, s = oy("start", "brush", "end"), o = 6, a;
  function c(g) {
    var m = g.property("__brush", y).selectAll(".overlay").data([yu("overlay")]);
    m.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", gr.overlay).merge(m).each(function() {
      var _ = D0(this).extent;
      re(this).attr("x", _[0][0]).attr("y", _[0][1]).attr("width", _[1][0] - _[0][0]).attr("height", _[1][1] - _[0][1]);
    }), g.selectAll(".selection").data([yu("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(_) {
      return _.type;
    });
    b.exit().remove(), b.enter().append("rect").attr("class", function(_) {
      return "handle handle--" + _.type;
    }).attr("cursor", function(_) {
      return gr[_.type];
    }), g.each(l).attr("fill", "none").attr("pointer-events", "all").on("mousedown.brush", h).filter(i).on("touchstart.brush", h).on("touchmove.brush", d).on("touchend.brush touchcancel.brush", p).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  c.move = function(g, m, b) {
    g.tween ? g.on("start.brush", function(_) {
      u(this, arguments).beforestart().start(_);
    }).on("interrupt.brush end.brush", function(_) {
      u(this, arguments).end(_);
    }).tween("brush", function() {
      var _ = this, w = _.__brush, v = u(_, arguments), x = w.selection, I = e.input(typeof m == "function" ? m.apply(this, arguments) : m, w.extent), T = qc(x, I);
      function D($) {
        w.selection = $ === 1 && I === null ? null : T($), l.call(_), v.brush();
      }
      return x !== null && I !== null ? D : D(1);
    }) : g.each(function() {
      var _ = this, w = arguments, v = _.__brush, x = e.input(typeof m == "function" ? m.apply(_, w) : m, v.extent), I = u(_, w).beforestart();
      Ha(_), v.selection = x === null ? null : x, l.call(_), I.start(b).brush(b).end(b);
    });
  }, c.clear = function(g, m) {
    c.move(g, null, m);
  };
  function l() {
    var g = re(this), m = D0(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 u(g, m, b) {
    var _ = g.__brush.emitter;
    return _ && (!b || !_.clean) ? _ : new f(g, m, b);
  }
  function f(g, m, b) {
    this.that = g, this.args = m, this.state = g.__brush, this.active = 0, this.clean = b;
  }
  f.prototype = {
    beforestart: function() {
      return ++this.active === 1 && (this.state.emitter = this, this.starting = !0), this;
    },
    start: function(g, m) {
      return this.starting ? (this.starting = !1, this.emit("start", g, m)) : this.emit("brush", g), this;
    },
    brush: function(g, m) {
      return this.emit("brush", g, m), this;
    },
    end: function(g, m) {
      return --this.active === 0 && (delete this.state.emitter, this.emit("end", g, m)), this;
    },
    emit: function(g, m, b) {
      var _ = re(this.that).datum();
      s.call(
        g,
        this.that,
        new ok(g, {
          sourceEvent: m,
          target: c,
          selection: e.output(this.state.selection),
          mode: b,
          dispatch: s
        }),
        _
      );
    }
  };
  function h(g) {
    if (a && !g.touches || !n.apply(this, arguments))
      return;
    var m = this, b = g.target.__data__.type, _ = (r && g.metaKey ? b = "overlay" : b) === "selection" ? $v : r && g.altKey ? ua : la, w = e === Ih ? null : lk[b], v = e === Sh ? null : uk[b], x = D0(m), I = x.extent, T = x.selection, D = I[0][0], $, A, F = I[0][1], E, S, M = I[1][0], B, N, L = I[1][1], k, U, j = 0, P = 0, K, Z = w && v && r && g.shiftKey, et, tt, H = Array.from(g.touches || [g], (Q) => {
      const ee = Q.identifier;
      return Q = ai(Q, m), Q.point0 = Q.slice(), Q.identifier = ee, Q;
    });
    Ha(m);
    var X = u(m, arguments, !0).beforestart();
    if (b === "overlay") {
      T && (K = !0);
      const Q = [H[0], H[1] || H[0]];
      x.selection = T = [[
        $ = e === Ih ? D : We(Q[0][0], Q[1][0]),
        E = e === Sh ? F : We(Q[0][1], Q[1][1])
      ], [
        B = e === Ih ? M : qe(Q[0][0], Q[1][0]),
        k = e === Sh ? L : qe(Q[0][1], Q[1][1])
      ]], H.length > 1 && nt(g);
    } else
      $ = T[0][0], E = T[0][1], B = T[1][0], k = T[1][1];
    A = $, S = E, N = B, U = k;
    var V = re(m).attr("pointer-events", "none"), G = V.selectAll(".overlay").attr("cursor", gr[b]);
    if (g.touches)
      X.moved = z, X.ended = ut;
    else {
      var J = re(g.view).on("mousemove.brush", z, !0).on("mouseup.brush", ut, !0);
      r && J.on("keydown.brush", Gt, !0).on("keyup.brush", Ot, !0), H3(g.view);
    }
    l.call(m), X.start(g, _.name);
    function z(Q) {
      for (const ee of Q.changedTouches || [Q])
        for (const Ei of H)
          Ei.identifier === ee.identifier && (Ei.cur = ai(ee, m));
      if (Z && !et && !tt && H.length === 1) {
        const ee = H[0];
        Av(ee.cur[0] - ee[0]) > Av(ee.cur[1] - ee[1]) ? tt = !0 : et = !0;
      }
      for (const ee of H)
        ee.cur && (ee[0] = ee.cur[0], ee[1] = ee.cur[1]);
      K = !0, N0(Q), nt(Q);
    }
    function nt(Q) {
      const ee = H[0], Ei = ee.point0;
      var An;
      switch (j = ee[0] - Ei[0], P = ee[1] - Ei[1], _) {
        case F0:
        case $v: {
          w && (j = qe(D - $, We(M - B, j)), A = $ + j, N = B + j), v && (P = qe(F - E, We(L - k, P)), S = E + P, U = k + P);
          break;
        }
        case la: {
          H[1] ? (w && (A = qe(D, We(M, H[0][0])), N = qe(D, We(M, H[1][0])), w = 1), v && (S = qe(F, We(L, H[0][1])), U = qe(F, We(L, H[1][1])), v = 1)) : (w < 0 ? (j = qe(D - $, We(M - $, j)), A = $ + j, N = B) : w > 0 && (j = qe(D - B, We(M - B, j)), A = $, N = B + j), v < 0 ? (P = qe(F - E, We(L - E, P)), S = E + P, U = k) : v > 0 && (P = qe(F - k, We(L - k, P)), S = E, U = k + P));
          break;
        }
        case ua: {
          w && (A = qe(D, We(M, $ - j * w)), N = qe(D, We(M, B + j * w))), v && (S = qe(F, We(L, E - P * v)), U = qe(F, We(L, k + P * v)));
          break;
        }
      }
      N < A && (w *= -1, An = $, $ = B, B = An, An = A, A = N, N = An, b in Tv && G.attr("cursor", gr[b = Tv[b]])), U < S && (v *= -1, An = E, E = k, k = An, An = S, S = U, U = An, b in Bv && G.attr("cursor", gr[b = Bv[b]])), x.selection && (T = x.selection), et && (A = T[0][0], N = T[1][0]), tt && (S = T[0][1], U = T[1][1]), (T[0][0] !== A || T[0][1] !== S || T[1][0] !== N || T[1][1] !== U) && (x.selection = [[A, S], [N, U]], l.call(m), X.brush(Q, _.name));
    }
    function ut(Q) {
      if (ak(Q), Q.touches) {
        if (Q.touches.length)
          return;
        a && clearTimeout(a), a = setTimeout(function() {
          a = null;
        }, 500);
      } else
        K3(Q.view, K), J.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
      V.attr("pointer-events", "all"), G.attr("cursor", gr.overlay), x.selection && (T = x.selection), pk(T) && (x.selection = null, l.call(m)), X.end(Q, _.name);
    }
    function Gt(Q) {
      switch (Q.keyCode) {
        case 16: {
          Z = w && v;
          break;
        }
        case 18: {
          _ === la && (w && (B = N - j * w, $ = A + j * w), v && (k = U - P * v, E = S + P * v), _ = ua, nt(Q));
          break;
        }
        case 32: {
          (_ === la || _ === ua) && (w < 0 ? B = N - j : w > 0 && ($ = A - j), v < 0 ? k = U - P : v > 0 && (E = S - P), _ = F0, G.attr("cursor", gr.selection), nt(Q));
          break;
        }
        default:
          return;
      }
      N0(Q);
    }
    function Ot(Q) {
      switch (Q.keyCode) {
        case 16: {
          Z && (et = tt = Z = !1, nt(Q));
          break;
        }
        case 18: {
          _ === ua && (w < 0 ? B = N : w > 0 && ($ = A), v < 0 ? k = U : v > 0 && (E = S), _ = la, nt(Q));
          break;
        }
        case 32: {
          _ === F0 && (Q.altKey ? (w && (B = N - j * w, $ = A + j * w), v && (k = U - P * v, E = S + P * v), _ = ua) : (w < 0 ? B = N : w > 0 && ($ = A), v < 0 ? k = U : v > 0 && (E = S), _ = la), G.attr("cursor", gr[b]), nt(Q));
          break;
        }
        default:
          return;
      }
      N0(Q);
    }
  }
  function d(g) {
    u(this, arguments).moved(g);
  }
  function p(g) {
    u(this, arguments).ended(g);
  }
  function y() {
    var g = this.__brush || { selection: null };
    return g.extent = ng(t.apply(this, arguments)), g.dim = e, g;
  }
  return c.extent = function(g) {
    return arguments.length ? (t = typeof g == "function" ? g : B0(ng(g)), c) : t;
  }, c.filter = function(g) {
    return arguments.length ? (n = typeof g == "function" ? g : B0(!!g), c) : n;
  }, c.touchable = function(g) {
    return arguments.length ? (i = typeof g == "function" ? g : B0(!!g), c) : i;
  }, c.handleSize = function(g) {
    return arguments.length ? (o = +g, c) : o;
  }, c.keyModifiers = function(g) {
    return arguments.length ? (r = !!g, c) : r;
  }, c.on = function() {
    var g = s.on.apply(s, arguments);
    return g === s ? c : g;
  }, c;
}
const ig = Math.PI, rg = 2 * ig, $o = 1e-6, bk = rg - $o;
function w$(e) {
  this._ += e[0];
  for (let t = 1, n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function _k(e) {
  let t = Math.floor(e);
  if (!(t >= 0))
    throw new Error(`invalid digits: ${e}`);
  if (t > 15)
    return w$;
  const n = 10 ** t;
  return function(i) {
    this._ += i[0];
    for (let r = 1, s = i.length; r < s; ++r)
      this._ += Math.round(arguments[r] * n) / n + i[r];
  };
}
let v$ = class {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? w$ : _k(t);
  }
  moveTo(t, n) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`);
  }
  lineTo(t, n) {
    this._append`L${this._x1 = +t},${this._y1 = +n}`;
  }
  quadraticCurveTo(t, n, i, r) {
    this._append`Q${+t},${+n},${this._x1 = +i},${this._y1 = +r}`;
  }
  bezierCurveTo(t, n, i, r, s, o) {
    this._append`C${+t},${+n},${+i},${+r},${this._x1 = +s},${this._y1 = +o}`;
  }
  arcTo(t, n, i, r, s) {
    if (t = +t, n = +n, i = +i, r = +r, s = +s, s < 0)
      throw new Error(`negative radius: ${s}`);
    let o = this._x1, a = this._y1, c = i - t, l = r - n, u = o - t, f = a - n, h = u * u + f * f;
    if (this._x1 === null)
      this._append`M${this._x1 = t},${this._y1 = n}`;
    else if (h > $o)
      if (!(Math.abs(f * c - l * u) > $o) || !s)
        this._append`L${this._x1 = t},${this._y1 = n}`;
      else {
        let d = i - o, p = r - a, y = c * c + l * l, g = d * d + p * p, m = Math.sqrt(y), b = Math.sqrt(h), _ = s * Math.tan((ig - Math.acos((y + h - g) / (2 * m * b))) / 2), w = _ / b, v = _ / m;
        Math.abs(w - 1) > $o && this._append`L${t + w * u},${n + w * f}`, this._append`A${s},${s},0,0,${+(f * d > u * p)},${this._x1 = t + v * c},${this._y1 = n + v * l}`;
      }
  }
  arc(t, n, i, r, s, o) {
    if (t = +t, n = +n, i = +i, o = !!o, i < 0)
      throw new Error(`negative radius: ${i}`);
    let a = i * Math.cos(r), c = i * Math.sin(r), l = t + a, u = n + c, f = 1 ^ o, h = o ? r - s : s - r;
    this._x1 === null ? this._append`M${l},${u}` : (Math.abs(this._x1 - l) > $o || Math.abs(this._y1 - u) > $o) && this._append`L${l},${u}`, i && (h < 0 && (h = h % rg + rg), h > bk ? this._append`A${i},${i},0,1,${f},${t - a},${n - c}A${i},${i},0,1,${f},${this._x1 = l},${this._y1 = u}` : h > $o && this._append`A${i},${i},0,${+(h >= ig)},${f},${this._x1 = t + i * Math.cos(s)},${this._y1 = n + i * Math.sin(s)}`);
  }
  rect(t, n, i, r) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${i = +i}v${+r}h${-i}Z`;
  }
  toString() {
    return this._;
  }
};
function zr(e = 3) {
  return new v$(+e);
}
var wk = Array.prototype, x$ = wk.slice;
function vk(e, t) {
  return e - t;
}
function xk(e) {
  for (var t = 0, n = e.length, i = e[n - 1][1] * e[0][0] - e[n - 1][0] * e[0][1]; ++t < n; )
    i += e[t - 1][1] * e[t][0] - e[t - 1][0] * e[t][1];
  return i;
}
const ws = (e) => () => e;
function Sk(e, t) {
  for (var n = -1, i = t.length, r; ++n < i; )
    if (r = Ik(e, t[n]))
      return r;
  return 0;
}
function Ik(e, t) {
  for (var n = t[0], i = t[1], r = -1, s = 0, o = e.length, a = o - 1; s < o; a = s++) {
    var c = e[s], l = c[0], u = c[1], f = e[a], h = f[0], d = f[1];
    if ($k(c, f, t))
      return 0;
    u > i != d > i && n < (h - l) * (i - u) / (d - u) + l && (r = -r);
  }
  return r;
}
function $k(e, t, n) {
  var i;
  return Ak(e, t, n) && Mk(e[i = +(e[0] === t[0])], n[i], t[i]);
}
function Ak(e, t, n) {
  return (t[0] - e[0]) * (n[1] - e[1]) === (n[0] - e[0]) * (t[1] - e[1]);
}
function Mk(e, t, n) {
  return e <= t && t <= n || n <= t && t <= e;
}
function Tk() {
}
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 xd() {
  var e = 1, t = 1, n = q1, i = c;
  function r(l) {
    var u = n(l);
    if (Array.isArray(u))
      u = u.slice().sort(vk);
    else {
      const f = He(l, Bk);
      for (u = Us(...D3(f[0], f[1], u), u); u[u.length - 1] >= f[1]; )
        u.pop();
      for (; u[1] < f[0]; )
        u.shift();
    }
    return u.map((f) => s(l, f));
  }
  function s(l, u) {
    const f = u == null ? NaN : +u;
    if (isNaN(f))
      throw new Error(`invalid value: ${u}`);
    var h = [], d = [];
    return o(l, f, function(p) {
      i(p, l, f), xk(p) > 0 ? h.push([p]) : d.push(p);
    }), d.forEach(function(p) {
      for (var y = 0, g = h.length, m; y < g; ++y)
        if (Sk((m = h[y])[0], p) !== -1) {
          m.push(p);
          return;
        }
    }), {
      type: "MultiPolygon",
      value: u,
      coordinates: h
    };
  }
  function o(l, u, f) {
    var h = new Array(), d = new Array(), p, y, g, m, b, _;
    for (p = y = -1, m = ho(l[0], u), br[m << 1].forEach(w); ++p < e - 1; )
      g = m, m = ho(l[p + 1], u), br[g | m << 1].forEach(w);
    for (br[m << 0].forEach(w); ++y < t - 1; ) {
      for (p = -1, m = ho(l[y * e + e], u), b = ho(l[y * e], u), br[m << 1 | b << 2].forEach(w); ++p < e - 1; )
        g = m, m = ho(l[y * e + e + p + 1], u), _ = b, b = ho(l[y * e + p + 1], u), br[g | m << 1 | b << 2 | _ << 3].forEach(w);
      br[m | b << 3].forEach(w);
    }
    for (p = -1, b = l[y * e] >= u, br[b << 2].forEach(w); ++p < e - 1; )
      _ = b, b = ho(l[y * e + p + 1], u), br[b << 2 | _ << 3].forEach(w);
    br[b << 3].forEach(w);
    function w(v) {
      var x = [v[0][0] + p, v[0][1] + y], I = [v[1][0] + p, v[1][1] + y], T = a(x), D = a(I), $, A;
      ($ = d[T]) ? (A = h[D]) ? (delete d[$.end], delete h[A.start], $ === A ? ($.ring.push(I), f($.ring)) : h[$.start] = d[A.end] = { start: $.start, end: A.end, ring: $.ring.concat(A.ring) }) : (delete d[$.end], $.ring.push(I), d[$.end = D] = $) : ($ = h[D]) ? (A = d[T]) ? (delete h[$.start], delete d[A.end], $ === A ? ($.ring.push(I), f($.ring)) : h[A.start] = d[$.end] = { start: A.start, end: $.end, ring: A.ring.concat($.ring) }) : (delete h[$.start], $.ring.unshift(x), h[$.start = T] = $) : h[T] = d[D] = { start: T, end: D, ring: [x, I] };
    }
  }
  function a(l) {
    return l[0] * 2 + l[1] * (e + 1) * 4;
  }
  function c(l, u, f) {
    l.forEach(function(h) {
      var d = h[0], p = h[1], y = d | 0, g = p | 0, m = O0(u[g * e + y]);
      d > 0 && d < e && y === d && (h[0] = Nv(d, O0(u[g * e + y - 1]), m, f)), p > 0 && p < t && g === p && (h[1] = Nv(p, O0(u[(g - 1) * e + y]), m, f));
    });
  }
  return r.contour = s, r.size = function(l) {
    if (!arguments.length)
      return [e, t];
    var u = Math.floor(l[0]), f = Math.floor(l[1]);
    if (!(u >= 0 && f >= 0))
      throw new Error("invalid size");
    return e = u, t = f, r;
  }, r.thresholds = function(l) {
    return arguments.length ? (n = typeof l == "function" ? l : Array.isArray(l) ? ws(x$.call(l)) : ws(l), r) : n;
  }, r.smooth = function(l) {
    return arguments.length ? (i = l ? c : Tk, r) : i === c;
  }, r;
}
function Bk(e) {
  return isFinite(e) ? e : NaN;
}
function ho(e, t) {
  return e == null ? !1 : +e >= t;
}
function O0(e) {
  return e == null || isNaN(e = +e) ? -1 / 0 : e;
}
function Nv(e, t, n, i) {
  const r = i - t, s = n - t, o = isFinite(r) || isFinite(s) ? r / s : Math.sign(r) / Math.sign(s);
  return isNaN(o) ? e : e + o - 0.5;
}
function Nk(e) {
  return e[0];
}
function Fk(e) {
  return e[1];
}
function Dk() {
  return 1;
}
function Ok() {
  var e = Nk, t = Fk, n = Dk, i = 960, r = 500, s = 20, o = 2, a = s * 3, c = i + a * 2 >> o, l = r + a * 2 >> o, u = ws(20);
  function f(b) {
    var _ = new Float32Array(c * l), w = Math.pow(2, -o), v = -1;
    for (const E of b) {
      var x = (e(E, ++v, b) + a) * w, I = (t(E, v, b) + a) * w, T = +n(E, v, b);
      if (T && x >= 0 && x < c && I >= 0 && I < l) {
        var D = Math.floor(x), $ = Math.floor(I), A = x - D - 0.5, F = I - $ - 0.5;
        _[D + $ * c] += (1 - A) * (1 - F) * T, _[D + 1 + $ * c] += A * (1 - F) * T, _[D + 1 + ($ + 1) * c] += A * F * T, _[D + ($ + 1) * c] += (1 - A) * F * T;
      }
    }
    return A3({ data: _, width: c, height: l }, s * w), _;
  }
  function h(b) {
    var _ = f(b), w = u(_), v = Math.pow(2, 2 * o);
    return Array.isArray(w) || (w = Us(Number.MIN_VALUE, Se(_) / v, w)), xd().size([c, l]).thresholds(w.map((x) => x * v))(_).map((x, I) => (x.value = +w[I], d(x)));
  }
  h.contours = function(b) {
    var _ = f(b), w = xd().size([c, l]), v = Math.pow(2, 2 * o), x = (I) => {
      I = +I;
      var T = d(w.contour(_, I * v));
      return T.value = I, T;
    };
    return Object.defineProperty(x, "max", { get: () => Se(_) / v }), 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 = i + a * 2 >> o, l = r + a * 2 >> o, h;
  }
  return h.x = function(b) {
    return arguments.length ? (e = typeof b == "function" ? b : ws(+b), h) : e;
  }, h.y = function(b) {
    return arguments.length ? (t = typeof b == "function" ? b : ws(+b), h) : t;
  }, h.weight = function(b) {
    return arguments.length ? (n = typeof b == "function" ? b : ws(+b), h) : n;
  }, h.size = function(b) {
    if (!arguments.length)
      return [i, r];
    var _ = +b[0], w = +b[1];
    if (!(_ >= 0 && w >= 0))
      throw new Error("invalid size");
    return i = _, r = w, m();
  }, h.cellSize = function(b) {
    if (!arguments.length)
      return 1 << o;
    if (!((b = +b) >= 1))
      throw new Error("invalid cell size");
    return o = Math.floor(Math.log(b) / Math.LN2), m();
  }, h.thresholds = function(b) {
    return arguments.length ? (u = typeof b == "function" ? b : Array.isArray(b) ? ws(x$.call(b)) : ws(b), h) : u;
  }, h.bandwidth = function(b) {
    if (!arguments.length)
      return Math.sqrt(s * (s + 1));
    if (!((b = +b) >= 0))
      throw new Error("invalid bandwidth");
    return s = (Math.sqrt(4 * b * b + 1) - 1) / 2, m();
  }, h;
}
const Wr = 11102230246251565e-32, Ge = 134217729, Ek = (3 + 8 * Wr) * Wr;
function E0(e, t, n, i, r) {
  let s, o, a, c, l = t[0], u = i[0], f = 0, h = 0;
  u > l == u > -l ? (s = l, l = t[++f]) : (s = u, u = i[++h]);
  let d = 0;
  if (f < e && h < n)
    for (u > l == u > -l ? (o = l + s, a = s - (o - l), l = t[++f]) : (o = u + s, a = s - (o - u), u = i[++h]), s = o, a !== 0 && (r[d++] = a); f < e && h < n; )
      u > l == u > -l ? (o = s + l, c = o - s, a = s - (o - c) + (l - c), l = t[++f]) : (o = s + u, c = o - s, a = s - (o - c) + (u - c), u = i[++h]), s = o, a !== 0 && (r[d++] = a);
  for (; f < e; )
    o = s + l, c = o - s, a = s - (o - c) + (l - c), l = t[++f], s = o, a !== 0 && (r[d++] = a);
  for (; h < n; )
    o = s + u, c = o - s, a = s - (o - c) + (u - c), u = i[++h], s = o, a !== 0 && (r[d++] = a);
  return (s !== 0 || d === 0) && (r[d++] = s), d;
}
function Lk(e, t) {
  let n = t[0];
  for (let i = 1; i < e; i++)
    n += t[i];
  return n;
}
function Ku(e) {
  return new Float64Array(e);
}
const Rk = (3 + 16 * Wr) * Wr, Ck = (2 + 12 * Wr) * Wr, kk = (9 + 64 * Wr) * Wr * Wr, fa = Ku(4), Fv = Ku(8), Dv = Ku(12), Ov = Ku(16), Ze = Ku(4);
function Uk(e, t, n, i, r, s, o) {
  let a, c, l, u, f, h, d, p, y, g, m, b, _, w, v, x, I, T;
  const D = e - r, $ = n - r, A = t - s, F = i - s;
  w = D * F, h = Ge * D, d = h - (h - D), p = D - d, h = Ge * F, y = h - (h - F), g = F - y, v = p * g - (w - d * y - p * y - d * g), x = A * $, h = Ge * A, d = h - (h - A), p = A - d, h = Ge * $, y = h - (h - $), g = $ - y, I = p * g - (x - d * y - p * y - d * g), m = v - I, f = v - m, fa[0] = v - (m + f) + (f - I), b = w + m, f = b - w, _ = w - (b - f) + (m - f), m = _ - x, f = _ - m, fa[1] = _ - (m + f) + (f - x), T = b + m, f = T - b, fa[2] = b - (T - f) + (m - f), fa[3] = T;
  let E = Lk(4, fa), S = Ck * o;
  if (E >= S || -E >= S || (f = e - D, a = e - (D + f) + (f - r), f = n - $, l = n - ($ + f) + (f - r), f = t - A, c = t - (A + f) + (f - s), f = i - F, u = i - (F + f) + (f - s), a === 0 && c === 0 && l === 0 && u === 0) || (S = kk * o + Ek * Math.abs(E), E += D * u + F * a - (A * l + $ * c), E >= S || -E >= S))
    return E;
  w = a * F, h = Ge * a, d = h - (h - a), p = a - d, h = Ge * F, y = h - (h - F), g = F - y, v = p * g - (w - d * y - p * y - d * g), x = c * $, h = Ge * c, d = h - (h - c), p = c - d, h = Ge * $, y = h - (h - $), g = $ - y, I = p * g - (x - d * y - p * y - d * g), m = v - I, f = v - m, Ze[0] = v - (m + f) + (f - I), b = w + m, f = b - w, _ = w - (b - f) + (m - f), m = _ - x, f = _ - m, Ze[1] = _ - (m + f) + (f - x), T = b + m, f = T - b, Ze[2] = b - (T - f) + (m - f), Ze[3] = T;
  const M = E0(4, fa, 4, Ze, Fv);
  w = D * u, h = Ge * D, d = h - (h - D), p = D - d, h = Ge * u, y = h - (h - u), g = u - y, v = p * g - (w - d * y - p * y - d * g), x = A * l, h = Ge * A, d = h - (h - A), p = A - d, h = Ge * l, y = h - (h - l), g = l - y, I = p * g - (x - d * y - p * y - d * g), m = v - I, f = v - m, Ze[0] = v - (m + f) + (f - I), b = w + m, f = b - w, _ = w - (b - f) + (m - f), m = _ - x, f = _ - m, Ze[1] = _ - (m + f) + (f - x), T = b + m, f = T - b, Ze[2] = b - (T - f) + (m - f), Ze[3] = T;
  const B = E0(M, Fv, 4, Ze, Dv);
  w = a * u, h = Ge * a, d = h - (h - a), p = a - d, h = Ge * u, y = h - (h - u), g = u - y, v = p * g - (w - d * y - p * y - d * g), x = c * l, h = Ge * c, d = h - (h - c), p = c - d, h = Ge * l, y = h - (h - l), g = l - y, I = p * g - (x - d * y - p * y - d * g), m = v - I, f = v - m, Ze[0] = v - (m + f) + (f - I), b = w + m, f = b - w, _ = w - (b - f) + (m - f), m = _ - x, f = _ - m, Ze[1] = _ - (m + f) + (f - x), T = b + m, f = T - b, Ze[2] = b - (T - f) + (m - f), Ze[3] = T;
  const N = E0(B, Dv, 4, Ze, Ov);
  return Ov[N - 1];
}
function Lf(e, t, n, i, r, s) {
  const o = (t - s) * (n - r), a = (e - r) * (i - s), c = o - a;
  if (o === 0 || a === 0 || o > 0 != a > 0)
    return c;
  const l = Math.abs(o + a);
  return Math.abs(c) >= Rk * l ? c : -Uk(e, t, n, i, r, s, l);
}
const Ev = Math.pow(2, -52), Rf = new Uint32Array(512);
class Sd {
  static from(t, n = Yk, i = qk) {
    const r = t.length, s = new Float64Array(r * 2);
    for (let o = 0; o < r; o++) {
      const a = t[o];
      s[2 * o] = n(a), s[2 * o + 1] = i(a);
    }
    return new Sd(s);
  }
  constructor(t) {
    const n = t.length >> 1;
    if (n > 0 && typeof t[0] != "number")
      throw new Error("Expected coords to contain numbers.");
    this.coords = t;
    const i = Math.max(2 * n - 5, 0);
    this._triangles = new Uint32Array(i * 3), this._halfedges = new Int32Array(i * 3), this._hashSize = Math.ceil(Math.sqrt(n)), this._hullPrev = new Uint32Array(n), this._hullNext = new Uint32Array(n), this._hullTri = new Uint32Array(n), this._hullHash = new Int32Array(this._hashSize).fill(-1), this._ids = new Uint32Array(n), this._dists = new Float64Array(n), this.update();
  }
  update() {
    const { coords: t, _hullPrev: n, _hullNext: i, _hullTri: r, _hullHash: s } = this, o = t.length >> 1;
    let a = 1 / 0, c = 1 / 0, l = -1 / 0, u = -1 / 0;
    for (let $ = 0; $ < o; $++) {
      const A = t[2 * $], F = t[2 * $ + 1];
      A < a && (a = A), F < c && (c = F), A > l && (l = A), F > u && (u = F), this._ids[$] = $;
    }
    const f = (a + l) / 2, h = (c + u) / 2;
    let d = 1 / 0, p, y, g;
    for (let $ = 0; $ < o; $++) {
      const A = L0(f, h, t[2 * $], t[2 * $ + 1]);
      A < d && (p = $, d = A);
    }
    const m = t[2 * p], b = t[2 * p + 1];
    d = 1 / 0;
    for (let $ = 0; $ < o; $++) {
      if ($ === p)
        continue;
      const A = L0(m, b, t[2 * $], t[2 * $ + 1]);
      A < d && A > 0 && (y = $, d = A);
    }
    let _ = t[2 * y], w = t[2 * y + 1], v = 1 / 0;
    for (let $ = 0; $ < o; $++) {
      if ($ === p || $ === y)
        continue;
      const A = Vk(m, b, _, w, t[2 * $], t[2 * $ + 1]);
      A < v && (g = $, v = A);
    }
    let x = t[2 * g], I = t[2 * g + 1];
    if (v === 1 / 0) {
      for (let F = 0; F < o; F++)
        this._dists[F] = t[2 * F] - t[0] || t[2 * F + 1] - t[1];
      Ca(this._ids, this._dists, 0, o - 1);
      const $ = new Uint32Array(o);
      let A = 0;
      for (let F = 0, E = -1 / 0; F < o; F++) {
        const S = this._ids[F];
        this._dists[S] > E && ($[A++] = S, E = this._dists[S]);
      }
      this.hull = $.subarray(0, A), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
      return;
    }
    if (Lf(m, b, _, w, x, I) < 0) {
      const $ = y, A = _, F = w;
      y = g, _ = x, w = I, g = $, x = A, I = F;
    }
    const T = jk(m, b, _, w, x, I);
    this._cx = T.x, this._cy = T.y;
    for (let $ = 0; $ < o; $++)
      this._dists[$] = L0(t[2 * $], t[2 * $ + 1], T.x, T.y);
    Ca(this._ids, this._dists, 0, o - 1), this._hullStart = p;
    let D = 3;
    i[p] = n[g] = y, i[y] = n[p] = g, i[g] = n[y] = p, r[p] = 0, r[y] = 1, r[g] = 2, s.fill(-1), s[this._hashKey(m, b)] = p, s[this._hashKey(_, w)] = y, s[this._hashKey(x, I)] = g, this.trianglesLen = 0, this._addTriangle(p, y, g, -1, -1, -1);
    for (let $ = 0, A, F; $ < this._ids.length; $++) {
      const E = this._ids[$], S = t[2 * E], M = t[2 * E + 1];
      if ($ > 0 && Math.abs(S - A) <= Ev && Math.abs(M - F) <= Ev || (A = S, F = M, E === p || E === y || E === g))
        continue;
      let B = 0;
      for (let j = 0, P = this._hashKey(S, M); j < this._hashSize && (B = s[(P + j) % this._hashSize], !(B !== -1 && B !== i[B])); j++)
        ;
      B = n[B];
      let N = B, L;
      for (; L = i[N], Lf(S, M, t[2 * N], t[2 * N + 1], t[2 * L], t[2 * L + 1]) >= 0; )
        if (N = L, N === B) {
          N = -1;
          break;
        }
      if (N === -1)
        continue;
      let k = this._addTriangle(N, E, i[N], -1, -1, r[N]);
      r[E] = this._legalize(k + 2), r[N] = k, D++;
      let U = i[N];
      for (; L = i[U], Lf(S, M, t[2 * U], t[2 * U + 1], t[2 * L], t[2 * L + 1]) < 0; )
        k = this._addTriangle(U, E, L, r[E], -1, r[U]), r[E] = this._legalize(k + 2), i[U] = U, D--, U = L;
      if (N === B)
        for (; L = n[N], Lf(S, M, t[2 * L], t[2 * L + 1], t[2 * N], t[2 * N + 1]) < 0; )
          k = this._addTriangle(L, E, N, -1, r[N], r[L]), this._legalize(k + 2), r[L] = k, i[N] = N, D--, N = L;
      this._hullStart = n[E] = N, i[N] = n[U] = E, i[E] = U, s[this._hashKey(S, M)] = E, s[this._hashKey(t[2 * N], t[2 * N + 1])] = N;
    }
    this.hull = new Uint32Array(D);
    for (let $ = 0, A = this._hullStart; $ < D; $++)
      this.hull[$] = A, A = i[A];
    this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
  }
  _hashKey(t, n) {
    return Math.floor(zk(t - this._cx, n - this._cy) * this._hashSize) % this._hashSize;
  }
  _legalize(t) {
    const { _triangles: n, _halfedges: i, coords: r } = this;
    let s = 0, o = 0;
    for (; ; ) {
      const a = i[t], c = t - t % 3;
      if (o = c + (t + 2) % 3, a === -1) {
        if (s === 0)
          break;
        t = Rf[--s];
        continue;
      }
      const l = a - a % 3, u = c + (t + 1) % 3, f = l + (a + 2) % 3, h = n[o], d = n[t], p = n[u], y = n[f];
      if (Pk(
        r[2 * h],
        r[2 * h + 1],
        r[2 * d],
        r[2 * d + 1],
        r[2 * p],
        r[2 * p + 1],
        r[2 * y],
        r[2 * y + 1]
      )) {
        n[t] = y, n[a] = h;
        const m = i[f];
        if (m === -1) {
          let _ = this._hullStart;
          do {
            if (this._hullTri[_] === f) {
              this._hullTri[_] = t;
              break;
            }
            _ = this._hullPrev[_];
          } while (_ !== this._hullStart);
        }
        this._link(t, m), this._link(a, i[o]), this._link(o, f);
        const b = l + (a + 1) % 3;
        s < Rf.length && (Rf[s++] = b);
      } else {
        if (s === 0)
          break;
        t = Rf[--s];
      }
    }
    return o;
  }
  _link(t, n) {
    this._halfedges[t] = n, n !== -1 && (this._halfedges[n] = t);
  }
  // add a new triangle given vertex indices and adjacent half-edge ids
  _addTriangle(t, n, i, r, s, o) {
    const a = this.trianglesLen;
    return this._triangles[a] = t, this._triangles[a + 1] = n, this._triangles[a + 2] = i, this._link(a, r), this._link(a + 1, s), this._link(a + 2, o), this.trianglesLen += 3, a;
  }
}
function zk(e, t) {
  const n = e / (Math.abs(e) + Math.abs(t));
  return (t > 0 ? 3 - n : 1 + n) / 4;
}
function L0(e, t, n, i) {
  const r = e - n, s = t - i;
  return r * r + s * s;
}
function Pk(e, t, n, i, r, s, o, a) {
  const c = e - o, l = t - a, u = n - o, f = i - a, h = r - o, d = s - a, p = c * c + l * l, y = u * u + f * f, g = h * h + d * d;
  return c * (f * g - y * d) - l * (u * g - y * h) + p * (u * d - f * h) < 0;
}
function Vk(e, t, n, i, r, s) {
  const o = n - e, a = i - t, c = r - e, l = s - t, u = o * o + a * a, f = c * c + l * l, h = 0.5 / (o * l - a * c), d = (l * u - a * f) * h, p = (o * f - c * u) * h;
  return d * d + p * p;
}
function jk(e, t, n, i, r, s) {
  const o = n - e, a = i - t, c = r - e, l = s - t, u = o * o + a * a, f = c * c + l * l, h = 0.5 / (o * l - a * c), d = e + (l * u - a * f) * h, p = t + (o * f - c * u) * h;
  return { x: d, y: p };
}
function Ca(e, t, n, i) {
  if (i - n <= 20)
    for (let r = n + 1; r <= i; r++) {
      const s = e[r], o = t[s];
      let a = r - 1;
      for (; a >= n && t[e[a]] > o; )
        e[a + 1] = e[a--];
      e[a + 1] = s;
    }
  else {
    const r = n + i >> 1;
    let s = n + 1, o = i;
    dl(e, r, s), t[e[n]] > t[e[i]] && dl(e, n, i), t[e[s]] > t[e[i]] && dl(e, s, i), t[e[n]] > t[e[s]] && dl(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;
      dl(e, s, o);
    }
    e[n + 1] = e[o], e[o] = a, i - s + 1 >= o - n ? (Ca(e, t, s, i), Ca(e, t, n, o - 1)) : (Ca(e, t, n, o - 1), Ca(e, t, s, i));
  }
}
function dl(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function Yk(e) {
  return e[0];
}
function qk(e) {
  return e[1];
}
const Lv = 1e-6;
class No {
  constructor() {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "";
  }
  moveTo(t, n) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z");
  }
  lineTo(t, n) {
    this._ += `L${this._x1 = +t},${this._y1 = +n}`;
  }
  arc(t, n, i) {
    t = +t, n = +n, i = +i;
    const r = t + i, s = n;
    if (i < 0)
      throw new Error("negative radius");
    this._x1 === null ? this._ += `M${r},${s}` : (Math.abs(this._x1 - r) > Lv || Math.abs(this._y1 - s) > Lv) && (this._ += "L" + r + "," + s), i && (this._ += `A${i},${i},0,1,1,${t - i},${n}A${i},${i},0,1,1,${this._x1 = r},${this._y1 = s}`);
  }
  rect(t, n, i, r) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${+i}v${+r}h${-i}Z`;
  }
  value() {
    return this._ || null;
  }
}
class sg {
  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 Wk = class {
  constructor(t, [n, i, r, s] = [0, 0, 960, 500]) {
    if (!((r = +r) >= (n = +n)) || !((s = +s) >= (i = +i)))
      throw new Error("invalid bounds");
    this.delaunay = t, this._circumcenters = new Float64Array(t.points.length * 2), this.vectors = new Float64Array(t.points.length * 2), this.xmax = r, this.xmin = n, this.ymax = s, this.ymin = i, this._init();
  }
  update() {
    return this.delaunay.update(), this._init(), this;
  }
  _init() {
    const { delaunay: { points: t, hull: n, triangles: i }, vectors: r } = this;
    let s, o;
    const a = this.circumcenters = this._circumcenters.subarray(0, i.length / 3 * 2);
    for (let y = 0, g = 0, m = i.length, b, _; y < m; y += 3, g += 2) {
      const w = i[y] * 2, v = i[y + 1] * 2, x = i[y + 2] * 2, I = t[w], T = t[w + 1], D = t[v], $ = t[v + 1], A = t[x], F = t[x + 1], E = D - I, S = $ - T, M = A - I, B = F - T, N = (E * B - S * M) * 2;
      if (Math.abs(N) < 1e-9) {
        if (s === void 0) {
          s = o = 0;
          for (const k of n)
            s += t[k * 2], o += t[k * 2 + 1];
          s /= n.length, o /= n.length;
        }
        const L = 1e9 * Math.sign((s - I) * B - (o - T) * M);
        b = (I + A) / 2 - L * B, _ = (T + F) / 2 + L * M;
      } else {
        const L = 1 / N, k = E * E + S * S, U = M * M + B * B;
        b = I + (B * k - S * U) * L, _ = T + (E * U - M * k) * L;
      }
      a[g] = b, a[g + 1] = _;
    }
    let c = n[n.length - 1], l, u = c * 4, f, h = t[2 * c], d, p = t[2 * c + 1];
    r.fill(0);
    for (let y = 0; y < n.length; ++y)
      c = n[y], l = u, f = h, d = p, u = c * 4, h = t[2 * c], p = t[2 * c + 1], r[l + 2] = r[u] = d - p, r[l + 3] = r[u + 1] = h - f;
  }
  render(t) {
    const n = t == null ? t = new No() : void 0, { delaunay: { halfedges: i, inedges: r, hull: s }, circumcenters: o, vectors: a } = this;
    if (s.length <= 1)
      return null;
    for (let u = 0, f = i.length; u < f; ++u) {
      const h = i[u];
      if (h < u)
        continue;
      const d = Math.floor(u / 3) * 2, p = Math.floor(h / 3) * 2, y = o[d], g = o[d + 1], m = o[p], b = o[p + 1];
      this._renderSegment(y, g, m, b, t);
    }
    let c, l = s[s.length - 1];
    for (let u = 0; u < s.length; ++u) {
      c = l, l = s[u];
      const f = Math.floor(r[l] / 3) * 2, h = o[f], d = o[f + 1], p = c * 4, y = this._project(h, d, a[p + 2], a[p + 3]);
      y && this._renderSegment(h, d, y[0], y[1], t);
    }
    return n && n.value();
  }
  renderBounds(t) {
    const n = t == null ? t = new No() : void 0;
    return t.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin), n && n.value();
  }
  renderCell(t, n) {
    const i = n == null ? n = new No() : void 0, r = this._clip(t);
    if (r === null || !r.length)
      return;
    n.moveTo(r[0], r[1]);
    let s = r.length;
    for (; r[0] === r[s - 2] && r[1] === r[s - 1] && s > 1; )
      s -= 2;
    for (let o = 2; o < s; o += 2)
      (r[o] !== r[o - 2] || r[o + 1] !== r[o - 1]) && n.lineTo(r[o], r[o + 1]);
    return n.closePath(), i && i.value();
  }
  *cellPolygons() {
    const { delaunay: { points: t } } = this;
    for (let n = 0, i = t.length / 2; n < i; ++n) {
      const r = this.cellPolygon(n);
      r && (r.index = n, yield r);
    }
  }
  cellPolygon(t) {
    const n = new sg();
    return this.renderCell(t, n), n.value();
  }
  _renderSegment(t, n, i, r, s) {
    let o;
    const a = this._regioncode(t, n), c = this._regioncode(i, r);
    a === 0 && c === 0 ? (s.moveTo(t, n), s.lineTo(i, r)) : (o = this._clipSegment(t, n, i, r, a, c)) && (s.moveTo(o[0], o[1]), s.lineTo(o[2], o[3]));
  }
  contains(t, n, i) {
    return n = +n, n !== n || (i = +i, i !== i) ? !1 : this.delaunay._step(t, n, i) === t;
  }
  *neighbors(t) {
    const n = this._clip(t);
    if (n)
      for (const i of this.delaunay.neighbors(t)) {
        const r = this._clip(i);
        if (r) {
          t:
            for (let s = 0, o = n.length; s < o; s += 2)
              for (let a = 0, c = r.length; a < c; a += 2)
                if (n[s] === r[a] && n[s + 1] === r[a + 1] && n[(s + 2) % o] === r[(a + c - 2) % c] && n[(s + 3) % o] === r[(a + c - 1) % c]) {
                  yield i;
                  break t;
                }
        }
      }
  }
  _cell(t) {
    const { circumcenters: n, delaunay: { inedges: i, halfedges: r, triangles: s } } = this, o = i[t];
    if (o === -1)
      return null;
    const a = [];
    let c = o;
    do {
      const l = Math.floor(c / 3);
      if (a.push(n[l * 2], n[l * 2 + 1]), c = c % 3 === 2 ? c - 2 : c + 1, s[c] !== t)
        break;
      c = r[c];
    } while (c !== o && c !== -1);
    return a;
  }
  _clip(t) {
    if (t === 0 && this.delaunay.hull.length === 1)
      return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
    const n = this._cell(t);
    if (n === null)
      return null;
    const { vectors: i } = this, r = t * 4;
    return this._simplify(i[r] || i[r + 1] ? this._clipInfinite(t, n, i[r], i[r + 1], i[r + 2], i[r + 3]) : this._clipFinite(t, n));
  }
  _clipFinite(t, n) {
    const i = n.length;
    let r = null, s, o, a = n[i - 2], c = n[i - 1], l, u = this._regioncode(a, c), f, h = 0;
    for (let d = 0; d < i; d += 2)
      if (s = a, o = c, a = n[d], c = n[d + 1], l = u, u = this._regioncode(a, c), l === 0 && u === 0)
        f = h, h = 0, r ? r.push(a, c) : r = [a, c];
      else {
        let p, y, g, m, b;
        if (l === 0) {
          if ((p = this._clipSegment(s, o, a, c, l, u)) === null)
            continue;
          [y, g, m, b] = p;
        } else {
          if ((p = this._clipSegment(a, c, s, o, u, l)) === null)
            continue;
          [m, b, y, g] = p, f = h, h = this._edgecode(y, g), f && h && this._edge(t, f, h, r, r.length), r ? r.push(y, g) : r = [y, g];
        }
        f = h, h = this._edgecode(m, b), f && h && this._edge(t, f, h, r, r.length), r ? r.push(m, b) : r = [m, b];
      }
    if (r)
      f = h, h = this._edgecode(r[0], r[1]), f && h && this._edge(t, f, h, r, r.length);
    else if (this.contains(t, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2))
      return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
    return r;
  }
  _clipSegment(t, n, i, r, s, o) {
    const a = s < o;
    for (a && ([t, n, i, r, s, o] = [i, r, t, n, o, s]); ; ) {
      if (s === 0 && o === 0)
        return a ? [i, r, t, n] : [t, n, i, r];
      if (s & o)
        return null;
      let c, l, u = s || o;
      u & 8 ? (c = t + (i - t) * (this.ymax - n) / (r - n), l = this.ymax) : u & 4 ? (c = t + (i - t) * (this.ymin - n) / (r - n), l = this.ymin) : u & 2 ? (l = n + (r - n) * (this.xmax - t) / (i - t), c = this.xmax) : (l = n + (r - n) * (this.xmin - t) / (i - t), c = this.xmin), s ? (t = c, n = l, s = this._regioncode(t, n)) : (i = c, r = l, o = this._regioncode(i, r));
    }
  }
  _clipInfinite(t, n, i, r, s, o) {
    let a = Array.from(n), c;
    if ((c = this._project(a[0], a[1], i, r)) && a.unshift(c[0], c[1]), (c = this._project(a[a.length - 2], a[a.length - 1], s, o)) && a.push(c[0], c[1]), a = this._clipFinite(t, a))
      for (let l = 0, u = a.length, f, h = this._edgecode(a[u - 2], a[u - 1]); l < u; l += 2)
        f = h, h = this._edgecode(a[l], a[l + 1]), f && h && (l = this._edge(t, f, h, a, l), u = a.length);
    else
      this.contains(t, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2) && (a = [this.xmin, this.ymin, this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax]);
    return a;
  }
  _edge(t, n, i, r, s) {
    for (; n !== i; ) {
      let o, a;
      switch (n) {
        case 5:
          n = 4;
          continue;
        case 4:
          n = 6, o = this.xmax, a = this.ymin;
          break;
        case 6:
          n = 2;
          continue;
        case 2:
          n = 10, o = this.xmax, a = this.ymax;
          break;
        case 10:
          n = 8;
          continue;
        case 8:
          n = 9, o = this.xmin, a = this.ymax;
          break;
        case 9:
          n = 1;
          continue;
        case 1:
          n = 5, o = this.xmin, a = this.ymin;
          break;
      }
      (r[s] !== o || r[s + 1] !== a) && this.contains(t, o, a) && (r.splice(s, 0, o, a), s += 2);
    }
    return s;
  }
  _project(t, n, i, r) {
    let s = 1 / 0, o, a, c;
    if (r < 0) {
      if (n <= this.ymin)
        return null;
      (o = (this.ymin - n) / r) < s && (c = this.ymin, a = t + (s = o) * i);
    } else if (r > 0) {
      if (n >= this.ymax)
        return null;
      (o = (this.ymax - n) / r) < s && (c = this.ymax, a = t + (s = o) * i);
    }
    if (i > 0) {
      if (t >= this.xmax)
        return null;
      (o = (this.xmax - t) / i) < s && (a = this.xmax, c = n + (s = o) * r);
    } else if (i < 0) {
      if (t <= this.xmin)
        return null;
      (o = (this.xmin - t) / i) < s && (a = this.xmin, c = n + (s = o) * r);
    }
    return [a, c];
  }
  _edgecode(t, n) {
    return (t === this.xmin ? 1 : t === this.xmax ? 2 : 0) | (n === this.ymin ? 4 : n === this.ymax ? 8 : 0);
  }
  _regioncode(t, n) {
    return (t < this.xmin ? 1 : t > this.xmax ? 2 : 0) | (n < this.ymin ? 4 : n > this.ymax ? 8 : 0);
  }
  _simplify(t) {
    if (t && t.length > 4) {
      for (let n = 0; n < t.length; n += 2) {
        const i = (n + 2) % t.length, r = (n + 4) % t.length;
        (t[n] === t[i] && t[i] === t[r] || t[n + 1] === t[i + 1] && t[i + 1] === t[r + 1]) && (t.splice(i, 2), n -= 2);
      }
      t.length || (t = null);
    }
    return t;
  }
};
const Gk = 2 * Math.PI, ha = Math.pow;
function Xk(e) {
  return e[0];
}
function Hk(e) {
  return e[1];
}
function Kk(e) {
  const { triangles: t, coords: n } = e;
  for (let i = 0; i < t.length; i += 3) {
    const r = 2 * t[i], s = 2 * t[i + 1], o = 2 * t[i + 2];
    if ((n[o] - n[r]) * (n[s + 1] - n[r + 1]) - (n[s] - n[r]) * (n[o + 1] - n[r + 1]) > 1e-10)
      return !1;
  }
  return !0;
}
function Jk(e, t, n) {
  return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n];
}
class ts {
  static from(t, n = Xk, i = Hk, r) {
    return new ts("length" in t ? Zk(t, n, i, r) : Float64Array.from(Qk(t, n, i, r)));
  }
  constructor(t) {
    this._delaunator = new Sd(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 && Kk(t)) {
      this.collinear = Int32Array.from({ length: n.length / 2 }, (h, d) => d).sort((h, d) => n[2 * h] - n[2 * d] || n[2 * h + 1] - n[2 * d + 1]);
      const c = this.collinear[0], l = this.collinear[this.collinear.length - 1], u = [n[2 * c], n[2 * c + 1], n[2 * l], n[2 * l + 1]], f = 1e-8 * Math.hypot(u[3] - u[1], u[2] - u[0]);
      for (let h = 0, d = n.length / 2; h < d; ++h) {
        const p = Jk(n[2 * h], n[2 * h + 1], f);
        n[2 * h] = p[0], n[2 * h + 1] = p[1];
      }
      this._delaunator = new Sd(n);
    } else
      delete this.collinear;
    const i = this.halfedges = this._delaunator.halfedges, r = this.hull = this._delaunator.hull, s = this.triangles = this._delaunator.triangles, o = this.inedges.fill(-1), a = this._hullIndex.fill(-1);
    for (let c = 0, l = i.length; c < l; ++c) {
      const u = s[c % 3 === 2 ? c - 2 : c + 1];
      (i[c] === -1 || o[u] === -1) && (o[u] = c);
    }
    for (let c = 0, l = r.length; c < l; ++c)
      a[r[c]] = c;
    r.length <= 2 && r.length > 0 && (this.triangles = new Int32Array(3).fill(-1), this.halfedges = new Int32Array(3).fill(-1), this.triangles[0] = r[0], o[r[0]] = 1, r.length === 2 && (o[r[1]] = 0, this.triangles[1] = r[1], this.triangles[2] = r[1]));
  }
  voronoi(t) {
    return new Wk(this, t);
  }
  *neighbors(t) {
    const { inedges: n, hull: i, _hullIndex: r, halfedges: s, triangles: o, collinear: a } = this;
    if (a) {
      const f = a.indexOf(t);
      f > 0 && (yield a[f - 1]), f < a.length - 1 && (yield a[f + 1]);
      return;
    }
    const c = n[t];
    if (c === -1)
      return;
    let l = c, u = -1;
    do {
      if (yield u = o[l], l = l % 3 === 2 ? l - 2 : l + 1, o[l] !== t)
        return;
      if (l = s[l], l === -1) {
        const f = i[(r[t] + 1) % i.length];
        f !== u && (yield f);
        return;
      }
    } while (l !== c);
  }
  find(t, n, i = 0) {
    if (t = +t, t !== t || (n = +n, n !== n))
      return -1;
    const r = i;
    let s;
    for (; (s = this._step(i, t, n)) >= 0 && s !== i && s !== r; )
      i = s;
    return s;
  }
  _step(t, n, i) {
    const { inedges: r, hull: s, _hullIndex: o, halfedges: a, triangles: c, points: l } = this;
    if (r[t] === -1 || !l.length)
      return (t + 1) % (l.length >> 1);
    let u = t, f = ha(n - l[t * 2], 2) + ha(i - l[t * 2 + 1], 2);
    const h = r[t];
    let d = h;
    do {
      let p = c[d];
      const y = ha(n - l[p * 2], 2) + ha(i - l[p * 2 + 1], 2);
      if (y < f && (f = y, u = 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 && ha(n - l[d * 2], 2) + ha(i - l[d * 2 + 1], 2) < f)
          return d;
        break;
      }
    } while (d !== h);
    return u;
  }
  render(t) {
    const n = t == null ? t = new No() : void 0, { points: i, halfedges: r, triangles: s } = this;
    for (let o = 0, a = r.length; o < a; ++o) {
      const c = r[o];
      if (c < o)
        continue;
      const l = s[o] * 2, u = s[c] * 2;
      t.moveTo(i[l], i[l + 1]), t.lineTo(i[u], i[u + 1]);
    }
    return this.renderHull(t), n && n.value();
  }
  renderPoints(t, n) {
    n === void 0 && (!t || typeof t.moveTo != "function") && (n = t, t = null), n = n == null ? 2 : +n;
    const i = t == null ? t = new No() : void 0, { points: r } = this;
    for (let s = 0, o = r.length; s < o; s += 2) {
      const a = r[s], c = r[s + 1];
      t.moveTo(a + n, c), t.arc(a, c, n, 0, Gk);
    }
    return i && i.value();
  }
  renderHull(t) {
    const n = t == null ? t = new No() : void 0, { hull: i, points: r } = this, s = i[0] * 2, o = i.length;
    t.moveTo(r[s], r[s + 1]);
    for (let a = 1; a < o; ++a) {
      const c = 2 * i[a];
      t.lineTo(r[c], r[c + 1]);
    }
    return t.closePath(), n && n.value();
  }
  hullPolygon() {
    const t = new sg();
    return this.renderHull(t), t.value();
  }
  renderTriangle(t, n) {
    const i = n == null ? n = new No() : void 0, { points: r, triangles: s } = this, o = s[t *= 3] * 2, a = s[t + 1] * 2, c = s[t + 2] * 2;
    return n.moveTo(r[o], r[o + 1]), n.lineTo(r[a], r[a + 1]), n.lineTo(r[c], r[c + 1]), n.closePath(), i && i.value();
  }
  *trianglePolygons() {
    const { triangles: t } = this;
    for (let n = 0, i = t.length / 3; n < i; ++n)
      yield this.trianglePolygon(n);
  }
  trianglePolygon(t) {
    const n = new sg();
    return this.renderTriangle(t, n), n.value();
  }
}
function Zk(e, t, n, i) {
  const r = e.length, s = new Float64Array(r * 2);
  for (let o = 0; o < r; ++o) {
    const a = e[o];
    s[o * 2] = t.call(i, a, o, e), s[o * 2 + 1] = n.call(i, a, o, e);
  }
  return s;
}
function* Qk(e, t, n, i) {
  let r = 0;
  for (const s of e)
    yield t.call(i, s, r, e), yield n.call(i, s, r, e), ++r;
}
function t9(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function Id(e, t) {
  if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0)
    return null;
  var n, i = e.slice(0, n);
  return [
    i.length > 1 ? i[0] + i.slice(2) : i,
    +e.slice(n + 1)
  ];
}
function vc(e) {
  return e = Id(Math.abs(e)), e ? e[1] : NaN;
}
function e9(e, t) {
  return function(n, i) {
    for (var r = n.length, s = [], o = 0, a = e[0], c = 0; r > 0 && a > 0 && (c + a + 1 > i && (a = Math.max(1, i - c)), s.push(n.substring(r -= a, r + a)), !((c += a + 1) > i)); )
      a = e[o = (o + 1) % e.length];
    return s.reverse().join(t);
  };
}
function n9(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var i9 = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function mu(e) {
  if (!(t = i9.exec(e)))
    throw new Error("invalid format: " + e);
  var t;
  return new ab({
    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]
  });
}
mu.prototype = ab.prototype;
function ab(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 + "";
}
ab.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 r9(e) {
  t:
    for (var t = e.length, n = 1, i = -1, r; n < t; ++n)
      switch (e[n]) {
        case ".":
          i = r = n;
          break;
        case "0":
          i === 0 && (i = n), r = n;
          break;
        default:
          if (!+e[n])
            break t;
          i > 0 && (i = 0);
          break;
      }
  return i > 0 ? e.slice(0, i) + e.slice(r + 1) : e;
}
var S$;
function s9(e, t) {
  var n = Id(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1], s = r - (S$ = Math.max(-8, Math.min(8, Math.floor(r / 3))) * 3) + 1, o = i.length;
  return s === o ? i : s > o ? i + new Array(s - o + 1).join("0") : s > 0 ? i.slice(0, s) + "." + i.slice(s) : "0." + new Array(1 - s).join("0") + Id(e, Math.max(0, t + s - 1))[0];
}
function Rv(e, t) {
  var n = Id(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1];
  return r < 0 ? "0." + new Array(-r).join("0") + i : i.length > r + 1 ? i.slice(0, r + 1) + "." + i.slice(r + 1) : i + new Array(r - i.length + 2).join("0");
}
const Cv = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: t9,
  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) => Rv(e * 100, t),
  r: Rv,
  s: s9,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function kv(e) {
  return e;
}
var Uv = Array.prototype.map, zv = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function o9(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? kv : e9(Uv.call(e.grouping, Number), e.thousands + ""), n = e.currency === void 0 ? "" : e.currency[0] + "", i = e.currency === void 0 ? "" : e.currency[1] + "", r = e.decimal === void 0 ? "." : e.decimal + "", s = e.numerals === void 0 ? kv : n9(Uv.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 l(f) {
    f = mu(f);
    var h = f.fill, d = f.align, p = f.sign, y = f.symbol, g = f.zero, m = f.width, b = f.comma, _ = f.precision, w = f.trim, v = f.type;
    v === "n" ? (b = !0, v = "g") : Cv[v] || (_ === void 0 && (_ = 12), w = !0, v = "g"), (g || h === "0" && d === "=") && (g = !0, h = "0", d = "=");
    var x = y === "$" ? n : y === "#" && /[boxX]/.test(v) ? "0" + v.toLowerCase() : "", I = y === "$" ? i : /[%p]/.test(v) ? o : "", T = Cv[v], D = /[defgprs%]/.test(v);
    _ = _ === void 0 ? 6 : /[gprs]/.test(v) ? Math.max(1, Math.min(21, _)) : Math.max(0, Math.min(20, _));
    function $(A) {
      var F = x, E = I, S, M, B;
      if (v === "c")
        E = T(A) + E, A = "";
      else {
        A = +A;
        var N = A < 0 || 1 / A < 0;
        if (A = isNaN(A) ? c : T(Math.abs(A), _), w && (A = r9(A)), N && +A == 0 && p !== "+" && (N = !1), F = (N ? p === "(" ? p : a : p === "-" || p === "(" ? "" : p) + F, E = (v === "s" ? zv[8 + S$ / 3] : "") + E + (N && p === "(" ? ")" : ""), D) {
          for (S = -1, M = A.length; ++S < M; )
            if (B = A.charCodeAt(S), 48 > B || B > 57) {
              E = (B === 46 ? r + A.slice(S + 1) : A.slice(S)) + E, A = A.slice(0, S);
              break;
            }
        }
      }
      b && !g && (A = t(A, 1 / 0));
      var L = F.length + A.length + E.length, k = L < m ? new Array(m - L + 1).join(h) : "";
      switch (b && g && (A = t(k + A, k.length ? m - E.length : 1 / 0), k = ""), d) {
        case "<":
          A = F + A + E + k;
          break;
        case "=":
          A = F + k + A + E;
          break;
        case "^":
          A = k.slice(0, L = k.length >> 1) + F + A + E + k.slice(L);
          break;
        default:
          A = k + F + A + E;
          break;
      }
      return s(A);
    }
    return $.toString = function() {
      return f + "";
    }, $;
  }
  function u(f, h) {
    var d = l((f = mu(f), f.type = "f", f)), p = Math.max(-8, Math.min(8, Math.floor(vc(h) / 3))) * 3, y = Math.pow(10, -p), g = zv[8 + p / 3];
    return function(m) {
      return d(y * m) + g;
    };
  }
  return {
    format: l,
    formatPrefix: u
  };
}
var Cf, Wc, I$;
a9({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function a9(e) {
  return Cf = o9(e), Wc = Cf.format, I$ = Cf.formatPrefix, Cf;
}
function c9(e) {
  return Math.max(0, -vc(Math.abs(e)));
}
function l9(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(vc(t) / 3))) * 3 - vc(Math.abs(e)));
}
function u9(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, vc(t) - vc(e)) + 1;
}
var at = 1e-6, $d = 1e-12, Dt = Math.PI, $e = Dt / 2, Pv = Dt / 4, En = Dt * 2, Ve = 180 / Dt, Pt = Dt / 180, qt = Math.abs, Gc = Math.atan, vi = Math.atan2, ct = Math.cos, kf = Math.ceil, $$ = Math.exp, og = Math.hypot, Ad = Math.log, R0 = Math.pow, rt = Math.sin, Hn = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, ln = Math.sqrt, cb = Math.tan;
function A$(e) {
  return e > 1 ? 0 : e < -1 ? Dt : Math.acos(e);
}
function bn(e) {
  return e > 1 ? $e : e < -1 ? -$e : Math.asin(e);
}
function Nn() {
}
function Md(e, t) {
  e && jv.hasOwnProperty(e.type) && jv[e.type](e, t);
}
var Vv = {
  Feature: function(e, t) {
    Md(e.geometry, t);
  },
  FeatureCollection: function(e, t) {
    for (var n = e.features, i = -1, r = n.length; ++i < r; )
      Md(n[i].geometry, t);
  }
}, jv = {
  Sphere: function(e, t) {
    t.sphere();
  },
  Point: function(e, t) {
    e = e.coordinates, t.point(e[0], e[1], e[2]);
  },
  MultiPoint: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      e = n[i], t.point(e[0], e[1], e[2]);
  },
  LineString: function(e, t) {
    ag(e.coordinates, t, 0);
  },
  MultiLineString: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      ag(n[i], t, 0);
  },
  Polygon: function(e, t) {
    Yv(e.coordinates, t);
  },
  MultiPolygon: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      Yv(n[i], t);
  },
  GeometryCollection: function(e, t) {
    for (var n = e.geometries, i = -1, r = n.length; ++i < r; )
      Md(n[i], t);
  }
};
function ag(e, t, n) {
  var i = -1, r = e.length - n, s;
  for (t.lineStart(); ++i < r; )
    s = e[i], t.point(s[0], s[1], s[2]);
  t.lineEnd();
}
function Yv(e, t) {
  var n = -1, i = e.length;
  for (t.polygonStart(); ++n < i; )
    ag(e[n], t, 1);
  t.polygonEnd();
}
function Is(e, t) {
  e && Vv.hasOwnProperty(e.type) ? Vv[e.type](e, t) : Md(e, t);
}
function cg(e) {
  return [vi(e[1], e[0]), bn(e[2])];
}
function xc(e) {
  var t = e[0], n = e[1], i = ct(n);
  return [i * ct(t), i * rt(t), rt(n)];
}
function Uf(e, t) {
  return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
}
function Td(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 C0(e, t) {
  e[0] += t[0], e[1] += t[1], e[2] += t[2];
}
function zf(e, t) {
  return [e[0] * t, e[1] * t, e[2] * t];
}
function lg(e) {
  var t = ln(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= t, e[1] /= t, e[2] /= t;
}
var El, Bd, Nd, Fd, Dd, Od, Ed, Ld, ug, fg, hg, M$, T$, nn, rn, sn, yi = {
  sphere: Nn,
  point: lb,
  lineStart: qv,
  lineEnd: Wv,
  polygonStart: function() {
    yi.lineStart = d9, yi.lineEnd = p9;
  },
  polygonEnd: function() {
    yi.lineStart = qv, yi.lineEnd = Wv;
  }
};
function lb(e, t) {
  e *= Pt, t *= Pt;
  var n = ct(t);
  Ju(n * ct(e), n * rt(e), rt(t));
}
function Ju(e, t, n) {
  ++El, Nd += (e - Nd) / El, Fd += (t - Fd) / El, Dd += (n - Dd) / El;
}
function qv() {
  yi.point = f9;
}
function f9(e, t) {
  e *= Pt, t *= Pt;
  var n = ct(t);
  nn = n * ct(e), rn = n * rt(e), sn = rt(t), yi.point = h9, Ju(nn, rn, sn);
}
function h9(e, t) {
  e *= Pt, t *= Pt;
  var n = ct(t), i = n * ct(e), r = n * rt(e), s = rt(t), o = vi(ln((o = rn * s - sn * r) * o + (o = sn * i - nn * s) * o + (o = nn * r - rn * i) * o), nn * i + rn * r + sn * s);
  Bd += o, Od += o * (nn + (nn = i)), Ed += o * (rn + (rn = r)), Ld += o * (sn + (sn = s)), Ju(nn, rn, sn);
}
function Wv() {
  yi.point = lb;
}
function d9() {
  yi.point = y9;
}
function p9() {
  B$(M$, T$), yi.point = lb;
}
function y9(e, t) {
  M$ = e, T$ = t, e *= Pt, t *= Pt, yi.point = B$;
  var n = ct(t);
  nn = n * ct(e), rn = n * rt(e), sn = rt(t), Ju(nn, rn, sn);
}
function B$(e, t) {
  e *= Pt, t *= Pt;
  var n = ct(t), i = n * ct(e), r = n * rt(e), s = rt(t), o = rn * s - sn * r, a = sn * i - nn * s, c = nn * r - rn * i, l = og(o, a, c), u = bn(l), f = l && -u / l;
  ug.add(f * o), fg.add(f * a), hg.add(f * c), Bd += u, Od += u * (nn + (nn = i)), Ed += u * (rn + (rn = r)), Ld += u * (sn + (sn = s)), Ju(nn, rn, sn);
}
function m9(e) {
  El = Bd = Nd = Fd = Dd = Od = Ed = Ld = 0, ug = new tr(), fg = new tr(), hg = new tr(), Is(e, yi);
  var t = +ug, n = +fg, i = +hg, r = og(t, n, i);
  return r < $d && (t = Od, n = Ed, i = Ld, Bd < at && (t = Nd, n = Fd, i = Dd), r = og(t, n, i), r < $d) ? [NaN, NaN] : [vi(n, t) * Ve, bn(i / r) * Ve];
}
function dg(e, t) {
  function n(i, r) {
    return i = e(i, r), t(i[0], i[1]);
  }
  return e.invert && t.invert && (n.invert = function(i, r) {
    return i = t.invert(i, r), i && e.invert(i[0], i[1]);
  }), n;
}
function pg(e, t) {
  return qt(e) > Dt && (e -= Math.round(e / En) * En), [e, t];
}
pg.invert = pg;
function N$(e, t, n) {
  return (e %= En) ? t || n ? dg(Xv(e), Hv(t, n)) : Xv(e) : t || n ? Hv(t, n) : pg;
}
function Gv(e) {
  return function(t, n) {
    return t += e, qt(t) > Dt && (t -= Math.round(t / En) * En), [t, n];
  };
}
function Xv(e) {
  var t = Gv(e);
  return t.invert = Gv(-e), t;
}
function Hv(e, t) {
  var n = ct(e), i = rt(e), r = ct(t), s = rt(t);
  function o(a, c) {
    var l = ct(c), u = ct(a) * l, f = rt(a) * l, h = rt(c), d = h * n + u * i;
    return [
      vi(f * r - d * s, u * n - h * i),
      bn(d * r + f * s)
    ];
  }
  return o.invert = function(a, c) {
    var l = ct(c), u = ct(a) * l, f = rt(a) * l, h = rt(c), d = h * r - f * s;
    return [
      vi(f * r + h * s, u * n + d * i),
      bn(d * n - u * i)
    ];
  }, o;
}
function g9(e) {
  e = N$(e[0] * Pt, e[1] * Pt, e.length > 2 ? e[2] * Pt : 0);
  function t(n) {
    return n = e(n[0] * Pt, n[1] * Pt), n[0] *= Ve, n[1] *= Ve, n;
  }
  return t.invert = function(n) {
    return n = e.invert(n[0] * Pt, n[1] * Pt), n[0] *= Ve, n[1] *= Ve, n;
  }, t;
}
function b9(e, t, n, i, r, s) {
  if (n) {
    var o = ct(t), a = rt(t), c = i * n;
    r == null ? (r = t + i * En, s = t - c / 2) : (r = Kv(o, r), s = Kv(o, s), (i > 0 ? r < s : r > s) && (r += i * En));
    for (var l, u = r; i > 0 ? u > s : u < s; u -= c)
      l = cg([o, -a * ct(u), -a * rt(u)]), e.point(l[0], l[1]);
  }
}
function Kv(e, t) {
  t = xc(t), t[0] -= e, lg(t);
  var n = A$(-t[1]);
  return ((-t[2] < 0 ? -n : n) + En - at) % En;
}
function F$() {
  var e = [], t;
  return {
    point: function(n, i, r) {
      t.push([n, i, r]);
    },
    lineStart: function() {
      e.push(t = []);
    },
    lineEnd: Nn,
    rejoin: function() {
      e.length > 1 && e.push(e.pop().concat(e.shift()));
    },
    result: function() {
      var n = e;
      return e = [], t = null, n;
    }
  };
}
function $h(e, t) {
  return qt(e[0] - t[0]) < at && qt(e[1] - t[1]) < at;
}
function Pf(e, t, n, i) {
  this.x = e, this.z = t, this.o = n, this.e = i, this.v = !1, this.n = this.p = null;
}
function D$(e, t, n, i, r) {
  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 ($h(g, m)) {
        if (!g[2] && !m[2]) {
          for (r.lineStart(), a = 0; a < y; ++a)
            r.point((g = p[a])[0], g[1]);
          r.lineEnd();
          return;
        }
        m[0] += 2 * at;
      }
      s.push(b = new Pf(g, p, null, !0)), o.push(b.o = new Pf(g, null, b, !1)), s.push(b = new Pf(m, p, null, !1)), o.push(b.o = new Pf(m, null, b, !0));
    }
  }), !!s.length) {
    for (o.sort(t), Jv(s), Jv(o), a = 0, c = o.length; a < c; ++a)
      o[a].e = n = !n;
    for (var l = s[0], u, f; ; ) {
      for (var h = l, d = !0; h.v; )
        if ((h = h.n) === l)
          return;
      u = h.z, r.lineStart();
      do {
        if (h.v = h.o.v = !0, h.e) {
          if (d)
            for (a = 0, c = u.length; a < c; ++a)
              r.point((f = u[a])[0], f[1]);
          else
            i(h.x, h.n.x, 1, r);
          h = h.n;
        } else {
          if (d)
            for (u = h.p.z, a = u.length - 1; a >= 0; --a)
              r.point((f = u[a])[0], f[1]);
          else
            i(h.x, h.p.x, -1, r);
          h = h.p;
        }
        h = h.o, u = h.z, d = !d;
      } while (!h.v);
      r.lineEnd();
    }
  }
}
function Jv(e) {
  if (t = e.length) {
    for (var t, n = 0, i = e[0], r; ++n < t; )
      i.n = r = e[n], r.p = i, i = r;
    i.n = r = e[0], r.p = i;
  }
}
function k0(e) {
  return qt(e[0]) <= Dt ? e[0] : Hn(e[0]) * ((qt(e[0]) + Dt) % En - Dt);
}
function _9(e, t) {
  var n = k0(t), i = t[1], r = rt(i), s = [rt(n), -ct(n), 0], o = 0, a = 0, c = new tr();
  r === 1 ? i = $e + at : r === -1 && (i = -$e - at);
  for (var l = 0, u = e.length; l < u; ++l)
    if (h = (f = e[l]).length)
      for (var f, h, d = f[h - 1], p = k0(d), y = d[1] / 2 + Pv, g = rt(y), m = ct(y), b = 0; b < h; ++b, p = w, g = x, m = I, d = _) {
        var _ = f[b], w = k0(_), v = _[1] / 2 + Pv, x = rt(v), I = ct(v), T = w - p, D = T >= 0 ? 1 : -1, $ = D * T, A = $ > Dt, F = g * x;
        if (c.add(vi(F * D * rt($), m * I + F * ct($))), o += A ? T + D * En : T, A ^ p >= n ^ w >= n) {
          var E = Td(xc(d), xc(_));
          lg(E);
          var S = Td(s, E);
          lg(S);
          var M = (A ^ T >= 0 ? -1 : 1) * bn(S[2]);
          (i > M || i === M && (E[0] || E[1])) && (a += A ^ T >= 0 ? 1 : -1);
        }
      }
  return (o < -at || o < at && c < -$d) ^ a & 1;
}
function O$(e, t, n, i) {
  return function(r) {
    var s = t(r), o = F$(), a = t(o), c = !1, l, u, f, h = {
      point: d,
      lineStart: y,
      lineEnd: g,
      polygonStart: function() {
        h.point = m, h.lineStart = b, h.lineEnd = _, u = [], l = [];
      },
      polygonEnd: function() {
        h.point = d, h.lineStart = y, h.lineEnd = g, u = L3(u);
        var w = _9(l, i);
        u.length ? (c || (r.polygonStart(), c = !0), D$(u, v9, w, n, r)) : w && (c || (r.polygonStart(), c = !0), r.lineStart(), n(null, null, 1, r), r.lineEnd()), c && (r.polygonEnd(), c = !1), u = l = null;
      },
      sphere: function() {
        r.polygonStart(), r.lineStart(), n(null, null, 1, r), r.lineEnd(), r.polygonEnd();
      }
    };
    function d(w, v) {
      e(w, v) && r.point(w, v);
    }
    function p(w, v) {
      s.point(w, v);
    }
    function y() {
      h.point = p, s.lineStart();
    }
    function g() {
      h.point = d, s.lineEnd();
    }
    function m(w, v) {
      f.push([w, v]), a.point(w, v);
    }
    function b() {
      a.lineStart(), f = [];
    }
    function _() {
      m(f[0][0], f[0][1]), a.lineEnd();
      var w = a.clean(), v = o.result(), x, I = v.length, T, D, $;
      if (f.pop(), l.push(f), f = null, !!I) {
        if (w & 1) {
          if (D = v[0], (T = D.length - 1) > 0) {
            for (c || (r.polygonStart(), c = !0), r.lineStart(), x = 0; x < T; ++x)
              r.point(($ = D[x])[0], $[1]);
            r.lineEnd();
          }
          return;
        }
        I > 1 && w & 2 && v.push(v.pop().concat(v.shift())), u.push(v.filter(w9));
      }
    }
    return h;
  };
}
function w9(e) {
  return e.length > 1;
}
function v9(e, t) {
  return ((e = e.x)[0] < 0 ? e[1] - $e - at : $e - e[1]) - ((t = t.x)[0] < 0 ? t[1] - $e - at : $e - t[1]);
}
const Zv = O$(
  function() {
    return !0;
  },
  x9,
  I9,
  [-Dt, -$e]
);
function x9(e) {
  var t = NaN, n = NaN, i = NaN, r;
  return {
    lineStart: function() {
      e.lineStart(), r = 1;
    },
    point: function(s, o) {
      var a = s > 0 ? Dt : -Dt, c = qt(s - t);
      qt(c - Dt) < at ? (e.point(t, n = (n + o) / 2 > 0 ? $e : -$e), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), e.point(s, n), r = 0) : i !== a && c >= Dt && (qt(t - i) < at && (t -= i * at), qt(s - a) < at && (s -= a * at), n = S9(t, n, s, o), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), r = 0), e.point(t = s, n = o), i = a;
    },
    lineEnd: function() {
      e.lineEnd(), t = n = NaN;
    },
    clean: function() {
      return 2 - r;
    }
  };
}
function S9(e, t, n, i) {
  var r, s, o = rt(e - n);
  return qt(o) > at ? Gc((rt(t) * (s = ct(i)) * rt(n) - rt(i) * (r = ct(t)) * rt(e)) / (r * s * o)) : (t + i) / 2;
}
function I9(e, t, n, i) {
  var r;
  if (e == null)
    r = n * $e, i.point(-Dt, r), i.point(0, r), i.point(Dt, r), i.point(Dt, 0), i.point(Dt, -r), i.point(0, -r), i.point(-Dt, -r), i.point(-Dt, 0), i.point(-Dt, r);
  else if (qt(e[0] - t[0]) > at) {
    var s = e[0] < t[0] ? Dt : -Dt;
    r = n * s / 2, i.point(-s, r), i.point(0, r), i.point(s, r);
  } else
    i.point(t[0], t[1]);
}
function $9(e) {
  var t = ct(e), n = 6 * Pt, i = t > 0, r = qt(t) > at;
  function s(u, f, h, d) {
    b9(d, e, n, h, u, f);
  }
  function o(u, f) {
    return ct(u) * ct(f) > t;
  }
  function a(u) {
    var f, h, d, p, y;
    return {
      lineStart: function() {
        p = d = !1, y = 1;
      },
      point: function(g, m) {
        var b = [g, m], _, w = o(g, m), v = i ? w ? 0 : l(g, m) : w ? l(g + (g < 0 ? Dt : -Dt), m) : 0;
        if (!f && (p = d = w) && u.lineStart(), w !== d && (_ = c(f, b), (!_ || $h(f, _) || $h(b, _)) && (b[2] = 1)), w !== d)
          y = 0, w ? (u.lineStart(), _ = c(b, f), u.point(_[0], _[1])) : (_ = c(f, b), u.point(_[0], _[1], 2), u.lineEnd()), f = _;
        else if (r && f && i ^ w) {
          var x;
          !(v & h) && (x = c(b, f, !0)) && (y = 0, i ? (u.lineStart(), u.point(x[0][0], x[0][1]), u.point(x[1][0], x[1][1]), u.lineEnd()) : (u.point(x[1][0], x[1][1]), u.lineEnd(), u.lineStart(), u.point(x[0][0], x[0][1], 3)));
        }
        w && (!f || !$h(f, b)) && u.point(b[0], b[1]), f = b, d = w, h = v;
      },
      lineEnd: function() {
        d && u.lineEnd(), f = null;
      },
      // Rejoin first and last segments if there were intersections and the first
      // and last points were visible.
      clean: function() {
        return y | (p && d) << 1;
      }
    };
  }
  function c(u, f, h) {
    var d = xc(u), p = xc(f), y = [1, 0, 0], g = Td(d, p), m = Uf(g, g), b = g[0], _ = m - b * b;
    if (!_)
      return !h && u;
    var w = t * m / _, v = -t * b / _, x = Td(y, g), I = zf(y, w), T = zf(g, v);
    C0(I, T);
    var D = x, $ = Uf(I, D), A = Uf(D, D), F = $ * $ - A * (Uf(I, I) - 1);
    if (!(F < 0)) {
      var E = ln(F), S = zf(D, (-$ - E) / A);
      if (C0(S, I), S = cg(S), !h)
        return S;
      var M = u[0], B = f[0], N = u[1], L = f[1], k;
      B < M && (k = M, M = B, B = k);
      var U = B - M, j = qt(U - Dt) < at, P = j || U < at;
      if (!j && L < N && (k = N, N = L, L = k), P ? j ? N + L > 0 ^ S[1] < (qt(S[0] - M) < at ? N : L) : N <= S[1] && S[1] <= L : U > Dt ^ (M <= S[0] && S[0] <= B)) {
        var K = zf(D, (-$ + E) / A);
        return C0(K, I), [S, cg(K)];
      }
    }
  }
  function l(u, f) {
    var h = i ? e : Dt - e, d = 0;
    return u < -h ? d |= 1 : u > h && (d |= 2), f < -h ? d |= 4 : f > h && (d |= 8), d;
  }
  return O$(o, a, s, i ? [0, -e] : [-Dt, e - Dt]);
}
function A9(e, t, n, i, r, s) {
  var o = e[0], a = e[1], c = t[0], l = t[1], u = 0, f = 1, h = c - o, d = l - a, p;
  if (p = n - o, !(!h && p > 0)) {
    if (p /= h, h < 0) {
      if (p < u)
        return;
      p < f && (f = p);
    } else if (h > 0) {
      if (p > f)
        return;
      p > u && (u = p);
    }
    if (p = r - o, !(!h && p < 0)) {
      if (p /= h, h < 0) {
        if (p > f)
          return;
        p > u && (u = p);
      } else if (h > 0) {
        if (p < u)
          return;
        p < f && (f = p);
      }
      if (p = i - a, !(!d && p > 0)) {
        if (p /= d, d < 0) {
          if (p < u)
            return;
          p < f && (f = p);
        } else if (d > 0) {
          if (p > f)
            return;
          p > u && (u = p);
        }
        if (p = s - a, !(!d && p < 0)) {
          if (p /= d, d < 0) {
            if (p > f)
              return;
            p > u && (u = p);
          } else if (d > 0) {
            if (p < u)
              return;
            p < f && (f = p);
          }
          return u > 0 && (e[0] = o + u * h, e[1] = a + u * d), f < 1 && (t[0] = o + f * h, t[1] = a + f * d), !0;
        }
      }
    }
  }
}
var Ll = 1e9, Vf = -Ll;
function E$(e, t, n, i) {
  function r(l, u) {
    return e <= l && l <= n && t <= u && u <= i;
  }
  function s(l, u, f, h) {
    var d = 0, p = 0;
    if (l == null || (d = o(l, f)) !== (p = o(u, f)) || c(l, u) < 0 ^ f > 0)
      do
        h.point(d === 0 || d === 3 ? e : n, d > 1 ? i : t);
      while ((d = (d + f + 4) % 4) !== p);
    else
      h.point(u[0], u[1]);
  }
  function o(l, u) {
    return qt(l[0] - e) < at ? u > 0 ? 0 : 3 : qt(l[0] - n) < at ? u > 0 ? 2 : 1 : qt(l[1] - t) < at ? u > 0 ? 1 : 0 : u > 0 ? 3 : 2;
  }
  function a(l, u) {
    return c(l.x, u.x);
  }
  function c(l, u) {
    var f = o(l, 1), h = o(u, 1);
    return f !== h ? f - h : f === 0 ? u[1] - l[1] : f === 1 ? l[0] - u[0] : f === 2 ? l[1] - u[1] : u[0] - l[0];
  }
  return function(l) {
    var u = l, f = F$(), h, d, p, y, g, m, b, _, w, v, x, I = {
      point: T,
      lineStart: F,
      lineEnd: E,
      polygonStart: $,
      polygonEnd: A
    };
    function T(M, B) {
      r(M, B) && u.point(M, B);
    }
    function D() {
      for (var M = 0, B = 0, N = d.length; B < N; ++B)
        for (var L = d[B], k = 1, U = L.length, j = L[0], P, K, Z = j[0], et = j[1]; k < U; ++k)
          P = Z, K = et, j = L[k], Z = j[0], et = j[1], K <= i ? et > i && (Z - P) * (i - K) > (et - K) * (e - P) && ++M : et <= i && (Z - P) * (i - K) < (et - K) * (e - P) && --M;
      return M;
    }
    function $() {
      u = f, h = [], d = [], x = !0;
    }
    function A() {
      var M = D(), B = x && M, N = (h = L3(h)).length;
      (B || N) && (l.polygonStart(), B && (l.lineStart(), s(null, null, 1, l), l.lineEnd()), N && D$(h, a, M, s, l), l.polygonEnd()), u = l, h = d = p = null;
    }
    function F() {
      I.point = S, d && d.push(p = []), v = !0, w = !1, b = _ = NaN;
    }
    function E() {
      h && (S(y, g), m && w && f.rejoin(), h.push(f.result())), I.point = T, w && u.lineEnd();
    }
    function S(M, B) {
      var N = r(M, B);
      if (d && p.push([M, B]), v)
        y = M, g = B, m = N, v = !1, N && (u.lineStart(), u.point(M, B));
      else if (N && w)
        u.point(M, B);
      else {
        var L = [b = Math.max(Vf, Math.min(Ll, b)), _ = Math.max(Vf, Math.min(Ll, _))], k = [M = Math.max(Vf, Math.min(Ll, M)), B = Math.max(Vf, Math.min(Ll, B))];
        A9(L, k, e, t, n, i) ? (w || (u.lineStart(), u.point(L[0], L[1])), u.point(k[0], k[1]), N || u.lineEnd(), x = !1) : N && (u.lineStart(), u.point(M, B), x = !1);
      }
      b = M, _ = B, w = N;
    }
    return I;
  };
}
function Qv(e, t, n) {
  var i = Bn(e, t - at, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [r, s];
    });
  };
}
function t2(e, t, n) {
  var i = Bn(e, t - at, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [s, r];
    });
  };
}
function M9() {
  var e, t, n, i, r, s, o, a, c = 10, l = c, u = 90, f = 360, h, d, p, y, g = 2.5;
  function m() {
    return { type: "MultiLineString", coordinates: b() };
  }
  function b() {
    return Bn(kf(i / u) * u, n, u).map(p).concat(Bn(kf(a / f) * f, o, f).map(y)).concat(Bn(kf(t / c) * c, e, c).filter(function(_) {
      return qt(_ % u) > at;
    }).map(h)).concat(Bn(kf(s / l) * l, r, l).filter(function(_) {
      return qt(_ % f) > at;
    }).map(d));
  }
  return m.lines = function() {
    return b().map(function(_) {
      return { type: "LineString", coordinates: _ };
    });
  }, m.outline = function() {
    return {
      type: "Polygon",
      coordinates: [
        p(i).concat(
          y(o).slice(1),
          p(n).reverse().slice(1),
          y(a).reverse().slice(1)
        )
      ]
    };
  }, m.extent = function(_) {
    return arguments.length ? m.extentMajor(_).extentMinor(_) : m.extentMinor();
  }, m.extentMajor = function(_) {
    return arguments.length ? (i = +_[0][0], n = +_[1][0], a = +_[0][1], o = +_[1][1], i > n && (_ = i, i = n, n = _), a > o && (_ = a, a = o, o = _), m.precision(g)) : [[i, a], [n, o]];
  }, m.extentMinor = function(_) {
    return arguments.length ? (t = +_[0][0], e = +_[1][0], s = +_[0][1], r = +_[1][1], t > e && (_ = t, t = e, e = _), s > r && (_ = s, s = r, r = _), m.precision(g)) : [[t, s], [e, r]];
  }, m.step = function(_) {
    return arguments.length ? m.stepMajor(_).stepMinor(_) : m.stepMinor();
  }, m.stepMajor = function(_) {
    return arguments.length ? (u = +_[0], f = +_[1], m) : [u, f];
  }, m.stepMinor = function(_) {
    return arguments.length ? (c = +_[0], l = +_[1], m) : [c, l];
  }, m.precision = function(_) {
    return arguments.length ? (g = +_, h = Qv(s, r, 90), d = t2(t, e, g), p = Qv(a, o, 90), y = t2(i, n, g), m) : g;
  }, m.extentMajor([[-180, -90 + at], [180, 90 - at]]).extentMinor([[-180, -80 - at], [180, 80 + at]]);
}
function T9() {
  return M9()();
}
const yg = (e) => e;
var U0 = new tr(), mg = new tr(), L$, R$, gg, bg, $s = {
  point: Nn,
  lineStart: Nn,
  lineEnd: Nn,
  polygonStart: function() {
    $s.lineStart = B9, $s.lineEnd = F9;
  },
  polygonEnd: function() {
    $s.lineStart = $s.lineEnd = $s.point = Nn, U0.add(qt(mg)), mg = new tr();
  },
  result: function() {
    var e = U0 / 2;
    return U0 = new tr(), e;
  }
};
function B9() {
  $s.point = N9;
}
function N9(e, t) {
  $s.point = C$, L$ = gg = e, R$ = bg = t;
}
function C$(e, t) {
  mg.add(bg * e - gg * t), gg = e, bg = t;
}
function F9() {
  C$(L$, R$);
}
const e2 = $s;
var Sc = 1 / 0, Rd = Sc, gu = -Sc, Cd = gu, D9 = {
  point: O9,
  lineStart: Nn,
  lineEnd: Nn,
  polygonStart: Nn,
  polygonEnd: Nn,
  result: function() {
    var e = [[Sc, Rd], [gu, Cd]];
    return gu = Cd = -(Rd = Sc = 1 / 0), e;
  }
};
function O9(e, t) {
  e < Sc && (Sc = e), e > gu && (gu = e), t < Rd && (Rd = t), t > Cd && (Cd = t);
}
const kd = D9;
var _g = 0, wg = 0, Rl = 0, Ud = 0, zd = 0, ka = 0, vg = 0, xg = 0, Cl = 0, k$, U$, Yi, qi, hi = {
  point: Ko,
  lineStart: n2,
  lineEnd: i2,
  polygonStart: function() {
    hi.lineStart = R9, hi.lineEnd = C9;
  },
  polygonEnd: function() {
    hi.point = Ko, hi.lineStart = n2, hi.lineEnd = i2;
  },
  result: function() {
    var e = Cl ? [vg / Cl, xg / Cl] : ka ? [Ud / ka, zd / ka] : Rl ? [_g / Rl, wg / Rl] : [NaN, NaN];
    return _g = wg = Rl = Ud = zd = ka = vg = xg = Cl = 0, e;
  }
};
function Ko(e, t) {
  _g += e, wg += t, ++Rl;
}
function n2() {
  hi.point = E9;
}
function E9(e, t) {
  hi.point = L9, Ko(Yi = e, qi = t);
}
function L9(e, t) {
  var n = e - Yi, i = t - qi, r = ln(n * n + i * i);
  Ud += r * (Yi + e) / 2, zd += r * (qi + t) / 2, ka += r, Ko(Yi = e, qi = t);
}
function i2() {
  hi.point = Ko;
}
function R9() {
  hi.point = k9;
}
function C9() {
  z$(k$, U$);
}
function k9(e, t) {
  hi.point = z$, Ko(k$ = Yi = e, U$ = qi = t);
}
function z$(e, t) {
  var n = e - Yi, i = t - qi, r = ln(n * n + i * i);
  Ud += r * (Yi + e) / 2, zd += r * (qi + t) / 2, ka += r, r = qi * e - Yi * t, vg += r * (Yi + e), xg += r * (qi + t), Cl += r * 3, Ko(Yi = e, qi = t);
}
const r2 = hi;
function P$(e) {
  this._context = e;
}
P$.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: Nn
};
var Sg = new tr(), z0, V$, j$, kl, Ul, Pd = {
  point: Nn,
  lineStart: function() {
    Pd.point = U9;
  },
  lineEnd: function() {
    z0 && Y$(V$, j$), Pd.point = Nn;
  },
  polygonStart: function() {
    z0 = !0;
  },
  polygonEnd: function() {
    z0 = null;
  },
  result: function() {
    var e = +Sg;
    return Sg = new tr(), e;
  }
};
function U9(e, t) {
  Pd.point = Y$, V$ = kl = e, j$ = Ul = t;
}
function Y$(e, t) {
  kl -= e, Ul -= t, Sg.add(ln(kl * kl + Ul * Ul)), kl = e, Ul = t;
}
const s2 = Pd;
let o2, Vd, a2, c2;
class l2 {
  constructor(t) {
    this._append = t == null ? q$ : z9(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 !== a2 || this._append !== Vd) {
          const i = this._radius, r = this._;
          this._ = "", this._append`m0,${i}a${i},${i} 0 1,1 0,${-2 * i}a${i},${i} 0 1,1 0,${2 * i}z`, a2 = i, Vd = this._append, c2 = this._, this._ = r;
        }
        this._ += c2;
        break;
      }
    }
  }
  result() {
    const t = this._;
    return this._ = "", t.length ? t : null;
  }
}
function q$(e) {
  let t = 1;
  this._ += e[0];
  for (const n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function z9(e) {
  const t = Math.floor(e);
  if (!(t >= 0))
    throw new RangeError(`invalid digits: ${e}`);
  if (t > 15)
    return q$;
  if (t !== o2) {
    const n = 10 ** t;
    o2 = t, Vd = function(r) {
      let s = 1;
      this._ += r[0];
      for (const o = r.length; s < o; ++s)
        this._ += Math.round(arguments[s] * n) / n + r[s];
    };
  }
  return Vd;
}
function to(e, t) {
  let n = 3, i = 4.5, r, s;
  function o(a) {
    return a && (typeof i == "function" && s.pointRadius(+i.apply(this, arguments)), Is(a, r(s))), s.result();
  }
  return o.area = function(a) {
    return Is(a, r(e2)), e2.result();
  }, o.measure = function(a) {
    return Is(a, r(s2)), s2.result();
  }, o.bounds = function(a) {
    return Is(a, r(kd)), kd.result();
  }, o.centroid = function(a) {
    return Is(a, r(r2)), r2.result();
  }, o.projection = function(a) {
    return arguments.length ? (r = a == null ? (e = null, yg) : (e = a).stream, o) : e;
  }, o.context = function(a) {
    return arguments.length ? (s = a == null ? (t = null, new l2(n)) : new P$(t = a), typeof i != "function" && s.pointRadius(i), o) : t;
  }, o.pointRadius = function(a) {
    return arguments.length ? (i = typeof a == "function" ? a : (s.pointRadius(+a), +a), o) : i;
  }, o.digits = function(a) {
    if (!arguments.length)
      return n;
    if (a == null)
      n = null;
    else {
      const c = Math.floor(a);
      if (!(c >= 0))
        throw new RangeError(`invalid digits: ${a}`);
      n = c;
    }
    return t === null && (s = new l2(n)), o;
  }, o.projection(e).digits(n).context(t);
}
function jd(e) {
  return {
    stream: dy(e)
  };
}
function dy(e) {
  return function(t) {
    var n = new Ig();
    for (var i in e)
      n[i] = e[i];
    return n.stream = t, n;
  };
}
function Ig() {
}
Ig.prototype = {
  constructor: Ig,
  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 ub(e, t, n) {
  var i = e.clipExtent && e.clipExtent();
  return e.scale(150).translate([0, 0]), i != null && e.clipExtent(null), Is(n, e.stream(kd)), t(kd.result()), i != null && e.clipExtent(i), e;
}
function fb(e, t, n) {
  return ub(e, function(i) {
    var r = t[1][0] - t[0][0], s = t[1][1] - t[0][1], o = Math.min(r / (i[1][0] - i[0][0]), s / (i[1][1] - i[0][1])), a = +t[0][0] + (r - o * (i[1][0] + i[0][0])) / 2, c = +t[0][1] + (s - o * (i[1][1] + i[0][1])) / 2;
    e.scale(150 * o).translate([a, c]);
  }, n);
}
function W$(e, t, n) {
  return fb(e, [[0, 0], t], n);
}
function G$(e, t, n) {
  return ub(e, function(i) {
    var r = +t, s = r / (i[1][0] - i[0][0]), o = (r - s * (i[1][0] + i[0][0])) / 2, a = -s * i[0][1];
    e.scale(150 * s).translate([o, a]);
  }, n);
}
function X$(e, t, n) {
  return ub(e, function(i) {
    var r = +t, s = r / (i[1][1] - i[0][1]), o = -s * i[0][0], a = (r - s * (i[1][1] + i[0][1])) / 2;
    e.scale(150 * s).translate([o, a]);
  }, n);
}
var u2 = 16, P9 = ct(30 * Pt);
function f2(e, t) {
  return +t ? j9(e, t) : V9(e);
}
function V9(e) {
  return dy({
    point: function(t, n) {
      t = e(t, n), this.stream.point(t[0], t[1]);
    }
  });
}
function j9(e, t) {
  function n(i, r, s, o, a, c, l, u, f, h, d, p, y, g) {
    var m = l - i, b = u - r, _ = m * m + b * b;
    if (_ > 4 * t && y--) {
      var w = o + h, v = a + d, x = c + p, I = ln(w * w + v * v + x * x), T = bn(x /= I), D = qt(qt(x) - 1) < at || qt(s - f) < at ? (s + f) / 2 : vi(v, w), $ = e(D, T), A = $[0], F = $[1], E = A - i, S = F - r, M = b * E - m * S;
      (M * M / _ > t || qt((m * E + b * S) / _ - 0.5) > 0.3 || o * h + a * d + c * p < P9) && (n(i, r, s, o, a, c, A, F, D, w /= I, v /= I, x, y, g), g.point(A, F), n(A, F, D, w, v, x, l, u, f, h, d, p, y, g));
    }
  }
  return function(i) {
    var r, s, o, a, c, l, u, f, h, d, p, y, g = {
      point: m,
      lineStart: b,
      lineEnd: w,
      polygonStart: function() {
        i.polygonStart(), g.lineStart = v;
      },
      polygonEnd: function() {
        i.polygonEnd(), g.lineStart = b;
      }
    };
    function m(T, D) {
      T = e(T, D), i.point(T[0], T[1]);
    }
    function b() {
      f = NaN, g.point = _, i.lineStart();
    }
    function _(T, D) {
      var $ = xc([T, D]), A = e(T, D);
      n(f, h, u, d, p, y, f = A[0], h = A[1], u = T, d = $[0], p = $[1], y = $[2], u2, i), i.point(f, h);
    }
    function w() {
      g.point = m, i.lineEnd();
    }
    function v() {
      b(), g.point = x, g.lineEnd = I;
    }
    function x(T, D) {
      _(r = T, D), s = f, o = h, a = d, c = p, l = y, g.point = _;
    }
    function I() {
      n(f, h, u, d, p, y, s, o, r, a, c, l, u2, i), g.lineEnd = w, w();
    }
    return g;
  };
}
var Y9 = dy({
  point: function(e, t) {
    this.stream.point(e * Pt, t * Pt);
  }
});
function q9(e) {
  return dy({
    point: function(t, n) {
      var i = e(t, n);
      return this.stream.point(i[0], i[1]);
    }
  });
}
function W9(e, t, n, i, r) {
  function s(o, a) {
    return o *= i, a *= r, [t + e * o, n - e * a];
  }
  return s.invert = function(o, a) {
    return [(o - t) / e * i, (n - a) / e * r];
  }, s;
}
function h2(e, t, n, i, r, s) {
  if (!s)
    return W9(e, t, n, i, r);
  var o = ct(s), a = rt(s), c = o * e, l = a * e, u = o / e, f = a / e, h = (a * n - o * t) / e, d = (a * t + o * n) / e;
  function p(y, g) {
    return y *= i, g *= r, [c * y - l * g + t, n - l * y - c * g];
  }
  return p.invert = function(y, g) {
    return [i * (u * y - f * g + h), r * (d - f * y - u * g)];
  }, p;
}
function eo(e) {
  return H$(function() {
    return e;
  })();
}
function H$(e) {
  var t, n = 150, i = 480, r = 250, s = 0, o = 0, a = 0, c = 0, l = 0, u, f = 0, h = 1, d = 1, p = null, y = Zv, g = null, m, b, _, w = yg, v = 0.5, x, I, T, D, $;
  function A(M) {
    return T(M[0] * Pt, M[1] * Pt);
  }
  function F(M) {
    return M = T.invert(M[0], M[1]), M && [M[0] * Ve, M[1] * Ve];
  }
  A.stream = function(M) {
    return D && $ === M ? D : D = Y9(q9(u)(y(x(w($ = M)))));
  }, A.preclip = function(M) {
    return arguments.length ? (y = M, p = void 0, S()) : y;
  }, A.postclip = function(M) {
    return arguments.length ? (w = M, g = m = b = _ = null, S()) : w;
  }, A.clipAngle = function(M) {
    return arguments.length ? (y = +M ? $9(p = M * Pt) : (p = null, Zv), S()) : p * Ve;
  }, A.clipExtent = function(M) {
    return arguments.length ? (w = M == null ? (g = m = b = _ = null, yg) : E$(g = +M[0][0], m = +M[0][1], b = +M[1][0], _ = +M[1][1]), S()) : g == null ? null : [[g, m], [b, _]];
  }, A.scale = function(M) {
    return arguments.length ? (n = +M, E()) : n;
  }, A.translate = function(M) {
    return arguments.length ? (i = +M[0], r = +M[1], E()) : [i, r];
  }, A.center = function(M) {
    return arguments.length ? (s = M[0] % 360 * Pt, o = M[1] % 360 * Pt, E()) : [s * Ve, o * Ve];
  }, A.rotate = function(M) {
    return arguments.length ? (a = M[0] % 360 * Pt, c = M[1] % 360 * Pt, l = M.length > 2 ? M[2] % 360 * Pt : 0, E()) : [a * Ve, c * Ve, l * Ve];
  }, A.angle = function(M) {
    return arguments.length ? (f = M % 360 * Pt, E()) : f * Ve;
  }, A.reflectX = function(M) {
    return arguments.length ? (h = M ? -1 : 1, E()) : h < 0;
  }, A.reflectY = function(M) {
    return arguments.length ? (d = M ? -1 : 1, E()) : d < 0;
  }, A.precision = function(M) {
    return arguments.length ? (x = f2(I, v = M * M), S()) : ln(v);
  }, A.fitExtent = function(M, B) {
    return fb(A, M, B);
  }, A.fitSize = function(M, B) {
    return W$(A, M, B);
  }, A.fitWidth = function(M, B) {
    return G$(A, M, B);
  }, A.fitHeight = function(M, B) {
    return X$(A, M, B);
  };
  function E() {
    var M = h2(n, 0, 0, h, d, f).apply(null, t(s, o)), B = h2(n, i - M[0], r - M[1], h, d, f);
    return u = N$(a, c, l), I = dg(t, B), T = dg(u, I), x = f2(I, v), S();
  }
  function S() {
    return D = $ = null, A;
  }
  return function() {
    return t = e.apply(this, arguments), A.invert = t.invert && F, E();
  };
}
function hb(e) {
  var t = 0, n = Dt / 3, i = H$(e), r = i(t, n);
  return r.parallels = function(s) {
    return arguments.length ? i(t = s[0] * Pt, n = s[1] * Pt) : [t * Ve, n * Ve];
  }, r;
}
function G9(e) {
  var t = ct(e);
  function n(i, r) {
    return [i * t, rt(r) / t];
  }
  return n.invert = function(i, r) {
    return [i / t, bn(r * t)];
  }, n;
}
function X9(e, t) {
  var n = rt(e), i = (n + rt(t)) / 2;
  if (qt(i) < at)
    return G9(e);
  var r = 1 + n * (2 * i - n), s = ln(r) / i;
  function o(a, c) {
    var l = ln(r - 2 * i * rt(c)) / i;
    return [l * rt(a *= i), s - l * ct(a)];
  }
  return o.invert = function(a, c) {
    var l = s - c, u = vi(a, qt(l)) * Hn(l);
    return l * i < 0 && (u -= Dt * Hn(a) * Hn(l)), [u / i, bn((r - (a * a + l * l) * i * i) / (2 * i))];
  }, o;
}
function Yd() {
  return hb(X9).scale(155.424).center([0, 33.6442]);
}
function K$() {
  return Yd().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
}
function H9(e) {
  var t = e.length;
  return {
    point: function(n, i) {
      for (var r = -1; ++r < t; )
        e[r].point(n, i);
    },
    sphere: function() {
      for (var n = -1; ++n < t; )
        e[n].sphere();
    },
    lineStart: function() {
      for (var n = -1; ++n < t; )
        e[n].lineStart();
    },
    lineEnd: function() {
      for (var n = -1; ++n < t; )
        e[n].lineEnd();
    },
    polygonStart: function() {
      for (var n = -1; ++n < t; )
        e[n].polygonStart();
    },
    polygonEnd: function() {
      for (var n = -1; ++n < t; )
        e[n].polygonEnd();
    }
  };
}
function K9() {
  var e, t, n = K$(), i, r = Yd().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), s, o = Yd().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), a, c, l = { point: function(h, d) {
    c = [h, d];
  } };
  function u(h) {
    var d = h[0], p = h[1];
    return c = null, i.point(d, p), c || (s.point(d, p), c) || (a.point(d, p), c);
  }
  u.invert = function(h) {
    var d = n.scale(), p = n.translate(), y = (h[0] - p[0]) / d, g = (h[1] - p[1]) / d;
    return (g >= 0.12 && g < 0.234 && y >= -0.425 && y < -0.214 ? r : g >= 0.166 && g < 0.234 && y >= -0.214 && y < -0.115 ? o : n).invert(h);
  }, u.stream = function(h) {
    return e && t === h ? e : e = H9([n.stream(t = h), r.stream(h), o.stream(h)]);
  }, u.precision = function(h) {
    return arguments.length ? (n.precision(h), r.precision(h), o.precision(h), f()) : n.precision();
  }, u.scale = function(h) {
    return arguments.length ? (n.scale(h), r.scale(h * 0.35), o.scale(h), u.translate(n.translate())) : n.scale();
  }, u.translate = function(h) {
    if (!arguments.length)
      return n.translate();
    var d = n.scale(), p = +h[0], y = +h[1];
    return i = n.translate(h).clipExtent([[p - 0.455 * d, y - 0.238 * d], [p + 0.455 * d, y + 0.238 * d]]).stream(l), s = r.translate([p - 0.307 * d, y + 0.201 * d]).clipExtent([[p - 0.425 * d + at, y + 0.12 * d + at], [p - 0.214 * d - at, y + 0.234 * d - at]]).stream(l), a = o.translate([p - 0.205 * d, y + 0.212 * d]).clipExtent([[p - 0.214 * d + at, y + 0.166 * d + at], [p - 0.115 * d - at, y + 0.234 * d - at]]).stream(l), f();
  }, u.fitExtent = function(h, d) {
    return fb(u, h, d);
  }, u.fitSize = function(h, d) {
    return W$(u, h, d);
  }, u.fitWidth = function(h, d) {
    return G$(u, h, d);
  }, u.fitHeight = function(h, d) {
    return X$(u, h, d);
  };
  function f() {
    return e = t = null, u;
  }
  return u.scale(1070);
}
function J$(e) {
  return function(t, n) {
    var i = ct(t), r = ct(n), s = e(i * r);
    return s === 1 / 0 ? [2, 0] : [
      s * r * rt(t),
      s * rt(n)
    ];
  };
}
function Zu(e) {
  return function(t, n) {
    var i = ln(t * t + n * n), r = e(i), s = rt(r), o = ct(r);
    return [
      vi(t * s, i * o),
      bn(i && n * s / i)
    ];
  };
}
var Z$ = J$(function(e) {
  return ln(2 / (1 + e));
});
Z$.invert = Zu(function(e) {
  return 2 * bn(e / 2);
});
function J9() {
  return eo(Z$).scale(124.75).clipAngle(180 - 1e-3);
}
var Q$ = J$(function(e) {
  return (e = A$(e)) && e / rt(e);
});
Q$.invert = Zu(function(e) {
  return e;
});
function Z9() {
  return eo(Q$).scale(79.4188).clipAngle(180 - 1e-3);
}
function py(e, t) {
  return [e, Ad(cb(($e + t) / 2))];
}
py.invert = function(e, t) {
  return [e, 2 * Gc($$(t)) - $e];
};
function Q9() {
  return tA(py).scale(961 / En);
}
function tA(e) {
  var t = eo(e), n = t.center, i = t.scale, r = t.translate, s = t.clipExtent, o = null, a, c, l;
  t.scale = function(f) {
    return arguments.length ? (i(f), u()) : i();
  }, t.translate = function(f) {
    return arguments.length ? (r(f), u()) : r();
  }, t.center = function(f) {
    return arguments.length ? (n(f), u()) : n();
  }, t.clipExtent = function(f) {
    return arguments.length ? (f == null ? o = a = c = l = null : (o = +f[0][0], a = +f[0][1], c = +f[1][0], l = +f[1][1]), u()) : o == null ? null : [[o, a], [c, l]];
  };
  function u() {
    var f = Dt * i(), h = t(g9(t.rotate()).invert([0, 0]));
    return s(o == null ? [[h[0] - f, h[1] - f], [h[0] + f, h[1] + f]] : e === py ? [[Math.max(h[0] - f, o), a], [Math.min(h[0] + f, c), l]] : [[o, Math.max(h[1] - f, a)], [c, Math.min(h[1] + f, l)]]);
  }
  return u();
}
function jf(e) {
  return cb(($e + e) / 2);
}
function tU(e, t) {
  var n = ct(e), i = e === t ? rt(e) : Ad(n / ct(t)) / Ad(jf(t) / jf(e)), r = n * R0(jf(e), i) / i;
  if (!i)
    return py;
  function s(o, a) {
    r > 0 ? a < -$e + at && (a = -$e + at) : a > $e - at && (a = $e - at);
    var c = r / R0(jf(a), i);
    return [c * rt(i * o), r - c * ct(i * o)];
  }
  return s.invert = function(o, a) {
    var c = r - a, l = Hn(i) * ln(o * o + c * c), u = vi(o, qt(c)) * Hn(c);
    return c * i < 0 && (u -= Dt * Hn(o) * Hn(c)), [u / i, 2 * Gc(R0(r / l, 1 / i)) - $e];
  }, s;
}
function eU() {
  return hb(tU).scale(109.5).parallels([30, 30]);
}
function qd(e, t) {
  return [e, t];
}
qd.invert = qd;
function nU() {
  return eo(qd).scale(152.63);
}
function iU(e, t) {
  var n = ct(e), i = e === t ? rt(e) : (n - ct(t)) / (t - e), r = n / i + e;
  if (qt(i) < at)
    return qd;
  function s(o, a) {
    var c = r - a, l = i * o;
    return [c * rt(l), r - c * ct(l)];
  }
  return s.invert = function(o, a) {
    var c = r - a, l = vi(o, qt(c)) * Hn(c);
    return c * i < 0 && (l -= Dt * Hn(o) * Hn(c)), [l / i, r - Hn(i) * ln(o * o + c * c)];
  }, s;
}
function rU() {
  return hb(iU).scale(131.154).center([0, 13.9389]);
}
var ql = 1.340264, Wl = -0.081106, Gl = 893e-6, Xl = 3796e-6, Wd = ln(3) / 2, sU = 12;
function eA(e, t) {
  var n = bn(Wd * rt(t)), i = n * n, r = i * i * i;
  return [
    e * ct(n) / (Wd * (ql + 3 * Wl * i + r * (7 * Gl + 9 * Xl * i))),
    n * (ql + Wl * i + r * (Gl + Xl * i))
  ];
}
eA.invert = function(e, t) {
  for (var n = t, i = n * n, r = i * i * i, s = 0, o, a, c; s < sU && (a = n * (ql + Wl * i + r * (Gl + Xl * i)) - t, c = ql + 3 * Wl * i + r * (7 * Gl + 9 * Xl * i), n -= o = a / c, i = n * n, r = i * i * i, !(qt(o) < $d)); ++s)
    ;
  return [
    Wd * e * (ql + 3 * Wl * i + r * (7 * Gl + 9 * Xl * i)) / ct(n),
    bn(rt(n) / Wd)
  ];
};
function oU() {
  return eo(eA).scale(177.158);
}
function nA(e, t) {
  var n = ct(t), i = ct(e) * n;
  return [n * rt(e) / i, rt(t) / i];
}
nA.invert = Zu(Gc);
function aU() {
  return eo(nA).scale(144.049).clipAngle(60);
}
function iA(e, t) {
  return [ct(t) * rt(e), rt(t)];
}
iA.invert = Zu(bn);
function cU() {
  return eo(iA).scale(249.5).clipAngle(90 + at);
}
function rA(e, t) {
  var n = ct(t), i = 1 + ct(e) * n;
  return [n * rt(e) / i, rt(t) / i];
}
rA.invert = Zu(function(e) {
  return 2 * Gc(e);
});
function lU() {
  return eo(rA).scale(250).clipAngle(142);
}
function sA(e, t) {
  return [Ad(cb(($e + t) / 2)), -e];
}
sA.invert = function(e, t) {
  return [-t, 2 * Gc($$(e)) - $e];
};
function uU() {
  var e = tA(sA), t = e.center, n = e.rotate;
  return e.center = function(i) {
    return arguments.length ? t([-i[1], i[0]]) : (i = t(), [i[1], -i[0]]);
  }, e.rotate = function(i) {
    return arguments.length ? n([i[0], i[1], i.length > 2 ? i[2] + 90 : 90]) : (i = n(), [i[0], i[1], i[2] - 90]);
  }, n([0, 0, 90]).scale(159.155);
}
function fU(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function hU(e) {
  return e.reduce(dU, 0) / e.length;
}
function dU(e, t) {
  return e + t.x;
}
function pU(e) {
  return 1 + e.reduce(yU, 0);
}
function yU(e, t) {
  return Math.max(e, t.y);
}
function mU(e) {
  for (var t; t = e.children; )
    e = t[0];
  return e;
}
function gU(e) {
  for (var t; t = e.children; )
    e = t[t.length - 1];
  return e;
}
function bU() {
  var e = fU, t = 1, n = 1, i = !1;
  function r(s) {
    var o, a = 0;
    s.eachAfter(function(h) {
      var d = h.children;
      d ? (h.x = hU(d), h.y = pU(d)) : (h.x = o ? a += e(h, o) : 0, h.y = 0, o = h);
    });
    var c = mU(s), l = gU(s), u = c.x - e(c, l) / 2, f = l.x + e(l, c) / 2;
    return s.eachAfter(i ? function(h) {
      h.x = (h.x - s.x) * t, h.y = (s.y - h.y) * n;
    } : function(h) {
      h.x = (h.x - u) / (f - u) * t, h.y = (1 - (s.y ? h.y / s.y : 1)) * n;
    });
  }
  return r.separation = function(s) {
    return arguments.length ? (e = s, r) : e;
  }, r.size = function(s) {
    return arguments.length ? (i = !1, t = +s[0], n = +s[1], r) : i ? null : [t, n];
  }, r.nodeSize = function(s) {
    return arguments.length ? (i = !0, t = +s[0], n = +s[1], r) : i ? [t, n] : null;
  }, r;
}
function _U(e) {
  var t = 0, n = e.children, i = n && n.length;
  if (!i)
    t = 1;
  else
    for (; --i >= 0; )
      t += n[i].value;
  e.value = t;
}
function wU() {
  return this.eachAfter(_U);
}
function vU(e, t) {
  let n = -1;
  for (const i of this)
    e.call(t, i, ++n, this);
  return this;
}
function xU(e, t) {
  for (var n = this, i = [n], r, s, o = -1; n = i.pop(); )
    if (e.call(t, n, ++o, this), r = n.children)
      for (s = r.length - 1; s >= 0; --s)
        i.push(r[s]);
  return this;
}
function SU(e, t) {
  for (var n = this, i = [n], r = [], s, o, a, c = -1; n = i.pop(); )
    if (r.push(n), s = n.children)
      for (o = 0, a = s.length; o < a; ++o)
        i.push(s[o]);
  for (; n = r.pop(); )
    e.call(t, n, ++c, this);
  return this;
}
function IU(e, t) {
  let n = -1;
  for (const i of this)
    if (e.call(t, i, ++n, this))
      return i;
}
function $U(e) {
  return this.eachAfter(function(t) {
    for (var n = +e(t.data) || 0, i = t.children, r = i && i.length; --r >= 0; )
      n += i[r].value;
    t.value = n;
  });
}
function AU(e) {
  return this.eachBefore(function(t) {
    t.children && t.children.sort(e);
  });
}
function MU(e) {
  for (var t = this, n = TU(t, e), i = [t]; t !== n; )
    t = t.parent, i.push(t);
  for (var r = i.length; e !== n; )
    i.splice(r, 0, e), e = e.parent;
  return i;
}
function TU(e, t) {
  if (e === t)
    return e;
  var n = e.ancestors(), i = t.ancestors(), r = null;
  for (e = n.pop(), t = i.pop(); e === t; )
    r = e, e = n.pop(), t = i.pop();
  return r;
}
function BU() {
  for (var e = this, t = [e]; e = e.parent; )
    t.push(e);
  return t;
}
function NU() {
  return Array.from(this);
}
function FU() {
  var e = [];
  return this.eachBefore(function(t) {
    t.children || e.push(t);
  }), e;
}
function DU() {
  var e = this, t = [];
  return e.each(function(n) {
    n !== e && t.push({ source: n.parent, target: n });
  }), t;
}
function* OU() {
  var e = this, t, n = [e], i, r, s;
  do
    for (t = n.reverse(), n = []; e = t.pop(); )
      if (yield e, i = e.children)
        for (r = 0, s = i.length; r < s; ++r)
          n.push(i[r]);
  while (n.length);
}
function oA(e, t) {
  e instanceof Map ? (e = [void 0, e], t === void 0 && (t = RU)) : t === void 0 && (t = LU);
  for (var n = new Ic(e), i, r = [n], s, o, a, c; i = r.pop(); )
    if ((o = t(i.data)) && (c = (o = Array.from(o)).length))
      for (i.children = o, a = c - 1; a >= 0; --a)
        r.push(s = o[a] = new Ic(o[a])), s.parent = i, s.depth = i.depth + 1;
  return n.eachBefore(aA);
}
function EU() {
  return oA(this).eachBefore(CU);
}
function LU(e) {
  return e.children;
}
function RU(e) {
  return Array.isArray(e) ? e[1] : null;
}
function CU(e) {
  e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
}
function aA(e) {
  var t = 0;
  do
    e.height = t;
  while ((e = e.parent) && e.height < ++t);
}
function Ic(e) {
  this.data = e, this.depth = this.height = 0, this.parent = null;
}
Ic.prototype = oA.prototype = {
  constructor: Ic,
  count: wU,
  each: vU,
  eachAfter: SU,
  eachBefore: xU,
  find: IU,
  sum: $U,
  sort: AU,
  path: MU,
  ancestors: BU,
  descendants: NU,
  leaves: FU,
  links: DU,
  copy: EU,
  [Symbol.iterator]: OU
};
function P0(e) {
  return e == null ? null : kU(e);
}
function kU(e) {
  if (typeof e != "function")
    throw new Error();
  return e;
}
var UU = { depth: -1 }, d2 = {}, V0 = {};
function zU(e) {
  return e.id;
}
function PU(e) {
  return e.parentId;
}
function cA() {
  var e = zU, t = PU, n;
  function i(r) {
    var s = Array.from(r), o = e, a = t, c, l, u, f, h, d, p, y, g = /* @__PURE__ */ new Map();
    if (n != null) {
      const m = s.map((w, v) => VU(n(w, v, r))), b = m.map(p2), _ = new Set(m).add("");
      for (const w of b)
        _.has(w) || (_.add(w), m.push(w), b.push(p2(w)), s.push(V0));
      o = (w, v) => m[v], a = (w, v) => b[v];
    }
    for (u = 0, c = s.length; u < c; ++u)
      l = s[u], d = s[u] = new Ic(l), (p = o(l, u, r)) != null && (p += "") && (y = d.id = p, g.set(y, g.has(y) ? d2 : d)), (p = a(l, u, r)) != null && (p += "") && (d.parent = p);
    for (u = 0; u < c; ++u)
      if (d = s[u], p = d.parent) {
        if (h = g.get(p), !h)
          throw new Error("missing: " + p);
        if (h === d2)
          throw new Error("ambiguous: " + p);
        h.children ? h.children.push(d) : h.children = [d], d.parent = h;
      } else {
        if (f)
          throw new Error("multiple roots");
        f = d;
      }
    if (!f)
      throw new Error("no root");
    if (n != null) {
      for (; f.data === V0 && f.children.length === 1; )
        f = f.children[0], --c;
      for (let m = s.length - 1; m >= 0 && (d = s[m], d.data === V0); --m)
        d.data = null;
    }
    if (f.parent = UU, f.eachBefore(function(m) {
      m.depth = m.parent.depth + 1, --c;
    }).eachBefore(aA), f.parent = null, c > 0)
      throw new Error("cycle");
    return f;
  }
  return i.id = function(r) {
    return arguments.length ? (e = P0(r), i) : e;
  }, i.parentId = function(r) {
    return arguments.length ? (t = P0(r), i) : t;
  }, i.path = function(r) {
    return arguments.length ? (n = P0(r), i) : n;
  }, i;
}
function VU(e) {
  e = `${e}`;
  let t = e.length;
  return $g(e, t - 1) && !$g(e, t - 2) && (e = e.slice(0, -1)), e[0] === "/" ? e : `/${e}`;
}
function p2(e) {
  let t = e.length;
  if (t < 2)
    return "";
  for (; --t > 1 && !$g(e, t); )
    ;
  return e.slice(0, t);
}
function $g(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
function jU(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function j0(e) {
  var t = e.children;
  return t ? t[0] : e.t;
}
function Y0(e) {
  var t = e.children;
  return t ? t[t.length - 1] : e.t;
}
function YU(e, t, n) {
  var i = n / (t.i - e.i);
  t.c -= i, t.s += n, e.c += i, t.z += n, t.m += n;
}
function qU(e) {
  for (var t = 0, n = 0, i = e.children, r = i.length, s; --r >= 0; )
    s = i[r], s.z += t, s.m += t, t += s.s + (n += s.c);
}
function WU(e, t, n) {
  return e.a.parent === t.parent ? e.a : n;
}
function Ah(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;
}
Ah.prototype = Object.create(Ic.prototype);
function GU(e) {
  for (var t = new Ah(e, 0), n, i = [t], r, s, o, a; n = i.pop(); )
    if (s = n._.children)
      for (n.children = new Array(a = s.length), o = a - 1; o >= 0; --o)
        i.push(r = n.children[o] = new Ah(s[o], o)), r.parent = n;
  return (t.parent = new Ah(null, 0)).children = [t], t;
}
function lA() {
  var e = jU, t = 1, n = 1, i = null;
  function r(l) {
    var u = GU(l);
    if (u.eachAfter(s), u.parent.m = -u.z, u.eachBefore(o), i)
      l.eachBefore(c);
    else {
      var f = l, h = l, d = l;
      l.eachBefore(function(b) {
        b.x < f.x && (f = b), b.x > h.x && (h = b), b.depth > d.depth && (d = b);
      });
      var p = f === h ? 1 : e(f, h) / 2, y = p - f.x, g = t / (h.x + p + y), m = n / (d.depth || 1);
      l.eachBefore(function(b) {
        b.x = (b.x + y) * g, b.y = b.depth * m;
      });
    }
    return l;
  }
  function s(l) {
    var u = l.children, f = l.parent.children, h = l.i ? f[l.i - 1] : null;
    if (u) {
      qU(l);
      var d = (u[0].z + u[u.length - 1].z) / 2;
      h ? (l.z = h.z + e(l._, h._), l.m = l.z - d) : l.z = d;
    } else
      h && (l.z = h.z + e(l._, h._));
    l.parent.A = a(l, h, l.parent.A || f[0]);
  }
  function o(l) {
    l._.x = l.z + l.parent.m, l.m += l.parent.m;
  }
  function a(l, u, f) {
    if (u) {
      for (var h = l, d = l, p = u, y = h.parent.children[0], g = h.m, m = d.m, b = p.m, _ = y.m, w; p = Y0(p), h = j0(h), p && h; )
        y = j0(y), d = Y0(d), d.a = l, w = p.z + b - h.z - g + e(p._, h._), w > 0 && (YU(WU(p, l, f), l, w), g += w, m += w), b += p.m, g += h.m, _ += y.m, m += d.m;
      p && !Y0(d) && (d.t = p, d.m += b - m), h && !j0(y) && (y.t = h, y.m += g - _, f = l);
    }
    return f;
  }
  function c(l) {
    l.x *= t, l.y = l.depth * n;
  }
  return r.separation = function(l) {
    return arguments.length ? (e = l, r) : e;
  }, r.size = function(l) {
    return arguments.length ? (i = !1, t = +l[0], n = +l[1], r) : i ? null : [t, n];
  }, r.nodeSize = function(l) {
    return arguments.length ? (i = !0, t = +l[0], n = +l[1], r) : i ? [t, n] : null;
  }, r;
}
const XU = 1664525, HU = 1013904223, y2 = 1 / 4294967296;
function db(e = Math.random()) {
  let t = (0 <= e && e < 1 ? e / y2 : Math.abs(e)) | 0;
  return () => (t = XU * t + HU | 0, y2 * (t >>> 0));
}
function hr(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
function yy(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 Ag = Symbol("implicit");
function pb() {
  var e = new qo(), t = [], n = [], i = Ag;
  function r(s) {
    let o = e.get(s);
    if (o === void 0) {
      if (i !== Ag)
        return i;
      e.set(s, o = t.push(s) - 1);
    }
    return n[o % n.length];
  }
  return r.domain = function(s) {
    if (!arguments.length)
      return t.slice();
    t = [], e = new qo();
    for (const o of s)
      e.has(o) || e.set(o, t.push(o) - 1);
    return r;
  }, r.range = function(s) {
    return arguments.length ? (n = Array.from(s), r) : n.slice();
  }, r.unknown = function(s) {
    return arguments.length ? (i = s, r) : i;
  }, r.copy = function() {
    return pb(t, n).unknown(i);
  }, hr.apply(r, arguments), r;
}
function my() {
  var e = pb().unknown(void 0), t = e.domain, n = e.range, i = 0, r = 1, s, o, a = !1, c = 0, l = 0, u = 0.5;
  delete e.unknown;
  function f() {
    var h = t().length, d = r < i, p = d ? r : i, y = d ? i : r;
    s = (y - p) / Math.max(1, h - c + l * 2), a && (s = Math.floor(s)), p += (y - p - s * (h - c)) * u, o = s * (1 - c), a && (p = Math.round(p), o = Math.round(o));
    var g = Bn(h).map(function(m) {
      return p + s * m;
    });
    return n(d ? g.reverse() : g);
  }
  return e.domain = function(h) {
    return arguments.length ? (t(h), f()) : t();
  }, e.range = function(h) {
    return arguments.length ? ([i, r] = h, i = +i, r = +r, f()) : [i, r];
  }, e.rangeRound = function(h) {
    return [i, r] = h, i = +i, r = +r, a = !0, f();
  }, e.bandwidth = function() {
    return o;
  }, e.step = function() {
    return s;
  }, e.round = function(h) {
    return arguments.length ? (a = !!h, f()) : a;
  }, e.padding = function(h) {
    return arguments.length ? (c = Math.min(1, l = +h), f()) : c;
  }, e.paddingInner = function(h) {
    return arguments.length ? (c = Math.min(1, h), f()) : c;
  }, e.paddingOuter = function(h) {
    return arguments.length ? (l = +h, f()) : l;
  }, e.align = function(h) {
    return arguments.length ? (u = Math.max(0, Math.min(1, h)), f()) : u;
  }, e.copy = function() {
    return my(t(), [i, r]).round(a).paddingInner(c).paddingOuter(l).align(u);
  }, hr.apply(f(), arguments);
}
function uA(e) {
  var t = e.copy;
  return e.padding = e.paddingOuter, delete e.paddingInner, delete e.paddingOuter, e.copy = function() {
    return uA(t());
  }, e;
}
function KU() {
  return uA(my.apply(null, arguments).paddingInner(1));
}
function JU(e) {
  return function() {
    return e;
  };
}
function Mg(e) {
  return +e;
}
var m2 = [0, 1];
function Kn(e) {
  return e;
}
function Tg(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : JU(isNaN(t) ? NaN : 0.5);
}
function ZU(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(i) {
    return Math.max(e, Math.min(t, i));
  };
}
function QU(e, t, n) {
  var i = e[0], r = e[1], s = t[0], o = t[1];
  return r < i ? (i = Tg(r, i), s = n(o, s)) : (i = Tg(i, r), s = n(s, o)), function(a) {
    return s(i(a));
  };
}
function tz(e, t, n) {
  var i = Math.min(e.length, t.length) - 1, r = new Array(i), s = new Array(i), o = -1;
  for (e[i] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++o < i; )
    r[o] = Tg(e[o], e[o + 1]), s[o] = n(t[o], t[o + 1]);
  return function(a) {
    var c = ny(e, a, 1, i) - 1;
    return s[c](r[c](a));
  };
}
function Qu(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function gy() {
  var e = m2, t = m2, n = qc, i, r, s, o = Kn, a, c, l;
  function u() {
    var h = Math.min(e.length, t.length);
    return o !== Kn && (o = ZU(e[0], e[h - 1])), a = h > 2 ? tz : QU, c = l = null, f;
  }
  function f(h) {
    return h == null || isNaN(h = +h) ? s : (c || (c = a(e.map(i), t, n)))(i(o(h)));
  }
  return f.invert = function(h) {
    return o(r((l || (l = a(t, e.map(i), Xe)))(h)));
  }, f.domain = function(h) {
    return arguments.length ? (e = Array.from(h, Mg), u()) : e.slice();
  }, f.range = function(h) {
    return arguments.length ? (t = Array.from(h), u()) : t.slice();
  }, f.rangeRound = function(h) {
    return t = Array.from(h), n = tb, u();
  }, f.clamp = function(h) {
    return arguments.length ? (o = h ? !0 : Kn, u()) : o !== Kn;
  }, f.interpolate = function(h) {
    return arguments.length ? (n = h, u()) : n;
  }, f.unknown = function(h) {
    return arguments.length ? (s = h, f) : s;
  }, function(h, d) {
    return i = h, r = d, u();
  };
}
function fA() {
  return gy()(Kn, Kn);
}
function ez(e, t, n, i) {
  var r = jm(e, t, n), s;
  switch (i = mu(i ?? ",f"), i.type) {
    case "s": {
      var o = Math.max(Math.abs(e), Math.abs(t));
      return i.precision == null && !isNaN(s = l9(r, o)) && (i.precision = s), I$(i, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      i.precision == null && !isNaN(s = u9(r, Math.max(Math.abs(e), Math.abs(t)))) && (i.precision = s - (i.type === "e"));
      break;
    }
    case "f":
    case "%": {
      i.precision == null && !isNaN(s = c9(r)) && (i.precision = s - (i.type === "%") * 2);
      break;
    }
  }
  return Wc(i);
}
function tf(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var i = t();
    return Us(i[0], i[i.length - 1], n ?? 10);
  }, e.tickFormat = function(n, i) {
    var r = t();
    return ez(r[0], r[r.length - 1], n ?? 10, i);
  }, e.nice = function(n) {
    n == null && (n = 10);
    var i = t(), r = 0, s = i.length - 1, o = i[r], a = i[s], c, l, u = 10;
    for (a < o && (l = o, o = a, a = l, l = r, r = s, s = l); u-- > 0; ) {
      if (l = uu(o, a, n), l === c)
        return i[r] = o, i[s] = a, t(i);
      if (l > 0)
        o = Math.floor(o / l) * l, a = Math.ceil(a / l) * l;
      else if (l < 0)
        o = Math.ceil(o * l) / l, a = Math.floor(a * l) / l;
      else
        break;
      c = l;
    }
    return e;
  }, e;
}
function by() {
  var e = fA();
  return e.copy = function() {
    return Qu(e, by());
  }, hr.apply(e, arguments), tf(e);
}
function hA(e) {
  var t;
  function n(i) {
    return i == null || isNaN(i = +i) ? t : i;
  }
  return n.invert = n, n.domain = n.range = function(i) {
    return arguments.length ? (e = Array.from(i, Mg), n) : e.slice();
  }, n.unknown = function(i) {
    return arguments.length ? (t = i, n) : t;
  }, n.copy = function() {
    return hA(e).unknown(t);
  }, e = arguments.length ? Array.from(e, Mg) : [0, 1], tf(n);
}
function dA(e, t) {
  e = e.slice();
  var n = 0, i = e.length - 1, r = e[n], s = e[i], o;
  return s < r && (o = n, n = i, i = o, o = r, r = s, s = o), e[n] = t.floor(r), e[i] = t.ceil(s), e;
}
function g2(e) {
  return Math.log(e);
}
function b2(e) {
  return Math.exp(e);
}
function nz(e) {
  return -Math.log(-e);
}
function iz(e) {
  return -Math.exp(-e);
}
function rz(e) {
  return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e;
}
function sz(e) {
  return e === 10 ? rz : e === Math.E ? Math.exp : (t) => Math.pow(e, t);
}
function oz(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 _2(e) {
  return (t, n) => -e(-t, n);
}
function pA(e) {
  const t = e(g2, b2), n = t.domain;
  let i = 10, r, s;
  function o() {
    return r = oz(i), s = sz(i), n()[0] < 0 ? (r = _2(r), s = _2(s), e(nz, iz)) : e(g2, b2), t;
  }
  return t.base = function(a) {
    return arguments.length ? (i = +a, o()) : i;
  }, t.domain = function(a) {
    return arguments.length ? (n(a), o()) : n();
  }, t.ticks = (a) => {
    const c = n();
    let l = c[0], u = c[c.length - 1];
    const f = u < l;
    f && ([l, u] = [u, l]);
    let h = r(l), d = r(u), p, y;
    const g = a == null ? 10 : +a;
    let m = [];
    if (!(i % 1) && d - h < g) {
      if (h = Math.floor(h), d = Math.ceil(d), l > 0) {
        for (; h <= d; ++h)
          for (p = 1; p < i; ++p)
            if (y = h < 0 ? p / s(-h) : p * s(h), !(y < l)) {
              if (y > u)
                break;
              m.push(y);
            }
      } else
        for (; h <= d; ++h)
          for (p = i - 1; p >= 1; --p)
            if (y = h > 0 ? p / s(-h) : p * s(h), !(y < l)) {
              if (y > u)
                break;
              m.push(y);
            }
      m.length * 2 < g && (m = Us(l, u, g));
    } else
      m = Us(h, d, Math.min(d - h, g)).map(s);
    return f ? m.reverse() : m;
  }, t.tickFormat = (a, c) => {
    if (a == null && (a = 10), c == null && (c = i === 10 ? "s" : ","), typeof c != "function" && (!(i % 1) && (c = mu(c)).precision == null && (c.trim = !0), c = Wc(c)), a === 1 / 0)
      return c;
    const l = Math.max(1, i * a / t.ticks().length);
    return (u) => {
      let f = u / s(Math.round(r(u)));
      return f * i < i - 0.5 && (f *= i), f <= l ? c(u) : "";
    };
  }, t.nice = () => n(dA(n(), {
    floor: (a) => s(Math.floor(r(a))),
    ceil: (a) => s(Math.ceil(r(a)))
  })), t;
}
function yA() {
  const e = pA(gy()).domain([1, 10]);
  return e.copy = () => Qu(e, yA()).base(e.base()), hr.apply(e, arguments), e;
}
function w2(e) {
  return function(t) {
    return Math.sign(t) * Math.log1p(Math.abs(t / e));
  };
}
function v2(e) {
  return function(t) {
    return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
  };
}
function mA(e) {
  var t = 1, n = e(w2(t), v2(t));
  return n.constant = function(i) {
    return arguments.length ? e(w2(t = +i), v2(t)) : t;
  }, tf(n);
}
function gA() {
  var e = mA(gy());
  return e.copy = function() {
    return Qu(e, gA()).constant(e.constant());
  }, hr.apply(e, arguments);
}
function x2(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function az(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function cz(e) {
  return e < 0 ? -e * e : e * e;
}
function bA(e) {
  var t = e(Kn, Kn), n = 1;
  function i() {
    return n === 1 ? e(Kn, Kn) : n === 0.5 ? e(az, cz) : e(x2(n), x2(1 / n));
  }
  return t.exponent = function(r) {
    return arguments.length ? (n = +r, i()) : n;
  }, tf(t);
}
function _A() {
  var e = bA(gy());
  return e.copy = function() {
    return Qu(e, _A()).exponent(e.exponent());
  }, hr.apply(e, arguments), e;
}
function wA() {
  var e = [], t = [], n = [], i;
  function r() {
    var o = 0, a = Math.max(1, t.length);
    for (n = new Array(a - 1); ++o < a; )
      n[o - 1] = mL(e, o / a);
    return s;
  }
  function s(o) {
    return o == null || isNaN(o = +o) ? i : t[ny(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(Be), r();
  }, s.range = function(o) {
    return arguments.length ? (t = Array.from(o), r()) : t.slice();
  }, s.unknown = function(o) {
    return arguments.length ? (i = o, s) : i;
  }, s.quantiles = function() {
    return n.slice();
  }, s.copy = function() {
    return wA().domain(e).range(t).unknown(i);
  }, hr.apply(s, arguments);
}
function vA() {
  var e = [0.5], t = [0, 1], n, i = 1;
  function r(s) {
    return s != null && s <= s ? t[ny(e, s, 0, i)] : n;
  }
  return r.domain = function(s) {
    return arguments.length ? (e = Array.from(s), i = Math.min(e.length, t.length - 1), r) : e.slice();
  }, r.range = function(s) {
    return arguments.length ? (t = Array.from(s), i = Math.min(e.length, t.length - 1), r) : t.slice();
  }, r.invertExtent = function(s) {
    var o = t.indexOf(s);
    return [e[o - 1], e[o]];
  }, r.unknown = function(s) {
    return arguments.length ? (n = s, r) : n;
  }, r.copy = function() {
    return vA().domain(e).range(t).unknown(n);
  }, hr.apply(r, arguments);
}
const q0 = /* @__PURE__ */ new Date(), W0 = /* @__PURE__ */ new Date();
function Oe(e, t, n, i) {
  function r(s) {
    return e(s = arguments.length === 0 ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date(+s)), s;
  }
  return r.floor = (s) => (e(s = /* @__PURE__ */ new Date(+s)), s), r.ceil = (s) => (e(s = new Date(s - 1)), t(s, 1), e(s), s), r.round = (s) => {
    const o = r(s), a = r.ceil(s);
    return s - o < a - s ? o : a;
  }, r.offset = (s, o) => (t(s = /* @__PURE__ */ new Date(+s), o == null ? 1 : Math.floor(o)), s), r.range = (s, o, a) => {
    const c = [];
    if (s = r.ceil(s), a = a == null ? 1 : Math.floor(a), !(s < o) || !(a > 0))
      return c;
    let l;
    do
      c.push(l = /* @__PURE__ */ new Date(+s)), t(s, a), e(s);
    while (l < s && s < o);
    return c;
  }, r.filter = (s) => Oe((o) => {
    if (o >= o)
      for (; e(o), !s(o); )
        o.setTime(o - 1);
  }, (o, a) => {
    if (o >= o)
      if (a < 0)
        for (; ++a <= 0; )
          for (; t(o, -1), !s(o); )
            ;
      else
        for (; --a >= 0; )
          for (; t(o, 1), !s(o); )
            ;
  }), n && (r.count = (s, o) => (q0.setTime(+s), W0.setTime(+o), e(q0), e(W0), Math.floor(n(q0, W0))), r.every = (s) => (s = Math.floor(s), !isFinite(s) || !(s > 0) ? null : s > 1 ? r.filter(i ? (o) => i(o) % s === 0 : (o) => r.count(0, o) % s === 0) : r)), r;
}
const Gd = Oe(() => {
}, (e, t) => {
  e.setTime(+e + t);
}, (e, t) => t - e);
Gd.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? Oe((t) => {
  t.setTime(Math.floor(t / e) * e);
}, (t, n) => {
  t.setTime(+t + n * e);
}, (t, n) => (n - t) / e) : Gd);
Gd.range;
const Pr = 1e3, Jn = Pr * 60, Vr = Jn * 60, es = Vr * 24, yb = es * 7, S2 = es * 30, G0 = es * 365, jr = Oe((e) => {
  e.setTime(e - e.getMilliseconds());
}, (e, t) => {
  e.setTime(+e + t * Pr);
}, (e, t) => (t - e) / Pr, (e) => e.getUTCSeconds());
jr.range;
const _y = Oe((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Pr);
}, (e, t) => {
  e.setTime(+e + t * Jn);
}, (e, t) => (t - e) / Jn, (e) => e.getMinutes());
_y.range;
const wy = Oe((e) => {
  e.setUTCSeconds(0, 0);
}, (e, t) => {
  e.setTime(+e + t * Jn);
}, (e, t) => (t - e) / Jn, (e) => e.getUTCMinutes());
wy.range;
const vy = Oe((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Pr - e.getMinutes() * Jn);
}, (e, t) => {
  e.setTime(+e + t * Vr);
}, (e, t) => (t - e) / Vr, (e) => e.getHours());
vy.range;
const xy = Oe((e) => {
  e.setUTCMinutes(0, 0, 0);
}, (e, t) => {
  e.setTime(+e + t * Vr);
}, (e, t) => (t - e) / Vr, (e) => e.getUTCHours());
xy.range;
const Xc = Oe(
  (e) => e.setHours(0, 0, 0, 0),
  (e, t) => e.setDate(e.getDate() + t),
  (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * Jn) / es,
  (e) => e.getDate() - 1
);
Xc.range;
const Sy = Oe((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / es, (e) => e.getUTCDate() - 1);
Sy.range;
const mb = Oe((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / es, (e) => Math.floor(e / es));
mb.range;
function ea(e) {
  return Oe((t) => {
    t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0);
  }, (t, n) => {
    t.setDate(t.getDate() + n * 7);
  }, (t, n) => (n - t - (n.getTimezoneOffset() - t.getTimezoneOffset()) * Jn) / yb);
}
const $c = ea(0), bu = ea(1), xA = ea(2), SA = ea(3), Jo = ea(4), IA = ea(5), $A = ea(6);
$c.range;
bu.range;
xA.range;
SA.range;
Jo.range;
IA.range;
$A.range;
function na(e) {
  return Oe((t) => {
    t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0);
  }, (t, n) => {
    t.setUTCDate(t.getUTCDate() + n * 7);
  }, (t, n) => (n - t) / yb);
}
const Ac = na(0), _u = na(1), AA = na(2), MA = na(3), Zo = na(4), TA = na(5), BA = na(6);
Ac.range;
_u.range;
AA.range;
MA.range;
Zo.range;
TA.range;
BA.range;
const Iy = Oe((e) => {
  e.setDate(1), e.setHours(0, 0, 0, 0);
}, (e, t) => {
  e.setMonth(e.getMonth() + t);
}, (e, t) => t.getMonth() - e.getMonth() + (t.getFullYear() - e.getFullYear()) * 12, (e) => e.getMonth());
Iy.range;
const $y = Oe((e) => {
  e.setUTCDate(1), e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCMonth(e.getUTCMonth() + t);
}, (e, t) => t.getUTCMonth() - e.getUTCMonth() + (t.getUTCFullYear() - e.getUTCFullYear()) * 12, (e) => e.getUTCMonth());
$y.range;
const xi = Oe((e) => {
  e.setMonth(0, 1), e.setHours(0, 0, 0, 0);
}, (e, t) => {
  e.setFullYear(e.getFullYear() + t);
}, (e, t) => t.getFullYear() - e.getFullYear(), (e) => e.getFullYear());
xi.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : Oe((t) => {
  t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0);
}, (t, n) => {
  t.setFullYear(t.getFullYear() + n * e);
});
xi.range;
const Si = Oe((e) => {
  e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCFullYear(e.getUTCFullYear() + t);
}, (e, t) => t.getUTCFullYear() - e.getUTCFullYear(), (e) => e.getUTCFullYear());
Si.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : Oe((t) => {
  t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0);
}, (t, n) => {
  t.setUTCFullYear(t.getUTCFullYear() + n * e);
});
Si.range;
function NA(e, t, n, i, r, s) {
  const o = [
    [jr, 1, Pr],
    [jr, 5, 5 * Pr],
    [jr, 15, 15 * Pr],
    [jr, 30, 30 * Pr],
    [s, 1, Jn],
    [s, 5, 5 * Jn],
    [s, 15, 15 * Jn],
    [s, 30, 30 * Jn],
    [r, 1, Vr],
    [r, 3, 3 * Vr],
    [r, 6, 6 * Vr],
    [r, 12, 12 * Vr],
    [i, 1, es],
    [i, 2, 2 * es],
    [n, 1, yb],
    [t, 1, S2],
    [t, 3, 3 * S2],
    [e, 1, G0]
  ];
  function a(l, u, f) {
    const h = u < l;
    h && ([l, u] = [u, l]);
    const d = f && typeof f.range == "function" ? f : c(l, u, f), p = d ? d.range(l, +u + 1) : [];
    return h ? p.reverse() : p;
  }
  function c(l, u, f) {
    const h = Math.abs(u - l) / f, d = z1(([, , g]) => g).right(o, h);
    if (d === o.length)
      return e.every(jm(l / G0, u / G0, f));
    if (d === 0)
      return Gd.every(Math.max(jm(l, u, f), 1));
    const [p, y] = o[h / o[d - 1][2] < o[d][2] / h ? d - 1 : d];
    return p.every(y);
  }
  return [a, c];
}
const [lz, FA] = NA(Si, $y, Ac, mb, xy, wy), [uz, fz] = NA(xi, Iy, $c, Xc, vy, _y);
function X0(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 H0(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 pl(e, t, n) {
  return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 };
}
function hz(e) {
  var t = e.dateTime, n = e.date, i = e.time, r = e.periods, s = e.days, o = e.shortDays, a = e.months, c = e.shortMonths, l = yl(r), u = ml(r), f = yl(s), h = ml(s), d = yl(o), p = ml(o), y = yl(a), g = ml(a), m = yl(c), b = ml(c), _ = {
    a: N,
    A: L,
    b: k,
    B: U,
    c: null,
    d: B2,
    e: B2,
    f: Lz,
    g: qz,
    G: Gz,
    H: Dz,
    I: Oz,
    j: Ez,
    L: DA,
    m: Rz,
    M: Cz,
    p: j,
    q: P,
    Q: D2,
    s: O2,
    S: kz,
    u: Uz,
    U: zz,
    V: Pz,
    w: Vz,
    W: jz,
    x: null,
    X: null,
    y: Yz,
    Y: Wz,
    Z: Xz,
    "%": F2
  }, w = {
    a: K,
    A: Z,
    b: et,
    B: tt,
    c: null,
    d: N2,
    e: N2,
    f: Zz,
    g: cP,
    G: uP,
    H: Hz,
    I: Kz,
    j: Jz,
    L: EA,
    m: Qz,
    M: tP,
    p: H,
    q: X,
    Q: D2,
    s: O2,
    S: eP,
    u: nP,
    U: iP,
    V: rP,
    w: sP,
    W: oP,
    x: null,
    X: null,
    y: aP,
    Y: lP,
    Z: fP,
    "%": F2
  }, v = {
    a: $,
    A,
    b: F,
    B: E,
    c: S,
    d: M2,
    e: M2,
    f: Tz,
    g: A2,
    G: $2,
    H: T2,
    I: T2,
    j: Iz,
    L: Mz,
    m: Sz,
    M: $z,
    p: D,
    q: xz,
    Q: Nz,
    s: Fz,
    S: Az,
    u: gz,
    U: bz,
    V: _z,
    w: mz,
    W: wz,
    x: M,
    X: B,
    y: A2,
    Y: $2,
    Z: vz,
    "%": Bz
  };
  _.x = x(n, _), _.X = x(i, _), _.c = x(t, _), w.x = x(n, w), w.X = x(i, w), w.c = x(t, w);
  function x(V, G) {
    return function(J) {
      var z = [], nt = -1, ut = 0, Gt = V.length, Ot, Q, ee;
      for (J instanceof Date || (J = /* @__PURE__ */ new Date(+J)); ++nt < Gt; )
        V.charCodeAt(nt) === 37 && (z.push(V.slice(ut, nt)), (Q = I2[Ot = V.charAt(++nt)]) != null ? Ot = V.charAt(++nt) : Q = Ot === "e" ? " " : "0", (ee = G[Ot]) && (Ot = ee(J, Q)), z.push(Ot), ut = nt + 1);
      return z.push(V.slice(ut, nt)), z.join("");
    };
  }
  function I(V, G) {
    return function(J) {
      var z = pl(1900, void 0, 1), nt = T(z, V, J += "", 0), ut, Gt;
      if (nt != J.length)
        return null;
      if ("Q" in z)
        return new Date(z.Q);
      if ("s" in z)
        return new Date(z.s * 1e3 + ("L" in z ? z.L : 0));
      if (G && !("Z" in z) && (z.Z = 0), "p" in z && (z.H = z.H % 12 + z.p * 12), z.m === void 0 && (z.m = "q" in z ? z.q : 0), "V" in z) {
        if (z.V < 1 || z.V > 53)
          return null;
        "w" in z || (z.w = 1), "Z" in z ? (ut = H0(pl(z.y, 0, 1)), Gt = ut.getUTCDay(), ut = Gt > 4 || Gt === 0 ? _u.ceil(ut) : _u(ut), ut = Sy.offset(ut, (z.V - 1) * 7), z.y = ut.getUTCFullYear(), z.m = ut.getUTCMonth(), z.d = ut.getUTCDate() + (z.w + 6) % 7) : (ut = X0(pl(z.y, 0, 1)), Gt = ut.getDay(), ut = Gt > 4 || Gt === 0 ? bu.ceil(ut) : bu(ut), ut = Xc.offset(ut, (z.V - 1) * 7), z.y = ut.getFullYear(), z.m = ut.getMonth(), z.d = ut.getDate() + (z.w + 6) % 7);
      } else
        ("W" in z || "U" in z) && ("w" in z || (z.w = "u" in z ? z.u % 7 : "W" in z ? 1 : 0), Gt = "Z" in z ? H0(pl(z.y, 0, 1)).getUTCDay() : X0(pl(z.y, 0, 1)).getDay(), z.m = 0, z.d = "W" in z ? (z.w + 6) % 7 + z.W * 7 - (Gt + 5) % 7 : z.w + z.U * 7 - (Gt + 6) % 7);
      return "Z" in z ? (z.H += z.Z / 100 | 0, z.M += z.Z % 100, H0(z)) : X0(z);
    };
  }
  function T(V, G, J, z) {
    for (var nt = 0, ut = G.length, Gt = J.length, Ot, Q; nt < ut; ) {
      if (z >= Gt)
        return -1;
      if (Ot = G.charCodeAt(nt++), Ot === 37) {
        if (Ot = G.charAt(nt++), Q = v[Ot in I2 ? G.charAt(nt++) : Ot], !Q || (z = Q(V, J, z)) < 0)
          return -1;
      } else if (Ot != J.charCodeAt(z++))
        return -1;
    }
    return z;
  }
  function D(V, G, J) {
    var z = l.exec(G.slice(J));
    return z ? (V.p = u.get(z[0].toLowerCase()), J + z[0].length) : -1;
  }
  function $(V, G, J) {
    var z = d.exec(G.slice(J));
    return z ? (V.w = p.get(z[0].toLowerCase()), J + z[0].length) : -1;
  }
  function A(V, G, J) {
    var z = f.exec(G.slice(J));
    return z ? (V.w = h.get(z[0].toLowerCase()), J + z[0].length) : -1;
  }
  function F(V, G, J) {
    var z = m.exec(G.slice(J));
    return z ? (V.m = b.get(z[0].toLowerCase()), J + z[0].length) : -1;
  }
  function E(V, G, J) {
    var z = y.exec(G.slice(J));
    return z ? (V.m = g.get(z[0].toLowerCase()), J + z[0].length) : -1;
  }
  function S(V, G, J) {
    return T(V, t, G, J);
  }
  function M(V, G, J) {
    return T(V, n, G, J);
  }
  function B(V, G, J) {
    return T(V, i, G, J);
  }
  function N(V) {
    return o[V.getDay()];
  }
  function L(V) {
    return s[V.getDay()];
  }
  function k(V) {
    return c[V.getMonth()];
  }
  function U(V) {
    return a[V.getMonth()];
  }
  function j(V) {
    return r[+(V.getHours() >= 12)];
  }
  function P(V) {
    return 1 + ~~(V.getMonth() / 3);
  }
  function K(V) {
    return o[V.getUTCDay()];
  }
  function Z(V) {
    return s[V.getUTCDay()];
  }
  function et(V) {
    return c[V.getUTCMonth()];
  }
  function tt(V) {
    return a[V.getUTCMonth()];
  }
  function H(V) {
    return r[+(V.getUTCHours() >= 12)];
  }
  function X(V) {
    return 1 + ~~(V.getUTCMonth() / 3);
  }
  return {
    format: function(V) {
      var G = x(V += "", _);
      return G.toString = function() {
        return V;
      }, G;
    },
    parse: function(V) {
      var G = I(V += "", !1);
      return G.toString = function() {
        return V;
      }, G;
    },
    utcFormat: function(V) {
      var G = x(V += "", w);
      return G.toString = function() {
        return V;
      }, G;
    },
    utcParse: function(V) {
      var G = I(V += "", !0);
      return G.toString = function() {
        return V;
      }, G;
    }
  };
}
var I2 = { "-": "", _: " ", 0: "0" }, Pe = /^\s*\d+/, dz = /^%/, pz = /[\\^$*+?|[\]().{}]/g;
function Vt(e, t, n) {
  var i = e < 0 ? "-" : "", r = (i ? -e : e) + "", s = r.length;
  return i + (s < n ? new Array(n - s + 1).join(t) + r : r);
}
function yz(e) {
  return e.replace(pz, "\\$&");
}
function yl(e) {
  return new RegExp("^(?:" + e.map(yz).join("|") + ")", "i");
}
function ml(e) {
  return new Map(e.map((t, n) => [t.toLowerCase(), n]));
}
function mz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 1));
  return i ? (e.w = +i[0], n + i[0].length) : -1;
}
function gz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 1));
  return i ? (e.u = +i[0], n + i[0].length) : -1;
}
function bz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.U = +i[0], n + i[0].length) : -1;
}
function _z(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.V = +i[0], n + i[0].length) : -1;
}
function wz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.W = +i[0], n + i[0].length) : -1;
}
function $2(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 4));
  return i ? (e.y = +i[0], n + i[0].length) : -1;
}
function A2(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.y = +i[0] + (+i[0] > 68 ? 1900 : 2e3), n + i[0].length) : -1;
}
function vz(e, t, n) {
  var i = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6));
  return i ? (e.Z = i[1] ? 0 : -(i[2] + (i[3] || "00")), n + i[0].length) : -1;
}
function xz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 1));
  return i ? (e.q = i[0] * 3 - 3, n + i[0].length) : -1;
}
function Sz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.m = i[0] - 1, n + i[0].length) : -1;
}
function M2(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.d = +i[0], n + i[0].length) : -1;
}
function Iz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 3));
  return i ? (e.m = 0, e.d = +i[0], n + i[0].length) : -1;
}
function T2(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.H = +i[0], n + i[0].length) : -1;
}
function $z(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.M = +i[0], n + i[0].length) : -1;
}
function Az(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.S = +i[0], n + i[0].length) : -1;
}
function Mz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 3));
  return i ? (e.L = +i[0], n + i[0].length) : -1;
}
function Tz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 6));
  return i ? (e.L = Math.floor(i[0] / 1e3), n + i[0].length) : -1;
}
function Bz(e, t, n) {
  var i = dz.exec(t.slice(n, n + 1));
  return i ? n + i[0].length : -1;
}
function Nz(e, t, n) {
  var i = Pe.exec(t.slice(n));
  return i ? (e.Q = +i[0], n + i[0].length) : -1;
}
function Fz(e, t, n) {
  var i = Pe.exec(t.slice(n));
  return i ? (e.s = +i[0], n + i[0].length) : -1;
}
function B2(e, t) {
  return Vt(e.getDate(), t, 2);
}
function Dz(e, t) {
  return Vt(e.getHours(), t, 2);
}
function Oz(e, t) {
  return Vt(e.getHours() % 12 || 12, t, 2);
}
function Ez(e, t) {
  return Vt(1 + Xc.count(xi(e), e), t, 3);
}
function DA(e, t) {
  return Vt(e.getMilliseconds(), t, 3);
}
function Lz(e, t) {
  return DA(e, t) + "000";
}
function Rz(e, t) {
  return Vt(e.getMonth() + 1, t, 2);
}
function Cz(e, t) {
  return Vt(e.getMinutes(), t, 2);
}
function kz(e, t) {
  return Vt(e.getSeconds(), t, 2);
}
function Uz(e) {
  var t = e.getDay();
  return t === 0 ? 7 : t;
}
function zz(e, t) {
  return Vt($c.count(xi(e) - 1, e), t, 2);
}
function OA(e) {
  var t = e.getDay();
  return t >= 4 || t === 0 ? Jo(e) : Jo.ceil(e);
}
function Pz(e, t) {
  return e = OA(e), Vt(Jo.count(xi(e), e) + (xi(e).getDay() === 4), t, 2);
}
function Vz(e) {
  return e.getDay();
}
function jz(e, t) {
  return Vt(bu.count(xi(e) - 1, e), t, 2);
}
function Yz(e, t) {
  return Vt(e.getFullYear() % 100, t, 2);
}
function qz(e, t) {
  return e = OA(e), Vt(e.getFullYear() % 100, t, 2);
}
function Wz(e, t) {
  return Vt(e.getFullYear() % 1e4, t, 4);
}
function Gz(e, t) {
  var n = e.getDay();
  return e = n >= 4 || n === 0 ? Jo(e) : Jo.ceil(e), Vt(e.getFullYear() % 1e4, t, 4);
}
function Xz(e) {
  var t = e.getTimezoneOffset();
  return (t > 0 ? "-" : (t *= -1, "+")) + Vt(t / 60 | 0, "0", 2) + Vt(t % 60, "0", 2);
}
function N2(e, t) {
  return Vt(e.getUTCDate(), t, 2);
}
function Hz(e, t) {
  return Vt(e.getUTCHours(), t, 2);
}
function Kz(e, t) {
  return Vt(e.getUTCHours() % 12 || 12, t, 2);
}
function Jz(e, t) {
  return Vt(1 + Sy.count(Si(e), e), t, 3);
}
function EA(e, t) {
  return Vt(e.getUTCMilliseconds(), t, 3);
}
function Zz(e, t) {
  return EA(e, t) + "000";
}
function Qz(e, t) {
  return Vt(e.getUTCMonth() + 1, t, 2);
}
function tP(e, t) {
  return Vt(e.getUTCMinutes(), t, 2);
}
function eP(e, t) {
  return Vt(e.getUTCSeconds(), t, 2);
}
function nP(e) {
  var t = e.getUTCDay();
  return t === 0 ? 7 : t;
}
function iP(e, t) {
  return Vt(Ac.count(Si(e) - 1, e), t, 2);
}
function LA(e) {
  var t = e.getUTCDay();
  return t >= 4 || t === 0 ? Zo(e) : Zo.ceil(e);
}
function rP(e, t) {
  return e = LA(e), Vt(Zo.count(Si(e), e) + (Si(e).getUTCDay() === 4), t, 2);
}
function sP(e) {
  return e.getUTCDay();
}
function oP(e, t) {
  return Vt(_u.count(Si(e) - 1, e), t, 2);
}
function aP(e, t) {
  return Vt(e.getUTCFullYear() % 100, t, 2);
}
function cP(e, t) {
  return e = LA(e), Vt(e.getUTCFullYear() % 100, t, 2);
}
function lP(e, t) {
  return Vt(e.getUTCFullYear() % 1e4, t, 4);
}
function uP(e, t) {
  var n = e.getUTCDay();
  return e = n >= 4 || n === 0 ? Zo(e) : Zo.ceil(e), Vt(e.getUTCFullYear() % 1e4, t, 4);
}
function fP() {
  return "+0000";
}
function F2() {
  return "%";
}
function D2(e) {
  return +e;
}
function O2(e) {
  return Math.floor(+e / 1e3);
}
var da, gb, wu;
hP({
  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 hP(e) {
  return da = hz(e), gb = da.format, da.parse, wu = da.utcFormat, da.utcParse, da;
}
function dP(e) {
  return new Date(e);
}
function pP(e) {
  return e instanceof Date ? +e : +/* @__PURE__ */ new Date(+e);
}
function bb(e, t, n, i, r, s, o, a, c, l) {
  var u = fA(), f = u.invert, h = u.domain, d = l(".%L"), p = l(":%S"), y = l("%I:%M"), g = l("%I %p"), m = l("%a %d"), b = l("%b %d"), _ = l("%B"), w = l("%Y");
  function v(x) {
    return (c(x) < x ? d : a(x) < x ? p : o(x) < x ? y : s(x) < x ? g : i(x) < x ? r(x) < x ? m : b : n(x) < x ? _ : w)(x);
  }
  return u.invert = function(x) {
    return new Date(f(x));
  }, u.domain = function(x) {
    return arguments.length ? h(Array.from(x, pP)) : h().map(dP);
  }, u.ticks = function(x) {
    var I = h();
    return e(I[0], I[I.length - 1], x ?? 10);
  }, u.tickFormat = function(x, I) {
    return I == null ? v : l(I);
  }, u.nice = function(x) {
    var I = h();
    return (!x || typeof x.range != "function") && (x = t(I[0], I[I.length - 1], x ?? 10)), x ? h(dA(I, x)) : u;
  }, u.copy = function() {
    return Qu(u, bb(e, t, n, i, r, s, o, a, c, l));
  }, u;
}
function yP() {
  return hr.apply(bb(uz, fz, xi, Iy, $c, Xc, vy, _y, jr, gb).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
function mP() {
  return hr.apply(bb(lz, FA, Si, $y, Ac, Sy, xy, wy, jr, wu).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
}
function Ay(e, t) {
  return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown());
}
function My() {
  var e = 0, t = 0.5, n = 1, i = 1, r, s, o, a, c, l = Kn, u, f = !1, h;
  function d(y) {
    return isNaN(y = +y) ? h : (y = 0.5 + ((y = +u(y)) - s) * (i * y < i * s ? a : c), l(f ? Math.max(0, Math.min(1, y)) : y));
  }
  d.domain = function(y) {
    return arguments.length ? ([e, t, n] = y, r = u(e = +e), s = u(t = +t), o = u(n = +n), a = r === s ? 0 : 0.5 / (s - r), c = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, d) : [e, t, n];
  }, d.clamp = function(y) {
    return arguments.length ? (f = !!y, d) : f;
  }, d.interpolator = function(y) {
    return arguments.length ? (l = y, d) : l;
  };
  function p(y) {
    return function(g) {
      var m, b, _;
      return arguments.length ? ([m, b, _] = g, l = nb(y, [m, b, _]), d) : [l(0), l(0.5), l(1)];
    };
  }
  return d.range = p(qc), d.rangeRound = p(tb), d.unknown = function(y) {
    return arguments.length ? (h = y, d) : h;
  }, function(y) {
    return u = y, r = y(e), s = y(t), o = y(n), a = r === s ? 0 : 0.5 / (s - r), c = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, d;
  };
}
function RA() {
  var e = tf(My()(Kn));
  return e.copy = function() {
    return Ay(e, RA());
  }, yy.apply(e, arguments);
}
function CA() {
  var e = pA(My()).domain([0.1, 1, 10]);
  return e.copy = function() {
    return Ay(e, CA()).base(e.base());
  }, yy.apply(e, arguments);
}
function kA() {
  var e = mA(My());
  return e.copy = function() {
    return Ay(e, kA()).constant(e.constant());
  }, yy.apply(e, arguments);
}
function UA() {
  var e = bA(My());
  return e.copy = function() {
    return Ay(e, UA()).exponent(e.exponent());
  }, yy.apply(e, arguments);
}
function Tt(e) {
  for (var t = e.length / 6 | 0, n = new Array(t), i = 0; i < t; )
    n[i] = "#" + e.slice(i * 6, ++i * 6);
  return n;
}
const gP = Tt("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"), bP = Tt("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"), _P = Tt("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"), wP = Tt("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"), vP = Tt("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"), xP = Tt("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"), SP = Tt("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"), IP = Tt("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"), $P = Tt("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"), AP = Tt("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"), oe = (e) => T7(e[e.length - 1]);
var zA = new Array(3).concat(
  "d8b365f5f5f55ab4ac",
  "a6611adfc27d80cdc1018571",
  "a6611adfc27df5f5f580cdc1018571",
  "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
  "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
  "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
  "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
  "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
  "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
).map(Tt);
const PA = oe(zA);
var VA = new Array(3).concat(
  "af8dc3f7f7f77fbf7b",
  "7b3294c2a5cfa6dba0008837",
  "7b3294c2a5cff7f7f7a6dba0008837",
  "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
  "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
  "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
  "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
  "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
  "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
).map(Tt);
const jA = oe(VA);
var YA = new Array(3).concat(
  "e9a3c9f7f7f7a1d76a",
  "d01c8bf1b6dab8e1864dac26",
  "d01c8bf1b6daf7f7f7b8e1864dac26",
  "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
  "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
  "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
  "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
  "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
  "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
).map(Tt);
const qA = oe(YA);
var WA = new Array(3).concat(
  "998ec3f7f7f7f1a340",
  "5e3c99b2abd2fdb863e66101",
  "5e3c99b2abd2f7f7f7fdb863e66101",
  "542788998ec3d8daebfee0b6f1a340b35806",
  "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
  "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
  "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
  "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
  "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
).map(Tt);
const GA = oe(WA);
var Bg = new Array(3).concat(
  "ef8a62f7f7f767a9cf",
  "ca0020f4a58292c5de0571b0",
  "ca0020f4a582f7f7f792c5de0571b0",
  "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
  "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
  "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
  "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
  "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
  "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
).map(Tt);
const Xd = oe(Bg);
var XA = new Array(3).concat(
  "ef8a62ffffff999999",
  "ca0020f4a582bababa404040",
  "ca0020f4a582ffffffbababa404040",
  "b2182bef8a62fddbc7e0e0e09999994d4d4d",
  "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
  "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
  "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
  "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
  "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
).map(Tt);
const HA = oe(XA);
var Ng = new Array(3).concat(
  "fc8d59ffffbf91bfdb",
  "d7191cfdae61abd9e92c7bb6",
  "d7191cfdae61ffffbfabd9e92c7bb6",
  "d73027fc8d59fee090e0f3f891bfdb4575b4",
  "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
  "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
  "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
  "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
  "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
).map(Tt);
const Hd = oe(Ng);
var KA = new Array(3).concat(
  "fc8d59ffffbf91cf60",
  "d7191cfdae61a6d96a1a9641",
  "d7191cfdae61ffffbfa6d96a1a9641",
  "d73027fc8d59fee08bd9ef8b91cf601a9850",
  "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
  "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
  "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
  "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
  "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
).map(Tt);
const JA = oe(KA);
var ZA = new Array(3).concat(
  "fc8d59ffffbf99d594",
  "d7191cfdae61abdda42b83ba",
  "d7191cfdae61ffffbfabdda42b83ba",
  "d53e4ffc8d59fee08be6f59899d5943288bd",
  "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
  "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
  "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
  "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
  "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
).map(Tt);
const QA = oe(ZA);
var tM = new Array(3).concat(
  "e5f5f999d8c92ca25f",
  "edf8fbb2e2e266c2a4238b45",
  "edf8fbb2e2e266c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
).map(Tt);
const eM = oe(tM);
var nM = new Array(3).concat(
  "e0ecf49ebcda8856a7",
  "edf8fbb3cde38c96c688419d",
  "edf8fbb3cde38c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
).map(Tt);
const iM = oe(nM);
var rM = new Array(3).concat(
  "e0f3dba8ddb543a2ca",
  "f0f9e8bae4bc7bccc42b8cbe",
  "f0f9e8bae4bc7bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
).map(Tt);
const sM = oe(rM);
var oM = new Array(3).concat(
  "fee8c8fdbb84e34a33",
  "fef0d9fdcc8afc8d59d7301f",
  "fef0d9fdcc8afc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
).map(Tt);
const aM = oe(oM);
var cM = new Array(3).concat(
  "ece2f0a6bddb1c9099",
  "f6eff7bdc9e167a9cf02818a",
  "f6eff7bdc9e167a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
).map(Tt);
const lM = oe(cM);
var uM = new Array(3).concat(
  "ece7f2a6bddb2b8cbe",
  "f1eef6bdc9e174a9cf0570b0",
  "f1eef6bdc9e174a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
).map(Tt);
const fM = oe(uM);
var hM = new Array(3).concat(
  "e7e1efc994c7dd1c77",
  "f1eef6d7b5d8df65b0ce1256",
  "f1eef6d7b5d8df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
).map(Tt);
const dM = oe(hM);
var pM = new Array(3).concat(
  "fde0ddfa9fb5c51b8a",
  "feebe2fbb4b9f768a1ae017e",
  "feebe2fbb4b9f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
).map(Tt);
const yM = oe(pM);
var mM = new Array(3).concat(
  "edf8b17fcdbb2c7fb8",
  "ffffcca1dab441b6c4225ea8",
  "ffffcca1dab441b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
).map(Tt);
const gM = oe(mM);
var bM = new Array(3).concat(
  "f7fcb9addd8e31a354",
  "ffffccc2e69978c679238443",
  "ffffccc2e69978c67931a354006837",
  "ffffccd9f0a3addd8e78c67931a354006837",
  "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
).map(Tt);
const _M = oe(bM);
var wM = new Array(3).concat(
  "fff7bcfec44fd95f0e",
  "ffffd4fed98efe9929cc4c02",
  "ffffd4fed98efe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
).map(Tt);
const vM = oe(wM);
var xM = new Array(3).concat(
  "ffeda0feb24cf03b20",
  "ffffb2fecc5cfd8d3ce31a1c",
  "ffffb2fecc5cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
).map(Tt);
const SM = oe(xM);
var IM = new Array(3).concat(
  "deebf79ecae13182bd",
  "eff3ffbdd7e76baed62171b5",
  "eff3ffbdd7e76baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
).map(Tt);
const $M = oe(IM);
var AM = new Array(3).concat(
  "e5f5e0a1d99b31a354",
  "edf8e9bae4b374c476238b45",
  "edf8e9bae4b374c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
).map(Tt);
const MM = oe(AM);
var TM = new Array(3).concat(
  "f0f0f0bdbdbd636363",
  "f7f7f7cccccc969696525252",
  "f7f7f7cccccc969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
).map(Tt);
const BM = oe(TM);
var NM = new Array(3).concat(
  "efedf5bcbddc756bb1",
  "f2f0f7cbc9e29e9ac86a51a3",
  "f2f0f7cbc9e29e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
).map(Tt);
const FM = oe(NM);
var DM = new Array(3).concat(
  "fee0d2fc9272de2d26",
  "fee5d9fcae91fb6a4acb181d",
  "fee5d9fcae91fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
).map(Tt);
const OM = oe(DM);
var EM = new Array(3).concat(
  "fee6cefdae6be6550d",
  "feeddefdbe85fd8d3cd94701",
  "feeddefdbe85fd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
).map(Tt);
const LM = oe(EM);
function RM(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 CM = eb(ar(300, 0.5, 0), ar(-240, 0.5, 1));
var kM = eb(ar(-100, 0.75, 0.35), ar(80, 1.5, 0.8)), UM = eb(ar(260, 0.75, 0.35), ar(80, 1.5, 0.8)), Yf = ar();
function zM(e) {
  (e < 0 || e > 1) && (e -= Math.floor(e));
  var t = Math.abs(e - 0.5);
  return Yf.h = 360 * e - 100, Yf.s = 1.5 - 1.5 * t, Yf.l = 0.8 - 0.9 * t, Yf + "";
}
var qf = ni(), MP = Math.PI / 3, TP = Math.PI * 2 / 3;
function PM(e) {
  var t;
  return e = (0.5 - e) * Math.PI, qf.r = 255 * (t = Math.sin(e)) * t, qf.g = 255 * (t = Math.sin(e + MP)) * t, qf.b = 255 * (t = Math.sin(e + TP)) * t, qf + "";
}
function VM(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 Ty(e) {
  var t = e.length;
  return function(n) {
    return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))];
  };
}
const jM = Ty(Tt("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
var YM = Ty(Tt("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")), qM = Ty(Tt("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")), WM = Ty(Tt("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
function Ce(e) {
  return function() {
    return e;
  };
}
const GM = Math.cos, _b = Math.min, Kd = Math.sin, Ee = Math.sqrt, E2 = 1e-12, Jd = Math.PI, By = 2 * Jd;
function XM(e) {
  let t = 3;
  return e.digits = function(n) {
    if (!arguments.length)
      return t;
    if (n == null)
      t = null;
    else {
      const i = Math.floor(n);
      if (!(i >= 0))
        throw new RangeError(`invalid digits: ${n}`);
      t = i;
    }
    return e;
  }, () => new v$(t);
}
function HM(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function KM(e) {
  this._context = e;
}
KM.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 ef(e) {
  return new KM(e);
}
function JM(e) {
  return e[0];
}
function ZM(e) {
  return e[1];
}
function QM(e, t) {
  var n = Ce(!0), i = null, r = ef, s = null, o = XM(a);
  e = typeof e == "function" ? e : e === void 0 ? JM : Ce(e), t = typeof t == "function" ? t : t === void 0 ? ZM : Ce(t);
  function a(c) {
    var l, u = (c = HM(c)).length, f, h = !1, d;
    for (i == null && (s = r(d = o())), l = 0; l <= u; ++l)
      !(l < u && n(f = c[l], l, c)) === h && ((h = !h) ? s.lineStart() : s.lineEnd()), h && s.point(+e(f, l, c), +t(f, l, c));
    if (d)
      return s = null, d + "" || null;
  }
  return a.x = function(c) {
    return arguments.length ? (e = typeof c == "function" ? c : Ce(+c), a) : e;
  }, a.y = function(c) {
    return arguments.length ? (t = typeof c == "function" ? c : Ce(+c), a) : t;
  }, a.defined = function(c) {
    return arguments.length ? (n = typeof c == "function" ? c : Ce(!!c), a) : n;
  }, a.curve = function(c) {
    return arguments.length ? (r = c, i != null && (s = r(i)), a) : r;
  }, a.context = function(c) {
    return arguments.length ? (c == null ? i = s = null : s = r(i = c), a) : i;
  }, a;
}
function wb(e, t, n) {
  var i = null, r = Ce(!0), s = null, o = ef, a = null, c = XM(l);
  e = typeof e == "function" ? e : e === void 0 ? JM : Ce(+e), t = typeof t == "function" ? t : Ce(t === void 0 ? 0 : +t), n = typeof n == "function" ? n : n === void 0 ? ZM : Ce(+n);
  function l(f) {
    var h, d, p, y = (f = HM(f)).length, g, m = !1, b, _ = new Array(y), w = new Array(y);
    for (s == null && (a = o(b = c())), h = 0; h <= y; ++h) {
      if (!(h < y && r(g = f[h], h, f)) === m)
        if (m = !m)
          d = h, a.areaStart(), a.lineStart();
        else {
          for (a.lineEnd(), a.lineStart(), p = h - 1; p >= d; --p)
            a.point(_[p], w[p]);
          a.lineEnd(), a.areaEnd();
        }
      m && (_[h] = +e(g, h, f), w[h] = +t(g, h, f), a.point(i ? +i(g, h, f) : _[h], n ? +n(g, h, f) : w[h]));
    }
    if (b)
      return a = null, b + "" || null;
  }
  function u() {
    return QM().defined(r).curve(o).context(s);
  }
  return l.x = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : Ce(+f), i = null, l) : e;
  }, l.x0 = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : Ce(+f), l) : e;
  }, l.x1 = function(f) {
    return arguments.length ? (i = f == null ? null : typeof f == "function" ? f : Ce(+f), l) : i;
  }, l.y = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : Ce(+f), n = null, l) : t;
  }, l.y0 = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : Ce(+f), l) : t;
  }, l.y1 = function(f) {
    return arguments.length ? (n = f == null ? null : typeof f == "function" ? f : Ce(+f), l) : n;
  }, l.lineX0 = l.lineY0 = function() {
    return u().x(e).y(t);
  }, l.lineY1 = function() {
    return u().x(e).y(n);
  }, l.lineX1 = function() {
    return u().x(i).y(t);
  }, l.defined = function(f) {
    return arguments.length ? (r = typeof f == "function" ? f : Ce(!!f), l) : r;
  }, l.curve = function(f) {
    return arguments.length ? (o = f, s != null && (a = o(s)), l) : o;
  }, l.context = function(f) {
    return arguments.length ? (f == null ? s = a = null : a = o(s = f), l) : s;
  }, l;
}
class t6 {
  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 BP(e) {
  return new t6(e, !0);
}
function NP(e) {
  return new t6(e, !1);
}
const FP = Ee(3), e6 = {
  draw(e, t) {
    const n = Ee(t + _b(t / 28, 0.75)) * 0.59436, i = n / 2, r = i * FP;
    e.moveTo(0, n), e.lineTo(0, -n), e.moveTo(-r, -i), e.lineTo(r, i), e.moveTo(-r, i), e.lineTo(r, -i);
  }
}, vu = {
  draw(e, t) {
    const n = Ee(t / Jd);
    e.moveTo(n, 0), e.arc(0, 0, n, 0, By);
  }
}, n6 = {
  draw(e, t) {
    const n = Ee(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();
  }
}, i6 = Ee(1 / 3), DP = i6 * 2, r6 = {
  draw(e, t) {
    const n = Ee(t / DP), i = n * i6;
    e.moveTo(0, -n), e.lineTo(i, 0), e.lineTo(0, n), e.lineTo(-i, 0), e.closePath();
  }
}, s6 = {
  draw(e, t) {
    const n = Ee(t) * 0.62625;
    e.moveTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.lineTo(-n, 0), e.closePath();
  }
}, o6 = {
  draw(e, t) {
    const n = Ee(t - _b(t / 7, 2)) * 0.87559;
    e.moveTo(-n, 0), e.lineTo(n, 0), e.moveTo(0, n), e.lineTo(0, -n);
  }
}, a6 = {
  draw(e, t) {
    const n = Ee(t), i = -n / 2;
    e.rect(i, i, n, n);
  }
}, c6 = {
  draw(e, t) {
    const n = Ee(t) * 0.4431;
    e.moveTo(n, n), e.lineTo(n, -n), e.lineTo(-n, -n), e.lineTo(-n, n), e.closePath();
  }
}, OP = 0.8908130915292852, l6 = Kd(Jd / 10) / Kd(7 * Jd / 10), EP = Kd(By / 10) * l6, LP = -GM(By / 10) * l6, u6 = {
  draw(e, t) {
    const n = Ee(t * OP), i = EP * n, r = LP * n;
    e.moveTo(0, -n), e.lineTo(i, r);
    for (let s = 1; s < 5; ++s) {
      const o = By * s / 5, a = GM(o), c = Kd(o);
      e.lineTo(c * n, -a * n), e.lineTo(a * i - c * r, c * i + a * r);
    }
    e.closePath();
  }
}, K0 = Ee(3), f6 = {
  draw(e, t) {
    const n = -Ee(t / (K0 * 3));
    e.moveTo(0, n * 2), e.lineTo(-K0 * n, -n), e.lineTo(K0 * n, -n), e.closePath();
  }
}, RP = Ee(3), h6 = {
  draw(e, t) {
    const n = Ee(t) * 0.6824, i = n / 2, r = n * RP / 2;
    e.moveTo(0, -n), e.lineTo(r, i), e.lineTo(-r, i), e.closePath();
  }
}, Cn = -0.5, kn = Ee(3) / 2, Fg = 1 / Ee(12), CP = (Fg / 2 + 1) * 3, d6 = {
  draw(e, t) {
    const n = Ee(t / CP), i = n / 2, r = n * Fg, s = i, o = n * Fg + n, a = -s, c = o;
    e.moveTo(i, r), e.lineTo(s, o), e.lineTo(a, c), e.lineTo(Cn * i - kn * r, kn * i + Cn * r), e.lineTo(Cn * s - kn * o, kn * s + Cn * o), e.lineTo(Cn * a - kn * c, kn * a + Cn * c), e.lineTo(Cn * i + kn * r, Cn * r - kn * i), e.lineTo(Cn * s + kn * o, Cn * o - kn * s), e.lineTo(Cn * a + kn * c, Cn * c - kn * a), e.closePath();
  }
}, p6 = {
  draw(e, t) {
    const n = Ee(t - _b(t / 6, 1.7)) * 0.6189;
    e.moveTo(-n, -n), e.lineTo(n, n), e.moveTo(-n, n), e.lineTo(n, -n);
  }
}, kP = [
  vu,
  n6,
  r6,
  a6,
  u6,
  f6,
  d6
], UP = [
  vu,
  o6,
  p6,
  h6,
  e6,
  c6,
  s6
];
function Ps() {
}
function Zd(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 Ny(e) {
  this._context = e;
}
Ny.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:
        Zd(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:
        Zd(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function zP(e) {
  return new Ny(e);
}
function y6(e) {
  this._context = e;
}
y6.prototype = {
  areaStart: Ps,
  areaEnd: Ps,
  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:
        Zd(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function PP(e) {
  return new y6(e);
}
function m6(e) {
  this._context = e;
}
m6.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3;
        var n = (this._x0 + 4 * this._x1 + e) / 6, i = (this._y0 + 4 * this._y1 + t) / 6;
        this._line ? this._context.lineTo(n, i) : this._context.moveTo(n, i);
        break;
      case 3:
        this._point = 4;
      default:
        Zd(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function VP(e) {
  return new m6(e);
}
function g6(e, t) {
  this._basis = new Ny(e), this._beta = t;
}
g6.prototype = {
  lineStart: function() {
    this._x = [], this._y = [], this._basis.lineStart();
  },
  lineEnd: function() {
    var e = this._x, t = this._y, n = e.length - 1;
    if (n > 0)
      for (var i = e[0], r = t[0], s = e[n] - i, o = t[n] - r, a = -1, c; ++a <= n; )
        c = a / n, this._basis.point(
          this._beta * e[a] + (1 - this._beta) * (i + c * s),
          this._beta * t[a] + (1 - this._beta) * (r + c * o)
        );
    this._x = this._y = null, this._basis.lineEnd();
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
const jP = function e(t) {
  function n(i) {
    return t === 1 ? new Ny(i) : new g6(i, t);
  }
  return n.beta = function(i) {
    return e(+i);
  }, n;
}(0.85);
function Qd(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 vb(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
vb.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:
        Qd(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:
        Qd(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 YP = function e(t) {
  function n(i) {
    return new vb(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function xb(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
xb.prototype = {
  areaStart: Ps,
  areaEnd: Ps,
  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:
        Qd(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 qP = function e(t) {
  function n(i) {
    return new xb(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function Sb(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Sb.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:
        Qd(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 WP = function e(t) {
  function n(i) {
    return new Sb(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function Ib(e, t, n) {
  var i = e._x1, r = e._y1, s = e._x2, o = e._y2;
  if (e._l01_a > E2) {
    var a = 2 * e._l01_2a + 3 * e._l01_a * e._l12_a + e._l12_2a, c = 3 * e._l01_a * (e._l01_a + e._l12_a);
    i = (i * a - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / c, r = (r * a - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / c;
  }
  if (e._l23_a > E2) {
    var l = 2 * e._l23_2a + 3 * e._l23_a * e._l12_a + e._l12_2a, u = 3 * e._l23_a * (e._l23_a + e._l12_a);
    s = (s * l + e._x1 * e._l23_2a - t * e._l12_2a) / u, o = (o * l + e._y1 * e._l23_2a - n * e._l12_2a) / u;
  }
  e._context.bezierCurveTo(i, r, s, o, e._x2, e._y2);
}
function b6(e, t) {
  this._context = e, this._alpha = t;
}
b6.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 2:
        this._context.lineTo(this._x2, this._y2);
        break;
      case 3:
        this.point(this._x2, this._y2);
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3;
      default:
        Ib(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 GP = function e(t) {
  function n(i) {
    return t ? new b6(i, t) : new vb(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function _6(e, t) {
  this._context = e, this._alpha = t;
}
_6.prototype = {
  areaStart: Ps,
  areaEnd: Ps,
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 1: {
        this._context.moveTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 2: {
        this._context.lineTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 3: {
        this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5);
        break;
      }
    }
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1, this._x3 = e, this._y3 = t;
        break;
      case 1:
        this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t);
        break;
      case 2:
        this._point = 3, this._x5 = e, this._y5 = t;
        break;
      default:
        Ib(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 XP = function e(t) {
  function n(i) {
    return t ? new _6(i, t) : new xb(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function w6(e, t) {
  this._context = e, this._alpha = t;
}
w6.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
        break;
      case 3:
        this._point = 4;
      default:
        Ib(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 HP = function e(t) {
  function n(i) {
    return t ? new w6(i, t) : new Sb(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function v6(e) {
  this._context = e;
}
v6.prototype = {
  areaStart: Ps,
  areaEnd: Ps,
  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 KP(e) {
  return new v6(e);
}
function L2(e) {
  return e < 0 ? -1 : 1;
}
function R2(e, t, n) {
  var i = e._x1 - e._x0, r = t - e._x1, s = (e._y1 - e._y0) / (i || r < 0 && -0), o = (n - e._y1) / (r || i < 0 && -0), a = (s * r + o * i) / (i + r);
  return (L2(s) + L2(o)) * Math.min(Math.abs(s), Math.abs(o), 0.5 * Math.abs(a)) || 0;
}
function C2(e, t) {
  var n = e._x1 - e._x0;
  return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
}
function J0(e, t, n) {
  var i = e._x0, r = e._y0, s = e._x1, o = e._y1, a = (s - i) / 3;
  e._context.bezierCurveTo(i + a, r + a * t, s - a, o - a * n, s, o);
}
function tp(e) {
  this._context = e;
}
tp.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:
        J0(this, this._t0, C2(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, J0(this, C2(this, n = R2(this, e, t)), n);
          break;
        default:
          J0(this, this._t0, n = R2(this, e, t));
          break;
      }
      this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
    }
  }
};
function x6(e) {
  this._context = new S6(e);
}
(x6.prototype = Object.create(tp.prototype)).point = function(e, t) {
  tp.prototype.point.call(this, t, e);
};
function S6(e) {
  this._context = e;
}
S6.prototype = {
  moveTo: function(e, t) {
    this._context.moveTo(t, e);
  },
  closePath: function() {
    this._context.closePath();
  },
  lineTo: function(e, t) {
    this._context.lineTo(t, e);
  },
  bezierCurveTo: function(e, t, n, i, r, s) {
    this._context.bezierCurveTo(t, e, i, n, s, r);
  }
};
function JP(e) {
  return new tp(e);
}
function ZP(e) {
  return new x6(e);
}
function I6(e) {
  this._context = e;
}
I6.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x = [], this._y = [];
  },
  lineEnd: function() {
    var e = this._x, t = this._y, n = e.length;
    if (n)
      if (this._line ? this._context.lineTo(e[0], t[0]) : this._context.moveTo(e[0], t[0]), n === 2)
        this._context.lineTo(e[1], t[1]);
      else
        for (var i = k2(e), r = k2(t), s = 0, o = 1; o < n; ++s, ++o)
          this._context.bezierCurveTo(i[0][s], r[0][s], i[1][s], r[1][s], e[o], t[o]);
    (this._line || this._line !== 0 && n === 1) && this._context.closePath(), this._line = 1 - this._line, this._x = this._y = null;
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
function k2(e) {
  var t, n = e.length - 1, i, r = new Array(n), s = new Array(n), o = new Array(n);
  for (r[0] = 0, s[0] = 2, o[0] = e[0] + 2 * e[1], t = 1; t < n - 1; ++t)
    r[t] = 1, s[t] = 4, o[t] = 4 * e[t] + 2 * e[t + 1];
  for (r[n - 1] = 2, s[n - 1] = 7, o[n - 1] = 8 * e[n - 1] + e[n], t = 1; t < n; ++t)
    i = r[t] / s[t - 1], s[t] -= i, o[t] -= i * o[t - 1];
  for (r[n - 1] = o[n - 1] / s[n - 1], t = n - 2; t >= 0; --t)
    r[t] = (o[t] - r[t + 1]) / s[t];
  for (s[n - 1] = (e[n] + r[n - 1]) / 2, t = 0; t < n - 1; ++t)
    s[t] = 2 * e[t + 1] - r[t + 1];
  return [r, s];
}
function QP(e) {
  return new I6(e);
}
function Fy(e, t) {
  this._context = e, this._t = t;
}
Fy.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 tV(e) {
  return new Fy(e, 0.5);
}
function eV(e) {
  return new Fy(e, 0);
}
function nV(e) {
  return new Fy(e, 1);
}
const Wf = (e) => () => e;
function iV(e, {
  sourceEvent: t,
  target: n,
  transform: i,
  dispatch: r
}) {
  Object.defineProperties(this, {
    type: { value: e, enumerable: !0, configurable: !0 },
    sourceEvent: { value: t, enumerable: !0, configurable: !0 },
    target: { value: n, enumerable: !0, configurable: !0 },
    transform: { value: i, enumerable: !0, configurable: !0 },
    _: { value: r }
  });
}
function Zi(e, t, n) {
  this.k = e, this.x = t, this.y = n;
}
Zi.prototype = {
  constructor: Zi,
  scale: function(e) {
    return e === 1 ? this : new Zi(this.k * e, this.x, this.y);
  },
  translate: function(e, t) {
    return e === 0 & t === 0 ? this : new Zi(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 $6 = new Zi(1, 0, 0);
Zi.prototype;
function Z0(e) {
  e.stopImmediatePropagation();
}
function gl(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function rV(e) {
  return (!e.ctrlKey || e.type === "wheel") && !e.button;
}
function sV() {
  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 U2() {
  return this.__zoom || $6;
}
function oV(e) {
  return -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 2e-3) * (e.ctrlKey ? 10 : 1);
}
function aV() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function cV(e, t, n) {
  var i = e.invertX(t[0][0]) - n[0][0], r = e.invertX(t[1][0]) - n[1][0], s = e.invertY(t[0][1]) - n[0][1], o = e.invertY(t[1][1]) - n[1][1];
  return e.translate(
    r > i ? (i + r) / 2 : Math.min(0, i) || Math.max(0, r),
    o > s ? (s + o) / 2 : Math.min(0, s) || Math.max(0, o)
  );
}
function lV() {
  var e = rV, t = sV, n = cV, i = oV, r = aV, s = [0, 1 / 0], o = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], a = 250, c = j7, l = oy("start", "zoom", "end"), u, f, h, d = 500, p = 150, y = 0, g = 10;
  function m(S) {
    S.property("__zoom", U2).on("wheel.zoom", T, { passive: !1 }).on("mousedown.zoom", D).on("dblclick.zoom", $).filter(r).on("touchstart.zoom", A).on("touchmove.zoom", F).on("touchend.zoom touchcancel.zoom", E).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  m.transform = function(S, M, B, N) {
    var L = S.selection ? S.selection() : S;
    L.property("__zoom", U2), S !== L ? v(S, M, B, N) : L.interrupt().each(function() {
      x(this, arguments).event(N).start().zoom(null, typeof M == "function" ? M.apply(this, arguments) : M).end();
    });
  }, m.scaleBy = function(S, M, B, N) {
    m.scaleTo(S, function() {
      var L = this.__zoom.k, k = typeof M == "function" ? M.apply(this, arguments) : M;
      return L * k;
    }, B, N);
  }, m.scaleTo = function(S, M, B, N) {
    m.transform(S, function() {
      var L = t.apply(this, arguments), k = this.__zoom, U = B == null ? w(L) : typeof B == "function" ? B.apply(this, arguments) : B, j = k.invert(U), P = typeof M == "function" ? M.apply(this, arguments) : M;
      return n(_(b(k, P), U, j), L, o);
    }, B, N);
  }, m.translateBy = function(S, M, B, N) {
    m.transform(S, function() {
      return n(this.__zoom.translate(
        typeof M == "function" ? M.apply(this, arguments) : M,
        typeof B == "function" ? B.apply(this, arguments) : B
      ), t.apply(this, arguments), o);
    }, null, N);
  }, m.translateTo = function(S, M, B, N, L) {
    m.transform(S, function() {
      var k = t.apply(this, arguments), U = this.__zoom, j = N == null ? w(k) : typeof N == "function" ? N.apply(this, arguments) : N;
      return n($6.translate(j[0], j[1]).scale(U.k).translate(
        typeof M == "function" ? -M.apply(this, arguments) : -M,
        typeof B == "function" ? -B.apply(this, arguments) : -B
      ), k, o);
    }, N, L);
  };
  function b(S, M) {
    return M = Math.max(s[0], Math.min(s[1], M)), M === S.k ? S : new Zi(M, S.x, S.y);
  }
  function _(S, M, B) {
    var N = M[0] - B[0] * S.k, L = M[1] - B[1] * S.k;
    return N === S.x && L === S.y ? S : new Zi(S.k, N, L);
  }
  function w(S) {
    return [(+S[0][0] + +S[1][0]) / 2, (+S[0][1] + +S[1][1]) / 2];
  }
  function v(S, M, B, 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 L = this, k = arguments, U = x(L, k).event(N), j = t.apply(L, k), P = B == null ? w(j) : typeof B == "function" ? B.apply(L, k) : B, K = Math.max(j[1][0] - j[0][0], j[1][1] - j[0][1]), Z = L.__zoom, et = typeof M == "function" ? M.apply(L, k) : M, tt = c(Z.invert(P).concat(K / Z.k), et.invert(P).concat(K / et.k));
      return function(H) {
        if (H === 1)
          H = et;
        else {
          var X = tt(H), V = K / X[2];
          H = new Zi(V, P[0] - X[0] * V, P[1] - X[1] * V);
        }
        U.zoom(null, H);
      };
    });
  }
  function x(S, M, B) {
    return !B && S.__zooming || new I(S, M);
  }
  function I(S, M) {
    this.that = S, this.args = M, this.active = 0, this.sourceEvent = null, this.extent = t.apply(S, M), this.taps = 0;
  }
  I.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, M) {
      return this.mouse && S !== "mouse" && (this.mouse[1] = M.invert(this.mouse[0])), this.touch0 && S !== "touch" && (this.touch0[1] = M.invert(this.touch0[0])), this.touch1 && S !== "touch" && (this.touch1[1] = M.invert(this.touch1[0])), this.that.__zoom = M, this.emit("zoom"), this;
    },
    end: function() {
      return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
    },
    emit: function(S) {
      var M = re(this.that).datum();
      l.call(
        S,
        this.that,
        new iV(S, {
          sourceEvent: this.sourceEvent,
          target: m,
          type: S,
          transform: this.that.__zoom,
          dispatch: l
        }),
        M
      );
    }
  };
  function T(S, ...M) {
    if (!e.apply(this, arguments))
      return;
    var B = x(this, M).event(S), N = this.__zoom, L = Math.max(s[0], Math.min(s[1], N.k * Math.pow(2, i.apply(this, arguments)))), k = ai(S);
    if (B.wheel)
      (B.mouse[0][0] !== k[0] || B.mouse[0][1] !== k[1]) && (B.mouse[1] = N.invert(B.mouse[0] = k)), clearTimeout(B.wheel);
    else {
      if (N.k === L)
        return;
      B.mouse = [k, N.invert(k)], Ha(this), B.start();
    }
    gl(S), B.wheel = setTimeout(U, p), B.zoom("mouse", n(_(b(N, L), B.mouse[0], B.mouse[1]), B.extent, o));
    function U() {
      B.wheel = null, B.end();
    }
  }
  function D(S, ...M) {
    if (h || !e.apply(this, arguments))
      return;
    var B = S.currentTarget, N = x(this, M, !0).event(S), L = re(S.view).on("mousemove.zoom", P, !0).on("mouseup.zoom", K, !0), k = ai(S, B), U = S.clientX, j = S.clientY;
    H3(S.view), Z0(S), N.mouse = [k, this.__zoom.invert(k)], Ha(this), N.start();
    function P(Z) {
      if (gl(Z), !N.moved) {
        var et = Z.clientX - U, tt = Z.clientY - j;
        N.moved = et * et + tt * tt > y;
      }
      N.event(Z).zoom("mouse", n(_(N.that.__zoom, N.mouse[0] = ai(Z, B), N.mouse[1]), N.extent, o));
    }
    function K(Z) {
      L.on("mousemove.zoom mouseup.zoom", null), K3(Z.view, N.moved), gl(Z), N.event(Z).end();
    }
  }
  function $(S, ...M) {
    if (e.apply(this, arguments)) {
      var B = this.__zoom, N = ai(S.changedTouches ? S.changedTouches[0] : S, this), L = B.invert(N), k = B.k * (S.shiftKey ? 0.5 : 2), U = n(_(b(B, k), N, L), t.apply(this, M), o);
      gl(S), a > 0 ? re(this).transition().duration(a).call(v, U, N, S) : re(this).call(m.transform, U, N, S);
    }
  }
  function A(S, ...M) {
    if (e.apply(this, arguments)) {
      var B = S.touches, N = B.length, L = x(this, M, S.changedTouches.length === N).event(S), k, U, j, P;
      for (Z0(S), U = 0; U < N; ++U)
        j = B[U], P = ai(j, this), P = [P, this.__zoom.invert(P), j.identifier], L.touch0 ? !L.touch1 && L.touch0[2] !== P[2] && (L.touch1 = P, L.taps = 0) : (L.touch0 = P, k = !0, L.taps = 1 + !!u);
      u && (u = clearTimeout(u)), k && (L.taps < 2 && (f = P[0], u = setTimeout(function() {
        u = null;
      }, d)), Ha(this), L.start());
    }
  }
  function F(S, ...M) {
    if (this.__zooming) {
      var B = x(this, M).event(S), N = S.changedTouches, L = N.length, k, U, j, P;
      for (gl(S), k = 0; k < L; ++k)
        U = N[k], j = ai(U, this), B.touch0 && B.touch0[2] === U.identifier ? B.touch0[0] = j : B.touch1 && B.touch1[2] === U.identifier && (B.touch1[0] = j);
      if (U = B.that.__zoom, B.touch1) {
        var K = B.touch0[0], Z = B.touch0[1], et = B.touch1[0], tt = B.touch1[1], H = (H = et[0] - K[0]) * H + (H = et[1] - K[1]) * H, X = (X = tt[0] - Z[0]) * X + (X = tt[1] - Z[1]) * X;
        U = b(U, Math.sqrt(H / X)), j = [(K[0] + et[0]) / 2, (K[1] + et[1]) / 2], P = [(Z[0] + tt[0]) / 2, (Z[1] + tt[1]) / 2];
      } else if (B.touch0)
        j = B.touch0[0], P = B.touch0[1];
      else
        return;
      B.zoom("touch", n(_(U, j, P), B.extent, o));
    }
  }
  function E(S, ...M) {
    if (this.__zooming) {
      var B = x(this, M).event(S), N = S.changedTouches, L = N.length, k, U;
      for (Z0(S), h && clearTimeout(h), h = setTimeout(function() {
        h = null;
      }, d), k = 0; k < L; ++k)
        U = N[k], B.touch0 && B.touch0[2] === U.identifier ? delete B.touch0 : B.touch1 && B.touch1[2] === U.identifier && delete B.touch1;
      if (B.touch1 && !B.touch0 && (B.touch0 = B.touch1, delete B.touch1), B.touch0)
        B.touch0[1] = this.__zoom.invert(B.touch0[0]);
      else if (B.end(), B.taps === 2 && (U = ai(U, this), Math.hypot(f[0] - U[0], f[1] - U[1]) < g)) {
        var j = re(this).on("dblclick.zoom");
        j && j.apply(this, arguments);
      }
    }
  }
  return m.wheelDelta = function(S) {
    return arguments.length ? (i = typeof S == "function" ? S : Wf(+S), m) : i;
  }, m.filter = function(S) {
    return arguments.length ? (e = typeof S == "function" ? S : Wf(!!S), m) : e;
  }, m.touchable = function(S) {
    return arguments.length ? (r = typeof S == "function" ? S : Wf(!!S), m) : r;
  }, m.extent = function(S) {
    return arguments.length ? (t = typeof S == "function" ? S : Wf([[+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 = l.on.apply(l, arguments);
    return S === l ? 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 cn(e) {
  return e != null && !Number.isNaN(e);
}
function ii(e, t) {
  return +cn(t) - +cn(e) || Be(e, t);
}
function ep(e, t) {
  return +cn(t) - +cn(e) || Gu(e, t);
}
function $b(e) {
  return e != null && `${e}` != "";
}
function np(e) {
  return isFinite(e) ? e : NaN;
}
function Gr(e) {
  return e > 0 && isFinite(e) ? e : NaN;
}
function Dy(e) {
  return e < 0 && isFinite(e) ? e : NaN;
}
const uV = /* @__PURE__ */ new Map([
  ["second", jr],
  ["minute", _y],
  ["hour", vy],
  ["day", Xc],
  // TODO local time equivalent of unixDay?
  ["week", $c],
  ["month", Iy],
  ["year", xi],
  ["monday", bu],
  ["tuesday", xA],
  ["wednesday", SA],
  ["thursday", Jo],
  ["friday", IA],
  ["saturday", $A],
  ["sunday", $c]
]), fV = /* @__PURE__ */ new Map([
  ["second", jr],
  ["minute", wy],
  ["hour", xy],
  ["day", mb],
  ["week", Ac],
  ["month", $y],
  ["year", Si],
  ["monday", _u],
  ["tuesday", AA],
  ["wednesday", MA],
  ["thursday", Zo],
  ["friday", TA],
  ["saturday", BA],
  ["sunday", Ac]
]);
function A6(e, t) {
  let n = `${e}`.toLowerCase();
  n.endsWith("s") && (n = n.slice(0, -1));
  let i = 1;
  const r = /^(?:(\d+)\s+)/.exec(n);
  switch (r && (n = n.slice(r[0].length), i = +r[1]), n) {
    case "quarter":
      n = "month", i *= 3;
      break;
    case "half":
      n = "month", i *= 6;
      break;
  }
  let s = t.get(n);
  if (!s)
    throw new Error(`unknown interval: ${e}`);
  if (!(i > 1))
    return s;
  if (!s.every)
    throw new Error(`non-periodic interval: ${n}`);
  return s.every(i);
}
function hV(e) {
  return A6(e, uV);
}
function M6(e) {
  return A6(e, fV);
}
function dV(e) {
  if (!e)
    return !1;
  const t = e.floor(new Date(Date.UTC(2e3, 11, 31)));
  return Si(t) >= t;
}
function pV(e) {
  if (!e)
    return !1;
  const t = e.floor(new Date(2e3, 11, 31));
  return xi(t) >= t;
}
const Mc = Object.getPrototypeOf(Uint8Array), yV = Object.prototype.toString;
function Lt(e, t, n) {
  const i = typeof t;
  return i === "string" ? z2(e, T6(t), n) : i === "function" ? z2(e, t, n) : i === "number" || t instanceof Date || i === "boolean" ? he(e, Ln(t), n) : typeof (t == null ? void 0 : t.transform) == "function" ? P2(t.transform(e), n) : P2(t, n);
}
function z2(e, t, n) {
  return he(e, (n == null ? void 0 : n.prototype) instanceof Mc ? mV(t) : t, n);
}
function P2(e, t) {
  return t === void 0 ? wn(e) : e instanceof t ? e : t.prototype instanceof Mc && !(e instanceof Mc) ? t.from(e, Tb) : t.from(e);
}
function mV(e) {
  return (t, n) => Tb(e(t, n));
}
const Hl = [null], T6 = (e) => (t) => t[e], In = { transform: ls }, lt = { transform: (e) => e }, Ab = () => 1, gV = () => !0, je = (e) => e == null ? e : `${e}`, kt = (e) => e == null ? e : +e, nf = (e) => e ? e[0] : void 0, xu = (e) => e ? e[1] : void 0, bV = (e) => e ? e[2] : void 0, Ln = (e) => () => e;
function Mb(e) {
  const t = +`${e}`.slice(1) / 100;
  return (n, i) => zs(n, t, i);
}
function pn(e) {
  return e instanceof Mc ? e : he(e, Tb, Float64Array);
}
function Tb(e) {
  return e == null ? NaN : Number(e);
}
function _V(e) {
  return he(e, B6);
}
function B6(e) {
  return e instanceof Date && !isNaN(e) ? e : typeof e == "string" ? R1(e) : e == null || isNaN(e = +e) ? void 0 : new Date(e);
}
function _n(e, t) {
  return e === void 0 && (e = t), e === null ? [void 0, "none"] : sf(e) ? [void 0, e] : [e, void 0];
}
function Te(e, t) {
  return e === void 0 && (e = t), e === null || typeof e == "number" ? [void 0, e] : [e, void 0];
}
function Oy(e, t, n) {
  if (e != null)
    return cs(e, t, n);
}
function cs(e, t, n) {
  const i = `${e}`.toLowerCase();
  if (!n.includes(i))
    throw new Error(`invalid ${t}: ${e}`);
  return i;
}
function wn(e) {
  return e == null || e instanceof Array || e instanceof Mc ? e : Array.from(e);
}
function he(e, t, n = Array) {
  return e == null ? e : e instanceof n ? e.map(t) : n.from(e, t);
}
function Dg(e, t = Array) {
  return e instanceof t ? e.slice() : t.from(e);
}
function N6({ x: e, x1: t, x2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function F6({ y: e, y1: t, y2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function Ey(e) {
  return N6(e) || F6(e) || e.interval !== void 0;
}
function Fi(e) {
  return (e == null ? void 0 : e.toString) === yV;
}
function Po(e) {
  return Fi(e) && (e.type !== void 0 || e.domain !== void 0);
}
function Pi(e) {
  return Fi(e) && typeof e.transform != "function";
}
function Vs(e) {
  return Pi(e) && e.value === void 0 && e.channel === void 0;
}
function D6(e, t, n, i = lt) {
  return t === void 0 && n === void 0 ? (t = 0, n = e === void 0 ? i : e) : t === void 0 ? t = e === void 0 ? 0 : e : n === void 0 && (n = e === void 0 ? 0 : e), [t, n];
}
function Di(e, t) {
  return e === void 0 && t === void 0 ? [nf, xu] : [e, t];
}
function no({ z: e, fill: t, stroke: n } = {}) {
  return e === void 0 && ([e] = _n(t)), e === void 0 && ([e] = _n(n)), e;
}
function ls(e) {
  const t = e.length, n = new Uint32Array(t);
  for (let i = 0; i < t; ++i)
    n[i] = i;
  return n;
}
function Ly(e, t) {
  return he(t, (n) => e[n]);
}
function Bb(e) {
  return e.length === 1 ? (t, n) => e(Ly(n, t)) : e;
}
function Fo(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function O6(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 Fn(e) {
  let t;
  return [
    {
      transform: () => t,
      label: us(e)
    },
    (n) => t = n
  ];
}
function un(e) {
  return e == null ? [e] : Fn(e);
}
function us(e, t) {
  return typeof e == "string" ? e : e && e.label !== void 0 ? e.label : t;
}
function ip(e, t) {
  return {
    transform(n) {
      const i = e.transform(n), r = t.transform(n);
      return vn(i) || vn(r) ? he(i, (s, o) => new Date((+i[o] + +r[o]) / 2)) : he(i, (s, o) => (+i[o] + +r[o]) / 2, Float64Array);
    },
    label: e.label
  };
}
function rp(e, t) {
  const n = E6(t == null ? void 0 : t.interval, t == null ? void 0 : t.type);
  return n ? he(e, n) : e;
}
function E6(e, t) {
  const n = Nb(e, t);
  return n && ((i) => cn(i) ? n.floor(i) : i);
}
function Nb(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: (i) => Math.floor(i * n) / n,
        offset: (i) => (i * n + 1) / n,
        // note: no optional step for simplicity
        range: (i, r) => Bn(Math.ceil(i * n), r * n).map((s) => s / n)
      } : {
        floor: (i) => Math.floor(i / n) * n,
        offset: (i) => i + n,
        // note: no optional step for simplicity
        range: (i, r) => Bn(Math.ceil(i / n), r / n).map((s) => s * n)
      };
    }
    if (typeof e == "string")
      return (t === "time" ? hV : M6)(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 Hc(e, t) {
  if (e = Nb(e, t), e && typeof e.range != "function")
    throw new Error("invalid interval: missing range method");
  return e;
}
function wV(e, t) {
  if (e = Hc(e, t), e && typeof e.ceil != "function")
    throw new Error("invalid interval: missing ceil method");
  return e;
}
function rf(e) {
  return e === void 0 || Pi(e) ? e : { value: e };
}
function vV(e) {
  return e == null ? null : {
    transform: (t) => Lt(t, e, Float64Array),
    label: us(e)
  };
}
function xV(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 L6(e) {
  for (const t of e)
    if (t != null)
      return typeof t != "object" || t instanceof Date;
}
function Qe(e) {
  for (const t of e) {
    if (t == null)
      continue;
    const n = typeof t;
    return n === "string" || n === "boolean";
  }
}
function vn(e) {
  for (const t of e)
    if (t != null)
      return t instanceof Date;
}
function SV(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "string" && isNaN(t) && R1(t);
}
function IV(e) {
  for (const t of e)
    if (t != null) {
      if (typeof t != "string")
        return !1;
      if (t.trim())
        return !isNaN(t);
    }
}
function R6(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "number";
}
function Q0(e, t) {
  let n;
  for (const i of e)
    if (i != null) {
      if (!t(i))
        return !1;
      n = !0;
    }
  return n;
}
function sf(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
  Zr(e) !== null);
}
function $V(e) {
  return typeof e == "number" && (0 <= e && e <= 1 || isNaN(e));
}
function ke(e) {
  return e == null || Tc(e);
}
function Tc(e) {
  return /^\s*none\s*$/i.test(e);
}
function AV(e) {
  return /^\s*round\s*$/i.test(e);
}
function C6(e, t) {
  return Oy(e, t, [
    "middle",
    "top-left",
    "top",
    "top-right",
    "right",
    "bottom-right",
    "bottom",
    "bottom-left",
    "left"
  ]);
}
function of(e = "middle") {
  return C6(e, "frameAnchor");
}
function Su(e) {
  if (e == null)
    return;
  const t = e[0], n = e[e.length - 1];
  return Gu(t, n);
}
function MV(e = {}, ...t) {
  let n = e;
  for (const i of t)
    for (const r in i)
      if (n[r] === void 0) {
        const s = i[r];
        n === e ? n = { ...n, [r]: s } : n[r] = s;
      }
  return n;
}
function TV(e) {
  console.warn("named iterables are deprecated; please use an object instead");
  const t = /* @__PURE__ */ new Set();
  return Object.fromEntries(
    Array.from(e, (n) => {
      const { name: i } = n;
      if (i == null)
        throw new Error("missing name");
      const r = `${i}`;
      if (r === "__proto__")
        throw new Error(`illegal name: ${r}`);
      if (t.has(r))
        throw new Error(`duplicate name: ${r}`);
      return t.add(r), [i, n];
    })
  );
}
function Fb(e) {
  return dr(e) ? TV(e) : e;
}
const Qi = Symbol("position"), fs = Symbol("color"), Ry = Symbol("radius"), Cy = Symbol("length"), ky = Symbol("opacity"), Uy = Symbol("symbol"), BV = Symbol("projection"), ve = /* @__PURE__ */ new Map([
  ["x", Qi],
  ["y", Qi],
  ["fx", Qi],
  ["fy", Qi],
  ["r", Ry],
  ["color", fs],
  ["opacity", ky],
  ["symbol", Uy],
  ["length", Cy],
  ["projection", BV]
]), k6 = Math.sqrt(3), U6 = 2 / k6, NV = {
  draw(e, t) {
    const n = Math.sqrt(t / Math.PI), i = n * U6, r = i / 2;
    e.moveTo(0, i), e.lineTo(n, r), e.lineTo(n, -r), e.lineTo(0, -i), e.lineTo(-n, -r), e.lineTo(-n, r), e.closePath();
  }
}, Db = /* @__PURE__ */ new Map([
  ["asterisk", e6],
  ["circle", vu],
  ["cross", n6],
  ["diamond", r6],
  ["diamond2", s6],
  ["hexagon", NV],
  ["plus", o6],
  ["square", a6],
  ["square2", c6],
  ["star", u6],
  ["times", p6],
  ["triangle", f6],
  ["triangle2", h6],
  ["wye", d6]
]);
function Ob(e) {
  return e && typeof e.draw == "function";
}
function FV(e) {
  return Ob(e) ? !0 : typeof e != "string" ? !1 : Db.has(e.toLowerCase());
}
function Eb(e) {
  if (e == null || Ob(e))
    return e;
  const t = Db.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid symbol: ${e}`);
}
function DV(e) {
  if (e == null || Ob(e))
    return [void 0, e];
  if (typeof e == "string") {
    const t = Db.get(`${e}`.toLowerCase());
    if (t)
      return [void 0, t];
  }
  return [e, void 0];
}
function pr({ filter: e, sort: t, reverse: n, transform: i, initializer: r, ...s } = {}, o) {
  if (i === void 0 && (e != null && (i = Lb(e)), t != null && !Vs(t) && (i = tm(i, Cb(t))), n && (i = tm(i, Rb))), o != null && r != null)
    throw new Error("transforms cannot be applied after initializers");
  return {
    ...s,
    ...(t === null || Vs(t)) && { sort: t },
    transform: tm(i, o)
  };
}
function Rn({ filter: e, sort: t, reverse: n, initializer: i, ...r } = {}, s) {
  return i === void 0 && (e != null && (i = Lb(e)), t != null && !Vs(t) && (i = em(i, Cb(t))), n && (i = em(i, Rb))), {
    ...r,
    ...(t === null || Vs(t)) && { sort: t },
    initializer: em(i, s)
  };
}
function tm(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, i, r) {
    return { data: n, facets: i } = e.call(this, n, i, r), t.call(this, wn(n), i, r);
  };
}
function em(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, i, r, ...s) {
    let o, a, c, l, u, f;
    return { data: a = n, facets: c = i, channels: o } = e.call(this, n, i, r, ...s), { data: u = a, facets: f = c, channels: l } = t.call(this, a, c, { ...r, ...o }, ...s), { data: u, facets: f, channels: { ...o, ...l } };
  };
}
function zy(e, t) {
  return (e.initializer != null ? Rn : pr)(e, t);
}
function OV(e, t) {
  return zy(t, Lb(e));
}
function Lb(e) {
  return (t, n) => {
    const i = Lt(t, e);
    return { data: t, facets: n.map((r) => r.filter((s) => i[s])) };
  };
}
function EV({ sort: e, ...t } = {}) {
  return {
    ...zy(t, Rb),
    sort: Vs(e) ? e : null
  };
}
function Rb(e, t) {
  return { data: e, facets: t.map((n) => n.slice().reverse()) };
}
function LV({ seed: e, sort: t, ...n } = {}) {
  return {
    ...zy(n, P6(e == null ? Math.random : db(e))),
    sort: Vs(t) ? t : null
  };
}
function z6(e, { sort: t, ...n } = {}) {
  return {
    ...(Pi(e) && e.channel !== void 0 ? Rn : zy)(n, Cb(e)),
    sort: Vs(t) ? t : null
  };
}
function Cb(e) {
  return (typeof e == "function" && e.length !== 1 ? RV : P6)(e);
}
function RV(e) {
  return (t, n) => {
    const i = (r, s) => e(t[r], t[s]);
    return { data: t, facets: n.map((r) => r.slice().sort(i)) };
  };
}
function P6(e) {
  let t, n;
  ({ channel: t, value: e, order: n } = { ...rf(e) });
  const i = t == null ? void 0 : t.startsWith("-");
  if (i && (t = t.slice(1)), n === void 0 && (n = i ? ep : ii), typeof n != "function")
    switch (`${n}`.toLowerCase()) {
      case "ascending":
        n = ii;
        break;
      case "descending":
        n = ep;
        break;
      default:
        throw new Error(`invalid order: ${n}`);
    }
  return (r, s, o) => {
    let a;
    if (t === void 0)
      a = Lt(r, 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 = (l, u) => n(a[l], a[u]);
    return { data: r, facets: s.map((l) => l.slice().sort(c)) };
  };
}
function kb(e, t) {
  return Py(null, null, e, t);
}
function Iu(e = { y: "count" }, t = {}) {
  const { x: n = lt } = t;
  if (n == null)
    throw new Error("missing channel: x");
  return Py(n, null, e, t);
}
function $u(e = { x: "count" }, t = {}) {
  const { y: n = lt } = t;
  if (n == null)
    throw new Error("missing channel: y");
  return Py(null, n, e, t);
}
function Ub(e = { fill: "count" }, t = {}) {
  let { x: n, y: i } = t;
  if ([n, i] = Di(n, i), n == null)
    throw new Error("missing channel: x");
  if (i == null)
    throw new Error("missing channel: y");
  return Py(n, i, e, t);
}
function Py(e, t, {
  data: n = Yb,
  filter: i,
  sort: r,
  reverse: s,
  ...o
  // output channel definitions
} = {}, a = {}) {
  o = zb(o, a), n = Vy(n, lt), r = r == null ? void 0 : Pb("sort", r, a), i = i == null ? void 0 : Vb("filter", i, a);
  const [c, l] = un(e), [u, f] = un(t), {
    z: h,
    fill: d,
    stroke: p,
    x1: y,
    x2: g,
    // consumed if x is an output
    y1: m,
    y2: b,
    // consumed if y is an output
    ..._
  } = a, [w, v] = un(h), [x] = _n(d), [I] = _n(p), [T, D] = un(x), [$, A] = un(I);
  return {
    ..."z" in a && { z: w || h },
    ..."fill" in a && { fill: T || d },
    ..."stroke" in a && { stroke: $ || p },
    ...pr(_, (F, E, S) => {
      const M = rp(Lt(F, e), S == null ? void 0 : S.x), B = rp(Lt(F, t), S == null ? void 0 : S.y), N = Lt(F, h), L = Lt(F, x), k = Lt(F, I), U = jb(o, { z: N, fill: L, stroke: k }), j = [], P = [], K = M && l([]), Z = B && f([]), et = N && v([]), tt = L && D([]), H = k && A([]);
      let X = 0;
      for (const V of o)
        V.initialize(F);
      r && r.initialize(F), i && i.initialize(F);
      for (const V of E) {
        const G = [];
        for (const J of o)
          J.scope("facet", V);
        r && r.scope("facet", V), i && i.scope("facet", V);
        for (const [J, z] of Ka(V, U))
          for (const [nt, ut] of Ka(z, B))
            for (const [Gt, Ot] of Ka(ut, M))
              if (!(i && !i.reduce(Ot))) {
                G.push(X++), P.push(n.reduceIndex(Ot, F)), M && K.push(Gt), B && Z.push(nt), N && et.push(U === N ? J : N[Ot[0]]), L && tt.push(U === L ? J : L[Ot[0]]), k && H.push(U === k ? J : k[Ot[0]]);
                for (const Q of o)
                  Q.reduce(Ot);
                r && r.reduce(Ot);
              }
        j.push(G);
      }
      return V6(j, r, s), { data: P, facets: j };
    }),
    ...!Bs(o, "x") && (c ? { x: c } : { x1: y, x2: g }),
    ...!Bs(o, "y") && (u ? { y: u } : { y1: m, y2: b }),
    ...Object.fromEntries(o.map(({ name: F, output: E }) => [F, E]))
  };
}
function Bs(e, ...t) {
  for (const { name: n } of e)
    if (t.includes(n))
      return !0;
  return !1;
}
function zb(e, t, n = Pb) {
  const i = Object.entries(e);
  return t.title != null && e.title === void 0 && i.push(["title", PV]), t.href != null && e.href === void 0 && i.push(["href", qb]), i.filter(([, r]) => r !== void 0).map(([r, s]) => s === null ? CV(r) : n(r, s, t));
}
function Pb(e, t, n, i = Vb) {
  let r;
  Fi(t) && "reduce" in t && (r = t.scale, t = t.reduce);
  const s = i(e, t, n), [o, a] = Fn(s.label);
  let c;
  return {
    name: e,
    output: r === void 0 ? o : { value: o, scale: r },
    initialize(l) {
      s.initialize(l), c = a([]);
    },
    scope(l, u) {
      s.scope(l, u);
    },
    reduce(l, u) {
      c.push(s.reduce(l, u));
    }
  };
}
function CV(e) {
  return { name: e, initialize() {
  }, scope() {
  }, reduce() {
  } };
}
function Vb(e, t, n, i = Vy) {
  const r = O6(e, n), s = i(t, r);
  let o, a;
  return {
    label: us(s === sp ? null : r, s.label),
    initialize(c) {
      o = r === void 0 ? c : Lt(c, r), s.scope === "data" && (a = s.reduceIndex(ls(c), o));
    },
    scope(c, l) {
      s.scope === c && (a = s.reduceIndex(l, o));
    },
    reduce(c, l) {
      return s.scope == null ? s.reduceIndex(c, o, l) : s.reduceIndex(c, o, a, l);
    }
  };
}
function Ka(e, t) {
  return t ? cu(
    as(e, (n) => t[n]),
    nf
  ) : [[, e]];
}
function Vy(e, t, n = kV) {
  if (e == null)
    return n(e);
  if (typeof e.reduceIndex == "function")
    return e;
  if (typeof e.reduce == "function" && Fi(e))
    return UV(e);
  if (typeof e == "function")
    return zV(e);
  if (/^p\d{2}$/i.test(e))
    return Ar(Mb(e));
  switch (`${e}`.toLowerCase()) {
    case "first":
      return qb;
    case "last":
      return VV;
    case "identity":
      return Yb;
    case "count":
      return sp;
    case "distinct":
      return jV;
    case "sum":
      return t == null ? sp : YV;
    case "proportion":
      return j2(t, "data");
    case "proportion-facet":
      return j2(t, "facet");
    case "deviation":
      return Ar(ry);
    case "min":
      return Ar(ze);
    case "min-index":
      return Ar(yL);
    case "max":
      return Ar(Se);
    case "max-index":
      return Ar(pL);
    case "mean":
      return V2(G1);
    case "median":
      return V2(fu);
    case "variance":
      return Ar(P1);
    case "mode":
      return Ar(R3);
  }
  return n(e);
}
function kV(e) {
  throw new Error(`invalid reduce: ${e}`);
}
function jb(e, t) {
  for (const n in t) {
    const i = t[n];
    if (i !== void 0 && !e.some((r) => r.name === n))
      return i;
  }
}
function V6(e, t, n) {
  if (t) {
    const i = t.output.transform(), r = (s, o) => ii(i[s], i[o]);
    e.forEach((s) => s.sort(r));
  }
  n && e.forEach((i) => i.reverse());
}
function UV(e) {
  return console.warn("deprecated reduce interface; implement reduceIndex instead."), { ...e, reduceIndex: e.reduce.bind(e) };
}
function zV(e) {
  return {
    reduceIndex(t, n, i) {
      return e(Ly(n, t), i);
    }
  };
}
function Ar(e) {
  return {
    reduceIndex(t, n) {
      return e(t, (i) => n[i]);
    }
  };
}
function V2(e) {
  return {
    reduceIndex(t, n) {
      const i = e(t, (r) => n[r]);
      return vn(n) ? new Date(i) : i;
    }
  };
}
const Yb = {
  reduceIndex(e, t) {
    return Ly(t, e);
  }
}, qb = {
  reduceIndex(e, t) {
    return t[e[0]];
  }
}, PV = {
  reduceIndex(e, t) {
    const i = cu(
      Wa(
        e,
        (s) => s.length,
        (s) => t[s]
      ),
      xu
    ), r = i.slice(-5).reverse();
    if (r.length < i.length) {
      const s = i.slice(0, -4);
      r[5 - 1] = [`… ${s.length.toLocaleString("en-US")} more`, or(s, xu)];
    }
    return r.map(([s, o]) => `${s} (${o.toLocaleString("en-US")})`).join(`
`);
  }
}, VV = {
  reduceIndex(e, t) {
    return t[e[e.length - 1]];
  }
}, sp = {
  label: "Frequency",
  reduceIndex(e) {
    return e.length;
  }
}, jV = {
  label: "Distinct",
  reduceIndex(e, t) {
    const n = new sy();
    for (const i of e)
      n.add(t[i]);
    return n.size;
  }
}, YV = Ar(or);
function j2(e, t) {
  return e == null ? { scope: t, label: "Frequency", reduceIndex: (n, i, r = 1) => n.length / r } : { scope: t, reduceIndex: (n, i, r = 1) => or(n, (s) => i[s]) / r };
}
function Au(e, { scale: t, type: n, value: i, filter: r, hint: s }, o) {
  return s === void 0 && typeof (i == null ? void 0 : i.transform) == "function" && (s = i.hint), Y6(o, {
    scale: t,
    type: n,
    value: Lt(e, i),
    label: us(i),
    filter: r,
    hint: s
  });
}
function j6(e, t) {
  return Object.fromEntries(
    Object.entries(e).map(([n, i]) => [n, Au(t, i, n)])
  );
}
function Wb(e, t) {
  const n = Object.fromEntries(
    Object.entries(e).map(([i, { scale: r, value: s }]) => {
      const o = r == null ? null : t[r];
      return [i, o == null ? s : he(s, o)];
    })
  );
  return n.channels = e, n;
}
function Y6(e, t) {
  const { scale: n, value: i } = t;
  if (n === !0 || n === "auto")
    switch (e) {
      case "fill":
      case "stroke":
      case "color":
        t.scale = n !== !0 && Q0(i, sf) ? null : "color";
        break;
      case "fillOpacity":
      case "strokeOpacity":
      case "opacity":
        t.scale = n !== !0 && Q0(i, $V) ? null : "opacity";
        break;
      case "symbol":
        n !== !0 && Q0(i, FV) ? (t.scale = null, t.value = he(i, Eb)) : t.scale = "symbol";
        break;
      default:
        t.scale = ve.has(e) ? e : null;
        break;
    }
  else if (n === !1)
    t.scale = null;
  else if (n != null && !ve.has(n))
    throw new Error(`unknown scale: ${n}`);
  return t;
}
function qV(e, t, n, i, r) {
  const { order: s, reverse: o, reduce: a = !0, limit: c } = r;
  for (const l in r) {
    if (!ve.has(l))
      continue;
    let { value: u, order: f = s, reverse: h = o, reduce: d = a, limit: p = c } = rf(r[l]);
    const y = u == null ? void 0 : u.startsWith("-");
    if (y && (u = u.slice(1)), f = f === void 0 ? y !== (u === "width" || u === "height") ? W6 : q6 : XV(f), d == null || d === !1)
      continue;
    const g = l === "fx" || l === "fy" ? GV(t, i[l]) : WV(n, l);
    if (!g)
      throw new Error(`missing channel for scale: ${l}`);
    const m = g.value, [b = 0, _ = 1 / 0] = dr(p) ? p : p < 0 ? [p] : [0, p];
    if (u == null)
      g.domain = () => {
        let w = Array.from(new sy(m));
        return h && (w = w.reverse()), (b !== 0 || _ !== 1 / 0) && (w = w.slice(b, _)), w;
      };
    else {
      const w = u === "data" ? e : u === "height" ? Y2(n, "y1", "y2") : u === "width" ? Y2(n, "x1", "x2") : Og(n, u, u === "y" ? "y2" : u === "x" ? "x2" : void 0), v = Vy(d === !0 ? "max" : d, w);
      g.domain = () => {
        let x = lL(
          ls(m),
          (I) => v.reduceIndex(I, w),
          (I) => m[I]
        );
        return f && x.sort(f), h && x.reverse(), (b !== 0 || _ !== 1 / 0) && (x = x.slice(b, _)), x.map(nf);
      };
    }
  }
}
function WV(e, t) {
  for (const n in e) {
    const i = e[n];
    if (i.scale === t)
      return i;
  }
}
function GV(e, t) {
  const n = e.original;
  if (n === e)
    return t;
  const i = t.value, r = t.value = [];
  for (let s = 0; s < n.length; ++s) {
    const o = i[n[s][0]];
    for (const a of e[s])
      r[a] = o;
  }
  return t;
}
function Y2(e, t, n) {
  const i = Og(e, t), r = Og(e, n);
  return he(r, (s, o) => Math.abs(s - i[o]), Float64Array);
}
function Og(e, t, n) {
  let i = e[t];
  if (!i && n !== void 0 && (i = e[n]), i)
    return i.value;
  throw new Error(`missing channel: ${t}`);
}
function XV(e) {
  if (e == null || typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "ascending":
      return q6;
    case "descending":
      return W6;
  }
  throw new Error(`invalid order: ${e}`);
}
function q6([e, t], [n, i]) {
  return ii(t, i) || ii(e, n);
}
function W6([e, t], [n, i]) {
  return ep(t, i) || ii(e, n);
}
function G6(e, t) {
  let n = e[t];
  if (n) {
    for (; n.source; )
      n = n.source;
    return n.source === null ? null : n;
  }
}
function jy(e = {}) {
  const { document: t = typeof window < "u" ? window.document : void 0 } = e;
  return { document: t };
}
function Wt(e, { document: t }) {
  return re(cy(e).call(t.documentElement));
}
let Eg = 0;
function HV() {
  const e = Eg;
  return Eg = 0, e;
}
function ir(e) {
  console.warn(e), ++Eg;
}
const X6 = Math.PI, _r = 2 * X6, q2 = 0.618;
function KV({
  projection: e,
  inset: t = 0,
  insetTop: n = t,
  insetRight: i = t,
  insetBottom: r = t,
  insetLeft: s = t
} = {}, o) {
  if (e == null)
    return;
  if (typeof e.stream == "function")
    return e;
  let a, c, l = "frame";
  if (Fi(e)) {
    let v;
    if ({
      type: e,
      domain: c,
      inset: v,
      insetTop: n = v !== void 0 ? v : n,
      insetRight: i = v !== void 0 ? v : i,
      insetBottom: r = v !== void 0 ? v : r,
      insetLeft: s = v !== void 0 ? v : s,
      clip: l = l,
      ...a
    } = e, e == null)
      return;
  }
  typeof e != "function" && ({ type: e } = H6(e));
  const { width: u, height: f, marginLeft: h, marginRight: d, marginTop: p, marginBottom: y } = o, g = u - h - d - s - i, m = f - p - y - n - r;
  if (e = e == null ? void 0 : e({ width: g, height: m, clip: l, ...a }), e == null)
    return;
  l = JV(l, h, p, u - d, f - y);
  let b = h + s, _ = p + n, w;
  if (c != null) {
    const [[v, x], [I, T]] = to(e).bounds(c), D = Math.min(g / (I - v), m / (T - x));
    D > 0 ? (b -= (D * (v + I) - g) / 2, _ -= (D * (x + T) - m) / 2, w = jd({
      point($, A) {
        this.stream.point($ * D + b, A * D + _);
      }
    })) : ir("Warning: the projection could not be fit to the specified domain; using the default scale.");
  }
  return w ?? (w = b === 0 && _ === 0 ? K6() : jd({
    point(v, x) {
      this.stream.point(v + b, x + _);
    }
  })), { stream: (v) => e.stream(w.stream(l(v))) };
}
function H6(e) {
  switch (`${e}`.toLowerCase()) {
    case "albers-usa":
      return si(K9, 0.7463, 0.4673);
    case "albers":
      return Gf(K$, 0.7463, 0.4673);
    case "azimuthal-equal-area":
      return si(J9, 4, 4);
    case "azimuthal-equidistant":
      return si(Z9, _r, _r);
    case "conic-conformal":
      return Gf(eU, _r, _r);
    case "conic-equal-area":
      return Gf(Yd, 6.1702, 2.9781);
    case "conic-equidistant":
      return Gf(rU, 7.312, 3.6282);
    case "equal-earth":
      return si(oU, 5.4133, 2.6347);
    case "equirectangular":
      return si(nU, _r, X6);
    case "gnomonic":
      return si(aU, 3.4641, 3.4641);
    case "identity":
      return { type: K6 };
    case "reflect-y":
      return { type: ZV };
    case "mercator":
      return si(Q9, _r, _r);
    case "orthographic":
      return si(cU, 2, 2);
    case "stereographic":
      return si(lU, 2, 2);
    case "transverse-mercator":
      return si(uU, _r, _r);
    default:
      throw new Error(`unknown projection type: ${e}`);
  }
}
function JV(e, t, n, i, r) {
  if (e === !1 || e == null || typeof e == "number")
    return (s) => s;
  switch (e === !0 && (e = "frame"), `${e}`.toLowerCase()) {
    case "frame":
      return E$(t, n, i, r);
    default:
      throw new Error(`unknown projection clip type: ${e}`);
  }
}
function si(e, t, n) {
  return {
    type: ({ width: i, height: r, rotate: s, precision: o = 0.15, clip: a }) => {
      var l, u, f;
      const c = e();
      return o != null && ((l = c.precision) == null || l.call(c, o)), s != null && ((u = c.rotate) == null || u.call(c, s)), typeof a == "number" && ((f = c.clipAngle) == null || f.call(c, a)), c.scale(Math.min(i / t, r / n)), c.translate([i / 2, r / 2]), c;
    },
    aspectRatio: n / t
  };
}
function Gf(e, t, n) {
  const { type: i, aspectRatio: r } = si(e, t, n);
  return {
    type: (s) => {
      const { parallels: o, domain: a, width: c, height: l } = s, u = i(s);
      return o != null && (u.parallels(o), a === void 0 && u.fitSize([c, l], { type: "Sphere" })), u;
    },
    aspectRatio: r
  };
}
const K6 = Ln({ stream: (e) => e }), ZV = Ln(
  jd({
    point(e, t) {
      this.stream.point(e, -t);
    }
  })
);
function J6(e, t, n, i) {
  const r = n[e], s = n[t], o = r.length, a = n[e] = new Float64Array(o).fill(NaN), c = n[t] = new Float64Array(o).fill(NaN);
  let l;
  const u = i.stream({
    point(f, h) {
      a[l] = f, c[l] = h;
    }
  });
  for (l = 0; l < o; ++l)
    u.point(r[l], s[l]);
}
function QV({ projection: e } = {}) {
  return e == null ? !1 : typeof e.stream == "function" ? !0 : (Fi(e) && (e = e.type), e != null);
}
function tj(e) {
  if (typeof (e == null ? void 0 : e.stream) == "function")
    return q2;
  if (Fi(e) && (e = e.type), e != null) {
    if (typeof e != "function") {
      const { aspectRatio: t } = H6(e);
      if (t)
        return t;
    }
    return q2;
  }
}
function Yy(e, t, { projection: n }) {
  const { x: i, y: r } = e;
  let s = {};
  return i && (s.x = i), r && (s.y = r), s = Wb(s, t), n && (i == null ? void 0 : i.scale) === "x" && (r == null ? void 0 : r.scale) === "y" && J6("x", "y", s, n), i && (s.x = pn(s.x)), r && (s.y = pn(s.y)), s;
}
function ej(e) {
  const t = [], n = [], i = { scale: "x", value: t }, r = { scale: "y", value: n }, s = {
    point(o, a) {
      t.push(o), n.push(a);
    },
    lineStart() {
    },
    lineEnd() {
    },
    polygonStart() {
    },
    polygonEnd() {
    },
    sphere() {
    }
  };
  for (const o of e.value)
    Is(o, s);
  return [i, r];
}
const Z6 = /* @__PURE__ */ new Map([
  ["accent", bP],
  ["category10", gP],
  ["dark2", _P],
  ["paired", wP],
  ["pastel1", vP],
  ["pastel2", xP],
  ["set1", SP],
  ["set2", IP],
  ["set3", $P],
  ["tableau10", AP]
]);
function nj(e) {
  return e != null && Z6.has(`${e}`.toLowerCase());
}
const W2 = new Map([
  ...Z6,
  // diverging
  ["brbg", wr(zA, PA)],
  ["prgn", wr(VA, jA)],
  ["piyg", wr(YA, qA)],
  ["puor", wr(WA, GA)],
  ["rdbu", wr(Bg, Xd)],
  ["rdgy", wr(XA, HA)],
  ["rdylbu", wr(Ng, Hd)],
  ["rdylgn", wr(KA, JA)],
  ["spectral", wr(ZA, QA)],
  // reversed diverging (for temperature data)
  ["burd", G2(Bg, Xd)],
  ["buylrd", G2(Ng, Hd)],
  // sequential (single-hue)
  ["blues", Re(IM, $M)],
  ["greens", Re(AM, MM)],
  ["greys", Re(TM, BM)],
  ["oranges", Re(EM, LM)],
  ["purples", Re(NM, FM)],
  ["reds", Re(DM, OM)],
  // sequential (multi-hue)
  ["turbo", vr(VM)],
  ["viridis", vr(jM)],
  ["magma", vr(YM)],
  ["inferno", vr(qM)],
  ["plasma", vr(WM)],
  ["cividis", vr(RM)],
  ["cubehelix", vr(CM)],
  ["warm", vr(kM)],
  ["cool", vr(UM)],
  ["bugn", Re(tM, eM)],
  ["bupu", Re(nM, iM)],
  ["gnbu", Re(rM, sM)],
  ["orrd", Re(oM, aM)],
  ["pubu", Re(uM, fM)],
  ["pubugn", Re(cM, lM)],
  ["purd", Re(hM, dM)],
  ["rdpu", Re(pM, yM)],
  ["ylgn", Re(bM, _M)],
  ["ylgnbu", Re(mM, gM)],
  ["ylorbr", Re(wM, vM)],
  ["ylorrd", Re(xM, SM)],
  // cyclical
  ["rainbow", X2(zM)],
  ["sinebow", X2(PM)]
]);
function Re(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 ? wi(t, n) : e[n]);
}
function wr(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][0], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 11 ? wi(t, n) : e[n]);
}
function G2(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][2], e[3][0]] : (n = Math.max(3, Math.floor(n)), n > 11 ? wi((i) => t(1 - i), n) : e[n].slice().reverse());
}
function vr(e) {
  return ({ length: t }) => wi(e, Math.max(2, Math.floor(t)));
}
function X2(e) {
  return ({ length: t }) => wi(e, Math.floor(t) + 1).slice(0, -1);
}
function Q6(e) {
  const t = `${e}`.toLowerCase();
  if (!W2.has(t))
    throw new Error(`unknown ordinal scheme: ${t}`);
  return W2.get(t);
}
function qy(e, t) {
  const n = Q6(e), i = typeof n == "function" ? n({ length: t }) : n;
  return i.length !== t ? i.slice(0, t) : i;
}
function ij(e, t = "greys") {
  const n = /* @__PURE__ */ new Set(), [i, r] = qy(t, 2);
  for (const s of e)
    if (s != null)
      if (s === !0)
        n.add(r);
      else if (s === !1)
        n.add(i);
      else
        return;
  return [...n];
}
const H2 = /* @__PURE__ */ new Map([
  // diverging
  ["brbg", PA],
  ["prgn", jA],
  ["piyg", qA],
  ["puor", GA],
  ["rdbu", Xd],
  ["rdgy", HA],
  ["rdylbu", Hd],
  ["rdylgn", JA],
  ["spectral", QA],
  // reversed diverging (for temperature data)
  ["burd", (e) => Xd(1 - e)],
  ["buylrd", (e) => Hd(1 - e)],
  // sequential (single-hue)
  ["blues", $M],
  ["greens", MM],
  ["greys", BM],
  ["purples", FM],
  ["reds", OM],
  ["oranges", LM],
  // sequential (multi-hue)
  ["turbo", VM],
  ["viridis", jM],
  ["magma", YM],
  ["inferno", qM],
  ["plasma", WM],
  ["cividis", RM],
  ["cubehelix", CM],
  ["warm", kM],
  ["cool", UM],
  ["bugn", eM],
  ["bupu", iM],
  ["gnbu", sM],
  ["orrd", aM],
  ["pubugn", lM],
  ["pubu", fM],
  ["purd", dM],
  ["rdpu", yM],
  ["ylgnbu", gM],
  ["ylgn", _M],
  ["ylorbr", vM],
  ["ylorrd", SM],
  // cyclical
  ["rainbow", zM],
  ["sinebow", PM]
]);
function Gb(e) {
  const t = `${e}`.toLowerCase();
  if (!H2.has(t))
    throw new Error(`unknown quantitative scheme: ${t}`);
  return H2.get(t);
}
const rj = /* @__PURE__ */ new Set([
  "brbg",
  "prgn",
  "piyg",
  "puor",
  "rdbu",
  "rdgy",
  "rdylbu",
  "rdylgn",
  "spectral",
  "burd",
  "buylrd"
]);
function sj(e) {
  return e != null && rj.has(`${e}`.toLowerCase());
}
const t4 = (e) => (t) => e(1 - t), nm = [0, 1], K2 = /* @__PURE__ */ new Map([
  // numbers
  ["number", Xe],
  // color spaces
  ["rgb", Xo],
  ["hsl", q7],
  ["hcl", X7],
  ["lab", W7]
]);
function e4(e) {
  const t = `${e}`.toLowerCase();
  if (!K2.has(t))
    throw new Error(`unknown interpolator: ${t}`);
  return K2.get(t);
}
function af(e, t, n, {
  type: i,
  nice: r,
  clamp: s,
  zero: o,
  domain: a = i4(e, n),
  unknown: c,
  round: l,
  scheme: u,
  interval: f,
  range: h = ve.get(e) === Ry ? mj(n, a) : ve.get(e) === Cy ? gj(n, a) : ve.get(e) === ky ? nm : void 0,
  interpolate: d = ve.get(e) === fs ? u == null && h !== void 0 ? Xo : Gb(u !== void 0 ? u : i === "cyclical" ? "rainbow" : "turbo") : l ? tb : Xe,
  reverse: p
}) {
  if (f = Hc(f, i), (i === "cyclical" || i === "sequential") && (i = "linear"), p = !!p, h !== void 0) {
    const y = (a = wn(a)).length, g = (h = wn(h)).length;
    y > g ? (a = a.slice(0, g), ir(`Warning: the ${e} scale domain contains extra elements.`)) : g > y && (h = h.slice(0, y), ir(`Warning: the ${e} scale range contains extra elements.`));
  }
  if (typeof d != "function" && (d = e4(d)), d.length === 1 ? (p && (d = t4(d), p = !1), h === void 0 && (h = Float64Array.from(a, (y, g) => g / (a.length - 1)), h.length === 2 && (h = nm)), t.interpolate((h === nm ? Ln : Hb)(d))) : t.interpolate(d), o) {
    const [y, g] = He(a);
    (y > 0 || g < 0) && (a = Dg(a), Su(a) !== Math.sign(y) ? a[a.length - 1] = 0 : a[0] = 0);
  }
  return p && (a = yd(a)), t.domain(a).unknown(c), r && (t.nice(oj(r, i)), a = t.domain()), h !== void 0 && t.range(h), s && t.clamp(s), { type: i, domain: a, range: h, scale: t, interpolate: d, interval: f };
}
function oj(e, t) {
  return e === !0 ? void 0 : typeof e == "number" ? e : wV(e, t);
}
function aj(e, t, n) {
  return af(e, by(), t, n);
}
function cj(e, t, n) {
  return n4(e, t, { ...n, exponent: 0.5 });
}
function n4(e, t, { exponent: n = 1, ...i }) {
  return af(e, _A().exponent(n), t, { ...i, type: "pow" });
}
function lj(e, t, { base: n = 10, domain: i = bj(t), ...r }) {
  return af(e, yA().base(n), t, { ...r, domain: i });
}
function uj(e, t, { constant: n = 1, ...i }) {
  return af(e, gA().constant(n), t, i);
}
function fj(e, t, {
  range: n,
  quantiles: i = n === void 0 ? 5 : (n = [...n]).length,
  // deprecated; use n instead
  n: r = i,
  scheme: s = "rdylbu",
  domain: o = _j(t),
  unknown: a,
  interpolate: c,
  reverse: l
}) {
  return n === void 0 && (n = c !== void 0 ? wi(c, r) : ve.get(e) === fs ? qy(s, r) : void 0), o.length > 0 && (o = wA(o, n === void 0 ? { length: r } : n).quantiles()), Xb(e, t, { domain: o, range: n, reverse: l, unknown: a });
}
function hj(e, t, {
  range: n,
  n: i = n === void 0 ? 5 : (n = [...n]).length,
  scheme: r = "rdylbu",
  domain: s = i4(e, t),
  unknown: o,
  interpolate: a,
  reverse: c
}) {
  const [l, u] = He(s);
  let f;
  return n === void 0 ? (f = Us(l, u, i), f[0] <= l && f.splice(0, 1), f[f.length - 1] >= u && f.pop(), i = f.length + 1, n = a !== void 0 ? wi(a, i) : ve.get(e) === fs ? qy(r, i) : void 0) : (f = wi(Xe(l, u), i + 1).slice(1, -1), l instanceof Date && (f = f.map((h) => new Date(h)))), Su(wn(s)) < 0 && f.reverse(), Xb(e, t, { domain: f, range: n, reverse: c, unknown: o });
}
function Xb(e, t, {
  domain: n = [0],
  // explicit thresholds in ascending order
  unknown: i,
  scheme: r = "rdylbu",
  interpolate: s,
  range: o = s !== void 0 ? wi(s, n.length + 1) : ve.get(e) === fs ? qy(r, n.length + 1) : void 0,
  reverse: a
}) {
  n = wn(n);
  const c = Su(n);
  if (!isNaN(c) && !dj(n, c))
    throw new Error(`the ${e} scale has a non-monotonic domain`);
  return a && (o = yd(o)), {
    type: "threshold",
    scale: vA(c < 0 ? yd(n) : n, o === void 0 ? [] : o).unknown(i),
    domain: n,
    range: o
  };
}
function dj(e, t) {
  for (let n = 1, i = e.length, r = e[0]; n < i; ++n) {
    const s = Gu(r, r = e[n]);
    if (s !== 0 && s !== t)
      return !1;
  }
  return !0;
}
function pj() {
  return { type: "identity", scale: hA() };
}
function Mu(e, t = np) {
  return e.length ? [
    ze(e, ({ value: n }) => n === void 0 ? n : ze(n, t)),
    Se(e, ({ value: n }) => n === void 0 ? n : Se(n, t))
  ] : [0, 1];
}
function i4(e, t) {
  const n = ve.get(e);
  return (n === Ry || n === ky || n === Cy ? yj : Mu)(t);
}
function yj(e) {
  return [0, e.length ? Se(e, ({ value: t }) => t === void 0 ? t : Se(t, np)) : 1];
}
function mj(e, t) {
  const n = e.find(({ radius: o }) => o !== void 0);
  if (n !== void 0)
    return [0, n.radius];
  const i = zs(e, 0.5, ({ value: o }) => o === void 0 ? NaN : zs(o, 0.25, Gr)), r = t.map((o) => 3 * Math.sqrt(o / i)), s = 30 / Se(r);
  return s < 1 ? r.map((o) => o * s) : r;
}
function gj(e, t) {
  const n = fu(e, ({ value: s }) => s === void 0 ? NaN : fu(s, Math.abs)), i = t.map((s) => 12 * s / n), r = 60 / Se(i);
  return r < 1 ? i.map((s) => s * r) : i;
}
function bj(e) {
  for (const { value: t } of e)
    if (t !== void 0)
      for (let n of t) {
        if (n > 0)
          return Mu(e, Gr);
        if (n < 0)
          return Mu(e, Dy);
      }
  return [1, 10];
}
function _j(e) {
  const t = [];
  for (const { value: n } of e)
    if (n !== void 0)
      for (const i of n)
        t.push(i);
  return t;
}
function Hb(e) {
  return (t, n) => (i) => e(t + i * (n - t));
}
function Wy(e, t, n, i, {
  type: r,
  nice: s,
  clamp: o,
  domain: a = Mu(i),
  unknown: c,
  pivot: l = 0,
  scheme: u,
  range: f,
  symmetric: h = !0,
  interpolate: d = ve.get(e) === fs ? u == null && f !== void 0 ? Xo : Gb(u !== void 0 ? u : "rdbu") : Xe,
  reverse: p
}) {
  l = +l, a = wn(a);
  let [y, g] = a;
  if (a.length > 2 && ir(`Warning: the diverging ${e} scale domain contains extra elements.`), Gu(y, g) < 0 && ([y, g] = [g, y], p = !p), y = Math.min(y, l), g = Math.max(g, l), typeof d != "function" && (d = e4(d)), f !== void 0 && (d = d.length === 1 ? Hb(d)(...f) : nb(d, f)), p && (d = t4(d)), h) {
    const m = n.apply(l), b = m - n.apply(y), _ = n.apply(g) - m;
    b < _ ? y = n.invert(m - _) : b > _ && (g = n.invert(m + b));
  }
  return t.domain([y, l, g]).unknown(c).interpolator(d), o && t.clamp(o), s && t.nice(s), { type: r, domain: [y, g], pivot: l, interpolate: d, scale: t };
}
function wj(e, t, n) {
  return Wy(e, RA(), Ij, t, n);
}
function vj(e, t, n) {
  return r4(e, t, { ...n, exponent: 0.5 });
}
function r4(e, t, { exponent: n = 1, ...i }) {
  return Wy(e, UA().exponent(n = +n), Mj(n), t, {
    ...i,
    type: "diverging-pow"
  });
}
function xj(e, t, { base: n = 10, pivot: i = 1, domain: r = Mu(t, i < 0 ? Dy : Gr), ...s }) {
  return Wy(e, CA().base(n = +n), $j, t, {
    domain: r,
    pivot: i,
    ...s
  });
}
function Sj(e, t, { constant: n = 1, ...i }) {
  return Wy(
    e,
    kA().constant(n = +n),
    Tj(n),
    t,
    i
  );
}
const Ij = {
  apply(e) {
    return e;
  },
  invert(e) {
    return e;
  }
}, $j = {
  apply: Math.log,
  invert: Math.exp
}, Aj = {
  apply(e) {
    return Math.sign(e) * Math.sqrt(Math.abs(e));
  },
  invert(e) {
    return Math.sign(e) * (e * e);
  }
};
function Mj(e) {
  return e === 0.5 ? Aj : {
    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 Tj(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 s4(e, t, n, i) {
  return af(e, t, n, i);
}
function Bj(e, t, n) {
  return s4(e, yP(), t, n);
}
function Nj(e, t, n) {
  return s4(e, mP(), t, n);
}
const cf = Symbol("ordinal");
function o4(e, t, n, { type: i, interval: r, domain: s, range: o, reverse: a, hint: c }) {
  return r = Hc(r, i), s === void 0 && (s = c4(n, r, e)), (i === "categorical" || i === cf) && (i = "ordinal"), a && (s = yd(s)), t.domain(s), o !== void 0 && (typeof o == "function" && (o = o(s)), t.range(o)), { type: i, domain: s, range: o, scale: t, hint: c, interval: r };
}
function Fj(e, t, { type: n, interval: i, domain: r, range: s, scheme: o, unknown: a, ...c }) {
  i = Hc(i, n), r === void 0 && (r = c4(t, i, e));
  let l;
  if (ve.get(e) === Uy)
    l = Ej(t), s = s === void 0 ? Lj(l) : he(s, Eb);
  else if (ve.get(e) === fs && (s === void 0 && (n === "ordinal" || n === cf) && (s = ij(r, o), s !== void 0 && (o = void 0)), o === void 0 && s === void 0 && (o = n === "ordinal" ? "turbo" : "tableau10"), o !== void 0))
    if (s !== void 0) {
      const u = Gb(o), f = s[0], h = s[1] - s[0];
      s = ({ length: d }) => wi((p) => u(f + h * p), d);
    } else
      s = Q6(o);
  if (a === Ag)
    throw new Error(`implicit unknown on ${e} scale is not supported`);
  return o4(e, pb().unknown(a), t, { ...c, type: n, domain: r, range: s, hint: l });
}
function Dj(e, t, { align: n = 0.5, padding: i = 0.5, ...r }) {
  return a4(KU().align(n).padding(i), t, r, e);
}
function Oj(e, t, {
  align: n = 0.5,
  padding: i = 0.1,
  paddingInner: r = i,
  paddingOuter: s = e === "fx" || e === "fy" ? 0 : i,
  ...o
}) {
  return a4(
    my().align(n).paddingInner(r).paddingOuter(s),
    t,
    o,
    e
  );
}
function a4(e, t, n, i) {
  let { round: r } = n;
  return r !== void 0 && e.round(r = !!r), e = o4(i, e, t, n), e.round = r, e;
}
function c4(e, t, n) {
  const i = new sy();
  for (const { value: r, domain: s } of e) {
    if (s !== void 0)
      return s();
    if (r !== void 0)
      for (const o of r)
        i.add(o);
  }
  if (t !== void 0) {
    const [r, s] = He(i).map(t.floor, t);
    return t.range(r, t.offset(s));
  }
  if (i.size > 1e4 && ve.get(n) === Qi)
    throw new Error(`implicit ordinal domain of ${n} scale has more than 10,000 values`);
  return cu(i, ii);
}
function J2(e, t) {
  let n;
  for (const { hint: i } of e) {
    const r = i == null ? void 0 : i[t];
    if (r !== void 0) {
      if (n === void 0)
        n = r;
      else if (n !== r)
        return;
    }
  }
  return n;
}
function Ej(e) {
  return {
    fill: J2(e, "fill"),
    stroke: J2(e, "stroke")
  };
}
function Lj(e) {
  return ke(e.fill) ? UP : kP;
}
function Lg(e, {
  label: t,
  inset: n = 0,
  insetTop: i = n,
  insetRight: r = n,
  insetBottom: s = n,
  insetLeft: o = n,
  round: a,
  nice: c,
  clamp: l,
  zero: u,
  align: f,
  padding: h,
  projection: d,
  facet: { label: p = t } = {},
  ...y
} = {}) {
  const g = {};
  for (const [m, b] of e) {
    const _ = y[m], w = h4(m, b, {
      round: ve.get(m) === Qi ? a : void 0,
      // only for position
      nice: c,
      clamp: l,
      zero: u,
      align: f,
      padding: h,
      projection: d,
      ..._
    });
    if (w) {
      let {
        label: v = m === "fx" || m === "fy" ? p : t,
        percent: x,
        transform: I,
        inset: T,
        insetTop: D = T !== void 0 ? T : m === "y" ? i : 0,
        // not fy
        insetRight: $ = T !== void 0 ? T : m === "x" ? r : 0,
        // not fx
        insetBottom: A = T !== void 0 ? T : m === "y" ? s : 0,
        // not fy
        insetLeft: F = T !== void 0 ? T : m === "x" ? o : 0
        // not fx
      } = _ || {};
      if (I == null)
        I = void 0;
      else if (typeof I != "function")
        throw new Error("invalid scale transform; not a function");
      w.percent = !!x, w.label = v === void 0 ? Cj(b, w) : v, w.transform = I, m === "x" || m === "fx" ? (w.insetLeft = +F, w.insetRight = +$) : (m === "y" || m === "fy") && (w.insetTop = +D, w.insetBottom = +A), g[m] = w;
    }
  }
  return g;
}
function Z2(e) {
  return Object.fromEntries(
    Object.entries(e).filter(([, { scale: t }]) => t).map(([t, { scale: n, type: i, interval: r, label: s }]) => (n.type = i, r != null && (n.interval = r), s != null && (n.label = s), [t, n]))
  );
}
function Rj(e, t) {
  const { x: n, y: i, fx: r, fy: s } = e, o = r || s ? Kb(t) : t;
  r && Q2(r, o), s && tx(s, o);
  const a = r || s ? l4(e, t) : t;
  n && Q2(n, a), i && tx(i, a);
}
function Cj(e = [], t) {
  let n;
  for (const { label: i } of e)
    if (i !== void 0) {
      if (n === void 0)
        n = i;
      else if (n !== i)
        return;
    }
  if (n !== void 0)
    return !ia(t) && t.percent && (n = `${n} (%)`), { inferred: !0, toString: () => n };
}
function Kb(e) {
  const {
    marginTop: t,
    marginRight: n,
    marginBottom: i,
    marginLeft: r,
    width: s,
    height: o,
    facet: {
      marginTop: a,
      marginRight: c,
      marginBottom: l,
      marginLeft: u
    }
  } = e;
  return {
    marginTop: Math.max(t, a),
    marginRight: Math.max(n, c),
    marginBottom: Math.max(i, l),
    marginLeft: Math.max(r, u),
    width: s,
    height: o
  };
}
function l4({ fx: e, fy: t }, n) {
  const { marginTop: i, marginRight: r, marginBottom: s, marginLeft: o, width: a, height: c } = Kb(n);
  return {
    marginTop: i,
    marginRight: r,
    marginBottom: s,
    marginLeft: o,
    width: e ? e.scale.bandwidth() + o + r : a,
    height: t ? t.scale.bandwidth() + i + s : c,
    facet: { width: a, height: c }
  };
}
function Q2(e, t) {
  if (e.range === void 0) {
    const { insetLeft: n, insetRight: i } = e, { width: r, marginLeft: s = 0, marginRight: o = 0 } = t, a = s + n, c = r - o - i;
    e.range = [a, Math.max(a, c)], ia(e) || (e.range = f4(e)), e.scale.range(e.range);
  }
  u4(e);
}
function tx(e, t) {
  if (e.range === void 0) {
    const { insetTop: n, insetBottom: i } = e, { height: r, marginTop: s = 0, marginBottom: o = 0 } = t, a = s + n, c = r - o - i;
    e.range = [Math.max(a, c), a], ia(e) ? e.range.reverse() : e.range = f4(e), e.scale.range(e.range);
  }
  u4(e);
}
function u4(e) {
  e.round === void 0 && zj(e) && kj(e) <= 30 && e.scale.round(!0);
}
function kj({ scale: e }) {
  const t = e.domain().length, [n, i] = e.range(), r = e.paddingInner ? e.paddingInner() : 1, s = e.paddingOuter ? e.paddingOuter() : e.padding(), o = t - r, a = Math.abs(i - n) / Math.max(1, o + s * 2);
  return (a - Math.floor(a)) * o;
}
function f4(e) {
  const t = e.scale.domain().length + p4(e);
  if (!(t > 2))
    return e.range;
  const [n, i] = e.range;
  return Array.from({ length: t }, (r, s) => n + s / (t - 1) * (i - n));
}
function Rg(e, t, n) {
  return h4(e, n === void 0 ? void 0 : [{ hint: n }], { ...t });
}
function h4(e, t = [], n = {}) {
  const i = Uj(e, t, n);
  if (n.type === void 0 && n.domain === void 0 && n.range === void 0 && n.interval == null && e !== "fx" && e !== "fy" && ia({ type: i })) {
    const r = t.map(({ value: s }) => s).filter((s) => s !== void 0);
    r.some(vn) ? ir(
      `Warning: some data associated with the ${e} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${pa(
        i
      )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${e} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${e} scale to "${pa(
        i
      )}".`
    ) : r.some(SV) ? ir(
      `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 "${pa(
        i
      )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${e} scale to "${pa(
        i
      )}".`
    ) : r.some(IV) && ir(
      `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 "${pa(
        i
      )}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${e} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${e} scale to "${pa(
        i
      )}".`
    );
  }
  switch (n.type = i, i) {
    case "diverging":
    case "diverging-sqrt":
    case "diverging-pow":
    case "diverging-log":
    case "diverging-symlog":
    case "cyclical":
    case "sequential":
    case "linear":
    case "sqrt":
    case "threshold":
    case "quantile":
    case "pow":
    case "log":
    case "symlog":
      n = Xf(t, n, pn);
      break;
    case "identity":
      switch (ve.get(e)) {
        case Qi:
          n = Xf(t, n, pn);
          break;
        case Uy:
          n = Xf(t, n, Pj);
          break;
      }
      break;
    case "utc":
    case "time":
      n = Xf(t, n, _V);
      break;
  }
  switch (i) {
    case "diverging":
      return wj(e, t, n);
    case "diverging-sqrt":
      return vj(e, t, n);
    case "diverging-pow":
      return r4(e, t, n);
    case "diverging-log":
      return xj(e, t, n);
    case "diverging-symlog":
      return Sj(e, t, n);
    case "categorical":
    case "ordinal":
    case cf:
      return Fj(e, t, n);
    case "cyclical":
    case "sequential":
    case "linear":
      return aj(e, t, n);
    case "sqrt":
      return cj(e, t, n);
    case "threshold":
      return Xb(e, t, n);
    case "quantile":
      return fj(e, t, n);
    case "quantize":
      return hj(e, t, n);
    case "pow":
      return n4(e, t, n);
    case "log":
      return lj(e, t, n);
    case "symlog":
      return uj(e, t, n);
    case "utc":
      return Nj(e, t, n);
    case "time":
      return Bj(e, t, n);
    case "point":
      return Dj(e, t, n);
    case "band":
      return Oj(e, t, n);
    case "identity":
      return ve.get(e) === Qi ? pj() : { type: "identity" };
    case void 0:
      return;
    default:
      throw new Error(`unknown scale type: ${i}`);
  }
}
function pa(e) {
  return typeof e == "symbol" ? e.description : e;
}
const ex = { toString: () => "projection" };
function Uj(e, t, { type: n, domain: i, range: r, scheme: s, pivot: o, projection: a }) {
  if (e === "fx" || e === "fy")
    return "band";
  (e === "x" || e === "y") && a != null && (n = ex);
  for (const { type: l } of t)
    if (l !== void 0) {
      if (n === void 0)
        n = l;
      else if (n !== l)
        throw new Error(`scale incompatible with channel: ${n} !== ${l}`);
    }
  if (n === ex)
    return;
  if (n !== void 0)
    return n;
  if (i === void 0 && !t.some(({ value: l }) => l !== void 0))
    return;
  const c = ve.get(e);
  if (c === Ry)
    return "sqrt";
  if (c === ky || c === Cy)
    return "linear";
  if (c === Uy)
    return "ordinal";
  if ((i || r || []).length > 2)
    return im(c);
  if (i !== void 0) {
    if (Qe(i))
      return im(c);
    if (vn(i))
      return "utc";
  } else {
    const l = t.map(({ value: u }) => u).filter((u) => u !== void 0);
    if (l.some(Qe))
      return im(c);
    if (l.some(vn))
      return "utc";
  }
  if (c === fs) {
    if (o != null || sj(s))
      return "diverging";
    if (nj(s))
      return "categorical";
  }
  return "linear";
}
function im(e) {
  switch (e) {
    case Qi:
      return "point";
    case fs:
      return cf;
    default:
      return "ordinal";
  }
}
function d4({ type: e }) {
  return e === "time" || e === "utc";
}
function ia({ type: e }) {
  return e === "ordinal" || e === "point" || e === "band" || e === cf;
}
function p4({ type: e }) {
  return e === "threshold";
}
function zj({ type: e }) {
  return e === "point" || e === "band";
}
function Zn(e) {
  if (e === void 0)
    return !0;
  const t = e.domain(), n = e(t[0]);
  for (let i = 1, r = t.length; i < r; ++i)
    if (e(t[i]) - n)
      return !1;
  return !0;
}
function Xf(e, { domain: t, ...n }, i) {
  for (const r of e)
    r.value !== void 0 && (r.value = i(r.value));
  return {
    domain: t === void 0 ? t : i(t),
    ...n
  };
}
function Pj(e) {
  return he(e, Eb);
}
function Qo(e = {}) {
  let t;
  for (const n in e)
    if (ve.has(n) && Po(e[n])) {
      if (t !== void 0)
        throw new Error("ambiguous scale definition; multiple scales found");
      t = y4(Rg(n, e[n]));
    }
  if (t === void 0)
    throw new Error("invalid scale definition; no scale found");
  return t;
}
function Vj(e) {
  return (t) => {
    if (!ve.has(t = `${t}`))
      throw new Error(`unknown scale: ${t}`);
    return t in e ? y4(e[t]) : void 0;
  };
}
function y4({ scale: e, type: t, domain: n, range: i, interpolate: r, interval: s, transform: o, percent: a, pivot: c }) {
  if (t === "identity")
    return { type: "identity", apply: (u) => u, invert: (u) => u };
  const l = e.unknown ? e.unknown() : void 0;
  return {
    type: t,
    domain: Dg(n),
    // defensive copy
    ...i !== void 0 && { range: Dg(i) },
    // defensive copy
    ...o !== void 0 && { transform: o },
    ...a && { percent: a },
    // only exposed if truthy
    ...l !== void 0 && { unknown: l },
    ...s !== void 0 && { interval: s },
    // quantitative
    ...r !== void 0 && { interpolate: r },
    ...e.clamp && { clamp: e.clamp() },
    // diverging (always asymmetric; we never want to apply the symmetric transform twice)
    ...c !== void 0 && { pivot: c, symmetric: !1 },
    // log, diverging-log
    ...e.base && { base: e.base() },
    // pow, diverging-pow
    ...e.exponent && { exponent: e.exponent() },
    // symlog, diverging-symlog
    ...e.constant && { constant: e.constant() },
    // band, point
    ...e.align && { align: e.align(), round: e.round() },
    ...e.padding && (e.paddingInner ? { paddingInner: e.paddingInner(), paddingOuter: e.paddingOuter() } : { padding: e.padding() }),
    ...e.bandwidth && { bandwidth: e.bandwidth(), step: e.step() },
    // utilities
    apply: (u) => e(u),
    ...e.invert && { invert: (u) => e.invert(u) }
  };
}
function Jb(e) {
  let t, n;
  return (...i) => (((n == null ? void 0 : n.length) !== i.length || n.some((r, s) => r !== i[s])) && (n = i, t = e(...i)), t);
}
const jj = Jb((e) => new Intl.NumberFormat(e)), Yj = Jb((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { month: t } })), qj = Jb((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { weekday: t } }));
function Wj(e = "en-US") {
  const t = jj(e);
  return (n) => n != null && !isNaN(n) ? t.format(n) : void 0;
}
function Gj(e = "en-US", t = "short") {
  const n = Yj(e, t);
  return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2e3, +i))) ? n.format(i) : void 0;
}
function Xj(e = "en-US", t = "short") {
  const n = qj(e, t);
  return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2001, 0, +i))) ? n.format(i) : void 0;
}
function Zb(e) {
  return v3(e, "Invalid Date");
}
function Hj(e = "en-US") {
  const t = Wj(e);
  return (n) => (n instanceof Date ? Zb : typeof n == "number" ? t : je)(n);
}
const Xr = Hj(), Ye = (typeof window < "u" ? window.devicePixelRatio > 1 : typeof it > "u") ? 0 : 0.5;
let Kj = 0;
function nx() {
  return `plot-clip-${++Kj}`;
}
function m4(e, {
  title: t,
  href: n,
  ariaLabel: i,
  ariaDescription: r,
  ariaHidden: s,
  target: o,
  fill: a,
  fillOpacity: c,
  stroke: l,
  strokeWidth: u,
  strokeOpacity: f,
  strokeLinejoin: h,
  strokeLinecap: d,
  strokeMiterlimit: p,
  strokeDasharray: y,
  strokeDashoffset: g,
  opacity: m,
  mixBlendMode: b,
  imageFilter: _,
  paintOrder: w,
  pointerEvents: v,
  shapeRendering: x,
  channels: I
}, {
  ariaLabel: T,
  fill: D = "currentColor",
  fillOpacity: $,
  stroke: A = "none",
  strokeOpacity: F,
  strokeWidth: E,
  strokeLinecap: S,
  strokeLinejoin: M,
  strokeMiterlimit: B,
  paintOrder: N
}) {
  D === null && (a = null, c = null), A === null && (l = null, f = null), ke(D) ? !ke(A) && (!ke(a) || I != null && I.fill) && (A = "none") : ke(A) && (!ke(l) || I != null && I.stroke) && (D = "none");
  const [L, k] = _n(a, D), [U, j] = Te(c, $), [P, K] = _n(l, A), [Z, et] = Te(f, F), [tt, H] = Te(m);
  Tc(K) || (u === void 0 && (u = E), d === void 0 && (d = S), h === void 0 && (h = M), p === void 0 && !AV(h) && (p = B), !Tc(k) && w === void 0 && (w = N));
  const [X, V] = Te(u);
  return D !== null && (e.fill = Ie(k, "currentColor"), e.fillOpacity = bl(j, 1)), A !== null && (e.stroke = Ie(K, "none"), e.strokeWidth = bl(V, 1), e.strokeOpacity = bl(et, 1), e.strokeLinejoin = Ie(h, "miter"), e.strokeLinecap = Ie(d, "butt"), e.strokeMiterlimit = bl(p, 4), e.strokeDasharray = Ie(y, "none"), e.strokeDashoffset = Ie(g, "0")), e.target = je(o), e.ariaLabel = je(T), e.ariaDescription = je(r), e.ariaHidden = je(s), e.opacity = bl(H, 1), e.mixBlendMode = Ie(b, "normal"), e.imageFilter = Ie(_, "none"), e.paintOrder = Ie(w, "normal"), e.pointerEvents = Ie(v, "auto"), e.shapeRendering = Ie(x, "auto"), {
    title: { value: t, optional: !0 },
    href: { value: n, optional: !0 },
    ariaLabel: { value: i, optional: !0 },
    fill: { value: L, scale: "auto", optional: !0 },
    fillOpacity: { value: U, scale: "auto", optional: !0 },
    stroke: { value: P, scale: "auto", optional: !0 },
    strokeOpacity: { value: Z, scale: "auto", optional: !0 },
    strokeWidth: { value: X, optional: !0 },
    opacity: { value: tt, scale: "auto", optional: !0 }
  };
}
function Jj(e, t) {
  t && e.filter((n) => $b(t[n])).append("title").call(Qj, t);
}
function Zj(e, t) {
  t && e.filter(([n]) => $b(t[n])).append("title").call(tY, t);
}
function Qj(e, t) {
  t && e.text((n) => Xr(t[n]));
}
function tY(e, t) {
  t && e.text(([n]) => Xr(t[n]));
}
function Le(e, { target: t, tip: n }, {
  ariaLabel: i,
  title: r,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: l,
  opacity: u,
  href: f
}) {
  i && ot(e, "aria-label", (h) => i[h]), s && ot(e, "fill", (h) => s[h]), o && ot(e, "fill-opacity", (h) => o[h]), a && ot(e, "stroke", (h) => a[h]), c && ot(e, "stroke-opacity", (h) => c[h]), l && ot(e, "stroke-width", (h) => l[h]), u && ot(e, "opacity", (h) => u[h]), f && b4(e, (h) => f[h], t), n || Jj(e, r);
}
function op(e, { target: t, tip: n }, {
  ariaLabel: i,
  title: r,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: l,
  opacity: u,
  href: f
}) {
  i && ot(e, "aria-label", ([h]) => i[h]), s && ot(e, "fill", ([h]) => s[h]), o && ot(e, "fill-opacity", ([h]) => o[h]), a && ot(e, "stroke", ([h]) => a[h]), c && ot(e, "stroke-opacity", ([h]) => c[h]), l && ot(e, "stroke-width", ([h]) => l[h]), u && ot(e, "opacity", ([h]) => u[h]), f && b4(e, ([h]) => f[h], t), n || Zj(e, r);
}
function eY({
  ariaLabel: e,
  title: t,
  fill: n,
  fillOpacity: i,
  stroke: r,
  strokeOpacity: s,
  strokeWidth: o,
  opacity: a,
  href: c
}, { tip: l }) {
  return [e, l ? void 0 : t, n, i, r, s, o, a, c].filter((u) => u !== void 0);
}
function Qb(e, t, n) {
  const i = as(e, (r) => t[r]);
  return n === void 0 && i.size > 1 + e.length >> 1 && ir(
    "Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null."
  ), i.values();
}
function* g4(e, t, n, i) {
  const { z: r } = n, { z: s } = i, o = eY(i, n), a = [...t, ...o];
  for (const c of s ? Qb(e, s, r) : [e]) {
    let l, u;
    t:
      for (const f of c) {
        for (const h of a)
          if (!cn(h[f])) {
            u && u.push(-1);
            continue t;
          }
        if (l === void 0) {
          u && (yield u), l = o.map((h) => Fo(h[f])), u = [f];
          continue;
        }
        u.push(f);
        for (let h = 0; h < o.length; ++h)
          if (Fo(o[h][f]) !== l[h]) {
            yield u, l = o.map((p) => Fo(p[f])), u = [f];
            continue t;
          }
      }
    u && (yield u);
  }
}
function nY(e) {
  return e === !0 ? e = "frame" : e === !1 && (e = null), Oy(e, "clip", ["frame", "sphere"]);
}
function iY(e, t, n, i) {
  let r;
  switch (t.clip) {
    case "frame": {
      const { width: s, height: o, marginLeft: a, marginRight: c, marginTop: l, marginBottom: u } = n, f = nx();
      r = `url(#${f})`, e = Wt("svg:g", i).call(
        (h) => h.append("svg:clipPath").attr("id", f).append("rect").attr("x", a).attr("y", l).attr("width", s - c - a).attr("height", o - l - u)
      ).each(function() {
        this.appendChild(e.node()), e.node = () => this;
      });
      break;
    }
    case "sphere": {
      const { projection: s } = i;
      if (!s)
        throw new Error('the "sphere" clip option requires a projection');
      const o = nx();
      r = `url(#${o})`, e.append("clipPath").attr("id", o).append("path").attr("d", to(s)({ type: "Sphere" }));
      break;
    }
  }
  ot(e, "aria-label", t.ariaLabel), ot(e, "aria-description", t.ariaDescription), ot(e, "aria-hidden", t.ariaHidden), ot(e, "clip-path", r);
}
function ye(e, t, n, i) {
  iY(e, t, n, i), ot(e, "fill", t.fill), ot(e, "fill-opacity", t.fillOpacity), ot(e, "stroke", t.stroke), ot(e, "stroke-width", t.strokeWidth), ot(e, "stroke-opacity", t.strokeOpacity), ot(e, "stroke-linejoin", t.strokeLinejoin), ot(e, "stroke-linecap", t.strokeLinecap), ot(e, "stroke-miterlimit", t.strokeMiterlimit), ot(e, "stroke-dasharray", t.strokeDasharray), ot(e, "stroke-dashoffset", t.strokeDashoffset), ot(e, "shape-rendering", t.shapeRendering), ot(e, "filter", t.imageFilter), ot(e, "paint-order", t.paintOrder), ot(e, "pointer-events", t.pointerEvents);
}
function pe(e, t) {
  rY(e, "mix-blend-mode", t.mixBlendMode), ot(e, "opacity", t.opacity);
}
function b4(e, t, n) {
  e.each(function(i) {
    const r = t(i);
    if (r != null) {
      const s = this.ownerDocument.createElementNS(Wo.svg, "a");
      s.setAttribute("fill", "inherit"), s.setAttributeNS(Wo.xlink, "href", r), n != null && s.setAttribute("target", n), this.parentNode.insertBefore(s, this).appendChild(this);
    }
  });
}
function ot(e, t, n) {
  n != null && e.attr(t, n);
}
function rY(e, t, n) {
  n != null && e.style(t, n);
}
function ae(e, t, { x: n, y: i }, r = Ye, s = Ye) {
  r += t.dx, s += t.dy, n != null && n.bandwidth && (r += n.bandwidth() / 2), i != null && i.bandwidth && (s += i.bandwidth() / 2), (r || s) && e.attr("transform", `translate(${r},${s})`);
}
function Ie(e, t) {
  if ((e = je(e)) !== t)
    return e;
}
function bl(e, t) {
  if ((e = kt(e)) !== t)
    return e;
}
const sY = /^-?([_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 t_(e) {
  if (e === void 0)
    return "plot-d6a7b5";
  if (e = `${e}`, !sY.test(e))
    throw new Error(`invalid class name: ${e}`);
  return e;
}
function e_(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: i, marginRight: r, marginBottom: s, marginLeft: o }) {
  return [
    /left$/.test(e) ? o : /right$/.test(e) ? t - r : (o + t - r) / 2,
    /^top/.test(e) ? i : /^bottom/.test(e) ? n - s : (i + n - s) / 2
  ];
}
function oY(e, t, n = {}) {
  let i = 0.5 - Ye, r = 0.5 + Ye, s = 0.5 + Ye, o = 0.5 - Ye;
  for (const { marginTop: y, marginRight: g, marginBottom: m, marginLeft: b } of t)
    y > i && (i = y), g > r && (r = g), m > s && (s = m), b > o && (o = b);
  let {
    margin: a,
    marginTop: c = a !== void 0 ? a : i,
    marginRight: l = a !== void 0 ? a : r,
    marginBottom: u = a !== void 0 ? a : s,
    marginLeft: f = a !== void 0 ? a : o
  } = n;
  c = +c, l = +l, u = +u, f = +f;
  let {
    width: h = 640,
    height: d = aY(e, n, {
      width: h,
      marginTopDefault: i,
      marginRightDefault: r,
      marginBottomDefault: s,
      marginLeftDefault: o
    }) + Math.max(0, c - i + u - s)
  } = n;
  h = +h, d = +d;
  const p = {
    width: h,
    height: d,
    marginTop: c,
    marginRight: l,
    marginBottom: u,
    marginLeft: f
  };
  if (e.fx || e.fy) {
    let {
      margin: y,
      marginTop: g = y !== void 0 ? y : c,
      marginRight: m = y !== void 0 ? y : l,
      marginBottom: b = y !== void 0 ? y : u,
      marginLeft: _ = y !== void 0 ? y : f
    } = n.facet ?? {};
    g = +g, m = +m, b = +b, _ = +_, p.facet = {
      marginTop: g,
      marginRight: m,
      marginBottom: b,
      marginLeft: _
    };
  }
  return p;
}
function aY({ x: e, y: t, fy: n, fx: i }, { projection: r, aspectRatio: s }, { width: o, marginTopDefault: a, marginRightDefault: c, marginBottomDefault: l, marginLeftDefault: u }) {
  const f = n ? n.scale.domain().length : 1, h = tj(r);
  if (h) {
    const p = i ? i.scale.domain().length : 1, y = (1.1 * f - 0.1) / (1.1 * p - 0.1) * h, g = Math.max(0.1, Math.min(10, y));
    return Math.round((o - u - c) * g + a + l);
  }
  const d = t ? ia(t) ? t.scale.domain().length : Math.max(7, 17 / f) : 1;
  if (s != null) {
    if (s = +s, !(isFinite(s) && s > 0))
      throw new Error(`invalid aspectRatio: ${s}`);
    const p = ix("y", t) / (ix("x", e) * s), y = i ? i.scale.bandwidth() : 1, g = n ? n.scale.bandwidth() : 1, m = y * (o - u - c) - e.insetLeft - e.insetRight;
    return (p * m + t.insetTop + t.insetBottom) / g + a + l;
  }
  return !!(t || n) * Math.max(1, Math.min(60, d * f)) * 20 + !!i * 30 + 60;
}
function ix(e, t) {
  if (!t)
    throw new Error(`aspectRatio requires ${e} scale`);
  const { type: n, domain: i } = t;
  let r;
  switch (n) {
    case "linear":
    case "utc":
    case "time":
      r = Number;
      break;
    case "pow": {
      const a = t.scale.exponent();
      r = (c) => Math.pow(c, a);
      break;
    }
    case "log":
      r = Math.log;
      break;
    case "point":
    case "band":
      return i.length;
    default:
      throw new Error(`unsupported ${e} scale for aspectRatio: ${n}`);
  }
  const [s, o] = He(i);
  return Math.abs(r(o) - r(s));
}
function cY(e, t) {
  const { fx: n, fy: i } = Lg(e, t), r = n == null ? void 0 : n.scale.domain(), s = i == null ? void 0 : i.scale.domain();
  return r && s ? aL(r, s).map(([o, a], c) => ({ x: o, y: a, i: c })) : r ? r.map((o, a) => ({ x: o, i: a })) : s ? s.map((o, a) => ({ y: o, i: a })) : void 0;
}
function lY(e, { x: t, y: n }) {
  return t && (t = Cg(t)), n && (n = Cg(n)), e.filter(
    t && n ? (i) => t.has(i.x) && n.has(i.y) : t ? (i) => t.has(i.x) : (i) => n.has(i.y)
  ).sort(
    t && n ? (i, r) => t.get(i.x) - t.get(r.x) || n.get(i.y) - n.get(r.y) : t ? (i, r) => t.get(i.x) - t.get(r.x) : (i, r) => n.get(i.y) - n.get(r.y)
  );
}
function n_(e, { fx: t, fy: n }) {
  const i = ls(e), r = t == null ? void 0 : t.value, s = n == null ? void 0 : n.value;
  return t && n ? Wa(
    i,
    (o) => (o.fx = r[o[0]], o.fy = s[o[0]], o),
    (o) => r[o],
    (o) => s[o]
  ) : t ? Wa(
    i,
    (o) => (o.fx = r[o[0]], o),
    (o) => r[o]
  ) : Wa(
    i,
    (o) => (o.fy = s[o[0]], o),
    (o) => s[o]
  );
}
function uY(e, t, { marginTop: n, marginLeft: i }) {
  return e && t ? ({ x: r, y: s }) => `translate(${e(r) - i},${t(s) - n})` : e ? ({ x: r }) => `translate(${e(r) - i},0)` : ({ y: r }) => `translate(0,${t(r) - n})`;
}
function fY(e) {
  const t = [], n = new Uint32Array(or(e, (i) => i.length));
  for (const i of e) {
    let r = 0;
    for (const s of e)
      i !== s && (n.set(s, r), r += s.length);
    t.push(n.slice(0, r));
  }
  return t;
}
const hY = /* @__PURE__ */ new Map([
  ["top", rm],
  ["right", am],
  ["bottom", sm],
  ["left", om],
  ["top-left", Hf(rm, om)],
  ["top-right", Hf(rm, am)],
  ["bottom-left", Hf(sm, om)],
  ["bottom-right", Hf(sm, am)],
  ["top-empty", yY],
  ["right-empty", bY],
  ["bottom-empty", mY],
  ["left-empty", gY],
  ["empty", _Y]
]);
function dY(e) {
  if (e == null)
    return null;
  const t = hY.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid facet anchor: ${e}`);
}
const rx = /* @__PURE__ */ new WeakMap();
function Cg(e) {
  let t = rx.get(e);
  return t || rx.set(e, t = new qo(he(e, (n, i) => [n, i]))), t;
}
function io(e, t) {
  return Cg(e).get(t);
}
function pY(e, t, n) {
  return t = Fo(t), n = Fo(n), e.find((i) => Object.is(Fo(i.x), t) && Object.is(Fo(i.y), n));
}
function Gy(e, t, n) {
  var i;
  return (i = pY(e, t, n)) == null ? void 0 : i.empty;
}
function rm(e, { y: t }, { y: n }) {
  return t ? io(t, n) === 0 : !0;
}
function sm(e, { y: t }, { y: n }) {
  return t ? io(t, n) === t.length - 1 : !0;
}
function om(e, { x: t }, { x: n }) {
  return t ? io(t, n) === 0 : !0;
}
function am(e, { x: t }, { x: n }) {
  return t ? io(t, n) === t.length - 1 : !0;
}
function yY(e, { y: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = io(t, i);
  if (s > 0)
    return Gy(e, n, t[s - 1]);
}
function mY(e, { y: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = io(t, i);
  if (s < t.length - 1)
    return Gy(e, n, t[s + 1]);
}
function gY(e, { x: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = io(t, n);
  if (s > 0)
    return Gy(e, t[s - 1], i);
}
function bY(e, { x: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = io(t, n);
  if (s < t.length - 1)
    return Gy(e, t[s + 1], i);
}
function _Y(e, t, { empty: n }) {
  return n;
}
function Hf(e, t) {
  return function() {
    return e.apply(null, arguments) && t.apply(null, arguments);
  };
}
function cm(e, { channels: { fx: t, fy: n }, groups: i }) {
  return t && n ? e.map(({ x: r, y: s }) => {
    var o;
    return ((o = i.get(r)) == null ? void 0 : o.get(s)) ?? [];
  }) : t ? e.map(({ x: r }) => i.get(r) ?? []) : e.map(({ y: r }) => i.get(r) ?? []);
}
let ce = class {
  constructor(t, n = {}, i = {}, r) {
    const {
      facet: s = "auto",
      facetAnchor: o,
      fx: a,
      fy: c,
      sort: l,
      dx: u = 0,
      dy: f = 0,
      margin: h = 0,
      marginTop: d = h,
      marginRight: p = h,
      marginBottom: y = h,
      marginLeft: g = h,
      clip: m,
      channels: b,
      tip: _,
      render: w
    } = i;
    if (this.data = t, this.sort = Vs(l) ? l : null, this.initializer = Rn(i).initializer, this.transform = this.initializer ? i.transform : pr(i).transform, s === null || s === !1 ? this.facet = null : (this.facet = cs(s === !0 ? "include" : s, "facet", ["auto", "include", "exclude", "super"]), this.fx = t === Hl && typeof a == "string" ? [a] : a, this.fy = t === Hl && typeof c == "string" ? [c] : c), this.facetAnchor = dY(o), n = Fb(n), b !== void 0 && (n = { ...wY(b), ...n }), r !== void 0 && (n = { ...m4(this, i, r), ...n }), this.channels = Object.fromEntries(
      Object.entries(n).map(([v, x]) => {
        if (Pi(x.value)) {
          const { value: I, scale: T = x.scale } = x.value;
          x = { ...x, scale: T, value: I };
        }
        if (t === Hl && typeof x.value == "string") {
          const { value: I } = x;
          x = { ...x, value: [I] };
        }
        return [v, x];
      }).filter(([v, { value: x, optional: I }]) => {
        if (x != null)
          return !0;
        if (I)
          return !1;
        throw new Error(`missing channel value: ${v}`);
      })
    ), this.dx = +u, this.dy = +f, this.marginTop = +d, this.marginRight = +p, this.marginBottom = +y, this.marginLeft = +g, this.clip = nY(m), this.tip = vY(_), this.facet === "super") {
      if (a || c)
        throw new Error("super-faceting cannot use fx or fy");
      for (const v in this.channels) {
        const { scale: x } = n[v];
        if (!(x !== "x" && x !== "y"))
          throw new Error("super-faceting cannot use x or y");
      }
    }
    w != null && (this.render = _4(w, this.render));
  }
  initialize(t, n, i) {
    let r = wn(this.data);
    t === void 0 && r != null && (t = [ls(r)]);
    const s = t;
    this.transform != null && ({ facets: t, data: r } = this.transform(r, t, i), r = wn(r)), t !== void 0 && (t.original = s);
    const o = j6(this.channels, r);
    return this.sort != null && qV(r, t, o, n, this.sort), { data: r, facets: t, channels: o };
  }
  filter(t, n, i) {
    for (const r in n) {
      const { filter: s = cn } = n[r];
      if (s !== null) {
        const o = i[r];
        t = t.filter((a) => s(o[a]));
      }
    }
    return t;
  }
  // If there is a projection, and there are 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, i) {
    for (const r in t)
      if (t[r].scale === "x" && /^x|x$/.test(r)) {
        const s = r.replace(/^x|x$/, "y");
        s in t && t[s].scale === "y" && J6(r, s, n, i.projection);
      }
  }
  scale(t, n, i) {
    const r = Wb(t, n);
    return i.projection && this.project(t, r, i), r;
  }
};
function ns(...e) {
  return e.plot = ce.prototype.plot, e;
}
function _4(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, i, r, s, o, a) {
    return e.call(this, n, i, r, s, o, (c, l, u, f, h) => t.call(this, c, l, u, f, h, a));
  };
}
function wY(e) {
  return Object.fromEntries(
    Object.entries(Fb(e)).map(([t, n]) => (n = rf(n), n.filter === void 0 && n.scale == null && (n = { ...n, filter: null }), [t, n]))
  );
}
function vY(e) {
  return e === !0 ? "xy" : e === !1 ? null : Oy(e, "tip", ["x", "y", "xy"]);
}
function Kc(e, t) {
  return (e == null ? void 0 : e.tip) === !0 ? { ...e, tip: t } : e;
}
const sx = /* @__PURE__ */ new WeakMap();
function i_(e, t, { x: n, y: i, px: r, py: s, maxRadius: o = 40, channels: a, render: c, ...l } = {}) {
  return o = +o, r != null && (n ?? (n = null), a = { ...a, px: { value: r, scale: "x" } }), s != null && (i ?? (i = null), a = { ...a, py: { value: s, scale: "y" } }), {
    x: n,
    y: i,
    channels: a,
    ...l,
    // 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: _4(function(u, f, h, d, p, y) {
      const g = p.ownerSVGElement, { data: m } = p.getMarkState(this);
      let b = sx.get(g);
      b || sx.set(g, b = { sticky: !1, roots: [], renders: [] });
      let _ = b.renders.push(P) - 1;
      const { x: w, y: v, fx: x, fy: I } = f;
      let T = x ? x(u.fx) - d.marginLeft : 0, D = I ? I(u.fy) - d.marginTop : 0;
      w != null && w.bandwidth && (T += w.bandwidth() / 2), v != null && v.bandwidth && (D += v.bandwidth() / 2);
      const $ = u.fi != null;
      let A;
      if ($) {
        let tt = b.facetStates;
        tt || (b.facetStates = tt = /* @__PURE__ */ new Map()), A = tt.get(this), A || tt.set(this, A = /* @__PURE__ */ new Map());
      }
      const [F, E] = yr(this, d), { px: S, py: M } = h, B = S ? (tt) => S[tt] : w4(h, F), N = M ? (tt) => M[tt] : v4(h, E);
      let L, k, U;
      function j(tt, H) {
        if ($)
          if (U && (U = cancelAnimationFrame(U)), tt == null)
            A.delete(u.fi);
          else {
            A.set(u.fi, H), U = requestAnimationFrame(() => {
              U = null;
              for (const X of A.values())
                if (X < H) {
                  tt = null;
                  break;
                }
              P(tt);
            });
            return;
          }
        P(tt);
      }
      function P(tt) {
        if (L === tt)
          return;
        L = tt;
        const H = L == null ? [] : [L];
        $ && (H.fx = u.fx, H.fy = u.fy, H.fi = u.fi);
        const X = y(H, f, h, d, p);
        if (k) {
          if ($) {
            const V = k.parentNode, G = k.getAttribute("transform"), J = X.getAttribute("transform");
            G ? X.setAttribute("transform", G) : X.removeAttribute("transform"), J ? V.setAttribute("transform", J) : V.removeAttribute("transform"), X.removeAttribute("aria-label"), X.removeAttribute("aria-description"), X.removeAttribute("aria-hidden");
          }
          k.replaceWith(X);
        }
        return b.roots[_] = k = X, p.dispatchValue(L == null ? null : m[L]), X;
      }
      function K(tt) {
        if (b.sticky || tt.pointerType === "mouse" && tt.buttons === 1)
          return;
        let [H, X] = ai(tt);
        H -= T, X -= D;
        let V = null, G = o * o;
        for (const J of u) {
          const z = e * (B(J) - H), nt = t * (N(J) - X), ut = z * z + nt * nt;
          ut <= G && (V = J, G = ut);
        }
        j(V, G);
      }
      function Z(tt) {
        tt.pointerType === "mouse" && L != null && (b.sticky && b.roots.some((H) => H == null ? void 0 : H.contains(tt.target)) || (b.sticky ? (b.sticky = !1, b.renders.forEach((H) => H(null))) : b.sticky = !0, tt.stopImmediatePropagation()));
      }
      function et(tt) {
        tt.pointerType === "mouse" && (b.sticky || j(null));
      }
      return g.addEventListener("pointerenter", K), g.addEventListener("pointermove", K), g.addEventListener("pointerdown", Z), g.addEventListener("pointerleave", et), P(null);
    }, c)
  };
}
function r_(e) {
  return i_(1, 1, e);
}
function s_(e) {
  return i_(1, 0.01, e);
}
function o_(e) {
  return i_(0.01, 1, e);
}
function w4({ x1: e, x2: t, x: n = e }, i) {
  return e && t ? (r) => (e[r] + t[r]) / 2 : n ? (r) => n[r] : () => i;
}
function v4({ y1: e, y2: t, y: n = e }, i) {
  return e && t ? (r) => (e[r] + t[r]) / 2 : n ? (r) => n[r] : () => i;
}
function x4(e) {
  return ia(e) && e.interval === void 0 ? void 0 : "tabular-nums";
}
function xY(e, t) {
  return e === void 0 ? vn(t) ? Zb : je : typeof e == "function" ? e : (typeof e == "string" ? vn(t) ? wu : Wc : Ln)(e);
}
function SY(e, t) {
  let {
    label: n = e.label,
    tickSize: i = 6,
    width: r = 240,
    height: s = 44 + i,
    marginTop: o = 18,
    marginRight: a = 0,
    marginBottom: c = 16 + i,
    marginLeft: l = 0,
    style: u,
    ticks: f = (r - l - a) / 64,
    tickFormat: h,
    fontVariant: d = x4(e),
    round: p = !0,
    opacity: y,
    className: g
  } = t;
  const m = jy(t);
  g = t_(g), y = Te(y)[1], h === null && (h = () => null);
  const b = Wt("svg", m).attr("class", `${g}-ramp`).attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("width", r).attr("height", s).attr("viewBox", `0 0 ${r} ${s}`).call(
    (F) => (
      // Warning: if you edit this, change defaultClassName.
      F.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(e_, u);
  let _ = (F) => F.selectAll(".tick line").attr("y1", o + c - s), w;
  const v = p ? (F, E) => F.rangeRound(E) : (F, E) => F.range(E), { type: x, domain: I, range: T, interpolate: D, scale: $, pivot: A } = e;
  if (D) {
    const F = T === void 0 ? D : nb(D.length === 1 ? Hb(D) : D, T);
    w = v(
      $.copy(),
      wi(
        Xe(l, r - a),
        Math.min(I.length + (A !== void 0), T === void 0 ? 1 / 0 : T.length)
      )
    );
    const E = 256, S = m.document.createElement("canvas");
    S.width = E, S.height = 1;
    const M = S.getContext("2d");
    for (let B = 0, N = E - 1; B < E; ++B)
      M.fillStyle = F(B / N), M.fillRect(B, 0, 1, 1);
    b.append("image").attr("opacity", y).attr("x", l).attr("y", o).attr("width", r - l - a).attr("height", s - o - c).attr("preserveAspectRatio", "none").attr("xlink:href", S.toDataURL());
  } else if (x === "threshold") {
    const F = I, E = h === void 0 ? (S) => S : typeof h == "string" ? Wc(h) : h;
    w = v(by().domain([-1, T.length - 1]), [l, r - a]), b.append("g").attr("fill-opacity", y).selectAll().data(T).enter().append("rect").attr("x", (S, M) => w(M - 1)).attr("y", o).attr("width", (S, M) => w(M) - w(M - 1)).attr("height", s - o - c).attr("fill", (S) => S), f = he(F, (S, M) => M), h = (S) => E(F[S], S);
  } else
    w = v(my().domain(I), [l, r - a]), b.append("g").attr("fill-opacity", y).selectAll().data(I).enter().append("rect").attr("x", w).attr("y", o).attr("width", Math.max(0, w.bandwidth() - 1)).attr("height", s - o - c).attr("fill", $), _ = () => {
    };
  return b.append("g").attr("transform", `translate(0,${s - c})`).call(
    ML(w).ticks(Array.isArray(f) ? null : f, typeof h == "string" ? h : void 0).tickFormat(typeof h == "function" ? h : void 0).tickSize(i).tickValues(Array.isArray(f) ? f : null)
  ).attr("font-size", null).attr("font-family", null).attr("font-variant", Ie(d, "normal")).call(_).call((F) => F.select(".domain").remove()), n !== void 0 && b.append("text").attr("x", l).attr("y", o - 6).attr("fill", "currentColor").attr("font-weight", "bold").text(n), b.node();
}
function ox(e, t) {
  if (t == null)
    return t;
  const n = e(t);
  if (!n)
    throw new Error(`scale not found: ${t}`);
  return n;
}
function IY(e, { opacity: t, ...n } = {}) {
  if (!ia(e) && !p4(e))
    throw new Error(`swatches legend requires ordinal or threshold color scale (not ${e.type})`);
  return S4(
    e,
    n,
    (i, r, s, o) => i.append("svg").attr("width", s).attr("height", o).attr("fill", r.scale).attr("fill-opacity", Te(t)[1]).append("rect").attr("width", "100%").attr("height", "100%")
  );
}
function $Y(e, {
  fill: t = ((l) => (l = e.hint) == null ? void 0 : l.fill)() !== void 0 ? e.hint.fill : "none",
  fillOpacity: n = 1,
  stroke: i = ((u) => (u = e.hint) == null ? void 0 : u.stroke)() !== void 0 ? e.hint.stroke : ke(t) ? "currentColor" : "none",
  strokeOpacity: r = 1,
  strokeWidth: s = 1.5,
  r: o = 4.5,
  ...a
} = {}, c) {
  const [f, h] = _n(t), [d, p] = _n(i), y = ox(c, f), g = ox(c, d), m = o * o * Math.PI;
  return n = Te(n)[1], r = Te(r)[1], s = Te(s)[1], S4(
    e,
    a,
    (b, _, w, v) => b.append("svg").attr("viewBox", "-8 -8 16 16").attr("width", w).attr("height", v).attr("fill", f === "color" ? (x) => y.scale(x) : h).attr("fill-opacity", n).attr("stroke", d === "color" ? (x) => g.scale(x) : p).attr("stroke-opacity", r).attr("stroke-width", s).append("path").attr("d", (x) => {
      const I = zr();
      return e.scale(x).draw(I, m), I;
    })
  );
}
function S4(e, t = {}, n) {
  let {
    columns: i,
    tickFormat: r,
    fontVariant: s = x4(e),
    // TODO label,
    swatchSize: o = 15,
    swatchWidth: a = o,
    swatchHeight: c = o,
    marginLeft: l = 0,
    className: u,
    style: f,
    width: h
  } = t;
  const d = jy(t);
  u = t_(u), r = xY(r, e.domain);
  const p = Wt("div", d).attr(
    "class",
    `${u}-swatches ${u}-swatches-${i != null ? "columns" : "wrap"}`
  );
  let y;
  return i != null ? (y = `.${u}-swatches-columns .${u}-swatch {
  display: flex;
  align-items: center;
  break-inside: avoid;
  padding-bottom: 1px;
}
.${u}-swatches-columns .${u}-swatch::before {
  flex-shrink: 0;
}
.${u}-swatches-columns .${u}-swatch-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}`, p.style("columns", i).selectAll().data(e.domain).enter().append("div").attr("class", `${u}-swatch`).call(n, e, a, c).call(
    (g) => g.append("div").attr("class", `${u}-swatch-label`).attr("title", r).text(r)
  )) : (y = `.${u}-swatches-wrap {
  display: flex;
  align-items: center;
  min-height: 33px;
  flex-wrap: wrap;
}
.${u}-swatches-wrap .${u}-swatch {
  display: inline-flex;
  align-items: center;
  margin-right: 1em;
}`, p.selectAll().data(e.domain).enter().append("span").attr("class", `${u}-swatch`).call(n, e, a, c).append(function() {
    return this.ownerDocument.createTextNode(r.apply(this, arguments));
  })), p.call(
    (g) => g.insert("style", "*").text(
      `.${u}-swatches {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  margin-bottom: 0.5em;
}
.${u}-swatch > svg {
  margin-right: 0.5em;
  overflow: visible;
}
${y}`
    )
  ).style("margin-left", l ? `${+l}px` : null).style("width", h === void 0 ? null : `${+h}px`).style("font-variant", Ie(s, "normal")).call(e_, f).node();
}
const ap = /* @__PURE__ */ new Map([
  ["symbol", $Y],
  ["color", I4],
  ["opacity", TY]
]);
function AY(e = {}) {
  for (const [t, n] of ap) {
    const i = e[t];
    if (Po(i)) {
      const r = jy(e);
      let s;
      if (t === "symbol") {
        const { fill: o, stroke: a = o === void 0 && Po(e.color) ? "color" : void 0 } = e;
        s = { fill: o, stroke: a };
      }
      return n(
        Rg(t, i, s),
        a_(r, i, e),
        (o) => Po(e[o]) ? Rg(o, e[o]) : null
      );
    }
  }
  throw new Error("unknown legend type; no scale found");
}
function MY(e, t, n = {}) {
  return (i, r) => {
    if (!ap.has(i))
      throw new Error(`unknown legend type: ${i}`);
    if (i in e)
      return ap.get(i)(e[i], a_(t, n[i], r), (s) => e[s]);
  };
}
function a_({ className: e, ...t }, { label: n, ticks: i, tickFormat: r } = {}, s) {
  return MV(s, { className: e, ...t }, { label: n, ticks: i, tickFormat: r });
}
function I4(e, { legend: t = !0, ...n }) {
  if (t === !0 && (t = e.type === "ordinal" ? "swatches" : "ramp"), e.domain !== void 0)
    switch (`${t}`.toLowerCase()) {
      case "swatches":
        return IY(e, n);
      case "ramp":
        return SY(e, n);
      default:
        throw new Error(`unknown legend type: ${t}`);
    }
}
function TY({ type: e, interpolate: t, ...n }, { legend: i = !0, color: r = ni(0, 0, 0), ...s }) {
  if (!t)
    throw new Error(`${e} opacity scales are not supported`);
  if (i === !0 && (i = "ramp"), `${i}`.toLowerCase() !== "ramp")
    throw new Error(`${i} opacity legends are not supported`);
  return I4({ type: e, ...n, interpolate: BY(r) }, { legend: i, ...s });
}
function BY(e) {
  const { r: t, g: n, b: i } = ni(e) || ni(0, 0, 0);
  return (r) => `rgba(${t},${n},${i},${r})`;
}
function NY(e, t, n) {
  const i = [];
  for (const [r, s] of ap) {
    const o = n[r];
    if (o != null && o.legend && r in e) {
      const a = s(e[r], a_(t, e[r], o), (c) => e[c]);
      a != null && i.push(a);
    }
  }
  return i;
}
const cp = Math.PI / 180;
function Jc(e, { marker: t, markerStart: n = t, markerMid: i = t, markerEnd: r = t } = {}) {
  e.markerStart = lm(n), e.markerMid = lm(i), e.markerEnd = lm(r);
}
function lm(e) {
  if (e == null || e === !1)
    return null;
  if (e === !0)
    return cx;
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return null;
    case "arrow":
      return ax("auto");
    case "arrow-reverse":
      return ax("auto-start-reverse");
    case "dot":
      return FY;
    case "circle":
    case "circle-fill":
      return cx;
    case "circle-stroke":
      return DY;
  }
  throw new Error(`invalid marker: ${e}`);
}
function ax(e) {
  return (t, n) => Wt("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((i) => i.append("path").attr("d", "M-1.5,-3l3,3l-3,3")).node();
}
function FY(e, t) {
  return Wt("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 cx(e, t) {
  return Wt("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 DY(e, t) {
  return Wt("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 OY = 0;
function lf(e, t, { stroke: n }, i) {
  return $4(e, t, n && ((r) => n[r]), i);
}
function EY(e, t, { stroke: n }, i) {
  return $4(e, t, n && (([r]) => n[r]), i);
}
function $4(e, { markerStart: t, markerMid: n, markerEnd: i, stroke: r }, s = () => r, o) {
  const a = /* @__PURE__ */ new Map();
  function c(l) {
    return function(u) {
      const f = s(u);
      let h = a.get(l);
      h || a.set(l, h = /* @__PURE__ */ new Map());
      let d = h.get(f);
      if (!d) {
        const p = this.parentNode.insertBefore(l(f, o), this), y = `plot-marker-${++OY}`;
        p.setAttribute("id", y), h.set(f, d = `url(#${y})`);
      }
      return d;
    };
  }
  t && e.attr("marker-start", c(t)), n && e.attr("marker-mid", c(n)), i && e.attr("marker-end", c(i));
}
function uf({ inset: e, insetLeft: t, insetRight: n, ...i } = {}) {
  return [t, n] = A4(e, t, n), { inset: e, insetLeft: t, insetRight: n, ...i };
}
function ff({ inset: e, insetTop: t, insetBottom: n, ...i } = {}) {
  return [t, n] = A4(e, t, n), { inset: e, insetTop: t, insetBottom: n, ...i };
}
function A4(e, t, n) {
  return e === void 0 && t === void 0 && n === void 0 ? Ye ? [1, 0] : [0.5, 0.5] : [t, n];
}
function M4(e, { interval: t }) {
  return e = { ...rf(e) }, e.interval = Nb(e.interval === void 0 ? t : e.interval), e;
}
function Xy(e, t, n, i) {
  const { [e]: r, [`${e}1`]: s, [`${e}2`]: o } = n, { value: a, interval: c } = M4(r, n);
  if (a == null || c == null && !i)
    return n;
  const l = us(r);
  if (c == null) {
    let d;
    const p = { transform: (y) => d || (d = Lt(y, a)), label: l };
    return {
      ...n,
      [e]: void 0,
      [`${e}1`]: s === void 0 ? p : s,
      [`${e}2`]: o === void 0 ? p : o
    };
  }
  let u, f;
  function h(d) {
    return f !== void 0 && d === u ? f : f = he(Lt(u = d, a), (p) => c.floor(p));
  }
  return t({
    ...n,
    [e]: void 0,
    [`${e}1`]: s === void 0 ? { transform: h, label: l } : s,
    [`${e}2`]: o === void 0 ? { transform: (d) => h(d).map((p) => c.offset(p)), label: l } : o
  });
}
function T4(e, t, n) {
  const { [e]: i } = n, { value: r, interval: s } = M4(i, n);
  return r == null || s == null ? n : t({
    ...n,
    [e]: {
      label: us(i),
      transform: (o) => {
        const a = he(Lt(o, r), (l) => s.floor(l)), c = a.map((l) => s.offset(l));
        return a.map(
          vn(a) ? (l, u) => l == null || isNaN(l = +l) || (u = c[u], u == null) || isNaN(u = +u) ? void 0 : new Date((l + u) / 2) : (l, u) => l == null || (u = c[u], u == null) ? NaN : (+l + +u) / 2
        );
      }
    }
  });
}
function B4(e = {}) {
  return Xy("x", uf, e, !0);
}
function N4(e = {}) {
  return Xy("y", ff, e, !0);
}
function F4(e = {}) {
  return Xy("x", uf, e);
}
function D4(e = {}) {
  return Xy("y", ff, e);
}
function O4(e = {}) {
  return T4("x", uf, e);
}
function E4(e = {}) {
  return T4("y", ff, e);
}
const L4 = {
  ariaLabel: "rule",
  fill: null,
  stroke: "currentColor"
};
class R4 extends ce {
  constructor(t, n = {}) {
    const { x: i, y1: r, y2: s, inset: o = 0, insetTop: a = o, insetBottom: c = o } = n;
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y1: { value: r, scale: "y", optional: !0 },
        y2: { value: s, scale: "y", optional: !0 }
      },
      Kc(n, "x"),
      L4
    ), this.insetTop = kt(a), this.insetBottom = kt(c), Jc(this, n);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y1: l, y2: u } = i, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: y, marginBottom: g } = r, { insetTop: m, insetBottom: b } = this;
    return Wt("svg:g", s).call(ye, this, r).call(ae, this, { x: c && o }, Ye, 0).call(
      (_) => _.selectAll().data(t).enter().append("line").call(pe, this).attr("x1", c ? (w) => c[w] : (y + f - p) / 2).attr("x2", c ? (w) => c[w] : (y + f - p) / 2).attr("y1", l && !Zn(a) ? (w) => l[w] + m : d + m).attr(
        "y2",
        u && !Zn(a) ? a.bandwidth ? (w) => u[w] + a.bandwidth() - b : (w) => u[w] - b : h - g - b
      ).call(Le, this, i).call(lf, this, i, s)
    ).node();
  }
}
class C4 extends ce {
  constructor(t, n = {}) {
    const { x1: i, x2: r, y: s, inset: o = 0, insetRight: a = o, insetLeft: c = o } = n;
    super(
      t,
      {
        y: { value: s, scale: "y", optional: !0 },
        x1: { value: i, scale: "x", optional: !0 },
        x2: { value: r, scale: "x", optional: !0 }
      },
      Kc(n, "y"),
      L4
    ), this.insetRight = kt(a), this.insetLeft = kt(c), Jc(this, n);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { y: c, x1: l, x2: u } = i, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: y, marginBottom: g } = r, { insetLeft: m, insetRight: b } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { y: c && a }, 0, Ye).call(
      (_) => _.selectAll().data(t).enter().append("line").call(pe, this).attr("x1", l && !Zn(o) ? (w) => l[w] + m : y + m).attr(
        "x2",
        u && !Zn(o) ? o.bandwidth ? (w) => u[w] + o.bandwidth() - b : (w) => u[w] - b : f - p - b
      ).attr("y1", c ? (w) => c[w] : (d + h - g) / 2).attr("y2", c ? (w) => c[w] : (d + h - g) / 2).call(Le, this, i).call(lf, this, i, s)
    ).node();
  }
}
function js(e, t) {
  let { x: n = lt, y: i, y1: r, y2: s, ...o } = D4(t);
  return [r, s] = k4(i, r, s), new R4(e, { ...o, x: n, y1: r, y2: s });
}
function Ys(e, t) {
  let { y: n = lt, x: i, x1: r, x2: s, ...o } = F4(t);
  return [r, s] = k4(i, r, s), new C4(e, { ...o, y: n, x1: r, x2: s });
}
function k4(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 Hy(e, ...t) {
  let n = t.length;
  for (let i = 0, r = !0; i < n; ++i)
    typeof t[i] != "function" && (r && (e = e.slice(), r = !1), e.splice(i, 2, e[i] + t[i] + e[i + 1]), t.splice(i, 1), --i, --n);
  return (i) => {
    let r = e[0];
    for (let s = 0; s < n; ++s)
      r += t[s](i) + e[s + 1];
    return r;
  };
}
const LY = {
  ariaLabel: "text",
  strokeLinejoin: "round",
  strokeWidth: 3,
  paintOrder: "stroke"
}, U4 = "­";
class Ky extends ce {
  constructor(t, n = {}) {
    const {
      x: i,
      y: r,
      text: s = dr(t) && L6(t) ? lt : In,
      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: l = 1,
      lineWidth: u = 1 / 0,
      textOverflow: f,
      monospace: h,
      fontFamily: d = h ? "ui-monospace, monospace" : void 0,
      fontSize: p,
      fontStyle: y,
      fontVariant: g,
      fontWeight: m,
      rotate: b
    } = n, [_, w] = Te(b, 0), [v, x] = UY(p);
    if (super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        fontSize: { value: v, optional: !0 },
        rotate: { value: vV(_), optional: !0 },
        text: { value: s, filter: $b, optional: !0 }
      },
      n,
      LY
    ), this.rotate = w, this.textAnchor = Ie(a, "middle"), this.lineAnchor = cs(c, "lineAnchor", ["top", "middle", "bottom"]), this.lineHeight = +l, this.lineWidth = +u, this.textOverflow = z4(f), this.monospace = !!h, this.fontFamily = je(d), this.fontSize = x, this.fontStyle = je(y), this.fontVariant = je(g), this.fontWeight = je(m), this.frameAnchor = of(o), !(this.lineWidth >= 0))
      throw new Error(`invalid lineWidth: ${u}`);
    this.splitLines = Y4(this), this.clipLine = q4(this);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, rotate: u, text: f, title: h, fontSize: d } = i, { rotate: p } = this, [y, g] = yr(this, r);
    return Wt("svg:g", s).call(ye, this, r, s).call(j4, this, f, r).call(ae, this, { x: c && o, y: l && a }).call(
      (m) => m.selectAll().data(t).enter().append("text").call(pe, this).call(RY, this, f, h).attr(
        "transform",
        Hy`translate(${c ? (b) => c[b] : y},${l ? (b) => l[b] : g})${u ? (b) => ` rotate(${u[b]})` : p ? ` rotate(${p})` : ""}`
      ).call(ot, "font-size", d && ((b) => d[b])).call(Le, this, i)
    ).node();
  }
}
function z4(e) {
  return e == null ? null : cs(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 RY(e, t, n, i) {
  if (!n)
    return;
  const { lineAnchor: r, lineHeight: s, textOverflow: o, splitLines: a, clipLine: c } = t;
  e.each(function(l) {
    const u = a(Xr(n[l]) ?? "").map(c), f = u.length, h = r === "top" ? 0.71 : r === "bottom" ? 1 - f : (164 - f * 100) / 200;
    if (f > 1) {
      let d = 0;
      for (let p = 0; p < f; ++p) {
        if (++d, !u[p])
          continue;
        const y = this.ownerDocument.createElementNS(Wo.svg, "tspan");
        y.setAttribute("x", 0), p === d - 1 ? y.setAttribute("y", `${(h + p) * s}em`) : y.setAttribute("dy", `${d * s}em`), y.textContent = u[p], this.appendChild(y), d = 0;
      }
    } else
      h && this.setAttribute("y", `${h * s}em`), this.textContent = u[0];
    if (o && !i && u[0] !== n[l]) {
      const d = this.ownerDocument.createElementNS(Wo.svg, "title");
      d.textContent = n[l], this.appendChild(d);
    }
  });
}
function Bc(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = Di(t, n)), new Ky(e, { ...i, x: t, y: n });
}
function P4(e, { x: t = lt, ...n } = {}) {
  return new Ky(e, E4({ ...n, x: t }));
}
function V4(e, { y: t = lt, ...n } = {}) {
  return new Ky(e, O4({ ...n, y: t }));
}
function j4(e, t, n) {
  ot(e, "text-anchor", t.textAnchor), ot(e, "font-family", t.fontFamily), ot(e, "font-size", t.fontSize), ot(e, "font-style", t.fontStyle), ot(e, "font-variant", t.fontVariant === void 0 ? CY(n) : t.fontVariant), ot(e, "font-weight", t.fontWeight);
}
function CY(e) {
  return e && (R6(e) || vn(e)) ? "tabular-nums" : void 0;
}
const kY = /* @__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 UY(e) {
  return e == null || typeof e == "number" ? [void 0, e] : typeof e != "string" ? [e, void 0] : (e = e.trim().toLowerCase(), kY.has(e) || /^[+-]?\d*\.?\d+(e[+-]?\d+)?(\w*|%)$/.test(e) ? [void 0, e] : [e, void 0]);
}
function zY(e, t, n) {
  const i = [];
  let r, s = 0;
  for (const [o, a, c] of PY(e)) {
    if (r === void 0 && (r = o), s > r && n(e, r, a) > t && (i.push(e.slice(r, s) + (e[s - 1] === U4 ? "-" : "")), r = o), c) {
      i.push(e.slice(r, a)), r = void 0;
      continue;
    }
    s = a;
  }
  return i;
}
function* PY(e) {
  let t = 0, n = 0;
  const i = e.length;
  for (; n < i; ) {
    let r = 1;
    switch (e[n]) {
      case U4:
      case "-":
        ++n, yield [t, n, !1], t = n;
        break;
      case " ":
        for (yield [t, n, !1]; e[++n] === " "; )
          ;
        t = n;
        break;
      case "\r":
        e[n + 1] === `
` && ++r;
      case `
`:
        yield [t, n, !0], n += r, t = n;
        break;
      default:
        ++n;
        break;
    }
  }
  yield [t, n, !0];
}
const lx = {
  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 c_(e, t = 0, n = e.length) {
  let i = 0;
  for (let r = t; r < n; r = Zc(e, r))
    i += lx[e[r]] ?? (G4(e, r) ? 120 : lx.e);
  return i;
}
function l_(e, t = 0, n = e.length) {
  let i = 0;
  for (let r = t; r < n; r = Zc(e, r))
    i += G4(e, r) ? 200 : 100;
  return i;
}
function Y4({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n != null || t == 1 / 0)
    return (s) => s.split(/\r\n?|\n/g);
  const i = e ? l_ : c_, r = t * 100;
  return (s) => zY(s, r, i);
}
function q4({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n == null || t == 1 / 0)
    return (s) => s;
  const i = e ? l_ : c_, r = t * 100;
  switch (n) {
    case "clip-start":
      return (s) => fx(s, r, i, "");
    case "clip-end":
      return (s) => ux(s, r, i, "");
    case "ellipsis-start":
      return (s) => fx(s, r, i, Ja);
    case "ellipsis-middle":
      return (s) => VY(s, r, i, Ja);
    case "ellipsis-end":
      return (s) => ux(s, r, i, Ja);
  }
}
const Ja = "…";
function Nc(e, t, n, i) {
  const r = [];
  let s = 0;
  for (let o = 0, a = 0, c = e.length; o < c; o = a) {
    a = Zc(e, o);
    const l = n(e, o, a);
    if (s + l > t) {
      for (s += i; s > t && o > 0; )
        a = o, o = r.pop(), s -= n(e, o, a);
      return [o, t - s];
    }
    s += l, r.push(o);
  }
  return [-1, 0];
}
function ux(e, t, n, i) {
  e = e.trim();
  const r = n(i), [s] = Nc(e, t, n, r);
  return s < 0 ? e : e.slice(0, s).trimEnd() + i;
}
function VY(e, t, n, i) {
  e = e.trim();
  const r = n(e);
  if (r <= t)
    return e;
  const s = n(i) / 2, [o, a] = Nc(e, t / 2, n, s), [c] = Nc(e, r - t / 2 - a + s, n, -s);
  return c < 0 ? i : e.slice(0, o).trimEnd() + i + e.slice(Zc(e, c)).trimStart();
}
function fx(e, t, n, i) {
  e = e.trim();
  const r = n(e);
  if (r <= t)
    return e;
  const s = n(i), [o] = Nc(e, r - t + s, n, -s);
  return o < 0 ? i : i + e.slice(Zc(e, o)).trimStart();
}
const kg = /[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy, hx = /\p{Extended_Pictographic}/uy;
function Zc(e, t) {
  return t += jY(e, t) ? 2 : 1, qY(e, t) && (t = kg.lastIndex), YY(e, t) ? Zc(e, t + 1) : t;
}
function W4(e, t) {
  return e.charCodeAt(t) < 128;
}
function jY(e, t) {
  const n = e.charCodeAt(t);
  if (n >= 55296 && n < 56320) {
    const i = e.charCodeAt(t + 1);
    return i >= 56320 && i < 57344;
  }
  return !1;
}
function YY(e, t) {
  return e.charCodeAt(t) === 8205;
}
function qY(e, t) {
  return W4(e, t) ? !1 : (kg.lastIndex = t, kg.test(e));
}
function G4(e, t) {
  return W4(e, t) ? !1 : (hx.lastIndex = t, hx.test(e));
}
const X4 = {
  ariaLabel: "vector",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinejoin: "round",
  strokeLinecap: "round"
}, H4 = 3.5, WY = H4 * 5, K4 = {
  draw(e, t, n) {
    const i = t * n / WY;
    e.moveTo(0, 0), e.lineTo(0, -t), e.moveTo(-i, i - t), e.lineTo(0, -t), e.lineTo(i, i - t);
  }
}, J4 = {
  draw(e, t, n) {
    e.moveTo(-n, 0), e.lineTo(0, -t), e.lineTo(n, 0);
  }
}, GY = /* @__PURE__ */ new Map([
  ["arrow", K4],
  ["spike", J4]
]);
function XY(e) {
  return e && typeof e.draw == "function";
}
function HY(e) {
  if (XY(e))
    return e;
  const t = GY.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid shape: ${e}`);
}
let Jy = class extends ce {
  constructor(t, n = {}) {
    const { x: i, y: r, r: s = H4, length: o, rotate: a, shape: c = K4, anchor: l = "middle", frameAnchor: u } = n, [f, h] = Te(o, 12), [d, p] = Te(a, 0);
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        length: { value: f, scale: "length", optional: !0 },
        rotate: { value: d, optional: !0 }
      },
      n,
      X4
    ), this.r = +s, this.length = h, this.rotate = p, this.shape = HY(c), this.anchor = cs(l, "anchor", ["start", "middle", "end"]), this.frameAnchor = of(u);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, length: u, rotate: f } = i, { length: h, rotate: d, anchor: p, shape: y, r: g } = this, [m, b] = yr(this, r);
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      (_) => _.selectAll().data(t).enter().append("path").call(pe, this).attr(
        "transform",
        Hy`translate(${c ? (w) => c[w] : m},${l ? (w) => l[w] : b})${f ? (w) => ` rotate(${f[w]})` : d ? ` rotate(${d})` : ""}${p === "start" ? "" : p === "end" ? u ? (w) => ` translate(0,${u[w]})` : ` translate(0,${h})` : u ? (w) => ` translate(0,${u[w] / 2})` : ` translate(0,${h / 2})`}`
      ).attr(
        "d",
        u ? (w) => {
          const v = zr();
          return y.draw(v, u[w], g), v;
        } : (() => {
          const w = zr();
          return y.draw(w, h, g), w;
        })()
      ).call(Le, this, i)
    ).node();
  }
};
function Z4(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return t.frameAnchor === void 0 && ([n, i] = Di(n, i)), new Jy(e, { ...r, x: n, y: i });
}
function Q4(e, t = {}) {
  const { x: n = lt, ...i } = t;
  return new Jy(e, { ...i, x: n });
}
function tT(e, t = {}) {
  const { y: n = lt, ...i } = t;
  return new Jy(e, { ...i, y: n });
}
function KY(e, t = {}) {
  const {
    shape: n = J4,
    stroke: i = X4.stroke,
    strokeWidth: r = 1,
    fill: s = i,
    fillOpacity: o = 0.3,
    anchor: a = "start",
    ...c
  } = t;
  return Z4(e, { ...c, shape: n, stroke: i, strokeWidth: r, fill: s, fillOpacity: o, anchor: a });
}
function ro(e, t) {
  return arguments.length < 2 && !dr(e) && (t = e, e = null), t === void 0 && (t = {}), [e, t];
}
function Zy({ anchor: e } = {}, t) {
  return e === void 0 ? t[0] : cs(e, "anchor", t);
}
function eT(e) {
  return Zy(e, ["left", "right"]);
}
function nT(e) {
  return Zy(e, ["right", "left"]);
}
function iT(e) {
  return Zy(e, ["bottom", "top"]);
}
function rT(e) {
  return Zy(e, ["top", "bottom"]);
}
function u_() {
  const [e, t] = ro(...arguments);
  return aT("y", eT(t), e, t);
}
function sT() {
  const [e, t] = ro(...arguments);
  return aT("fy", nT(t), e, t);
}
function f_() {
  const [e, t] = ro(...arguments);
  return cT("x", iT(t), e, t);
}
function oT() {
  const [e, t] = ro(...arguments);
  return cT("fx", rT(t), e, t);
}
function aT(e, t, n, {
  color: i = "currentColor",
  opacity: r = 1,
  stroke: s = i,
  strokeOpacity: o = r,
  strokeWidth: a = 1,
  fill: c = i,
  fillOpacity: l = r,
  textAnchor: u,
  textStroke: f,
  textStrokeOpacity: h,
  textStrokeWidth: d,
  tickSize: p = e === "y" ? 6 : 0,
  tickPadding: y,
  tickRotate: g,
  x: m,
  margin: b,
  marginTop: _ = b === void 0 ? 20 : b,
  marginRight: w = b === void 0 ? t === "right" ? 40 : 0 : b,
  marginBottom: v = b === void 0 ? 20 : b,
  marginLeft: x = b === void 0 ? t === "left" ? 40 : 0 : b,
  label: I,
  labelAnchor: T,
  labelArrow: D,
  labelOffset: $,
  ...A
}) {
  return p = kt(p), y = kt(y), g = kt(g), T !== void 0 && (T = cs(T, "labelAnchor", ["center", "top", "bottom"])), D = wT(D), ns(
    p && !ke(s) ? JY(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      x: m,
      ...A
    }) : null,
    ke(c) ? null : QY(e, t, n, {
      fill: c,
      fillOpacity: l,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: u,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      x: m,
      marginTop: _,
      marginRight: w,
      marginBottom: v,
      marginLeft: x,
      ...A
    }),
    !ke(c) && I !== null ? Bc(
      [],
      mT({ fill: c, fillOpacity: l, ...A }, function(F, E, S, M, B) {
        const N = M[e], { marginTop: L, marginRight: k, marginBottom: U, marginLeft: j } = e === "y" && B.inset || B, P = T ?? (N.bandwidth ? "center" : "top"), K = $ ?? (t === "right" ? k : j) - 3;
        return P === "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 = P, this.frameAnchor = `${P}-${t}`, this.rotate = 0), this.dy = P === "top" ? 3 - L : P === "bottom" ? U - 3 : 0, this.dx = t === "right" ? K : -K, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [_T(e, N, { anchor: t, label: I, labelAnchor: P, labelArrow: D })] } }
        };
      })
    ) : null
  );
}
function cT(e, t, n, {
  color: i = "currentColor",
  opacity: r = 1,
  stroke: s = i,
  strokeOpacity: o = r,
  strokeWidth: a = 1,
  fill: c = i,
  fillOpacity: l = r,
  textAnchor: u,
  textStroke: f,
  textStrokeOpacity: h,
  textStrokeWidth: d,
  tickSize: p = e === "x" ? 6 : 0,
  tickPadding: y,
  tickRotate: g,
  y: m,
  margin: b,
  marginTop: _ = b === void 0 ? t === "top" ? 30 : 0 : b,
  marginRight: w = b === void 0 ? 20 : b,
  marginBottom: v = b === void 0 ? t === "bottom" ? 30 : 0 : b,
  marginLeft: x = b === void 0 ? 20 : b,
  label: I,
  labelAnchor: T,
  labelArrow: D,
  labelOffset: $,
  ...A
}) {
  return p = kt(p), y = kt(y), g = kt(g), T !== void 0 && (T = cs(T, "labelAnchor", ["center", "left", "right"])), D = wT(D), ns(
    p && !ke(s) ? ZY(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      y: m,
      ...A
    }) : null,
    ke(c) ? null : tq(e, t, n, {
      fill: c,
      fillOpacity: l,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: u,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      y: m,
      marginTop: _,
      marginRight: w,
      marginBottom: v,
      marginLeft: x,
      ...A
    }),
    !ke(c) && I !== null ? Bc(
      [],
      mT({ fill: c, fillOpacity: l, ...A }, function(F, E, S, M, B) {
        const N = M[e], { marginTop: L, marginRight: k, marginBottom: U, marginLeft: j } = e === "x" && B.inset || B, P = T ?? (N.bandwidth ? "center" : "right"), K = $ ?? (t === "top" ? L : U) - 3;
        return P === "center" ? (this.frameAnchor = t, this.textAnchor = void 0) : (this.frameAnchor = `${t}-${P}`, this.textAnchor = P === "right" ? "end" : "start"), this.lineAnchor = t, this.dy = t === "top" ? -K : K, this.dx = P === "right" ? k - 3 : P === "left" ? 3 - j : 0, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [_T(e, N, { anchor: t, label: I, labelAnchor: P, labelArrow: D })] } }
        };
      })
    ) : null
  );
}
function JY(e, t, n, {
  strokeWidth: i = 1,
  strokeLinecap: r = null,
  strokeLinejoin: s = null,
  facetAnchor: o = t + (e === "y" ? "-empty" : ""),
  frameAnchor: a = t,
  tickSize: c,
  inset: l = 0,
  insetLeft: u = l,
  insetRight: f = l,
  dx: h = 0,
  y: d = e === "y" ? void 0 : null,
  ...p
}) {
  return Qc(tT, e, `${e}-axis tick`, n, {
    strokeWidth: i,
    strokeLinecap: r,
    strokeLinejoin: s,
    facetAnchor: o,
    frameAnchor: a,
    y: d,
    ...p,
    dx: t === "left" ? +h - Ye + +u : +h + Ye - f,
    anchor: "start",
    length: c,
    shape: t === "left" ? iq : rq
  });
}
function ZY(e, t, n, {
  strokeWidth: i = 1,
  strokeLinecap: r = null,
  strokeLinejoin: s = null,
  facetAnchor: o = t + (e === "x" ? "-empty" : ""),
  frameAnchor: a = t,
  tickSize: c,
  inset: l = 0,
  insetTop: u = l,
  insetBottom: f = l,
  dy: h = 0,
  x: d = e === "x" ? void 0 : null,
  ...p
}) {
  return Qc(Q4, e, `${e}-axis tick`, n, {
    strokeWidth: i,
    strokeLinejoin: s,
    strokeLinecap: r,
    facetAnchor: o,
    frameAnchor: a,
    x: d,
    ...p,
    dy: t === "bottom" ? +h - Ye - f : +h + Ye + +u,
    anchor: "start",
    length: c,
    shape: t === "bottom" ? eq : nq
  });
}
function QY(e, t, n, {
  facetAnchor: i = t + (e === "y" ? "-empty" : ""),
  frameAnchor: r = t,
  tickSize: s,
  tickRotate: o = 0,
  tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) > 60 ? 4 * Math.cos(o * cp) : 0),
  tickFormat: c,
  text: l = typeof c == "function" ? c : void 0,
  textAnchor: u = Math.abs(o) > 60 ? "middle" : t === "left" ? "end" : "start",
  lineAnchor: f = o > 60 ? "top" : o < -60 ? "bottom" : "middle",
  fontVariant: h,
  inset: d = 0,
  insetLeft: p = d,
  insetRight: y = d,
  dx: g = 0,
  y: m = e === "y" ? void 0 : null,
  ...b
}) {
  return Qc(
    V4,
    e,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: i,
      frameAnchor: r,
      text: l === void 0 ? null : l,
      textAnchor: u,
      lineAnchor: f,
      fontVariant: h,
      rotate: o,
      y: m,
      ...b,
      dx: t === "left" ? +g - s - a + +p : +g + +s + +a - y
    },
    function(_, w, v) {
      h === void 0 && (this.fontVariant = bT(_)), l === void 0 && (v.text = gT(_, w, c));
    }
  );
}
function tq(e, t, n, {
  facetAnchor: i = t + (e === "x" ? "-empty" : ""),
  frameAnchor: r = t,
  tickSize: s,
  tickRotate: o = 0,
  tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) >= 10 ? 4 * Math.cos(o * cp) : 0),
  tickFormat: c,
  text: l = typeof c == "function" ? c : void 0,
  textAnchor: u = Math.abs(o) >= 10 ? o < 0 ^ t === "bottom" ? "start" : "end" : "middle",
  lineAnchor: f = Math.abs(o) >= 10 ? "middle" : t === "bottom" ? "top" : "bottom",
  fontVariant: h,
  inset: d = 0,
  insetTop: p = d,
  insetBottom: y = d,
  dy: g = 0,
  x: m = e === "x" ? void 0 : null,
  ...b
}) {
  return Qc(
    P4,
    e,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: i,
      frameAnchor: r,
      text: l === void 0 ? null : l,
      textAnchor: u,
      lineAnchor: f,
      fontVariant: h,
      rotate: o,
      x: m,
      ...b,
      dy: t === "bottom" ? +g + +s + +a - y : +g - s - a + +p
    },
    function(_, w, v) {
      h === void 0 && (this.fontVariant = bT(_)), l === void 0 && (v.text = gT(_, w, c));
    }
  );
}
function lT() {
  const [e, t] = ro(...arguments);
  return dT("y", eT(t), e, t);
}
function uT() {
  const [e, t] = ro(...arguments);
  return dT("fy", nT(t), e, t);
}
function fT() {
  const [e, t] = ro(...arguments);
  return pT("x", iT(t), e, t);
}
function hT() {
  const [e, t] = ro(...arguments);
  return pT("fx", rT(t), e, t);
}
function dT(e, t, n, {
  y: i = e === "y" ? void 0 : null,
  x: r = null,
  x1: s = t === "left" ? r : null,
  x2: o = t === "right" ? r : null,
  ...a
}) {
  return Qc(Ys, e, `${e}-grid`, n, { y: i, x1: s, x2: o, ...yT(a) });
}
function pT(e, t, n, {
  x: i = e === "x" ? void 0 : null,
  y: r = null,
  y1: s = t === "top" ? r : null,
  y2: o = t === "bottom" ? r : null,
  ...a
}) {
  return Qc(js, e, `${e}-grid`, n, { x: i, y1: s, y2: o, ...yT(a) });
}
function yT({
  color: e = "currentColor",
  opacity: t = 0.1,
  stroke: n = e,
  strokeOpacity: i = t,
  strokeWidth: r = 1,
  ...s
}) {
  return { stroke: n, strokeOpacity: i, strokeWidth: r, ...s };
}
function mT({ fill: e, fillOpacity: t, fontFamily: n, fontSize: i, fontStyle: r, fontWeight: s, monospace: o, pointerEvents: a, shapeRendering: c }, l) {
  return [, e] = _n(e), [, t] = Te(t), {
    facet: "super",
    x: null,
    y: null,
    fill: e,
    fillOpacity: t,
    fontFamily: n,
    fontSize: i,
    fontStyle: r,
    fontWeight: s,
    monospace: o,
    pointerEvents: a,
    shapeRendering: c,
    initializer: l
  };
}
function Qc(e, t, n, i, r, s) {
  let o;
  const a = e(
    i,
    Rn(r, function(c, l, u, f, h, d) {
      const p = c == null && (t === "fx" || t === "fy"), { [t]: y } = f;
      if (!y)
        throw new Error(`missing scale: ${t}`);
      let { ticks: g, tickSpacing: m, interval: b } = r;
      if (d4(y) && typeof g == "string" && (b = g, g = void 0), c == null) {
        if (dr(g))
          c = wn(g);
        else if (y.ticks)
          if (g !== void 0)
            c = y.ticks(g);
          else if (b = Hc(b === void 0 ? y.interval : b, y.type), b !== void 0) {
            const [w, v] = He(y.domain());
            c = b.range(w, b.offset(b.floor(v)));
          } else {
            const [w, v] = He(y.range());
            g = (v - w) / (m === void 0 ? t === "x" ? 80 : 35 : m), c = y.ticks(g);
          }
        else
          c = y.domain();
        t === "y" || t === "x" ? l = [ls(c)] : o[t] = { scale: t, value: lt };
      }
      s == null || s.call(this, y, g, o);
      const _ = Object.fromEntries(
        Object.entries(o).map(([w, v]) => [w, { ...v, value: Lt(c, v.value) }])
      );
      return p && (l = d.filterFacets(c, _)), { data: c, facets: l, channels: _ };
    })
  );
  return i == null ? (o = a.channels, a.channels = {}) : o = {}, a.ariaLabel = n, a;
}
function gT(e, t, n) {
  return { value: Ug(e, t, n) };
}
function Ug(e, t, n) {
  return e.tickFormat ? e.tickFormat(dr(t) ? null : t, n) : n === void 0 ? dV(e.interval) ? wu("%Y") : pV(e.interval) ? gb("%Y") : Xr : typeof n == "string" ? (vn(e.domain()) ? wu : Wc)(n) : Ln(n);
}
const eq = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, t);
  }
}, nq = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, -t);
  }
}, iq = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(-t, 0);
  }
}, rq = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(t, 0);
  }
};
function bT(e) {
  return e.bandwidth && !e.interval ? void 0 : "tabular-nums";
}
function sq(e) {
  return Math.sign(Su(e.domain())) * Math.sign(Su(e.range()));
}
function _T(e, t, { anchor: n, label: i = t.label, labelAnchor: r, labelArrow: s } = {}) {
  if (!(i == null || i.inferred && oq(t) && /^(date|time|year)$/i.test(i))) {
    if (i = String(i), s === "auto" && (s = (!t.bandwidth || t.interval) && !/[↑↓→←]/.test(i)), !s)
      return i;
    if (s === !0) {
      const o = sq(t);
      o && (s = /x$/.test(e) || r === "center" ? /x$/.test(e) === o < 0 ? "left" : "right" : o < 0 ? "up" : "down");
    }
    switch (s) {
      case "left":
        return `← ${i}`;
      case "right":
        return `${i} →`;
      case "up":
        return n === "right" ? `${i} ↑` : `↑ ${i}`;
      case "down":
        return n === "right" ? `${i} ↓` : `↓ ${i}`;
    }
    return i;
  }
}
function wT(e = "auto") {
  return ke(e) ? !1 : typeof e == "boolean" ? e : cs(e, "labelArrow", ["auto", "up", "right", "down", "left"]);
}
function oq(e) {
  return d4(e) || e.interval != null;
}
const aq = {
  ariaLabel: "frame",
  fill: "none",
  stroke: "currentColor"
}, cq = {
  ariaLabel: "frame",
  fill: null,
  stroke: "currentColor",
  strokeLinecap: "square"
};
class vT extends ce {
  constructor(t = {}) {
    const {
      anchor: n = null,
      inset: i = 0,
      insetTop: r = i,
      insetRight: s = i,
      insetBottom: o = i,
      insetLeft: a = i,
      rx: c,
      ry: l
    } = t;
    super(Hl, void 0, t, n == null ? aq : cq), this.anchor = Oy(n, "anchor", ["top", "right", "bottom", "left"]), this.insetTop = kt(r), this.insetRight = kt(s), this.insetBottom = kt(o), this.insetLeft = kt(a), this.rx = kt(c), this.ry = kt(l);
  }
  render(t, n, i, r, s) {
    const { marginTop: o, marginRight: a, marginBottom: c, marginLeft: l, width: u, height: f } = r, { anchor: h, insetTop: d, insetRight: p, insetBottom: y, insetLeft: g, rx: m, ry: b } = this, _ = l + g, w = u - a - p, v = o + d, x = f - c - y;
    return Wt(h ? "svg:line" : "svg:rect", s).datum(0).call(ye, this, r, s).call(pe, this).call(Le, this, i).call(ae, this, {}).call(
      h === "left" ? (I) => I.attr("x1", _).attr("x2", _).attr("y1", v).attr("y2", x) : h === "right" ? (I) => I.attr("x1", w).attr("x2", w).attr("y1", v).attr("y2", x) : h === "top" ? (I) => I.attr("x1", _).attr("x2", w).attr("y1", v).attr("y2", v) : h === "bottom" ? (I) => I.attr("x1", _).attr("x2", w).attr("y1", x).attr("y2", x) : (I) => I.attr("x", _).attr("y", v).attr("width", w - _).attr("height", x - v).attr("rx", m).attr("ry", b)
    ).node();
  }
}
function h_(e) {
  return new vT(e);
}
const um = {
  ariaLabel: "tip",
  fill: "white",
  stroke: "currentColor"
}, lq = /* @__PURE__ */ new Set(["geometry", "href", "src", "ariaLabel"]);
class xT extends ce {
  constructor(t, n = {}) {
    n.tip && (n = { ...n, tip: !1 }), n.title === void 0 && dr(t) && L6(t) && (n = { ...n, title: lt });
    const {
      x: i,
      y: r,
      x1: s,
      x2: o,
      y1: a,
      y2: c,
      anchor: l,
      monospace: u,
      fontFamily: f = u ? "ui-monospace, monospace" : void 0,
      fontSize: h,
      fontStyle: d,
      fontVariant: p,
      fontWeight: y,
      lineHeight: g = 1,
      lineWidth: m = 20,
      frameAnchor: b,
      textAnchor: _ = "start",
      textOverflow: w,
      textPadding: v = 8,
      pointerSize: x = 12,
      pathFilter: I = "drop-shadow(0 3px 4px rgba(0,0,0,0.2))"
    } = n;
    super(
      t,
      {
        x: { value: s != null && o != null ? null : i, scale: "x", optional: !0 },
        // ignore midpoint
        y: { value: a != null && c != null ? null : r, 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,
      um
    ), this.anchor = C6(l, "anchor"), this.previousAnchor = this.anchor ?? "top-left", this.frameAnchor = of(b), this.textAnchor = Ie(_, "middle"), this.textPadding = +v, this.pointerSize = +x, this.pathFilter = je(I), this.lineHeight = +g, this.lineWidth = +m, this.textOverflow = z4(w), this.monospace = !!u, this.fontFamily = je(f), this.fontSize = kt(h), this.fontStyle = je(d), this.fontVariant = je(p), this.fontWeight = je(y);
    for (const T in um)
      T in this.channels && (this[T] = um[T]);
    this.splitLines = Y4(this), this.clipLine = q4(this);
  }
  render(t, n, i, r, s) {
    const o = this, { x: a, y: c, fx: l, fy: u } = n, { ownerSVGElement: f, document: h } = s, { anchor: d, monospace: p, lineHeight: y, lineWidth: g } = this, { textPadding: m, pointerSize: b, pathFilter: _ } = this, { marginTop: w, marginLeft: v } = r, x = dq(i), { x1: I, y1: T, x2: D, y2: $, x: A = I ?? D, y: F = T ?? $ } = i, E = l ? l(t.fx) - v : 0, S = u ? u(t.fy) - w : 0, [M, B] = yr(this, r), N = w4(i, M), L = v4(i, B), k = p ? l_ : c_, U = k(Ja), j = l && Ug(l), P = u && Ug(u);
    function* K(H, X) {
      if ("title" in H) {
        const V = H.title.value[X];
        for (const G of o.splitLines(Xr(V)))
          yield { name: "", value: o.clipLine(G) };
        return;
      }
      for (const V in H) {
        if (V === "x1" && "x2" in H || V === "y1" && "y2" in H)
          continue;
        const G = H[V], J = G.value[X];
        if (!(!cn(J) && G.scale == null))
          if (V === "x2" && "x1" in H)
            yield { name: fm(n, G, "x"), value: dx(H.x1, G, X) };
          else if (V === "y2" && "y1" in H)
            yield { name: fm(n, G, "y"), value: dx(H.y1, G, X) };
          else {
            const z = G.scale, nt = { name: fm(n, G, V), value: Xr(J) };
            (z === "color" || z === "opacity") && (nt[z] = i[V][X]), yield nt;
          }
      }
      t.fi != null && l && (yield { name: String(l.label ?? "fx"), value: j(t.fx) }), t.fi != null && u && (yield { name: String(u.label ?? "fy"), value: P(t.fy) });
    }
    const Z = Wt("svg:g", s).call(ye, this, r, s).call(j4, this).call(ae, this, { x: A && a, y: F && c }).call(
      (H) => H.selectAll().data(t).enter().append("g").attr("transform", (X) => `translate(${Math.round(N(X))},${Math.round(L(X))})`).call(pe, this).call((X) => X.append("path").attr("filter", _)).call(
        (X) => X.append("text").each(function(V) {
          const G = re(this);
          this.setAttribute("fill", "currentColor"), this.setAttribute("fill-opacity", 1), this.setAttribute("stroke", "none");
          const J = /* @__PURE__ */ new Set();
          for (const z of K(x, V)) {
            const nt = z.name;
            nt && J.has(nt) || (J.add(nt), et(G, z));
          }
        })
      )
    );
    function et(H, { name: X, value: V, color: G, opacity: J }) {
      const z = G != null || J != null;
      let nt, ut = g * 100;
      const [Gt] = Nc(X, ut, k, U);
      if (Gt >= 0)
        X = X.slice(0, Gt).trimEnd() + Ja, nt = V.trim(), V = "";
      else {
        (X || !V && !z) && (V = " " + V);
        const [Q] = Nc(V, ut - k(X), k, U);
        Q >= 0 && (V = V.slice(0, Q).trimEnd() + Ja, nt = V.trim());
      }
      const Ot = H.append("tspan").attr("x", 0).attr("dy", `${y}em`).text("​");
      X && Ot.append("tspan").attr("font-weight", "bold").text(X), V && Ot.append(() => h.createTextNode(V)), z && Ot.append("tspan").text(" ■").attr("fill", G).attr("fill-opacity", J).style("user-select", "none"), nt && Ot.append("title").text(nt);
    }
    function tt() {
      const { width: H, height: X } = r.facet ?? r;
      Z.selectChildren().each(function(V) {
        let { x: G, width: J, height: z } = this.getBBox();
        J = Math.round(J), z = Math.round(z);
        let nt = d;
        if (nt === void 0) {
          nt = o.previousAnchor;
          const Ot = N(V) + E, Q = L(V) + S, ee = Ot + J + m * 2 < H, Ei = Ot - J - m * 2 > 0, An = Q + z + b + m * 2 + 7 < X, If = Q - z - b - m * 2 > 0, $f = (/-left$/.test(nt) ? ee || !Ei : ee && !Ei) ? "left" : "right", h0 = (/^top-/.test(nt) ? An || !If : An && !If) ? "top" : "bottom";
          nt = o.previousAnchor = `${h0}-${$f}`;
        }
        const ut = this.firstChild, Gt = this.lastChild;
        if (ut.setAttribute("d", hq(nt, b, m, J, z)), G)
          for (const Ot of Gt.childNodes)
            Ot.setAttribute("x", -G);
        Gt.setAttribute("y", `${+uq(nt, Gt.childNodes.length, y).toFixed(6)}em`), Gt.setAttribute("transform", `translate(${fq(nt, b, m, J, z)})`);
      });
    }
    return f.isConnected ? Promise.resolve().then(tt) : typeof requestAnimationFrame < "u" && requestAnimationFrame(tt), Z.node();
  }
}
function ST(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = Di(t, n)), new xT(e, { ...i, x: t, y: n });
}
function uq(e, t, n) {
  return /^top(?:-|$)/.test(e) ? 0.94 - n : -0.29 - t * n;
}
function fq(e, t, n, i, r) {
  switch (e) {
    case "middle":
      return [-i / 2, r / 2];
    case "top-left":
      return [n, t + n];
    case "top":
      return [-i / 2, t / 2 + n];
    case "top-right":
      return [-i - n, t + n];
    case "right":
      return [-t / 2 - i - n, r / 2];
    case "bottom-left":
      return [n, -t - n];
    case "bottom":
      return [-i / 2, -t / 2 - n];
    case "bottom-right":
      return [-i - n, -t - n];
    case "left":
      return [n + t / 2, r / 2];
  }
}
function hq(e, t, n, i, r) {
  const s = i + n * 2, o = r + 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 dq({ channels: e }) {
  const t = {};
  for (const n in e) {
    if (lq.has(n))
      continue;
    const i = G6(e, n);
    i && (t[n] = i);
  }
  return t;
}
function dx(e, t, n) {
  var i;
  return (i = t.hint) != null && i.length ? `${Xr(t.value[n] - e.value[n])}` : `${Xr(e.value[n])}–${Xr(t.value[n])}`;
}
function fm(e, t, n) {
  var i;
  return String(((i = e[t.scale]) == null ? void 0 : i.label) ?? (t == null ? void 0 : t.label) ?? n);
}
function d_(e = {}) {
  var B;
  const { facet: t, style: n, caption: i, ariaLabel: r, ariaDescription: s } = e, o = t_(e.className), a = e.marks === void 0 ? [] : px(e.marks);
  a.push(...wq(a));
  const c = bq(t, e), l = /* @__PURE__ */ new Map();
  for (const N of a) {
    const L = yx(N, c, e);
    L && l.set(N, L);
  }
  const u = /* @__PURE__ */ new Map();
  c && _l(u, [c], e), _l(u, l, e);
  const f = px(vq(a, u, e));
  for (const N of f) {
    const L = yx(N, c, e);
    L && l.set(N, L);
  }
  a.unshift(...f);
  let h = cY(u, e);
  if (h !== void 0) {
    const N = c ? cm(h, c) : void 0;
    for (const k of a) {
      if (k.facet === null || k.facet === "super")
        continue;
      const U = l.get(k);
      U !== void 0 && (U.facetsIndex = k.fx != null || k.fy != null ? cm(h, U) : N);
    }
    const L = /* @__PURE__ */ new Set();
    for (const { facetsIndex: k } of l.values())
      k == null || k.forEach((U, j) => {
        (U == null ? void 0 : U.length) > 0 && L.add(j);
      });
    h.forEach(
      0 < L.size && L.size < h.length ? (k, U) => k.empty = !L.has(U) : (k) => k.empty = !1
    );
    for (const k of a)
      if (k.facet === "exclude") {
        const U = l.get(k);
        U !== void 0 && (U.facetsIndex = fY(U.facetsIndex));
      }
  }
  for (const N of ve.keys())
    Po(e[N]) && N !== "fx" && N !== "fy" && u.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: L, channels: k } = l.get(N) ?? {}, { data: U, facets: j, channels: P } = N.initialize(L, k, e);
    p_(P, e), d.set(N, { data: U, facets: j, channels: P });
  }
  const p = Lg(_l(u, d, e), e), y = Z2(p), g = oY(p, a, e);
  Rj(p, g);
  const { fx: m, fy: b } = y, _ = m || b ? l4(p, g) : g, w = m || b ? Tq(y, g) : g, v = jy(e), x = v.document, I = cy("svg").call(x.documentElement);
  let T = I;
  v.ownerSVGElement = I, v.className = o, v.projection = KV(e, _), v.filterFacets = (N, L) => cm(h, { channels: L, groups: n_(N, L) }), v.getMarkState = (N) => {
    const L = d.get(N), k = l.get(N);
    return { ...L, channels: { ...L.channels, ...k == null ? void 0 : k.channels } };
  }, v.dispatchValue = (N) => {
    T.value !== N && (T.value = N, T.dispatchEvent(new Event("input", { bubbles: !0 })));
  };
  const D = /* @__PURE__ */ new Set();
  for (const [N, L] of d)
    if (N.initializer != null) {
      const k = N.facet === "super" ? w : _, U = N.initializer(L.data, L.facets, L.channels, y, k, v);
      if (U.data !== void 0 && (L.data = U.data), U.facets !== void 0 && (L.facets = U.facets), U.channels !== void 0) {
        const { fx: j, fy: P, ...K } = U.channels;
        gq(K), Object.assign(L.channels, K);
        for (const Z of Object.values(K)) {
          const { scale: et } = Z;
          et != null && ve.get(et) !== Qi && (IT(Z, e), D.add(et));
        }
        (j != null || P != null) && l.set(N, !0);
      }
    }
  if (D.size) {
    const N = /* @__PURE__ */ new Map();
    _l(N, d, e, (U) => D.has(U)), _l(u, d, e, (U) => D.has(U));
    const L = Mq(Lg(N, e), p), k = Z2(L);
    Object.assign(p, L), Object.assign(y, k);
  }
  let $, A;
  h !== void 0 && ($ = { x: m == null ? void 0 : m.domain(), y: b == null ? void 0 : b.domain() }, h = lY(h, $), A = uY(m, b, g));
  for (const [N, L] of d)
    L.values = N.scale(L.channels, y, v);
  const { width: F, height: E } = g;
  re(I).attr("class", o).attr("fill", "currentColor").attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("text-anchor", "middle").attr("width", F).attr("height", E).attr("viewBox", `0 0 ${F} ${E}`).attr("aria-label", r).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(e_, n);
  for (const N of a) {
    const { channels: L, values: k, facets: U } = d.get(N);
    if (h === void 0 || N.facet === "super") {
      let j = null;
      if (U && (j = U[0], j = N.filter(j, L, k), j.length === 0))
        continue;
      const P = N.render(j, y, k, w, v);
      if (P == null)
        continue;
      I.appendChild(P);
    } else {
      let j;
      for (const P of h) {
        if (!(((B = N.facetAnchor) == null ? void 0 : B.call(N, h, $, P)) ?? !P.empty))
          continue;
        let K = null;
        if (U) {
          const et = l.has(N);
          if (K = U[et ? P.i : 0], K = N.filter(K, L, k), K.length === 0)
            continue;
          et && (K.fx = P.x, K.fy = P.y, K.fi = P.i);
        }
        const Z = N.render(K, y, k, _, v);
        if (Z != null) {
          (j ?? (j = re(I).append("g"))).append(() => Z).datum(P);
          for (const et of ["aria-label", "aria-description", "aria-hidden", "transform"])
            Z.hasAttribute(et) && (j.attr(et, Z.getAttribute(et)), Z.removeAttribute(et));
        }
      }
      j == null || j.selectChildren().attr("transform", A);
    }
  }
  const S = NY(p, v, e);
  if (i != null || S.length > 0) {
    T = x.createElement("figure"), T.style.maxWidth = "initial";
    for (const N of S)
      T.appendChild(N);
    if (T.appendChild(I), i != null) {
      const N = x.createElement("figcaption");
      N.appendChild(i != null && i.ownerDocument ? i : x.createTextNode(i)), T.appendChild(N);
    }
  }
  T.scale = Vj(p), T.legend = MY(p, v, e);
  const M = HV();
  return M > 0 && re(I).append("text").attr("x", F).attr("y", 20).attr("dy", "-1em").attr("text-anchor", "end").attr("font-family", "initial").text("⚠️").append("title").text(`${M.toLocaleString("en-US")} warning${M === 1 ? "" : "s"}. Please check the console.`), T;
}
function pq({ marks: e = [], ...t } = {}) {
  return d_({ ...t, marks: [...e, this] });
}
ce.prototype.plot = pq;
function px(e) {
  return e.flat(1 / 0).filter((t) => t != null).map(yq);
}
function yq(e) {
  return typeof e.render == "function" ? e : new mq(e);
}
class mq extends ce {
  constructor(t) {
    if (typeof t != "function")
      throw new TypeError("invalid mark; missing render function");
    super(), this.render = t;
  }
  render() {
  }
}
function p_(e, t) {
  for (const n in e)
    IT(e[n], t);
  return e;
}
function IT(e, t) {
  const { scale: n, transform: i = !0 } = e;
  if (n == null || !i)
    return;
  const {
    type: r,
    percent: s,
    interval: o,
    transform: a = s ? (c) => c * 100 : E6(o, r)
  } = t[n] ?? {};
  a != null && (e.value = he(e.value, a), e.transform = !1);
}
function gq(e) {
  for (const t in e)
    Y6(t, e[t]);
}
function _l(e, t, n, i = gV) {
  var r, s;
  for (const { channels: o } of t.values())
    for (const a in o) {
      const c = o[a], { scale: l } = c;
      if (l != null && i(l))
        if (l === "projection") {
          if (!QV(n)) {
            const u = ((r = n.x) == null ? void 0 : r.domain) === void 0, f = ((s = n.y) == null ? void 0 : s.domain) === void 0;
            if (u || f) {
              const [h, d] = ej(c);
              u && hm(e, "x", h), f && hm(e, "y", d);
            }
          }
        } else
          hm(e, l, c);
    }
  return e;
}
function hm(e, t, n) {
  const i = e.get(t);
  i !== void 0 ? i.push(n) : e.set(t, [n]);
}
function bq(e, t) {
  if (e == null)
    return;
  const { x: n, y: i } = e;
  if (n == null && i == null)
    return;
  const r = wn(e.data);
  if (r == null)
    throw new Error("missing facet data");
  const s = {};
  n != null && (s.fx = Au(r, { value: n, scale: "fx" })), i != null && (s.fy = Au(r, { value: i, scale: "fy" })), p_(s, t);
  const o = n_(r, s);
  return { channels: s, groups: o, data: e.data };
}
function yx(e, t, n) {
  var c;
  if (e.facet === null || e.facet === "super")
    return;
  const { fx: i, fy: r } = e;
  if (i != null || r != null) {
    const l = wn(e.data ?? i ?? r);
    if (l === void 0)
      throw new Error(`missing facet data in ${e.ariaLabel}`);
    if (l === null)
      return;
    const u = {};
    return i != null && (u.fx = Au(l, { value: i, scale: "fx" })), r != null && (u.fy = Au(l, { value: r, scale: "fy" })), p_(u, n), { channels: u, groups: n_(l, u) };
  }
  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 = wn(e.data)) == null ? void 0 : c.length) === a.length && ir(
    `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 _q(e, t = {}) {
  return Rn({ ...t, x: null, y: null }, (n, i, r, s, o, a) => a.getMarkState(e));
}
function wq(e) {
  const t = [];
  for (const n of e) {
    const i = n.tip;
    if (i) {
      const s = (i === "x" ? s_ : i === "y" ? o_ : r_)(_q(n));
      s.title = null, t.push(ST(n.data, s));
    }
  }
  return t;
}
function vq(e, t, n) {
  let {
    projection: i,
    x: r = {},
    y: s = {},
    fx: o = {},
    fy: a = {},
    axis: c,
    grid: l,
    facet: u = {},
    facet: { axis: f = c, grid: h } = u,
    x: { axis: d = c, grid: p = d === null ? null : l } = r,
    y: { axis: y = c, grid: g = y === null ? null : l } = s,
    fx: { axis: m = f, grid: b = m === null ? null : h } = o,
    fy: { axis: _ = f, grid: w = _ === null ? null : h } = a
  } = n;
  (i || !Po(r) && !mx("x", e)) && (d = p = null), (i || !Po(s) && !mx("y", e)) && (y = g = null), t.has("fx") || (m = b = null), t.has("fy") || (_ = w = null), d === void 0 && (d = !Zf(e, "x")), y === void 0 && (y = !Zf(e, "y")), m === void 0 && (m = !Zf(e, "fx")), _ === void 0 && (_ = !Zf(e, "fy")), d === !0 && (d = "bottom"), y === !0 && (y = "left"), m === !0 && (m = d === "top" || d === null ? "bottom" : "top"), _ === !0 && (_ = y === "right" || y === null ? "left" : "right");
  const v = [];
  return Jf(v, w, uT, a), Kf(v, _, sT, "right", "left", u, a), Jf(v, b, hT, o), Kf(v, m, oT, "top", "bottom", u, o), Jf(v, g, lT, s), Kf(v, y, u_, "left", "right", n, s), Jf(v, p, fT, r), Kf(v, d, f_, "bottom", "top", n, r), v;
}
function Kf(e, t, n, i, r, s, o) {
  if (!t)
    return;
  const a = xq(t);
  o = Sq(a ? i : t, s, o);
  const { line: c } = o;
  (n === u_ || n === f_) && c && !Tc(c) && e.push(h_(Iq(o))), e.push(n(o)), a && e.push(n({ ...o, anchor: r, label: null }));
}
function Jf(e, t, n, i) {
  !t || Tc(t) || e.push(n($q(t, i)));
}
function xq(e) {
  return /^\s*both\s*$/i.test(e);
}
function Sq(e, t, {
  line: n = t.line,
  ticks: i,
  tickSize: r,
  tickSpacing: s,
  tickPadding: o,
  tickFormat: a,
  tickRotate: c,
  fontVariant: l,
  ariaLabel: u,
  ariaDescription: f,
  label: h = t.label,
  labelAnchor: d,
  labelArrow: p = t.labelArrow,
  labelOffset: y
}) {
  return {
    anchor: e,
    line: n,
    ticks: i,
    tickSize: r,
    tickSpacing: s,
    tickPadding: o,
    tickFormat: a,
    tickRotate: c,
    fontVariant: l,
    ariaLabel: u,
    ariaDescription: f,
    label: h,
    labelAnchor: d,
    labelArrow: p,
    labelOffset: y
  };
}
function Iq(e) {
  const { anchor: t, line: n } = e;
  return { anchor: t, facetAnchor: t + "-empty", stroke: n === !0 ? void 0 : n };
}
function $q(e, {
  stroke: t = sf(e) ? e : void 0,
  ticks: n = Aq(e) ? e : void 0,
  tickSpacing: i,
  ariaLabel: r,
  ariaDescription: s
}) {
  return {
    stroke: t,
    ticks: n,
    tickSpacing: i,
    ariaLabel: r,
    ariaDescription: s
  };
}
function Aq(e) {
  switch (typeof e) {
    case "number":
      return !0;
    case "string":
      return !sf(e);
  }
  return dr(e) || typeof (e == null ? void 0 : e.range) == "function";
}
function Zf(e, t) {
  const n = `${t}-axis `;
  return e.some((i) => {
    var r;
    return (r = i.ariaLabel) == null ? void 0 : r.startsWith(n);
  });
}
function mx(e, t) {
  for (const n of t)
    for (const i in n.channels) {
      const { scale: r } = n.channels[i];
      if (r === e || r === "projection")
        return !0;
    }
  return !1;
}
function Mq(e, t) {
  for (const n in e) {
    const i = e[n], r = t[n];
    i.label === void 0 && r && (i.label = r.label);
  }
  return e;
}
function Tq({ fx: e, fy: t }, n) {
  const { marginTop: i, marginRight: r, marginBottom: s, marginLeft: o, width: a, height: c } = Kb(n), l = e && gx(e), u = t && gx(t);
  return {
    marginTop: t ? u[0] : i,
    marginRight: e ? a - l[1] : r,
    marginBottom: t ? c - u[1] : s,
    marginLeft: e ? l[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 gx(e) {
  const t = e.domain();
  let n = e(t[0]), i = e(t[t.length - 1]);
  return i < n && ([n, i] = [i, n]), [n, i + e.bandwidth()];
}
const Bq = /* @__PURE__ */ new Map([
  ["basis", zP],
  ["basis-closed", PP],
  ["basis-open", VP],
  ["bundle", jP],
  ["bump-x", BP],
  ["bump-y", NP],
  ["cardinal", YP],
  ["cardinal-closed", qP],
  ["cardinal-open", WP],
  ["catmull-rom", GP],
  ["catmull-rom-closed", XP],
  ["catmull-rom-open", HP],
  ["linear", ef],
  ["linear-closed", KP],
  ["monotone-x", JP],
  ["monotone-y", ZP],
  ["natural", QP],
  ["step", tV],
  ["step-after", nV],
  ["step-before", eV]
]);
function y_(e = ef, t) {
  if (typeof e == "function")
    return e;
  const n = Bq.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 $T(e = Fc, t) {
  return typeof e != "function" && `${e}`.toLowerCase() === "auto" ? Fc : y_(e, t);
}
function Fc(e) {
  return ef(e);
}
function As(e = { y: "count" }, t = {}) {
  [e, t] = __(e, t);
  const { x: n, y: i } = t;
  return b_(lp(n, t, lt), null, null, i, e, uf(t));
}
function Ms(e = { x: "count" }, t = {}) {
  [e, t] = __(e, t);
  const { x: n, y: i } = t;
  return b_(null, lp(i, t, lt), n, null, e, ff(t));
}
function Mo(e = { fill: "count" }, t = {}) {
  [e, t] = __(e, t);
  const { x: n, y: i } = Nq(t);
  return b_(n, i, null, null, e, uf(ff(t)));
}
function AT(e, t, n = {}) {
  return (n == null ? void 0 : n.interval) == null ? n : e({ [t]: (n == null ? void 0 : n.reduce) === void 0 ? qb : n.reduce, filter: null }, n);
}
function m_(e = {}) {
  return AT(As, "y", Kc(e, "x"));
}
function g_(e = {}) {
  return AT(Ms, "x", Kc(e, "y"));
}
function b_(e, t, n, i, {
  data: r = Yb,
  // TODO avoid materializing when unused?
  filter: s = sp,
  // return only non-empty bins by default
  sort: o,
  reverse: a,
  ...c
  // output channel definitions
} = {}, l = {}) {
  e = bx(e), t = bx(t), c = Fq(c, l), r = NT(r, lt), o = o == null ? void 0 : TT("sort", o, l), s = s == null ? void 0 : BT("filter", s, l), n != null && Bs(c, "x", "x1", "x2") && (n = null), i != null && Bs(c, "y", "y1", "y2") && (i = null);
  const [u, f] = un(e), [h, d] = un(e), [p, y] = un(t), [g, m] = un(t), [b, _] = n != null ? [n, "x"] : i != null ? [i, "y"] : [], [w, v] = un(b), {
    x,
    y: I,
    z: T,
    fill: D,
    stroke: $,
    x1: A,
    x2: F,
    // consumed if x is an output
    y1: E,
    y2: S,
    // consumed if y is an output
    domain: M,
    cumulative: B,
    thresholds: N,
    interval: L,
    ...k
  } = l, [U, j] = un(T), [P] = _n(D), [K] = _n($), [Z, et] = un(P), [tt, H] = un(K);
  return {
    ..."z" in l && { z: U || T },
    ..."fill" in l && { fill: Z || D },
    ..."stroke" in l && { stroke: tt || $ },
    ...pr(k, (X, V, G) => {
      const J = rp(Lt(X, b), G == null ? void 0 : G[_]), z = Lt(X, T), nt = Lt(X, P), ut = Lt(X, K), Gt = jb(c, { z, fill: nt, stroke: ut }), Ot = [], Q = [], ee = J && v([]), Ei = z && j([]), An = nt && et([]), If = ut && H([]), $f = e && f([]), h0 = e && d([]), vw = t && y([]), iF = t && m([]), rF = Lq(e == null ? void 0 : e(X), t == null ? void 0 : t(X));
      let sF = 0;
      for (const sa of c)
        sa.initialize(X);
      o && o.initialize(X), s && s.initialize(X);
      for (const sa of V) {
        const xw = [];
        for (const cl of c)
          cl.scope("facet", sa);
        o && o.scope("facet", sa), s && s.scope("facet", sa);
        for (const [cl, oF] of Ka(sa, Gt))
          for (const [aF, cF] of Ka(oF, J))
            for (const [lo, uo] of rF(cF))
              if (!(s && !s.reduce(lo, uo))) {
                xw.push(sF++), Q.push(r.reduceIndex(lo, X, uo)), J && ee.push(aF), z && Ei.push(Gt === z ? cl : z[lo[0]]), nt && An.push(Gt === nt ? cl : nt[lo[0]]), ut && If.push(Gt === ut ? cl : ut[lo[0]]), $f && ($f.push(uo.x1), h0.push(uo.x2)), vw && (vw.push(uo.y1), iF.push(uo.y2));
                for (const lF of c)
                  lF.reduce(lo, uo);
                o && o.reduce(lo);
              }
        Ot.push(xw);
      }
      return V6(Ot, o, a), { data: Q, facets: Ot };
    }),
    ...!Bs(c, "x") && (u ? { x1: u, x2: h, x: ip(u, h) } : { x, x1: A, x2: F }),
    ...!Bs(c, "y") && (p ? { y1: p, y2: g, y: ip(p, g) } : { y: I, y1: E, y2: S }),
    ...w && { [_]: w },
    ...Object.fromEntries(c.map(({ name: X, output: V }) => [X, V]))
  };
}
function __({ cumulative: e, domain: t, thresholds: n, interval: i, ...r }, s) {
  return [r, { cumulative: e, domain: t, thresholds: n, interval: i, ...s }];
}
function lp(e, { cumulative: t, domain: n, thresholds: i, interval: r }, s) {
  return e = { ...rf(e) }, e.domain === void 0 && (e.domain = n), e.cumulative === void 0 && (e.cumulative = t), e.thresholds === void 0 && (e.thresholds = i), e.interval === void 0 && (e.interval = r), e.value === void 0 && (e.value = s), e.thresholds = MT(e.thresholds, e.interval), e;
}
function Nq(e) {
  let { x: t, y: n } = e;
  return t = lp(t, e), n = lp(n, e), [t.value, n.value] = Di(t.value, n.value), { x: t, y: n };
}
function bx(e) {
  if (e == null)
    return;
  const { value: t, cumulative: n, domain: i = He, thresholds: r } = e, s = (o) => {
    let a = Lt(o, t), c;
    if (vn(a) || Oq(r)) {
      a = he(a, B6, Float64Array);
      let [u, f] = typeof i == "function" ? i(a) : i, h = typeof r == "function" && !zl(r) ? r(a, u, f) : r;
      typeof h == "number" && (h = FA(u, f, h)), zl(h) && (i === He && (u = h.floor(u), f = h.offset(h.floor(f))), h = h.range(u, h.offset(f))), c = h;
    } else {
      a = pn(a);
      let [u, f] = typeof i == "function" ? i(a) : i, h = typeof r == "function" && !zl(r) ? r(a, u, f) : r;
      if (typeof h == "number")
        if (i === He) {
          let d = uu(u, f, h);
          if (isFinite(d))
            if (d > 0) {
              let p = Math.round(u / d), y = Math.round(f / d);
              p * d <= u || --p, y * d > f || ++y;
              let g = y - p + 1;
              h = new Float64Array(g);
              for (let m = 0; m < g; ++m)
                h[m] = (p + m) * d;
            } else if (d < 0) {
              d = -d;
              let p = Math.round(u * d), y = Math.round(f * d);
              p / d <= u || --p, y / d > f || ++y;
              let g = y - p + 1;
              h = new Float64Array(g);
              for (let m = 0; m < g; ++m)
                h[m] = (p + m) / d;
            } else
              h = [u];
          else
            h = [u];
        } else
          h = Us(u, f, h);
      else
        zl(h) && (i === He && (u = h.floor(u), f = h.offset(h.floor(f))), h = h.range(u, h.offset(f)));
      c = h;
    }
    const l = [];
    if (c.length === 1)
      l.push([c[0], c[0]]);
    else
      for (let u = 1; u < c.length; ++u)
        l.push([c[u - 1], c[u]]);
    return l.bin = (n < 0 ? Cq : n > 0 ? Rq : w_)(l, c, a), l;
  };
  return s.label = us(t), s;
}
function MT(e, t, n = _x) {
  if (e === void 0)
    return t === void 0 ? n : Hc(t);
  if (typeof e == "string") {
    switch (e.toLowerCase()) {
      case "freedman-diaconis":
        return gL;
      case "scott":
        return E3;
      case "sturges":
        return q1;
      case "auto":
        return _x;
    }
    return M6(e);
  }
  return e;
}
function Fq(e, t) {
  return zb(e, t, TT);
}
function TT(e, t, n) {
  return Pb(e, t, n, BT);
}
function BT(e, t, n) {
  return Vb(e, t, n, NT);
}
function NT(e, t) {
  return Vy(e, t, Dq);
}
function Dq(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return kq;
    case "x1":
      return zq;
    case "x2":
      return Pq;
    case "y":
      return Uq;
    case "y1":
      return Vq;
    case "y2":
      return jq;
  }
  throw new Error(`invalid bin reduce: ${e}`);
}
function _x(e, t, n) {
  return Math.min(200, E3(e, t, n));
}
function Oq(e) {
  return Eq(e) || dr(e) && vn(e);
}
function Eq(e) {
  return zl(e) && typeof e == "function" && e() instanceof Date;
}
function zl(e) {
  return typeof (e == null ? void 0 : e.range) == "function";
}
function Lq(e, t) {
  return e && t ? function* (n) {
    const i = e.bin(n);
    for (const [r, [s, o]] of e.entries()) {
      const a = t.bin(i[r]);
      for (const [c, [l, u]] of t.entries())
        yield [a[c], { x1: s, y1: l, x2: o, y2: u }];
    }
  } : e ? function* (n) {
    const i = e.bin(n);
    for (const [r, [s, o]] of e.entries())
      yield [i[r], { x1: s, x2: o }];
  } : function* (n) {
    const i = t.bin(n);
    for (const [r, [s, o]] of t.entries())
      yield [i[r], { y1: s, y2: o }];
  };
}
function w_(e, t, n) {
  return t = pn(t), (i) => {
    var s;
    const r = e.map(() => []);
    for (const o of i)
      (s = r[ny(t, n[o]) - 1]) == null || s.push(o);
    return r;
  };
}
function Rq(e, t, n) {
  const i = w_(e, t, n);
  return (r) => {
    const s = i(r);
    for (let o = 1, a = s.length; o < a; ++o) {
      const c = s[o - 1], l = s[o];
      for (const u of c)
        l.push(u);
    }
    return s;
  };
}
function Cq(e, t, n) {
  const i = w_(e, t, n);
  return (r) => {
    const s = i(r);
    for (let o = s.length - 2; o >= 0; --o) {
      const a = s[o + 1], c = s[o];
      for (const l of a)
        c.push(l);
    }
    return s;
  };
}
function FT(e, t) {
  const n = (+e + +t) / 2;
  return e instanceof Date ? new Date(n) : n;
}
const kq = {
  reduceIndex(e, t, { x1: n, x2: i }) {
    return FT(n, i);
  }
}, Uq = {
  reduceIndex(e, t, { y1: n, y2: i }) {
    return FT(n, i);
  }
}, zq = {
  reduceIndex(e, t, { x1: n }) {
    return n;
  }
}, Pq = {
  reduceIndex(e, t, { x2: n }) {
    return n;
  }
}, Vq = {
  reduceIndex(e, t, { y1: n }) {
    return n;
  }
}, jq = {
  reduceIndex(e, t, { y2: n }) {
    return n;
  }
};
function v_(e = {}) {
  return N6(e) ? e : { ...e, x: lt };
}
function x_(e = {}) {
  return F6(e) ? e : { ...e, y: lt };
}
function DT(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = tl(e));
  const { y1: n, y: i = n, x: r, ...s } = t, [o, a, c, l] = el(i, r, "y", "x", e, s);
  return { ...o, y1: n, y: a, x1: c, x2: l, x: ip(c, l) };
}
function Yq(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = tl(e));
  const { y1: n, y: i = n, x: r } = t, [s, o, a] = el(i, r, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function qq(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = tl(e));
  const { y1: n, y: i = n, x: r } = t, [s, o, , a] = el(i, r, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function OT(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = tl(e));
  const { x1: n, x: i = n, y: r, ...s } = t, [o, a, c, l] = el(i, r, "x", "y", e, s);
  return { ...o, x1: n, x: a, y1: c, y2: l, y: ip(c, l) };
}
function Wq(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = tl(e));
  const { x1: n, x: i = n, y: r } = t, [s, o, a] = el(i, r, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function Gq(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = tl(e));
  const { x1: n, x: i = n, y: r } = t, [s, o, , a] = el(i, r, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function S_({ x: e, x1: t, x2: n, ...i } = {}) {
  return i = Kc(i, "y"), t === void 0 && n === void 0 ? DT({ x: e, ...i }) : ([t, n] = D6(e, t, n), { ...i, x1: t, x2: n });
}
function I_({ y: e, y1: t, y2: n, ...i } = {}) {
  return i = Kc(i, "x"), t === void 0 && n === void 0 ? OT({ y: e, ...i }) : ([t, n] = D6(e, t, n), { ...i, y1: t, y2: n });
}
function tl(e) {
  const { offset: t, order: n, reverse: i, ...r } = e;
  return [{ offset: t, order: n, reverse: i }, r];
}
const Xq = { length: !0 };
function el(e, t = Ab, n, i, { offset: r, order: s, reverse: o }, a) {
  const c = no(a), [l, u] = un(e), [f, h] = Fn(t), [d, p] = Fn(t);
  return f.hint = d.hint = Xq, r = Hq(r), s = Zq(s, r, i), [
    pr(a, (y, g, m) => {
      const b = e == null ? void 0 : u(rp(Lt(y, e), m == null ? void 0 : m[n])), _ = Lt(y, t, Float64Array), w = Lt(y, c), v = s && s(y, b, _, w), x = y.length, I = h(new Float64Array(x)), T = p(new Float64Array(x)), D = [];
      for (const $ of g) {
        const A = b ? Array.from(as($, (F) => b[F]).values()) : [$];
        if (v)
          for (const F of A)
            F.sort(v);
        for (const F of A) {
          let E = 0, S = 0;
          o && F.reverse();
          for (const M of F) {
            const B = _[M];
            B < 0 ? E = T[M] = (I[M] = E) + B : B > 0 ? S = T[M] = (I[M] = S) + B : T[M] = I[M] = S;
          }
        }
        D.push(A);
      }
      return r && r(D, I, T, w), { data: y, facets: g };
    }),
    l,
    f,
    d
  ];
}
function Hq(e) {
  if (e != null) {
    if (typeof e == "function")
      return e;
    switch (`${e}`.toLowerCase()) {
      case "expand":
      case "normalize":
        return Kq;
      case "center":
      case "silhouette":
        return Jq;
      case "wiggle":
        return LT;
    }
    throw new Error(`unknown offset: ${e}`);
  }
}
function ET(e, t) {
  let n = 0, i = 0;
  for (const r of e) {
    const s = t[r];
    s < n && (n = s), s > i && (i = s);
  }
  return [n, i];
}
function Kq(e, t, n) {
  for (const i of e)
    for (const r of i) {
      const [s, o] = ET(r, n);
      for (const a of r) {
        const c = 1 / (o - s || 1);
        t[a] = c * (t[a] - s), n[a] = c * (n[a] - s);
      }
    }
}
function Jq(e, t, n) {
  for (const i of e) {
    for (const r of i) {
      const [s, o] = ET(r, n);
      for (const a of r) {
        const c = (o + s) / 2;
        t[a] -= c, n[a] -= c;
      }
    }
    RT(i, t, n);
  }
  CT(e, t, n);
}
function LT(e, t, n, i) {
  for (const r of e) {
    const s = new qo();
    let o = 0;
    for (const a of r) {
      let c = -1;
      const l = a.map((d) => Math.abs(n[d] - t[d])), u = a.map((d) => {
        c = i ? i[d] : ++c;
        const p = n[d] - t[d], y = s.has(c) ? p - s.get(c) : 0;
        return s.set(c, p), y;
      }), f = [0, ...cL(u)];
      for (const d of a)
        t[d] += o, n[d] += o;
      const h = or(l);
      h && (o -= or(l, (d, p) => (u[p] / 2 + f[p]) * d) / h);
    }
    RT(r, t, n);
  }
  CT(e, t, n);
}
function RT(e, t, n) {
  const i = ze(e, (r) => ze(r, (s) => t[s]));
  for (const r of e)
    for (const s of r)
      t[s] -= i, n[s] -= i;
}
function CT(e, t, n) {
  const i = e.length;
  if (i === 1)
    return;
  const r = e.map((a) => a.flat()), s = r.map((a) => (ze(a, (c) => t[c]) + Se(a, (c) => n[c])) / 2), o = ze(s);
  for (let a = 0; a < i; a++) {
    const c = o - s[a];
    for (const l of r[a])
      t[l] += c, n[l] += c;
  }
}
function Zq(e, t, n) {
  if (e === void 0 && t === LT)
    return wx(ii);
  if (e != null) {
    if (typeof e == "string") {
      const i = e.startsWith("-"), r = i ? ep : ii;
      switch ((i ? e.slice(1) : e).toLowerCase()) {
        case "value":
        case n:
          return Qq(r);
        case "z":
          return tW(r);
        case "sum":
          return eW(r);
        case "appearance":
          return nW(r);
        case "inside-out":
          return wx(r);
      }
      return vx(T6(e));
    }
    if (typeof e == "function")
      return (e.length === 1 ? vx : iW)(e);
    if (Array.isArray(e))
      return rW(e);
    throw new Error(`invalid order: ${e}`);
  }
}
function Qq(e) {
  return (t, n, i) => (r, s) => e(i[r], i[s]);
}
function tW(e) {
  return (t, n, i, r) => (s, o) => e(r[s], r[o]);
}
function eW(e) {
  return Qy(
    e,
    (t, n, i, r) => Y1(
      ls(t),
      (s) => or(s, (o) => i[o]),
      (s) => r[s]
    )
  );
}
function nW(e) {
  return Qy(
    e,
    (t, n, i, r) => Y1(
      ls(t),
      (s) => n[W1(s, (o) => i[o])],
      (s) => r[s]
    )
  );
}
function wx(e) {
  return Qy(e, (t, n, i, r) => {
    const s = ls(t), o = Y1(
      s,
      (f) => n[W1(f, (h) => i[h])],
      (f) => r[f]
    ), a = Wa(
      s,
      (f) => or(f, (h) => i[h]),
      (f) => r[f]
    ), c = [], l = [];
    let u = 0;
    for (const f of o)
      u < 0 ? (u += a.get(f), c.push(f)) : (u -= a.get(f), l.push(f));
    return l.reverse().concat(c);
  });
}
function vx(e) {
  return (t) => {
    const n = Lt(t, e);
    return (i, r) => ii(n[i], n[r]);
  };
}
function iW(e) {
  return (t) => (n, i) => e(t[n], t[i]);
}
function rW(e) {
  return Qy(ii, () => e);
}
function Qy(e, t) {
  return (n, i, r, s) => {
    if (!s)
      throw new Error("missing channel: z");
    const o = new qo(t(n, i, r, s).map((a, c) => [a, c]));
    return (a, c) => e(o.get(s[a]), o.get(s[c]));
  };
}
const sW = {
  ariaLabel: "area",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class t0 extends ce {
  constructor(t, n = {}) {
    const { x1: i, y1: r, x2: s, y2: o, z: a, curve: c, tension: l } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x" },
        y1: { value: r, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 },
        z: { value: no(n), optional: !0 }
      },
      n,
      sW
    ), this.z = a, this.curve = y_(c, l);
  }
  filter(t) {
    return t;
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: l = a } = i;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n, 0, 0).call(
      (u) => u.selectAll().data(g4(t, [o, a, c, l], this, i)).enter().append("path").call(pe, this).call(op, this, i).attr(
        "d",
        wb().curve(this.curve).defined((f) => f >= 0).x0((f) => o[f]).y0((f) => a[f]).x1((f) => c[f]).y1((f) => l[f])
      )
    ).node();
  }
}
function oW(e, t) {
  return t === void 0 ? Tu(e, { x: nf, y: xu }) : new t0(e, t);
}
function up(e, t) {
  const { y: n = In, ...i } = g_(t);
  return new t0(e, S_(v_({ ...i, y1: n, y2: void 0 })));
}
function Tu(e, t) {
  const { x: n = In, ...i } = m_(t);
  return new t0(e, I_(x_({ ...i, x1: n, x2: void 0 })));
}
const aW = {
  ariaLabel: "link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class kT extends ce {
  constructor(t, n = {}) {
    const { x1: i, y1: r, x2: s, y2: o, curve: a, tension: c } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x" },
        y1: { value: r, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      aW
    ), this.curve = $T(a, c), Jc(this, n);
  }
  project(t, n, i) {
    this.curve !== Fc && super.project(t, n, i);
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: l = a } = i, { curve: u } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (f) => f.selectAll().data(t).enter().append("path").call(pe, this).attr(
        "d",
        u === Fc && s.projection ? cW(s.projection, o, a, c, l) : (h) => {
          const d = zr(), p = u(d);
          return p.lineStart(), p.point(o[h], a[h]), p.point(c[h], l[h]), p.lineEnd(), d;
        }
      ).call(Le, this, i).call(lf, this, i, s)
    ).node();
  }
}
function cW(e, t, n, i, r) {
  const s = to(e);
  return t = pn(t), n = pn(n), i = pn(i), r = pn(r), (o) => s({
    type: "LineString",
    coordinates: [
      [t[o], n[o]],
      [i[o], r[o]]
    ]
  });
}
function UT(e, { x: t, x1: n, x2: i, y: r, y1: s, y2: o, ...a } = {}) {
  return [n, i] = fp(t, n, i), [s, o] = fp(r, s, o), new kT(e, { ...a, x1: n, x2: i, y1: s, y2: o });
}
function fp(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 lW = {
  ariaLabel: "arrow",
  fill: "none",
  stroke: "currentColor",
  strokeLinecap: "round",
  strokeMiterlimit: 1,
  strokeWidth: 1.5
};
class zT extends ce {
  constructor(t, n = {}) {
    const {
      x1: i,
      y1: r,
      x2: s,
      y2: o,
      bend: a = 0,
      headAngle: c = 60,
      headLength: l = 8,
      // Disable the arrow with headLength = 0; or, use Plot.link.
      inset: u = 0,
      insetStart: f = u,
      insetEnd: h = u
    } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x" },
        y1: { value: r, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      lW
    ), this.bend = a === !0 ? 22.5 : Math.max(-90, Math.min(90, a)), this.headAngle = +c, this.headLength = +l, this.insetStart = +f, this.insetEnd = +h;
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: l = a, SW: u } = i, { strokeWidth: f, bend: h, headAngle: d, headLength: p, insetStart: y, insetEnd: g } = this, m = u ? (v) => u[v] : Ln(f === void 0 ? 1 : f), b = h * cp, _ = d * cp / 2, w = p / 1.5;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (v) => v.selectAll().data(t).enter().append("path").call(pe, this).attr("d", (x) => {
        let I = o[x], T = a[x], D = c[x], $ = l[x];
        const A = Math.hypot(D - I, $ - T);
        if (A <= y + g)
          return null;
        let F = Math.atan2($ - T, D - I);
        const E = Math.min(w * m(x), A / 3), S = Math.hypot(A / Math.tan(b), A) / 2;
        if (y || g)
          if (S < 1e5) {
            const P = Math.sign(b), [K, Z] = uW([I, T], [D, $], S, P);
            if (y && ([I, T] = xx([K, Z, S], [I, T, y], -P * Math.sign(y))), g) {
              const [et, tt] = xx([K, Z, S], [D, $, g], P * Math.sign(g));
              F += Math.atan2(tt - Z, et - K) - Math.atan2($ - Z, D - K), D = et, $ = tt;
            }
          } else {
            const P = D - I, K = $ - T, Z = Math.hypot(P, K);
            y && (I += P / Z * y, T += K / Z * y), g && (D -= P / Z * g, $ -= K / Z * g);
          }
        const M = F + b, B = M + _, N = M - _, L = D - E * Math.cos(B), k = $ - E * Math.sin(B), U = D - E * Math.cos(N), j = $ - E * Math.sin(N);
        return `M${I},${T}${S < 1e5 ? `A${S},${S} 0,0,${b > 0 ? 1 : 0} ` : "L"}${D},${$}M${L},${k}L${D},${$}L${U},${j}`;
      }).call(Le, this, i)
    ).node();
  }
}
function uW([e, t], [n, i], r, s) {
  const o = n - e, a = i - t, c = Math.hypot(o, a), l = s * Math.sqrt(r * r - c * c / 4) / c;
  return [(e + n) / 2 - a * l, (t + i) / 2 + o * l];
}
function xx([e, t, n], [i, r, s], o) {
  const a = i - e, c = r - t, l = Math.hypot(a, c), u = (a * a + c * c - s * s + n * n) / (2 * l), f = o * Math.sqrt(n * n - u * u);
  return [e + (a * u + c * f) / l, t + (c * u - a * f) / l];
}
function fW(e, { x: t, x1: n, x2: i, y: r, y1: s, y2: o, ...a } = {}) {
  return [n, i] = fp(t, n, i), [s, o] = fp(r, s, o), new zT(e, { ...a, x1: n, x2: i, y1: s, y2: o });
}
class $_ extends ce {
  constructor(t, n, i = {}, r) {
    super(t, n, i, r);
    const { inset: s = 0, insetTop: o = s, insetRight: a = s, insetBottom: c = s, insetLeft: l = s, rx: u, ry: f } = i;
    this.insetTop = kt(o), this.insetRight = kt(a), this.insetBottom = kt(c), this.insetLeft = kt(l), this.rx = Ie(u, "auto"), this.ry = Ie(f, "auto");
  }
  render(t, n, i, r, s) {
    const { rx: o, ry: a } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(this._transform, this, n).call(
      (c) => c.selectAll().data(t).enter().append("rect").call(pe, this).attr("x", this._x(n, i, r)).attr("width", this._width(n, i, r)).attr("y", this._y(n, i, r)).attr("height", this._height(n, i, r)).call(ot, "rx", o).call(ot, "ry", a).call(Le, this, i)
    ).node();
  }
  _x(t, { x: n }, { marginLeft: i }) {
    const { insetLeft: r } = this;
    return n ? (s) => n[s] + r : i + r;
  }
  _y(t, { y: n }, { marginTop: i }) {
    const { insetTop: r } = this;
    return n ? (s) => n[s] + r : i + r;
  }
  _width({ x: t }, { x: n }, { marginRight: i, marginLeft: r, width: s }) {
    const { insetLeft: o, insetRight: a } = this, c = n && t ? t.bandwidth() : s - i - r;
    return Math.max(0, c - o - a);
  }
  _height({ y: t }, { y: n }, { marginTop: i, marginBottom: r, height: s }) {
    const { insetTop: o, insetBottom: a } = this, c = n && t ? t.bandwidth() : s - i - r;
    return Math.max(0, c - o - a);
  }
}
const PT = {
  ariaLabel: "bar"
};
class VT extends $_ {
  constructor(t, n = {}) {
    const { x1: i, x2: r, y: s } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x" },
        x2: { value: r, scale: "x" },
        y: { value: s, scale: "y", type: "band", optional: !0 }
      },
      n,
      PT
    );
  }
  _transform(t, n, { x: i }) {
    t.call(ae, n, { x: i }, 0, 0);
  }
  _x({ x: t }, { x1: n, x2: i }, { marginLeft: r }) {
    const { insetLeft: s } = this;
    return Zn(t) ? r + s : (o) => Math.min(n[o], i[o]) + s;
  }
  _width({ x: t }, { x1: n, x2: i }, { marginRight: r, marginLeft: s, width: o }) {
    const { insetLeft: a, insetRight: c } = this;
    return Zn(t) ? o - r - s - a - c : (l) => Math.max(0, Math.abs(i[l] - n[l]) - a - c);
  }
}
class jT extends $_ {
  constructor(t, n = {}) {
    const { x: i, y1: r, y2: s } = n;
    super(
      t,
      {
        y1: { value: r, scale: "y" },
        y2: { value: s, scale: "y" },
        x: { value: i, scale: "x", type: "band", optional: !0 }
      },
      n,
      PT
    );
  }
  _transform(t, n, { y: i }) {
    t.call(ae, n, { y: i }, 0, 0);
  }
  _y({ y: t }, { y1: n, y2: i }, { marginTop: r }) {
    const { insetTop: s } = this;
    return Zn(t) ? r + s : (o) => Math.min(n[o], i[o]) + s;
  }
  _height({ y: t }, { y1: n, y2: i }, { marginTop: r, marginBottom: s, height: o }) {
    const { insetTop: a, insetBottom: c } = this;
    return Zn(t) ? o - r - s - a - c : (l) => Math.max(0, Math.abs(i[l] - n[l]) - a - c);
  }
}
function Za(e, t = {}) {
  return Ey(t) || (t = { ...t, y: In, x2: lt }), new VT(e, S_(F4(v_(t))));
}
function Qa(e, t = {}) {
  return Ey(t) || (t = { ...t, x: In, y2: lt }), new jT(e, I_(D4(x_(t))));
}
const hW = {
  ariaLabel: "cell"
};
class e0 extends $_ {
  constructor(t, { x: n, y: i, ...r } = {}) {
    super(
      t,
      {
        x: { value: n, scale: "x", type: "band", optional: !0 },
        y: { value: i, scale: "y", type: "band", optional: !0 }
      },
      r,
      hW
    );
  }
  _transform(t, n) {
    t.call(ae, n, {}, 0, 0);
  }
}
function A_(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = Di(t, n), new e0(e, { ...i, x: t, y: n });
}
function dW(e, { x: t = In, fill: n, stroke: i, ...r } = {}) {
  return n === void 0 && _n(i)[0] === void 0 && (n = lt), new e0(e, { ...r, x: t, fill: n, stroke: i });
}
function pW(e, { y: t = In, fill: n, stroke: i, ...r } = {}) {
  return n === void 0 && _n(i)[0] === void 0 && (n = lt), new e0(e, { ...r, y: t, fill: n, stroke: i });
}
const yW = {
  ariaLabel: "dot",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5
};
function M_(e) {
  return e.sort === void 0 && e.reverse === void 0 ? z6({ channel: "-r" }, e) : e;
}
class n0 extends ce {
  constructor(t, n = {}) {
    const { x: i, y: r, r: s, rotate: o, symbol: a = vu, frameAnchor: c } = n, [l, u] = Te(o, 0), [f, h] = DV(a), [d, p] = Te(s, f == null ? 3 : 4.5);
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        r: { value: d, scale: "r", filter: Gr, optional: !0 },
        rotate: { value: l, optional: !0 },
        symbol: { value: f, scale: "auto", optional: !0 }
      },
      M_(n),
      yW
    ), this.r = p, this.rotate = u, this.symbol = h, this.frameAnchor = of(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, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, r: u, rotate: f, symbol: h } = i, { r: d, rotate: p, symbol: y } = this, [g, m] = yr(this, r), b = y === vu, _ = u ? void 0 : d * d * Math.PI;
    return Dy(d) && (t = []), Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      (w) => w.selectAll().data(t).enter().append(b ? "circle" : "path").call(pe, this).call(
        b ? (v) => {
          v.attr("cx", c ? (x) => c[x] : g).attr("cy", l ? (x) => l[x] : m).attr("r", u ? (x) => u[x] : d);
        } : (v) => {
          v.attr(
            "transform",
            Hy`translate(${c ? (x) => c[x] : g},${l ? (x) => l[x] : m})${f ? (x) => ` rotate(${f[x]})` : p ? ` rotate(${p})` : ""}`
          ).attr(
            "d",
            u && h ? (x) => {
              const I = zr();
              return h[x].draw(I, u[x] * u[x] * Math.PI), I;
            } : u ? (x) => {
              const I = zr();
              return y.draw(I, u[x] * u[x] * Math.PI), I;
            } : h ? (x) => {
              const I = zr();
              return h[x].draw(I, _), I;
            } : (() => {
              const x = zr();
              return y.draw(x, _), x;
            })()
          );
        }
      ).call(Le, this, i)
    ).node();
  }
}
function so(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = Di(t, n)), new n0(e, { ...i, x: t, y: n });
}
function mW(e, { x: t = lt, ...n } = {}) {
  return new n0(e, E4({ ...n, x: t }));
}
function gW(e, { y: t = lt, ...n } = {}) {
  return new n0(e, O4({ ...n, y: t }));
}
function bW(e, t) {
  return so(e, { ...t, symbol: "circle" });
}
function _W(e, t) {
  return so(e, { ...t, symbol: "hexagon" });
}
const wW = {
  ariaLabel: "line",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class i0 extends ce {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s, curve: o, tension: a } = n;
    super(
      t,
      {
        x: { value: i, scale: "x" },
        y: { value: r, scale: "y" },
        z: { value: no(n), optional: !0 }
      },
      n,
      wW
    ), this.z = s, this.curve = $T(o, a), Jc(this, n);
  }
  filter(t) {
    return t;
  }
  project(t, n, i) {
    this.curve !== Fc && super.project(t, n, i);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = i, { curve: c } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (l) => l.selectAll().data(g4(t, [o, a], this, i)).enter().append("path").call(pe, this).call(op, this, i).call(EY, this, i, s).attr(
        "d",
        c === Fc && s.projection ? vW(s.projection, o, a) : QM().curve(c).defined((u) => u >= 0).x((u) => o[u]).y((u) => a[u])
      )
    ).node();
  }
}
function vW(e, t, n) {
  const i = to(e);
  return t = pn(t), n = pn(n), (r) => {
    let s = [];
    const o = [s];
    for (const a of r)
      a === -1 ? (s = [], o.push(s)) : s.push([t[a], n[a]]);
    return i({ type: "MultiLineString", coordinates: o });
  };
}
function T_(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = Di(t, n), new i0(e, { ...i, x: t, y: n });
}
function hp(e, { x: t = lt, y: n = In, ...i } = {}) {
  return new i0(e, g_({ ...i, x: t, y: n }));
}
function dp(e, { x: t = In, y: n = lt, ...i } = {}) {
  return new i0(e, m_({ ...i, x: t, y: n }));
}
const xW = {
  ariaLabel: "rect"
};
class r0 extends ce {
  constructor(t, n = {}) {
    const {
      x1: i,
      y1: r,
      x2: s,
      y2: o,
      inset: a = 0,
      insetTop: c = a,
      insetRight: l = a,
      insetBottom: u = a,
      insetLeft: f = a,
      rx: h,
      ry: d
    } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x", optional: !0 },
        y1: { value: r, scale: "y", optional: !0 },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      xW
    ), this.insetTop = kt(c), this.insetRight = kt(l), this.insetBottom = kt(u), this.insetLeft = kt(f), this.rx = Ie(h, "auto"), this.ry = Ie(d, "auto");
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x1: c, y1: l, x2: u, y2: f } = i, { marginTop: h, marginRight: d, marginBottom: p, marginLeft: y, width: g, height: m } = r, { projection: b } = s, { insetTop: _, insetRight: w, insetBottom: v, insetLeft: x, rx: I, ry: T } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && u && o, y: l && f && a }, 0, 0).call(
      (D) => D.selectAll().data(t).enter().append("rect").call(pe, this).attr(
        "x",
        c && u && (b || !Zn(o)) ? ($) => Math.min(c[$], u[$]) + x : y + x
      ).attr(
        "y",
        l && f && (b || !Zn(a)) ? ($) => Math.min(l[$], f[$]) + _ : h + _
      ).attr(
        "width",
        c && u && (b || !Zn(o)) ? ($) => Math.max(0, Math.abs(u[$] - c[$]) - x - w) : g - d - y - w - x
      ).attr(
        "height",
        l && f && (b || !Zn(a)) ? ($) => Math.max(0, Math.abs(l[$] - f[$]) - _ - v) : m - h - p - _ - v
      ).call(ot, "rx", I).call(ot, "ry", T).call(Le, this, i)
    ).node();
  }
}
function B_(e, t) {
  return new r0(e, B4(N4(t)));
}
function Kl(e, t = {}) {
  return Ey(t) || (t = { ...t, y: In, x2: lt, interval: 1 }), new r0(e, S_(N4(v_(t))));
}
function Jl(e, t = {}) {
  return Ey(t) || (t = { ...t, x: In, y2: lt, interval: 1 }), new r0(e, I_(B4(x_(t))));
}
function YT(e, t) {
  t = IW(t);
  const { x: n, y: i, color: r, size: s } = t, o = Qf(e, n), a = Qf(e, i), c = Qf(e, r), l = Qf(e, s);
  let {
    fx: u,
    fy: f,
    x: { value: h, reduce: d, zero: p, ...y },
    y: { value: g, reduce: m, zero: b, ..._ },
    color: { value: w, color: v, reduce: x },
    size: { value: I, reduce: T },
    // TODO constant radius?
    mark: D
  } = t;
  if (d === void 0 && (d = m == null && h == null && I == null && g != null ? "count" : null), m === void 0 && (m = d == null && g == null && I == null && h != null ? "count" : null), T === void 0 && I == null && x == null && d == null && m == null && (h == null || Qe(o)) && (g == null || Qe(a)) && (T = "count"), p === void 0 && (p = th(d) ? !0 : void 0), b === void 0 && (b = th(m) ? !0 : void 0), h == null && g == null)
    throw new Error("must specify x or y");
  if (d != null && g == null)
    throw new Error("reducing x requires y");
  if (m != null && h == null)
    throw new Error("reducing y requires x");
  D === void 0 && (D = I != null || T != null ? "dot" : th(d) || th(m) || x != null ? "bar" : h != null && g != null ? Qe(o) || Qe(a) || d == null && m == null && !wl(o) && !wl(a) ? "dot" : "line" : h != null || g != null ? "rule" : null);
  let $, A, F;
  switch (D) {
    case "dot":
      F = so, A = "stroke";
      break;
    case "line":
      F = o && a || d != null || m != null ? b || m != null || o && wl(o) ? dp : p || d != null || a && wl(a) ? hp : T_ : o ? hp : dp, A = "stroke", Sx(c) && ($ = null);
      break;
    case "area":
      F = !(b || m != null) && (p || d != null || a && wl(a)) ? up : Tu, A = "fill", Sx(c) && ($ = null);
      break;
    case "rule":
      F = o ? js : Ys, A = "stroke";
      break;
    case "bar":
      F = b ? ma(d, o) ? Qa : Jl : p ? ma(m, a) ? Za : Kl : ma(d, o) && ma(m, a) ? A_ : ma(d, o) ? Qa : ma(m, a) ? Za : d != null ? Kl : m != null ? Jl : B_, A = "fill";
      break;
    default:
      throw new Error(`invalid mark: ${D}`);
  }
  let E = {
    fx: u,
    fy: f,
    x: o ?? void 0,
    // treat null x as undefined for implicit stack
    y: a ?? void 0,
    // treat null y as undefined for implicit stack
    [A]: c ?? v,
    z: $,
    r: l ?? void 0,
    // treat null size as undefined for default constant radius
    tip: !0
  }, S, M = { [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 ? (M.y = m, S = Qe(o) ? Iu : As) : d != null ? (M.x = d, S = Qe(a) ? $u : Ms) : (x != null || T != null) && (o && a ? S = Qe(o) && Qe(a) ? Ub : Qe(o) ? Ms : Qe(a) ? As : Mo : o ? S = Qe(o) ? Iu : As : a && (S = Qe(a) ? $u : Ms)), (S === Mo || S === As) && (E.x = { value: o, ...y }), (S === Mo || S === Ms) && (E.y = { value: a, ..._ }), p === void 0 && (p = o && !(S === Mo || S === As) && (F === Za || F === up || F === Kl || F === Ys)), b === void 0 && (b = a && !(S === Mo || S === Ms) && (F === Qa || F === Tu || F === Jl || F === js)), {
    fx: u ?? null,
    fy: f ?? null,
    x: {
      value: h ?? null,
      reduce: d ?? null,
      zero: !!p,
      ...y
    },
    y: {
      value: g ?? null,
      reduce: m ?? null,
      zero: !!b,
      ..._
    },
    color: {
      value: w ?? null,
      reduce: x ?? null,
      ...v !== void 0 && { color: v }
    },
    size: {
      value: I ?? null,
      reduce: T ?? null
    },
    mark: D,
    markImpl: Ix[F],
    markOptions: E,
    transformImpl: Ix[S],
    transformOptions: M,
    colorMode: A
  };
}
function SW(e, t) {
  const n = YT(e, t), {
    fx: i,
    fy: r,
    x: { zero: s },
    y: { zero: o },
    markOptions: a,
    transformOptions: c,
    colorMode: l
  } = n, u = zg[n.markImpl], f = zg[n.transformImpl], h = i != null || r != null ? h_({ strokeOpacity: 0.1 }) : null, d = [s ? js([0]) : null, o ? Ys([0]) : null], p = u(e, f ? f(c, a) : a);
  return l === "stroke" ? ns(h, d, p) : ns(h, p, d);
}
function wl(e) {
  let t, n;
  for (const i of e) {
    if (i == null)
      continue;
    if (t === void 0) {
      t = i;
      continue;
    }
    const r = Math.sign(Be(t, i));
    if (r) {
      if (n !== void 0 && r !== n)
        return !1;
      t = i, n = r;
    }
  }
  return !0;
}
function IW({ x: e, y: t, color: n, size: i, fx: r, fy: s, mark: o } = {}) {
  return Pi(e) || (e = ya(e)), Pi(t) || (t = ya(t)), Pi(n) || (n = sf(n) ? { color: n } : ya(n)), Pi(i) || (i = ya(i)), Pi(r) && ({ value: r } = ya(r)), Pi(s) && ({ value: s } = ya(s)), o != null && (o = `${o}`.toLowerCase()), { x: e, y: t, color: n, size: i, fx: r, fy: s, mark: o };
}
function Qf(e, t) {
  const n = Lt(e, t.value);
  return n && (n.label = us(t.value)), n;
}
function ya(e) {
  return AW(e) ? { reduce: e } : { value: e };
}
function th(e) {
  return /^(?:distinct|count|sum|proportion)$/i.test(e);
}
function $W(e) {
  return /^(?:first|last|mode)$/i.test(e);
}
function ma(e, t) {
  return e != null && !$W(e) || !t ? !1 : Qe(t);
}
function AW(e) {
  if (e == null)
    return !1;
  if (typeof e.reduceIndex == "function" || typeof e.reduce == "function" && Fi(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 Sx(e) {
  return e ? new sy(e).size > e.length >> 1 : !1;
}
const zg = {
  dot: so,
  line: T_,
  lineX: hp,
  lineY: dp,
  areaX: up,
  areaY: Tu,
  ruleX: js,
  ruleY: Ys,
  barX: Za,
  barY: Qa,
  rect: B_,
  rectX: Kl,
  rectY: Jl,
  cell: A_,
  bin: Mo,
  binX: As,
  binY: Ms,
  group: Ub,
  groupX: Iu,
  groupY: $u
}, Ix = Object.fromEntries(Object.entries(zg).map(([e, t]) => [t, e]));
function N_(e, t = {}) {
  let { x: n, x1: i, x2: r } = t;
  n === void 0 && i === void 0 && r === void 0 && (t = { ...t, x: n = lt });
  const s = {};
  return n != null && (s.x = e), i != null && (s.x1 = e), r != null && (s.x2 = e), hf(s, t);
}
function F_(e, t = {}) {
  let { y: n, y1: i, y2: r } = t;
  n === void 0 && i === void 0 && r === void 0 && (t = { ...t, y: n = lt });
  const s = {};
  return n != null && (s.y = e), i != null && (s.y1 = e), r != null && (s.y2 = e), hf(s, t);
}
function hf(e = {}, t = {}) {
  const n = no(t), i = Object.entries(e).map(([r, s]) => {
    const o = O6(r, t);
    if (o == null)
      throw new Error(`missing channel: ${r}`);
    const [a, c] = Fn(o);
    return { key: r, input: o, output: a, setOutput: c, map: MW(s) };
  });
  return {
    ...pr(t, (r, s) => {
      const o = Lt(r, n), a = i.map(({ input: l }) => Lt(r, l)), c = i.map(({ setOutput: l }) => l(new Array(r.length)));
      for (const l of s)
        for (const u of o ? as(l, (f) => o[f]).values() : [l])
          i.forEach(({ map: f }, h) => f.mapIndex(u, a[h], c[h]));
      return { data: r, facets: s };
    }),
    ...Object.fromEntries(i.map(({ key: r, output: s }) => [r, s]))
  };
}
function MW(e) {
  if (e == null)
    throw new Error("missing map");
  if (typeof e.mapIndex == "function")
    return e;
  if (typeof e.map == "function" && Fi(e))
    return TW(e);
  if (typeof e == "function")
    return dm(Bb(e));
  switch (`${e}`.toLowerCase()) {
    case "cumsum":
      return NW;
    case "rank":
      return dm((t, n) => C3(t, (i) => n[i]));
    case "quantile":
      return dm((t, n) => BW(t, (i) => n[i]));
  }
  throw new Error(`invalid map: ${e}`);
}
function TW(e) {
  return console.warn("deprecated map interface; implement mapIndex instead."), { mapIndex: e.map.bind(e) };
}
function BW(e, t) {
  const n = iy(e, t) - 1;
  return C3(e, t).map((i) => i / n);
}
function dm(e) {
  return {
    mapIndex(t, n, i) {
      const r = e(t, n);
      if (r.length !== t.length)
        throw new Error("map function returned a mismatched length");
      for (let s = 0, o = t.length; s < o; ++s)
        i[t[s]] = r[s];
    }
  };
}
const NW = {
  mapIndex(e, t, n) {
    let i = 0;
    for (const r of e)
      n[r] = i += t[r];
  }
}, FW = {
  ariaLabel: "tick",
  fill: null,
  stroke: "currentColor"
};
class qT extends ce {
  constructor(t, n, i) {
    super(t, n, i, FW), Jc(this, i);
  }
  render(t, n, i, r, s) {
    return Wt("svg:g", s).call(ye, this, r, s).call(this._transform, this, n).call(
      (o) => o.selectAll().data(t).enter().append("line").call(pe, this).attr("x1", this._x1(n, i, r)).attr("x2", this._x2(n, i, r)).attr("y1", this._y1(n, i, r)).attr("y2", this._y2(n, i, r)).call(Le, this, i).call(lf, this, i, s)
    ).node();
  }
}
class WT extends qT {
  constructor(t, n = {}) {
    const { x: i, y: r, inset: s = 0, insetTop: o = s, insetBottom: a = s } = n;
    super(
      t,
      {
        x: { value: i, scale: "x" },
        y: { value: r, scale: "y", type: "band", optional: !0 }
      },
      n
    ), this.insetTop = kt(o), this.insetBottom = kt(a);
  }
  _transform(t, n, { x: i }) {
    t.call(ae, n, { x: i }, Ye, 0);
  }
  _x1(t, { x: n }) {
    return (i) => n[i];
  }
  _x2(t, { x: n }) {
    return (i) => n[i];
  }
  _y1({ y: t }, { y: n }, { marginTop: i }) {
    const { insetTop: r } = this;
    return n && t ? (s) => n[s] + r : i + r;
  }
  _y2({ y: t }, { y: n }, { height: i, marginBottom: r }) {
    const { insetBottom: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : i - r - s;
  }
}
class GT extends qT {
  constructor(t, n = {}) {
    const { x: i, y: r, inset: s = 0, insetRight: o = s, insetLeft: a = s } = n;
    super(
      t,
      {
        y: { value: r, scale: "y" },
        x: { value: i, scale: "x", type: "band", optional: !0 }
      },
      n
    ), this.insetRight = kt(o), this.insetLeft = kt(a);
  }
  _transform(t, n, { y: i }) {
    t.call(ae, n, { y: i }, 0, Ye);
  }
  _x1({ x: t }, { x: n }, { marginLeft: i }) {
    const { insetLeft: r } = this;
    return n && t ? (s) => n[s] + r : i + r;
  }
  _x2({ x: t }, { x: n }, { width: i, marginRight: r }) {
    const { insetRight: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : i - r - s;
  }
  _y1(t, { y: n }) {
    return (i) => n[i];
  }
  _y2(t, { y: n }) {
    return (i) => n[i];
  }
}
function XT(e, { x: t = lt, ...n } = {}) {
  return new WT(e, { ...n, x: t });
}
function HT(e, { y: t = lt, ...n } = {}) {
  return new GT(e, { ...n, y: t });
}
function DW(e, {
  x: t = lt,
  y: n = null,
  fill: i = "#ccc",
  fillOpacity: r,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...l
} = {}) {
  const u = n != null ? $u : kb;
  return ns(
    Ys(e, u({ x1: D_, x2: O_ }, { x: t, y: n, stroke: s, strokeOpacity: o, ...l })),
    Za(e, u({ x1: "p25", x2: "p75" }, { x: t, y: n, fill: i, fillOpacity: r, ...l })),
    XT(e, u({ x: "p50" }, { x: t, y: n, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...l })),
    so(e, hf({ x: KT }, { x: t, y: n, z: n, stroke: s, strokeOpacity: o, ...l }))
  );
}
function OW(e, {
  y: t = lt,
  x: n = null,
  fill: i = "#ccc",
  fillOpacity: r,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...l
} = {}) {
  const u = n != null ? Iu : kb;
  return ns(
    js(e, u({ y1: D_, y2: O_ }, { x: n, y: t, stroke: s, strokeOpacity: o, ...l })),
    Qa(e, u({ y1: "p25", y2: "p75" }, { x: n, y: t, fill: i, fillOpacity: r, ...l })),
    HT(e, u({ y: "p50" }, { x: n, y: t, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...l })),
    so(e, hf({ y: KT }, { x: n, y: t, z: n, stroke: s, strokeOpacity: o, ...l }))
  );
}
function KT(e) {
  const t = D_(e), n = O_(e);
  return e.map((i) => i < t || i > n ? i : NaN);
}
function D_(e) {
  const t = JT(e) * 2.5 - ZT(e) * 1.5;
  return ze(e, (n) => n >= t ? n : NaN);
}
function O_(e) {
  const t = ZT(e) * 2.5 - JT(e) * 1.5;
  return Se(e, (n) => n <= t ? n : NaN);
}
function JT(e) {
  return zs(e, 0.25);
}
function ZT(e) {
  return zs(e, 0.75);
}
const EW = {
  ariaLabel: "raster",
  stroke: null,
  pixelSize: 1
};
function ga(e, t) {
  const n = +e;
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
function $x(e, t) {
  const n = Math.floor(e);
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
class QT extends ce {
  constructor(t, n, i = {}, r) {
    let {
      width: s,
      height: o,
      x: a,
      y: c,
      x1: l = a == null ? 0 : void 0,
      y1: u = c == null ? 0 : void 0,
      x2: f = a == null ? s : void 0,
      y2: h = c == null ? o : void 0,
      pixelSize: d = r.pixelSize,
      blur: p = 0,
      interpolate: y
    } = i;
    if (s != null && (s = $x(s, "width")), o != null && (o = $x(o, "height")), l != null && (l = ga(l, "x1")), u != null && (u = ga(u, "y1")), f != null && (f = ga(f, "x2")), h != null && (h = ga(h, "y2")), a == null && (l == null || f == null))
      throw new Error("missing x");
    if (c == null && (u == null || h == null))
      throw new Error("missing y");
    t != null && s != null && o != null && (a === void 0 && l != null && f != null && (a = zW(l, f, s)), c === void 0 && u != null && h != null && (c = PW(u, h, s, o))), super(
      t,
      {
        x: { value: a, scale: "x", optional: !0 },
        y: { value: c, scale: "y", optional: !0 },
        x1: { value: l == null ? null : [l], scale: "x", optional: !0, filter: null },
        y1: { value: u == null ? null : [u], scale: "y", optional: !0, filter: null },
        x2: { value: f == null ? null : [f], scale: "x", optional: !0, filter: null },
        y2: { value: h == null ? null : [h], scale: "y", optional: !0, filter: null },
        ...n
      },
      i,
      r
    ), this.width = s, this.height = o, this.pixelSize = ga(d, "pixelSize"), this.blur = ga(p, "blur"), this.interpolate = a == null || c == null ? null : RW(y);
  }
}
class t8 extends QT {
  constructor(t, n = {}) {
    const { imageRendering: i } = n;
    if (t == null) {
      const { fill: r, fillOpacity: s } = n;
      Te(s)[0] !== void 0 && (n = Pg("fillOpacity", n)), _n(r)[0] !== void 0 && (n = Pg("fill", n));
    }
    super(t, void 0, n, EW), this.imageRendering = Ie(i, "auto");
  }
  // Ignore the color scale, so the fill channel is returned unscaled.
  scale(t, { color: n, ...i }, r) {
    return super.scale(t, i, r);
  }
  render(t, n, i, r, s) {
    var M;
    const o = n[(M = i.channels.fill) == null ? void 0 : M.scale] ?? ((B) => B), { x: a, y: c } = i, { document: l } = s, [u, f, h, d] = n8(i, r, s), p = h - u, y = d - f, { pixelSize: g, width: m = Math.round(Math.abs(p) / g), height: b = Math.round(Math.abs(y) / g) } = this, _ = m * b;
    let { fill: w, fillOpacity: v } = i, x = 0;
    if (this.interpolate) {
      const B = m / p, N = b / y, L = he(a, (U) => (U - u) * B, Float64Array), k = he(c, (U) => (U - f) * N, Float64Array);
      w && (w = this.interpolate(t, m, b, L, k, w)), v && (v = this.interpolate(t, m, b, L, k, v));
    } else
      this.data == null && t && (x = t.fi * _);
    const I = l.createElement("canvas");
    I.width = m, I.height = b;
    const T = I.getContext("2d"), D = T.createImageData(m, b), $ = D.data;
    let { r: A, g: F, b: E } = ni(this.fill) ?? { r: 0, g: 0, b: 0 }, S = (this.fillOpacity ?? 1) * 255;
    for (let B = 0; B < _; ++B) {
      const N = B << 2;
      if (w) {
        const L = o(w[B + x]);
        if (L == null) {
          $[N + 3] = 0;
          continue;
        }
        ({ r: A, g: F, b: E } = ni(L));
      }
      v && (S = v[B + x] * 255), $[N + 0] = A, $[N + 1] = F, $[N + 2] = E, $[N + 3] = S;
    }
    return this.blur > 0 && tL(D, this.blur), T.putImageData(D, 0, 0), Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (B) => B.append("image").attr("transform", `translate(${u},${f}) scale(${Math.sign(h - u)},${Math.sign(d - f)})`).attr("width", Math.abs(p)).attr("height", Math.abs(y)).attr("preserveAspectRatio", "none").call(ot, "image-rendering", this.imageRendering).call(pe, this).attr("xlink:href", I.toDataURL())
    ).node();
  }
}
function e8(e, t, n) {
  arguments.length < 3 && (n = t, t = null);
  let { x: i, y: r, [e]: s, ...o } = n;
  return i === void 0 && r === void 0 && xV(t) && (i = nf, r = xu, s === void 0 && (s = bV)), [t, { ...o, x: i, y: r, [e]: s }];
}
function LW() {
  const [e, t] = e8("fill", ...arguments);
  return new t8(
    e,
    e == null || t.fill !== void 0 || t.fillOpacity !== void 0 ? t : { ...t, fill: lt }
  );
}
function n8({ x1: e, y1: t, x2: n, y2: i }, r, { projection: s }) {
  const { width: o, height: a, marginTop: c, marginRight: l, marginBottom: u, marginLeft: f } = r;
  return [
    e && s == null ? e[0] : f,
    t && s == null ? t[0] : c,
    n && s == null ? n[0] : o - l,
    i && s == null ? i[0] : a - u
  ];
}
function i8({ x1: e, y1: t, x2: n, y2: i }, r, s, o) {
  const a = {};
  return e && (a.x1 = e), t && (a.y1 = t), n && (a.x2 = n), i && (a.y2 = i), n8(Wb(a, r), s, o);
}
function Pg(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(i, r, s, o, a, c) {
    const { x: l, y: u } = o;
    if (!l)
      throw new Error("missing scale: x");
    if (!u)
      throw new Error("missing scale: y");
    const [f, h, d, p] = i8(s, o, a, c), y = d - f, g = p - h, { pixelSize: m } = this, { width: b = Math.round(Math.abs(y) / m), height: _ = Math.round(Math.abs(g) / m) } = t, w = new Array(b * _ * (r ? r.length : 1)), v = y / b, x = g / _;
    let I = 0;
    for (const T of r ?? [void 0])
      for (let D = 0.5; D < _; ++D)
        for (let $ = 0.5; $ < b; ++$, ++I)
          w[I] = n(l.invert(f + $ * v), u.invert(h + D * x), T);
    return { data: w, facets: r, channels: { [e]: { value: w, scale: "auto" } } };
  });
}
function RW(e) {
  if (typeof e == "function")
    return e;
  if (e == null)
    return Vg;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return Vg;
    case "nearest":
      return s8;
    case "barycentric":
      return r8();
    case "random-walk":
      return o8();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function Vg(e, t, n, i, r, s) {
  const o = new Array(t * n);
  for (const a of e)
    i[a] < 0 || i[a] >= t || r[a] < 0 || r[a] >= n || (o[Math.floor(r[a]) * t + Math.floor(i[a])] = s[a]);
  return o;
}
function r8({ random: e = db(42) } = {}) {
  return (t, n, i, r, s, o) => {
    const a = t.length, c = n >> 2, l = (i >> 2) - 1, u = a + c * 2 + l * 2, f = new Float64Array(u * 2);
    for (let _ = 0; _ < a; ++_)
      f[_ * 2] = r[t[_]], f[_ * 2 + 1] = s[t[_]];
    let h = a;
    const d = (_, w) => (f[h * 2] = _, f[h * 2 + 1] = w, h++);
    for (let _ = 0; _ <= c; ++_)
      d(_ / c * n, 0), d(_ / c * n, i);
    for (let _ = 0; _ < l; ++_)
      d(n, _ / l * i), d(0, _ / l * i);
    o = Ly(o, t);
    const p = new ts(f.subarray(0, a * 2));
    for (let _ = a, w; _ < u; ++_)
      o[_] = o[w = p.find(f[_ * 2], f[_ * 2 + 1], w)];
    const { points: y, triangles: g } = new ts(f), m = new o.constructor(n * i), b = UW(o, e);
    for (let _ = 0; _ < g.length; _ += 3) {
      const w = g[_], v = g[_ + 1], x = g[_ + 2], I = y[2 * w], T = y[2 * v], D = y[2 * x], $ = y[2 * w + 1], A = y[2 * v + 1], F = y[2 * x + 1], E = Math.min(I, T, D), S = Math.max(I, T, D), M = Math.min($, A, F), B = Math.max($, A, F), N = (A - F) * (I - D) + ($ - F) * (D - T);
      if (!N)
        continue;
      const L = o[w], k = o[v], U = o[x];
      for (let j = Math.floor(E); j < S; ++j)
        for (let P = Math.floor(M); P < B; ++P) {
          if (j < 0 || j >= n || P < 0 || P >= i)
            continue;
          const K = j + 0.5, Z = P + 0.5, et = ((A - F) * (K - D) + (Z - F) * (D - T)) / N;
          if (et < 0)
            continue;
          const tt = ((F - $) * (K - D) + (Z - F) * (I - D)) / N;
          if (tt < 0)
            continue;
          const H = 1 - et - tt;
          H < 0 || (m[j + n * P] = b(L, et, k, tt, U, H, j, P));
        }
    }
    return m;
  };
}
function s8(e, t, n, i, r, s) {
  const o = new s.constructor(t * n), a = ts.from(
    e,
    (u) => i[u],
    (u) => r[u]
  );
  let c, l;
  for (let u = 0.5, f = 0; u < n; ++u) {
    l = c;
    for (let h = 0.5; h < t; ++h, ++f)
      l = a.find(h, u, l), h === 0.5 && (c = l), o[f] = s[e[l]];
  }
  return o;
}
function o8({ random: e = db(42), minDistance: t = 0.5, maxSteps: n = 2 } = {}) {
  return (i, r, s, o, a, c) => {
    const l = new c.constructor(r * s), u = ts.from(
      i,
      (p) => o[p],
      (p) => a[p]
    );
    let f, h, d;
    for (let p = 0.5, y = 0; p < s; ++p) {
      h = f;
      for (let g = 0.5; g < r; ++g, ++y) {
        let m = g, b = p;
        d = h = u.find(m, b, h), g === 0.5 && (f = h);
        let _, w = 0;
        for (; (_ = Math.hypot(o[i[d]] - m, a[i[d]] - b)) > t && w < n; ) {
          const v = e(g, p, w) * 2 * Math.PI;
          m += Math.cos(v) * _, b += Math.sin(v) * _, d = u.find(m, b, d), ++w;
        }
        l[y] = c[i[d]];
      }
    }
    return l;
  };
}
function CW(e, t, n, i, r, s) {
  return t * e + i * n + s * r;
}
function kW(e) {
  return (t, n, i, r, s, o, a, c) => {
    const l = e(a, c);
    return l < n ? t : l < n + r ? i : s;
  };
}
function UW(e, t) {
  return R6(e) || vn(e) ? CW : kW(t);
}
function zW(e, t, n) {
  return {
    transform(i) {
      const r = i.length, s = new Float64Array(r), o = (t - e) / n, a = e + o / 2;
      for (let c = 0; c < r; ++c)
        s[c] = c % n * o + a;
      return s;
    }
  };
}
function PW(e, t, n, i) {
  return {
    transform(r) {
      const s = r.length, o = new Float64Array(s), a = (t - e) / i, c = e + a / 2;
      for (let l = 0; l < s; ++l)
        o[l] = Math.floor(l / n) % i * a + c;
      return o;
    }
  };
}
const Ax = {
  ariaLabel: "contour",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1,
  pixelSize: 2
};
class a8 extends QT {
  constructor(t, { smooth: n = !0, value: i, ...r } = {}) {
    const s = m4({}, r, Ax);
    if (i === void 0) {
      for (const a in s)
        if (s[a].value != null) {
          if (i !== void 0)
            throw new Error("ambiguous contour value");
          i = r[a], r[a] = "value";
        }
    }
    if (i != null) {
      const a = { transform: (c) => c.map((l) => l.value), label: us(i) };
      for (const c in s)
        r[c] === "value" && (r[c] = a);
    }
    if (t == null) {
      if (i == null)
        throw new Error("missing contour value");
      r = Pg("value", { value: i, ...r }), i = null;
    } else {
      let { interpolate: a } = r;
      i === void 0 && (i = lt), a === void 0 && (r.interpolate = "nearest");
    }
    super(t, { value: { value: i, optional: !0 } }, VW(r), Ax);
    const o = { geometry: { value: lt } };
    for (const a in this.channels) {
      const c = this.channels[a], { scale: l } = c;
      l === "x" || l === "y" || a === "value" || (o[a] = c, delete this.channels[a]);
    }
    this.contourChannels = o, this.smooth = !!n;
  }
  filter(t, { x: n, y: i, value: r, ...s }, o) {
    return super.filter(t, s, o);
  }
  render(t, n, i, r, s) {
    const { geometry: o } = i, a = to();
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call((c) => {
      c.selectAll().data(t).enter().append("path").call(pe, this).attr("d", (l) => a(o[l])).call(Le, this, i);
    }).node();
  }
}
function VW({ thresholds: e, interval: t, ...n }) {
  return e = MT(e, t, q1), Rn(n, function(i, r, s, o, a, c) {
    const [l, u, f, h] = i8(s, o, a, c), d = f - l, p = h - u, { pixelSize: y, width: g = Math.round(Math.abs(d) / y), height: m = Math.round(Math.abs(p) / y) } = this, b = g / d, _ = m / p, w = s.value.value, v = [];
    if (this.interpolate) {
      const { x: $, y: A } = Yy(s, o, c), F = he($, (B) => (B - l) * b, Float64Array), E = he(A, (B) => (B - u) * _, Float64Array), S = [s.x, s.y, s.value], M = [F, E, w];
      for (const B of r) {
        const N = this.filter(B, S, M);
        v.push(this.interpolate(N, g, m, F, E, w));
      }
    } else if (r) {
      const $ = g * m, A = r.length;
      for (let F = 0; F < A; ++F)
        v.push(w.slice(F * $, F * $ + $));
    } else
      v.push(w);
    if (this.blur > 0)
      for (const $ of v)
        A3({ data: $, width: g, height: m }, this.blur);
    const x = jW(e, w, ...qW(v));
    if (x === null)
      throw new Error(`unsupported thresholds: ${e}`);
    const { contour: I } = xd().size([g, m]).smooth(this.smooth), T = [], D = [];
    for (const $ of v)
      D.push(Bn(T.length, T.push(...he(x, (A) => I($, A)))));
    for (const { coordinates: $ } of T)
      for (const A of $)
        for (const F of A)
          for (const E of F)
            E[0] = E[0] / b + l, E[1] = E[1] / _ + u;
    return {
      data: T,
      facets: D,
      channels: j6(this.contourChannels, T)
    };
  });
}
function jW(e, t, n, i) {
  if (typeof (e == null ? void 0 : e.range) == "function")
    return e.range(e.floor(n), i);
  if (typeof e == "function" && (e = e(t, n, i)), typeof e != "number")
    return wn(e);
  const r = Us(...D3(n, i, e), e);
  for (; r[r.length - 1] >= i; )
    r.pop();
  for (; r[1] < n; )
    r.shift();
  return r;
}
function YW() {
  return new a8(...e8("value", ...arguments));
}
function qW(e) {
  return [ze(e, (t) => ze(t, Mx)), Se(e, (t) => Se(t, Mx))];
}
function Mx(e) {
  return isFinite(e) ? e : NaN;
}
function WW(e, t) {
  return E_(r_, e, t);
}
function GW(e, t = {}) {
  return E_(s_, e, t);
}
function XW(e, t = {}) {
  return E_(o_, e, t);
}
function E_(e, t, n = {}) {
  const { x: i, y: r, maxRadius: s } = n, o = e({ px: i, py: r, maxRadius: s }), a = [];
  i != null && a.push(js(t, Tx("x", { ...o, inset: -6 }, n))), r != null && a.push(Ys(t, Tx("y", { ...o, inset: -6 }, n))), i != null && a.push(Bc(t, Bx("x", { ...o, dy: 9, frameAnchor: "bottom", lineAnchor: "top" }, n))), r != null && a.push(Bc(t, Bx("y", { ...o, dx: -9, frameAnchor: "left", textAnchor: "end" }, n)));
  for (const c of a)
    c.ariaLabel = `crosshair ${c.ariaLabel}`;
  return ns(...a);
}
function c8(e, { channels: t, ...n }, { facet: i, facetAnchor: r, fx: s, fy: o, [e]: a, channels: c, transform: l, initializer: u }) {
  return {
    ...n,
    facet: i,
    facetAnchor: r,
    fx: s,
    fy: o,
    [e]: a,
    channels: { ...t, ...c },
    transform: l,
    initializer: HW(e, u)
  };
}
function HW(e, t) {
  return t == null ? t : function(n, i, { x: r, y: s, px: o, py: a, ...c }, ...l) {
    const { channels: { x: u, y: f, ...h } = {}, ...d } = t.call(this, n, i, { ...c, x: o, y: a }, ...l);
    return {
      channels: {
        ...h,
        ...u && { px: u, ...e === "x" && { x: u } },
        ...f && { py: f, ...e === "y" && { y: f } }
      },
      ...d
    };
  };
}
function Tx(e, t, n) {
  const {
    color: i = "currentColor",
    opacity: r = 0.2,
    ruleStroke: s = i,
    ruleStrokeOpacity: o = r,
    ruleStrokeWidth: a
  } = n;
  return {
    ...c8(e, t, n),
    stroke: s,
    strokeOpacity: o,
    strokeWidth: a
  };
}
function Bx(e, t, n) {
  const {
    color: i = "currentColor",
    textFill: r = i,
    textFillOpacity: s,
    textStroke: o = "white",
    textStrokeOpacity: a,
    textStrokeWidth: c = 5
  } = n;
  return {
    ...c8(e, t, KW(e, n)),
    fill: r,
    fillOpacity: s,
    stroke: o,
    strokeOpacity: a,
    strokeWidth: c
  };
}
function KW(e, t) {
  return Rn(t, (n, i, r) => {
    var s;
    return { channels: { text: { value: (s = G6(r, e)) == null ? void 0 : s.value } } };
  });
}
const JW = {
  ariaLabel: "delaunay link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, ZW = {
  ariaLabel: "delaunay mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
}, QW = {
  ariaLabel: "hull",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeMiterlimit: 1
}, tG = {
  ariaLabel: "voronoi",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, eG = {
  ariaLabel: "voronoi mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
};
class nG extends ce {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s, curve: o, tension: a } = n;
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        z: { value: s, optional: !0 }
      },
      n,
      JW
    ), this.curve = y_(o, a), Jc(this, n);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, z: u } = i, { curve: f } = this, [h, d] = yr(this, r), p = c ? (b) => c[b] : Ln(h), y = l ? (b) => l[b] : Ln(d), g = this;
    function m(b) {
      let _ = -1;
      const w = [], v = {};
      for (const S in i)
        v[S] = [];
      const x = [], I = [], T = [], D = [];
      function $(S, M) {
        S = b[S], M = b[M], w.push(++_), x[_] = p(S), T[_] = y(S), I[_] = p(M), D[_] = y(M);
        for (const B in i)
          v[B].push(i[B][M]);
      }
      const { halfedges: A, hull: F, triangles: E } = ts.from(b, p, y);
      for (let S = 0; S < A.length; ++S) {
        const M = A[S];
        M > S && $(E[S], E[M]);
      }
      for (let S = 0; S < F.length; ++S)
        $(F[S], F[(S + 1) % F.length]);
      re(this).selectAll().data(w).enter().append("path").call(pe, g).attr("d", (S) => {
        const M = zr(), B = f(M);
        return B.lineStart(), B.point(x[S], T[S]), B.point(I[S], D[S]), B.lineEnd(), M;
      }).call(Le, g, v).call(lf, g, v, s);
    }
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      u ? (b) => b.selectAll().data(as(t, (_) => u[_]).values()).enter().append("g").each(m) : (b) => b.datum(t).each(m)
    ).node();
  }
}
class L_ extends ce {
  constructor(t, n = {}, i, r = ({ z: s }) => s) {
    const { x: s, y: o } = n;
    super(
      t,
      {
        x: { value: s, scale: "x", optional: !0 },
        y: { value: o, scale: "y", optional: !0 },
        z: { value: r(n), optional: !0 }
      },
      n,
      i
    );
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, z: u } = i, [f, h] = yr(this, r), d = c ? (m) => c[m] : Ln(f), p = l ? (m) => l[m] : Ln(h), y = this;
    function g(m) {
      const b = ts.from(m, d, p);
      re(this).append("path").datum(m[0]).call(pe, y).attr("d", y._render(b, r)).call(Le, y, i);
    }
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      u ? (m) => m.selectAll().data(as(t, (b) => u[b]).values()).enter().append("g").each(g) : (m) => m.datum(t).each(g)
    ).node();
  }
}
class iG extends L_ {
  constructor(t, n = {}) {
    super(t, n, ZW), this.fill = "none";
  }
  _render(t) {
    return t.render();
  }
}
class rG extends L_ {
  constructor(t, n = {}) {
    super(t, n, QW, no);
  }
  _render(t) {
    return t.renderHull();
  }
}
class sG extends ce {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s } = n;
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        z: { value: s, optional: !0 }
      },
      n,
      tG
    );
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, z: u } = i, [f, h] = yr(this, r), d = c ? (m) => c[m] : Ln(f), p = l ? (m) => l[m] : Ln(h), y = this;
    function g(m) {
      const b = ts.from(m, d, p), _ = l8(b, r);
      re(this).selectAll().data(m).enter().append("path").call(pe, y).attr("d", (w, v) => _.renderCell(v)).call(Le, y, i);
    }
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      u ? (m) => m.selectAll().data(as(t, (b) => u[b]).values()).enter().append("g").each(g) : (m) => m.datum(t).each(g)
    ).node();
  }
}
class oG extends L_ {
  constructor(t, n) {
    super(t, n, eG), this.fill = "none";
  }
  _render(t, n) {
    return l8(t, n).render();
  }
}
function l8(e, t) {
  const { width: n, height: i, marginTop: r, marginRight: s, marginBottom: o, marginLeft: a } = t;
  return e.voronoi([a, r, n - s, i - o]);
}
function df(e, t, { x: n, y: i, ...r } = {}) {
  return [n, i] = Di(n, i), new e(t, { ...r, x: n, y: i });
}
function aG(e, t) {
  return df(nG, e, t);
}
function cG(e, t) {
  return df(iG, e, t);
}
function lG(e, t) {
  return df(rG, e, t);
}
function uG(e, t) {
  return df(sG, e, t);
}
function fG(e, t) {
  return df(oG, e, t);
}
const hG = {
  ariaLabel: "density",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class u8 extends ce {
  constructor(t, { x: n, y: i, z: r, weight: s, fill: o, stroke: a, ...c } = {}) {
    const l = Nx(o) && (o = "currentColor", !0), u = Nx(a) && (a = "currentColor", !0);
    super(
      t,
      {
        x: { value: n, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        z: { value: no({ z: r, fill: o, stroke: a }), optional: !0 },
        weight: { value: s, optional: !0 }
      },
      yG({ ...c, fill: o, stroke: a }, l, u),
      hG
    ), l && (this.fill = void 0), u && (this.stroke = void 0), this.z = r;
  }
  filter(t) {
    return t;
  }
  render(t, n, i, r, s) {
    const { contours: o } = i, a = to();
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, {}).call(
      (c) => c.selectAll().data(t).enter().append("path").call(pe, this).call(Le, this, i).attr("d", (l) => a(o[l]))
    ).node();
  }
}
function dG(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = Di(t, n), new u8(e, { ...i, x: t, y: n });
}
const pG = /* @__PURE__ */ new Set(["x", "y", "z", "weight"]);
function yG(e, t, n) {
  let { bandwidth: r, thresholds: s } = e;
  return r = r === void 0 ? 20 : +r, s = s === void 0 ? 20 : typeof (s == null ? void 0 : s[Symbol.iterator]) == "function" ? pn(s) : +s, Rn(e, function(o, a, c, l, u, f) {
    var E;
    const h = c.weight ? pn(c.weight.value) : null, d = (E = c.z) == null ? void 0 : E.value, { z: p } = this, [y, g] = yr(this, u), { width: m, height: b } = u, { x: _, y: w } = Yy(c, l, f), v = Object.fromEntries(
      Object.entries(c).filter(([S]) => !pG.has(S)).map(([S, M]) => [S, { ...M, value: [] }])
    ), x = t && [], I = n && [], T = Ok().x(_ ? (S) => _[S] : y).y(w ? (S) => w[S] : g).weight(h ? (S) => h[S] : 1).size([m, b]).bandwidth(r), D = [];
    for (const S of a) {
      const M = [];
      D.push(M);
      for (const B of d ? Qb(S, d, p) : [S]) {
        const N = T.contours(B);
        M.push([B, N]);
      }
    }
    let $ = s;
    if (!($ instanceof Mc)) {
      let S = 0;
      for (const M of D)
        for (const [, B] of M) {
          const N = B.max;
          N > S && (S = N);
        }
      $ = Float64Array.from({ length: s - 1 }, (M, B) => S * 100 * (B + 1) / s);
    }
    const A = [], F = [];
    for (const S of D) {
      const M = [];
      A.push(M);
      for (const [B, N] of S)
        for (const L of $) {
          M.push(F.length), F.push(N(L / 100)), x && x.push(L), I && I.push(L);
          for (const k in v)
            v[k].value.push(c[k].value[B[0]]);
        }
    }
    return x && x.push(0), I && I.push(0), {
      data: o,
      facets: A,
      channels: {
        ...v,
        ...x && { fill: { value: x, scale: "color" } },
        ...I && { stroke: { value: I, scale: "color" } },
        contours: { value: F }
      }
    };
  });
}
function Nx(e) {
  return /^density$/i.test(e);
}
const mG = {
  ariaLabel: "geo",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class f8 extends ce {
  constructor(t, n = {}) {
    const [i, r] = Te(n.r, 3);
    super(
      t,
      {
        geometry: { value: n.geometry, scale: "projection" },
        r: { value: i, scale: "r", filter: Gr, optional: !0 }
      },
      M_(n),
      mG
    ), this.r = r;
  }
  render(t, n, i, r, s) {
    const { geometry: o, r: a } = i, c = to(s.projection ?? gG(n)), { r: l } = this;
    return Dy(l) ? t = [] : l !== void 0 && c.pointRadius(l), Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call((u) => {
      u.selectAll().data(t).enter().append("path").call(pe, this).attr("d", a ? (f) => c.pointRadius(a[f])(o[f]) : (f) => c(o[f])).call(Le, this, i);
    }).node();
  }
}
function gG({ x: e, y: t }) {
  if (e || t)
    return e ?? (e = (n) => n), t ?? (t = (n) => n), jd({
      point(n, i) {
        this.stream.point(e(n), t(i));
      }
    });
}
function R_(e, { geometry: t = lt, ...n } = {}) {
  switch (e == null ? void 0 : e.type) {
    case "FeatureCollection":
      e = e.features;
      break;
    case "GeometryCollection":
      e = e.geometries;
      break;
    case "Feature":
    case "LineString":
    case "MultiLineString":
    case "MultiPoint":
    case "MultiPolygon":
    case "Point":
    case "Polygon":
    case "Sphere":
      e = [e];
      break;
  }
  return new f8(e, { geometry: t, ...n });
}
function bG({ strokeWidth: e = 1.5, ...t } = {}) {
  return R_({ type: "Sphere" }, { strokeWidth: e, ...t });
}
function _G({ strokeOpacity: e = 0.1, ...t } = {}) {
  return R_(T9(), { strokeOpacity: e, ...t });
}
const Zl = 0.5, Ql = 0;
function wG(e = { fill: "count" }, { binWidth: t, ...n } = {}) {
  const { z: i } = n;
  return t = t === void 0 ? 20 : kt(t), e = zb(e, n), Bs(e, "fill") && (n.channels = { ...n.channels, fill: { value: [] } }), n.symbol === void 0 && (n.symbol = "hexagon"), n.r === void 0 && !Bs(e, "r") && (n.r = t / 2), Rn(n, (r, s, o, a, c, l) => {
    let { x: u, y: f, z: h, fill: d, stroke: p, symbol: y } = o;
    if (u === void 0)
      throw new Error("missing channel: x");
    if (f === void 0)
      throw new Error("missing channel: y");
    ({ x: u, y: f } = Yy(o, a, l)), h = h ? h.value : Lt(r, i), d = d == null ? void 0 : d.value, p = p == null ? void 0 : p.value, y = y == null ? void 0 : y.value;
    const g = jb(e, { z: h, fill: d, stroke: p, symbol: y }), m = h && [], b = d && [], _ = p && [], w = y && [], v = [], x = [], I = [];
    let T = -1;
    for (const F of e)
      F.initialize(r);
    for (const F of s) {
      const E = [];
      for (const S of e)
        S.scope("facet", F);
      for (const [S, M] of Ka(F, g))
        for (const B of vG(M, u, f, t)) {
          E.push(++T), x.push(B.x), I.push(B.y), h && m.push(g === h ? S : h[B[0]]), d && b.push(g === d ? S : d[B[0]]), p && _.push(g === p ? S : p[B[0]]), y && w.push(g === y ? S : y[B[0]]);
          for (const N of e)
            N.reduce(B);
        }
      v.push(E);
    }
    const D = o.x.scale, $ = o.y.scale, A = {
      x: { value: x, source: a[D] ? { value: he(x, a[D].invert), scale: D } : null },
      y: { value: I, source: a[$] ? { value: he(I, a[$].invert), scale: $ } : null },
      ...h && { z: { value: m } },
      ...d && { fill: { value: b, scale: "auto" } },
      ...p && { stroke: { value: _, scale: "auto" } },
      ...y && { symbol: { value: w, scale: "auto" } },
      ...Object.fromEntries(
        e.map(({ name: F, output: E }) => [
          F,
          {
            scale: "auto",
            label: E.label,
            radius: F === "r" ? t / 2 : void 0,
            value: E.transform()
          }
        ])
      )
    };
    return { data: r, facets: v, channels: A };
  });
}
function vG(e, t, n, i) {
  const r = i * (1.5 / k6), s = /* @__PURE__ */ new Map();
  for (const o of e) {
    let a = t[o], c = n[o];
    if (isNaN(a) || isNaN(c))
      continue;
    let l = Math.round(c = (c - Ql) / r), u = Math.round(a = (a - Zl) / i - (l & 1) / 2), f = c - l;
    if (Math.abs(f) * 3 > 1) {
      let p = a - u, y = u + (a < u ? -1 : 1) / 2, g = l + (c < l ? -1 : 1), m = a - y, b = c - g;
      p * p + f * f > m * m + b * b && (u = y + (l & 1 ? 1 : -1) / 2, l = g);
    }
    const h = `${u},${l}`;
    let d = s.get(h);
    d === void 0 && (s.set(h, d = []), d.x = (u + (l & 1) / 2) * i + Zl, d.y = l * r + Ql), d.push(o);
  }
  return s.values();
}
const xG = {
  ariaLabel: "hexgrid",
  fill: "none",
  stroke: "currentColor",
  strokeOpacity: 0.1
};
function SG(e) {
  return new h8(e);
}
class h8 extends ce {
  constructor({ binWidth: t = 20, clip: n = !0, ...i } = {}) {
    super(Hl, void 0, { clip: n, ...i }, xG), this.binWidth = kt(t);
  }
  render(t, n, i, r, s) {
    const { binWidth: o } = this, { marginTop: a, marginRight: c, marginBottom: l, marginLeft: u, width: f, height: h } = r, d = u - Zl, p = f - c - Zl, y = a - Ql, g = h - l - Ql, m = o / 2, b = m * U6, _ = b / 2, w = m * 2, v = b * 1.5, x = Math.floor(d / w), I = Math.ceil(p / w), T = Math.floor((y + _) / v), D = Math.ceil((g - _) / v) + 1, $ = `m0,${ys(-b)}l${ys(m)},${ys(_)}v${ys(b)}l${ys(-m)},${ys(_)}`;
    let A = $;
    for (let F = T; F < D; ++F)
      for (let E = x; E < I; ++E)
        A += `M${ys(E * w + (F & 1) * m)},${ys(F * v)}${$}`;
    return Wt("svg:g", s).datum(0).call(ye, this, r, s).call(ae, this, {}, Ye + Zl, Ye + Ql).call((F) => F.append("path").call(pe, this).call(Le, this, i).attr("d", A)).node();
  }
}
function ys(e) {
  return Math.round(e * 1e3) / 1e3;
}
const IG = {
  ariaLabel: "image",
  fill: null,
  stroke: null
};
function $G(e) {
  return /^\.*\//.test(e);
}
function AG(e) {
  return /^(blob|data|file|http|https):/i.test(e);
}
function MG(e) {
  return typeof e == "string" && ($G(e) || AG(e)) ? [void 0, e] : [e, void 0];
}
class d8 extends ce {
  constructor(t, n = {}) {
    let { x: i, y: r, r: s, width: o, height: a, rotate: c, src: l, preserveAspectRatio: u, crossOrigin: f, frameAnchor: h, imageRendering: d } = n;
    s == null && (s = void 0), s === void 0 && o === void 0 && a === void 0 ? o = a = 16 : o === void 0 && a !== void 0 ? o = a : a === void 0 && o !== void 0 && (a = o);
    const [p, y] = MG(l), [g, m] = Te(s), [b, _] = Te(o, m !== void 0 ? m * 2 : void 0), [w, v] = Te(a, m !== void 0 ? m * 2 : void 0), [x, I] = Te(c, 0);
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        r: { value: g, scale: "r", filter: Gr, optional: !0 },
        width: { value: b, filter: Gr, optional: !0 },
        height: { value: w, filter: Gr, optional: !0 },
        rotate: { value: x, optional: !0 },
        src: { value: p, optional: !0 }
      },
      M_(n),
      IG
    ), this.src = y, this.width = _, this.rotate = I, this.height = v, this.r = m, this.preserveAspectRatio = Ie(u, "xMidYMid"), this.crossOrigin = je(f), this.frameAnchor = of(h), this.imageRendering = Ie(d, "auto");
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, width: u, height: f, r: h, rotate: d, src: p } = i, { r: y, width: g, height: m, rotate: b } = this, [_, w] = yr(this, r);
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      (v) => v.selectAll().data(t).enter().append("image").call(pe, this).attr("x", Fx(c, u, h, _, g, y)).attr("y", Fx(l, f, h, w, m, y)).attr("width", u ? (x) => u[x] : g !== void 0 ? g : h ? (x) => h[x] * 2 : y * 2).attr("height", f ? (x) => f[x] : m !== void 0 ? m : h ? (x) => h[x] * 2 : y * 2).attr("transform", d ? (x) => `rotate(${d[x]})` : b ? `rotate(${b})` : null).attr("transform-origin", d || b ? Hy`${c ? (x) => c[x] : _}px ${l ? (x) => l[x] : w}px` : null).call(ot, "href", p ? (x) => p[x] : this.src).call(ot, "preserveAspectRatio", this.preserveAspectRatio).call(ot, "crossorigin", this.crossOrigin).call(ot, "image-rendering", this.imageRendering).call(ot, "clip-path", h ? (x) => `circle(${h[x]}px)` : y !== void 0 ? `circle(${y}px)` : null).call(Le, this, i)
    ).node();
  }
}
function Fx(e, t, n, i, r, s) {
  return t && e ? (o) => e[o] - t[o] / 2 : t ? (o) => i - t[o] / 2 : e && r !== void 0 ? (o) => e[o] - r / 2 : r !== void 0 ? i - r / 2 : n && e ? (o) => e[o] - n[o] : n ? (o) => i - n[o] : e ? (o) => e[o] - s : i - s;
}
function TG(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = Di(t, n)), new d8(e, { ...i, x: t, y: n });
}
function BG(e, t, n) {
  var i = 1e-8, r = t - 1, s = n - 1, o = 0, a, c, l, u, f, h, d, p, y, g, m;
  if (e <= 0)
    return 0;
  if (e >= 1)
    return 1;
  for (t >= 1 && n >= 1 ? (l = e < 0.5 ? e : 1 - e, u = Math.sqrt(-2 * Math.log(l)), d = (2.30753 + u * 0.27061) / (1 + u * (0.99229 + u * 0.04481)) - u, 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)), u = Math.exp(t * a) / t, f = Math.exp(n * c) / n, g = u + f, e < u / g ? d = Math.pow(t * g * e, 1 / t) : d = 1 - Math.pow(n * g * (1 - e), 1 / n)), m = -tc(t) - tc(n) + tc(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = NG(d, t, n) - e, u = Math.exp(r * Math.log(d) + s * Math.log(1 - d) + m), f = h / u, d -= u = f / (1 - 0.5 * Math.min(1, f * (r / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + u)), d >= 1 && (d = 0.5 * (d + u + 1)), Math.abs(u) < i * d && o > 0)
      break;
  }
  return d;
}
function NG(e, t, n) {
  var i = e === 0 || e === 1 ? 0 : Math.exp(tc(t + n) - tc(t) - tc(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? i * Dx(e, t, n) / t : 1 - i * Dx(1 - e, n, t) / n;
}
function Dx(e, t, n) {
  var i = 1e-30, r = 1, s = t + n, o = t + 1, a = t - 1, c = 1, l = 1 - s * e / o, u, f, h, d;
  for (Math.abs(l) < i && (l = i), l = 1 / l, d = l; r <= 100 && (u = 2 * r, f = r * (n - r) * e / ((a + u) * (t + u)), l = 1 + f * l, Math.abs(l) < i && (l = i), c = 1 + f / c, Math.abs(c) < i && (c = i), l = 1 / l, d *= l * c, f = -(t + r) * (s + r) * e / ((t + u) * (o + u)), l = 1 + f * l, Math.abs(l) < i && (l = i), c = 1 + f / c, Math.abs(c) < i && (c = i), l = 1 / l, h = l * c, d *= h, !(Math.abs(h - 1) < 3e-7)); r++)
    ;
  return d;
}
function tc(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], i = 1.000000000190015, r, s, o;
  for (o = (s = r = e) + 5.5, o -= (r + 0.5) * Math.log(o); t < 6; t++)
    i += n[t] / ++s;
  return Math.log(2.506628274631 * i / r) - o;
}
function FG(e, t) {
  var n = BG(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 DG = {
  ariaLabel: "linear-regression",
  fill: "currentColor",
  fillOpacity: 0.1,
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class p8 extends ce {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s, ci: o = 0.95, precision: a = 4 } = n;
    if (super(
      t,
      {
        x: { value: i, scale: "x" },
        y: { value: r, scale: "y" },
        z: { value: no(n), optional: !0 }
      },
      n,
      DG
    ), this.z = s, this.ci = +o, this.precision = +a, !(0 <= this.ci && this.ci < 1))
      throw new Error(`invalid ci; not in [0, 1): ${o}`);
    if (!(this.precision > 0))
      throw new Error(`invalid precision: ${a}`);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a, z: c } = i, { ci: l } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (u) => u.selectAll().data(c ? Qb(t, c, this.z) : [t]).enter().call(
        (f) => f.append("path").attr("fill", "none").call(pe, this).call(op, this, { ...i, fill: null, fillOpacity: null }).attr("d", (h) => this._renderLine(h, o, a)).call(
          l && !Tc(this.fill) ? (h) => h.select(OG).attr("stroke", "none").call(pe, this).call(op, this, {
            ...i,
            stroke: null,
            strokeOpacity: null,
            strokeWidth: null
          }).attr("d", (d) => this._renderBand(d, o, a)) : () => {
          }
        )
      )
    ).node();
  }
}
function OG() {
  return this.parentNode.insertBefore(this.ownerDocument.createElementNS(Wo.svg, "path"), this);
}
class EG extends p8 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, i) {
    const { ci: r, precision: s } = this, [o, a] = He(t, (u) => i[u]), c = pp(t, i, n), l = y8(t, i, n, (1 - r) / 2, c);
    return wb().y((u) => u).x0((u) => l(u, -1)).x1((u) => l(u, 1))(Bn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, i) {
    const [r, s] = He(t, (a) => i[a]), o = pp(t, i, n);
    return `M${o(r)},${r}L${o(s)},${s}`;
  }
}
class LG extends p8 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, i) {
    const { ci: r, precision: s } = this, [o, a] = He(t, (u) => n[u]), c = pp(t, n, i), l = y8(t, n, i, (1 - r) / 2, c);
    return wb().x((u) => u).y0((u) => l(u, -1)).y1((u) => l(u, 1))(Bn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, i) {
    const [r, s] = He(t, (a) => n[a]), o = pp(t, n, i);
    return `M${r},${o(r)}L${s},${o(s)}`;
  }
}
function RG(e, { y: t = In, x: n = lt, stroke: i, fill: r = ke(i) ? "currentColor" : i, ...s } = {}) {
  return new EG(e, g_({ ...s, x: n, y: t, fill: r, stroke: i }));
}
function CG(e, { x: t = In, y: n = lt, stroke: i, fill: r = ke(i) ? "currentColor" : i, ...s } = {}) {
  return new LG(e, m_({ ...s, x: t, y: n, fill: r, stroke: i }));
}
function pp(e, t, n) {
  let i = 0, r = 0, s = 0, o = 0;
  for (const u of e) {
    const f = t[u], h = n[u];
    i += f, r += h, s += f * h, o += f * f;
  }
  const a = e.length, c = (a * s - i * r) / (a * o - i * i), l = (r - c * i) / a;
  return (u) => c * u + l;
}
function y8(e, t, n, i, r) {
  const s = or(e, (u) => t[u]) / e.length;
  let o = 0, a = 0;
  for (const u of e)
    o += (t[u] - s) ** 2, a += (n[u] - r(t[u])) ** 2;
  const c = Math.sqrt(a / (e.length - 2)), l = FG(i, e.length - 2);
  return (u, f) => {
    const h = r(u), d = c * Math.sqrt(1 / e.length + (u - s) ** 2 / o);
    return h + f * l * d;
  };
}
function jg({
  path: e = lt,
  // the delimited path
  delimiter: t,
  // how the path is separated
  frameAnchor: n,
  treeLayout: i = lA,
  treeSort: r,
  treeSeparation: s,
  treeAnchor: o,
  ...a
} = {}) {
  o = C_(o), r = g8(r), n === void 0 && (n = o.frameAnchor);
  const c = b8(t), l = I8(a, w8), [u, f] = Fn(), [h, d] = Fn();
  return {
    x: u,
    y: h,
    frameAnchor: n,
    ...pr(a, (p, y) => {
      const g = c(Lt(p, e)), m = f([]), b = d([]);
      let _ = -1;
      const w = [], v = [], x = cA().path((T) => g[T]), I = i();
      I.nodeSize && I.nodeSize([1, 1]), I.separation && s !== void 0 && I.separation(s ?? Ab);
      for (const T of l)
        T[yp] = T[x8]([]);
      for (const T of y) {
        const D = [], $ = x(T.filter((A) => g[A] != null)).each((A) => A.data = p[A.data]);
        r != null && $.sort(r), I($);
        for (const A of $.descendants()) {
          D.push(++_), w[_] = A.data, o.position(A, _, m, b);
          for (const F of l)
            F[yp][_] = F[S8](A);
        }
        v.push(D);
      }
      return { data: w, facets: v };
    }),
    ...Object.fromEntries(l)
  };
}
function m8({
  path: e = lt,
  // the delimited path
  delimiter: t,
  // how the path is separated
  curve: n = "bump-x",
  stroke: i = "#555",
  strokeWidth: r = 1.5,
  strokeOpacity: s = 0.5,
  treeLayout: o = lA,
  treeSort: a,
  treeSeparation: c,
  treeAnchor: l,
  ...u
} = {}) {
  l = C_(l), a = g8(a), u = { curve: n, stroke: i, strokeWidth: r, strokeOpacity: s, ...u };
  const f = b8(t), h = I8(u, YG), [d, p] = Fn(), [y, g] = Fn(), [m, b] = Fn(), [_, w] = Fn();
  return {
    x1: d,
    x2: y,
    y1: m,
    y2: _,
    ...pr(u, (v, x) => {
      const I = f(Lt(v, e)), T = p([]), D = g([]), $ = b([]), A = w([]);
      let F = -1;
      const E = [], S = [], M = cA().path((N) => I[N]), B = o();
      B.nodeSize && B.nodeSize([1, 1]), B.separation && c !== void 0 && B.separation(c ?? Ab);
      for (const N of h)
        N[yp] = N[x8]([]);
      for (const N of x) {
        const L = [], k = M(N.filter((U) => I[U] != null)).each((U) => U.data = v[U.data]);
        a != null && k.sort(a), B(k);
        for (const { source: U, target: j } of k.links()) {
          L.push(++F), E[F] = j.data, l.position(U, F, T, $), l.position(j, F, D, A);
          for (const P of h)
            P[yp][F] = P[S8](j, U);
        }
        S.push(L);
      }
      return { data: E, facets: S };
    }),
    ...Object.fromEntries(h)
  };
}
function C_(e = "left") {
  switch (`${e}`.trim().toLowerCase()) {
    case "left":
      return kG;
    case "right":
      return UG;
  }
  throw new Error(`invalid tree anchor: ${e}`);
}
const kG = {
  frameAnchor: "left",
  dx: 6,
  position({ x: e, y: t }, n, i, r) {
    i[n] = t, r[n] = -e;
  }
}, UG = {
  frameAnchor: "right",
  dx: -6,
  position({ x: e, y: t }, n, i, r) {
    i[n] = -t, r[n] = -e;
  }
};
function g8(e) {
  return e == null || typeof e == "function" ? e : `${e}`.trim().toLowerCase().startsWith("node:") ? Ox(w8(e)) : Ox(zG(e));
}
function Ox(e) {
  return (t, n) => ii(e(t), e(n));
}
function zG(e) {
  return (t) => {
    var n;
    return (n = t.data) == null ? void 0 : n[e];
  };
}
function b8(e = "/") {
  return `${e}` == "/" ? (t) => t : (t) => t.map(PG(e, "/"));
}
function PG(e, t) {
  return e = new RegExp(VG(e), "g"), (n) => n == null ? null : `${n}`.replace(e, t);
}
function VG(e) {
  return `${e}`.replace(/[\\^$*+?.()|[\]{}]/g, "\\$&");
}
function _8(e) {
  return Fi(e) && typeof e.node == "function";
}
function jG(e) {
  return Fi(e) && typeof e.link == "function";
}
function w8(e) {
  if (_8(e))
    return e.node;
  if (e = `${e}`.trim().toLowerCase(), !!e.startsWith("node:")) {
    switch (e) {
      case "node:name":
        return qg;
      case "node:path":
        return Yg;
      case "node:internal":
        return v8;
      case "node:depth":
        return Wg;
      case "node:height":
        return Gg;
    }
    throw new Error(`invalid node value: ${e}`);
  }
}
function YG(e) {
  if (_8(e))
    return e.node;
  if (jG(e))
    return e.link;
  if (e = `${e}`.trim().toLowerCase(), !(!e.startsWith("node:") && !e.startsWith("parent:"))) {
    switch (e) {
      case "parent:name":
        return eh(qg);
      case "parent:path":
        return eh(Yg);
      case "parent:depth":
        return eh(Wg);
      case "parent:height":
        return eh(Gg);
      case "node:name":
        return qg;
      case "node:path":
        return Yg;
      case "node:internal":
        return v8;
      case "node:depth":
        return Wg;
      case "node:height":
        return Gg;
    }
    throw new Error(`invalid link value: ${e}`);
  }
}
function Yg(e) {
  return e.id;
}
function qg(e) {
  return qG(e.id);
}
function Wg(e) {
  return e.depth;
}
function Gg(e) {
  return e.height;
}
function v8(e) {
  return !!e.children;
}
function eh(e) {
  return (t, n) => n == null ? void 0 : e(n);
}
function qG(e) {
  let t = e.length;
  for (; --t > 0 && !WG(e, t); )
    ;
  return e.slice(t + 1);
}
function WG(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
const x8 = 2, S8 = 3, yp = 4;
function I8(e, t) {
  const n = [];
  for (const i in e) {
    const r = e[i], s = t(r);
    s !== void 0 && n.push([i, ...Fn(r), s]);
  }
  return n;
}
function $8(e, {
  fill: t,
  stroke: n,
  strokeWidth: i,
  strokeOpacity: r,
  strokeLinejoin: s,
  strokeLinecap: o,
  strokeMiterlimit: a,
  strokeDasharray: c,
  strokeDashoffset: l,
  marker: u,
  markerStart: f = u,
  markerEnd: h = u,
  dot: d = ke(f) && ke(h),
  text: p = "node:name",
  textStroke: y = "white",
  title: g = "node:path",
  dx: m,
  dy: b,
  ..._
} = {}) {
  return m === void 0 && (m = C_(_.treeAnchor).dx), ns(
    UT(
      e,
      m8({
        markerStart: f,
        markerEnd: h,
        stroke: n !== void 0 ? n : t === void 0 ? "node:internal" : t,
        strokeWidth: i,
        strokeOpacity: r,
        strokeLinejoin: s,
        strokeLinecap: o,
        strokeMiterlimit: a,
        strokeDasharray: c,
        strokeDashoffset: l,
        ..._
      })
    ),
    d ? so(e, jg({ fill: t === void 0 ? "node:internal" : t, title: g, ..._ })) : null,
    p != null ? Bc(
      e,
      jg({
        text: p,
        fill: t === void 0 ? "currentColor" : t,
        stroke: y,
        dx: m,
        dy: b,
        title: g,
        ..._
      })
    ) : null
  );
}
function GG(e, t) {
  return $8(e, { ...t, treeLayout: bU });
}
function XG({ geometry: e = lt, ...t } = {}) {
  return Rn({ ...t, x: null, y: null }, (n, i, r, s, o, { projection: a }) => {
    const c = Lt(n, e), l = c.length, u = new Float64Array(l), f = new Float64Array(l), h = to(a);
    for (let d = 0; d < l; ++d)
      [u[d], f[d]] = h.centroid(c[d]);
    return { data: n, facets: i, channels: { x: { value: u, source: null }, y: { value: f, source: null } } };
  });
}
function HG({ geometry: e = lt, ...t } = {}) {
  let n;
  return {
    ...t,
    x: { transform: (i) => Float64Array.from(n = Lt(Lt(i, e), m9), ([r]) => r) },
    y: { transform: () => Float64Array.from(n, ([, i]) => i) }
  };
}
function KG(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function JG(e, t, n, i, r) {
  for (var s = r + 1; i <= r; ) {
    var o = i + r >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c >= 0 ? (s = o, r = o - 1) : i = o + 1;
  }
  return s;
}
function ZG(e, t, n, i, r) {
  for (var s = r + 1; i <= r; ) {
    var o = i + r >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c > 0 ? (s = o, r = o - 1) : i = o + 1;
  }
  return s;
}
function QG(e, t, n, i, r) {
  for (var s = i - 1; i <= r; ) {
    var o = i + r >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c < 0 ? (s = o, i = o + 1) : r = o - 1;
  }
  return s;
}
function tX(e, t, n, i, r) {
  for (var s = i - 1; i <= r; ) {
    var o = i + r >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c <= 0 ? (s = o, i = o + 1) : r = o - 1;
  }
  return s;
}
function eX(e, t, n, i, r) {
  for (; i <= r; ) {
    var s = i + r >>> 1, o = e[s], a = n !== void 0 ? n(o, t) : o - t;
    if (a === 0)
      return s;
    a <= 0 ? i = s + 1 : r = s - 1;
  }
  return -1;
}
function vl(e, t, n, i, r, s) {
  return typeof n == "function" ? s(e, t, n, i === void 0 ? 0 : i | 0, r === void 0 ? e.length - 1 : r | 0) : s(e, t, void 0, n === void 0 ? 0 : n | 0, i === void 0 ? e.length - 1 : i | 0);
}
var nX = {
  ge: function(e, t, n, i, r) {
    return vl(e, t, n, i, r, JG);
  },
  gt: function(e, t, n, i, r) {
    return vl(e, t, n, i, r, ZG);
  },
  lt: function(e, t, n, i, r) {
    return vl(e, t, n, i, r, QG);
  },
  le: function(e, t, n, i, r) {
    return vl(e, t, n, i, r, tX);
  },
  eq: function(e, t, n, i, r) {
    return vl(e, t, n, i, r, eX);
  }
}, mp = nX, Ua = 0, Ao = 1, Mh = 2, iX = sX;
function k_(e, t, n, i, r) {
  this.mid = e, this.left = t, this.right = n, this.leftPoints = i, this.rightPoints = r, this.count = (t ? t.count : 0) + (n ? n.count : 0) + i.length;
}
var pf = k_.prototype;
function pm(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 A8(e, t) {
  var n = Dc(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 Ex(e, t) {
  var n = e.intervals([]);
  n.push(t), A8(e, n);
}
function Lx(e, t) {
  var n = e.intervals([]), i = n.indexOf(t);
  return i < 0 ? Ua : (n.splice(i, 1), A8(e, n), Ao);
}
pf.intervals = function(e) {
  return e.push.apply(e, this.leftPoints), this.left && this.left.intervals(e), this.right && this.right.intervals(e), e;
};
pf.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) ? Ex(this, e) : this.left.insert(e) : this.left = Dc([e]);
  else if (e[0] > this.mid)
    this.right ? 4 * (this.right.count + 1) > 3 * (t + 1) ? Ex(this, e) : this.right.insert(e) : this.right = Dc([e]);
  else {
    var n = mp.ge(this.leftPoints, e, U_), i = mp.ge(this.rightPoints, e, z_);
    this.leftPoints.splice(n, 0, e), this.rightPoints.splice(i, 0, e);
  }
};
pf.remove = function(e) {
  var t = this.count - this.leftPoints;
  if (e[1] < this.mid) {
    if (!this.left)
      return Ua;
    var n = this.right ? this.right.count : 0;
    if (4 * n > 3 * (t - 1))
      return Lx(this, e);
    var i = this.left.remove(e);
    return i === Mh ? (this.left = null, this.count -= 1, Ao) : (i === Ao && (this.count -= 1), i);
  } else if (e[0] > this.mid) {
    if (!this.right)
      return Ua;
    var r = this.left ? this.left.count : 0;
    if (4 * r > 3 * (t - 1))
      return Lx(this, e);
    var i = this.right.remove(e);
    return i === Mh ? (this.right = null, this.count -= 1, Ao) : (i === Ao && (this.count -= 1), i);
  } else {
    if (this.count === 1)
      return this.leftPoints[0] === e ? Mh : Ua;
    if (this.leftPoints.length === 1 && this.leftPoints[0] === e) {
      if (this.left && this.right) {
        for (var s = this, o = this.left; o.right; )
          s = o, o = o.right;
        if (s === this)
          o.right = this.right;
        else {
          var a = this.left, i = this.right;
          s.count -= o.count, s.right = o.left, o.left = a, o.right = i;
        }
        pm(this, o), this.count = (this.left ? this.left.count : 0) + (this.right ? this.right.count : 0) + this.leftPoints.length;
      } else
        this.left ? pm(this, this.left) : pm(this, this.right);
      return Ao;
    }
    for (var a = mp.ge(this.leftPoints, e, U_); a < this.leftPoints.length && this.leftPoints[a][0] === e[0]; ++a)
      if (this.leftPoints[a] === e) {
        this.count -= 1, this.leftPoints.splice(a, 1);
        for (var i = mp.ge(this.rightPoints, e, z_); i < this.rightPoints.length && this.rightPoints[i][1] === e[1]; ++i)
          if (this.rightPoints[i] === e)
            return this.rightPoints.splice(i, 1), Ao;
      }
    return Ua;
  }
};
function M8(e, t, n) {
  for (var i = 0; i < e.length && e[i][0] <= t; ++i) {
    var r = n(e[i]);
    if (r)
      return r;
  }
}
function T8(e, t, n) {
  for (var i = e.length - 1; i >= 0 && e[i][1] >= t; --i) {
    var r = n(e[i]);
    if (r)
      return r;
  }
}
function B8(e, t) {
  for (var n = 0; n < e.length; ++n) {
    var i = t(e[n]);
    if (i)
      return i;
  }
}
pf.queryPoint = function(e, t) {
  if (e < this.mid) {
    if (this.left) {
      var n = this.left.queryPoint(e, t);
      if (n)
        return n;
    }
    return M8(this.leftPoints, e, t);
  } else if (e > this.mid) {
    if (this.right) {
      var n = this.right.queryPoint(e, t);
      if (n)
        return n;
    }
    return T8(this.rightPoints, e, t);
  } else
    return B8(this.leftPoints, t);
};
pf.queryInterval = function(e, t, n) {
  if (e < this.mid && this.left) {
    var i = this.left.queryInterval(e, t, n);
    if (i)
      return i;
  }
  if (t > this.mid && this.right) {
    var i = this.right.queryInterval(e, t, n);
    if (i)
      return i;
  }
  return t < this.mid ? M8(this.leftPoints, t, n) : e > this.mid ? T8(this.rightPoints, e, n) : B8(this.leftPoints, n);
};
function rX(e, t) {
  return e - t;
}
function U_(e, t) {
  var n = e[0] - t[0];
  return n || e[1] - t[1];
}
function z_(e, t) {
  var n = e[1] - t[1];
  return n || e[0] - t[0];
}
function Dc(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(rX);
  for (var i = t[t.length >> 1], r = [], s = [], o = [], n = 0; n < e.length; ++n) {
    var a = e[n];
    a[1] < i ? r.push(a) : i < a[0] ? s.push(a) : o.push(a);
  }
  var c = o, l = o.slice();
  return c.sort(U_), l.sort(z_), new k_(
    i,
    Dc(r),
    Dc(s),
    c,
    l
  );
}
function Xg(e) {
  this.root = e;
}
var nl = Xg.prototype;
nl.insert = function(e) {
  this.root ? this.root.insert(e) : this.root = new k_(e[0], null, null, [e], [e]);
};
nl.remove = function(e) {
  if (this.root) {
    var t = this.root.remove(e);
    return t === Mh && (this.root = null), t !== Ua;
  }
  return !1;
};
nl.queryPoint = function(e, t) {
  if (this.root)
    return this.root.queryPoint(e, t);
};
nl.queryInterval = function(e, t, n) {
  if (e <= t && this.root)
    return this.root.queryInterval(e, t, n);
};
Object.defineProperty(nl, "count", {
  get: function() {
    return this.root ? this.root.count : 0;
  }
});
Object.defineProperty(nl, "intervals", {
  get: function() {
    return this.root ? this.root.intervals([]) : [];
  }
});
function sX(e) {
  return !e || e.length === 0 ? new Xg(null) : new Xg(Dc(e));
}
const oX = /* @__PURE__ */ KG(iX), aX = ({ marginLeft: e }) => [1, e], cX = ({ width: e, marginRight: t }) => [-1, e - t], lX = ({ width: e, marginLeft: t, marginRight: n }) => [0, (t + e - n) / 2], uX = ({ marginTop: e }) => [1, e], fX = ({ height: e, marginBottom: t }) => [-1, e - t], hX = ({ height: e, marginTop: t, marginBottom: n }) => [0, (t + e - n) / 2];
function N8(e) {
  return typeof e == "string" ? { anchor: e } : e;
}
function dX(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = F8(e));
  let { anchor: n = "left", padding: i = 1, r = t.r } = N8(e);
  switch (`${n}`.toLowerCase()) {
    case "left":
      n = aX;
      break;
    case "right":
      n = cX;
      break;
    case "middle":
      n = lX;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return D8("x", "y", n, kt(i), r, t);
}
function pX(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = F8(e));
  let { anchor: n = "bottom", padding: i = 1, r = t.r } = N8(e);
  switch (`${n}`.toLowerCase()) {
    case "top":
      n = uX;
      break;
    case "bottom":
      n = fX;
      break;
    case "middle":
      n = hX;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return D8("y", "x", n, kt(i), r, t);
}
function F8(e) {
  const { anchor: t, padding: n, ...i } = e, { r } = i;
  return [{ anchor: t, padding: n, r }, i];
}
function D8(e, t, n, i, r, s) {
  if (r != null && typeof r != "number") {
    let { channels: o, sort: a, reverse: c } = s;
    o = Fb(o), (o == null ? void 0 : o.r) === void 0 && (s = { ...s, channels: { ...o, r: { value: r, scale: "r" } } }), a === void 0 && c === void 0 && (s.sort = { channel: "-r" });
  }
  return Rn(s, function(o, a, c, l, u, f) {
    let { [t]: h, r: d } = c;
    if (!c[t])
      throw new Error(`missing channel: ${t}`);
    ({ [t]: h } = Yy(c, l, f));
    const p = d ? void 0 : r !== void 0 ? kt(r) : this.r !== void 0 ? this.r : 3;
    d && (d = Lt(d.value, l[d.scale] || lt, Float64Array));
    let [y, g] = n(u);
    const m = y ? mX : yX, b = new Float64Array(h.length), _ = d ? (w) => d[w] : () => p;
    for (let w of a) {
      const v = oX();
      w = w.filter(d ? (I) => np(h[I]) && Gr(d[I]) : (I) => np(h[I]));
      const x = new Float64Array(2 * w.length + 2);
      for (const I of w) {
        const T = _(I), D = y ? T + i : 0, $ = h[I] - T, A = h[I] + T;
        let F = 2;
        v.queryInterval($ - i, A + i, ([, , S]) => {
          const M = b[S] - D, B = h[I] - h[S], N = i + (d ? d[I] + d[S] : 2 * p), L = Math.sqrt(N * N - B * B);
          x[F++] = M - L, x[F++] = M + L;
        });
        let E = x.slice(0, F);
        y && (E = E.filter((S) => S >= 0));
        t:
          for (const S of E.sort(m)) {
            for (let M = 0; M < F; M += 2)
              if (x[M] + 1e-6 < S && S < x[M + 1] - 1e-6)
                continue t;
            b[I] = S + D;
            break;
          }
        v.insert([$, A, I]);
      }
    }
    y || (y = 1);
    for (const w of a)
      for (const v of w)
        b[v] = b[v] * y + g;
    return {
      data: o,
      facets: a,
      channels: {
        [e]: { value: b, source: null },
        // don’t show in tooltip
        [t]: { value: h, source: c[t] },
        ...d && { r: { value: d, source: c.r } }
      }
    };
  });
}
function yX(e, t) {
  return Math.abs(e) - Math.abs(t);
}
function mX(e, t) {
  return e - t;
}
function gX(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), N_(P_(e), t);
}
function bX(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), F_(P_(e), t);
}
function P_(e) {
  if (e === void 0)
    return Rx;
  if (typeof e == "function")
    return s0(Bb(e));
  if (/^p\d{2}$/i.test(e))
    return il(Mb(e));
  switch (`${e}`.toLowerCase()) {
    case "deviation":
      return vX;
    case "first":
      return Rx;
    case "last":
      return wX;
    case "max":
      return xX;
    case "mean":
      return SX;
    case "median":
      return IX;
    case "min":
      return $X;
    case "sum":
      return AX;
    case "extent":
      return _X;
  }
  throw new Error(`invalid basis: ${e}`);
}
function s0(e) {
  return {
    mapIndex(t, n, i) {
      const r = +e(t, n);
      for (const s of t)
        i[s] = n[s] === null ? NaN : n[s] / r;
    }
  };
}
function il(e) {
  return s0((t, n) => e(t, (i) => n[i]));
}
const _X = {
  mapIndex(e, t, n) {
    const [i, r] = He(e, (o) => t[o]), s = r - i;
    for (const o of e)
      n[o] = t[o] === null ? NaN : (t[o] - i) / s;
  }
}, Rx = s0((e, t) => {
  for (let n = 0; n < e.length; ++n) {
    const i = t[e[n]];
    if (cn(i))
      return i;
  }
}), wX = s0((e, t) => {
  for (let n = e.length - 1; n >= 0; --n) {
    const i = t[e[n]];
    if (cn(i))
      return i;
  }
}), vX = {
  mapIndex(e, t, n) {
    const i = G1(e, (s) => t[s]), r = ry(e, (s) => t[s]);
    for (const s of e)
      n[s] = t[s] === null ? NaN : r ? (t[s] - i) / r : 0;
  }
}, xX = il(Se), SX = il(G1), IX = il(fu), $X = il(ze), AX = il(or);
function MX(e = {}, t) {
  return arguments.length === 1 && (t = e), N_(V_(e), t);
}
function TX(e = {}, t) {
  return arguments.length === 1 && (t = e), F_(V_(e), t);
}
function V_(e = {}) {
  typeof e == "number" && (e = { k: e });
  let { k: t, reduce: n, shift: i, anchor: r, strict: s } = e;
  if (r === void 0 && i !== void 0 && (r = NX(i), ir(`Warning: the shift option is deprecated; please use anchor "${r}" instead.`)), !((t = Math.floor(t)) > 0))
    throw new Error(`invalid k: ${t}`);
  return FX(n)(t, BX(r, t), s);
}
function BX(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 NX(e) {
  switch (`${e}`.toLowerCase()) {
    case "centered":
      return "middle";
    case "leading":
      return "start";
    case "trailing":
      return "end";
  }
  throw new Error(`invalid shift: ${e}`);
}
function FX(e = "mean") {
  if (typeof e == "string") {
    if (/^p\d{2}$/i.test(e))
      return nh(Mb(e));
    switch (e.toLowerCase()) {
      case "deviation":
        return nh(ry);
      case "max":
        return ih((t, n) => Se(t, (i) => n[i]));
      case "mean":
        return DX;
      case "median":
        return nh(fu);
      case "min":
        return ih((t, n) => ze(t, (i) => n[i]));
      case "mode":
        return ih((t, n) => R3(t, (i) => n[i]));
      case "sum":
        return O8;
      case "variance":
        return nh(P1);
      case "difference":
        return LX;
      case "ratio":
        return RX;
      case "first":
        return CX;
      case "last":
        return kX;
    }
  }
  if (typeof e != "function")
    throw new Error(`invalid reduce: ${e}`);
  return ih(Bb(e));
}
function ec(e, t, n) {
  return e.subarray ? e.subarray(t, n) : e.slice(t, n);
}
function nh(e) {
  return (t, n, i) => i ? {
    mapIndex(r, s, o) {
      const a = (l) => s[l] == null ? NaN : +s[l];
      let c = 0;
      for (let l = 0; l < t - 1; ++l)
        isNaN(a(l)) && ++c;
      for (let l = 0, u = r.length - t + 1; l < u; ++l)
        isNaN(a(l + t - 1)) && ++c, o[r[l + a]] = c === 0 ? e(ec(r, l, l + t), a) : NaN, isNaN(a(l)) && --c;
    }
  } : {
    mapIndex(r, s, o) {
      const a = (c) => s[c] == null ? NaN : +s[c];
      for (let c = -a; c < 0; ++c)
        o[r[c + a]] = e(ec(r, 0, c + t), a);
      for (let c = 0, l = r.length - a; c < l; ++c)
        o[r[c + a]] = e(ec(r, c, c + t), a);
    }
  };
}
function ih(e) {
  return (t, n, i) => i ? {
    mapIndex(r, s, o) {
      let a = 0;
      for (let c = 0; c < t - 1; ++c)
        a += cn(s[r[c]]);
      for (let c = 0, l = r.length - t + 1; c < l; ++c)
        a += cn(s[r[c + t - 1]]), a === t && (o[r[c + n]] = e(ec(r, c, c + t), s)), a -= cn(s[r[c]]);
    }
  } : {
    mapIndex(r, s, o) {
      for (let a = -n; a < 0; ++a)
        o[r[a + n]] = e(ec(r, 0, a + t), s);
      for (let a = 0, c = r.length - n; a < c; ++a)
        o[r[a + n]] = e(ec(r, a, a + t), s);
    }
  };
}
function O8(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      let o = 0, a = 0;
      for (let c = 0; c < e - 1; ++c) {
        const l = r[i[c]];
        l === null || isNaN(l) ? ++o : a += +l;
      }
      for (let c = 0, l = i.length - e + 1; c < l; ++c) {
        const u = r[i[c]], f = r[i[c + e - 1]];
        f === null || isNaN(f) ? ++o : a += +f, s[i[c + t]] = o === 0 ? a : NaN, u === null || isNaN(u) ? --o : a -= +u;
      }
    }
  } : {
    mapIndex(i, r, s) {
      let o = 0;
      const a = i.length;
      for (let c = 0, l = Math.min(a, e - t - 1); c < l; ++c)
        o += +r[i[c]] || 0;
      for (let c = -t, l = a - t; c < l; ++c)
        o += +r[i[c + e - 1]] || 0, s[i[c + t]] = o, o -= +r[i[c]] || 0;
    }
  };
}
function DX(e, t, n) {
  if (n) {
    const i = O8(e, t, n);
    return {
      mapIndex(r, s, o) {
        i.mapIndex(r, s, o);
        for (let a = 0, c = r.length - e + 1; a < c; ++a)
          o[r[a + t]] /= e;
      }
    };
  } else
    return {
      mapIndex(i, r, s) {
        let o = 0, a = 0;
        const c = i.length;
        for (let l = 0, u = Math.min(c, e - t - 1); l < u; ++l) {
          let f = r[i[l]];
          f !== null && !isNaN(f = +f) && (o += f, ++a);
        }
        for (let l = -t, u = c - t; l < u; ++l) {
          let f = r[i[l + e - 1]], h = r[i[l]];
          f !== null && !isNaN(f = +f) && (o += f, ++a), s[i[l + t]] = o / a, h !== null && !isNaN(h = +h) && (o -= h, --a);
        }
      }
    };
}
function OX(e, t, n, i) {
  for (let r = n + i; n < r; ++n) {
    const s = e[t[n]];
    if (cn(s))
      return s;
  }
}
function EX(e, t, n, i) {
  for (let r = n + i - 1; r >= n; --r) {
    const s = e[t[r]];
    if (cn(s))
      return s;
  }
}
function E8(e, t, n, i) {
  for (let r = n + i; n < r; ++n) {
    let s = e[t[n]];
    if (s !== null && !isNaN(s = +s))
      return s;
  }
}
function L8(e, t, n, i) {
  for (let r = n + i - 1; r >= n; --r) {
    let s = e[t[r]];
    if (s !== null && !isNaN(s = +s))
      return s;
  }
}
function LX(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o) {
        const c = r[i[o]], l = r[i[o + e - 1]];
        s[i[o + t]] = c === null || l === null ? NaN : l - c;
      }
    }
  } : {
    mapIndex(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = L8(r, i, o, e) - E8(r, i, o, e);
    }
  };
}
function RX(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o) {
        const c = r[i[o]], l = r[i[o + e - 1]];
        s[i[o + t]] = c === null || l === null ? NaN : l / c;
      }
    }
  } : {
    mapIndex(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = L8(r, i, o, e) / E8(r, i, o, e);
    }
  };
}
function CX(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o)
        s[i[o + t]] = r[i[o]];
    }
  } : {
    mapIndex(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = OX(r, i, o, e);
    }
  };
}
function kX(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o)
        s[i[o + t]] = r[i[o + e - 1]];
    }
  } : {
    mapIndex(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = EX(r, i, o, e);
    }
  };
}
function UX(e, t = {}) {
  if (typeof e == "string")
    switch (e.toLowerCase()) {
      case "first":
        return R8(t);
      case "last":
        return C8(t);
    }
  if (typeof e == "function")
    return qs(null, e, t);
  let n, i;
  for (n in e) {
    if (i !== void 0)
      throw new Error("ambiguous selector; multiple inputs");
    i = zX(e[n]);
  }
  if (i === void 0)
    throw new Error(`invalid selector: ${e}`);
  return qs(n, i, t);
}
function zX(e) {
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "min":
      return j_;
    case "max":
      return Y_;
  }
  throw new Error(`unknown selector: ${e}`);
}
function R8(e) {
  return qs(null, qX, e);
}
function C8(e) {
  return qs(null, WX, e);
}
function PX(e) {
  return qs("x", j_, e);
}
function VX(e) {
  return qs("y", j_, e);
}
function jX(e) {
  return qs("x", Y_, e);
}
function YX(e) {
  return qs("y", Y_, e);
}
function* qX(e) {
  yield e[0];
}
function* WX(e) {
  yield e[e.length - 1];
}
function* j_(e, t) {
  yield _L(e, (n) => t[n]);
}
function* Y_(e, t) {
  yield W1(e, (n) => t[n]);
}
function qs(e, t, n) {
  if (e != null) {
    if (n[e] == null)
      throw new Error(`missing channel: ${e}`);
    e = n[e];
  }
  const i = no(n);
  return pr(n, (r, s) => {
    const o = Lt(r, i), a = Lt(r, e), c = [];
    for (const l of s) {
      const u = [];
      for (const f of o ? as(l, (h) => o[h]).values() : [l])
        for (const h of t(f, a))
          u.push(h);
      c.push(u);
    }
    return { data: r, facets: c };
  });
}
const Cx = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Area: t0,
  Arrow: zT,
  BarX: VT,
  BarY: jT,
  Cell: e0,
  Contour: a8,
  Density: u8,
  Dot: n0,
  Frame: vT,
  Geo: f8,
  Hexgrid: h8,
  Image: d8,
  Line: i0,
  Link: kT,
  Mark: ce,
  Raster: t8,
  Rect: r0,
  RuleX: R4,
  RuleY: C4,
  Text: Ky,
  TickX: WT,
  TickY: GT,
  Tip: xT,
  Vector: Jy,
  area: oW,
  areaX: up,
  areaY: Tu,
  arrow: fW,
  auto: SW,
  autoSpec: YT,
  axisFx: oT,
  axisFy: sT,
  axisX: f_,
  axisY: u_,
  barX: Za,
  barY: Qa,
  bin: Mo,
  binX: As,
  binY: Ms,
  boxX: DW,
  boxY: OW,
  cell: A_,
  cellX: dW,
  cellY: pW,
  centroid: XG,
  circle: bW,
  cluster: GG,
  column: Fn,
  contour: YW,
  crosshair: WW,
  crosshairX: GW,
  crosshairY: XW,
  delaunayLink: aG,
  delaunayMesh: cG,
  density: dG,
  dodgeX: dX,
  dodgeY: pX,
  dot: so,
  dotX: mW,
  dotY: gW,
  filter: OV,
  formatIsoDate: Zb,
  formatMonth: Gj,
  formatWeekday: Xj,
  frame: h_,
  geo: R_,
  geoCentroid: HG,
  graticule: _G,
  gridFx: hT,
  gridFy: uT,
  gridX: fT,
  gridY: lT,
  group: Ub,
  groupX: Iu,
  groupY: $u,
  groupZ: kb,
  hexagon: _W,
  hexbin: wG,
  hexgrid: SG,
  hull: lG,
  identity: lt,
  image: TG,
  indexOf: In,
  initializer: Rn,
  interpolateNearest: s8,
  interpolateNone: Vg,
  interpolatorBarycentric: r8,
  interpolatorRandomWalk: o8,
  legend: AY,
  line: T_,
  lineX: hp,
  lineY: dp,
  linearRegressionX: RG,
  linearRegressionY: CG,
  link: UT,
  map: hf,
  mapX: N_,
  mapY: F_,
  marks: ns,
  normalize: P_,
  normalizeX: gX,
  normalizeY: bX,
  plot: d_,
  pointer: r_,
  pointerX: s_,
  pointerY: o_,
  raster: LW,
  rect: B_,
  rectX: Kl,
  rectY: Jl,
  reverse: EV,
  ruleX: js,
  ruleY: Ys,
  scale: Qo,
  select: UX,
  selectFirst: R8,
  selectLast: C8,
  selectMaxX: jX,
  selectMaxY: YX,
  selectMinX: PX,
  selectMinY: VX,
  shuffle: LV,
  sort: z6,
  sphere: bG,
  spike: KY,
  stackX: DT,
  stackX1: Yq,
  stackX2: qq,
  stackY: OT,
  stackY1: Wq,
  stackY2: Gq,
  text: Bc,
  textX: P4,
  textY: V4,
  tickX: XT,
  tickY: HT,
  tip: ST,
  transform: pr,
  tree: $8,
  treeLink: m8,
  treeNode: jg,
  valueof: Lt,
  vector: Z4,
  vectorX: Q4,
  vectorY: tT,
  voronoi: uG,
  voronoiMesh: fG,
  window: V_,
  windowX: MX,
  windowY: TX
}, Symbol.toStringTag, { value: "Module" })), GX = /* @__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"]
]), XX = /* @__PURE__ */ new Set([
  "frame",
  "hexgrid",
  "sphere",
  "graticule"
]);
function HX(e, t, n) {
  for (let i = 0; i < t.length; ++i) {
    const r = t[i];
    i === t.length - 1 ? e[r] = n : e = e[r] || (e[r] = {});
  }
}
async function KX(e) {
  const t = { marks: [] }, n = [], { attributes: i, marks: r } = e;
  for (const a in i) {
    const c = GX.get(a);
    if (c == null)
      throw new Error(`Unrecognized plot attribute: ${a}`);
    const l = i[a];
    typeof l == "symbol" ? n.push(a) : l !== void 0 && HX(t, c.split("."), l);
  }
  const s = [];
  for (const a of r)
    for (const { type: c, data: l, options: u } of a.plotSpecs())
      XX.has(c) ? t.marks.push(Cx[c](u)) : t.marks.push(Cx[c](l, u)), s.push(a.index);
  ZX(t, e);
  const o = d_(t);
  QX(o, s), JX(e, o, i, n);
  for (const a of e.interactors)
    await a.init(o);
  return o;
}
function JX(e, t, n, i) {
  i.forEach((r) => {
    const s = n[r];
    if (s === U1) {
      if (!r.endsWith("Domain"))
        throw new Error(`Unsupported fixed attribute: ${r}`);
      const o = r.slice(0, -6), a = t.scale(o);
      a != null && a.domain && e.setAttribute(r, n[`${o}Reverse`] ? a.domain.slice().reverse() : a.domain);
    } else
      throw new Error(`Unrecognized symbol: ${s}`);
  });
}
function ZX(e, t) {
  const { marks: n } = t;
  rh("x", e, n, ["x", "x1", "x2"]), rh("y", e, n, ["y", "y1", "y2"]), rh("fx", e, n), rh("fy", e, n);
}
function rh(e, t, n, i = [e]) {
  const r = t[e] || {};
  if (r.axis === null || r.label !== void 0)
    return;
  const s = n.map((u) => {
    var f;
    return (f = u.channelField(i)) == null ? void 0 : f.field;
  });
  if (s.every((u) => u == null))
    return;
  let o, a, c;
  for (let u = 0; u < s.length; ++u) {
    const { column: f, label: h } = s[u] || {};
    f === void 0 && h === void 0 || (o === void 0 && a === void 0 ? (o = f, a = h, c = tH(n[u].data, i) || "number") : a !== h ? a = void 0 : o !== f && (o = void 0));
  }
  let l = a || o;
  if (l !== void 0) {
    if ((c === "number" || c === "date") && (e === "x" || e === "y")) {
      r.percent && (l = `${l} (%)`);
      const u = (e === "x" ? 1 : -1) * (r.reverse ? -1 : 1);
      e === "x" || r.labelAnchor === "center" ? l = e === "x" == u < 0 ? `← ${l}` : `${l} →` : l = `${u < 0 ? "↑ " : "↓ "}${l}`;
    }
    t[e] = { ...r, label: l };
  }
}
function QX(e, t) {
  const n = e.querySelectorAll('g[aria-label="facet"]');
  if (n.length)
    for (const i of n)
      kx(i, t);
  else
    kx(e, t);
}
function kx(e, t) {
  let n = -1;
  for (const i of e.children) {
    const r = i.getAttribute("aria-label") || "";
    i.nodeName === "style" || r.includes("-axis") || r.includes("-grid") || i.setAttribute("data-index", t[++n]);
  }
}
function tH(e, t) {
  for (const n of e)
    for (let i = 0; i < t.length; ++i) {
      const r = n[t[i]];
      if (r != null)
        return r instanceof Date ? "date" : typeof r;
    }
}
const eH = {
  width: 640,
  marginLeft: 40,
  marginRight: 20,
  marginTop: 20,
  marginBottom: 30
};
class nH {
  constructor(t) {
    this.attributes = { ...eH }, 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 = M5();
  }
  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 KX(this), n = this.legends.flatMap(({ legend: i, include: r }) => {
      const s = i.init(t);
      return r ? s : [];
    });
    this.element.replaceChildren(t, ...n), this.synch.resolve();
  }
  getAttribute(t) {
    return this.attributes[t];
  }
  setAttribute(t, n, i) {
    var r, s;
    return w3(this.attributes[t], n) ? (n === void 0 ? delete this.attributes[t] : this.attributes[t] = n, i != null && i.silent || (s = (r = this.listeners) == null ? void 0 : r.get(t)) == null || s.forEach((o) => o(t, n)), !0) : !1;
  }
  addAttributeListener(t, n) {
    const i = this.listeners || (this.listeners = /* @__PURE__ */ new Map());
    return i.has(t) || i.set(t, /* @__PURE__ */ new Set()), i.get(t).add(n), this;
  }
  removeAttributeListener(t, n) {
    var i, r;
    return (r = (i = this.listeners) == null ? void 0 : i.get(t)) == null ? void 0 : r.delete(n);
  }
  addParams(t, n) {
    const { params: i } = this;
    for (const r of n)
      i.has(r) ? i.get(r).push(t) : (i.set(r, [t]), r.addEventListener("value", () => Promise.allSettled(
        i.get(r).map((s) => s.requestQuery())
      )));
  }
  addMark(t) {
    return t.setPlot(this, this.marks.length), this.marks.push(t), this.markset = null, this;
  }
  get markSet() {
    return this.markset || (this.markset = new Set(this.marks));
  }
  addInteractor(t) {
    return this.interactors.push(t), this;
  }
  addLegend(t, n = !0) {
    t.setPlot(this), this.legends.push({ legend: t, include: n });
  }
}
function iH(...e) {
  const t = new nH();
  return e.flat().forEach((n) => n(t)), t.marks.forEach((n) => pi().connect(n)), t.element;
}
class rH extends Map {
  request(t, n) {
    if (this.has(t))
      n(this.get(t));
    else {
      const i = this.waiting || (this.waiting = /* @__PURE__ */ new Map()), r = i.get(t) || [];
      i.set(t, r.concat(n));
    }
  }
  set(t, n) {
    this.has(t) && console.warn(`Overwriting named plot "${t}".`);
    const { waiting: i } = this;
    return i != null && i.has(t) && (i.get(t).forEach((r) => r(n)), i.delete(t)), super.set(t, n);
  }
}
const q_ = new rH();
function sH(e) {
  return (t) => q_.set(e, t);
}
function k8(e, t, n) {
  Ds(n) ? (n.addEventListener("value", (i) => {
    e.setAttribute(t, i), e.update();
  }), n.value !== void 0 && e.setAttribute(t, n.value)) : e.setAttribute(t, n);
}
function U8(e, t) {
  return (n) => {
    k8(n, e, t);
  };
}
function W_(e) {
  return (t) => {
    for (const [n, i] of Object.entries(e))
      k8(t, n, i);
  };
}
function oH(e) {
  const { top: t, bottom: n, left: i, right: r } = e, s = {};
  return t !== void 0 && (s.marginTop = t), n !== void 0 && (s.marginBottom = n), i !== void 0 && (s.marginLeft = i), r !== void 0 && (s.marginRight = r), W_(s);
}
function aH(e) {
  return W_({ xDomain: e, yDomain: e });
}
const O = (e) => (t) => U8(e, t), cH = O("style"), lH = O("width"), uH = O("height"), fH = O("margin"), hH = O("marginLeft"), dH = O("marginRight"), pH = O("marginTop"), yH = O("marginBottom"), mH = O("align"), gH = O("aspectRatio"), bH = O("axis"), _H = O("inset"), wH = O("grid"), vH = O("label"), xH = O("padding"), SH = O("round"), IH = O("xScale"), $H = O("xDomain"), AH = O("xRange"), MH = O("xNice"), TH = O("xInset"), BH = O("xInsetLeft"), NH = O("xInsetRight"), FH = O("xClamp"), DH = O("xRound"), OH = O("xAlign"), EH = O("xPadding"), LH = O("xPaddingInner"), RH = O("xPaddingOuter"), CH = O("xAxis"), kH = O("xTicks"), UH = O("xTickSize"), zH = O("xTickSpacing"), PH = O("xTickPadding"), VH = O("xTickFormat"), jH = O("xTickRotate"), YH = O("xGrid"), qH = O("xLine"), WH = O("xLabel"), GH = O("xLabelAnchor"), XH = O("xLabelOffset"), HH = O("xFontVariant"), KH = O("xAriaLabel"), JH = O("xAriaDescription"), ZH = O("xReverse"), QH = O("xZero"), tK = O("yScale"), eK = O("yDomain"), nK = O("yRange"), iK = O("yNice"), rK = O("yInset"), sK = O("yInsetTop"), oK = O("yInsetBottom"), aK = O("yClamp"), cK = O("yRound"), lK = O("yAlign"), uK = O("yPadding"), fK = O("yPaddingInner"), hK = O("yPaddingOuter"), dK = O("yAxis"), pK = O("yTicks"), yK = O("yTickSize"), mK = O("yTickSpacing"), gK = O("yTickPadding"), bK = O("yTickFormat"), _K = O("yTickRotate"), wK = O("yGrid"), vK = O("yLine"), xK = O("yLabel"), SK = O("yLabelAnchor"), IK = O("yLabelOffset"), $K = O("yFontVariant"), AK = O("yAriaLabel"), MK = O("yAriaDescription"), TK = O("yReverse"), BK = O("yZero"), NK = O("facetMargin"), FK = O("facetMarginTop"), DK = O("facetMarginBottom"), OK = O("facetMarginLeft"), EK = O("facetMarginRight"), LK = O("facetGrid"), RK = O("facetLabel"), CK = O("fxDomain"), kK = O("fxRange"), UK = O("fxNice"), zK = O("fxInset"), PK = O("fxInsetLeft"), VK = O("fxInsetRight"), jK = O("fxRound"), YK = O("fxAlign"), qK = O("fxPadding"), WK = O("fxPaddingInner"), GK = O("fxPaddingOuter"), XK = O("fxAxis"), HK = O("fxTicks"), KK = O("fxTickSize"), JK = O("fxTickSpacing"), ZK = O("fxTickPadding"), QK = O("fxTickFormat"), tJ = O("fxTickRotate"), eJ = O("fxGrid"), nJ = O("fxLine"), iJ = O("fxLabel"), rJ = O("fxLabelAnchor"), sJ = O("fxLabelOffset"), oJ = O("fxFontVariant"), aJ = O("fxAriaLabel"), cJ = O("fxAriaDescription"), lJ = O("fxReverse"), uJ = O("fyDomain"), fJ = O("fyRange"), hJ = O("fyNice"), dJ = O("fyInset"), pJ = O("fyInsetTop"), yJ = O("fyInsetBottom"), mJ = O("fyRound"), gJ = O("fyAlign"), bJ = O("fyPadding"), _J = O("fyPaddingInner"), wJ = O("fyPaddingOuter"), vJ = O("fyAxis"), xJ = O("fyTicks"), SJ = O("fyTickSize"), IJ = O("fyTickSpacing"), $J = O("fyTickPadding"), AJ = O("fyTickFormat"), MJ = O("fyTickRotate"), TJ = O("fyGrid"), BJ = O("fyLine"), NJ = O("fyLabel"), FJ = O("fyLabelAnchor"), DJ = O("fyLabelOffset"), OJ = O("fyFontVariant"), EJ = O("fyAriaLabel"), LJ = O("fyAriaDescription"), RJ = O("fyReverse"), CJ = O("colorScale"), kJ = O("colorDomain"), UJ = O("colorRange"), zJ = O("colorClamp"), PJ = O("colorNice"), VJ = O("colorScheme"), jJ = O("colorInterpolate"), YJ = O("colorPivot"), qJ = O("colorSymmetric"), WJ = O("colorLabel"), GJ = O("colorReverse"), XJ = O("colorZero"), HJ = O("colorTickFormat"), KJ = O("opacityScale"), JJ = O("opacityDomain"), ZJ = O("opacityRange"), QJ = O("opacityClamp"), tZ = O("opacityNice"), eZ = O("opacityLabel"), nZ = O("opacityReverse"), iZ = O("opacityZero"), rZ = O("opacityTickFormat"), sZ = O("rScale"), oZ = O("rDomain"), aZ = O("rRange"), cZ = O("rClamp"), lZ = O("rNice"), uZ = O("rZero"), fZ = O("lengthScale"), hZ = O("lengthDomain"), dZ = O("lengthRange"), pZ = O("lengthClamp"), yZ = O("lengthNice"), mZ = O("lengthZero"), gZ = O("projectionType"), bZ = O("projectionParallels"), _Z = O("projectionPrecision"), wZ = O("projectionRotate"), vZ = O("projectionDomain"), xZ = O("projectionInset"), SZ = O("projectionInsetLeft"), IZ = O("projectionInsetRight"), $Z = O("projectionInsetTop"), AZ = O("projectionInsetBottom"), MZ = O("projectionClip"), TZ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  align: mH,
  aspectRatio: gH,
  attribute: U8,
  attributes: W_,
  axis: bH,
  colorClamp: zJ,
  colorDomain: kJ,
  colorInterpolate: jJ,
  colorLabel: WJ,
  colorNice: PJ,
  colorPivot: YJ,
  colorRange: UJ,
  colorReverse: GJ,
  colorScale: CJ,
  colorScheme: VJ,
  colorSymmetric: qJ,
  colorTickFormat: HJ,
  colorZero: XJ,
  facetGrid: LK,
  facetLabel: RK,
  facetMargin: NK,
  facetMarginBottom: DK,
  facetMarginLeft: OK,
  facetMarginRight: EK,
  facetMarginTop: FK,
  fxAlign: YK,
  fxAriaDescription: cJ,
  fxAriaLabel: aJ,
  fxAxis: XK,
  fxDomain: CK,
  fxFontVariant: oJ,
  fxGrid: eJ,
  fxInset: zK,
  fxInsetLeft: PK,
  fxInsetRight: VK,
  fxLabel: iJ,
  fxLabelAnchor: rJ,
  fxLabelOffset: sJ,
  fxLine: nJ,
  fxNice: UK,
  fxPadding: qK,
  fxPaddingInner: WK,
  fxPaddingOuter: GK,
  fxRange: kK,
  fxReverse: lJ,
  fxRound: jK,
  fxTickFormat: QK,
  fxTickPadding: ZK,
  fxTickRotate: tJ,
  fxTickSize: KK,
  fxTickSpacing: JK,
  fxTicks: HK,
  fyAlign: gJ,
  fyAriaDescription: LJ,
  fyAriaLabel: EJ,
  fyAxis: vJ,
  fyDomain: uJ,
  fyFontVariant: OJ,
  fyGrid: TJ,
  fyInset: dJ,
  fyInsetBottom: yJ,
  fyInsetTop: pJ,
  fyLabel: NJ,
  fyLabelAnchor: FJ,
  fyLabelOffset: DJ,
  fyLine: BJ,
  fyNice: hJ,
  fyPadding: bJ,
  fyPaddingInner: _J,
  fyPaddingOuter: wJ,
  fyRange: fJ,
  fyReverse: RJ,
  fyRound: mJ,
  fyTickFormat: AJ,
  fyTickPadding: $J,
  fyTickRotate: MJ,
  fyTickSize: SJ,
  fyTickSpacing: IJ,
  fyTicks: xJ,
  grid: wH,
  height: uH,
  inset: _H,
  label: vH,
  lengthClamp: pZ,
  lengthDomain: hZ,
  lengthNice: yZ,
  lengthRange: dZ,
  lengthScale: fZ,
  lengthZero: mZ,
  margin: fH,
  marginBottom: yH,
  marginLeft: hH,
  marginRight: dH,
  marginTop: pH,
  margins: oH,
  name: sH,
  opacityClamp: QJ,
  opacityDomain: JJ,
  opacityLabel: eZ,
  opacityNice: tZ,
  opacityRange: ZJ,
  opacityReverse: nZ,
  opacityScale: KJ,
  opacityTickFormat: rZ,
  opacityZero: iZ,
  padding: xH,
  projectionClip: MZ,
  projectionDomain: vZ,
  projectionInset: xZ,
  projectionInsetBottom: AZ,
  projectionInsetLeft: SZ,
  projectionInsetRight: IZ,
  projectionInsetTop: $Z,
  projectionParallels: bZ,
  projectionPrecision: _Z,
  projectionRotate: wZ,
  projectionType: gZ,
  rClamp: cZ,
  rDomain: oZ,
  rNice: lZ,
  rRange: aZ,
  rScale: sZ,
  rZero: uZ,
  round: SH,
  style: cH,
  width: lH,
  xAlign: OH,
  xAriaDescription: JH,
  xAriaLabel: KH,
  xAxis: CH,
  xClamp: FH,
  xDomain: $H,
  xFontVariant: HH,
  xGrid: YH,
  xInset: TH,
  xInsetLeft: BH,
  xInsetRight: NH,
  xLabel: WH,
  xLabelAnchor: GH,
  xLabelOffset: XH,
  xLine: qH,
  xNice: MH,
  xPadding: EH,
  xPaddingInner: LH,
  xPaddingOuter: RH,
  xRange: AH,
  xReverse: ZH,
  xRound: DH,
  xScale: IH,
  xTickFormat: VH,
  xTickPadding: PH,
  xTickRotate: jH,
  xTickSize: UH,
  xTickSpacing: zH,
  xTicks: kH,
  xZero: QH,
  xyDomain: aH,
  yAlign: lK,
  yAriaDescription: MK,
  yAriaLabel: AK,
  yAxis: dK,
  yClamp: aK,
  yDomain: eK,
  yFontVariant: $K,
  yGrid: wK,
  yInset: rK,
  yInsetBottom: oK,
  yInsetTop: sK,
  yLabel: xK,
  yLabelAnchor: SK,
  yLabelOffset: IK,
  yLine: vK,
  yNice: iK,
  yPadding: uK,
  yPaddingInner: fK,
  yPaddingOuter: hK,
  yRange: nK,
  yReverse: TK,
  yRound: cK,
  yScale: tK,
  yTickFormat: bK,
  yTickPadding: gK,
  yTickRotate: _K,
  yTickSize: yK,
  yTickSpacing: mK,
  yTicks: pK,
  yZero: BK
}, Symbol.toStringTag, { value: "Module" }));
function BZ(e, t) {
  return { table: e, options: t };
}
function G_(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
  Zr(e) !== null);
}
const NZ = /* @__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 FZ(e) {
  return NZ.has(e);
}
const DZ = /* @__PURE__ */ new Set([
  "asterisk",
  "circle",
  "cross",
  "diamond",
  "diamond2",
  "hexagon",
  "plus",
  "square",
  "square2",
  "star",
  "times",
  "triangle",
  "triangle2",
  "wye"
]);
function OZ(e) {
  return DZ.has(`${e}`.toLowerCase());
}
const z8 = (e) => e === "stroke" || e === "fill", EZ = (e) => e === "symbol", ym = (e, t) => ({
  channel: e,
  field: t,
  as: t instanceof ks ? t.column : e
}), mm = (e, t) => ({ channel: e, value: t });
class rl extends Wu {
  constructor(t, n, i, r = {}) {
    var c;
    super((c = n == null ? void 0 : n.options) == null ? void 0 : c.filterBy), this.type = t, this.reqs = r, this.source = n, Array.isArray(this.source) && (this.data = this.source);
    const s = this.channels = [], o = this.params = /* @__PURE__ */ new Set(), a = (l, u) => {
      const f = typeof u;
      if (f === "function" && u[I3]) {
        const h = u(this, l);
        for (const d in h)
          a(d, h[d]);
      } else if (f === "string")
        FZ(l) || z8(l) && G_(u) || EZ(l) && OZ(u) ? s.push(mm(l, u)) : s.push(ym(l, O1(u)));
      else if (yc(u))
        if (Array.isArray(u.columns))
          s.push(ym(l, u)), o.add(u);
        else {
          const h = mm(l, u.value);
          s.push(h), u.addEventListener("value", (d) => (h.value = d, this.update()));
        }
      else
        f === "object" && !Array.isArray(u) && u != null ? s.push(ym(l, u)) : u !== void 0 && s.push(mm(l, u));
    };
    for (const l in i)
      a(l, i[l]);
  }
  setPlot(t, n) {
    var i;
    this.plot = t, this.index = n, t.addParams(this, this.params), (i = this.source) != null && i.table && this.queryPending();
  }
  hasOwnData() {
    return this.source == null || Array.isArray(this.source);
  }
  channel(t) {
    return this.channels.find((n) => n.channel === t);
  }
  channelField(...t) {
    const n = t.flat();
    for (const i of n) {
      const r = this.channel(i);
      if (r != null && r.field)
        return r;
    }
    return null;
  }
  fields() {
    var s, o, a;
    if (this.hasOwnData())
      return null;
    const { source: { table: t }, channels: n, reqs: i } = this, r = /* @__PURE__ */ new Map();
    for (const { channel: c, field: l } of n) {
      const u = l == null ? void 0 : l.column;
      if (u) {
        if ((s = l.stats) != null && s.length || i[c]) {
          r.has(u) || r.set(u, /* @__PURE__ */ new Set());
          const f = r.get(u);
          (o = i[c]) == null || o.forEach((h) => f.add(h)), (a = l.stats) == null || a.forEach((h) => f.add(h));
        }
      } else
        continue;
    }
    return Array.from(r, ([c, l]) => ({ table: t, column: c, stats: Array.from(l) }));
  }
  fieldInfo(t) {
    return this.stats = t.reduce(
      (n, i) => (n[i.column] = i, n),
      /* @__PURE__ */ Object.create(null)
    ), this;
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { channels: n, source: { table: i } } = this;
    return P8(n, i).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: i } = this, r = {};
    for (const s of i)
      r[s.channel] = Ns(s);
    return [{ type: t, data: n, options: r }];
  }
}
function Ns(e) {
  return Object.hasOwn(e, "value") ? e.value : z8(e.channel) ? { value: e.as, scale: "color" } : e.as;
}
function P8(e, t, n = []) {
  const i = Et.from({ source: t }), r = /* @__PURE__ */ new Set();
  let s = !1;
  for (const o of e) {
    const { channel: a, field: c, as: l } = o;
    if (!n.includes(a)) {
      if (a === "order")
        i.orderby(o.value);
      else if (c) {
        if (c.aggregate)
          s = !0;
        else {
          if (r.has(l))
            continue;
          r.add(l);
        }
        i.select({ [l]: c });
      }
    }
  }
  return s && i.groupby(Array.from(r)), i;
}
function Ws(e, t, n) {
  if (!e.stats)
    return i;
  const { field: i } = e.channelField(t), { type: r } = e.stats[i.column];
  return n = n ?? i, r === "date" ? y3(n) : n;
}
function Hg(e, t, n, i, r = !1, s = 1) {
  const o = (i - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return r ? q`(${+n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${+t})${a}`;
}
const V8 = { x: ["min", "max"] }, j8 = { y: ["min", "max"] }, Y8 = { ...V8, ...j8 };
function q8(e, t, n, i, r) {
  const { plot: s, stats: o } = e, a = s.getAttribute(i), c = s.getAttribute(r);
  if (Array.isArray(a) && !a[Yo])
    return a;
  {
    const { field: l } = e.channelField(n), { column: u } = l, { min: f, max: h } = o[u], d = W8(t, u) || (c ? by().domain([f, h]).nice().domain() : [f, h]);
    return a !== U1 && (d[Yo] = !0), s.setAttribute(i, d, { silent: !0 }), d;
  }
}
function yf(e, t) {
  return q8(e, t, "x", "xDomain", "xNice");
}
function mf(e, t) {
  return q8(e, t, "y", "yDomain", "yNice");
}
function W8(e, t) {
  if (!e)
    return;
  let n, i;
  const r = (s, o) => {
    if (s === "BETWEEN" && o.field.column === t) {
      const { range: a } = o;
      a && (n == null || a[0] < n) && (n = a[0]), a && (i == null || a[1] > i) && (i = a[1]);
    }
  };
  return Array.isArray(e) ? e.forEach((s) => {
    var o;
    return (o = s.visit) == null ? void 0 : o.call(s, r);
  }) : e.visit && e.visit(r), n != null && i != null && n !== i ? [n, i] : void 0;
}
class LZ extends rl {
  constructor(t, n, i) {
    const r = t.endsWith("X") ? "y" : "x", s = { [r]: ["count", "min", "max"] };
    super(t, n, i, s), this.dim = r;
  }
  query(t = []) {
    const { plot: n, dim: i, source: r, stats: s } = this, { optimize: o = !0 } = r.options || {}, { field: a, as: c } = this.channelField(i), l = super.query(t);
    if (o) {
      const { column: u } = a, { count: f, max: h, min: d } = s[u], p = i === "x" ? n.innerWidth() : n.innerHeight(), [y, g] = W8(t, u) || [d, h], m = (g - y) / (h - d);
      if (f * m > p * 4) {
        const b = Ws(this, i, c), _ = this.channelField(i === "x" ? "y" : "x").as, w = l.select().map((v) => v.as).filter((v) => v !== c && v !== _);
        return RZ(l, b, c, _, y, g, p, w);
      }
    }
    return l.orderby(c);
  }
}
function RZ(e, t, n, i, r, s, o, a = []) {
  const c = q`FLOOR(${o / (s - r)}::DOUBLE * (${t} - ${+r}::DOUBLE))::INTEGER`, l = (u) => Et.from(e).select(u).groupby(c, a);
  return Et.union(
    l([{ [n]: gc(n), [i]: Zw(i, n) }, ...a]),
    l([{ [n]: mc(n), [i]: Qw(i, n) }, ...a]),
    l([{ [n]: Zw(n, i), [i]: gc(i) }, ...a]),
    l([{ [n]: Qw(n, i), [i]: mc(i) }, ...a])
  ).orderby(a, n);
}
function Kg(e, t = !1) {
  const n = new Float64Array(5), i = new Float64Array(4);
  CZ(n, i, e);
  const r = Float64Array.of(
    0,
    i[1] - n[1] * i[0],
    i[2] - n[2] * i[0],
    i[3] - n[3] * i[0],
    -n[4] * i[0]
  ), s = 1 + n[1] + n[2] + n[3] + n[4], o = (i[0] + i[1] + i[2] + i[3]) / s, a = (r[1] + r[2] + r[3] + r[4]) / s;
  return {
    sigma: e,
    negative: t,
    a: n,
    b_causal: i,
    b_anticausal: r,
    sum_causal: o,
    sum_anticausal: a
  };
}
function CZ(e, t, n) {
  const r = Float64Array.of(
    0.84,
    1.8675,
    0.84,
    -1.8675,
    -0.34015,
    -0.1299,
    -0.34015,
    0.1299
  ), s = Math.exp(-1.783 / n), o = Math.exp(-1.723 / n), a = 0.6318 / n, c = 1.997 / n, l = 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)
  ), u = n * 2.5066282746310007, f = Float64Array.of(r[0], r[1], 0, 0, 0, 0, 0, 0), h = Float64Array.of(1, 0, l[0], l[1], 0, 0, 0, 0, 0, 0);
  let d, p;
  for (p = 2; p < 8; p += 2) {
    for (f[p] = l[p] * f[p - 2] - l[p + 1] * f[p - 1], f[p + 1] = l[p] * f[p - 1] + l[p + 1] * f[p - 2], d = p - 2; d > 0; d -= 2)
      f[d] += l[p] * f[d - 2] - l[p + 1] * f[d - 1], f[d + 1] += l[p] * f[d - 1] + l[p + 1] * f[d - 2];
    for (d = 0; d <= p; d += 2)
      f[d] += r[p] * h[d] - r[p + 1] * h[d + 1], f[d + 1] += r[p] * h[d + 1] + r[p + 1] * h[d];
    for (h[p + 2] = l[p] * h[p] - l[p + 1] * h[p + 1], h[p + 3] = l[p] * h[p + 1] + l[p + 1] * h[p], d = p; d > 0; d -= 2)
      h[d] += l[p] * h[d - 2] - l[p + 1] * h[d - 1], h[d + 1] += l[p] * h[d - 1] + l[p + 1] * h[d - 2];
  }
  for (p = 0; p < 4; ++p)
    d = p << 1, t[p] = f[d] / u, e[p + 1] = h[d + 2];
}
function kZ(e, t, n, [i, r]) {
  const s = new Float64Array(Math.max(i, r)), o = new Float64Array(Math.max(i, r)), a = new Float64Array(5), c = new Float64Array(n.length);
  for (let l = 0, u = 0; l < r; ++l, u += i) {
    const f = c.subarray(u);
    Jg(e, n.subarray(u), i, 1, s, o, a, f);
  }
  for (let l = 0; l < i; ++l) {
    const u = c.subarray(l);
    Jg(t, u, r, i, s, o, a, u);
  }
  return c;
}
function Jg(e, t, n, i = 1, r = new Float64Array(n), s = new Float64Array(n), o = new Float64Array(5), a = r, c = UZ) {
  const l = i * 2, u = i * 3, f = i * 4, h = i * n;
  let d, p;
  for (c(
    r,
    t,
    n,
    i,
    e.b_causal,
    3,
    e.a,
    4,
    e.sum_causal,
    o,
    e.sigma
  ), p = 4, d = f; p < n; ++p, d += i)
    r[p] = e.b_causal[0] * t[d] + e.b_causal[1] * t[d - i] + e.b_causal[2] * t[d - l] + e.b_causal[3] * t[d - u] - e.a[1] * r[p - 1] - e.a[2] * r[p - 2] - e.a[3] * r[p - 3] - e.a[4] * r[p - 4];
  for (c(
    s,
    t,
    n,
    -i,
    e.b_anticausal,
    4,
    e.a,
    4,
    e.sum_anticausal,
    o,
    e.sigma
  ), p = 4, d = h - i * 5; p < n; ++p, d -= i)
    s[p] = e.b_anticausal[1] * t[d + i] + e.b_anticausal[2] * t[d + l] + e.b_anticausal[3] * t[d + u] + e.b_anticausal[4] * t[d + f] - e.a[1] * s[p - 1] - e.a[2] * s[p - 2] - e.a[3] * s[p - 3] - e.a[4] * s[p - 4];
  if (e.negative)
    for (p = 0, d = 0; p < n; ++p, d += i)
      a[d] = r[p] + s[n - p - 1];
  else
    for (p = 0, d = 0; p < n; ++p, d += i)
      a[d] = Math.max(0, r[p] + s[n - p - 1]);
  return a;
}
function UZ(e, t, n, i, r, s, o, a, c, l) {
  const u = Math.abs(i) * n, f = i < 0 ? u + i : 0;
  let h, d, p;
  for (d = 0; d < a; ++d)
    for (l[d] = d <= s ? r[d] : 0, p = 1; p <= a && p <= d; ++p)
      l[d] -= o[p] * l[d - p];
  for (p = 0; p < a; ++p)
    for (e[p] = 0, d = 1; d <= p; ++d)
      h = f + i * d, h >= 0 && h < u && (e[p] += l[p - d] * t[h]);
  const y = t[f];
  if (y > 0)
    for (p = 0; p < a; ++p)
      e[p] += l[p] * y;
}
function zZ(e, t) {
  return X8(new Float64Array(e), t);
}
function PZ(e, t, n, i = []) {
  return i.length ? Object.values(VZ(e * t, n, i)) : [{ grid: X8(new Float64Array(e * t), n) }];
}
function G8(e) {
  return typeof e.getChild == "function";
}
function X8(e, t) {
  if (G8(t)) {
    const n = t.numRows;
    if (n === 0)
      return e;
    const i = t.getChild("index").toArray(), r = t.getChild("value").toArray();
    for (let s = 0; s < n; ++s)
      e[i[s]] = r[s];
  } else
    for (const n of t)
      e[n.index] = n.value;
  return e;
}
function VZ(e, t, n) {
  const i = {}, r = (s) => (i[s] || (i[s] = { key: s, grid: new Float64Array(e) })).grid;
  if (G8(t)) {
    const s = t.numRows;
    if (s === 0)
      return i;
    const o = t.getChild("index").toArray(), a = t.getChild("value").toArray(), c = n.map((l) => t.getChild(l));
    for (let l = 0; l < s; ++l) {
      const u = c.map((f) => f.get(l));
      r(u)[o[l]] = a[l];
    }
  } else
    for (const s of t) {
      const o = n.map((a) => s[a]);
      r(o)[s.index] = s.value;
    }
  return i;
}
function Qn(e, t, n, i) {
  Ds(n) ? (i = i || (() => e.requestUpdate()), n.addEventListener("value", (r) => (e[t] = r, i())), e[t] = n.value) : e[t] = n;
}
class H8 extends rl {
  constructor(t, n, i) {
    const { bins: r = 1024, bandwidth: s = 20, ...o } = i, a = t.endsWith("X") ? "y" : "x";
    super(t, n, o, a === "x" ? V8 : j8), this.dim = a, Qn(this, "bins", r), Qn(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[Yo];
  }
  query(t = []) {
    if (this.hasOwnData())
      throw new Error("Density1DMark requires a data source");
    const { bins: n, channels: i, dim: r, source: { table: s } } = this, [o, a] = this.extent = (r === "x" ? yf : mf)(this, t), c = Ws(this, r);
    return jZ(
      P8(i, s, [r]).where(t.concat(Dn(c, [o, a]))),
      Hg(c, o, a, n),
      this.channelField("weight") ? "weight" : null
    );
  }
  queryResult(t) {
    return this.grid = zZ(this.bins, t), this.convolve();
  }
  convolve() {
    const { bins: t, bandwidth: n, dim: i, grid: r, plot: s, extent: [o, a] } = this, c = r.some((b) => b < 0), l = i === "x" ? s.innerWidth() : s.innerHeight(), u = Kg(n * (t - 1) / l, c), f = Jg(u, r, t), h = this.data = [], d = i === "x" ? "y" : "x", p = this.channelField(i).as, y = +o, g = (a - y) / (t - 1), m = 1 / g;
    for (let b = 0; b < t; ++b)
      h.push({
        [p]: y + b * g,
        [d]: f[b] * m
      });
    return this;
  }
  plotSpecs() {
    const { type: t, data: n, channels: i, dim: r } = this, s = r === "x" ? { y: "y" } : { x: "x" };
    for (const o of i)
      s[o.channel] = Ns(o);
    return [{ type: t, data: n, options: s }];
  }
}
function jZ(e, t, n) {
  const i = n ? `* ${n}` : "", r = e.clone().select({
    p: t,
    i: q`FLOOR(p)::INTEGER`,
    w: q`(FLOOR(p) + 1 - p)${i}`
  }), s = e.clone().select({
    p: t,
    i: q`FLOOR(p)::INTEGER + 1`,
    w: q`(p - FLOOR(p))${i}`
  });
  return Et.from(Et.unionAll(r, s)).select({ index: "i", value: ta("w") }).groupby("index").having(p3("value", 0));
}
class o0 extends rl {
  constructor(t, n, i) {
    const {
      bandwidth: r = 20,
      binType: s = "linear",
      binWidth: o = 2,
      binPad: a = 1,
      ...c
    } = i, l = YZ(c);
    super(t, n, c, Y8), this.densityMap = l, Qn(this, "bandwidth", r, () => this.grids ? this.convolve().update() : null), Qn(this, "binWidth", o), Qn(this, "binType", s), Qn(this, "binPad", a);
  }
  setPlot(t, n) {
    const i = () => {
      this.stats && this.requestUpdate();
    };
    return t.addAttributeListener("domainX", i), t.addAttributeListener("domainY", i), super.setPlot(t, n);
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[Yo] && !n[Yo];
  }
  query(t = []) {
    const { plot: n, binType: i, binPad: r, channels: s, densityMap: o, source: a } = this, [c, l] = this.extentX = yf(this, t), [u, f] = this.extentY = mf(this, t), [h, d] = this.bins = this.binDimensions(this), p = Ws(this, "x"), y = Ws(this, "y"), g = !!n.getAttribute("xReverse"), m = !!n.getAttribute("yReverse"), b = Ux(p, c, l, h, g, this.binPad), _ = Ux(y, u, f, d, m, this.binPad), w = r ? [Dn(p, [c, l]), Dn(y, [u, f])] : [hd(c, p), fd(p, l), hd(u, y), fd(y, f)], v = Et.from(a.table).where(t.concat(w)), x = this.groupby = [];
    let I = ko();
    for (const T of s)
      if (Object.hasOwn(T, "field")) {
        const { as: D, channel: $, field: A } = T;
        A.aggregate ? (I = A, o[$] = !0) : $ === "weight" ? I = ta(A) : $ !== "x" && $ !== "y" && (v.select({ [D]: A }), x.push(D));
      }
    return i === "linear" ? WZ(v, b, _, I, h, x) : qZ(v, b, _, I, h, x);
  }
  binDimensions() {
    const { plot: t, binWidth: n } = this;
    return [
      Math.round(t.innerWidth() / n),
      Math.round(t.innerHeight() / n)
    ];
  }
  queryResult(t) {
    const [n, i] = this.bins;
    return this.grids = PZ(n, i, t, this.groupby), this.convolve();
  }
  convolve() {
    const { bandwidth: t, bins: n, grids: i, plot: r } = this;
    if (t <= 0)
      this.kde = this.grids.map(({ key: s, grid: o }) => (o.key = s, o));
    else {
      const s = r.innerWidth(), o = r.innerHeight(), [a, c] = n, l = i.some(({ grid: h }) => h.some((d) => d < 0)), u = Kg(t * (a - 1) / s, l), f = Kg(t * (c - 1) / o, l);
      this.kde = this.grids.map(({ key: h, grid: d }) => {
        const p = kZ(u, f, d, n);
        return p.key = h, p;
      });
    }
    return this;
  }
  plotSpecs() {
    throw new Error("Unimplemented. Use a Grid2D mark subclass.");
  }
}
function YZ(e) {
  const t = {};
  for (const n in e)
    e[n] === "density" && (delete e[n], t[n] = !0);
  return t;
}
function Ux(e, t, n, i, r, s) {
  const o = (i - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return r ? q`(${n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${t})${a}`;
}
function qZ(e, t, n, i, r, s) {
  return e.select({
    index: q`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${r}`,
    value: i
  }).groupby("index", s);
}
function WZ(e, t, n, i, r, s) {
  const o = i.column ? `* ${i.column}` : "", a = (h, d) => e.clone().select({ xp: t, yp: n, i: h, w: d }), c = a(
    q`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${r}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), l = a(
    q`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${r}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), u = a(
    q`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${r}`,
    q`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), f = a(
    q`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${r}`,
    q`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return Et.from(Et.unionAll(c, l, u, f)).select({ index: "i", value: ta("w") }, s).groupby("index", s).having(p3("value", 0));
}
class GZ extends o0 {
  constructor(t, n) {
    const { type: i = "dot", binsX: r, binsY: s, ...o } = n;
    o.binPad = o.binPad ?? 0, super(i, t, o), Qn(this, "binsX", r), Qn(this, "binsY", s);
  }
  convolve() {
    super.convolve();
    const { bins: t, binPad: n, extentX: i, extentY: r } = this, [s, o] = t, [a, c] = i, [l, u] = r, f = (c - a) / (s - n), h = (u - l) / (o - n), d = n ? 0 : 0.5;
    return this.data = XZ(this.kde, t, a, l, f, h, d), this;
  }
  binDimensions() {
    const { plot: t, binWidth: n, binsX: i, binsY: r } = this;
    return [
      i ?? Math.round(t.innerWidth() / n),
      r ?? Math.round(t.innerHeight() / n)
    ];
  }
  plotSpecs() {
    const { type: t, channels: n, densityMap: i, data: r } = this, s = {};
    for (const o of n) {
      const { channel: a } = o;
      s[a] = a === "x" || a === "y" ? a : Ns(o);
    }
    for (const o in i)
      i[o] && (s[o] = "density");
    return [{ type: t, data: r, options: s }];
  }
}
function XZ(e, t, n, i, r, s, o) {
  const a = 1 / (r * s), [c, l] = t, u = [];
  for (const f of e)
    for (let h = 0, d = 0; d < l; ++d)
      for (let p = 0; p < c; ++p, ++h)
        u.push({
          x: n + (p + o) * r,
          y: i + (d + o) * s,
          density: f[h] * a
        });
  return u;
}
function K8(e, t, n, i, r, s) {
  const o = (s.length >> 2) - 1;
  for (let a = 0, c = 0; a < i; ++a)
    for (let l = 0, u = (i - a - 1) * n; l < n; ++l, c += 4) {
      const f = o * r(e[l + u]) << 2;
      t[c + 0] = s[f + 0], t[c + 1] = s[f + 1], t[c + 2] = s[f + 2], t[c + 3] = s[f + 3];
    }
}
function gp(e, t) {
  const n = new Uint8ClampedArray(4 * e), i = e - 1;
  for (let r = 0; r <= i; ++r) {
    const s = t(r / i), { r: o, g: a, b: c, opacity: l = 1 } = typeof s == "string" ? ni(s) : s, u = r << 2;
    n[u + 0] = o, n[u + 1] = a, n[u + 2] = c, n[u + 3] = 255 * l | 0;
  }
  return n;
}
function J8(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 Z8(e = "black") {
  const { r: t, g: n, b: i } = ni(e);
  return (r) => ({ r: t, g: n, b: i, opacity: r });
}
class Q8 extends o0 {
  constructor(t, n) {
    super("image", t, n);
  }
  setPlot(t, n) {
    const i = () => {
      this.stats && this.rasterize();
    };
    t.addAttributeListener("schemeColor", i), super.setPlot(t, n);
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var h;
    const { bins: t, kde: n, groupby: i } = this, [r, s] = t, { canvas: o, ctx: a, img: c } = HZ(this, r, s), l = KZ(this), u = i.indexOf((h = this.channelField("fill")) == null ? void 0 : h.as), f = u < 0 ? [] : n.map(({ key: d }) => d[u]);
    return this.data = n.map((d) => {
      var y;
      const p = JZ(this, f, (y = d.key) == null ? void 0 : y[u]);
      return K8(d, c.data, r, s, l, p), a.putImageData(c, 0, 0), { src: o.toDataURL() };
    }), this;
  }
  plotSpecs() {
    var s;
    const { type: t, plot: n, data: i } = this, r = {
      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: i, options: r }];
  }
}
function HZ(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const i = J8(t, n), r = i.getContext("2d", { willReadFrequently: !0 }), s = r.getImageData(0, 0, t, n);
    e.image = { canvas: i, ctx: r, img: s, w: t, h: n };
  }
  return e.image;
}
function KZ(e) {
  const { densityMap: t, kde: n, plot: i } = e;
  let r = t.fill && i.getAttribute("colorDomain");
  if (!r) {
    let o = 0, a = 0;
    n.forEach((c) => {
      for (const l of c)
        l < o && (o = l), l > a && (a = l);
    }), r = o === 0 && a === 0 ? [0, 1] : [o, a];
  }
  const s = i.getAttribute("colorScale");
  return Qo({ x: { type: s, domain: r, range: [0, 1] } }).apply;
}
function JZ(e, t, n, i = 1024) {
  const { densityMap: r, plot: s } = e, o = s.getAttribute("colorScheme");
  let a;
  if (r.fill) {
    if (o)
      try {
        return gp(
          i,
          Qo({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (c) {
        console.warn(c);
      }
  } else if (t.length) {
    const c = s.getAttribute("colorRange");
    a = Qo({ color: {
      domain: t,
      range: c,
      scheme: o || (c ? void 0 : "tableau10")
    } }).apply(n);
  } else {
    const c = e.channelField("fill");
    a = G_(c == null ? void 0 : c.value) ? c.value : void 0;
  }
  return gp(i, Z8(a));
}
class ZZ extends Q8 {
  constructor(t, n) {
    const { normalize: i = !0, ...r } = n;
    super(t, { bandwidth: 0, ...r }), Qn(this, "normalize", i);
  }
  query(t = []) {
    const { plot: n, channels: i, normalize: r, source: s } = this, [o, a] = yf(this, t), [c, l] = mf(this, t), [u, f] = this.bins = this.binDimensions(this), h = Ws(this, "x"), d = Ws(this, "y"), p = !!n.getAttribute("xReverse"), y = !!n.getAttribute("yReverse"), g = Hg(h, o, a, u, p, this.binPad), m = Hg(d, c, l, f, y, this.binPad), b = Et.from(s.table).where(QZ(this, t)), _ = this.groupby = [], w = [];
    for (const v of i)
      if (Object.hasOwn(v, "field")) {
        const { channel: x, field: I } = v;
        x === "z" ? (b.select({ [x]: I }), w.push("z")) : x !== "x" && x !== "y" && (b.select({ [x]: I }), _.push(x));
      }
    return tQ(b, g, m, w, u, f, _, r);
  }
}
function QZ(e, t) {
  if (Array.isArray(t) && !t.length)
    return t;
  const n = e.channelField("x").field.column, i = e.channelField("y").field.column, r = (o) => o.op !== "BETWEEN" || o.field.column !== n && o.field.column !== i, s = (o) => o.op === "AND" ? Vo(o.children.filter((a) => r(a))) : o;
  return Array.isArray(t) ? t.filter((o) => r(o)).map((o) => s(o)) : s(t);
}
function tQ(e, t, n, i, r, s, o = [], a = !0) {
  e.select({
    x: q`FLOOR(${t})::INTEGER`,
    y: q`FLOOR(${n})::INTEGER`
  });
  const c = o.concat(i), l = c.length ? `PARTITION BY ${c.join(", ")} ` : "", u = Et.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`${l}ORDER BY x ASC` }).qualify(Vo(
    q`(x0 < ${r} OR x0 + dx < ${r})`,
    q`(y0 < ${s} OR y0 + dy < ${s})`,
    q`(x0 > 0 OR x0 + dx > 0)`,
    q`(y0 > 0 OR y0 + dy > 0)`
  )), f = Et.select({ x: q`GREATEST(MAX(ABS(dx)), MAX(ABS(dy)))` }).from("pairs"), h = Et.select({ i: q`UNNEST(range((${f})))::INTEGER` }), d = Et.unionAll(
    Et.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)`),
    Et.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)`),
    Et.select(c, { x: "x0", y: "y0" }).from("pairs").where(d3("dx"))
  ), p = ["x"].concat(c).join(", "), y = Et.from("raster").select(
    c,
    "x",
    "y",
    a ? { w: q`1.0 / COUNT(*) OVER (PARTITION BY ${p})` } : null
  ).where(Vo(Dn("x", [0, r]), Dn("y", [0, s])));
  return Et.with({ pairs: u, indices: h, raster: d, points: y }).from("points").select(o, {
    index: q`x + y * ${r}::INTEGER`,
    value: a ? ta("w") : ko()
  }).groupby("index", o);
}
class eQ extends o0 {
  constructor(t, n) {
    const { thresholds: i = 10, ...r } = n;
    super("geo", t, r), Qn(this, "thresholds", i, () => this.grids ? this.contours().update() : null);
  }
  convolve() {
    return super.convolve().contours();
  }
  contours() {
    const { bins: t, densityMap: n, kde: i, thresholds: r, groupby: s, plot: o } = this;
    let a = r;
    if (!Array.isArray(a)) {
      const v = Se(i.map((x) => Se(x)));
      a = Array.from({ length: a - 1 }, (x, I) => v * (I + 1) / a);
    }
    (n.fill || n.stroke) && this.plot.getAttribute("colorScale") !== "log" && this.plot.setAttribute("colorZero", !0);
    const [c, l] = t, [u, f] = o.getAttribute("xDomain"), [h, d] = o.getAttribute("yDomain"), p = (f - u) / c, y = (d - h) / l, g = +u, m = +h, b = (v) => g + v * p, _ = (v) => m + v * y, w = xd().size(t);
    return this.data = i.flatMap((v) => a.map((x) => {
      const I = nQ(w.contour(v, x), b, _);
      return s.forEach((T, D) => I[T] = v.key[D]), I.density = x, I;
    })), this;
  }
  plotSpecs() {
    const { type: t, channels: n, densityMap: i, data: r } = this, s = {};
    for (const o of n) {
      const { channel: a } = o;
      a !== "x" && a !== "y" && (s[a] = Ns(o));
    }
    return i.fill && (s.fill = "density"), i.stroke && (s.stroke = "density"), [{ type: t, data: r, options: s }];
  }
}
function nQ(e, t, n) {
  function i(o) {
    o.forEach(r);
  }
  function r(o) {
    o.forEach(s);
  }
  function s(o) {
    o[0] = t(o[0]), o[1] = n(o[1]);
  }
  return e.coordinates.forEach(i), e;
}
class iQ extends rl {
  constructor(t, n) {
    const { type: i = "hexagon", binWidth: r = 20, ...s } = n;
    super(i, t, { r: r / 2, clip: !0, ...s }, Y8), this.binWidth = r;
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[Yo] && !n[Yo];
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { plot: n, binWidth: i, channels: r, source: s } = this, [o, a] = yf(this, t), [c, l] = mf(this, t), u = 0.5 - n.getAttribute("marginLeft"), f = 0 - n.getAttribute("marginTop"), h = `${i}::DOUBLE`, d = `${i * (1.5 / Math.sqrt(3))}::DOUBLE`, p = `${n.innerWidth() / (a - o)}::DOUBLE`, y = `${n.innerHeight() / (l - c)}::DOUBLE`;
    let g, m;
    const b = /* @__PURE__ */ new Set(), _ = {};
    for (const T of r)
      T.channel === "order" ? w.orderby(T.value) : T.channel === "x" ? g = T : T.channel === "y" ? m = T : Object.hasOwn(T, "field") && (_[T.as] = T.field, T.field.aggregate && T.field.columns.forEach((D) => b.add(D)));
    const w = Et.select({
      [g.as]: q`${o}::DOUBLE + ((x + 0.5 * (y & 1)) * ${h} + ${u})::DOUBLE / ${p}`,
      [m.as]: q`${l}::DOUBLE - (y * ${d} + ${f})::DOUBLE / ${y}`,
      ..._
    }).groupby("x", "y"), v = `${p} * (${g.field} - ${o}::DOUBLE)`, x = `${y} * (${l}::DOUBLE - ${m.field})`, I = Et.select({
      py: q`(${x} - ${f}) / ${d}`,
      pj: q`ROUND(py)::INTEGER`,
      px: q`(${v} - ${u}) / ${h} - 0.5 * (pj & 1)`,
      pi: q`ROUND(px)::INTEGER`,
      tt: q`ABS(py-pj) * 3 > 1 AND (px-pi)**2 + (py-pj)**2 > (px - pi - 0.5 * CASE WHEN px < pi THEN -1 ELSE 1 END)**2 + (py - pj - CASE WHEN py < pj THEN -1 ELSE 1 END)**2`,
      x: q`CASE WHEN tt THEN (pi + (CASE WHEN px < pi THEN -0.5 ELSE 0.5 END) + (CASE WHEN pj & 1 <> 0 THEN 0.5 ELSE -0.5 END))::INTEGER ELSE pi END`,
      y: q`CASE WHEN tt THEN (pj + CASE WHEN py < pj THEN -1 ELSE 1 END)::INTEGER ELSE pj END`
    }).select(Array.from(b)).from(s.table).where(ud(g.field), ud(m.field), t);
    return w.from(I);
  }
}
class rQ extends o0 {
  constructor(t, n) {
    const { origin: i = [0, 0], dim: r = "xy", ...s } = n;
    super("image", t, s), this.origin = i, this.tileX = r.toLowerCase().includes("x"), this.tileY = r.toLowerCase().includes("y");
  }
  setPlot(t, n) {
    const i = () => {
      this.stats && this.rasterize();
    };
    t.addAttributeListener("schemeColor", i), super.setPlot(t, n);
  }
  requestQuery() {
    return this.requestTiles();
  }
  query(t = []) {
    return this._filter = t, null;
  }
  tileQuery(t) {
    const { plot: n, binType: i, binPad: r, channels: s, densityMap: o, source: a } = this, [[c, l], [u, f]] = t, [h, d] = this.bins, p = Ws(this, "x"), y = Ws(this, "y"), g = !!n.getAttribute("xReverse"), m = !!n.getAttribute("yReverse"), b = zx(p, c, l, h, g, r), _ = zx(y, u, f, d, m, r), w = r ? [Dn(p, [c, l]), Dn(y, [u, f])] : [hd(c, p), fd(p, l), hd(u, y), fd(y, f)], v = Et.from(a.table).where(w), x = this.groupby = [];
    let I = ko();
    for (const T of s)
      if (Object.hasOwn(T, "field")) {
        const { channel: D, field: $ } = T;
        $.aggregate ? (I = $, o[D] = !0) : D === "weight" ? I = ta($) : D !== "x" && D !== "y" && (v.select({ [D]: $ }), x.push(D));
      }
    return i === "linear" ? fQ(v, b, _, I, h, x) : uQ(v, b, _, I, h, x);
  }
  async requestTiles() {
    const t = pi();
    this.prefetch && t.cancel(this.prefetch);
    const { binPad: n, tileX: i, tileY: r, origin: [s, o] } = this, [a, c] = this.bins = this.binDimensions(this), [l, u] = yf(this, this._filter), [f, h] = mf(this, this._filter), d = u - l, p = h - f, y = Math.floor((l - s) * (a - n) / d), g = Math.floor((f - o) * (c - n) / p), m = ($, A) => [
      [s + $ * d, s + ($ + 1) * d],
      [o + A * p, o + (A + 1) * p]
    ], b = Math.floor((l - s) / d), _ = i ? Px((u - s) / d) : b, w = Math.floor((f - o) / p), v = r ? Px((h - o) / p) : w, x = [];
    for (let $ = b; $ <= _; ++$)
      for (let A = w; A <= v; ++A)
        x.push([$, A]);
    const I = x.map(
      ([$, A]) => t.query(this.tileQuery(m($, A)))
    ), T = [];
    if (i)
      for (let $ = w; $ <= v; ++$)
        T.push([_ + 1, $]), T.push([b - 1, $]);
    if (r) {
      const $ = i ? b - 1 : b, A = i ? _ + 1 : _;
      for (let F = $; F <= A; ++F)
        T.push([F, v + 1]), T.push([F, w - 1]);
    }
    this.prefetch = T.map(
      ([$, A]) => t.prefetch(this.tileQuery(m($, A)))
    );
    const D = await Promise.all(I);
    this.grids = [{ grid: sQ(a, c, y, g, x, D) }], this.convolve().update();
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var h;
    const { bins: t, kde: n, groupby: i } = this, [r, s] = t, { canvas: o, ctx: a, img: c } = aQ(this, r, s), l = cQ(this), u = i.indexOf((h = this.channelField("fill")) == null ? void 0 : h.as), f = u < 0 ? [] : n.map(({ key: d }) => d[u]);
    return this.data = n.map((d) => {
      var y;
      const p = lQ(this, f, (y = d.key) == null ? void 0 : y[u]);
      return K8(d, c.data, r, s, l, p), a.putImageData(c, 0, 0), { src: o.toDataURL() };
    }), this;
  }
  plotSpecs() {
    var s;
    const { type: t, data: n, plot: i } = this, r = {
      src: "src",
      width: i.innerWidth(),
      height: i.innerHeight(),
      preserveAspectRatio: "none",
      imageRendering: (s = this.channel("imageRendering")) == null ? void 0 : s.value,
      frameAnchor: "middle"
    };
    return [{ type: t, data: n, options: r }];
  }
}
function sQ(e, t, n, i, r, s) {
  const o = new Float64Array(e * t);
  return s.forEach((a, c) => {
    const [l, u] = r[c], f = l * e - n, h = u * t - i;
    oQ(e, t, o, a, f, h);
  }), o;
}
function oQ(e, t, n, i, r, s) {
  const o = i.numRows;
  if (o === 0)
    return;
  const a = i.getChild("index").toArray(), c = i.getChild("value").toArray();
  for (let l = 0; l < o; ++l) {
    const u = a[l], f = r + u % e, h = s + Math.floor(u / e);
    0 <= f && f < e && 0 <= h && h < t && (n[f + h * e] = c[l]);
  }
}
function aQ(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const i = J8(t, n), r = i.getContext("2d", { willReadFrequently: !0 }), s = r.getImageData(0, 0, t, n);
    e.image = { canvas: i, ctx: r, img: s, w: t, h: n };
  }
  return e.image;
}
function cQ(e) {
  const { densityMap: t, kde: n, plot: i } = e;
  let r = t.fill && i.getAttribute("colorDomain");
  if (!r) {
    let o = 0, a = 0;
    n.forEach((c) => {
      for (const l of c)
        l < o && (o = l), l > a && (a = l);
    }), r = o === 0 && a === 0 ? [0, 1] : [o, a];
  }
  const s = i.getAttribute("colorScale");
  return Qo({ x: { type: s, domain: r, range: [0, 1] } }).apply;
}
function lQ(e, t, n, i = 1024) {
  const { densityMap: r, plot: s } = e, o = s.getAttribute("colorScheme");
  let a;
  if (r.fill) {
    if (o)
      try {
        return gp(
          i,
          Qo({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (c) {
        console.warn(c);
      }
  } else if (t.length) {
    const c = s.getAttribute("colorRange");
    a = Qo({ color: {
      domain: t,
      range: c,
      scheme: o || (c ? void 0 : "tableau10")
    } }).apply(n);
  } else {
    const c = e.channelField("fill");
    a = G_(c == null ? void 0 : c.value) ? c.value : void 0;
  }
  return gp(i, Z8(a));
}
function zx(e, t, n, i, r, s) {
  const o = (i - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return r ? q`(${n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${t})${a}`;
}
function uQ(e, t, n, i, r, s) {
  return e.select({
    index: q`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${r}`,
    value: i
  }).groupby("index", s);
}
function fQ(e, t, n, i, r, s) {
  const o = i.column ? `* ${i.column}` : "", a = (h, d) => e.clone().select({ xp: t, yp: n, i: h, w: d }), c = a(
    q`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${r}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), l = a(
    q`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${r}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), u = a(
    q`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${r}`,
    q`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), f = a(
    q`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${r}`,
    q`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return Et.from(Et.unionAll(c, l, u, f)).select({ index: "i", value: ta("w") }, s).groupby("index", s).having(iE("value", 0));
}
function Px(e) {
  const t = Math.floor(e);
  return t === e ? t - 1 : t;
}
function hQ(e, t, n) {
  var i = 1e-8, r = t - 1, s = n - 1, o = 0, a, c, l, u, f, h, d, p, y, g, m;
  if (e <= 0)
    return 0;
  if (e >= 1)
    return 1;
  for (t >= 1 && n >= 1 ? (l = e < 0.5 ? e : 1 - e, u = Math.sqrt(-2 * Math.log(l)), d = (2.30753 + u * 0.27061) / (1 + u * (0.99229 + u * 0.04481)) - u, 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)), u = Math.exp(t * a) / t, f = Math.exp(n * c) / n, g = u + f, e < u / g ? d = Math.pow(t * g * e, 1 / t) : d = 1 - Math.pow(n * g * (1 - e), 1 / n)), m = -nc(t) - nc(n) + nc(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = dQ(d, t, n) - e, u = Math.exp(r * Math.log(d) + s * Math.log(1 - d) + m), f = h / u, d -= u = f / (1 - 0.5 * Math.min(1, f * (r / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + u)), d >= 1 && (d = 0.5 * (d + u + 1)), Math.abs(u) < i * d && o > 0)
      break;
  }
  return d;
}
function dQ(e, t, n) {
  var i = e === 0 || e === 1 ? 0 : Math.exp(nc(t + n) - nc(t) - nc(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? i * Vx(e, t, n) / t : 1 - i * Vx(1 - e, n, t) / n;
}
function Vx(e, t, n) {
  var i = 1e-30, r = 1, s = t + n, o = t + 1, a = t - 1, c = 1, l = 1 - s * e / o, u, f, h, d;
  for (Math.abs(l) < i && (l = i), l = 1 / l, d = l; r <= 100 && (u = 2 * r, f = r * (n - r) * e / ((a + u) * (t + u)), l = 1 + f * l, Math.abs(l) < i && (l = i), c = 1 + f / c, Math.abs(c) < i && (c = i), l = 1 / l, d *= l * c, f = -(t + r) * (s + r) * e / ((t + u) * (o + u)), l = 1 + f * l, Math.abs(l) < i && (l = i), c = 1 + f / c, Math.abs(c) < i && (c = i), l = 1 / l, h = l * c, d *= h, !(Math.abs(h - 1) < 3e-7)); r++)
    ;
  return d;
}
function nc(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], i = 1.000000000190015, r, s, o;
  for (o = (s = r = e) + 5.5, o -= (r + 0.5) * Math.log(o); t < 6; t++)
    i += n[t] / ++s;
  return Math.log(2.506628274631 * i / r) - o;
}
function pQ(e, t) {
  var n = hQ(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 yQ extends rl {
  constructor(t, n) {
    const { ci: i = 0.95, precision: r = 4, ...s } = n;
    super("line", t, s);
    const o = () => this.modelFit ? this.confidenceBand().update() : null;
    Qn(this, "ci", i, o), Qn(this, "precision", r, o);
  }
  query(t = []) {
    const n = this.channelField("x").as, i = this.channelField("y").as, r = Array.from(new Set(
      ["stroke", "z", "fx", "fy"].flatMap((s) => {
        var o;
        return ((o = this.channelField(s)) == null ? void 0 : o.as) || [];
      })
    ));
    return Et.from(super.query(t)).select({
      intercept: AE(i, n),
      slope: ME(i, n),
      n: TE(i, n),
      ssy: BE(i, n),
      ssx: NE(i, n),
      xm: FE(i, n),
      x0: tv(gc(n).where(ud(i))),
      x1: tv(mc(n).where(ud(i)))
    }).select(r).groupby(r);
  }
  queryResult(t) {
    return this.modelFit = Array.from(t), this.lineData = this.modelFit.flatMap((n) => mQ(n)), this.confidenceBand();
  }
  confidenceBand() {
    const { ci: t, modelFit: n, precision: i, plot: r } = this, s = r.innerWidth();
    return this.areaData = t ? n.flatMap((o) => gQ(t, i, o, s)) : null, this;
  }
  plotSpecs() {
    const { lineData: t, areaData: n, channels: i, ci: r } = this, s = { x: "x", y: "y" }, o = { x: "x", y1: "y1", y2: "y2", fillOpacity: 0.1 };
    for (const a of i)
      switch (a.channel) {
        case "x":
        case "y":
        case "fill":
          break;
        case "stroke":
          s.stroke = o.fill = Ns(a);
          break;
        case "strokeOpacity":
          s.strokeOpacity = Ns(a);
          break;
        case "fillOpacity":
          o.fillOpacity = Ns(a);
          break;
        default:
          s[a.channel] = o[a.channel] = Ns(a);
          break;
      }
    return [
      ...r ? [{ type: "areaY", data: n, options: o }] : [],
      { type: "line", data: t, options: s }
    ];
  }
}
function mQ(e) {
  const { x0: t, x1: n, xm: i, intercept: r, slope: s, n: o, ssx: a, ssy: c, ...l } = e;
  return [
    { x: t, y: r + t * s, ...l },
    { x: n, y: r + n * s, ...l }
  ];
}
function gQ(e, t, n, i) {
  const { x0: r, x1: s, xm: o, intercept: a, slope: c, n: l, ssx: u, ssy: f, ...h } = n, d = t * (s - r) / i, p = pQ((1 - e) / 2, l - 2) * Math.sqrt(f / (l - 2));
  return Bn(r, s - d / 2, d).concat(s).map((y) => {
    const g = a + y * c, m = p * Math.sqrt(1 / l + (y - o) ** 2 / u);
    return { x: y, y1: g - m, y2: g + m, ...h };
  });
}
const bQ = /* @__PURE__ */ new Set([
  "frame",
  "axisX",
  "axisY",
  "axisFx",
  "axisFy",
  "gridX",
  "gridY",
  "gridFx",
  "gridFy",
  "hexgrid",
  "graticule",
  "sphere"
]);
function st(e, t, n) {
  arguments.length === 2 && (n = t, t = bQ.has(e) ? null : [{}]);
  const i = e.startsWith("area") || e.startsWith("line") ? LZ : rl;
  return X_(i, e, t, n);
}
function X_(e, t, n, i) {
  return (r) => {
    r.addMark(new e(t, n, i));
  };
}
function ra(e, t, n) {
  return (i) => {
    i.addMark(new e(t, n));
  };
}
const _Q = (...e) => st("area", ...e), wQ = (...e) => st("areaX", ...e), vQ = (...e) => st("areaY", ...e), xQ = (...e) => st("line", ...e), SQ = (...e) => st("lineX", ...e), IQ = (...e) => st("lineY", ...e), $Q = (...e) => st("barX", ...e), AQ = (...e) => st("barY", ...e), MQ = (...e) => st("cell", ...e), TQ = (...e) => st("cellX", ...e), BQ = (...e) => st("cellY", ...e), NQ = (...e) => st("rect", ...e), FQ = (...e) => st("rectX", ...e), DQ = (...e) => st("rectY", ...e), OQ = (...e) => st("dot", ...e), EQ = (...e) => st("dotX", ...e), LQ = (...e) => st("dotY", ...e), RQ = (...e) => st("circle", ...e), CQ = (...e) => st("hexagon", ...e), kQ = (...e) => st("text", ...e), UQ = (...e) => st("textX", ...e), zQ = (...e) => st("textY", ...e), PQ = (...e) => st("ruleX", ...e), VQ = (...e) => st("ruleY", ...e), jQ = (...e) => st("tickX", ...e), YQ = (...e) => st("tickY", ...e), qQ = (...e) => st("vector", ...e), WQ = (...e) => st("vectoX", ...e), GQ = (...e) => st("vectorY", ...e), XQ = (...e) => st("spike", ...e), HQ = (...e) => st("image", ...e), KQ = (...e) => X_(H8, "areaX", ...e), JQ = (...e) => X_(H8, "areaY", ...e), ZQ = (...e) => ra(GZ, ...e), QQ = (...e) => ra(ZZ, ...e), ttt = (...e) => ra(eQ, ...e), ett = (...e) => ra(Q8, ...e), ntt = (...e) => ra(rQ, ...e), itt = (...e) => ra(iQ, ...e), rtt = (...e) => st("hexgrid", ...e), stt = (...e) => ra(yQ, ...e), ott = (...e) => st("voronoi", ...e), att = (...e) => st("voronoiMesh", ...e), ctt = (...e) => st("delaunayLink", ...e), ltt = (...e) => st("delaunayMesh", ...e), utt = (...e) => st("hull", ...e), ftt = (...e) => st("arrow", ...e), htt = (...e) => st("link", ...e), dtt = (...e) => st("frame", ...e), ptt = (...e) => st("axisX", ...e), ytt = (...e) => st("axisY", ...e), mtt = (...e) => st("axisFx", ...e), gtt = (...e) => st("axisFy", ...e), btt = (...e) => st("gridX", ...e), _tt = (...e) => st("gridY", ...e), wtt = (...e) => st("gridFx", ...e), vtt = (...e) => st("gridFy", ...e), xtt = (...e) => st("geo", ...e), Stt = (...e) => st("sphere", ...e), Itt = (...e) => st("graticule", ...e), $tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  area: _Q,
  areaX: wQ,
  areaY: vQ,
  arrow: ftt,
  axisFx: mtt,
  axisFy: gtt,
  axisX: ptt,
  axisY: ytt,
  barX: $Q,
  barY: AQ,
  cell: MQ,
  cellX: TQ,
  cellY: BQ,
  circle: RQ,
  contour: ttt,
  delaunayLink: ctt,
  delaunayMesh: ltt,
  denseLine: QQ,
  density: ZQ,
  densityX: KQ,
  densityY: JQ,
  dot: OQ,
  dotX: EQ,
  dotY: LQ,
  frame: dtt,
  geo: xtt,
  graticule: Itt,
  gridFx: wtt,
  gridFy: vtt,
  gridX: btt,
  gridY: _tt,
  hexagon: CQ,
  hexbin: itt,
  hexgrid: rtt,
  hull: utt,
  image: HQ,
  line: xQ,
  lineX: SQ,
  lineY: IQ,
  link: htt,
  raster: ett,
  rasterTile: ntt,
  rect: NQ,
  rectX: FQ,
  rectY: DQ,
  regressionY: stt,
  ruleX: PQ,
  ruleY: VQ,
  sphere: Stt,
  spike: XQ,
  text: kQ,
  textX: UQ,
  textY: zQ,
  tickX: jQ,
  tickY: YQ,
  vector: qQ,
  vectorX: WQ,
  vectorY: GQ,
  voronoi: ott,
  voronoiMesh: att
}, Symbol.toStringTag, { value: "Module" }));
function Att(e) {
  const t = e.toLowerCase(), n = e.length;
  let i = "";
  for (let r = 0; r < n; ++r)
    i += (e[r] !== t[r] ? "-" : "") + t[r];
  return i;
}
function H_(e) {
  const t = {};
  for (const n in e)
    t[Att(n)] = e[n];
  return t;
}
class Mtt {
  constructor(t, {
    selection: n,
    channels: i = {}
  }) {
    this.mark = t, this.selection = n;
    const r = Object.entries(H_(i));
    this.channels = r.length ? r : [["opacity", 0.2]], this.selection.addEventListener("value", _3(() => this.update()));
  }
  init(t) {
    this.svg = t;
    const n = this.values = [], i = this.mark.index, r = this.nodes = t.querySelectorAll(`[data-index="${i}"] > *`), { channels: s } = this;
    for (let o = 0; o < r.length; ++o) {
      const a = r[o];
      n.push(s.map((c) => a.getAttribute(c[0])));
    }
    return this.update();
  }
  async update() {
    const { svg: t, nodes: n, channels: i, values: r, mark: s, selection: o } = this;
    if (!t)
      return;
    const a = await Ttt(s, o);
    for (let c = 0; c < n.length; ++c) {
      const l = n[c], u = r[c], f = a(l.__data__);
      for (let h = 0; h < i.length; ++h) {
        const [d, p] = i[h];
        l.setAttribute(d, f ? u[h] : p);
      }
    }
  }
}
async function Ttt(e, t) {
  var c, l;
  const n = t == null ? void 0 : t.predicate(e);
  if (!n || n.length === 0)
    return () => !0;
  const i = { __: Vo(n) }, r = e.query((c = e.filterBy) == null ? void 0 : c.predicate(e)), s = r.groupby().length ? r.select(i) : r.$select(i), o = await pi().query(s), a = (l = o.getChild) == null ? void 0 : l.call(o, "__");
  return a ? (u) => a.get(u) : (u) => o[u].__;
}
class tB {
  constructor(t, {
    selection: n,
    channels: i
  }) {
    this.value = null, this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.channels = i.map((r) => {
      var o;
      const s = r === "color" ? ["fill", "stroke"] : r === "x" ? ["x", "x1", "x2"] : r === "y" ? ["y", "y1", "y2"] : [r];
      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: ${r}`);
    });
  }
  clause(t) {
    const { channels: n, clients: i } = this;
    let r = null;
    if (t) {
      const s = t.map((o) => {
        const a = o.map((c, l) => ty(n[l].field, ju(c)));
        return a.length > 1 ? Vo(a) : a[0];
      });
      r = s.length > 1 ? f3(s) : s[0];
    }
    return {
      source: this,
      schema: { type: "point" },
      clients: i,
      value: t,
      predicate: r
    };
  }
  init(t, n, i) {
    const { mark: r, channels: s, selection: o } = this, { data: a } = r;
    i = i || ((l) => {
      const u = a[l.__data__];
      return s.map((f) => u[f.as]);
    }), n = n || `[data-index="${r.index}"]`;
    const c = new Set(t.querySelectorAll(n));
    t.addEventListener("pointerdown", (l) => {
      const u = o.single ? o.value : this.value, f = l.target;
      let h = null;
      if (Btt(c, f)) {
        const d = i(f);
        l.shiftKey && (u != null && u.length) ? (h = u.filter((p) => Zg(p, d)), h.length === u.length && h.push(d)) : (u == null ? void 0 : u.length) === 1 && !Zg(u[0], d) ? h = null : h = [d];
      }
      this.value = h, Ntt(u, h) && o.update(this.clause(h));
    }), t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause([this.channels.map(() => 0)]));
    });
  }
}
function Btt(e, t) {
  var n;
  return e.has(t) || e.has(t.parentNode) || e.has((n = t.parentNode) == null ? void 0 : n.parentNode);
}
function Ntt(e, t) {
  return e == null || t == null ? e != null || t != null : e.length !== t.length || e.some((n, i) => Zg(n, t[i]));
}
function Zg(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !0;
  for (let i = 0; i < n; ++i)
    if (e[i] !== t[i])
      return !0;
  return !1;
}
function K_(e) {
  const t = e.on;
  let n = !0;
  function i(r) {
    n = !1, r(), n = !0;
  }
  return e.reset = (...r) => {
    i(() => e.clear(...r));
  }, e.moveSilent = (...r) => {
    i(() => e.move(...r));
  }, e.on = (...r) => {
    if (r.length > 1 && r[1]) {
      const s = r[1];
      r[1] = (...o) => n && s(...o);
    }
    return t(...r);
  }, e;
}
function Ftt() {
  return K_(gk());
}
function Dtt() {
  return K_(yk());
}
function Ott() {
  return K_(mk());
}
const jx = 1e-12;
function Qg(e, t) {
  return e === t || e && t && Math.abs(e[0] - t[0]) < jx && Math.abs(e[1] - t[1]) < jx || !1;
}
function Oc(e, t) {
  var i;
  const n = (i = e.channelField(t)) == null ? void 0 : i.field;
  return (n == null ? void 0 : n.basis) || n;
}
function t1(e, t, n = 1) {
  return t.invert(n * Math.floor(e / n));
}
function eB() {
  const e = this, t = e.getScreenCTM;
  let n;
  e.getScreenCTM = () => e.isConnected ? n = t.call(e) : n;
}
class nB {
  constructor(t, {
    channel: n,
    selection: i,
    field: r,
    pixelSize: s = 1,
    peers: o = !0,
    brush: a
  }) {
    this.mark = t, this.channel = n, this.pixelSize = s || 1, this.selection = i, this.peers = o, this.field = r || Oc(t, [n, n + "1", n + "2"]), this.style = a && H_(a), this.brush = n === "y" ? Ott() : Dtt(), 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((i) => t1(i, this.scale, this.pixelSize)).sort((i, r) => i - r)), Qg(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: i, field: r, scale: s } = this;
    return {
      source: this,
      schema: { type: "interval", pixelSize: i, scales: [s] },
      clients: this.peers ? n.plot.markSet : (/* @__PURE__ */ new Set()).add(n),
      value: t,
      predicate: t ? Dn(r, t) : null
    };
  }
  init(t) {
    var l;
    const { brush: n, channel: i, style: r } = this;
    this.scale = t.scale(i);
    const s = t.scale("x").range, o = t.scale("y").range;
    n.extent([[ze(s), ze(o)], [Se(s), Se(o)]]);
    const a = re(t).selectAll('g[aria-label="facet"]'), c = a.size() ? a : re(t);
    if (this.g = c.append("g").attr("class", `interval-${i}`).each(eB).call(n).call(n.moveSilent, (l = this.value) == null ? void 0 : l.map(this.scale.apply)), r) {
      const u = this.g.selectAll("rect.selection");
      for (const f in r)
        u.attr(f, r[f]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
const sh = (e, t) => e - t;
class Ett {
  constructor(t, {
    selection: n,
    xfield: i,
    yfield: r,
    pixelSize: s = 1,
    peers: o = !0,
    brush: a
  }) {
    this.mark = t, this.pixelSize = s || 1, this.selection = n, this.peers = o, this.xfield = i || Oc(t, ["x", "x1", "x2"]), this.yfield = r || Oc(t, ["y", "y1", "y2"]), this.style = a && H_(a), this.brush = Ftt(), 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: i, xscale: r, yscale: s } = this;
    let o, a;
    if (t) {
      const [c, l] = t;
      o = [c[0], l[0]].map((u) => t1(u, r, i)).sort(sh), a = [c[1], l[1]].map((u) => t1(u, s, i)).sort(sh);
    }
    (!Qg(o, n == null ? void 0 : n[0]) || !Qg(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: i, xfield: r, yfield: s, xscale: o, yscale: a } = this;
    return {
      source: this,
      schema: { type: "interval", pixelSize: i, scales: [o, a] },
      clients: this.peers ? n.plot.markSet : (/* @__PURE__ */ new Set()).add(n),
      value: t,
      predicate: t ? Vo(Dn(r, t[0]), Dn(s, t[1])) : null
    };
  }
  init(t) {
    const { brush: n, style: i } = this, r = this.xscale = t.scale("x"), s = this.yscale = t.scale("y"), o = r.range, a = s.range;
    n.extent([[ze(o), ze(a)], [Se(o), Se(a)]]);
    const c = re(t).selectAll('g[aria-label="facet"]'), l = c.size() ? c : re(t);
    if (this.g = l.append("g").attr("class", "interval-xy").each(eB).call(n), i) {
      const u = this.g.selectAll("rect.selection");
      for (const f in i)
        u.attr(f, i[f]);
    }
    if (this.value) {
      const [u, f] = this.value[0].map(r.apply).sort(sh), [h, d] = this.value[1].map(s.apply).sort(sh);
      this.g.call(n.moveSilent, [[u, h], [f, d]]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
const Yx = (e, t) => e - t;
class Ltt {
  constructor(t, {
    x: n = new Ts(),
    y: i = new Ts(),
    xfield: r,
    yfield: s,
    zoom: o = !0,
    panx: a = !0,
    pany: c = !0
  }) {
    this.mark = t, this.xsel = n, this.ysel = i, this.xfield = r || Oc(t, ["x", "x1", "x2"]), this.yfield = s || Oc(t, ["y", "y1", "y2"]), this.zoom = gm(o, [0, 1 / 0], [1, 1]), this.panx = this.xsel && a, this.pany = this.ysel && c;
    const { plot: l } = t;
    a && this.xsel.addEventListener("value", (u) => {
      l.setAttribute("xDomain", u) && l.update();
    }), c && this.ysel.addEventListener("value", (u) => {
      l.setAttribute("yDomain", u) && l.update();
    });
  }
  publish(t) {
    if (this.panx) {
      const n = Rtt(t, this.xscale);
      this.xsel.update(this.clause(n, this.xfield, this.xscale));
    }
    if (this.pany) {
      const n = Ctt(t, this.yscale);
      this.ysel.update(this.clause(n, this.yfield, this.yscale));
    }
  }
  clause(t, n, i) {
    return {
      source: this,
      schema: { type: "interval", scales: [i] },
      clients: this.mark.plot.markSet,
      value: t,
      predicate: t ? Dn(n, t) : null
    };
  }
  init(t) {
    if (this.svg = t, this.initialized)
      return;
    this.initialized = !0;
    const { panx: n, pany: i, mark: { plot: { element: r } }, xsel: s, ysel: o } = this;
    this.xscale = t.scale("x"), this.yscale = t.scale("y");
    const a = this.xscale.range.slice().sort(Yx), c = this.yscale.range.slice().sort(Yx), l = gm(n, [-1 / 0, 1 / 0], a), u = gm(i, [-1 / 0, 1 / 0], c), f = lV().extent([[a[0], c[0]], [a[1], c[1]]]).scaleExtent(this.zoom).translateExtent([[l[0], u[0]], [l[1], u[1]]]).on("start", () => {
      this.xscale = this.svg.scale("x"), this.yscale = this.svg.scale("y");
    }).on("end", () => r.__zoom = new Zi(1, 0, 0)).on("zoom", ({ transform: h }) => this.publish(h));
    if (re(r).call(f), n || i) {
      let h = !1;
      r.addEventListener("mouseenter", () => {
        if (!h) {
          if (h = !0, n) {
            const { xscale: d, xfield: p } = this;
            s.activate(this.clause(d.domain, p, d));
          }
          if (i) {
            const { yscale: d, yfield: p } = this;
            o.activate(this.clause(d.domain, p, d));
          }
        }
      }), r.addEventListener("mouseleave", () => h = !1);
    }
  }
}
function gm(e, t, n) {
  return e ? Array.isArray(e) ? e : t : n;
}
function Rtt(e, t) {
  return t.range.map(e.invertX, e).map(t.invert, t);
}
function Ctt(e, t) {
  return t.range.map(e.invertY, e).map(t.invert, t);
}
class iB {
  constructor(t, {
    selection: n,
    channel: i,
    field: r
  }) {
    this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.channel = i, this.field = r || Oc(t, [i]);
  }
  clause(t) {
    const { clients: n, field: i } = this, r = t ? ty(i, ju(t)) : null;
    return {
      source: this,
      schema: { type: "point" },
      clients: n,
      value: t,
      predicate: r
    };
  }
  init(t) {
    const n = this, { mark: i, channel: r, selection: s } = this, { data: o } = i, a = i.channelField(r).as, c = re(t).selectAll('g[aria-label="facet"]'), l = c.size() ? c : re(t), u = t.scale(r), f = !jo(s);
    l.on("pointerdown pointermove", function(h) {
      const [d, p] = ai(h, this), y = ktt(o, a, u.invert(r === "x" ? d : p));
      s.update(f ? y : n.clause(y));
    }), !f && t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause(0));
    });
  }
}
function ktt(e, t, n) {
  let i = 1 / 0, r;
  return e.forEach((s) => {
    const o = Math.abs(s[t] - n);
    o < i && (i = o, r = s[t]);
  }), r;
}
function oo(e, t) {
  return (n) => {
    const i = n.marks[n.marks.length - 1];
    n.addInteractor(new e(i, t));
  };
}
function Utt({ by: e, ...t }) {
  return oo(Mtt, { selection: e, channels: t });
}
function a0({ as: e, ...t }) {
  return oo(tB, { ...t, selection: e });
}
function ztt({ as: e }) {
  return a0({ as: e, channels: ["x"] });
}
function Ptt({ as: e }) {
  return a0({ as: e, channels: ["y"] });
}
function Vtt({ as: e }) {
  return a0({ as: e, channels: ["color"] });
}
function jtt({ as: e, ...t }) {
  return oo(iB, { ...t, selection: e, channel: "x" });
}
function Ytt({ as: e, ...t }) {
  return oo(iB, { ...t, selection: e, channel: "y" });
}
function qtt({ as: e, ...t }) {
  return oo(nB, { ...t, selection: e, channel: "x" });
}
function Wtt({ as: e, ...t }) {
  return oo(nB, { ...t, selection: e, channel: "y" });
}
function Gtt({ as: e, ...t }) {
  return oo(Ett, { ...t, selection: e });
}
function sl(e) {
  return oo(Ltt, e);
}
function Xtt(e = {}) {
  return sl({ ...e, zoom: !1 });
}
function Htt(e = {}) {
  return sl({ ...e, zoom: !1, pany: !1 });
}
function Ktt(e = {}) {
  return sl({ ...e, zoom: !1, panx: !1 });
}
function Jtt(e = {}) {
  return sl(e);
}
function Ztt(e = {}) {
  return sl({ ...e, pany: !1 });
}
function Qtt(e = {}) {
  return sl({ ...e, panx: !1 });
}
const tet = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  highlight: Utt,
  intervalX: qtt,
  intervalXY: Gtt,
  intervalY: Wtt,
  nearestX: jtt,
  nearestY: Ytt,
  pan: Xtt,
  panX: Htt,
  panY: Ktt,
  panZoom: Jtt,
  panZoomX: Ztt,
  panZoomY: Qtt,
  toggle: a0,
  toggleColor: Vtt,
  toggleX: ztt,
  toggleY: Ptt
}, Symbol.toStringTag, { value: "Module" }));
class qx {
  constructor(t, n) {
    const { as: i, ...r } = n;
    this.channel = t, this.options = { label: null, ...r }, this.selection = i, this.element = document.createElement("div"), this.element.setAttribute("class", "legend"), this.element.value = this;
  }
  setPlot(t) {
    const { channel: n, selection: i } = this, r = eet(t, n);
    this.selection && r && (this.handler = new tB(r, { selection: i, channels: [n] }), this.selection.addEventListener("value", () => this.update()));
  }
  init(t) {
    const { channel: n, options: i, handler: r } = this, o = t.scale(n).type === "ordinal" ? i : { marginTop: 1, tickSize: 2, height: 28, ...i };
    return this.legend = t.legend(n, o), r && (r.init(this.legend, ":scope > div", (a) => [a.__data__]), this.update()), this.element.replaceChildren(this.legend), this.element;
  }
  update() {
    if (!this.legend)
      return;
    const { value: t } = this.selection, n = t && t.length ? new Set(t.map((r) => r[0])) : null, i = this.legend.querySelectorAll(":scope > div");
    for (const r of i) {
      const s = n ? n.has(r.__data__) : !0;
      r.style.opacity = s ? 1 : 0.2;
    }
  }
}
function eet({ marks: e }, t) {
  const n = t === "color" ? ["fill", "stroke"] : t === "opacity" ? ["opacity", "fillOpacity", "strokeOpacity"] : null;
  if (n == null)
    return null;
  for (let i = e.length - 1; i > -1; --i)
    if (e[i].channelField(n))
      return e[i];
  return null;
}
function J_(e, t = {}) {
  if (t.for) {
    const { for: n, ...i } = t, r = new qx(e, i), s = typeof n, o = (a) => a.addLegend(r, !1);
    return s === "string" ? q_.request(n, o) : n.value && o(n.value), r.element;
  } else
    return (n) => n.addLegend(new qx(e, t));
}
const net = (e) => J_("color", e), iet = (e) => J_("opacity", e), ret = (e) => J_("symbol", e), set = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  colorLegend: net,
  opacityLegend: iet,
  symbolLegend: ret
}, Symbol.toStringTag, { value: "Module" }));
function rB({ direction: e = "vertical", wrap: t = !1 }, n) {
  const i = document.createElement("div");
  return i.style.display = "flex", i.style.flexDirection = e === "vertical" ? "column" : "row", i.style.flexWrap = t ? t === !0 ? "wrap" : t : "nowrap", i.style.justifyContent = "flex-start", i.style.alignItems = "flex-start", n.forEach((r) => i.appendChild(r)), i.value = { element: i }, i;
}
function oet(...e) {
  return rB({ direction: "vertical" }, e.flat());
}
function aet(...e) {
  return rB({ direction: "horizontal" }, e.flat());
}
function sB({ 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 i = { element: n };
  return n.value = i, n;
}
function cet(e) {
  return sB({ dim: "height", size: e });
}
function uet(e) {
  return sB({ dim: "width", size: e });
}
function fet(e) {
  return e;
}
function het(e) {
  if (e == null)
    return fet;
  var t, n, i = e.scale[0], r = e.scale[1], s = e.translate[0], o = e.translate[1];
  return function(a, c) {
    c || (t = n = 0);
    var l = 2, u = a.length, f = new Array(u);
    for (f[0] = (t += a[0]) * i + s, f[1] = (n += a[1]) * r + o; l < u; )
      f[l] = a[l], ++l;
    return f;
  };
}
function det(e, t) {
  for (var n, i = e.length, r = i - t; r < --i; )
    n = e[r], e[r++] = e[i], e[i] = n;
}
function pet(e, t) {
  return typeof t == "string" && (t = e.objects[t]), t.type === "GeometryCollection" ? { type: "FeatureCollection", features: t.geometries.map(function(n) {
    return Wx(e, n);
  }) } : Wx(e, t);
}
function Wx(e, t) {
  var n = t.id, i = t.bbox, r = t.properties == null ? {} : t.properties, s = oB(e, t);
  return n == null && i == null ? { type: "Feature", properties: r, geometry: s } : i == null ? { type: "Feature", id: n, properties: r, geometry: s } : { type: "Feature", id: n, bbox: i, properties: r, geometry: s };
}
function oB(e, t) {
  var n = het(e.transform), i = e.arcs;
  function r(u, f) {
    f.length && f.pop();
    for (var h = i[u < 0 ? ~u : u], d = 0, p = h.length; d < p; ++d)
      f.push(n(h[d], d));
    u < 0 && det(f, p);
  }
  function s(u) {
    return n(u);
  }
  function o(u) {
    for (var f = [], h = 0, d = u.length; h < d; ++h)
      r(u[h], f);
    return f.length < 2 && f.push(f[0]), f;
  }
  function a(u) {
    for (var f = o(u); f.length < 4; )
      f.push(f[0]);
    return f;
  }
  function c(u) {
    return u.map(a);
  }
  function l(u) {
    var f = u.type, h;
    switch (f) {
      case "GeometryCollection":
        return { type: f, geometries: u.geometries.map(l) };
      case "Point":
        h = s(u.coordinates);
        break;
      case "MultiPoint":
        h = u.coordinates.map(s);
        break;
      case "LineString":
        h = o(u.arcs);
        break;
      case "MultiLineString":
        h = u.arcs.map(o);
        break;
      case "Polygon":
        h = c(u.arcs);
        break;
      case "MultiPolygon":
        h = u.arcs.map(c);
        break;
      default:
        return null;
    }
    return { type: f, coordinates: h };
  }
  return l(t);
}
function yet(e, t) {
  var n = {}, i = {}, r = {}, s = [], o = -1;
  t.forEach(function(l, u) {
    var f = e.arcs[l < 0 ? ~l : l], h;
    f.length < 3 && !f[1][0] && !f[1][1] && (h = t[++o], t[o] = l, t[u] = h);
  }), t.forEach(function(l) {
    var u = a(l), f = u[0], h = u[1], d, p;
    if (d = r[f])
      if (delete r[d.end], d.push(l), d.end = h, p = i[h]) {
        delete i[p.start];
        var y = p === d ? d : d.concat(p);
        i[y.start = d.start] = r[y.end = p.end] = y;
      } else
        i[d.start] = r[d.end] = d;
    else if (d = i[h])
      if (delete i[d.start], d.unshift(l), d.start = f, p = r[f]) {
        delete r[p.end];
        var g = p === d ? d : p.concat(d);
        i[g.start = p.start] = r[g.end = d.end] = g;
      } else
        i[d.start] = r[d.end] = d;
    else
      d = [l], i[d.start = f] = r[d.end = h] = d;
  });
  function a(l) {
    var u = e.arcs[l < 0 ? ~l : l], f = u[0], h;
    return e.transform ? (h = [0, 0], u.forEach(function(d) {
      h[0] += d[0], h[1] += d[1];
    })) : h = u[u.length - 1], l < 0 ? [h, f] : [f, h];
  }
  function c(l, u) {
    for (var f in l) {
      var h = l[f];
      delete u[h.start], delete h.start, delete h.end, h.forEach(function(d) {
        n[d < 0 ? ~d : d] = 1;
      }), s.push(h);
    }
  }
  return c(r, i), c(i, r), t.forEach(function(l) {
    n[l < 0 ? ~l : l] || s.push([l]);
  }), s;
}
function met(e) {
  return oB(e, get.apply(this, arguments));
}
function get(e, t, n) {
  var i, r, s;
  if (arguments.length > 1)
    i = bet(e, t, n);
  else
    for (r = 0, i = new Array(s = e.arcs.length); r < s; ++r)
      i[r] = r;
  return { type: "MultiLineString", arcs: yet(e, i) };
}
function bet(e, t, n) {
  var i = [], r = [], s;
  function o(f) {
    var h = f < 0 ? ~f : f;
    (r[h] || (r[h] = [])).push({ i: f, g: s });
  }
  function a(f) {
    f.forEach(o);
  }
  function c(f) {
    f.forEach(a);
  }
  function l(f) {
    f.forEach(c);
  }
  function u(f) {
    switch (s = f, f.type) {
      case "GeometryCollection":
        f.geometries.forEach(u);
        break;
      case "LineString":
        a(f.arcs);
        break;
      case "MultiLineString":
      case "Polygon":
        c(f.arcs);
        break;
      case "MultiPolygon":
        l(f.arcs);
        break;
    }
  }
  return u(t), r.forEach(n == null ? function(f) {
    i.push(f[0].i);
  } : function(f) {
    n(f[0].g, f[f.length - 1].g) && i.push(f[0].i);
  }), i;
}
function _et(e) {
  const t = typeof e;
  return t === "object" ? e == null ? void 0 : e.param : t === "string" ? wet(e) : null;
}
function wet(e) {
  return (e == null ? void 0 : e[0]) === "$" ? e.slice(1) : null;
}
function bm(e) {
  return [e].flat();
}
function ic(e) {
  return Array.isArray(e);
}
function aB(e) {
  return e !== null && typeof e == "object" && !ic(e);
}
function Gx(e) {
  const t = typeof e;
  return t === "number" || t === "string";
}
function Os(e) {
  return typeof e == "string";
}
function gf(e) {
  return typeof e == "function";
}
function cr(e, t) {
  throw Object.assign(Error(e), { data: t });
}
function vet(e, t, n) {
  t = xet(t, n);
  const i = n.dataFormats.get(t.type);
  if (i)
    return i(e, t, n);
  cr("Unrecognized data format type.", t);
}
function xet(e, t) {
  return ic(e) && (e = { type: "json", data: e }), Os(e) && (e = { type: "table", query: e }), {
    ...e,
    type: Iet(e),
    file: Aet(e, t)
  };
}
function Iet(e) {
  return e.type || $et(e.file) || "table";
}
function $et(e) {
  const t = e == null ? void 0 : e.lastIndexOf(".");
  return t > 0 ? e.slice(t + 1) : null;
}
function Aet({ file: e }, t) {
  return e && t.baseURL ? new URL(e, t.baseURL).toString() : e;
}
function Met(e, t) {
  const { query: n, type: i, ...r } = t;
  if (n)
    return E1(e, n, r);
}
function Tet(e, t) {
  const { file: n, type: i, ...r } = t;
  return zE(e, n, r);
}
function Bet(e, t) {
  const { file: n, type: i, ...r } = t;
  return kE(e, n, r);
}
function Net(e, t) {
  const { data: n, file: i, type: r, ...s } = t;
  return n ? PE(e, n, s) : UE(e, i, s);
}
const Fet = { menu: B5, search: O5, slider: R5, table: P5 }, Det = /* @__PURE__ */ new Map([
  ["intersect", () => Ts.intersect()],
  ["crossfilter", () => Ts.crossfilter()],
  ["union", () => Ts.union()],
  ["single", () => Ts.single()],
  ["value", ({ date: e, value: t }, n) => Array.isArray(t) ? qr.array(t.map((i) => n.maybeParam(i))) : qr.value(R1(e, t))]
]), Oet = /* @__PURE__ */ new Map([
  ["plot", { type: ic, parse: lB }],
  ["mark", { type: Os, parse: Jet }],
  ["legend", { type: Os, parse: uB }],
  ["hconcat", { type: ic, parse: Ket }],
  ["vconcat", { type: ic, parse: Het }],
  ["hspace", { type: Gx, parse: Wet }],
  ["vspace", { type: Gx, parse: Get }],
  ["input", { type: Os, parse: Xet }]
]), Eet = /* @__PURE__ */ new Map([
  ["csv", Bet],
  ["json", Net],
  ["geojson", jet],
  ["topojson", Yet],
  ["parquet", Tet],
  ["table", Met]
]), Let = /* @__PURE__ */ new Map([
  ["avg", xE],
  ["bin", sv],
  ["count", ko],
  ["dateMonth", OE],
  ["dateMonthDay", EE],
  ["dateDay", LE],
  ["bin", sv],
  ["max", mc],
  ["median", SE],
  ["min", gc],
  ["mode", $E],
  ["quantile", IE],
  ["sum", ta],
  ["row_number", lE],
  ["rank", uE],
  ["dense_rank", fE],
  ["percent_rank", hE],
  ["cume_dist", dE],
  ["ntile", pE],
  ["lag", yE],
  ["lead", mE],
  ["first_value", gE],
  ["last_value", bE],
  ["nth_value", _E]
]), Ret = new Map(Object.entries($tt)), Cet = new Map(Object.entries(Fet)), ket = new Map(Object.entries(set)), Uet = new Map(Object.entries(TZ)), zet = new Map(Object.entries(tet));
function Pet(e, t) {
  return e = Os(e) ? JSON.parse(e) : e, new Vet(t).parse(e);
}
class Vet {
  constructor({
    specParsers: t = Oet,
    paramParsers: n = Det,
    dataFormats: i = Eet,
    transforms: r = Let,
    attributes: s = Uet,
    interactors: o = zet,
    legends: a = ket,
    inputs: c = Cet,
    marks: l = Ret,
    params: u = [],
    datasets: f = [],
    baseURL: h = null
  } = {}) {
    this.specParsers = t, this.paramParsers = n, this.dataFormats = i, this.transforms = r, this.attributes = s, this.interactors = o, this.legends = a, this.inputs = c, this.marks = l, this.params = new Map(u), this.datasets = new Map(f), this.baseURL = h, this.postQueue = [];
  }
  after(t) {
    this.postQueue.push(t);
  }
  maybeParam(t, n = () => qr.value()) {
    const { params: i } = this, r = _et(t);
    if (r) {
      if (i.has(r))
        return i.get(r);
      {
        const s = n();
        return i.set(r, s), s;
      }
    }
    return t;
  }
  maybeSelection(t) {
    return this.maybeParam(t, () => Ts.intersect());
  }
  maybeTransform(t) {
    if (aB(t))
      return t.expr ? int(t, this) : rnt(t, this);
  }
  async parse(t) {
    const { meta: n, data: i = {}, plotDefaults: r = {}, params: s, ...o } = t;
    for (const c in i) {
      const l = await vet(c, i[c], this);
      l != null && l.data ? this.datasets.set(c, l.data) : l && await pi().exec(l);
    }
    this.plotDefaults = Object.keys(r).map((c) => fB(r, c, this));
    for (const c in s)
      this.params.set(c, qet(s[c], this));
    const a = Z_(o, this);
    return this.postQueue.forEach((c) => c()), this.postQueue = [], this.plotDefaults = {}, a;
  }
}
async function cB(e) {
  const { data: t, file: n } = e;
  return t || await fetch(n).then((i) => i.json());
}
async function jet(e, t) {
  return { data: await cB(t) };
}
async function Yet(e, t) {
  const n = await cB(t);
  let i;
  if (t.feature)
    i = pet(n, n.objects[t.feature]);
  else {
    const r = t.mesh ? n.objects[t.mesh] : void 0, s = {
      interior: (o, a) => o !== a,
      exterior: (o, a) => o === a
    }[t.filter];
    i = met(n, r, s);
  }
  return { data: i && i.features || [i] };
}
function qet(e, t) {
  e = aB(e) ? e : { value: e };
  const { select: n = "value" } = e, i = t.paramParsers.get(n);
  return i || cr(`Unrecognized param type: ${n}`, e), i(e, t);
}
function Z_(e, t) {
  for (const [n, { type: i, parse: r }] of t.specParsers) {
    const s = e[n];
    if (s != null) {
      if (i(s))
        return r(e, t);
      cr(`Invalid property type: ${n}`, e);
    }
  }
  cr("Invalid specification.", e);
}
function Wet(e) {
  return uet(e.hspace);
}
function Get(e) {
  return cet(e.vspace);
}
function Xet(e, t) {
  const { input: n, ...i } = e, r = t.inputs.get(n);
  gf(r) || cr(`Unrecognized input: ${n}`, e);
  for (const s in i)
    i[s] = t.maybeSelection(i[s]);
  return r(i);
}
function Het(e, t) {
  return oet(e.vconcat.map((n) => Z_(n, t)));
}
function Ket(e, t) {
  return aet(e.hconcat.map((n) => Z_(n, t)));
}
function lB(e, t) {
  const { plot: n, ...i } = e, r = t.plotDefaults.concat(
    Object.keys(i).map((o) => fB(e, o, t))
  ), s = n.map((o) => Zet(o, t));
  return iH(r, s);
}
function Jet(e, t) {
  return lB({ plot: [e] }, t);
}
function uB(e, t) {
  const { legend: n, ...i } = e, r = `${n}Legend`, s = t.legends.get(r);
  gf(s) || cr(`Unrecognized legend type: ${n}`, e);
  for (const o in i)
    i[o] = t.maybeSelection(i[o]);
  return s(i);
}
function fB(e, t, n) {
  const i = n.attributes.get(t);
  gf(i) || cr(`Unrecognized attribute: ${t}`, e);
  const r = e[t], s = r === "Fixed" ? U1 : n.maybeParam(r);
  return i(s);
}
function Zet(e, t) {
  return Os(e.mark) ? Qet(e, t) : Os(e.legend) ? uB(e, t) : Os(e.select) ? nnt(e, t) : cr("Invalid plot entry.", e);
}
function Qet(e, t) {
  const { mark: n, data: i, ...r } = e, s = t.marks.get(n);
  gf(s) || cr(`Unrecognized mark type: ${n}`, e);
  const o = tnt(i, t);
  for (const a in r)
    r[a] = ent(r[a], t);
  return o ? s(o, r) : s(r);
}
function tnt(e, t) {
  if (!e)
    return null;
  if (ic(e))
    return e;
  const { from: n, ...i } = e;
  if (t.datasets.has(n))
    return t.datasets.get(n);
  for (const r in i)
    i[r] = t.maybeSelection(i[r]);
  return BZ(n, i);
}
function ent(e, t) {
  return t.maybeTransform(e) || t.maybeParam(e);
}
function nnt(e, t) {
  const { select: n, ...i } = e, r = t.interactors.get(n);
  gf(r) || cr(`Unrecognized interactor type: ${n}`, e);
  for (const s in i)
    i[s] = t.maybeSelection(i[s]);
  return r(i);
}
function int(e, t) {
  const { expr: n, label: i } = e, r = n.split(/(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\$\w+)/g), s = [""], o = [];
  for (let a = 0, c = 0; a < r.length; ++a) {
    const l = r[a];
    l.startsWith("$") ? (o[c] = t.maybeParam(l), s[++c] = "") : s[c] += l;
  }
  return q(s, ...o).annotate({ label: i });
}
function rnt(e, t) {
  const { transforms: n } = t;
  let i;
  for (const a in e)
    n.has(a) && (i = a);
  if (!i)
    return;
  const r = n.get(i), s = i === "count" || i == null ? [] : bm(e[i]);
  let o = r(...s);
  if (e.distinct && (o = o.distinct()), e.order) {
    const a = bm(e.order).map((c) => t.maybeParam(c));
    o = o.orderby(a);
  }
  if (e.partition) {
    const a = bm(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;
}
const snt = new TextDecoder("utf-8"), e1 = (e) => snt.decode(e), ont = new TextEncoder(), Q_ = (e) => ont.encode(e), [bf, dot] = (() => {
  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];
})(), [_f, pot] = (() => {
  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];
})(), ant = (e) => typeof e == "number", cnt = (e) => typeof e == "boolean", en = (e) => typeof e == "function", Ii = (e) => e != null && Object(e) === e, Bu = (e) => Ii(e) && en(e.then), c0 = (e) => Ii(e) && en(e[Symbol.iterator]), tw = (e) => Ii(e) && en(e[Symbol.asyncIterator]), n1 = (e) => Ii(e) && Ii(e.schema), hB = (e) => Ii(e) && "done" in e && "value" in e, dB = (e) => Ii(e) && en(e.stat) && ant(e.fd), pB = (e) => Ii(e) && ew(e.body), yB = (e) => "_getDOMStream" in e && "_getNodeStream" in e, ew = (e) => Ii(e) && en(e.cancel) && en(e.getReader) && !yB(e), mB = (e) => Ii(e) && en(e.read) && en(e.pipe) && cnt(e.readable) && !yB(e), lnt = (e) => Ii(e) && en(e.clear) && en(e.bytes) && en(e.position) && en(e.setPosition) && en(e.capacity) && en(e.getBufferIdentifier) && en(e.createLong), nw = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function unt(e) {
  const t = e[0] ? [e[0]] : [];
  let n, i, r, s;
  for (let o, a, c = 0, l = 0, u = e.length; ++c < u; ) {
    if (o = t[l], a = e[c], !o || !a || o.buffer !== a.buffer || a.byteOffset < o.byteOffset) {
      a && (t[++l] = a);
      continue;
    }
    if ({ byteOffset: n, byteLength: r } = o, { byteOffset: i, byteLength: s } = a, n + r < i || i + s < n) {
      a && (t[++l] = a);
      continue;
    }
    t[l] = new Uint8Array(o.buffer, n, i - n + s);
  }
  return t;
}
function Xx(e, t, n = 0, i = t.byteLength) {
  const r = e.byteLength, s = new Uint8Array(e.buffer, e.byteOffset, r), o = new Uint8Array(t.buffer, t.byteOffset, Math.min(i, r));
  return s.set(o, n), e;
}
function lr(e, t) {
  const n = unt(e), i = n.reduce((u, f) => u + f.byteLength, 0);
  let r, s, o, a = 0, c = -1;
  const l = Math.min(t || Number.POSITIVE_INFINITY, i);
  for (const u = n.length; ++c < u; ) {
    if (r = n[c], s = r.subarray(0, Math.min(r.length, l - a)), l <= a + s.length) {
      s.length < r.length ? n[c] = r.subarray(s.length) : s.length === r.length && c++, o ? Xx(o, s, a) : o = s;
      break;
    }
    Xx(o || (o = new Uint8Array(l)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), i - (o ? o.byteLength : 0)];
}
function ie(e, t) {
  let n = hB(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = Q_(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof nw ? new e(n) : lnt(n) ? ie(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 xl = (e) => ie(Int32Array, e), Ht = (e) => ie(Uint8Array, e), i1 = (e) => (e.next(), e);
function* fnt(e, t) {
  const n = function* (r) {
    yield r;
  }, i = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof nw ? n(t) : c0(t) ? t : n(t);
  return yield* i1(function* (r) {
    let s = null;
    do
      s = r.next(yield ie(e, s));
    while (!s.done);
  }(i[Symbol.iterator]())), new e();
}
const hnt = (e) => fnt(Uint8Array, e);
function gB(e, t) {
  return Fe(this, arguments, function* () {
    if (Bu(t))
      return yield W(yield W(yield* Fs(ti(gB(e, yield W(t))))));
    const i = function(o) {
      return Fe(this, arguments, function* () {
        yield yield W(yield W(o));
      });
    }, r = function(o) {
      return Fe(this, arguments, function* () {
        yield W(yield* Fs(ti(i1(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 nw ? i(t) : c0(t) ? r(t) : tw(t) ? t : i(t);
    return yield W(
      // otherwise if AsyncIterable, use it
      yield* Fs(ti(i1(function(o) {
        return Fe(this, arguments, function* () {
          let a = null;
          do
            a = yield W(o.next(yield yield W(ie(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield W(new e());
  });
}
const dnt = (e) => gB(Uint8Array, e);
function pnt(e, t) {
  let n = 0;
  const i = e.length;
  if (i !== t.length)
    return !1;
  if (i > 0)
    do
      if (e[n] !== t[n])
        return !1;
    while (++n < i);
  return !0;
}
const Vn = {
  fromIterable(e) {
    return oh(ynt(e));
  },
  fromAsyncIterable(e) {
    return oh(mnt(e));
  },
  fromDOMStream(e) {
    return oh(gnt(e));
  },
  fromNodeStream(e) {
    return oh(_nt(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');
  }
}, oh = (e) => (e.next(), e);
function* ynt(e) {
  let t, n = !1, i = [], r, s, o, a = 0;
  function c() {
    return s === "peek" ? lr(i, o)[0] : ([r, i, a] = lr(i, o), r);
  }
  ({ cmd: s, size: o } = yield null);
  const l = hnt(e)[Symbol.iterator]();
  try {
    do
      if ({ done: t, value: r } = Number.isNaN(o - a) ? l.next() : l.next(o - a), !t && r.byteLength > 0 && (i.push(r), a += r.byteLength), t || o <= a)
        do
          ({ cmd: s, size: o } = yield c());
        while (o < a);
    while (!t);
  } catch (u) {
    (n = !0) && typeof l.throw == "function" && l.throw(u);
  } finally {
    n === !1 && typeof l.return == "function" && l.return(null);
  }
  return null;
}
function mnt(e) {
  return Fe(this, arguments, function* () {
    let n, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? lr(r, a)[0] : ([s, r, c] = lr(r, a), s);
    }
    ({ cmd: o, size: a } = yield yield W(null));
    const u = dnt(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield W(u.next()) : yield W(u.next(a - c)), !n && s.byteLength > 0 && (r.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield W(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && typeof u.throw == "function" && (yield W(u.throw(f)));
    } finally {
      i === !1 && typeof u.return == "function" && (yield W(u.return(new Uint8Array(0))));
    }
    return yield W(null);
  });
}
function gnt(e) {
  return Fe(this, arguments, function* () {
    let n = !1, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? lr(r, a)[0] : ([s, r, c] = lr(r, a), s);
    }
    ({ cmd: o, size: a } = yield yield W(null));
    const u = new bnt(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield W(u.read()) : yield W(u.read(a - c)), !n && s.byteLength > 0 && (r.push(Ht(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield W(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && (yield W(u.cancel(f)));
    } finally {
      i === !1 ? yield W(u.cancel()) : e.locked && u.releaseLock();
    }
    return yield W(null);
  });
}
class bnt {
  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 Y(this, void 0, void 0, function* () {
      const { reader: n, source: i } = this;
      n && (yield n.cancel(t).catch(() => {
      })), i && i.locked && this.releaseLock();
    });
  }
  read(t) {
    return Y(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 = Ht(n)), n;
    });
  }
}
const _m = (e, t) => {
  const n = (r) => i([t, r]);
  let i;
  return [t, n, new Promise((r) => (i = r) && e.once(t, n))];
};
function _nt(e) {
  return Fe(this, arguments, function* () {
    const n = [];
    let i = "error", r = !1, s = null, o, a, c = 0, l = [], u;
    function f() {
      return o === "peek" ? lr(l, a)[0] : ([u, l, c] = lr(l, a), u);
    }
    if ({ cmd: o, size: a } = yield yield W(null), e.isTTY)
      return yield yield W(new Uint8Array(0)), yield W(null);
    try {
      n[0] = _m(e, "end"), n[1] = _m(e, "error");
      do {
        if (n[2] = _m(e, "readable"), [i, s] = yield W(Promise.race(n.map((d) => d[2]))), i === "error")
          break;
        if ((r = i === "end") || (Number.isFinite(a - c) ? (u = Ht(e.read(a - c)), u.byteLength < a - c && (u = Ht(e.read()))) : u = Ht(e.read()), u.byteLength > 0 && (l.push(u), c += u.byteLength)), r || a <= c)
          do
            ({ cmd: o, size: a } = yield yield W(f()));
          while (a < c);
      } while (!r);
    } finally {
      yield W(h(n, i === "error" ? s : null));
    }
    return yield W(null);
    function h(d, p) {
      return u = l = 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 Gn;
(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";
})(Gn || (Gn = {}));
var $i;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})($i || ($i = {}));
var mn;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(mn || (mn = {}));
var is;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(is || (is = {}));
var Yt;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(Yt || (Yt = {}));
var Gs;
(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";
})(Gs || (Gs = {}));
var Qt;
(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";
})(Qt || (Qt = {}));
var C;
(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";
})(C || (C = {}));
var Fr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(Fr || (Fr = {}));
const wnt = void 0;
function Nu(e) {
  if (e === null)
    return "null";
  if (e === wnt)
    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 bf || e instanceof _f ? `[${[...e].map((t) => Nu(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const vnt = Symbol.for("isArrowBigNum");
function Oi(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(ie(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
Oi.prototype[vnt] = !0;
Oi.prototype.toJSON = function() {
  return `"${bp(this)}"`;
};
Oi.prototype.valueOf = function() {
  return bB(this);
};
Oi.prototype.toString = function() {
  return bp(this);
};
Oi.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return bB(this);
    case "string":
      return bp(this);
    case "default":
      return xnt(this);
  }
  return bp(this);
};
function rc(...e) {
  return Oi.apply(this, e);
}
function sc(...e) {
  return Oi.apply(this, e);
}
function Fu(...e) {
  return Oi.apply(this, e);
}
Object.setPrototypeOf(rc.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(sc.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(Fu.prototype, Object.create(Uint32Array.prototype));
Object.assign(rc.prototype, Oi.prototype, { constructor: rc, signed: !0, TypedArray: Int32Array, BigIntArray: bf });
Object.assign(sc.prototype, Oi.prototype, { constructor: sc, signed: !1, TypedArray: Uint32Array, BigIntArray: _f });
Object.assign(Fu.prototype, Oi.prototype, { constructor: Fu, signed: !0, TypedArray: Uint32Array, BigIntArray: _f });
function bB(e) {
  const { buffer: t, byteOffset: n, length: i, signed: r } = e, s = new _f(t, n, i), o = r && s[s.length - 1] & BigInt(1) << BigInt(63);
  let a = BigInt(o ? 1 : 0), c = BigInt(0);
  if (o) {
    for (const l of s)
      a += ~l * (BigInt(1) << BigInt(32) * c++);
    a *= BigInt(-1);
  } else
    for (const l of s)
      a += l * (BigInt(1) << BigInt(32) * c++);
  return a;
}
const bp = (e) => e.byteLength === 8 ? `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}` : _B(e), xnt = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : _B(e);
function _B(e) {
  let t = "";
  const n = new Uint32Array(2);
  let i = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  const r = new Uint32Array((i = new Uint16Array(i).reverse()).buffer);
  let s = -1;
  const o = i.length - 1;
  do {
    for (n[0] = i[s = 0]; s < o; )
      i[s++] = n[1] = n[0] / 10, n[0] = (n[0] - n[1] * 10 << 16) + i[s];
    i[s] = n[1] = n[0] / 10, n[0] = n[0] - n[1] * 10, t = `${n[0]}${t}`;
  } while (r[0] || r[1] || r[2] || r[3]);
  return t ?? "0";
}
class iw {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new rc(t);
      case !1:
        return new sc(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case bf:
        return new rc(t);
    }
    return t.byteLength === 16 ? new Fu(t) : new sc(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new rc(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new sc(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new Fu(t);
  }
  constructor(t, n) {
    return iw.new(t, n);
  }
}
function Ai(e) {
  if (typeof e == "bigint" && (e < Number.MIN_SAFE_INTEGER || e > Number.MAX_SAFE_INTEGER))
    throw new TypeError(`${e} is not safe to convert to a number.`);
  return Number(e);
}
var wB, vB, xB, SB, IB, $B, AB, MB, TB, BB, NB, FB, DB, OB, EB, LB, RB, CB, kB;
class $t {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === C.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === C.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === C.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === C.Binary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === C.Utf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === C.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === C.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === C.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === C.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === C.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === C.Interval;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === C.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === C.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === C.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === C.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === C.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === C.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === C.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return $t.isUnion(t) && t.mode === $i.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return $t.isUnion(t) && t.mode === $i.Sparse;
  }
  get typeId() {
    return C.NONE;
  }
}
wB = Symbol.toStringTag;
$t[wB] = ((e) => (e.children = null, e.ArrayType = Array, e[Symbol.toStringTag] = "DataType"))($t.prototype);
let Xs = class extends $t {
  toString() {
    return "Null";
  }
  get typeId() {
    return C.Null;
  }
};
vB = Symbol.toStringTag;
Xs[vB] = ((e) => e[Symbol.toStringTag] = "Null")(Xs.prototype);
class Hs extends $t {
  constructor(t, n) {
    super(), this.isSigned = t, this.bitWidth = n;
  }
  get typeId() {
    return C.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 ? bf : _f;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
}
xB = Symbol.toStringTag;
Hs[xB] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(Hs.prototype);
class Du extends Hs {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
}
Object.defineProperty(Du.prototype, "ArrayType", { value: Int32Array });
class Ou extends $t {
  constructor(t) {
    super(), this.precision = t;
  }
  get typeId() {
    return C.Float;
  }
  get ArrayType() {
    switch (this.precision) {
      case mn.HALF:
        return Uint16Array;
      case mn.SINGLE:
        return Float32Array;
      case mn.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
}
SB = Symbol.toStringTag;
Ou[SB] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(Ou.prototype);
let _p = class extends $t {
  constructor() {
    super();
  }
  get typeId() {
    return C.Binary;
  }
  toString() {
    return "Binary";
  }
};
IB = Symbol.toStringTag;
_p[IB] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(_p.prototype);
let wp = class extends $t {
  constructor() {
    super();
  }
  get typeId() {
    return C.Utf8;
  }
  toString() {
    return "Utf8";
  }
};
$B = Symbol.toStringTag;
wp[$B] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(wp.prototype);
let vp = class extends $t {
  constructor() {
    super();
  }
  get typeId() {
    return C.Bool;
  }
  toString() {
    return "Bool";
  }
};
AB = Symbol.toStringTag;
vp[AB] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(vp.prototype);
let xp = class extends $t {
  constructor(t, n, i = 128) {
    super(), this.scale = t, this.precision = n, this.bitWidth = i;
  }
  get typeId() {
    return C.Decimal;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
};
MB = Symbol.toStringTag;
xp[MB] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(xp.prototype);
class Sp extends $t {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return C.Date;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${is[this.unit]}>`;
  }
}
TB = Symbol.toStringTag;
Sp[TB] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(Sp.prototype);
class Eu extends $t {
  constructor(t, n) {
    super(), this.unit = t, this.bitWidth = n;
  }
  get typeId() {
    return C.Time;
  }
  toString() {
    return `Time${this.bitWidth}<${Yt[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return bf;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
}
BB = Symbol.toStringTag;
Eu[BB] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(Eu.prototype);
class Ip extends $t {
  constructor(t, n) {
    super(), this.unit = t, this.timezone = n;
  }
  get typeId() {
    return C.Timestamp;
  }
  toString() {
    return `Timestamp<${Yt[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
}
NB = Symbol.toStringTag;
Ip[NB] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(Ip.prototype);
class $p extends $t {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return C.Interval;
  }
  toString() {
    return `Interval<${Gs[this.unit]}>`;
  }
}
FB = Symbol.toStringTag;
$p[FB] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))($p.prototype);
let Ap = class extends $t {
  constructor(t) {
    super(), this.children = [t];
  }
  get typeId() {
    return C.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;
  }
};
DB = Symbol.toStringTag;
Ap[DB] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(Ap.prototype);
class an extends $t {
  constructor(t) {
    super(), this.children = t;
  }
  get typeId() {
    return C.Struct;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
OB = Symbol.toStringTag;
an[OB] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(an.prototype);
class Mp extends $t {
  constructor(t, n, i) {
    super(), this.mode = t, this.children = i, this.typeIds = n = Int32Array.from(n), this.typeIdToChildIndex = n.reduce((r, s, o) => (r[s] = o) && r || r, /* @__PURE__ */ Object.create(null));
  }
  get typeId() {
    return C.Union;
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
}
EB = Symbol.toStringTag;
Mp[EB] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(Mp.prototype);
let Tp = class extends $t {
  constructor(t) {
    super(), this.byteWidth = t;
  }
  get typeId() {
    return C.FixedSizeBinary;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
};
LB = Symbol.toStringTag;
Tp[LB] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(Tp.prototype);
let Bp = class extends $t {
  constructor(t, n) {
    super(), this.listSize = t, this.children = [n];
  }
  get typeId() {
    return C.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}>`;
  }
};
RB = Symbol.toStringTag;
Bp[RB] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(Bp.prototype);
class Np extends $t {
  constructor(t, n = !1) {
    super(), this.children = [t], this.keysSorted = n;
  }
  get typeId() {
    return C.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(", ")}}>`;
  }
}
CB = Symbol.toStringTag;
Np[CB] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(Np.prototype);
const Snt = ((e) => () => ++e)(-1);
class Ec extends $t {
  constructor(t, n, i, r) {
    super(), this.indices = n, this.dictionary = t, this.isOrdered = r || !1, this.id = i == null ? Snt() : Ai(i);
  }
  get typeId() {
    return C.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}>`;
  }
}
kB = Symbol.toStringTag;
Ec[kB] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(Ec.prototype);
function Dr(e) {
  const t = e;
  switch (e.typeId) {
    case C.Decimal:
      return e.bitWidth / 32;
    case C.Timestamp:
      return 2;
    case C.Date:
      return 1 + t.unit;
    case C.Interval:
      return 1 + t.unit;
    case C.FixedSizeList:
      return t.listSize;
    case C.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
class zt {
  visitMany(t, ...n) {
    return t.map((i, r) => this.visit(i, ...n.map((s) => s[r])));
  }
  visit(...t) {
    return this.getVisitFn(t[0], !1).apply(this, t);
  }
  getVisitFn(t, n = !0) {
    return Int(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return Fa(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 Int(e, t, n = !0) {
  return typeof t == "number" ? Fa(e, t, n) : typeof t == "string" && t in C ? Fa(e, C[t], n) : t && t instanceof $t ? Fa(e, Hx(t), n) : t != null && t.type && t.type instanceof $t ? Fa(e, Hx(t.type), n) : Fa(e, C.NONE, n);
}
function Fa(e, t, n = !0) {
  let i = null;
  switch (t) {
    case C.Null:
      i = e.visitNull;
      break;
    case C.Bool:
      i = e.visitBool;
      break;
    case C.Int:
      i = e.visitInt;
      break;
    case C.Int8:
      i = e.visitInt8 || e.visitInt;
      break;
    case C.Int16:
      i = e.visitInt16 || e.visitInt;
      break;
    case C.Int32:
      i = e.visitInt32 || e.visitInt;
      break;
    case C.Int64:
      i = e.visitInt64 || e.visitInt;
      break;
    case C.Uint8:
      i = e.visitUint8 || e.visitInt;
      break;
    case C.Uint16:
      i = e.visitUint16 || e.visitInt;
      break;
    case C.Uint32:
      i = e.visitUint32 || e.visitInt;
      break;
    case C.Uint64:
      i = e.visitUint64 || e.visitInt;
      break;
    case C.Float:
      i = e.visitFloat;
      break;
    case C.Float16:
      i = e.visitFloat16 || e.visitFloat;
      break;
    case C.Float32:
      i = e.visitFloat32 || e.visitFloat;
      break;
    case C.Float64:
      i = e.visitFloat64 || e.visitFloat;
      break;
    case C.Utf8:
      i = e.visitUtf8;
      break;
    case C.Binary:
      i = e.visitBinary;
      break;
    case C.FixedSizeBinary:
      i = e.visitFixedSizeBinary;
      break;
    case C.Date:
      i = e.visitDate;
      break;
    case C.DateDay:
      i = e.visitDateDay || e.visitDate;
      break;
    case C.DateMillisecond:
      i = e.visitDateMillisecond || e.visitDate;
      break;
    case C.Timestamp:
      i = e.visitTimestamp;
      break;
    case C.TimestampSecond:
      i = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case C.TimestampMillisecond:
      i = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case C.TimestampMicrosecond:
      i = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case C.TimestampNanosecond:
      i = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case C.Time:
      i = e.visitTime;
      break;
    case C.TimeSecond:
      i = e.visitTimeSecond || e.visitTime;
      break;
    case C.TimeMillisecond:
      i = e.visitTimeMillisecond || e.visitTime;
      break;
    case C.TimeMicrosecond:
      i = e.visitTimeMicrosecond || e.visitTime;
      break;
    case C.TimeNanosecond:
      i = e.visitTimeNanosecond || e.visitTime;
      break;
    case C.Decimal:
      i = e.visitDecimal;
      break;
    case C.List:
      i = e.visitList;
      break;
    case C.Struct:
      i = e.visitStruct;
      break;
    case C.Union:
      i = e.visitUnion;
      break;
    case C.DenseUnion:
      i = e.visitDenseUnion || e.visitUnion;
      break;
    case C.SparseUnion:
      i = e.visitSparseUnion || e.visitUnion;
      break;
    case C.Dictionary:
      i = e.visitDictionary;
      break;
    case C.Interval:
      i = e.visitInterval;
      break;
    case C.IntervalDayTime:
      i = e.visitIntervalDayTime || e.visitInterval;
      break;
    case C.IntervalYearMonth:
      i = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case C.FixedSizeList:
      i = e.visitFixedSizeList;
      break;
    case C.Map:
      i = e.visitMap;
      break;
  }
  if (typeof i == "function")
    return i;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${C[t]}'`);
}
function Hx(e) {
  switch (e.typeId) {
    case C.Null:
      return C.Null;
    case C.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? C.Int8 : C.Uint8;
        case 16:
          return n ? C.Int16 : C.Uint16;
        case 32:
          return n ? C.Int32 : C.Uint32;
        case 64:
          return n ? C.Int64 : C.Uint64;
      }
      return C.Int;
    }
    case C.Float:
      switch (e.precision) {
        case mn.HALF:
          return C.Float16;
        case mn.SINGLE:
          return C.Float32;
        case mn.DOUBLE:
          return C.Float64;
      }
      return C.Float;
    case C.Binary:
      return C.Binary;
    case C.Utf8:
      return C.Utf8;
    case C.Bool:
      return C.Bool;
    case C.Decimal:
      return C.Decimal;
    case C.Time:
      switch (e.unit) {
        case Yt.SECOND:
          return C.TimeSecond;
        case Yt.MILLISECOND:
          return C.TimeMillisecond;
        case Yt.MICROSECOND:
          return C.TimeMicrosecond;
        case Yt.NANOSECOND:
          return C.TimeNanosecond;
      }
      return C.Time;
    case C.Timestamp:
      switch (e.unit) {
        case Yt.SECOND:
          return C.TimestampSecond;
        case Yt.MILLISECOND:
          return C.TimestampMillisecond;
        case Yt.MICROSECOND:
          return C.TimestampMicrosecond;
        case Yt.NANOSECOND:
          return C.TimestampNanosecond;
      }
      return C.Timestamp;
    case C.Date:
      switch (e.unit) {
        case is.DAY:
          return C.DateDay;
        case is.MILLISECOND:
          return C.DateMillisecond;
      }
      return C.Date;
    case C.Interval:
      switch (e.unit) {
        case Gs.DAY_TIME:
          return C.IntervalDayTime;
        case Gs.YEAR_MONTH:
          return C.IntervalYearMonth;
      }
      return C.Interval;
    case C.Map:
      return C.Map;
    case C.List:
      return C.List;
    case C.Struct:
      return C.Struct;
    case C.Union:
      switch (e.mode) {
        case $i.Dense:
          return C.DenseUnion;
        case $i.Sparse:
          return C.SparseUnion;
      }
      return C.Union;
    case C.FixedSizeBinary:
      return C.FixedSizeBinary;
    case C.FixedSizeList:
      return C.FixedSizeList;
    case C.Dictionary:
      return C.Dictionary;
  }
  throw new Error(`Unrecognized type '${C[e.typeId]}'`);
}
zt.prototype.visitInt8 = null;
zt.prototype.visitInt16 = null;
zt.prototype.visitInt32 = null;
zt.prototype.visitInt64 = null;
zt.prototype.visitUint8 = null;
zt.prototype.visitUint16 = null;
zt.prototype.visitUint32 = null;
zt.prototype.visitUint64 = null;
zt.prototype.visitFloat16 = null;
zt.prototype.visitFloat32 = null;
zt.prototype.visitFloat64 = null;
zt.prototype.visitDateDay = null;
zt.prototype.visitDateMillisecond = null;
zt.prototype.visitTimestampSecond = null;
zt.prototype.visitTimestampMillisecond = null;
zt.prototype.visitTimestampMicrosecond = null;
zt.prototype.visitTimestampNanosecond = null;
zt.prototype.visitTimeSecond = null;
zt.prototype.visitTimeMillisecond = null;
zt.prototype.visitTimeMicrosecond = null;
zt.prototype.visitTimeNanosecond = null;
zt.prototype.visitDenseUnion = null;
zt.prototype.visitSparseUnion = null;
zt.prototype.visitIntervalDayTime = null;
zt.prototype.visitIntervalYearMonth = null;
const UB = new Float64Array(1), ba = new Uint32Array(UB.buffer);
function zB(e) {
  const t = (e & 31744) >> 10, n = (e & 1023) / 1024, i = Math.pow(-1, (e & 32768) >> 15);
  switch (t) {
    case 31:
      return i * (n ? Number.NaN : 1 / 0);
    case 0:
      return i * (n ? 6103515625e-14 * n : 0);
  }
  return i * Math.pow(2, t - 15) * (1 + n);
}
function $nt(e) {
  if (e !== e)
    return 32256;
  UB[0] = e;
  const t = (ba[1] & 2147483648) >> 16 & 65535;
  let n = ba[1] & 2146435072, i = 0;
  return n >= 1089470464 ? ba[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, i = (ba[1] & 1048575) >> 10) : n <= 1056964608 ? (i = 1048576 + (ba[1] & 1048575), i = 1048576 + (i << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, i = (ba[1] & 1048575) + 512 >> 10), t | n | i & 65535;
}
class xt extends zt {
}
function Mt(e) {
  return (t, n, i) => {
    if (t.setValid(n, i != null))
      return e(t, n, i);
  };
}
const Ant = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, rw = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, Mnt = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, Tnt = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, PB = (e, t, n, i) => {
  if (n + 1 < t.length) {
    const { [n]: r, [n + 1]: s } = t;
    e.set(i.subarray(0, s - r), r);
  }
}, Bnt = ({ offset: e, values: t }, n, i) => {
  const r = e + n;
  i ? t[r >> 3] |= 1 << r % 8 : t[r >> 3] &= ~(1 << r % 8);
}, hs = ({ values: e }, t, n) => {
  e[t] = n;
}, sw = ({ values: e }, t, n) => {
  e[t] = n;
}, VB = ({ values: e }, t, n) => {
  e[t] = $nt(n);
}, Nnt = (e, t, n) => {
  switch (e.type.precision) {
    case mn.HALF:
      return VB(e, t, n);
    case mn.SINGLE:
    case mn.DOUBLE:
      return sw(e, t, n);
  }
}, jB = ({ values: e }, t, n) => {
  Ant(e, t, n.valueOf());
}, YB = ({ values: e }, t, n) => {
  rw(e, t * 2, n.valueOf());
}, Fnt = ({ stride: e, values: t }, n, i) => {
  t.set(i.subarray(0, e), e * n);
}, Dnt = ({ values: e, valueOffsets: t }, n, i) => PB(e, t, n, i), Ont = ({ values: e, valueOffsets: t }, n, i) => {
  PB(e, t, n, Q_(i));
}, Ent = (e, t, n) => {
  e.type.unit === is.DAY ? jB(e, t, n) : YB(e, t, n);
}, qB = ({ values: e }, t, n) => rw(e, t * 2, n / 1e3), WB = ({ values: e }, t, n) => rw(e, t * 2, n), GB = ({ values: e }, t, n) => Mnt(e, t * 2, n), XB = ({ values: e }, t, n) => Tnt(e, t * 2, n), Lnt = (e, t, n) => {
  switch (e.type.unit) {
    case Yt.SECOND:
      return qB(e, t, n);
    case Yt.MILLISECOND:
      return WB(e, t, n);
    case Yt.MICROSECOND:
      return GB(e, t, n);
    case Yt.NANOSECOND:
      return XB(e, t, n);
  }
}, HB = ({ values: e }, t, n) => {
  e[t] = n;
}, KB = ({ values: e }, t, n) => {
  e[t] = n;
}, JB = ({ values: e }, t, n) => {
  e[t] = n;
}, ZB = ({ values: e }, t, n) => {
  e[t] = n;
}, Rnt = (e, t, n) => {
  switch (e.type.unit) {
    case Yt.SECOND:
      return HB(e, t, n);
    case Yt.MILLISECOND:
      return KB(e, t, n);
    case Yt.MICROSECOND:
      return JB(e, t, n);
    case Yt.NANOSECOND:
      return ZB(e, t, n);
  }
}, Cnt = ({ values: e, stride: t }, n, i) => {
  e.set(i.subarray(0, t), t * n);
}, knt = (e, t, n) => {
  const i = e.children[0], r = e.valueOffsets, s = ri.getVisitFn(i);
  if (Array.isArray(n))
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n[++o]);
  else
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n.get(++o));
}, Unt = (e, t, n) => {
  const i = e.children[0], { valueOffsets: r } = e, s = ri.getVisitFn(i);
  let { [t]: o, [t + 1]: a } = r;
  const c = n instanceof Map ? n.entries() : Object.entries(n);
  for (const l of c)
    if (s(i, o, l), ++o >= a)
      break;
}, znt = (e, t) => (n, i, r, s) => i && n(i, e, t[s]), Pnt = (e, t) => (n, i, r, s) => i && n(i, e, t.get(s)), Vnt = (e, t) => (n, i, r, s) => i && n(i, e, t.get(r.name)), jnt = (e, t) => (n, i, r, s) => i && n(i, e, t[r.name]), Ynt = (e, t, n) => {
  const i = e.type.children.map((s) => ri.getVisitFn(s.type)), r = n instanceof Map ? Vnt(t, n) : n instanceof te ? Pnt(t, n) : Array.isArray(n) ? znt(t, n) : jnt(t, n);
  e.type.children.forEach((s, o) => r(i[o], e.children[o], s, o));
}, qnt = (e, t, n) => {
  e.type.mode === $i.Dense ? QB(e, t, n) : tN(e, t, n);
}, QB = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  ri.visit(r, e.valueOffsets[t], n);
}, tN = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  ri.visit(r, t, n);
}, Wnt = (e, t, n) => {
  var i;
  (i = e.dictionary) === null || i === void 0 || i.set(e.values[t], n);
}, Gnt = (e, t, n) => {
  e.type.unit === Gs.DAY_TIME ? eN(e, t, n) : nN(e, t, n);
}, eN = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, nN = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, Xnt = (e, t, n) => {
  const { stride: i } = e, r = e.children[0], s = ri.getVisitFn(r);
  if (Array.isArray(n))
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n[o]);
  else
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n.get(o));
};
xt.prototype.visitBool = Mt(Bnt);
xt.prototype.visitInt = Mt(hs);
xt.prototype.visitInt8 = Mt(hs);
xt.prototype.visitInt16 = Mt(hs);
xt.prototype.visitInt32 = Mt(hs);
xt.prototype.visitInt64 = Mt(hs);
xt.prototype.visitUint8 = Mt(hs);
xt.prototype.visitUint16 = Mt(hs);
xt.prototype.visitUint32 = Mt(hs);
xt.prototype.visitUint64 = Mt(hs);
xt.prototype.visitFloat = Mt(Nnt);
xt.prototype.visitFloat16 = Mt(VB);
xt.prototype.visitFloat32 = Mt(sw);
xt.prototype.visitFloat64 = Mt(sw);
xt.prototype.visitUtf8 = Mt(Ont);
xt.prototype.visitBinary = Mt(Dnt);
xt.prototype.visitFixedSizeBinary = Mt(Fnt);
xt.prototype.visitDate = Mt(Ent);
xt.prototype.visitDateDay = Mt(jB);
xt.prototype.visitDateMillisecond = Mt(YB);
xt.prototype.visitTimestamp = Mt(Lnt);
xt.prototype.visitTimestampSecond = Mt(qB);
xt.prototype.visitTimestampMillisecond = Mt(WB);
xt.prototype.visitTimestampMicrosecond = Mt(GB);
xt.prototype.visitTimestampNanosecond = Mt(XB);
xt.prototype.visitTime = Mt(Rnt);
xt.prototype.visitTimeSecond = Mt(HB);
xt.prototype.visitTimeMillisecond = Mt(KB);
xt.prototype.visitTimeMicrosecond = Mt(JB);
xt.prototype.visitTimeNanosecond = Mt(ZB);
xt.prototype.visitDecimal = Mt(Cnt);
xt.prototype.visitList = Mt(knt);
xt.prototype.visitStruct = Mt(Ynt);
xt.prototype.visitUnion = Mt(qnt);
xt.prototype.visitDenseUnion = Mt(QB);
xt.prototype.visitSparseUnion = Mt(tN);
xt.prototype.visitDictionary = Mt(Wnt);
xt.prototype.visitInterval = Mt(Gnt);
xt.prototype.visitIntervalDayTime = Mt(eN);
xt.prototype.visitIntervalYearMonth = Mt(nN);
xt.prototype.visitFixedSizeList = Mt(Xnt);
xt.prototype.visitMap = Mt(Unt);
const ri = new xt(), ci = Symbol.for("parent"), oc = Symbol.for("rowIndex");
class ow {
  constructor(t, n) {
    return this[ci] = t, this[oc] = n, new Proxy(this, new Knt());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[oc], n = this[ci], i = n.type.children, r = {};
    for (let s = -1, o = i.length; ++s < o; )
      r[i[s].name] = xn.visit(n.children[s], t);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${Nu(t)}: ${Nu(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new Hnt(this[ci], this[oc]);
  }
}
class Hnt {
  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,
        xn.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
}
Object.defineProperties(ow.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [ci]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [oc]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
class Knt {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[ci].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[ci].type.children.findIndex((i) => i.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[ci].type.children.findIndex((i) => i.name === n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[ci].type.children.findIndex((r) => r.name === n);
    if (i !== -1) {
      const r = xn.visit(t[ci].children[i], t[oc]);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[ci].type.children.findIndex((s) => s.name === n);
    return r !== -1 ? (ri.visit(t[ci].children[r], t[oc], i), Reflect.set(t, n, i)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, i) : !1;
  }
}
class yt extends zt {
}
function St(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const Jnt = (e, t) => 864e5 * e[t], aw = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), Znt = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, Qnt = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, iN = (e) => new Date(e), tit = (e, t) => iN(Jnt(e, t)), eit = (e, t) => iN(aw(e, t)), nit = (e, t) => null, rN = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const i = t[n], r = t[n + 1];
  return e.subarray(i, r);
}, iit = ({ offset: e, values: t }, n) => {
  const i = e + n;
  return (t[i >> 3] & 1 << i % 8) !== 0;
}, sN = ({ values: e }, t) => tit(e, t), oN = ({ values: e }, t) => eit(e, t * 2), ao = ({ stride: e, values: t }, n) => t[e * n], rit = ({ stride: e, values: t }, n) => zB(t[e * n]), aN = ({ values: e }, t) => e[t], sit = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), oit = ({ values: e, valueOffsets: t }, n) => rN(e, t, n), ait = ({ values: e, valueOffsets: t }, n) => {
  const i = rN(e, t, n);
  return i !== null ? e1(i) : null;
}, cit = ({ values: e }, t) => e[t], lit = ({ type: e, values: t }, n) => e.precision !== mn.HALF ? t[n] : zB(t[n]), uit = (e, t) => e.type.unit === is.DAY ? sN(e, t) : oN(e, t), cN = ({ values: e }, t) => 1e3 * aw(e, t * 2), lN = ({ values: e }, t) => aw(e, t * 2), uN = ({ values: e }, t) => Znt(e, t * 2), fN = ({ values: e }, t) => Qnt(e, t * 2), fit = (e, t) => {
  switch (e.type.unit) {
    case Yt.SECOND:
      return cN(e, t);
    case Yt.MILLISECOND:
      return lN(e, t);
    case Yt.MICROSECOND:
      return uN(e, t);
    case Yt.NANOSECOND:
      return fN(e, t);
  }
}, hN = ({ values: e }, t) => e[t], dN = ({ values: e }, t) => e[t], pN = ({ values: e }, t) => e[t], yN = ({ values: e }, t) => e[t], hit = (e, t) => {
  switch (e.type.unit) {
    case Yt.SECOND:
      return hN(e, t);
    case Yt.MILLISECOND:
      return dN(e, t);
    case Yt.MICROSECOND:
      return pN(e, t);
    case Yt.NANOSECOND:
      return yN(e, t);
  }
}, dit = ({ values: e, stride: t }, n) => iw.decimal(e.subarray(t * n, t * (n + 1))), pit = (e, t) => {
  const { valueOffsets: n, stride: i, children: r } = e, { [t * i]: s, [t * i + 1]: o } = n, c = r[0].slice(s, o - s);
  return new te([c]);
}, yit = (e, t) => {
  const { valueOffsets: n, children: i } = e, { [t]: r, [t + 1]: s } = n, o = i[0];
  return new cw(o.slice(r, s - r));
}, mit = (e, t) => new ow(e, t), git = (e, t) => e.type.mode === $i.Dense ? mN(e, t) : gN(e, t), mN = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return xn.visit(i, e.valueOffsets[t]);
}, gN = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return xn.visit(i, t);
}, bit = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, _it = (e, t) => e.type.unit === Gs.DAY_TIME ? bN(e, t) : _N(e, t), bN = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), _N = ({ values: e }, t) => {
  const n = e[t], i = new Int32Array(2);
  return i[0] = Math.trunc(n / 12), i[1] = Math.trunc(n % 12), i;
}, wit = (e, t) => {
  const { stride: n, children: i } = e, s = i[0].slice(t * n, n);
  return new te([s]);
};
yt.prototype.visitNull = St(nit);
yt.prototype.visitBool = St(iit);
yt.prototype.visitInt = St(cit);
yt.prototype.visitInt8 = St(ao);
yt.prototype.visitInt16 = St(ao);
yt.prototype.visitInt32 = St(ao);
yt.prototype.visitInt64 = St(aN);
yt.prototype.visitUint8 = St(ao);
yt.prototype.visitUint16 = St(ao);
yt.prototype.visitUint32 = St(ao);
yt.prototype.visitUint64 = St(aN);
yt.prototype.visitFloat = St(lit);
yt.prototype.visitFloat16 = St(rit);
yt.prototype.visitFloat32 = St(ao);
yt.prototype.visitFloat64 = St(ao);
yt.prototype.visitUtf8 = St(ait);
yt.prototype.visitBinary = St(oit);
yt.prototype.visitFixedSizeBinary = St(sit);
yt.prototype.visitDate = St(uit);
yt.prototype.visitDateDay = St(sN);
yt.prototype.visitDateMillisecond = St(oN);
yt.prototype.visitTimestamp = St(fit);
yt.prototype.visitTimestampSecond = St(cN);
yt.prototype.visitTimestampMillisecond = St(lN);
yt.prototype.visitTimestampMicrosecond = St(uN);
yt.prototype.visitTimestampNanosecond = St(fN);
yt.prototype.visitTime = St(hit);
yt.prototype.visitTimeSecond = St(hN);
yt.prototype.visitTimeMillisecond = St(dN);
yt.prototype.visitTimeMicrosecond = St(pN);
yt.prototype.visitTimeNanosecond = St(yN);
yt.prototype.visitDecimal = St(dit);
yt.prototype.visitList = St(pit);
yt.prototype.visitStruct = St(mit);
yt.prototype.visitUnion = St(git);
yt.prototype.visitDenseUnion = St(mN);
yt.prototype.visitSparseUnion = St(gN);
yt.prototype.visitDictionary = St(bit);
yt.prototype.visitInterval = St(_it);
yt.prototype.visitIntervalDayTime = St(bN);
yt.prototype.visitIntervalYearMonth = St(_N);
yt.prototype.visitFixedSizeList = St(wit);
yt.prototype.visitMap = St(yit);
const xn = new yt(), Wi = Symbol.for("keys"), ac = Symbol.for("vals");
class cw {
  constructor(t) {
    return this[Wi] = new te([t.children[0]]).memoize(), this[ac] = t.children[1], new Proxy(this, new xit());
  }
  [Symbol.iterator]() {
    return new vit(this[Wi], this[ac]);
  }
  get size() {
    return this[Wi].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[Wi], n = this[ac], i = {};
    for (let r = -1, s = t.length; ++r < s; )
      i[t.get(r)] = xn.visit(n, r);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${Nu(t)}: ${Nu(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}
class vit {
  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),
        xn.visit(this.vals, t)
      ]
    });
  }
}
class xit {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[Wi].toArray().map(String);
  }
  has(t, n) {
    return t[Wi].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[Wi].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[Wi].indexOf(n);
    if (i !== -1) {
      const r = xn.visit(Reflect.get(t, ac), i);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[Wi].indexOf(n);
    return r !== -1 ? (ri.visit(Reflect.get(t, ac), r, i), Reflect.set(t, n, i)) : Reflect.has(t, n) ? Reflect.set(t, n, i) : !1;
  }
}
Object.defineProperties(cw.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [Wi]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [ac]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let Kx;
function wN(e, t, n, i) {
  const { length: r = 0 } = e;
  let s = typeof t != "number" ? 0 : t, o = typeof n != "number" ? r : n;
  return s < 0 && (s = (s % r + r) % r), o < 0 && (o = (o % r + r) % r), o < s && (Kx = s, s = o, o = Kx), o > r && (o = r), i ? i(e, s, o) : [s, o];
}
const Jx = (e) => e !== e;
function ol(e) {
  if (typeof e !== "object" || e === null)
    return Jx(e) ? Jx : (n) => n === e;
  if (e instanceof Date) {
    const n = e.valueOf();
    return (i) => i instanceof Date ? i.valueOf() === n : !1;
  }
  return ArrayBuffer.isView(e) ? (n) => n ? pnt(e, n) : !1 : e instanceof Map ? Iit(e) : Array.isArray(e) ? Sit(e) : e instanceof te ? $it(e) : Ait(e, !0);
}
function Sit(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = ol(e[n]);
  return l0(t);
}
function Iit(e) {
  let t = -1;
  const n = [];
  for (const i of e.values())
    n[++t] = ol(i);
  return l0(n);
}
function $it(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = ol(e.get(n));
  return l0(t);
}
function Ait(e, t = !1) {
  const n = Object.keys(e);
  if (!t && n.length === 0)
    return () => !1;
  const i = [];
  for (let r = -1, s = n.length; ++r < s; )
    i[r] = ol(e[n[r]]);
  return l0(i, n);
}
function l0(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return Mit(e, n);
      case Map:
        return Zx(e, n, n.keys());
      case cw:
      case ow:
      case Object:
      case void 0:
        return Zx(e, n, t || Object.keys(n));
    }
    return n instanceof te ? Tit(e, n) : !1;
  };
}
function Mit(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t[i]))
      return !1;
  return !0;
}
function Tit(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t.get(i)))
      return !1;
  return !0;
}
function Zx(e, t, n) {
  const i = n[Symbol.iterator](), r = t instanceof Map ? t.keys() : Object.keys(t)[Symbol.iterator](), s = t instanceof Map ? t.values() : Object.values(t)[Symbol.iterator]();
  let o = 0;
  const a = e.length;
  let c = s.next(), l = i.next(), u = r.next();
  for (; o < a && !l.done && !u.done && !c.done && !(l.value !== u.value || !e[o](c.value)); ++o, l = i.next(), u = r.next(), c = s.next())
    ;
  return o === a && l.done && u.done && c.done ? !0 : (i.return && i.return(), r.return && r.return(), s.return && s.return(), !1);
}
function vN(e, t, n, i) {
  return (n & 1 << i) !== 0;
}
function Bit(e, t, n, i) {
  return (n & 1 << i) >> i;
}
function Nit(e, t, n) {
  const i = n.byteLength + 7 & -8;
  if (e > 0 || n.byteLength < i) {
    const r = new Uint8Array(i);
    return r.set(e % 8 === 0 ? n.subarray(e >> 3) : (
      // Otherwise iterate each bit from the offset and return a new one
      r1(new lw(n, e, t, null, vN)).subarray(0, i)
    )), r;
  }
  return n;
}
function r1(e) {
  const t = [];
  let n = 0, i = 0, r = 0;
  for (const o of e)
    o && (r |= 1 << i), ++i === 8 && (t[n++] = r, r = i = 0);
  (n === 0 || i > 0) && (t[n++] = r);
  const s = new Uint8Array(t.length + 7 & -8);
  return s.set(t), s;
}
class lw {
  constructor(t, n, i, r, s) {
    this.bytes = t, this.length = i, this.context = r, this.get = s, this.bit = n % 8, this.byteIndex = n >> 3, this.byte = t[this.byteIndex++], this.index = 0;
  }
  next() {
    return this.index < this.length ? (this.bit === 8 && (this.bit = 0, this.byte = this.bytes[this.byteIndex++]), {
      value: this.get(this.context, this.index++, this.byte, this.bit++)
    }) : { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
function s1(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new lw(e, t, n - t, e, Bit))
      s += o;
    return s;
  }
  const i = n >> 3 << 3, r = t + (t % 8 === 0 ? 0 : 8 - t % 8);
  return (
    // Get the popcnt of bits between the left hand side, and the next highest multiple of 8
    s1(e, t, r) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    s1(e, i, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    Fit(e, r >> 3, i - r >> 3)
  );
}
function Fit(e, t, n) {
  let i = 0, r = Math.trunc(t);
  const s = new DataView(e.buffer, e.byteOffset, e.byteLength), o = n === void 0 ? e.byteLength : r + n;
  for (; o - r >= 4; )
    i += wm(s.getUint32(r)), r += 4;
  for (; o - r >= 2; )
    i += wm(s.getUint16(r)), r += 2;
  for (; o - r >= 1; )
    i += wm(s.getUint8(r)), r += 1;
  return i;
}
function wm(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 Dit = -1;
class ue {
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  get byteLength() {
    let t = 0;
    const { valueOffsets: n, values: i, nullBitmap: r, typeIds: s } = this;
    return n && (t += n.byteLength), i && (t += i.byteLength), r && (t += r.byteLength), s && (t += s.byteLength), this.children.reduce((o, a) => o + a.byteLength, t);
  }
  get nullCount() {
    let t = this._nullCount, n;
    return t <= Dit && (n = this.nullBitmap) && (this._nullCount = t = this.length - s1(n, this.offset, this.offset + this.length)), t;
  }
  constructor(t, n, i, r, s, o = [], a) {
    this.type = t, this.children = o, this.dictionary = a, this.offset = Math.floor(Math.max(n || 0, 0)), this.length = Math.floor(Math.max(i || 0, 0)), this._nullCount = Math.floor(Math.max(r || 0, -1));
    let c;
    s instanceof ue ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = Dr(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;
  }
  getValid(t) {
    if (this.nullable && this.nullCount > 0) {
      const n = this.offset + t;
      return (this.nullBitmap[n >> 3] & 1 << n % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    if (!this.nullable)
      return n;
    if (!this.nullBitmap || this.nullBitmap.byteLength <= t >> 3) {
      const { nullBitmap: c } = this._changeLengthAndBackfillNullBitmap(this.length);
      Object.assign(this, { nullBitmap: c, _nullCount: 0 });
    }
    const { nullBitmap: i, offset: r } = this, s = r + t >> 3, o = (r + t) % 8, a = i[s] >> o & 1;
    return n ? a === 0 && (i[s] |= 1 << o, this._nullCount = this.nullCount + 1) : a === 1 && (i[s] &= ~(1 << o), this._nullCount = this.nullCount - 1), n;
  }
  clone(t = this.type, n = this.offset, i = this.length, r = this._nullCount, s = this, o = this.children) {
    return new ue(t, n, i, r, s, o, this.dictionary);
  }
  slice(t, n) {
    const { stride: i, typeId: r, children: s } = this, o = +(this._nullCount === 0) - 1, a = r === 16 ? i : 1, c = this._sliceBuffers(t, n, i, r);
    return this.clone(
      this.type,
      this.offset + t,
      n,
      o,
      c,
      // Don't slice children if we have value offsets (the variable-width types)
      s.length === 0 || this.valueOffsets ? s : this._sliceChildren(s, a * t, a * n)
    );
  }
  _changeLengthAndBackfillNullBitmap(t) {
    if (this.typeId === C.Null)
      return this.clone(this.type, 0, t, 0);
    const { length: n, nullCount: i } = this, r = new Uint8Array((t + 63 & -64) >> 3).fill(255, 0, n >> 3);
    r[n >> 3] = (1 << n - (n & -8)) - 1, i > 0 && r.set(Nit(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[Fr.VALIDITY] = r, this.clone(this.type, 0, t, i + (t - n), s);
  }
  _sliceBuffers(t, n, i, r) {
    let s;
    const { buffers: o } = this;
    return (s = o[Fr.TYPE]) && (o[Fr.TYPE] = s.subarray(t, t + n)), (s = o[Fr.OFFSET]) && (o[Fr.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[Fr.DATA]) && (o[Fr.DATA] = r === 6 ? s : s.subarray(i * t, i * (t + n))), o;
  }
  _sliceChildren(t, n, i) {
    return t.map((r) => r.slice(n, i));
  }
}
ue.prototype.children = Object.freeze([]);
class tu extends zt {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["length"]: r = 0 } = t;
    return new ue(n, i, r, 0);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.data), s = Ht(t.nullBitmap), o = xl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [o, r, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.data), s = Ht(t.nullBitmap), o = xl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [o, r, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r } = t, s = Ht(t.nullBitmap), o = xl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [o, void 0, s], [r]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Ht(t.nullBitmap), { length: o = r.reduce((c, { length: l }) => Math.max(c, l), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, void 0, s], r);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Ht(t.nullBitmap), o = ie(n.ArrayType, t.typeIds), { ["length"]: a = o.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    if ($t.isSparseUnion(n))
      return new ue(n, i, a, c, [void 0, void 0, s, o], r);
    const l = xl(t.valueOffsets);
    return new ue(n, i, a, c, [l, void 0, s, o], r);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.indices.ArrayType, t.data), { ["dictionary"]: o = new te([new tu().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [void 0, s, r], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new tu().visit({ type: n.valueType }) } = t, s = Ht(t.nullBitmap), { ["length"]: o = r.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, void 0, s], [r]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new tu().visit({ type: n.childType }) } = t, s = Ht(t.nullBitmap), o = xl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [o, void 0, s], [r]);
  }
}
function Ct(e) {
  return new tu().visit(e);
}
class Qx {
  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 xN(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function SN(e) {
  return e.reduce((t, n, i) => (t[i + 1] = t[i] + n.length, t), new Uint32Array(e.length + 1));
}
function IN(e, t, n, i) {
  const r = [];
  for (let s = -1, o = e.length; ++s < o; ) {
    const a = e[s], c = t[s], { length: l } = a;
    if (c >= i)
      break;
    if (n >= c + l)
      continue;
    if (c >= n && c + l <= i) {
      r.push(a);
      continue;
    }
    const u = Math.max(0, n - c), f = Math.min(i - c, l);
    r.push(a.slice(u, f - u));
  }
  return r.length === 0 && r.push(e[0].slice(0, 0)), r;
}
function uw(e, t, n, i) {
  let r = 0, s = 0, o = t.length - 1;
  do {
    if (r >= o - 1)
      return n < t[o] ? i(e, r, n - t[r]) : null;
    s = r + Math.trunc((o - r) * 0.5), n < t[s] ? o = s : r = s;
  } while (r < o);
}
function fw(e, t) {
  return e.getValid(t);
}
function cc(e) {
  function t(n, i, r) {
    return e(n[i], r);
  }
  return function(n) {
    const i = this.data;
    return uw(i, this._offsets, n, t);
  };
}
function $N(e) {
  let t;
  function n(i, r, s) {
    return e(i[r], s, t);
  }
  return function(i, r) {
    const s = this.data;
    t = r;
    const o = uw(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
function AN(e) {
  let t;
  function n(i, r, s) {
    let o = s, a = 0, c = 0;
    for (let l = r - 1, u = i.length; ++l < u; ) {
      const f = i[l];
      if (~(a = e(f, t, o)))
        return c + a;
      o = 0, c += f.length;
    }
    return -1;
  }
  return function(i, r) {
    t = i;
    const s = this.data, o = typeof r != "number" ? n(s, 0, 0) : uw(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
class mt extends zt {
}
function Oit(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function Eit(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let i = 0;
  for (const r of new lw(n, e.offset + (t || 0), e.length, n, vN)) {
    if (!r)
      return i;
    ++i;
  }
  return -1;
}
function Nt(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    return Eit(e, n);
  const i = xn.getVisitFn(e), r = ol(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
function MN(e, t, n) {
  const i = xn.getVisitFn(e), r = ol(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
mt.prototype.visitNull = Oit;
mt.prototype.visitBool = Nt;
mt.prototype.visitInt = Nt;
mt.prototype.visitInt8 = Nt;
mt.prototype.visitInt16 = Nt;
mt.prototype.visitInt32 = Nt;
mt.prototype.visitInt64 = Nt;
mt.prototype.visitUint8 = Nt;
mt.prototype.visitUint16 = Nt;
mt.prototype.visitUint32 = Nt;
mt.prototype.visitUint64 = Nt;
mt.prototype.visitFloat = Nt;
mt.prototype.visitFloat16 = Nt;
mt.prototype.visitFloat32 = Nt;
mt.prototype.visitFloat64 = Nt;
mt.prototype.visitUtf8 = Nt;
mt.prototype.visitBinary = Nt;
mt.prototype.visitFixedSizeBinary = Nt;
mt.prototype.visitDate = Nt;
mt.prototype.visitDateDay = Nt;
mt.prototype.visitDateMillisecond = Nt;
mt.prototype.visitTimestamp = Nt;
mt.prototype.visitTimestampSecond = Nt;
mt.prototype.visitTimestampMillisecond = Nt;
mt.prototype.visitTimestampMicrosecond = Nt;
mt.prototype.visitTimestampNanosecond = Nt;
mt.prototype.visitTime = Nt;
mt.prototype.visitTimeSecond = Nt;
mt.prototype.visitTimeMillisecond = Nt;
mt.prototype.visitTimeMicrosecond = Nt;
mt.prototype.visitTimeNanosecond = Nt;
mt.prototype.visitDecimal = Nt;
mt.prototype.visitList = Nt;
mt.prototype.visitStruct = Nt;
mt.prototype.visitUnion = Nt;
mt.prototype.visitDenseUnion = MN;
mt.prototype.visitSparseUnion = MN;
mt.prototype.visitDictionary = Nt;
mt.prototype.visitInterval = Nt;
mt.prototype.visitIntervalDayTime = Nt;
mt.prototype.visitIntervalYearMonth = Nt;
mt.prototype.visitFixedSizeList = Nt;
mt.prototype.visitMap = Nt;
const Fp = new mt();
class gt extends zt {
}
function It(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === C.Timestamp || t instanceof Hs && t.bitWidth !== 64 || t instanceof Eu && t.bitWidth !== 64 || t instanceof Ou && t.precision !== mn.HALF))
    return new Qx(e.data.length, (i) => {
      const r = e.data[i];
      return r.values.subarray(0, r.length)[Symbol.iterator]();
    });
  let n = 0;
  return new Qx(e.data.length, (i) => {
    const s = e.data[i].length, o = e.slice(n, n + s);
    return n += s, new Lit(o);
  });
}
class Lit {
  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;
  }
}
gt.prototype.visitNull = It;
gt.prototype.visitBool = It;
gt.prototype.visitInt = It;
gt.prototype.visitInt8 = It;
gt.prototype.visitInt16 = It;
gt.prototype.visitInt32 = It;
gt.prototype.visitInt64 = It;
gt.prototype.visitUint8 = It;
gt.prototype.visitUint16 = It;
gt.prototype.visitUint32 = It;
gt.prototype.visitUint64 = It;
gt.prototype.visitFloat = It;
gt.prototype.visitFloat16 = It;
gt.prototype.visitFloat32 = It;
gt.prototype.visitFloat64 = It;
gt.prototype.visitUtf8 = It;
gt.prototype.visitBinary = It;
gt.prototype.visitFixedSizeBinary = It;
gt.prototype.visitDate = It;
gt.prototype.visitDateDay = It;
gt.prototype.visitDateMillisecond = It;
gt.prototype.visitTimestamp = It;
gt.prototype.visitTimestampSecond = It;
gt.prototype.visitTimestampMillisecond = It;
gt.prototype.visitTimestampMicrosecond = It;
gt.prototype.visitTimestampNanosecond = It;
gt.prototype.visitTime = It;
gt.prototype.visitTimeSecond = It;
gt.prototype.visitTimeMillisecond = It;
gt.prototype.visitTimeMicrosecond = It;
gt.prototype.visitTimeNanosecond = It;
gt.prototype.visitDecimal = It;
gt.prototype.visitList = It;
gt.prototype.visitStruct = It;
gt.prototype.visitUnion = It;
gt.prototype.visitDenseUnion = It;
gt.prototype.visitSparseUnion = It;
gt.prototype.visitDictionary = It;
gt.prototype.visitInterval = It;
gt.prototype.visitIntervalDayTime = It;
gt.prototype.visitIntervalYearMonth = It;
gt.prototype.visitFixedSizeList = It;
gt.prototype.visitMap = It;
const hw = new gt(), Rit = (e, t) => e + t;
class co extends zt {
  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 === Yt.SECOND ? 4 : 8;
  }
  visitInterval(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitStruct(t, n) {
    return t.children.reduce((i, r) => i + ur.visit(r, n), 0);
  }
  visitFixedSizeBinary(t, n) {
    return t.type.byteWidth;
  }
  visitMap(t, n) {
    return 8 + t.children.reduce((i, r) => i + ur.visit(r, n), 0);
  }
  visitDictionary(t, n) {
    var i;
    return t.type.indices.bitWidth / 8 + (((i = t.dictionary) === null || i === void 0 ? void 0 : i.getByteLength(t.values[n])) || 0);
  }
}
const Cit = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), kit = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), Uit = ({ valueOffsets: e, stride: t, children: n }, i) => {
  const r = n[0], { [i * t]: s } = e, { [i * t + 1]: o } = e, a = ur.getVisitFn(r.type), c = r.slice(s, o - s);
  let l = 8;
  for (let u = -1, f = o - s; ++u < f; )
    l += a(c, u);
  return l;
}, zit = ({ stride: e, children: t }, n) => {
  const i = t[0], r = i.slice(n * e, e), s = ur.getVisitFn(i.type);
  let o = 0;
  for (let a = -1, c = r.length; ++a < c; )
    o += s(r, a);
  return o;
}, Pit = (e, t) => e.type.mode === $i.Dense ? TN(e, t) : BN(e, t), TN = ({ type: e, children: t, typeIds: n, valueOffsets: i }, r) => {
  const s = e.typeIdToChildIndex[n[r]];
  return 8 + ur.visit(t[s], i[r]);
}, BN = ({ children: e }, t) => 4 + ur.visitMany(e, e.map(() => t)).reduce(Rit, 0);
co.prototype.visitUtf8 = Cit;
co.prototype.visitBinary = kit;
co.prototype.visitList = Uit;
co.prototype.visitFixedSizeList = zit;
co.prototype.visitUnion = Pit;
co.prototype.visitDenseUnion = TN;
co.prototype.visitSparseUnion = BN;
const ur = new co();
var NN;
const FN = {}, DN = {};
class te {
  constructor(t) {
    var n, i, r;
    const s = t[0] instanceof te ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof ue)))
      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: l, byteLength: u } = FN[o.typeId], f = s[0];
        this.isValid = (h) => fw(f, h), this.get = (h) => a(f, h), this.set = (h, d) => c(f, h, d), this.indexOf = (h) => l(f, h), this.getByteLength = (h) => u(f, h), this._offsets = [0, f.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, DN[o.typeId]), this._offsets = SN(s);
        break;
    }
    this.data = s, this.type = o, this.stride = Dr(o), this.numChildren = (r = (i = o.children) === null || i === void 0 ? void 0 : i.length) !== null && r !== void 0 ? r : 0, this.length = this._offsets[this._offsets.length - 1];
  }
  /**
   * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
   */
  get byteLength() {
    return this._byteLength === -1 && (this._byteLength = this.data.reduce((t, n) => t + n.byteLength, 0)), this._byteLength;
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return this._nullCount === -1 && (this._nullCount = xN(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 `${C[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 hw.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 te(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 te(wN(this, t, n, ({ data: i, _offsets: r }, s, o) => IN(i, r, s, o)));
  }
  toJSON() {
    return [...this];
  }
  /**
   * Return a JavaScript Array or TypedArray of the Vector's elements.
   *
   * @note If this Vector contains a single Data chunk and the Vector's type is a
   *  primitive numeric type corresponding to one of the JavaScript TypedArrays, this
   *  method returns a zero-copy slice of the underlying TypedArray values. If there's
   *  more than one chunk, the resulting TypedArray will be a copy of the data from each
   *  chunk's underlying TypedArray values.
   *
   * @returns An Array or TypedArray of the Vector's elements, based on the Vector's DataType.
   */
  toArray() {
    const { type: t, data: n, length: i, stride: r, ArrayType: s } = this;
    switch (t.typeId) {
      case C.Int:
      case C.Float:
      case C.Decimal:
      case C.Time:
      case C.Timestamp:
        switch (n.length) {
          case 0:
            return new s();
          case 1:
            return n[0].values.subarray(0, i * r);
          default:
            return n.reduce((o, { values: a, length: c }) => (o.array.set(a.subarray(0, c * r), o.offset), o.offset += c * r, o), { array: new s(i * r), offset: 0 }).array;
        }
    }
    return [...this];
  }
  /**
   * Returns a string representation of the Vector.
   *
   * @returns A string representation of the Vector.
   */
  toString() {
    return `[${[...this].join(",")}]`;
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    var n;
    return this.getChildAt((n = this.type.children) === null || n === void 0 ? void 0 : n.findIndex((i) => i.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    return t > -1 && t < this.numChildren ? new te(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return $t.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 ($t.isDictionary(this.type)) {
      const t = new Dp(this.data[0].dictionary), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new te(n);
    }
    return new Dp(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 ($t.isDictionary(this.type) && this.isMemoized) {
      const t = this.data[0].dictionary.unmemoize(), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new te(n);
    }
    return this;
  }
}
NN = Symbol.toStringTag;
te[NN] = ((e) => {
  e.type = $t.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(C).map((n) => C[n]).filter((n) => typeof n == "number" && n !== C.NONE);
  for (const n of t) {
    const i = xn.getVisitFnByTypeId(n), r = ri.getVisitFnByTypeId(n), s = Fp.getVisitFnByTypeId(n), o = ur.getVisitFnByTypeId(n);
    FN[n] = { get: i, set: r, indexOf: s, byteLength: o }, DN[n] = Object.create(e, {
      isValid: { value: cc(fw) },
      get: { value: cc(xn.getVisitFnByTypeId(n)) },
      set: { value: $N(ri.getVisitFnByTypeId(n)) },
      indexOf: { value: AN(Fp.getVisitFnByTypeId(n)) },
      getByteLength: { value: cc(ur.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(te.prototype);
class Dp extends te {
  constructor(t) {
    super(t.data);
    const n = this.get, i = this.set, r = this.slice, s = new Array(this.length);
    Object.defineProperty(this, "get", {
      value(o) {
        const a = s[o];
        if (a !== void 0)
          return a;
        const c = n.call(this, o);
        return s[o] = c, c;
      }
    }), Object.defineProperty(this, "set", {
      value(o, a) {
        i.call(this, o, a), s[o] = a;
      }
    }), Object.defineProperty(this, "slice", {
      value: (o, a) => new Dp(r.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new te(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}
class o1 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * Index to the start of the RecordBlock (note this is past the Message header)
   */
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * Length of the metadata
   */
  metaDataLength() {
    return this.bb.readInt32(this.bb_pos + 8);
  }
  /**
   * Length of the data (this is aligned so there can be a gap between this and
   * the metadata).
   */
  bodyLength() {
    return this.bb.readInt64(this.bb_pos + 16);
  }
  static sizeOf() {
    return 24;
  }
  static createBlock(t, n, i, r) {
    return t.prep(8, 24), t.writeInt64(BigInt(r ?? 0)), t.pad(4), t.writeInt32(i), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}
const vm = 2, Gi = 4, Rr = 4, le = 4, vs = new Int32Array(2), tS = new Float32Array(vs.buffer), eS = new Float64Array(vs.buffer), ah = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
var a1;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(a1 || (a1 = {}));
let Lc = class ON {
  /**
   * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
   */
  constructor(t) {
    this.bytes_ = t, this.position_ = 0, this.text_decoder_ = new TextDecoder();
  }
  /**
   * Create and allocate a new ByteBuffer with a given size.
   */
  static allocate(t) {
    return new ON(new Uint8Array(t));
  }
  clear() {
    this.position_ = 0;
  }
  /**
   * Get the underlying `Uint8Array`.
   */
  bytes() {
    return this.bytes_;
  }
  /**
   * Get the buffer's position.
   */
  position() {
    return this.position_;
  }
  /**
   * Set the buffer's position.
   */
  setPosition(t) {
    this.position_ = t;
  }
  /**
   * Get the buffer's capacity.
   */
  capacity() {
    return this.bytes_.length;
  }
  readInt8(t) {
    return this.readUint8(t) << 24 >> 24;
  }
  readUint8(t) {
    return this.bytes_[t];
  }
  readInt16(t) {
    return this.readUint16(t) << 16 >> 16;
  }
  readUint16(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8;
  }
  readInt32(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8 | this.bytes_[t + 2] << 16 | this.bytes_[t + 3] << 24;
  }
  readUint32(t) {
    return this.readInt32(t) >>> 0;
  }
  readInt64(t) {
    return BigInt.asIntN(64, BigInt(this.readUint32(t)) + (BigInt(this.readUint32(t + 4)) << BigInt(32)));
  }
  readUint64(t) {
    return BigInt.asUintN(64, BigInt(this.readUint32(t)) + (BigInt(this.readUint32(t + 4)) << BigInt(32)));
  }
  readFloat32(t) {
    return vs[0] = this.readInt32(t), tS[0];
  }
  readFloat64(t) {
    return vs[ah ? 0 : 1] = this.readInt32(t), vs[ah ? 1 : 0] = this.readInt32(t + 4), eS[0];
  }
  writeInt8(t, n) {
    this.bytes_[t] = n;
  }
  writeUint8(t, n) {
    this.bytes_[t] = n;
  }
  writeInt16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeUint16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeInt32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeUint32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeInt64(t, n) {
    this.writeInt32(t, Number(BigInt.asIntN(32, n))), this.writeInt32(t + 4, Number(BigInt.asIntN(32, n >> BigInt(32))));
  }
  writeUint64(t, n) {
    this.writeUint32(t, Number(BigInt.asUintN(32, n))), this.writeUint32(t + 4, Number(BigInt.asUintN(32, n >> BigInt(32))));
  }
  writeFloat32(t, n) {
    tS[0] = n, this.writeInt32(t, vs[0]);
  }
  writeFloat64(t, n) {
    eS[0] = n, this.writeInt32(t, vs[ah ? 0 : 1]), this.writeInt32(t + 4, vs[ah ? 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_ + Gi + Rr)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < Rr; n++)
      t += String.fromCharCode(this.readInt8(this.position_ + Gi + n));
    return t;
  }
  /**
   * Look up a field in the vtable, return an offset into the object, or 0 if the
   * field is not present.
   */
  __offset(t, n) {
    const i = t - this.readInt32(t);
    return n < this.readInt16(i) ? this.readInt16(i + n) : 0;
  }
  /**
   * Initialize any Table-derived type to point to the union at the given offset.
   */
  __union(t, n) {
    return t.bb_pos = n + this.readInt32(n), t.bb = this, t;
  }
  /**
   * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.
   * This allocates a new string and converts to wide chars upon each access.
   *
   * To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
   * "optionalEncoding" argument. This is useful for avoiding conversion when
   * the data will just be packaged back up in another FlatBuffer later on.
   *
   * @param offset
   * @param opt_encoding Defaults to UTF16_STRING
   */
  __string(t, n) {
    t += this.readInt32(t);
    const i = this.readInt32(t);
    t += Gi;
    const r = this.bytes_.subarray(t, t + i);
    return n === a1.UTF8_BYTES ? r : this.text_decoder_.decode(r);
  }
  /**
   * Handle unions that can contain string as its member, if a Table-derived type then initialize it,
   * if a string then return a new one
   *
   * WARNING: strings are immutable in JS so we can't change the string that the user gave us, this
   * makes the behaviour of __union_with_string different compared to __union
   */
  __union_with_string(t, n) {
    return typeof t == "string" ? this.__string(n) : this.__union(t, n);
  }
  /**
   * Retrieve the relative offset stored at "offset"
   */
  __indirect(t) {
    return t + this.readInt32(t);
  }
  /**
   * Get the start of data of a vector whose offset is stored at "offset" in this object.
   */
  __vector(t) {
    return t + this.readInt32(t) + Gi;
  }
  /**
   * 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 != Rr)
      throw new Error("FlatBuffers: file identifier must be length " + Rr);
    for (let n = 0; n < Rr; n++)
      if (t.charCodeAt(n) != this.readInt8(this.position() + Gi + n))
        return !1;
    return !0;
  }
  /**
   * A helper function for generating list for obj api
   */
  createScalarList(t, n) {
    const i = [];
    for (let r = 0; r < n; ++r) {
      const s = t(r);
      s !== null && i.push(s);
    }
    return i;
  }
  /**
   * A helper function for generating list for obj api
   * @param listAccessor function that accepts an index and return data at that index
   * @param listLength listLength
   * @param res result list
   */
  createObjList(t, n) {
    const i = [];
    for (let r = 0; r < n; ++r) {
      const s = t(r);
      s !== null && i.push(s.unpack());
    }
    return i;
  }
}, EN = class LN {
  /**
   * Create a FlatBufferBuilder.
   */
  constructor(t) {
    this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null, this.text_encoder = new TextEncoder();
    let n;
    t ? n = t : n = 1024, this.bb = Lc.allocate(n), this.space = n;
  }
  clear() {
    this.bb.clear(), this.space = this.bb.capacity(), this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null;
  }
  /**
   * In order to save space, fields that are set to their default value
   * don't get serialized into the buffer. Forcing defaults provides a
   * way to manually disable this optimization.
   *
   * @param forceDefaults true always serializes default values
   */
  forceDefaults(t) {
    this.force_defaults = t;
  }
  /**
   * Get the ByteBuffer representing the FlatBuffer. Only call this after you've
   * called finish(). The actual data starts at the ByteBuffer's current position,
   * not necessarily at 0.
   */
  dataBuffer() {
    return this.bb;
  }
  /**
   * Get the bytes representing the FlatBuffer. Only call this after you've
   * called finish().
   */
  asUint8Array() {
    return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());
  }
  /**
   * Prepare to write an element of `size` after `additional_bytes` have been
   * written, e.g. if you write a string, you need to align such the int length
   * field is aligned to 4 bytes, and the string data follows it directly. If all
   * you need to do is alignment, `additional_bytes` will be 0.
   *
   * @param size This is the of the new element to write
   * @param additional_bytes The padding size
   */
  prep(t, n) {
    t > this.minalign && (this.minalign = t);
    const i = ~(this.bb.capacity() - this.space + n) + 1 & t - 1;
    for (; this.space < i + t + n; ) {
      const r = this.bb.capacity();
      this.bb = LN.growByteBuffer(this.bb), this.space += this.bb.capacity() - r;
    }
    this.pad(i);
  }
  pad(t) {
    for (let n = 0; n < t; n++)
      this.bb.writeInt8(--this.space, 0);
  }
  writeInt8(t) {
    this.bb.writeInt8(this.space -= 1, t);
  }
  writeInt16(t) {
    this.bb.writeInt16(this.space -= 2, t);
  }
  writeInt32(t) {
    this.bb.writeInt32(this.space -= 4, t);
  }
  writeInt64(t) {
    this.bb.writeInt64(this.space -= 8, t);
  }
  writeFloat32(t) {
    this.bb.writeFloat32(this.space -= 4, t);
  }
  writeFloat64(t) {
    this.bb.writeFloat64(this.space -= 8, t);
  }
  /**
   * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int8` to add the buffer.
   */
  addInt8(t) {
    this.prep(1, 0), this.writeInt8(t);
  }
  /**
   * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int16` to add the buffer.
   */
  addInt16(t) {
    this.prep(2, 0), this.writeInt16(t);
  }
  /**
   * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int32` to add the buffer.
   */
  addInt32(t) {
    this.prep(4, 0), this.writeInt32(t);
  }
  /**
   * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int64` to add the buffer.
   */
  addInt64(t) {
    this.prep(8, 0), this.writeInt64(t);
  }
  /**
   * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float32` to add the buffer.
   */
  addFloat32(t) {
    this.prep(4, 0), this.writeFloat32(t);
  }
  /**
   * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float64` to add the buffer.
   */
  addFloat64(t) {
    this.prep(8, 0), this.writeFloat64(t);
  }
  addFieldInt8(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt8(n), this.slot(t));
  }
  addFieldInt16(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt16(n), this.slot(t));
  }
  addFieldInt32(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt32(n), this.slot(t));
  }
  addFieldInt64(t, n, i) {
    (this.force_defaults || n !== i) && (this.addInt64(n), this.slot(t));
  }
  addFieldFloat32(t, n, i) {
    (this.force_defaults || n != i) && (this.addFloat32(n), this.slot(t));
  }
  addFieldFloat64(t, n, i) {
    (this.force_defaults || n != i) && (this.addFloat64(n), this.slot(t));
  }
  addFieldOffset(t, n, i) {
    (this.force_defaults || n != i) && (this.addOffset(n), this.slot(t));
  }
  /**
   * Structs are stored inline, so nothing additional is being added. `d` is always 0.
   */
  addFieldStruct(t, n, i) {
    n != i && (this.nested(n), this.slot(t));
  }
  /**
   * Structures are always stored inline, they need to be created right
   * where they're used.  You'll get this assertion failure if you
   * created it elsewhere.
   */
  nested(t) {
    if (t != this.offset())
      throw new Error("FlatBuffers: struct must be serialized inline.");
  }
  /**
   * Should not be creating any other object, string or vector
   * while an object is being constructed
   */
  notNested() {
    if (this.isNested)
      throw new Error("FlatBuffers: object serialization must not be nested.");
  }
  /**
   * Set the current vtable at `voffset` to the current location in the buffer.
   */
  slot(t) {
    this.vtable !== null && (this.vtable[t] = this.offset());
  }
  /**
   * @returns Offset relative to the end of the buffer.
   */
  offset() {
    return this.bb.capacity() - this.space;
  }
  /**
   * Doubles the size of the backing ByteBuffer and copies the old data towards
   * the end of the new buffer (since we build the buffer backwards).
   *
   * @param bb The current buffer with the existing data
   * @returns A new byte buffer with the old data copied
   * to it. The data is located at the end of the buffer.
   *
   * uint8Array.set() formally takes {Array<number>|ArrayBufferView}, so to pass
   * it a uint8Array we need to suppress the type check:
   * @suppress {checkTypes}
   */
  static growByteBuffer(t) {
    const n = t.capacity();
    if (n & 3221225472)
      throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
    const i = n << 1, r = Lc.allocate(i);
    return r.setPosition(i - n), r.bytes().set(t.bytes(), i - n), r;
  }
  /**
   * Adds on offset, relative to where it will be written.
   *
   * @param offset The offset to add.
   */
  addOffset(t) {
    this.prep(Gi, 0), this.writeInt32(this.offset() - t + Gi);
  }
  /**
   * Start encoding a new object in the buffer.  Users will not usually need to
   * call this directly. The FlatBuffers compiler will generate helper methods
   * that call this method internally.
   */
  startObject(t) {
    this.notNested(), this.vtable == null && (this.vtable = []), this.vtable_in_use = t;
    for (let n = 0; n < t; n++)
      this.vtable[n] = 0;
    this.isNested = !0, this.object_start = this.offset();
  }
  /**
   * Finish off writing the object that is under construction.
   *
   * @returns The offset to the object inside `dataBuffer`
   */
  endObject() {
    if (this.vtable == null || !this.isNested)
      throw new Error("FlatBuffers: endObject called without startObject");
    this.addInt32(0);
    const t = this.offset();
    let n = this.vtable_in_use - 1;
    for (; n >= 0 && this.vtable[n] == 0; n--)
      ;
    const i = n + 1;
    for (; n >= 0; n--)
      this.addInt16(this.vtable[n] != 0 ? t - this.vtable[n] : 0);
    const r = 2;
    this.addInt16(t - this.object_start);
    const s = (i + r) * vm;
    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 l = vm; l < s; l += vm)
            if (this.bb.readInt16(a + l) != this.bb.readInt16(c + l))
              continue t;
          o = this.vtables[n];
          break;
        }
      }
    return o ? (this.space = this.bb.capacity() - t, this.bb.writeInt32(this.space, o - t)) : (this.vtables.push(this.offset()), this.bb.writeInt32(this.bb.capacity() - t, this.offset() - t)), this.isNested = !1, t;
  }
  /**
   * Finalize a buffer, poiting to the given `root_table`.
   */
  finish(t, n, i) {
    const r = i ? le : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, Gi + Rr + r), s.length != Rr)
        throw new Error("FlatBuffers: file identifier must be length " + Rr);
      for (let o = Rr - 1; o >= 0; o--)
        this.writeInt8(s.charCodeAt(o));
    }
    this.prep(this.minalign, Gi + r), this.addOffset(t), r && this.addInt32(this.bb.capacity() - this.space), this.bb.setPosition(this.space);
  }
  /**
   * Finalize a size prefixed buffer, pointing to the given `root_table`.
   */
  finishSizePrefixed(t, n) {
    this.finish(t, n, !0);
  }
  /**
   * This checks a required field has been set in a given table that has
   * just been constructed.
   */
  requiredField(t, n) {
    const i = this.bb.capacity() - t, r = i - this.bb.readInt32(i);
    if (!(n < this.bb.readInt16(r) && this.bb.readInt16(r + n) != 0))
      throw new Error("FlatBuffers: field " + n + " must be set");
  }
  /**
   * Start a new array/vector of objects.  Users usually will not call
   * this directly. The FlatBuffers compiler will create a start/end
   * method for vector types in generated code.
   *
   * @param elem_size The size of each element in the array
   * @param num_elems The number of elements in the array
   * @param alignment The alignment of the array
   */
  startVector(t, n, i) {
    this.notNested(), this.vector_num_elems = n, this.prep(Gi, t * n), this.prep(i, t * n);
  }
  /**
   * Finish off the creation of an array and all its elements. The array must be
   * created with `startVector`.
   *
   * @returns The offset at which the newly created array
   * starts.
   */
  endVector() {
    return this.writeInt32(this.vector_num_elems), this.offset();
  }
  /**
   * Encode the string `s` in the buffer using UTF-8. If the string passed has
   * already been seen, we return the offset of the already written string
   *
   * @param s The string to encode
   * @return The offset in the buffer where the encoded string starts
   */
  createSharedString(t) {
    if (!t)
      return 0;
    if (this.string_maps || (this.string_maps = /* @__PURE__ */ new Map()), this.string_maps.has(t))
      return this.string_maps.get(t);
    const n = this.createString(t);
    return this.string_maps.set(t, n), n;
  }
  /**
   * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed
   * instead of a string, it is assumed to contain valid UTF-8 encoded data.
   *
   * @param s The string to encode
   * @return The offset in the buffer where the encoded string starts
   */
  createString(t) {
    if (t == null)
      return 0;
    let n;
    t instanceof Uint8Array ? n = t : n = this.text_encoder.encode(t), this.addInt8(0), this.startVector(1, n.length, 1), this.bb.setPosition(this.space -= n.length);
    for (let i = 0, r = this.space, s = this.bb.bytes(); i < n.length; i++)
      s[r++] = n[i];
    return this.endVector();
  }
  /**
   * A helper function to pack an object
   *
   * @returns offset of obj
   */
  createObjectOffset(t) {
    return t === null ? 0 : typeof t == "string" ? this.createString(t) : t.pack(this);
  }
  /**
   * A helper function to pack a list of object
   *
   * @returns list of offsets of each non null object
   */
  createObjectOffsetList(t) {
    const n = [];
    for (let i = 0; i < t.length; ++i) {
      const r = t[i];
      if (r !== null)
        n.push(this.createObjectOffset(r));
      else
        throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return n;
  }
  createStructOffsetList(t, n) {
    return n(this, t.length), this.createObjectOffsetList(t.slice().reverse()), this.endVector();
  }
};
class De {
  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 De()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + le), (n || new De()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  key(t) {
    const n = this.bb.__offset(this.bb_pos, 4);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  value(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  static startKeyValue(t) {
    t.startObject(2);
  }
  static addKey(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addValue(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endKeyValue(t) {
    return t.endObject();
  }
  static createKeyValue(t, n, i) {
    return De.startKeyValue(t), De.addKey(t, n), De.addValue(t, i), De.endKeyValue(t);
  }
}
var Rc;
(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";
})(Rc || (Rc = {}));
var Cc;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(Cc || (Cc = {}));
var Op;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(Op || (Op = {}));
class Tn {
  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 Tn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + le), (n || new Tn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  isSigned() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startInt(t) {
    t.startObject(2);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static addIsSigned(t, n) {
    t.addFieldInt8(1, +n, 0);
  }
  static endInt(t) {
    return t.endObject();
  }
  static createInt(t, n, i) {
    return Tn.startInt(t), Tn.addBitWidth(t, n), Tn.addIsSigned(t, i), Tn.endInt(t);
  }
}
class Cr {
  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 Cr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + le), (n || new Cr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * The known dictionary id in the application where this data is used. In
   * the file or streaming formats, the dictionary ids are found in the
   * DictionaryBatch messages
   */
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  /**
   * The dictionary indices are constrained to be non-negative integers. If
   * this field is null, the indices must be signed int32. To maximize
   * cross-language compatibility and performance, implementations are
   * recommended to prefer signed integer types over unsigned integer types
   * and to avoid uint64 indices unless they are required by an application.
   */
  indexType(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Tn()).__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) : Op.DenseArray;
  }
  static startDictionaryEncoding(t) {
    t.startObject(4);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addIndexType(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsOrdered(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static addDictionaryKind(t, n) {
    t.addFieldInt16(3, n, Op.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}
class Do {
  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 Do()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + le), (n || new Do()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return Do.startBinary(t), Do.endBinary(t);
  }
}
class Oo {
  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 Oo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + le), (n || new Oo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return Oo.startBool(t), Oo.endBool(t);
  }
}
var Ep;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Ep || (Ep = {}));
let Th = class Da {
  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 Da()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + le), (n || new Da()).__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) : Ep.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Ep.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return Da.startDate(t), Da.addUnit(t, n), Da.endDate(t);
  }
};
class hn {
  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 hn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + le), (n || new hn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Total number of decimal digits
   */
  precision() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  /**
   * Number of digits after the decimal point "."
   */
  scale() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  /**
   * Number of bits per value. The only accepted widths are 128 and 256.
   * We use bitWidth for consistency with Int::bitWidth.
   */
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.readInt32(this.bb_pos + t) : 128;
  }
  static startDecimal(t) {
    t.startObject(3);
  }
  static addPrecision(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static addScale(t, n) {
    t.addFieldInt32(1, n, 0);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(2, n, 128);
  }
  static endDecimal(t) {
    return t.endObject();
  }
  static createDecimal(t, n, i, r) {
    return hn.startDecimal(t), hn.addPrecision(t, n), hn.addScale(t, i), hn.addBitWidth(t, r), hn.endDecimal(t);
  }
}
var kc;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(kc || (kc = {}));
class Xi {
  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 Xi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + le), (n || new Xi()).__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 Xi.startFixedSizeBinary(t), Xi.addByteWidth(t, n), Xi.endFixedSizeBinary(t);
  }
}
class Hi {
  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 Hi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + le), (n || new Hi()).__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 Hi.startFixedSizeList(t), Hi.addListSize(t, n), Hi.endFixedSizeList(t);
  }
}
var Lp;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(Lp || (Lp = {}));
class Ki {
  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 Ki()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + le), (n || new Ki()).__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) : Lp.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, Lp.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return Ki.startFloatingPoint(t), Ki.addPrecision(t, n), Ki.endFloatingPoint(t);
  }
}
var Rp;
(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";
})(Rp || (Rp = {}));
class Ji {
  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 Ji()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + le), (n || new Ji()).__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) : Rp.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Rp.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return Ji.startInterval(t), Ji.addUnit(t, n), Ji.endInterval(t);
  }
}
class Eo {
  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 Eo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + le), (n || new Eo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return Eo.startList(t), Eo.endList(t);
  }
}
let Bh = class Oa {
  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 Oa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + le), (n || new Oa()).__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 Oa.startMap(t), Oa.addKeysSorted(t, n), Oa.endMap(t);
  }
};
class Lo {
  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 Lo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + le), (n || new Lo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return Lo.startNull(t), Lo.endNull(t);
  }
}
class Ro {
  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 Ro()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + le), (n || new Ro()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return Ro.startStruct_(t), Ro.endStruct_(t);
  }
}
class jn {
  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 jn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + le), (n || new jn()).__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) : kc.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, kc.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, i) {
    return jn.startTime(t), jn.addUnit(t, n), jn.addBitWidth(t, i), jn.endTime(t);
  }
}
class Yn {
  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 Yn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + le), (n || new Yn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : kc.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, kc.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, i) {
    return Yn.startTimestamp(t), Yn.addUnit(t, n), Yn.addTimezone(t, i), Yn.endTimestamp(t);
  }
}
var Cp;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(Cp || (Cp = {}));
class dn {
  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 dn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + le), (n || new dn()).__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) : Cp.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, Cp.Sparse);
  }
  static addTypeIds(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createTypeIdsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addInt32(n[i]);
    return t.endVector();
  }
  static startTypeIdsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endUnion(t) {
    return t.endObject();
  }
  static createUnion(t, n, i) {
    return dn.startUnion(t), dn.addMode(t, n), dn.addTypeIds(t, i), dn.endUnion(t);
  }
}
class Co {
  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 Co()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + le), (n || new Co()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return Co.startUtf8(t), Co.endUtf8(t);
  }
}
var be;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Null = 1] = "Null", e[e.Int = 2] = "Int", e[e.FloatingPoint = 3] = "FloatingPoint", e[e.Binary = 4] = "Binary", e[e.Utf8 = 5] = "Utf8", e[e.Bool = 6] = "Bool", e[e.Decimal = 7] = "Decimal", e[e.Date = 8] = "Date", e[e.Time = 9] = "Time", e[e.Timestamp = 10] = "Timestamp", e[e.Interval = 11] = "Interval", e[e.List = 12] = "List", e[e.Struct_ = 13] = "Struct_", e[e.Union = 14] = "Union", e[e.FixedSizeBinary = 15] = "FixedSizeBinary", e[e.FixedSizeList = 16] = "FixedSizeList", e[e.Map = 17] = "Map", e[e.Duration = 18] = "Duration", e[e.LargeBinary = 19] = "LargeBinary", e[e.LargeUtf8 = 20] = "LargeUtf8", e[e.LargeList = 21] = "LargeList", e[e.RunEndEncoded = 22] = "RunEndEncoded";
})(be || (be = {}));
let zn = class Nh {
  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 Nh()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + le), (n || new Nh()).__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) : be.NONE;
  }
  /**
   * This is the type of the decoded value if the field is dictionary encoded.
   */
  type(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  /**
   * Present only if the field is dictionary encoded.
   */
  dictionary(t) {
    const n = this.bb.__offset(this.bb_pos, 12);
    return n ? (t || new Cr()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * children apply only to nested data types like Struct, List and Union. For
   * primitive types children will have length 0.
   */
  children(t, n) {
    const i = this.bb.__offset(this.bb_pos, 14);
    return i ? (n || new Nh()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  childrenLength() {
    const t = this.bb.__offset(this.bb_pos, 14);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * User-defined metadata
   */
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 16);
    return i ? (n || new De()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 16);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startField(t) {
    t.startObject(7);
  }
  static addName(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addNullable(t, n) {
    t.addFieldInt8(1, +n, 0);
  }
  static addTypeType(t, n) {
    t.addFieldInt8(2, n, be.NONE);
  }
  static addType(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static addDictionary(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static addChildren(t, n) {
    t.addFieldOffset(5, n, 0);
  }
  static createChildrenVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startChildrenVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(6, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endField(t) {
    return t.endObject();
  }
}, Ui = class Mr {
  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 Mr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsSchema(t, n) {
    return t.setPosition(t.position() + le), (n || new Mr()).__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) : Cc.Little;
  }
  fields(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new zn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  fieldsLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new De()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Features used in the stream/file.
   */
  features(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.readInt64(this.bb.__vector(this.bb_pos + n) + t * 8) : BigInt(0);
  }
  featuresLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startSchema(t) {
    t.startObject(4);
  }
  static addEndianness(t, n) {
    t.addFieldInt16(0, n, Cc.Little);
  }
  static addFields(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createFieldsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startFieldsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addFeatures(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static createFeaturesVector(t, n) {
    t.startVector(8, n.length, 8);
    for (let i = n.length - 1; i >= 0; i--)
      t.addInt64(n[i]);
    return t.endVector();
  }
  static startFeaturesVector(t, n) {
    t.startVector(8, n, 8);
  }
  static endSchema(t) {
    return t.endObject();
  }
  static finishSchemaBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedSchemaBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
  static createSchema(t, n, i, r, s) {
    return Mr.startSchema(t), Mr.addEndianness(t, n), Mr.addFields(t, i), Mr.addCustomMetadata(t, r), Mr.addFeatures(t, s), Mr.endSchema(t);
  }
};
class Mn {
  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 Mn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + le), (n || new Mn()).__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) : Rc.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Ui()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  dictionaries(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new o1()).__init(this.bb.__vector(this.bb_pos + i) + t * 24, this.bb) : null;
  }
  dictionariesLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  recordBatches(t, n) {
    const i = this.bb.__offset(this.bb_pos, 10);
    return i ? (n || new o1()).__init(this.bb.__vector(this.bb_pos + i) + t * 24, this.bb) : null;
  }
  recordBatchesLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * User-defined metadata
   */
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new De()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 12);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startFooter(t) {
    t.startObject(5);
  }
  static addVersion(t, n) {
    t.addFieldInt16(0, n, Rc.V1);
  }
  static addSchema(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addDictionaries(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startDictionariesVector(t, n) {
    t.startVector(24, n, 8);
  }
  static addRecordBatches(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static startRecordBatchesVector(t, n) {
    t.startVector(24, n, 8);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endFooter(t) {
    return t.endObject();
  }
  static finishFooterBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedFooterBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
}
class Kt {
  constructor(t = [], n, i) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), i || (i = c1(t)), this.dictionaries = i;
  }
  get [Symbol.toStringTag]() {
    return "Schema";
  }
  get names() {
    return this.fields.map((t) => t.name);
  }
  toString() {
    return `Schema<{ ${this.fields.map((t, n) => `${n}: ${t}`).join(", ")} }>`;
  }
  /**
   * Construct a new Schema containing only specified fields.
   *
   * @param fieldNames Names of fields to keep.
   * @returns A new Schema of fields matching the specified names.
   */
  select(t) {
    const n = new Set(t), i = this.fields.filter((r) => n.has(r.name));
    return new Kt(i, this.metadata);
  }
  /**
   * Construct a new Schema containing only fields at the specified indices.
   *
   * @param fieldIndices Indices of fields to keep.
   * @returns A new Schema of fields at the specified indices.
   */
  selectAt(t) {
    const n = t.map((i) => this.fields[i]).filter(Boolean);
    return new 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), i = [...this.fields], r = ch(ch(/* @__PURE__ */ new Map(), this.metadata), n.metadata), s = n.fields.filter((a) => {
      const c = i.findIndex((l) => l.name === a.name);
      return ~c ? (i[c] = a.clone({
        metadata: ch(ch(/* @__PURE__ */ new Map(), i[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = c1(s, /* @__PURE__ */ new Map());
    return new Kt([...i, ...s], r, new Map([...this.dictionaries, ...o]));
  }
}
Kt.prototype.fields = null;
Kt.prototype.metadata = null;
Kt.prototype.dictionaries = null;
class de {
  /** @nocollapse */
  static new(...t) {
    let [n, i, r, s] = t;
    return t[0] && typeof t[0] == "object" && ({ name: n } = t[0], i === void 0 && (i = t[0].type), r === void 0 && (r = t[0].nullable), s === void 0 && (s = t[0].metadata)), new de(`${n}`, i, r, s);
  }
  constructor(t, n, i = !1, r) {
    this.name = t, this.type = n, this.nullable = i, this.metadata = r || /* @__PURE__ */ new Map();
  }
  get typeId() {
    return this.type.typeId;
  }
  get [Symbol.toStringTag]() {
    return "Field";
  }
  toString() {
    return `${this.name}: ${this.type}`;
  }
  clone(...t) {
    let [n, i, r, s] = t;
    return !t[0] || typeof t[0] != "object" ? [n = this.name, i = this.type, r = this.nullable, s = this.metadata] = t : { name: n = this.name, type: i = this.type, nullable: r = this.nullable, metadata: s = this.metadata } = t[0], de.new(n, i, r, s);
  }
}
de.prototype.type = null;
de.prototype.name = null;
de.prototype.nullable = null;
de.prototype.metadata = null;
function ch(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function c1(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, i = e.length; ++n < i; ) {
    const s = e[n].type;
    if ($t.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 && c1(s.children, t);
  }
  return t;
}
var Vit = EN, jit = Lc;
class dw {
  /** @nocollapse */
  static decode(t) {
    t = new jit(Ht(t));
    const n = Mn.getRootAsFooter(t), i = Kt.decode(n.schema());
    return new Yit(i, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new Vit(), i = Kt.encode(n, t.schema);
    Mn.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      Uc.encode(n, o);
    const r = n.endVector();
    Mn.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      Uc.encode(n, o);
    const s = n.endVector();
    return Mn.startFooter(n), Mn.addSchema(n, i), Mn.addVersion(n, Gn.V4), Mn.addRecordBatches(n, r), Mn.addDictionaries(n, s), Mn.finishFooterBuffer(n, Mn.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  constructor(t, n = Gn.V4, i, r) {
    this.schema = t, this.version = n, i && (this._recordBatches = i), r && (this._dictionaryBatches = r);
  }
  *recordBatches() {
    for (let t, n = -1, i = this.numRecordBatches; ++n < i; )
      (t = this.getRecordBatch(n)) && (yield t);
  }
  *dictionaryBatches() {
    for (let t, n = -1, i = this.numDictionaries; ++n < i; )
      (t = this.getDictionaryBatch(n)) && (yield t);
  }
  getRecordBatch(t) {
    return t >= 0 && t < this.numRecordBatches && this._recordBatches[t] || null;
  }
  getDictionaryBatch(t) {
    return t >= 0 && t < this.numDictionaries && this._dictionaryBatches[t] || null;
  }
}
class Yit extends dw {
  get numRecordBatches() {
    return this._footer.recordBatchesLength();
  }
  get numDictionaries() {
    return this._footer.dictionariesLength();
  }
  constructor(t, n) {
    super(t, n.version()), this._footer = n;
  }
  getRecordBatch(t) {
    if (t >= 0 && t < this.numRecordBatches) {
      const n = this._footer.recordBatches(t);
      if (n)
        return Uc.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return Uc.decode(n);
    }
    return null;
  }
}
class Uc {
  /** @nocollapse */
  static decode(t) {
    return new Uc(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: i } = n, r = BigInt(n.offset), s = BigInt(n.bodyLength);
    return o1.createBlock(t, r, i, s);
  }
  constructor(t, n, i) {
    this.metaDataLength = t, this.offset = Ai(i), this.bodyLength = Ai(n);
  }
}
const xe = Object.freeze({ done: !0, value: void 0 });
class nS {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}
class RN {
  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 qit extends RN {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return Y(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(xe);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return Vn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return Vn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.abort(t), xe;
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), xe;
    });
  }
  read(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(...t) {
    return this._values.length > 0 ? Promise.resolve({ done: !1, value: this._values.shift() }) : this._error ? Promise.reject({ done: !0, value: this._error.error }) : this._closedPromiseResolve ? new Promise((n, i) => {
      this.resolvers.push({ resolve: n, reject: i });
    }) : Promise.resolve(xe);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}
class Wit extends qit {
  write(t) {
    if ((t = Ht(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? e1(this.toUint8Array(!0)) : this.toUint8Array(!1).then(e1);
  }
  toUint8Array(t = !1) {
    return t ? lr(this._values)[0] : (() => Y(this, void 0, void 0, function* () {
      var n, i, r, s;
      const o = [];
      let a = 0;
      try {
        for (var c = !0, l = ti(this), u; u = yield l.next(), n = u.done, !n; ) {
          s = u.value, c = !1;
          try {
            const f = s;
            o.push(f), a += f.byteLength;
          } finally {
            c = !0;
          }
        }
      } catch (f) {
        i = { error: f };
      } finally {
        try {
          !c && !n && (r = l.return) && (yield r.call(l));
        } finally {
          if (i)
            throw i.error;
        }
      }
      return lr(o, a)[0];
    }))();
  }
}
class kp {
  constructor(t) {
    t && (this.source = new Git(Vn.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 zc {
  constructor(t) {
    t instanceof zc ? this.source = t.source : t instanceof Wit ? this.source = new po(Vn.fromAsyncIterable(t)) : mB(t) ? this.source = new po(Vn.fromNodeStream(t)) : ew(t) ? this.source = new po(Vn.fromDOMStream(t)) : pB(t) ? this.source = new po(Vn.fromDOMStream(t.body)) : c0(t) ? this.source = new po(Vn.fromIterable(t)) : Bu(t) ? this.source = new po(Vn.fromAsyncIterable(t)) : tw(t) && (this.source = new po(Vn.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 Git {
  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) || xe);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || xe);
  }
}
class po {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return Y(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || xe;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || xe;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}
class iS extends kp {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Ht(t), this.size = n === void 0 ? this.buffer.byteLength : n;
  }
  readInt32(t) {
    const { buffer: n, byteOffset: i } = this.readAt(t, 4);
    return new DataView(n, i).getInt32(0, !0);
  }
  seek(t) {
    return this.position = Math.min(t, this.size), t < this.size;
  }
  read(t) {
    const { buffer: n, size: i, position: r } = this;
    return n && r < i ? (typeof t != "number" && (t = Number.POSITIVE_INFINITY), this.position = Math.min(i, r + Math.min(i - r, t)), n.subarray(r, this.position)) : null;
  }
  readAt(t, n) {
    const i = this.buffer, r = Math.min(this.size, t + n);
    return i ? i.subarray(t, r) : new Uint8Array(n);
  }
  close() {
    this.buffer && (this.buffer = null);
  }
  throw(t) {
    return this.close(), { done: !0, value: t };
  }
  return(t) {
    return this.close(), { done: !0, value: t };
  }
}
class Up extends zc {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = (() => Y(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    }))();
  }
  readInt32(t) {
    return Y(this, void 0, void 0, function* () {
      const { buffer: n, byteOffset: i } = yield this.readAt(t, 4);
      return new DataView(n, i).getInt32(0, !0);
    });
  }
  seek(t) {
    return Y(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 Y(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: n, size: i, position: r } = this;
      if (n && r < i) {
        typeof t != "number" && (t = Number.POSITIVE_INFINITY);
        let s = r, o = 0, a = 0;
        const c = Math.min(i, s + Math.min(i - s, t)), l = new Uint8Array(Math.max(0, (this.position = c) - s));
        for (; (s += a) < c && (o += a) < l.byteLength; )
          ({ bytesRead: a } = yield n.read(l, o, l.byteLength - o, s));
        return l;
      }
      return null;
    });
  }
  readAt(t, n) {
    return Y(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: i, size: r } = this;
      if (i && t + n < r) {
        const s = Math.min(r, t + n), o = new Uint8Array(s - t);
        return (yield i.read(o, 0, n, t)).buffer;
      }
      return new Uint8Array(n);
    });
  }
  close() {
    return Y(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
}
const Xit = 65536;
function za(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const Pc = 8, pw = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
class CN {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return this.buffer[1];
  }
  low() {
    return this.buffer[0];
  }
  _times(t) {
    const n = new Uint32Array([
      this.buffer[1] >>> 16,
      this.buffer[1] & 65535,
      this.buffer[0] >>> 16,
      this.buffer[0] & 65535
    ]), i = new Uint32Array([
      t.buffer[1] >>> 16,
      t.buffer[1] & 65535,
      t.buffer[0] >>> 16,
      t.buffer[0] & 65535
    ]);
    let r = n[3] * i[3];
    this.buffer[0] = r & 65535;
    let s = r >>> 16;
    return r = n[2] * i[3], s += r, r = n[3] * i[2] >>> 0, s += r, this.buffer[0] += s << 16, this.buffer[1] = s >>> 0 < r ? Xit : 0, this.buffer[1] += s >>> 16, this.buffer[1] += n[1] * i[3] + n[2] * i[2] + n[3] * i[1], this.buffer[1] += n[0] * i[3] + n[1] * i[2] + n[2] * i[1] + n[3] * i[0] << 16, this;
  }
  _plus(t) {
    const n = this.buffer[0] + t.buffer[0] >>> 0;
    this.buffer[1] += t.buffer[1], n < this.buffer[0] >>> 0 && ++this.buffer[1], this.buffer[0] = n;
  }
  lessThan(t) {
    return this.buffer[1] < t.buffer[1] || this.buffer[1] === t.buffer[1] && this.buffer[0] < t.buffer[0];
  }
  equals(t) {
    return this.buffer[1] === t.buffer[1] && this.buffer[0] == t.buffer[0];
  }
  greaterThan(t) {
    return t.lessThan(this);
  }
  hex() {
    return `${za(this.buffer[1])} ${za(this.buffer[0])}`;
  }
}
class Jt extends CN {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Jt.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Jt.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.length, r = new Jt(n);
    for (let s = 0; s < i; ) {
      const o = Pc < i - s ? Pc : i - s, a = new Jt(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Jt(new Uint32Array([pw[o], 0]));
      r.times(c), r.plus(a), s += o;
    }
    return r;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      Jt.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Jt(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Jt(new Uint32Array(t.buffer)).plus(n);
  }
}
class fn extends CN {
  negate() {
    return this.buffer[0] = ~this.buffer[0] + 1, this.buffer[1] = ~this.buffer[1], this.buffer[0] == 0 && ++this.buffer[1], this;
  }
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  lessThan(t) {
    const n = this.buffer[1] << 0, i = t.buffer[1] << 0;
    return n < i || n === i && this.buffer[0] < t.buffer[0];
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return fn.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return fn.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.startsWith("-"), r = t.length, s = new fn(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = Pc < r - o ? Pc : r - o, c = new fn(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), l = new fn(new Uint32Array([pw[a], 0]));
      s.times(l), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      fn.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new fn(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new fn(new Uint32Array(t.buffer)).plus(n);
  }
}
class zi {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new fn(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new fn(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 Jt(new Uint32Array([this.buffer[3], 0])), i = new Jt(new Uint32Array([this.buffer[2], 0])), r = new Jt(new Uint32Array([this.buffer[1], 0])), s = new Jt(new Uint32Array([this.buffer[0], 0])), o = new Jt(new Uint32Array([t.buffer[3], 0])), a = new Jt(new Uint32Array([t.buffer[2], 0])), c = new Jt(new Uint32Array([t.buffer[1], 0])), l = new Jt(new Uint32Array([t.buffer[0], 0]));
    let u = Jt.multiply(s, l);
    this.buffer[0] = u.low();
    const f = new Jt(new Uint32Array([u.high(), 0]));
    return u = Jt.multiply(r, l), f.plus(u), u = Jt.multiply(s, c), f.plus(u), this.buffer[1] = f.low(), this.buffer[3] = f.lessThan(u) ? 1 : 0, this.buffer[2] = f.high(), new Jt(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(Jt.multiply(i, l)).plus(Jt.multiply(r, c)).plus(Jt.multiply(s, a)), this.buffer[3] += Jt.multiply(n, l).plus(Jt.multiply(i, c)).plus(Jt.multiply(r, a)).plus(Jt.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 `${za(this.buffer[3])} ${za(this.buffer[2])} ${za(this.buffer[1])} ${za(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new zi(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new zi(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return zi.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return zi.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const i = t.startsWith("-"), r = t.length, s = new zi(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = Pc < r - o ? Pc : r - o, c = new zi(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), l = new zi(new Uint32Array([pw[a], 0, 0, 0]));
      s.times(l), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 4);
    for (let i = -1, r = t.length; ++i < r; )
      zi.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * i, 4));
    return n;
  }
}
class kN extends zt {
  constructor(t, n, i, r) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = i, this.dictionaries = r;
  }
  visit(t) {
    return super.visit(t instanceof de ? t.type : t);
  }
  visitNull(t, { length: n } = this.nextFieldNode()) {
    return Ct({ type: t, length: n });
  }
  visitBool(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitInt(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFloat(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitUtf8(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitFixedSizeBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDate(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTimestamp(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTime(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDecimal(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  visitStruct(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), children: this.visitMany(t.children) });
  }
  visitUnion(t) {
    return t.mode === $i.Sparse ? this.visitSparseUnion(t) : this.visitDenseUnion(t);
  }
  visitDenseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), typeIds: this.readTypeIds(t), valueOffsets: this.readOffsets(t), children: this.visitMany(t.children) });
  }
  visitSparseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), typeIds: this.readTypeIds(t), children: this.visitMany(t.children) });
  }
  visitDictionary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t.indices), dictionary: this.readDictionary(t) });
  }
  visitInterval(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFixedSizeList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), child: this.visit(t.children[0]) });
  }
  visitMap(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  nextFieldNode() {
    return this.nodes[++this.nodesIndex];
  }
  nextBufferRange() {
    return this.buffers[++this.buffersIndex];
  }
  readNullBitmap(t, n, i = this.nextBufferRange()) {
    return n > 0 && this.readData(t, i) || new Uint8Array(0);
  }
  readOffsets(t, n) {
    return this.readData(t, n);
  }
  readTypeIds(t, n) {
    return this.readData(t, n);
  }
  readData(t, { length: n, offset: i } = this.nextBufferRange()) {
    return this.bytes.subarray(i, i + n);
  }
  readDictionary(t) {
    return this.dictionaries.get(t.id);
  }
}
class Hit extends kN {
  constructor(t, n, i, r) {
    super(new Uint8Array(0), n, i, r), this.sources = t;
  }
  readNullBitmap(t, n, { offset: i } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : r1(this.sources[i]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return ie(Uint8Array, ie(Int32Array, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return ie(Uint8Array, ie(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: i } = this;
    return $t.isTimestamp(t) || ($t.isInt(t) || $t.isTime(t)) && t.bitWidth === 64 || $t.isDate(t) && t.unit === is.MILLISECOND ? ie(Uint8Array, fn.convertArray(i[n])) : $t.isDecimal(t) ? ie(Uint8Array, zi.convertArray(i[n])) : $t.isBinary(t) || $t.isFixedSizeBinary(t) ? Kit(i[n]) : $t.isBool(t) ? r1(i[n]) : $t.isUtf8(t) ? Q_(i[n].join("")) : ie(Uint8Array, ie(t.ArrayType, i[n].map((r) => +r)));
  }
}
function Kit(e) {
  const t = e.join(""), n = new Uint8Array(t.length / 2);
  for (let i = 0; i < t.length; i += 2)
    n[i >> 1] = Number.parseInt(t.slice(i, i + 2), 16);
  return n;
}
class bt extends zt {
  compareSchemas(t, n) {
    return t === n || n instanceof t.constructor && this.compareManyFields(t.fields, n.fields);
  }
  compareManyFields(t, n) {
    return t === n || Array.isArray(t) && Array.isArray(n) && t.length === n.length && t.every((i, r) => this.compareFields(i, n[r]));
  }
  compareFields(t, n) {
    return t === n || n instanceof t.constructor && t.name === n.name && t.nullable === n.nullable && this.visit(t.type, n.type);
  }
}
function $n(e, t) {
  return t instanceof e.constructor;
}
function wf(e, t) {
  return e === t || $n(e, t);
}
function ds(e, t) {
  return e === t || $n(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function u0(e, t) {
  return e === t || $n(e, t) && e.precision === t.precision;
}
function Jit(e, t) {
  return e === t || $n(e, t) && e.byteWidth === t.byteWidth;
}
function yw(e, t) {
  return e === t || $n(e, t) && e.unit === t.unit;
}
function vf(e, t) {
  return e === t || $n(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function xf(e, t) {
  return e === t || $n(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function Zit(e, t) {
  return e === t || $n(e, t) && e.children.length === t.children.length && Ks.compareManyFields(e.children, t.children);
}
function Qit(e, t) {
  return e === t || $n(e, t) && e.children.length === t.children.length && Ks.compareManyFields(e.children, t.children);
}
function mw(e, t) {
  return e === t || $n(e, t) && e.mode === t.mode && e.typeIds.every((n, i) => n === t.typeIds[i]) && Ks.compareManyFields(e.children, t.children);
}
function trt(e, t) {
  return e === t || $n(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && Ks.visit(e.indices, t.indices) && Ks.visit(e.dictionary, t.dictionary);
}
function gw(e, t) {
  return e === t || $n(e, t) && e.unit === t.unit;
}
function ert(e, t) {
  return e === t || $n(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && Ks.compareManyFields(e.children, t.children);
}
function nrt(e, t) {
  return e === t || $n(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && Ks.compareManyFields(e.children, t.children);
}
bt.prototype.visitNull = wf;
bt.prototype.visitBool = wf;
bt.prototype.visitInt = ds;
bt.prototype.visitInt8 = ds;
bt.prototype.visitInt16 = ds;
bt.prototype.visitInt32 = ds;
bt.prototype.visitInt64 = ds;
bt.prototype.visitUint8 = ds;
bt.prototype.visitUint16 = ds;
bt.prototype.visitUint32 = ds;
bt.prototype.visitUint64 = ds;
bt.prototype.visitFloat = u0;
bt.prototype.visitFloat16 = u0;
bt.prototype.visitFloat32 = u0;
bt.prototype.visitFloat64 = u0;
bt.prototype.visitUtf8 = wf;
bt.prototype.visitBinary = wf;
bt.prototype.visitFixedSizeBinary = Jit;
bt.prototype.visitDate = yw;
bt.prototype.visitDateDay = yw;
bt.prototype.visitDateMillisecond = yw;
bt.prototype.visitTimestamp = vf;
bt.prototype.visitTimestampSecond = vf;
bt.prototype.visitTimestampMillisecond = vf;
bt.prototype.visitTimestampMicrosecond = vf;
bt.prototype.visitTimestampNanosecond = vf;
bt.prototype.visitTime = xf;
bt.prototype.visitTimeSecond = xf;
bt.prototype.visitTimeMillisecond = xf;
bt.prototype.visitTimeMicrosecond = xf;
bt.prototype.visitTimeNanosecond = xf;
bt.prototype.visitDecimal = wf;
bt.prototype.visitList = Zit;
bt.prototype.visitStruct = Qit;
bt.prototype.visitUnion = mw;
bt.prototype.visitDenseUnion = mw;
bt.prototype.visitSparseUnion = mw;
bt.prototype.visitDictionary = trt;
bt.prototype.visitInterval = gw;
bt.prototype.visitIntervalDayTime = gw;
bt.prototype.visitIntervalYearMonth = gw;
bt.prototype.visitFixedSizeList = ert;
bt.prototype.visitMap = nrt;
const Ks = new bt();
function irt(e, t) {
  return Ks.compareSchemas(e, t);
}
function xm(e, t) {
  return rrt(e, t.map((n) => n.data.concat()));
}
function rrt(e, t) {
  const n = [...e.fields], i = [], r = { numBatches: t.reduce((f, h) => Math.max(f, h.length), 0) };
  let s = 0, o = 0, a = -1;
  const c = t.length;
  let l, u = [];
  for (; r.numBatches-- > 0; ) {
    for (o = Number.POSITIVE_INFINITY, a = -1; ++a < c; )
      u[a] = l = t[a].shift(), o = Math.min(o, l ? l.length : o);
    Number.isFinite(o) && (u = srt(n, o, u, t, r), o > 0 && (i[s++] = Ct({
      type: new an(n),
      length: o,
      nullCount: 0,
      children: u.slice()
    })));
  }
  return [
    e = e.assign(n),
    i.map((f) => new ui(e, f))
  ];
}
function srt(e, t, n, i, r) {
  var s;
  const o = (t + 63 & -64) >> 3;
  for (let a = -1, c = i.length; ++a < c; ) {
    const l = n[a], u = l == null ? void 0 : l.length;
    if (u >= t)
      u === t ? n[a] = l : (n[a] = l.slice(0, t), r.numBatches = Math.max(r.numBatches, i[a].unshift(l.slice(t, u - t))));
    else {
      const f = e[a];
      e[a] = f.clone({ nullable: !0 }), n[a] = (s = l == null ? void 0 : l._changeLengthAndBackfillNullBitmap(t)) !== null && s !== void 0 ? s : Ct({
        type: f.type,
        length: t,
        nullCount: t,
        nullBitmap: new Uint8Array(o)
      });
    }
  }
  return n;
}
var UN;
class qn {
  constructor(...t) {
    var n, i;
    if (t.length === 0)
      return this.batches = [], this.schema = new Kt([]), this._offsets = [0], this;
    let r, s;
    t[0] instanceof Kt && (r = t.shift()), t[t.length - 1] instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof ui)
          return [c];
        if (c instanceof qn)
          return c.batches;
        if (c instanceof ue) {
          if (c.type instanceof an)
            return [new ui(new Kt(c.type.children), c)];
        } else {
          if (Array.isArray(c))
            return c.flatMap((l) => o(l));
          if (typeof c[Symbol.iterator] == "function")
            return [...c].flatMap((l) => o(l));
          if (typeof c == "object") {
            const l = Object.keys(c), u = l.map((d) => new te([c[d]])), f = new Kt(l.map((d, p) => new de(String(d), u[p].type))), [, h] = xm(f, u);
            return h.length === 0 ? [new ui(c)] : h;
          }
        }
      }
      return [];
    }, a = t.flatMap((c) => o(c));
    if (r = (i = r ?? ((n = a[0]) === null || n === void 0 ? void 0 : n.schema)) !== null && i !== void 0 ? i : new Kt([]), !(r instanceof Kt))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof ui))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!irt(r, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = r, this.batches = a, this._offsets = s ?? SN(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 = xN(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 ? hw.visit(new te(this.data)) : new Array(0)[Symbol.iterator]();
  }
  /**
   * Return a JavaScript Array of the Table rows.
   *
   * @returns An Array of Table rows.
   */
  toArray() {
    return [...this];
  }
  /**
   * Returns a string representation of the Table rows.
   *
   * @returns A string representation of the Table rows.
   */
  toString() {
    return `[
  ${this.toArray().join(`,
  `)}
]`;
  }
  /**
   * Combines two or more Tables of the same schema.
   *
   * @param others Additional Tables to add to the end of this Tables.
   */
  concat(...t) {
    const n = this.schema, i = this.data.concat(t.flatMap(({ data: r }) => r));
    return new qn(n, i.map((r) => new ui(n, r)));
  }
  /**
   * Return a zero-copy sub-section of this Table.
   *
   * @param begin The beginning of the specified portion of the Table.
   * @param end The end of the specified portion of the Table. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    const i = this.schema;
    [t, n] = wN({ length: this.numRows }, t, n);
    const r = IN(this.data, this._offsets, t, n);
    return new qn(i, r.map((s) => new ui(i, s)));
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   *
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    return this.getChildAt(this.schema.fields.findIndex((n) => n.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   *
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    if (t > -1 && t < this.schema.fields.length) {
      const n = this.data.map((i) => i.children[t]);
      if (n.length === 0) {
        const { type: i } = this.schema.fields[t], r = Ct({ type: i, length: 0, nullCount: 0 });
        n.push(r._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new te(n);
    }
    return null;
  }
  /**
   * Sets a child Vector by name.
   *
   * @param name The name of the child to overwrite.
   * @returns A new Table with the supplied child for the specified name.
   */
  setChild(t, n) {
    var i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = [...this.batches];
    if (t > -1 && t < this.numCols) {
      n || (n = new te([Ct({ type: new Xs(), length: this.numRows })]));
      const s = i.fields.slice(), o = s[t].clone({ type: n.type }), a = this.schema.fields.map((c, l) => this.getChildAt(l));
      [s[t], a[t]] = [o, n], [i, r] = xm(i, a);
    }
    return new qn(i, r);
  }
  /**
   * Construct a new Table containing only specified columns.
   *
   * @param columnNames Names of columns to keep.
   * @returns A new Table of columns matching the specified names.
   */
  select(t) {
    const n = this.schema.fields.reduce((i, r, s) => i.set(r.name, s), /* @__PURE__ */ new Map());
    return this.selectAt(t.map((i) => n.get(i)).filter((i) => i > -1));
  }
  /**
   * Construct a new Table containing only columns at the specified indices.
   *
   * @param columnIndices Indices of columns to keep.
   * @returns A new Table of columns at the specified indices.
   */
  selectAt(t) {
    const n = this.schema.selectAt(t), i = this.batches.map((r) => r.selectAt(t));
    return new qn(n, i);
  }
  assign(t) {
    const n = this.schema.fields, [i, r] = t.schema.fields.reduce((a, c, l) => {
      const [u, f] = a, h = n.findIndex((d) => d.name === c.name);
      return ~h ? f[h] = l : u.push(l), a;
    }, [[], []]), s = this.schema.assign(t.schema), o = [
      ...n.map((a, c) => [c, r[c]]).map(([a, c]) => c === void 0 ? this.getChildAt(a) : t.getChildAt(c)),
      ...i.map((a) => t.getChildAt(a))
    ].filter(Boolean);
    return new qn(...xm(s, o));
  }
}
UN = Symbol.toStringTag;
qn[UN] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = cc(fw), e.get = cc(xn.getVisitFn(C.Struct)), e.set = $N(ri.getVisitFn(C.Struct)), e.indexOf = AN(Fp.getVisitFn(C.Struct)), e.getByteLength = cc(ur.getVisitFn(C.Struct)), "Table"))(qn.prototype);
var zN;
let ui = class Pl {
  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 = Ct({
            nullCount: 0,
            type: new an(this.schema.fields),
            children: this.schema.fields.map((n) => Ct({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof ue))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = rS(this.schema, this.data.children);
        break;
      }
      case 1: {
        const [n] = t, { fields: i, children: r, length: s } = Object.keys(n).reduce((c, l, u) => (c.children[u] = n[l], c.length = Math.max(c.length, n[l].length), c.fields[u] = de.new({ name: l, type: n[l].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new Kt(i), a = Ct({ type: new an(i), length: s, children: r, nullCount: 0 });
        [this.schema, this.data] = rS(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 = PN(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 xn.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 ri.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 Fp.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 ur.visit(this.data, t);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return hw.visit(new te([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 qn(this.schema, [this, ...t]);
  }
  /**
   * Return a zero-copy sub-section of this RecordBatch.
   * @param start The beginning of the specified portion of the RecordBatch.
   * @param end The end of the specified portion of the RecordBatch. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    const [i] = new te([this.data]).slice(t, n).data;
    return new Pl(this.schema, i);
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    var n;
    return this.getChildAt((n = this.schema.fields) === null || n === void 0 ? void 0 : n.findIndex((i) => i.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    return t > -1 && t < this.schema.fields.length ? new te([this.data.children[t]]) : null;
  }
  /**
   * Sets a child Vector by name.
   * @param name The name of the child to overwrite.
   * @returns A new RecordBatch with the new child for the specified name.
   */
  setChild(t, n) {
    var i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = this.data;
    if (t > -1 && t < this.numCols) {
      n || (n = new te([Ct({ type: new Xs(), length: this.numRows })]));
      const s = i.fields.slice(), o = r.children.slice(), a = s[t].clone({ type: n.type });
      [s[t], o[t]] = [a, n.data[0]], i = new Kt(s, new Map(this.schema.metadata)), r = Ct({ type: new an(s), children: o });
    }
    return new Pl(i, r);
  }
  /**
   * Construct a new RecordBatch containing only specified columns.
   *
   * @param columnNames Names of columns to keep.
   * @returns A new RecordBatch of columns matching the specified names.
   */
  select(t) {
    const n = this.schema.select(t), i = new an(n.fields), r = [];
    for (const s of t) {
      const o = this.schema.fields.findIndex((a) => a.name === s);
      ~o && (r[o] = this.data.children[o]);
    }
    return new Pl(n, Ct({ type: i, length: this.numRows, children: r }));
  }
  /**
   * Construct a new RecordBatch containing only columns at the specified indices.
   *
   * @param columnIndices Indices of columns to keep.
   * @returns A new RecordBatch of columns matching at the specified indices.
   */
  selectAt(t) {
    const n = this.schema.selectAt(t), i = t.map((s) => this.data.children[s]).filter(Boolean), r = Ct({ type: new an(n.fields), length: this.numRows, children: i });
    return new Pl(n, r);
  }
};
zN = Symbol.toStringTag;
ui[zN] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(ui.prototype);
function rS(e, t, n = t.reduce((i, r) => Math.max(i, r.length), 0)) {
  var i;
  const r = [...e.fields], s = [...t], o = (n + 63 & -64) >> 3;
  for (const [a, c] of e.fields.entries()) {
    const l = t[a];
    (!l || l.length !== n) && (r[a] = c.clone({ nullable: !0 }), s[a] = (i = l == null ? void 0 : l._changeLengthAndBackfillNullBitmap(n)) !== null && i !== void 0 ? i : Ct({
      type: c.type,
      length: n,
      nullCount: n,
      nullBitmap: new Uint8Array(o)
    }));
  }
  return [
    e.assign(r),
    Ct({ type: new an(r), length: n, children: s })
  ];
}
function PN(e, t, n = /* @__PURE__ */ new Map()) {
  for (let i = -1, r = e.length; ++i < r; ) {
    const o = e[i].type, a = t[i];
    if ($t.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 && PN(o.children, a.children, n);
  }
  return n;
}
class VN extends ui {
  constructor(t) {
    const n = t.fields.map((r) => Ct({ type: r.type })), i = Ct({ type: new an(t.fields), nullCount: 0, children: n });
    super(t, i);
  }
}
var zp;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(zp || (zp = {}));
var Pp;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(Pp || (Pp = {}));
class xs {
  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 xs()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + le), (n || new xs()).__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) : Pp.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) : zp.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, Pp.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, zp.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, i) {
    return xs.startBodyCompression(t), xs.addCodec(t, n), xs.addMethod(t, i), xs.endBodyCompression(t);
  }
}
class jN {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * The relative offset into the shared memory page where the bytes for this
   * buffer starts
   */
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * The absolute length (in bytes) of the memory buffer. The memory is found
   * from offset (inclusive) to offset + length (non-inclusive). When building
   * messages using the encapsulated IPC message, padding bytes may be written
   * after a buffer, but such padding bytes do not need to be accounted for in
   * the size here.
   */
  length() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createBuffer(t, n, i) {
    return t.prep(8, 16), t.writeInt64(BigInt(i ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}
let YN = class {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * The number of value slots in the Arrow array at this level of a nested
   * tree
   */
  length() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * The number of observed nulls. Fields with null_count == 0 may choose not
   * to write their physical validity bitmap out as a materialized buffer,
   * instead setting the length of the bitmap buffer to 0.
   */
  nullCount() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createFieldNode(t, n, i) {
    return t.prep(8, 16), t.writeInt64(BigInt(i ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, Or = class l1 {
  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 l1()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + le), (n || new l1()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * number of records / rows. The arrays in the batch should all have this
   * length
   */
  length() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  /**
   * Nodes correspond to the pre-ordered flattened logical schema
   */
  nodes(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new YN()).__init(this.bb.__vector(this.bb_pos + i) + t * 16, this.bb) : null;
  }
  nodesLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Buffers correspond to the pre-ordered flattened buffer tree
   *
   * The number of buffers appended to this list depends on the schema. For
   * example, most primitive arrays will have 2 buffers, 1 for the validity
   * bitmap and 1 for the values. For struct arrays, there will only be a
   * single buffer for the validity (nulls) bitmap
   */
  buffers(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new jN()).__init(this.bb.__vector(this.bb_pos + i) + t * 16, this.bb) : null;
  }
  buffersLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Optional compression of the message body
   */
  compression(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? (t || new xs()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  static startRecordBatch(t) {
    t.startObject(4);
  }
  static addLength(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addNodes(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static startNodesVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addBuffers(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startBuffersVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addCompression(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static endRecordBatch(t) {
    return t.endObject();
  }
}, Ea = class u1 {
  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 u1()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + le), (n || new u1()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  data(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Or()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * If isDelta is true the values in the dictionary are to be appended to a
   * dictionary with the indicated id. If isDelta is false this dictionary
   * should replace the existing dictionary.
   */
  isDelta() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startDictionaryBatch(t) {
    t.startObject(3);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addData(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsDelta(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static endDictionaryBatch(t) {
    return t.endObject();
  }
};
var Vp;
(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";
})(Vp || (Vp = {}));
let ms = class Ci {
  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 Ci()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + le), (n || new Ci()).__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) : Rc.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : Vp.NONE;
  }
  header(t) {
    const n = this.bb.__offset(this.bb_pos, 8);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  bodyLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  customMetadata(t, n) {
    const i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new De()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 12);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startMessage(t) {
    t.startObject(5);
  }
  static addVersion(t, n) {
    t.addFieldInt16(0, n, Rc.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, Vp.NONE);
  }
  static addHeader(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static addBodyLength(t, n) {
    t.addFieldInt64(3, n, BigInt("0"));
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endMessage(t) {
    return t.endObject();
  }
  static finishMessageBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedMessageBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
  static createMessage(t, n, i, r, s, o) {
    return Ci.startMessage(t), Ci.addVersion(t, n), Ci.addHeaderType(t, i), Ci.addHeader(t, r), Ci.addBodyLength(t, s), Ci.addCustomMetadata(t, o), Ci.endMessage(t);
  }
};
class ort extends zt {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return Lo.startNull(n), Lo.endNull(n);
  }
  visitInt(t, n) {
    return Tn.startInt(n), Tn.addBitWidth(n, t.bitWidth), Tn.addIsSigned(n, t.isSigned), Tn.endInt(n);
  }
  visitFloat(t, n) {
    return Ki.startFloatingPoint(n), Ki.addPrecision(n, t.precision), Ki.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return Do.startBinary(n), Do.endBinary(n);
  }
  visitBool(t, n) {
    return Oo.startBool(n), Oo.endBool(n);
  }
  visitUtf8(t, n) {
    return Co.startUtf8(n), Co.endUtf8(n);
  }
  visitDecimal(t, n) {
    return hn.startDecimal(n), hn.addScale(n, t.scale), hn.addPrecision(n, t.precision), hn.addBitWidth(n, t.bitWidth), hn.endDecimal(n);
  }
  visitDate(t, n) {
    return Th.startDate(n), Th.addUnit(n, t.unit), Th.endDate(n);
  }
  visitTime(t, n) {
    return jn.startTime(n), jn.addUnit(n, t.unit), jn.addBitWidth(n, t.bitWidth), jn.endTime(n);
  }
  visitTimestamp(t, n) {
    const i = t.timezone && n.createString(t.timezone) || void 0;
    return Yn.startTimestamp(n), Yn.addUnit(n, t.unit), i !== void 0 && Yn.addTimezone(n, i), Yn.endTimestamp(n);
  }
  visitInterval(t, n) {
    return Ji.startInterval(n), Ji.addUnit(n, t.unit), Ji.endInterval(n);
  }
  visitList(t, n) {
    return Eo.startList(n), Eo.endList(n);
  }
  visitStruct(t, n) {
    return Ro.startStruct_(n), Ro.endStruct_(n);
  }
  visitUnion(t, n) {
    dn.startTypeIdsVector(n, t.typeIds.length);
    const i = dn.createTypeIdsVector(n, t.typeIds);
    return dn.startUnion(n), dn.addMode(n, t.mode), dn.addTypeIds(n, i), dn.endUnion(n);
  }
  visitDictionary(t, n) {
    const i = this.visit(t.indices, n);
    return Cr.startDictionaryEncoding(n), Cr.addId(n, BigInt(t.id)), Cr.addIsOrdered(n, t.isOrdered), i !== void 0 && Cr.addIndexType(n, i), Cr.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return Xi.startFixedSizeBinary(n), Xi.addByteWidth(n, t.byteWidth), Xi.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return Hi.startFixedSizeList(n), Hi.addListSize(n, t.listSize), Hi.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return Bh.startMap(n), Bh.addKeysSorted(n, t.keysSorted), Bh.endMap(n);
  }
}
const Sm = new ort();
function art(e, t = /* @__PURE__ */ new Map()) {
  return new Kt(lrt(e, t), Fh(e.customMetadata), t);
}
function qN(e) {
  return new Mi(e.count, WN(e.columns), GN(e.columns));
}
function crt(e) {
  return new rs(qN(e.data), e.id, e.isDelta);
}
function lrt(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => de.fromJSON(n, t));
}
function sS(e, t) {
  return (e.children || []).filter(Boolean).map((n) => de.fromJSON(n, t));
}
function WN(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new al(n.count, urt(n.VALIDITY)),
    ...WN(n.children)
  ], []);
}
function GN(e, t = []) {
  for (let n = -1, i = (e || []).length; ++n < i; ) {
    const r = e[n];
    r.VALIDITY && t.push(new Yr(t.length, r.VALIDITY.length)), r.TYPE && t.push(new Yr(t.length, r.TYPE.length)), r.OFFSET && t.push(new Yr(t.length, r.OFFSET.length)), r.DATA && t.push(new Yr(t.length, r.DATA.length)), t = GN(r.children, t);
  }
  return t;
}
function urt(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function frt(e, t) {
  let n, i, r, s, o, a;
  return !t || !(s = e.dictionary) ? (o = aS(e, sS(e, t)), r = new de(e.name, o, e.nullable, Fh(e.customMetadata))) : t.has(n = s.id) ? (i = (i = s.indexType) ? oS(i) : new Du(), a = new Ec(t.get(n), i, n, s.isOrdered), r = new de(e.name, a, e.nullable, Fh(e.customMetadata))) : (i = (i = s.indexType) ? oS(i) : new Du(), t.set(n, o = aS(e, sS(e, t))), a = new Ec(o, i, n, s.isOrdered), r = new de(e.name, a, e.nullable, Fh(e.customMetadata))), r || null;
}
function Fh(e) {
  return new Map(Object.entries(e || {}));
}
function oS(e) {
  return new Hs(e.isSigned, e.bitWidth);
}
function aS(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new Xs();
    case "null":
      return new Xs();
    case "binary":
      return new _p();
    case "utf8":
      return new wp();
    case "bool":
      return new vp();
    case "list":
      return new Ap((t || [])[0]);
    case "struct":
      return new an(t || []);
    case "struct_":
      return new an(t || []);
  }
  switch (n) {
    case "int": {
      const i = e.type;
      return new Hs(i.isSigned, i.bitWidth);
    }
    case "floatingpoint": {
      const i = e.type;
      return new Ou(mn[i.precision]);
    }
    case "decimal": {
      const i = e.type;
      return new xp(i.scale, i.precision, i.bitWidth);
    }
    case "date": {
      const i = e.type;
      return new Sp(is[i.unit]);
    }
    case "time": {
      const i = e.type;
      return new Eu(Yt[i.unit], i.bitWidth);
    }
    case "timestamp": {
      const i = e.type;
      return new Ip(Yt[i.unit], i.timezone);
    }
    case "interval": {
      const i = e.type;
      return new $p(Gs[i.unit]);
    }
    case "union": {
      const i = e.type;
      return new Mp($i[i.mode], i.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const i = e.type;
      return new Tp(i.byteWidth);
    }
    case "fixedsizelist": {
      const i = e.type;
      return new Bp(i.listSize, (t || [])[0]);
    }
    case "map": {
      const i = e.type;
      return new Np((t || [])[0], i.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var hrt = EN, drt = Lc;
class di {
  /** @nocollapse */
  static fromJSON(t, n) {
    const i = new di(0, Gn.V4, n);
    return i._createHeader = prt(t, n), i;
  }
  /** @nocollapse */
  static decode(t) {
    t = new drt(Ht(t));
    const n = ms.getRootAsMessage(t), i = n.bodyLength(), r = n.version(), s = n.headerType(), o = new di(i, r, s);
    return o._createHeader = yrt(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new hrt();
    let i = -1;
    return t.isSchema() ? i = Kt.encode(n, t.header()) : t.isRecordBatch() ? i = Mi.encode(n, t.header()) : t.isDictionaryBatch() && (i = rs.encode(n, t.header())), ms.startMessage(n), ms.addVersion(n, Gn.V4), ms.addHeader(n, i), ms.addHeaderType(n, t.headerType), ms.addBodyLength(n, BigInt(t.bodyLength)), ms.finishMessageBuffer(n, ms.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof Kt)
      return new di(0, Gn.V4, Qt.Schema, t);
    if (t instanceof Mi)
      return new di(n, Gn.V4, Qt.RecordBatch, t);
    if (t instanceof rs)
      return new di(n, Gn.V4, Qt.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 === Qt.Schema;
  }
  isRecordBatch() {
    return this.headerType === Qt.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === Qt.DictionaryBatch;
  }
  constructor(t, n, i, r) {
    this._version = n, this._headerType = i, this.body = new Uint8Array(0), r && (this._createHeader = () => r), this._bodyLength = Ai(t);
  }
}
class Mi {
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
  constructor(t, n, i) {
    this._nodes = n, this._buffers = i, this._length = Ai(t);
  }
}
class rs {
  get id() {
    return this._id;
  }
  get data() {
    return this._data;
  }
  get isDelta() {
    return this._isDelta;
  }
  get length() {
    return this.data.length;
  }
  get nodes() {
    return this.data.nodes;
  }
  get buffers() {
    return this.data.buffers;
  }
  constructor(t, n, i = !1) {
    this._data = t, this._isDelta = i, this._id = Ai(n);
  }
}
class Yr {
  constructor(t, n) {
    this.offset = Ai(t), this.length = Ai(n);
  }
}
class al {
  constructor(t, n) {
    this.length = Ai(t), this.nullCount = Ai(n);
  }
}
function prt(e, t) {
  return () => {
    switch (t) {
      case Qt.Schema:
        return Kt.fromJSON(e);
      case Qt.RecordBatch:
        return Mi.fromJSON(e);
      case Qt.DictionaryBatch:
        return rs.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Qt[t]}, type: ${t} }`);
  };
}
function yrt(e, t) {
  return () => {
    switch (t) {
      case Qt.Schema:
        return Kt.decode(e.header(new Ui()));
      case Qt.RecordBatch:
        return Mi.decode(e.header(new Or()), e.version());
      case Qt.DictionaryBatch:
        return rs.decode(e.header(new Ea()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Qt[t]}, type: ${t} }`);
  };
}
de.encode = Art;
de.decode = Irt;
de.fromJSON = frt;
Kt.encode = $rt;
Kt.decode = mrt;
Kt.fromJSON = art;
Mi.encode = Mrt;
Mi.decode = grt;
Mi.fromJSON = qN;
rs.encode = Trt;
rs.decode = brt;
rs.fromJSON = crt;
al.encode = Brt;
al.decode = wrt;
Yr.encode = Nrt;
Yr.decode = _rt;
function mrt(e, t = /* @__PURE__ */ new Map()) {
  const n = Srt(e, t);
  return new Kt(n, Dh(e), t);
}
function grt(e, t = Gn.V4) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new Mi(e.length(), vrt(e), xrt(e, t));
}
function brt(e, t = Gn.V4) {
  return new rs(Mi.decode(e.data(), t), e.id(), e.isDelta());
}
function _rt(e) {
  return new Yr(e.offset(), e.length());
}
function wrt(e) {
  return new al(e.length(), e.nullCount());
}
function vrt(e) {
  const t = [];
  for (let n, i = -1, r = -1, s = e.nodesLength(); ++i < s; )
    (n = e.nodes(i)) && (t[++r] = al.decode(n));
  return t;
}
function xrt(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.buffersLength(); ++r < o; )
    (i = e.buffers(r)) && (t < Gn.V4 && (i.bb_pos += 8 * (r + 1)), n[++s] = Yr.decode(i));
  return n;
}
function Srt(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.fieldsLength(); ++r < o; )
    (i = e.fields(r)) && (n[++s] = de.decode(i, t));
  return n;
}
function cS(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.childrenLength(); ++r < o; )
    (i = e.children(r)) && (n[++s] = de.decode(i, t));
  return n;
}
function Irt(e, t) {
  let n, i, r, s, o, a;
  return !t || !(a = e.dictionary()) ? (r = uS(e, cS(e, t)), i = new de(e.name(), r, e.nullable(), Dh(e))) : t.has(n = Ai(a.id())) ? (s = (s = a.indexType()) ? lS(s) : new Du(), o = new Ec(t.get(n), s, n, a.isOrdered()), i = new de(e.name(), o, e.nullable(), Dh(e))) : (s = (s = a.indexType()) ? lS(s) : new Du(), t.set(n, r = uS(e, cS(e, t))), o = new Ec(r, s, n, a.isOrdered()), i = new de(e.name(), o, e.nullable(), Dh(e))), i || null;
}
function Dh(e) {
  const t = /* @__PURE__ */ new Map();
  if (e)
    for (let n, i, r = -1, s = Math.trunc(e.customMetadataLength()); ++r < s; )
      (n = e.customMetadata(r)) && (i = n.key()) != null && t.set(i, n.value());
  return t;
}
function lS(e) {
  return new Hs(e.isSigned(), e.bitWidth());
}
function uS(e, t) {
  const n = e.typeType();
  switch (n) {
    case be.NONE:
      return new Xs();
    case be.Null:
      return new Xs();
    case be.Binary:
      return new _p();
    case be.Utf8:
      return new wp();
    case be.Bool:
      return new vp();
    case be.List:
      return new Ap((t || [])[0]);
    case be.Struct_:
      return new an(t || []);
  }
  switch (n) {
    case be.Int: {
      const i = e.type(new Tn());
      return new Hs(i.isSigned(), i.bitWidth());
    }
    case be.FloatingPoint: {
      const i = e.type(new Ki());
      return new Ou(i.precision());
    }
    case be.Decimal: {
      const i = e.type(new hn());
      return new xp(i.scale(), i.precision(), i.bitWidth());
    }
    case be.Date: {
      const i = e.type(new Th());
      return new Sp(i.unit());
    }
    case be.Time: {
      const i = e.type(new jn());
      return new Eu(i.unit(), i.bitWidth());
    }
    case be.Timestamp: {
      const i = e.type(new Yn());
      return new Ip(i.unit(), i.timezone());
    }
    case be.Interval: {
      const i = e.type(new Ji());
      return new $p(i.unit());
    }
    case be.Union: {
      const i = e.type(new dn());
      return new Mp(i.mode(), i.typeIdsArray() || [], t || []);
    }
    case be.FixedSizeBinary: {
      const i = e.type(new Xi());
      return new Tp(i.byteWidth());
    }
    case be.FixedSizeList: {
      const i = e.type(new Hi());
      return new Bp(i.listSize(), (t || [])[0]);
    }
    case be.Map: {
      const i = e.type(new Bh());
      return new Np((t || [])[0], i.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${be[n]}" (${n})`);
}
function $rt(e, t) {
  const n = t.fields.map((s) => de.encode(e, s));
  Ui.startFieldsVector(e, n.length);
  const i = Ui.createFieldsVector(e, n), r = t.metadata && t.metadata.size > 0 ? Ui.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return De.startKeyValue(e), De.addKey(e, a), De.addValue(e, c), De.endKeyValue(e);
  })) : -1;
  return Ui.startSchema(e), Ui.addFields(e, i), Ui.addEndianness(e, Frt ? Cc.Little : Cc.Big), r !== -1 && Ui.addCustomMetadata(e, r), Ui.endSchema(e);
}
function Art(e, t) {
  let n = -1, i = -1, r = -1;
  const s = t.type;
  let o = t.typeId;
  $t.isDictionary(s) ? (o = s.dictionary.typeId, r = Sm.visit(s, e), i = Sm.visit(s.dictionary, e)) : i = Sm.visit(s, e);
  const a = (s.children || []).map((u) => de.encode(e, u)), c = zn.createChildrenVector(e, a), l = t.metadata && t.metadata.size > 0 ? zn.createCustomMetadataVector(e, [...t.metadata].map(([u, f]) => {
    const h = e.createString(`${u}`), d = e.createString(`${f}`);
    return De.startKeyValue(e), De.addKey(e, h), De.addValue(e, d), De.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), zn.startField(e), zn.addType(e, i), zn.addTypeType(e, o), zn.addChildren(e, c), zn.addNullable(e, !!t.nullable), n !== -1 && zn.addName(e, n), r !== -1 && zn.addDictionary(e, r), l !== -1 && zn.addCustomMetadata(e, l), zn.endField(e);
}
function Mrt(e, t) {
  const n = t.nodes || [], i = t.buffers || [];
  Or.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    al.encode(e, o);
  const r = e.endVector();
  Or.startBuffersVector(e, i.length);
  for (const o of i.slice().reverse())
    Yr.encode(e, o);
  const s = e.endVector();
  return Or.startRecordBatch(e), Or.addLength(e, BigInt(t.length)), Or.addNodes(e, r), Or.addBuffers(e, s), Or.endRecordBatch(e);
}
function Trt(e, t) {
  const n = Mi.encode(e, t.data);
  return Ea.startDictionaryBatch(e), Ea.addId(e, BigInt(t.id)), Ea.addIsDelta(e, t.isDelta), Ea.addData(e, n), Ea.endDictionaryBatch(e);
}
function Brt(e, t) {
  return YN.createFieldNode(e, BigInt(t.length), BigInt(t.nullCount));
}
function Nrt(e, t) {
  return jN.createBuffer(e, BigInt(t.offset), BigInt(t.length));
}
const Frt = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), bw = (e) => `Expected ${Qt[e]} Message in stream, but was null or length 0.`, _w = (e) => `Header pointer of flatbuffer-encoded ${Qt[e]} Message is null or length 0.`, XN = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, HN = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
class KN {
  constructor(t) {
    this.source = t instanceof kp ? t : new kp(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 ? xe : 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(bw(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Ht(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(HN(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 = Qt.Schema, i = this.readMessage(n), r = i == null ? void 0 : i.header();
    if (t && !r)
      throw new Error(_w(n));
    return r;
  }
  readMetadataLength() {
    const t = this.source.read(f0), n = t && new Lc(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
    return { done: i === 0, value: i };
  }
  readMetadata(t) {
    const n = this.source.read(t);
    if (!n)
      return xe;
    if (n.byteLength < t)
      throw new Error(XN(t, n.byteLength));
    return { done: !1, value: di.decode(n) };
  }
}
class Drt {
  constructor(t, n) {
    this.source = t instanceof zc ? t : dB(t) ? new Up(t, n) : new zc(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return Y(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 ? xe : t;
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return Y(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(bw(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return Y(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Ht(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(HN(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return Y(this, void 0, void 0, function* () {
      const n = Qt.Schema, i = yield this.readMessage(n), r = i == null ? void 0 : i.header();
      if (t && !r)
        throw new Error(_w(n));
      return r;
    });
  }
  readMetadataLength() {
    return Y(this, void 0, void 0, function* () {
      const t = yield this.source.read(f0), n = t && new Lc(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: i === 0, value: i };
    });
  }
  readMetadata(t) {
    return Y(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return xe;
      if (n.byteLength < t)
        throw new Error(XN(t, n.byteLength));
      return { done: !1, value: di.decode(n) };
    });
  }
}
class Ort extends KN {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof nS ? t : new nS(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: di.fromJSON(t.schema, Qt.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: di.fromJSON(n, Qt.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: di.fromJSON(n, Qt.RecordBatch) };
    }
    return this._body = [], xe;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(i) {
      return (i || []).reduce((r, s) => [
        ...r,
        ...s.VALIDITY && [s.VALIDITY] || [],
        ...s.TYPE && [s.TYPE] || [],
        ...s.OFFSET && [s.OFFSET] || [],
        ...s.DATA && [s.DATA] || [],
        ...n(s.children)
      ], []);
    }
  }
  readMessage(t) {
    let n;
    if ((n = this.next()).done)
      return null;
    if (t != null && n.value.headerType !== t)
      throw new Error(bw(t));
    return n.value;
  }
  readSchema() {
    const t = Qt.Schema, n = this.readMessage(t), i = n == null ? void 0 : n.header();
    if (!n || !i)
      throw new Error(_w(t));
    return i;
  }
}
const f0 = 4, f1 = "ARROW1", jp = new Uint8Array(f1.length);
for (let e = 0; e < f1.length; e += 1)
  jp[e] = f1.codePointAt(e);
function ww(e, t = 0) {
  for (let n = -1, i = jp.length; ++n < i; )
    if (jp[n] !== e[t + n])
      return !1;
  return !0;
}
const Sf = jp.length, JN = Sf + f0, Ert = Sf * 2 + f0;
class Hr extends RN {
  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 Bu(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 Vn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return Vn.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 Hr ? t : n1(t) ? krt(t) : dB(t) ? Prt(t) : Bu(t) ? (() => Y(this, void 0, void 0, function* () {
      return yield Hr.from(yield t);
    }))() : pB(t) || ew(t) || mB(t) || tw(t) ? zrt(new zc(t)) : Urt(new kp(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof Hr ? t.isSync() ? fS(t) : hS(t) : n1(t) || ArrayBuffer.isView(t) || c0(t) || hB(t) ? fS(t) : hS(t);
  }
}
class Yp extends Hr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return Fe(this, arguments, function* () {
      yield W(yield* Fs(ti(this[Symbol.iterator]())));
    });
  }
}
class qp extends Hr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n, i, r;
    return Y(this, void 0, void 0, function* () {
      const s = new Array();
      try {
        for (var o = !0, a = ti(this), c; c = yield a.next(), t = c.done, !t; ) {
          r = c.value, o = !1;
          try {
            const l = r;
            s.push(l);
          } finally {
            o = !0;
          }
        }
      } catch (l) {
        n = { error: l };
      } finally {
        try {
          !o && !t && (i = a.return) && (yield i.call(a));
        } finally {
          if (n)
            throw n.error;
        }
      }
      return s;
    });
  }
  [Symbol.iterator]() {
    throw new Error("AsyncRecordBatchStreamReader is not Iterable");
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
}
class ZN extends Yp {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class Lrt extends qp {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class QN {
  get numDictionaries() {
    return this._dictionaryIndex;
  }
  get numRecordBatches() {
    return this._recordBatchIndex;
  }
  constructor(t = /* @__PURE__ */ new Map()) {
    this.closed = !1, this.autoDestroy = !0, this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.dictionaries = t;
  }
  isSync() {
    return !1;
  }
  isAsync() {
    return !1;
  }
  isFile() {
    return !1;
  }
  isStream() {
    return !1;
  }
  reset(t) {
    return this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.schema = t, this.dictionaries = /* @__PURE__ */ new Map(), this;
  }
  _loadRecordBatch(t, n) {
    const i = this._loadVectors(t, n, this.schema.fields), r = Ct({ type: new an(this.schema.fields), length: t.length, children: i });
    return new ui(this.schema, r);
  }
  _loadDictionaryBatch(t, n) {
    const { id: i, isDelta: r } = t, { dictionaries: s, schema: o } = this, a = s.get(i);
    if (r || !a) {
      const c = o.dictionaries.get(i), l = this._loadVectors(t.data, n, [c]);
      return (a && r ? a.concat(new te(l)) : new te(l)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, i) {
    return new kN(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
}
class Wp extends QN {
  constructor(t, n) {
    super(n), this._reader = n1(t) ? new Ort(this._handle = t) : new KN(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 = eF(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) : xe;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : xe;
  }
  next() {
    if (this.closed)
      return xe;
    let t;
    const { _reader: n } = this;
    for (; t = this._readNextMessageAndValidate(); )
      if (t.isSchema())
        this.reset(t.header());
      else if (t.isRecordBatch()) {
        this._recordBatchIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength);
        return { done: !1, value: this._loadRecordBatch(i, r) };
      } else if (t.isDictionaryBatch()) {
        this._dictionaryIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
        this.dictionaries.set(i.id, s);
      }
    return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new VN(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}
class Gp extends QN {
  constructor(t, n) {
    super(n), this._reader = new Drt(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return Y(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 Y(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = eF(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : xe;
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : xe;
    });
  }
  next() {
    return Y(this, void 0, void 0, function* () {
      if (this.closed)
        return xe;
      let t;
      const { _reader: n } = this;
      for (; t = yield this._readNextMessageAndValidate(); )
        if (t.isSchema())
          yield this.reset(t.header());
        else if (t.isRecordBatch()) {
          this._recordBatchIndex++;
          const i = t.header(), r = yield n.readMessageBody(t.bodyLength);
          return { done: !1, value: this._loadRecordBatch(i, r) };
        } else if (t.isDictionaryBatch()) {
          this._dictionaryIndex++;
          const i = t.header(), r = yield n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
          this.dictionaries.set(i.id, s);
        }
      return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new VN(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}
class tF extends Wp {
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  constructor(t, n) {
    super(t instanceof iS ? t : new iS(t), n);
  }
  isSync() {
    return !0;
  }
  isFile() {
    return !0;
  }
  open(t) {
    if (!this.closed && !this._footer) {
      this.schema = (this._footer = this._readFooter()).schema;
      for (const n of this._footer.dictionaryBatches())
        n && this._readDictionaryBatch(this._dictionaryIndex++);
    }
    return super.open(t);
  }
  readRecordBatch(t) {
    var n;
    if (this.closed)
      return null;
    this._footer || this.open();
    const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(Qt.RecordBatch);
      if (r != null && r.isRecordBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength);
        return this._loadRecordBatch(s, o);
      }
    }
    return null;
  }
  _readDictionaryBatch(t) {
    var n;
    const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(Qt.DictionaryBatch);
      if (r != null && r.isDictionaryBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
        this.dictionaries.set(s.id, a);
      }
    }
  }
  _readFooter() {
    const { _handle: t } = this, n = t.size - JN, i = t.readInt32(n), r = t.readAt(n - i, i);
    return dw.decode(r);
  }
  _readNextMessageAndValidate(t) {
    var n;
    if (this._footer || this.open(), this._footer && this._recordBatchIndex < this.numRecordBatches) {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(this._recordBatchIndex);
      if (i && this._handle.seek(i.offset))
        return this._reader.readMessage(t);
    }
    return null;
  }
}
class Rrt extends Gp {
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  constructor(t, ...n) {
    const i = typeof n[0] != "number" ? n.shift() : void 0, r = n[0] instanceof Map ? n.shift() : void 0;
    super(t instanceof Up ? t : new Up(t, i), r);
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return Y(this, void 0, void 0, function* () {
      if (!this.closed && !this._footer) {
        this.schema = (this._footer = yield this._readFooter()).schema;
        for (const i of this._footer.dictionaryBatches())
          i && (yield this._readDictionaryBatch(this._dictionaryIndex++));
      }
      return yield n.open.call(this, t);
    });
  }
  readRecordBatch(t) {
    var n;
    return Y(this, void 0, void 0, function* () {
      if (this.closed)
        return null;
      this._footer || (yield this.open());
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(Qt.RecordBatch);
        if (r != null && r.isRecordBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength);
          return this._loadRecordBatch(s, o);
        }
      }
      return null;
    });
  }
  _readDictionaryBatch(t) {
    var n;
    return Y(this, void 0, void 0, function* () {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(Qt.DictionaryBatch);
        if (r != null && r.isDictionaryBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
          this.dictionaries.set(s.id, a);
        }
      }
    });
  }
  _readFooter() {
    return Y(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - JN, i = yield t.readInt32(n), r = yield t.readAt(n - i, i);
      return dw.decode(r);
    });
  }
  _readNextMessageAndValidate(t) {
    return Y(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 Crt extends Wp {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, i) {
    return new Hit(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
}
function eF(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* fS(e) {
  const t = Hr.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function hS(e) {
  return Fe(this, arguments, function* () {
    const n = yield W(Hr.from(e));
    try {
      if (!(yield W(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield W(n);
        while (!(yield W(n.reset().open())).closed);
    } finally {
      yield W(n.cancel());
    }
  });
}
function krt(e) {
  return new Yp(new Crt(e));
}
function Urt(e) {
  const t = e.peek(Sf + 7 & -8);
  return t && t.byteLength >= 4 ? ww(t) ? new ZN(new tF(e.read())) : new Yp(new Wp(e)) : new Yp(new Wp(function* () {
  }()));
}
function zrt(e) {
  return Y(this, void 0, void 0, function* () {
    const t = yield e.peek(Sf + 7 & -8);
    return t && t.byteLength >= 4 ? ww(t) ? new ZN(new tF(yield e.read())) : new qp(new Gp(e)) : new qp(new Gp(function() {
      return Fe(this, arguments, function* () {
      });
    }()));
  });
}
function Prt(e) {
  return Y(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new Up(e, t);
    return t >= Ert && ww(yield n.readAt(0, Sf + 7 & -8)) ? new Lrt(new Rrt(n)) : new qp(new Gp(n));
  });
}
function nF(e) {
  const t = Hr.from(e);
  return Bu(t) ? t.then((n) => nF(n)) : t.isAsync() ? t.readAll().then((n) => new qn(n)) : new qn(t.readAll());
}
async function Iot(e) {
  e.el.classList.add("mosaic-widget");
  const t = () => e.model.get("spec"), n = pi().logger(), i = /* @__PURE__ */ new Map();
  function r(c, l, u) {
    const f = globalThis.crypto.randomUUID();
    i.set(f, { query: c, startTime: performance.now(), resolve: l, reject: u }), e.model.send({ ...c, uuid: f });
  }
  const s = {
    query(c) {
      return new Promise((l, u) => r(c, l, u));
    }
  };
  function o() {
    pi().clear(), q_.clear();
  }
  async function a() {
    const c = t();
    o(), n.log("Setting spec:", c), e.el.replaceChildren(await Pet(c));
    const l = pi(), u = new Set([...l.clients].flatMap((f) => f.filterBy).filter((f) => f));
    for (const f of u)
      f.addEventListener("value", () => {
        const h = [...u].map(
          (d) => d.clauses.map(
            (p) => ({
              value: p.value,
              sql: String(p.predicate)
            })
          )
        );
        e.model.set("selections", h), e.model.save_changes();
      });
  }
  return e.model.on("change:spec", () => a()), e.model.on("msg:custom", (c, l) => {
    n.group(`query ${c.uuid}`), n.log("received message", c, l);
    const u = i.get(c.uuid);
    if (i.delete(c.uuid), n.log(u.query.sql, (performance.now() - u.startTime).toFixed(1)), c.error)
      u.reject(c.error), n.error(c.error);
    else
      switch (c.type) {
        case "arrow": {
          const f = nF(l[0].buffer);
          n.log("table", f), u.resolve(f);
          break;
        }
        case "json": {
          n.log("json", c.result), u.resolve(c.result);
          break;
        }
        default: {
          u.resolve({});
          break;
        }
      }
    n.groupEnd("query");
  }), pi().databaseConnector(s), a(), () => {
    o();
  };
}
export {
  Iot as render
};
