//#region ../../node_modules/hyparquet/src/constants.js
var e = [
	"BOOLEAN",
	"INT32",
	"INT64",
	"INT96",
	"FLOAT",
	"DOUBLE",
	"BYTE_ARRAY",
	"FIXED_LEN_BYTE_ARRAY"
], t = [
	"PLAIN",
	"GROUP_VAR_INT",
	"PLAIN_DICTIONARY",
	"RLE",
	"BIT_PACKED",
	"DELTA_BINARY_PACKED",
	"DELTA_LENGTH_BYTE_ARRAY",
	"DELTA_BYTE_ARRAY",
	"RLE_DICTIONARY",
	"BYTE_STREAM_SPLIT"
], n = [
	"REQUIRED",
	"OPTIONAL",
	"REPEATED"
], r = [
	"UTF8",
	"MAP",
	"MAP_KEY_VALUE",
	"LIST",
	"ENUM",
	"DECIMAL",
	"DATE",
	"TIME_MILLIS",
	"TIME_MICROS",
	"TIMESTAMP_MILLIS",
	"TIMESTAMP_MICROS",
	"UINT_8",
	"UINT_16",
	"UINT_32",
	"UINT_64",
	"INT_8",
	"INT_16",
	"INT_32",
	"INT_64",
	"JSON",
	"BSON",
	"INTERVAL"
], i = [
	"UNCOMPRESSED",
	"SNAPPY",
	"GZIP",
	"LZO",
	"BROTLI",
	"LZ4",
	"ZSTD",
	"LZ4_RAW"
], a = [
	"DATA_PAGE",
	"INDEX_PAGE",
	"DICTIONARY_PAGE",
	"DATA_PAGE_V2"
], o = [
	"SPHERICAL",
	"VINCENTY",
	"THOMAS",
	"ANDOYER",
	"KARNEY"
];
//#endregion
//#region ../../node_modules/hyparquet/src/wkb.js
function s(e) {
	let t = c(e);
	if (t.type === 1) return {
		type: "Point",
		coordinates: l(e, t)
	};
	if (t.type === 2) return {
		type: "LineString",
		coordinates: u(e, t)
	};
	if (t.type === 3) return {
		type: "Polygon",
		coordinates: d(e, t)
	};
	if (t.type === 4) {
		let n = [];
		for (let r = 0; r < t.count; r++) n.push(l(e, c(e)));
		return {
			type: "MultiPoint",
			coordinates: n
		};
	} else if (t.type === 5) {
		let n = [];
		for (let r = 0; r < t.count; r++) n.push(u(e, c(e)));
		return {
			type: "MultiLineString",
			coordinates: n
		};
	} else if (t.type === 6) {
		let n = [];
		for (let r = 0; r < t.count; r++) n.push(d(e, c(e)));
		return {
			type: "MultiPolygon",
			coordinates: n
		};
	} else if (t.type === 7) {
		let n = [];
		for (let r = 0; r < t.count; r++) n.push(s(e));
		return {
			type: "GeometryCollection",
			geometries: n
		};
	} else throw Error(`Unsupported geometry type: ${t.type}`);
}
function c(e) {
	let { view: t } = e, n = t.getUint8(e.offset++) === 1, r = t.getUint32(e.offset, n);
	e.offset += 4;
	let i = r % 1e3, a = Math.floor(r / 1e3), o = 0;
	i > 1 && i <= 7 && (o = t.getUint32(e.offset, n), e.offset += 4);
	let s = 2;
	return a && s++, a === 3 && s++, {
		littleEndian: n,
		type: i,
		dim: s,
		count: o
	};
}
function l(e, t) {
	let n = [];
	for (let r = 0; r < t.dim; r++) {
		let r = e.view.getFloat64(e.offset, t.littleEndian);
		e.offset += 8, n.push(r);
	}
	return n;
}
function u(e, t) {
	let n = [];
	for (let r = 0; r < t.count; r++) n.push(l(e, t));
	return n;
}
function d(e, t) {
	let { view: n } = e, r = [];
	for (let i = 0; i < t.count; i++) {
		let i = n.getUint32(e.offset, t.littleEndian);
		e.offset += 4, r.push(u(e, {
			...t,
			count: i
		}));
	}
	return r;
}
//#endregion
//#region ../../node_modules/hyparquet/src/convert.js
var f = new TextDecoder(), p = {
	timestampFromMilliseconds(e) {
		return new Date(Number(e));
	},
	timestampFromMicroseconds(e) {
		return new Date(Number(e / 1000n));
	},
	timestampFromNanoseconds(e) {
		return new Date(Number(e / 1000000n));
	},
	dateFromDays(e) {
		return /* @__PURE__ */ new Date(e * 864e5);
	},
	stringFromBytes(e) {
		return e && f.decode(e);
	},
	geometryFromBytes(e) {
		return e && s({
			view: new DataView(e.buffer, e.byteOffset, e.byteLength),
			offset: 0
		});
	},
	geographyFromBytes(e) {
		return e && s({
			view: new DataView(e.buffer, e.byteOffset, e.byteLength),
			offset: 0
		});
	}
};
function m(e, t, n, r) {
	if (t && n.endsWith("_DICTIONARY")) {
		let n = e;
		e instanceof Uint8Array && !(t instanceof Uint8Array) && (n = new t.constructor(e.length));
		for (let r = 0; r < e.length; r++) n[r] = t[e[r]];
		return n;
	} else return h(e, r);
}
function h(e, t) {
	let { element: n, parsers: r, utf8: i = !0, schemaPath: a } = t, { type: o, converted_type: s, logical_type: c } = n;
	if (a?.some((e) => e.element.logical_type?.type === "VARIANT") && o === "BYTE_ARRAY" && s !== "UTF8" && c?.type !== "STRING") return e;
	if (s === "DECIMAL") {
		let t = 10 ** -(n.scale || 0), r = Array(e.length);
		for (let n = 0; n < r.length; n++) e[n] instanceof Uint8Array ? r[n] = g(e[n]) * t : r[n] = Number(e[n]) * t;
		return r;
	}
	if (!s && o === "INT96") return Array.from(e).map((e) => r.timestampFromNanoseconds(_(e)));
	if (s === "DATE") return Array.from(e).map((e) => r.dateFromDays(e));
	if (s === "TIMESTAMP_MILLIS") return Array.from(e).map((e) => r.timestampFromMilliseconds(e));
	if (s === "TIMESTAMP_MICROS") return Array.from(e).map((e) => r.timestampFromMicroseconds(e));
	if (s === "JSON") return e.map((e) => JSON.parse(f.decode(e)));
	if (s === "BSON") throw Error("parquet bson not supported");
	if (s === "INTERVAL") throw Error("parquet interval not supported");
	if (c?.type === "GEOMETRY") return e.map((e) => r.geometryFromBytes(e));
	if (c?.type === "GEOGRAPHY") return e.map((e) => r.geographyFromBytes(e));
	if (s === "UTF8" || c?.type === "STRING" || i && o === "BYTE_ARRAY") return e.map((e) => r.stringFromBytes(e));
	if (s === "UINT_64" || c?.type === "INTEGER" && c.bitWidth === 64 && !c.isSigned) {
		if (e instanceof BigInt64Array) return new BigUint64Array(e.buffer, e.byteOffset, e.length);
		let t = new BigUint64Array(e.length);
		for (let n = 0; n < t.length; n++) t[n] = BigInt(e[n]);
		return t;
	}
	if (s === "UINT_32" || c?.type === "INTEGER" && c.bitWidth === 32 && !c.isSigned) {
		if (e instanceof Int32Array) return new Uint32Array(e.buffer, e.byteOffset, e.length);
		let t = new Uint32Array(e.length);
		for (let n = 0; n < t.length; n++) t[n] = e[n];
		return t;
	}
	if (c?.type === "FLOAT16") return Array.from(e).map(v);
	if (c?.type === "TIMESTAMP") {
		let { unit: t } = c, n = r.timestampFromMilliseconds;
		t === "MICROS" && (n = r.timestampFromMicroseconds), t === "NANOS" && (n = r.timestampFromNanoseconds);
		let i = Array(e.length);
		for (let t = 0; t < i.length; t++) i[t] = n(e[t]);
		return i;
	}
	return e;
}
function g(e) {
	if (!e.length) return 0;
	let t = 0n;
	for (let n of e) t = t * 256n + BigInt(n);
	let n = e.length * 8;
	return t >= 2n ** BigInt(n - 1) && (t -= 2n ** BigInt(n)), Number(t);
}
function _(e) {
	let t = (e >> 64n) - 2440588n, n = e & 18446744073709551615n;
	return t * 86400000000000n + n;
}
function v(e) {
	if (!e) return;
	let t = e[1] << 8 | e[0], n = t >> 15 ? -1 : 1, r = t >> 10 & 31, i = t & 1023;
	return r === 0 ? n * 2 ** -14 * (i / 1024) : r === 31 ? i ? NaN : n * Infinity : n * 2 ** (r - 15) * (1 + i / 1024);
}
//#endregion
//#region ../../node_modules/hyparquet/src/schema.js
function y(e, t, n) {
	let r = e[t], i = [], a = 1;
	if (r.num_children) for (; i.length < r.num_children;) {
		let r = e[t + a], o = y(e, t + a, [...n, r.name]);
		a += o.count, i.push(o);
	}
	return {
		count: a,
		element: r,
		children: i,
		path: n
	};
}
function b(e, t) {
	let n = y(e, 0, []), r = [n];
	for (let e of t) {
		let i = n.children.find((t) => t.element.name === e);
		if (!i) throw Error(`parquet schema element not found: ${t}`);
		r.push(i), n = i;
	}
	return r;
}
function ee(e) {
	let t = [];
	function n(e) {
		if (e.children.length) for (let t of e.children) n(t);
		else t.push(e.path.join("."));
	}
	return n(e), t;
}
function x(e) {
	let t = 0;
	for (let { element: n } of e) n.repetition_type === "REPEATED" && t++;
	return t;
}
function S(e) {
	let t = 0;
	for (let { element: n } of e.slice(1)) n.repetition_type !== "REQUIRED" && t++;
	return t;
}
function te(e) {
	if (!e || e.element.converted_type !== "LIST" || e.children.length > 1) return !1;
	let t = e.children[0];
	return !(t.children.length > 1 || t.element.repetition_type !== "REPEATED");
}
function ne(e) {
	if (!e || e.element.converted_type !== "MAP" || e.children.length > 1) return !1;
	let t = e.children[0];
	return !(t.children.length !== 2 || t.element.repetition_type !== "REPEATED" || t.children.find((e) => e.element.name === "key")?.element.repetition_type === "REPEATED" || t.children.find((e) => e.element.name === "value")?.element.repetition_type === "REPEATED");
}
function re(e) {
	if (e.length !== 2) return !1;
	let [, t] = e;
	return !(t.element.repetition_type === "REPEATED" || t.children.length);
}
//#endregion
//#region ../../node_modules/hyparquet/src/thrift.js
var C = {
	STOP: 0,
	TRUE: 1,
	FALSE: 2,
	BYTE: 3,
	I16: 4,
	I32: 5,
	I64: 6,
	DOUBLE: 7,
	BINARY: 8,
	LIST: 9,
	SET: 10,
	MAP: 11,
	STRUCT: 12,
	UUID: 13
};
function w(e) {
	let t = 0, n = {};
	for (; e.offset < e.view.byteLength;) {
		let [r, i, a] = ae(e, t);
		if (t = a, r === C.STOP) break;
		n[`field_${i}`] = T(e, r);
	}
	return n;
}
function T(e, t) {
	switch (t) {
		case C.TRUE: return !0;
		case C.FALSE: return !1;
		case C.BYTE: return e.view.getInt8(e.offset++);
		case C.I16:
		case C.I32: return D(e);
		case C.I64: return O(e);
		case C.DOUBLE: {
			let t = e.view.getFloat64(e.offset, !0);
			return e.offset += 8, t;
		}
		case C.BINARY: {
			let t = E(e), n = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, t);
			return e.offset += t, n;
		}
		case C.LIST: {
			let t = e.view.getUint8(e.offset++), n = t & 15, r = t >> 4;
			r === 15 && (r = E(e));
			let i = n === C.TRUE || n === C.FALSE, a = Array(r);
			for (let t = 0; t < r; t++) a[t] = i ? T(e, C.BYTE) === 1 : T(e, n);
			return a;
		}
		case C.STRUCT: {
			let t = {}, n = 0;
			for (;;) {
				let [r, i, a] = ae(e, n);
				if (n = a, r === C.STOP) break;
				t[`field_${i}`] = T(e, r);
			}
			return t;
		}
		default: throw Error(`thrift unhandled type: ${t}`);
	}
}
function E(e) {
	let t = 0, n = 0;
	for (;;) {
		let r = e.view.getUint8(e.offset++);
		if (t |= (r & 127) << n, !(r & 128)) return t;
		n += 7;
	}
}
function ie(e) {
	let t = 0n, n = 0n;
	for (;;) {
		let r = e.view.getUint8(e.offset++);
		if (t |= BigInt(r & 127) << n, !(r & 128)) return t;
		n += 7n;
	}
}
function D(e) {
	let t = E(e);
	return t >>> 1 ^ -(t & 1);
}
function O(e) {
	let t = ie(e);
	return t >> 1n ^ -(t & 1n);
}
function ae(e, t) {
	let n = e.view.getUint8(e.offset++), r = n & 15;
	if (r === C.STOP) return [
		0,
		0,
		t
	];
	let i = n >> 4, a = i ? t + i : D(e);
	return [
		r,
		a,
		a
	];
}
//#endregion
//#region ../../node_modules/hyparquet/src/geoparquet.js
function oe(e, t) {
	let n = /* @__PURE__ */ new Map(), r = t?.find(({ key: e }) => e === "geo")?.value, i = (r && JSON.parse(r)?.columns) ?? {};
	for (let [e, t] of Object.entries(i)) {
		if (t.encoding !== "WKB") continue;
		let r = t.edges === "spherical" ? "GEOGRAPHY" : "GEOMETRY", i = t.crs?.id ?? t.crs?.ids?.[0], a = i ? `${i.authority}:${i.code.toString()}` : void 0;
		n.set(e, {
			type: r,
			crs: a
		});
	}
	for (let t = 1; t < e.length; t++) {
		let r = e[t], { logical_type: i, name: a, num_children: o, repetition_type: s, type: c } = r;
		if (o) {
			t += o;
			continue;
		}
		c === "BYTE_ARRAY" && i === void 0 && s !== "REPEATED" && (r.logical_type = n.get(a));
	}
}
//#endregion
//#region ../../node_modules/hyparquet/src/metadata.js
var se = 1 << 19, ce = new TextDecoder();
function k(e) {
	return e && ce.decode(e);
}
async function le(e, { parsers: t, initialFetchSize: n = se, geoparquet: r = !0 } = {}) {
	if (!e || !(e.byteLength >= 0)) throw Error("parquet expected AsyncBuffer");
	let i = Math.max(0, e.byteLength - n), a = await e.slice(i, e.byteLength), o = new DataView(a);
	if (o.getUint32(a.byteLength - 4, !0) !== 827474256) throw Error("parquet file invalid (footer != PAR1)");
	let s = o.getUint32(a.byteLength - 8, !0);
	if (s > e.byteLength - 8) throw Error(`parquet metadata length ${s} exceeds available buffer ${e.byteLength - 8}`);
	if (s + 8 > n) {
		let n = e.byteLength - s - 8, o = await e.slice(n, i), c = new ArrayBuffer(s + 8), l = new Uint8Array(c);
		return l.set(new Uint8Array(o)), l.set(new Uint8Array(a), i - n), ue(c, {
			parsers: t,
			geoparquet: r
		});
	} else return ue(a, {
		parsers: t,
		geoparquet: r
	});
}
function ue(o, { parsers: s, geoparquet: c = !0 } = {}) {
	if (!(o instanceof ArrayBuffer)) throw Error("parquet expected ArrayBuffer");
	let l = new DataView(o);
	if (s = {
		...p,
		...s
	}, l.byteLength < 8) throw Error("parquet file is too short");
	if (l.getUint32(l.byteLength - 4, !0) !== 827474256) throw Error("parquet file invalid (footer != PAR1)");
	let u = l.byteLength - 8, d = l.getUint32(u, !0);
	if (d > l.byteLength - 8) throw Error(`parquet metadata length ${d} exceeds available buffer ${l.byteLength - 8}`);
	let f = w({
		view: l,
		offset: u - d
	}), m = f.field_1, h = f.field_2.map((t) => ({
		type: e[t.field_1],
		type_length: t.field_2,
		repetition_type: n[t.field_3],
		name: k(t.field_4),
		num_children: t.field_5,
		converted_type: r[t.field_6],
		scale: t.field_7,
		precision: t.field_8,
		field_id: t.field_9,
		logical_type: de(t.field_10)
	})), g = h.filter((e) => e.type), _ = f.field_3, v = f.field_4.map((n) => ({
		columns: n.field_1.map((n, r) => ({
			file_path: k(n.field_1),
			file_offset: n.field_2,
			meta_data: n.field_3 && {
				type: e[n.field_3.field_1],
				encodings: n.field_3.field_2?.map((e) => t[e]),
				path_in_schema: n.field_3.field_3.map(k),
				codec: i[n.field_3.field_4],
				num_values: n.field_3.field_5,
				total_uncompressed_size: n.field_3.field_6,
				total_compressed_size: n.field_3.field_7,
				key_value_metadata: n.field_3.field_8?.map((e) => ({
					key: k(e.field_1),
					value: k(e.field_2)
				})),
				data_page_offset: n.field_3.field_9,
				index_page_offset: n.field_3.field_10,
				dictionary_page_offset: n.field_3.field_11,
				statistics: fe(n.field_3.field_12, g[r], s),
				encoding_stats: n.field_3.field_13?.map((e) => ({
					page_type: a[e.field_1],
					encoding: t[e.field_2],
					count: e.field_3
				})),
				bloom_filter_offset: n.field_3.field_14,
				bloom_filter_length: n.field_3.field_15,
				size_statistics: n.field_3.field_16 && {
					unencoded_byte_array_data_bytes: n.field_3.field_16.field_1,
					repetition_level_histogram: n.field_3.field_16.field_2,
					definition_level_histogram: n.field_3.field_16.field_3
				},
				geospatial_statistics: n.field_3.field_17 && {
					bbox: n.field_3.field_17.field_1 && {
						xmin: n.field_3.field_17.field_1.field_1,
						xmax: n.field_3.field_17.field_1.field_2,
						ymin: n.field_3.field_17.field_1.field_3,
						ymax: n.field_3.field_17.field_1.field_4,
						zmin: n.field_3.field_17.field_1.field_5,
						zmax: n.field_3.field_17.field_1.field_6,
						mmin: n.field_3.field_17.field_1.field_7,
						mmax: n.field_3.field_17.field_1.field_8
					},
					geospatial_types: n.field_3.field_17.field_2
				}
			},
			offset_index_offset: n.field_4,
			offset_index_length: n.field_5,
			column_index_offset: n.field_6,
			column_index_length: n.field_7,
			crypto_metadata: n.field_8,
			encrypted_column_metadata: n.field_9
		})),
		total_byte_size: n.field_2,
		num_rows: n.field_3,
		sorting_columns: n.field_4?.map((e) => ({
			column_idx: e.field_1,
			descending: e.field_2,
			nulls_first: e.field_3
		})),
		file_offset: n.field_5,
		total_compressed_size: n.field_6,
		ordinal: n.field_7
	})), y = f.field_5?.map((e) => ({
		key: k(e.field_1),
		value: k(e.field_2)
	})), b = k(f.field_6);
	return c && oe(h, y), {
		version: m,
		schema: h,
		num_rows: _,
		row_groups: v,
		key_value_metadata: y,
		created_by: b,
		metadata_length: d
	};
}
function A({ schema: e }) {
	return b(e, [])[0];
}
function de(e) {
	return e?.field_1 ? { type: "STRING" } : e?.field_2 ? { type: "MAP" } : e?.field_3 ? { type: "LIST" } : e?.field_4 ? { type: "ENUM" } : e?.field_5 ? {
		type: "DECIMAL",
		scale: e.field_5.field_1,
		precision: e.field_5.field_2
	} : e?.field_6 ? { type: "DATE" } : e?.field_7 ? {
		type: "TIME",
		isAdjustedToUTC: e.field_7.field_1,
		unit: j(e.field_7.field_2)
	} : e?.field_8 ? {
		type: "TIMESTAMP",
		isAdjustedToUTC: e.field_8.field_1,
		unit: j(e.field_8.field_2)
	} : e?.field_10 ? {
		type: "INTEGER",
		bitWidth: e.field_10.field_1,
		isSigned: e.field_10.field_2
	} : e?.field_11 ? { type: "NULL" } : e?.field_12 ? { type: "JSON" } : e?.field_13 ? { type: "BSON" } : e?.field_14 ? { type: "UUID" } : e?.field_15 ? { type: "FLOAT16" } : e?.field_16 ? {
		type: "VARIANT",
		specification_version: e.field_16.field_1
	} : e?.field_17 ? {
		type: "GEOMETRY",
		crs: k(e.field_17.field_1)
	} : e?.field_18 ? {
		type: "GEOGRAPHY",
		crs: k(e.field_18.field_1),
		algorithm: o[e.field_18.field_2]
	} : e;
}
function j(e) {
	if (e.field_1) return "MILLIS";
	if (e.field_2) return "MICROS";
	if (e.field_3) return "NANOS";
	throw Error("parquet time unit required");
}
function fe(e, t, n) {
	return e && {
		max: M(e.field_1, t, n),
		min: M(e.field_2, t, n),
		null_count: e.field_3,
		distinct_count: e.field_4,
		max_value: M(e.field_5, t, n),
		min_value: M(e.field_6, t, n),
		is_max_value_exact: e.field_7,
		is_min_value_exact: e.field_8
	};
}
function M(e, t, n) {
	let { type: r, converted_type: i, logical_type: a } = t;
	if (e === void 0) return e;
	if (r === "BOOLEAN") return e[0] === 1;
	if (r === "BYTE_ARRAY") return n.stringFromBytes(e);
	let o = new DataView(e.buffer, e.byteOffset, e.byteLength);
	return r === "FLOAT" && o.byteLength === 4 ? o.getFloat32(0, !0) : r === "DOUBLE" && o.byteLength === 8 ? o.getFloat64(0, !0) : r === "INT32" && i === "DATE" ? n.dateFromDays(o.getInt32(0, !0)) : r === "INT64" && i === "TIMESTAMP_MILLIS" ? n.timestampFromMilliseconds(o.getBigInt64(0, !0)) : r === "INT64" && i === "TIMESTAMP_MICROS" ? n.timestampFromMicroseconds(o.getBigInt64(0, !0)) : r === "INT64" && a?.type === "TIMESTAMP" && a?.unit === "NANOS" ? n.timestampFromNanoseconds(o.getBigInt64(0, !0)) : r === "INT64" && a?.type === "TIMESTAMP" && a?.unit === "MICROS" ? n.timestampFromMicroseconds(o.getBigInt64(0, !0)) : r === "INT64" && a?.type === "TIMESTAMP" ? n.timestampFromMilliseconds(o.getBigInt64(0, !0)) : r === "INT32" && o.byteLength === 4 ? o.getInt32(0, !0) : r === "INT64" && o.byteLength === 8 ? o.getBigInt64(0, !0) : i === "DECIMAL" ? g(e) * 10 ** -(t.scale || 0) : a?.type === "FLOAT16" ? v(e) : e;
}
//#endregion
//#region ../../node_modules/hyparquet/src/utils.js
function N(e, t) {
	let n = 1e4;
	for (let r = 0; r < t.length; r += n) e.push(...t.slice(r, r + n));
}
function P(e, t, n = !0) {
	if (n ? e === t : e == t) return !0;
	if (e instanceof Uint8Array && t instanceof Uint8Array) return P(Array.from(e), Array.from(t), n);
	if (!e || !t || typeof e != typeof t) return !1;
	if (Array.isArray(e) && Array.isArray(t)) {
		if (e.length !== t.length) return !1;
		for (let r = 0; r < e.length; r++) if (!P(e[r], t[r], n)) return !1;
		return !0;
	}
	if (typeof e != "object") return !1;
	let r = Object.keys(e);
	if (r.length !== Object.keys(t).length) return !1;
	for (let i of r) if (!P(e[i], t[i], n)) return !1;
	return !0;
}
function pe(e) {
	if (!e) return [];
	if (e.length === 1) return e[0];
	let t = [];
	for (let n of e) N(t, n);
	return t;
}
//#endregion
//#region ../../node_modules/hyparquet/src/filter.js
function F({ rowGroup: e, physicalColumns: t, filter: n, strict: r = !0 }) {
	if (!n) return !1;
	if ("$and" in n && Array.isArray(n.$and)) return n.$and.some((n) => F({
		rowGroup: e,
		physicalColumns: t,
		filter: n,
		strict: r
	}));
	if ("$or" in n && Array.isArray(n.$or)) return n.$or.every((n) => F({
		rowGroup: e,
		physicalColumns: t,
		filter: n,
		strict: r
	}));
	if ("$nor" in n && Array.isArray(n.$nor)) return !1;
	for (let [i, a] of Object.entries(n)) {
		let n = t.indexOf(i);
		if (n === -1) continue;
		let o = e.columns[n].meta_data?.statistics;
		if (!o) continue;
		let { min: s, max: c, min_value: l, max_value: u } = o, d = l === void 0 ? s : l, f = u === void 0 ? c : u;
		if (!(d === void 0 || f === void 0)) {
			for (let [e, t] of Object.entries(a || {})) if (e === "$gt" && f <= t || e === "$gte" && f < t || e === "$lt" && d >= t || e === "$lte" && d > t || e === "$eq" && (t < d || t > f) || e === "$ne" && P(d, f, r) && P(d, t, r) || e === "$in" && Array.isArray(t) && t.every((e) => e < d || e > f) || e === "$nin" && Array.isArray(t) && P(d, f, r) && t.includes(d)) return !0;
		}
	}
	return !1;
}
//#endregion
//#region ../../node_modules/hyparquet/src/plan.js
var me = 1 << 21;
function he({ metadata: e, rowStart: t = 0, rowEnd: n = Infinity, columns: r, filter: i, filterStrict: a = !0, useOffsetIndex: o = !1 }) {
	if (!e) throw Error("parquetPlan requires metadata");
	let s = [], c = [], l = [], u = ee(A(e)), d = 0;
	for (let f of e.row_groups) {
		let e = Number(f.num_rows), p = d + e;
		if (e > 0 && p > t && d < n && !F({
			rowGroup: f,
			physicalColumns: u,
			filter: i,
			strict: a
		})) {
			let i = [], a = Infinity, u = -Infinity;
			for (let e of f.columns) {
				let t = e.meta_data;
				if (e.file_path) throw Error("parquet file_path not supported");
				if (!t) throw Error("parquet column metadata is undefined");
				if (!r || r.includes(t.path_in_schema[0])) {
					let n = t.dictionary_page_offset || t.data_page_offset, r = Number(n), s = Number(n + t.total_compressed_size);
					if (r < a && (a = r), s > u && (u = s), o && e.offset_index_offset && e.offset_index_length) {
						let n = Number(e.offset_index_offset);
						i.push({
							columnMetadata: t,
							offsetIndex: {
								startByte: n,
								endByte: n + e.offset_index_length
							},
							bounds: {
								startByte: r,
								endByte: s
							}
						});
					} else i.push({
						columnMetadata: t,
						range: {
							startByte: r,
							endByte: s
						}
					});
				}
			}
			let p = Math.max(t - d, 0), m = Math.min(n - d, e);
			s.push({
				chunks: i,
				rowGroup: f,
				groupStart: d,
				groupRows: e,
				selectStart: p,
				selectEnd: m
			});
			let h;
			for (let e of i) if ("offsetIndex" in e) l.push(e.offsetIndex);
			else {
				let { range: t } = e;
				r ? c.push(t) : h && t.endByte - h.startByte <= me ? h.endByte = t.endByte : (h && c.push(h), h = { ...t });
			}
			h && c.push(h);
		}
		d = p;
	}
	return isFinite(n) || (n = d), c.push(...l), {
		metadata: e,
		rowStart: t,
		rowEnd: n,
		columns: r,
		fetches: c,
		groups: s
	};
}
function ge(e, { fetches: t }) {
	let n = t.map(({ startByte: t, endByte: n }) => e.slice(t, n));
	return {
		byteLength: e.byteLength,
		slice(r, i = e.byteLength) {
			let a = t.findIndex(({ startByte: e, endByte: t }) => e <= r && i <= t);
			if (a < 0) return e.slice(r, i);
			if (t[a].startByte !== r || t[a].endByte !== i) {
				let e = r - t[a].startByte, o = i - t[a].startByte;
				return n[a] instanceof Promise ? n[a].then((t) => t.slice(e, o)) : n[a].slice(e, o);
			} else return n[a];
		}
	};
}
//#endregion
//#region ../../node_modules/hyparquet/src/variant.js
var I = new TextDecoder(), L = /* @__PURE__ */ new WeakMap();
function R(e, t = p) {
	if (Array.isArray(e)) return e.map((e) => R(e, t));
	if (typeof e != "object") return e;
	if ("metadata" in e) {
		let n = _e(e.metadata), r = e.typed_value && z(e.typed_value, n, t), i = e.value && H(B(e.value), n, t);
		return r && i ? {
			...i,
			...r
		} : r ?? i;
	}
	return e;
}
function z(e, t, n) {
	if (e && typeof e == "object" && !Array.isArray(e) && !(e instanceof Uint8Array)) {
		if ("typed_value" in e) return z(e.typed_value, t, n);
		if ("value" in e && e.value instanceof Uint8Array) return H(B(e.value), t, n);
		let r = {};
		for (let [i, a] of Object.entries(e)) r[i] = z(a, t, n);
		return r;
	}
	return e instanceof Uint8Array ? H(B(e), t, n) : Array.isArray(e) ? e.map((e) => z(e, t, n)) : e;
}
function B(e) {
	return {
		view: new DataView(e.buffer, e.byteOffset, e.byteLength),
		offset: 0
	};
}
function _e(e) {
	let t = L.get(e.buffer);
	t || (t = /* @__PURE__ */ new Map(), L.set(e.buffer, t));
	let n = `${e.byteOffset}:${e.byteLength}`, r = t.get(n);
	if (r) return r;
	let i = B(e), a = i.view.getUint8(i.offset++), o = a & 15;
	if (o !== 1) throw Error(`parquet unsupported variant metadata version: ${o}`);
	let s = (a >> 4 & 1) == 1, c = (a >> 6 & 3) + 1, l = V(i, c), u = Array(l + 1);
	for (let e = 0; e < u.length; e++) u[e] = V(i, c);
	let d = i.offset, f = Array(l);
	for (let t = 0; t < l; t++) {
		let n = u[t], r = u[t + 1], i = new Uint8Array(e.buffer, e.byteOffset + d + n, r - n);
		f[t] = I.decode(i);
	}
	let p = {
		dictionary: f,
		sorted: s
	};
	return t.set(n, p), p;
}
function V(e, t) {
	let n = 0;
	for (let r = 0; r < t; r++) n |= e.view.getUint8(e.offset + r) << r * 8;
	return e.offset += t, n;
}
function H(e, t, n) {
	let r = e.view.getUint8(e.offset++), i = r & 3, a = r >> 2;
	if (i === 0) return ve(e, a, n);
	if (i === 2) return ye(e, a, t, n);
	if (i === 3) return be(e, a, t, n);
	let o = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, a);
	return e.offset += a, I.decode(o);
}
function ve(e, t, n) {
	switch (t) {
		case 0: return null;
		case 1: return !0;
		case 2: return !1;
		case 3: {
			let t = e.view.getInt8(e.offset);
			return e.offset += 1, t;
		}
		case 4: {
			let t = e.view.getInt16(e.offset, !0);
			return e.offset += 2, t;
		}
		case 5: {
			let t = e.view.getInt32(e.offset, !0);
			return e.offset += 4, t;
		}
		case 6: {
			let t = e.view.getBigInt64(e.offset, !0);
			return e.offset += 8, t;
		}
		case 7: {
			let t = e.view.getFloat64(e.offset, !0);
			return e.offset += 8, t;
		}
		case 8: return U(e, 4);
		case 9: return U(e, 8);
		case 10: return U(e, 16);
		case 11: {
			let t = e.view.getInt32(e.offset, !0);
			return e.offset += 4, n.dateFromDays(t);
		}
		case 12:
		case 13: {
			let t = e.view.getBigInt64(e.offset, !0);
			return e.offset += 8, n.timestampFromMicroseconds(t);
		}
		case 14: {
			let t = e.view.getFloat32(e.offset, !0);
			return e.offset += 4, t;
		}
		case 15: return W(e);
		case 16: {
			let t = W(e);
			return I.decode(t);
		}
		case 17: {
			let t = e.view.getBigInt64(e.offset, !0);
			return e.offset += 8, t;
		}
		case 18:
		case 19: {
			let t = e.view.getBigInt64(e.offset, !0);
			return e.offset += 8, n.timestampFromNanoseconds(t);
		}
		case 20: {
			let t = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, 16);
			e.offset += 16;
			let n = Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
			return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
		}
		default: throw Error(`parquet unsupported variant primitive type: ${t}`);
	}
}
function ye(e, t, n, r) {
	let i = (t & 3) + 1, a = (t >> 2 & 3) + 1, o = t >> 4 & 1 ? V(e, 4) : e.view.getUint8(e.offset++), s = Array(o);
	for (let t = 0; t < o; t++) s[t] = V(e, a);
	let c = Array(o + 1);
	for (let t = 0; t < c.length; t++) c[t] = V(e, i);
	let l = {};
	for (let t = 0; t < o; t++) {
		let i = n.dictionary[s[t]];
		l[i] = H({
			view: e.view,
			offset: e.offset + c[t]
		}, n, r);
	}
	return e.offset += c[c.length - 1], l;
}
function be(e, t, n, r) {
	let i = t & 3, a = t >> 2 & 1, o = i + 1, s = V(e, a ? 4 : 1), c = Array(s + 1);
	for (let t = 0; t < c.length; t++) c[t] = V(e, o);
	let l = e.offset, u = Array(s);
	for (let t = 0; t < s; t++) u[t] = H({
		view: e.view,
		offset: l + c[t]
	}, n, r);
	return e.offset = l + c[c.length - 1], u;
}
function U(e, t) {
	let n = e.view.getUint8(e.offset);
	e.offset += 1;
	let r;
	if (t === 4) r = BigInt(e.view.getInt32(e.offset, !0)), e.offset += 4;
	else if (t === 8) r = e.view.getBigInt64(e.offset, !0), e.offset += 8;
	else {
		let t = e.view.getBigUint64(e.offset, !0);
		r = e.view.getBigInt64(e.offset + 8, !0) << 64n | t, e.offset += 16;
	}
	return Number(r) * 10 ** -n;
}
function W(e) {
	let t = e.view.getUint32(e.offset, !0);
	e.offset += 4;
	let n = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, t);
	return e.offset += t, n;
}
//#endregion
//#region ../../node_modules/hyparquet/src/assemble.js
function G(e, t, n, r, i) {
	let a = S(i);
	if (!t?.length && !n.length) {
		if (!a || !r.length) return r;
		t = Array(r.length).fill(a);
	}
	let o = t?.length || n.length, s = i.map(({ element: e }) => e.repetition_type), c = 0, l = [e], u = e, d = 0, f = 0, p = 0;
	if (n[0]) for (; d < s.length - 2 && p < n[0];) d++, s[d] !== "REQUIRED" && (u = u.at(-1), l.push(u), f++), s[d] === "REPEATED" && p++;
	for (let e = 0; e < o; e++) {
		let i = t?.length ? t[e] : a, o = n[e];
		for (; d && (o < p || s[d] !== "REPEATED");) s[d] !== "REQUIRED" && (l.pop(), f--), s[d] === "REPEATED" && p--, d--;
		for (u = l.at(-1); (d < s.length - 2 || s[d + 1] === "REPEATED") && (f < i || s[d + 1] === "REQUIRED");) {
			if (d++, s[d] !== "REQUIRED") {
				let e = [];
				u.push(e), u = e, l.push(e), f++;
			}
			s[d] === "REPEATED" && p++;
		}
		i === a ? u.push(r[c++]) : d === s.length - 2 ? u.push(null) : u.push([]);
	}
	if (!e.length) for (let e = 0; e < a; e++) {
		let e = [];
		u.push(e), u = e;
	}
	return e;
}
function K(e, t, n, r = 0) {
	let i = t.path.join("."), a = t.element.repetition_type === "OPTIONAL", o = a ? r + 1 : r;
	if (te(t)) {
		let s = t.children[0], c = o;
		s.children.length === 1 && (s = s.children[0], c++), K(e, s, n, c);
		let l = s.path.join("."), u = e.get(l);
		if (!u) throw Error("parquet list column missing values");
		a && q(u, r), e.set(i, u), e.delete(l);
		return;
	}
	if (ne(t)) {
		let s = t.children[0].element.name;
		K(e, t.children[0].children[0], n, o + 1), K(e, t.children[0].children[1], n, o + 1);
		let c = e.get(`${i}.${s}.key`), l = e.get(`${i}.${s}.value`);
		if (!c) throw Error("parquet map column missing keys");
		if (!l) throw Error("parquet map column missing values");
		if (c.length !== l.length) throw Error("parquet map column key/value length mismatch");
		let u = xe(c, l, o);
		a && q(u, r), e.delete(`${i}.${s}.key`), e.delete(`${i}.${s}.value`), e.set(i, u);
		return;
	}
	if (t.children.length) {
		let o = t.element.repetition_type === "REQUIRED" ? r : r + 1, s = {};
		for (let r of t.children) {
			K(e, r, n, o);
			let t = e.get(r.path.join("."));
			if (!t) throw Error("parquet struct missing child data");
			s[r.element.name] = t;
		}
		for (let n of t.children) e.delete(n.path.join("."));
		let c = Se(s, o);
		t.element.logical_type?.type === "VARIANT" && (c = R(c, n)), a && q(c, r), e.set(i, c);
	}
}
function q(e, t) {
	for (let n = 0; n < e.length; n++) t ? q(e[n], t - 1) : e[n] = e[n][0];
}
function xe(e, t, n) {
	let r = [];
	for (let i = 0; i < e.length; i++) if (n) r.push(xe(e[i], t[i], n - 1));
	else if (e[i]) {
		let n = {};
		for (let r = 0; r < e[i].length; r++) {
			let a = t[i][r];
			n[e[i][r]] = a === void 0 ? null : a;
		}
		r.push(n);
	} else r.push(void 0);
	return r;
}
function Se(e, t) {
	let n = Object.keys(e), r = e[n[0]]?.length, i = [];
	for (let a = 0; a < r; a++) {
		let o = {};
		for (let t of n) {
			if (e[t].length !== r) throw Error("parquet struct parsing error");
			o[t] = e[t][a];
		}
		t ? i.push(Se(o, t - 1)) : i.push(o);
	}
	return i;
}
//#endregion
//#region ../../node_modules/hyparquet/src/delta.js
function J(e, t, n) {
	let r = n instanceof Int32Array, i = E(e), a = E(e);
	E(e);
	let o = O(e), s = 0;
	n[s++] = r ? Number(o) : o;
	let c = i / a;
	for (; s < t;) {
		let i = O(e), l = new Uint8Array(a);
		for (let t = 0; t < a; t++) l[t] = e.view.getUint8(e.offset++);
		for (let u = 0; u < a && s < t; u++) {
			let a = BigInt(l[u]);
			if (a) {
				let l = 0n, u = c, d = (1n << a) - 1n;
				for (; u && s < t;) {
					let t = BigInt(e.view.getUint8(e.offset)) >> l & d;
					for (l += a; l >= 8;) l -= 8n, e.offset++, l && (t |= BigInt(e.view.getUint8(e.offset)) << a - l & d);
					let c = i + t;
					o += c, n[s++] = r ? Number(o) : o, u--;
				}
				u && (e.offset += Math.ceil((u * Number(a) + Number(l)) / 8));
			} else for (let e = 0; e < c && s < t; e++) o += i, n[s++] = r ? Number(o) : o;
		}
	}
}
function Ce(e, t, n) {
	let r = new Int32Array(t);
	J(e, t, r);
	for (let i = 0; i < t; i++) n[i] = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, r[i]), e.offset += r[i];
}
function we(e, t, n) {
	let r = new Int32Array(t);
	J(e, t, r);
	let i = new Int32Array(t);
	J(e, t, i);
	for (let a = 0; a < t; a++) {
		let t = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, i[a]);
		r[a] ? (n[a] = new Uint8Array(r[a] + i[a]), n[a].set(n[a - 1].subarray(0, r[a])), n[a].set(t, r[a])) : n[a] = t, e.offset += i[a];
	}
}
//#endregion
//#region ../../node_modules/hyparquet/src/encoding.js
function Y(e) {
	return 32 - Math.clz32(e);
}
function X(e, t, n, r) {
	r === void 0 && (r = e.view.getUint32(e.offset, !0), e.offset += 4);
	let i = e.offset, a = 0;
	for (; a < n.length;) {
		let r = E(e);
		if (r & 1) a = Ee(e, r, t, n, a);
		else {
			let i = r >>> 1;
			Te(e, i, t, n, a), a += i;
		}
	}
	e.offset = i + r;
}
function Te(e, t, n, r, i) {
	let a = n + 7 >> 3, o = 0;
	for (let t = 0; t < a; t++) o |= e.view.getUint8(e.offset++) << (t << 3);
	for (let e = 0; e < t; e++) r[i + e] = o;
}
function Ee(e, t, n, r, i) {
	let a = t >> 1 << 3, o = (1 << n) - 1, s = 0;
	if (e.offset < e.view.byteLength) s = e.view.getUint8(e.offset++);
	else if (o) throw Error(`parquet bitpack offset ${e.offset} out of range`);
	let c = 8, l = 0;
	for (; a;) l > 8 ? (l -= 8, c -= 8, s >>>= 8) : c - l < n ? (s |= e.view.getUint8(e.offset) << c, e.offset++, c += 8) : (i < r.length && (r[i++] = s >> l & o), a--, l += n);
	return i;
}
function De(e, t, n, r) {
	let i = Oe(n, r), a = new Uint8Array(t * i);
	for (let n = 0; n < i; n++) for (let r = 0; r < t; r++) a[r * i + n] = e.view.getUint8(e.offset++);
	if (n === "FLOAT") return new Float32Array(a.buffer);
	if (n === "DOUBLE") return new Float64Array(a.buffer);
	if (n === "INT32") return new Int32Array(a.buffer);
	if (n === "INT64") return new BigInt64Array(a.buffer);
	if (n === "FIXED_LEN_BYTE_ARRAY") {
		let e = Array(t);
		for (let n = 0; n < t; n++) e[n] = a.subarray(n * i, (n + 1) * i);
		return e;
	}
	throw Error(`parquet byte_stream_split unsupported type: ${n}`);
}
function Oe(e, t) {
	switch (e) {
		case "INT32":
		case "FLOAT": return 4;
		case "INT64":
		case "DOUBLE": return 8;
		case "FIXED_LEN_BYTE_ARRAY":
			if (!t) throw Error("parquet byteWidth missing type_length");
			return t;
		default: throw Error(`parquet unsupported type: ${e}`);
	}
}
//#endregion
//#region ../../node_modules/hyparquet/src/plain.js
function Z(e, t, n, r) {
	if (n === 0) return [];
	if (t === "BOOLEAN") return ke(e, n);
	if (t === "INT32") return Ae(e, n);
	if (t === "INT64") return je(e, n);
	if (t === "INT96") return Me(e, n);
	if (t === "FLOAT") return Ne(e, n);
	if (t === "DOUBLE") return Pe(e, n);
	if (t === "BYTE_ARRAY") return Fe(e, n);
	if (t === "FIXED_LEN_BYTE_ARRAY") {
		if (!r) throw Error("parquet missing fixed length");
		return Ie(e, n, r);
	} else throw Error(`parquet unhandled type: ${t}`);
}
function ke(e, t) {
	let n = Array(t);
	for (let r = 0; r < t; r++) {
		let t = e.offset + (r / 8 | 0), i = r % 8;
		n[r] = (e.view.getUint8(t) & 1 << i) != 0;
	}
	return e.offset += Math.ceil(t / 8), n;
}
function Ae(e, t) {
	let n = (e.view.byteOffset + e.offset) % 4 ? new Int32Array(Q(e.view.buffer, e.view.byteOffset + e.offset, t * 4)) : new Int32Array(e.view.buffer, e.view.byteOffset + e.offset, t);
	return e.offset += t * 4, n;
}
function je(e, t) {
	let n = (e.view.byteOffset + e.offset) % 8 ? new BigInt64Array(Q(e.view.buffer, e.view.byteOffset + e.offset, t * 8)) : new BigInt64Array(e.view.buffer, e.view.byteOffset + e.offset, t);
	return e.offset += t * 8, n;
}
function Me(e, t) {
	let n = Array(t);
	for (let r = 0; r < t; r++) {
		let t = e.view.getBigInt64(e.offset + r * 12, !0), i = e.view.getInt32(e.offset + r * 12 + 8, !0);
		n[r] = BigInt(i) << 64n | t;
	}
	return e.offset += t * 12, n;
}
function Ne(e, t) {
	let n = (e.view.byteOffset + e.offset) % 4 ? new Float32Array(Q(e.view.buffer, e.view.byteOffset + e.offset, t * 4)) : new Float32Array(e.view.buffer, e.view.byteOffset + e.offset, t);
	return e.offset += t * 4, n;
}
function Pe(e, t) {
	let n = (e.view.byteOffset + e.offset) % 8 ? new Float64Array(Q(e.view.buffer, e.view.byteOffset + e.offset, t * 8)) : new Float64Array(e.view.buffer, e.view.byteOffset + e.offset, t);
	return e.offset += t * 8, n;
}
function Fe(e, t) {
	let n = Array(t);
	for (let r = 0; r < t; r++) {
		let t = e.view.getUint32(e.offset, !0);
		e.offset += 4, n[r] = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, t), e.offset += t;
	}
	return n;
}
function Ie(e, t, n) {
	let r = Array(t);
	for (let i = 0; i < t; i++) r[i] = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, n), e.offset += n;
	return r;
}
function Q(e, t, n) {
	let r = new ArrayBuffer(n);
	return new Uint8Array(r).set(new Uint8Array(e, t, n)), r;
}
//#endregion
//#region ../../node_modules/hyparquet/src/snappy.js
var Le = [
	0,
	255,
	65535,
	16777215,
	4294967295
];
function Re(e, t, n, r, i) {
	for (let a = 0; a < i; a++) n[r + a] = e[t + a];
}
function ze(e, t) {
	let n = e.byteLength, r = t.byteLength, i = 0, a = 0;
	for (; i < n;) {
		let t = e[i];
		if (i++, t < 128) break;
	}
	if (r && i >= n) throw Error("invalid snappy length header");
	for (; i < n;) {
		let r = e[i], o = 0;
		if (i++, i >= n) throw Error("missing eof marker");
		if (r & 3) {
			let s = 0;
			switch (r & 3) {
				case 1:
					o = (r >>> 2 & 7) + 4, s = e[i] + (r >>> 5 << 8), i++;
					break;
				case 2:
					if (n <= i + 1) throw Error("snappy error end of input");
					o = (r >>> 2) + 1, s = e[i] + (e[i + 1] << 8), i += 2;
					break;
				case 3:
					if (n <= i + 3) throw Error("snappy error end of input");
					o = (r >>> 2) + 1, s = e[i] + (e[i + 1] << 8) + (e[i + 2] << 16) + (e[i + 3] << 24), i += 4;
					break;
				default: break;
			}
			if (s === 0 || isNaN(s)) throw Error(`invalid offset ${s} pos ${i} inputLength ${n}`);
			if (s > a) throw Error("cannot copy from before start of buffer");
			Re(t, a - s, t, a, o), a += o;
		} else {
			let o = (r >>> 2) + 1;
			if (o > 60) {
				if (i + 3 >= n) throw Error("snappy error literal pos + 3 >= inputLength");
				let t = o - 60;
				o = e[i] + (e[i + 1] << 8) + (e[i + 2] << 16) + (e[i + 3] << 24), o = (o & Le[t]) + 1, i += t;
			}
			if (i + o > n) throw Error("snappy error literal exceeds input length");
			Re(e, i, t, a, o), i += o, a += o;
		}
	}
	if (a !== r) throw Error("premature end of input");
}
//#endregion
//#region ../../node_modules/hyparquet/src/datapage.js
function Be(e, t, { type: n, element: r, schemaPath: i }) {
	let a = new DataView(e.buffer, e.byteOffset, e.byteLength), o = {
		view: a,
		offset: 0
	}, s, c = Ve(o, t, i), { definitionLevels: l, numNulls: u } = He(o, t, i), d = t.num_values - u;
	if (t.encoding === "PLAIN") s = Z(o, n, d, r.type_length);
	else if (t.encoding === "PLAIN_DICTIONARY" || t.encoding === "RLE_DICTIONARY" || t.encoding === "RLE") {
		let e = n === "BOOLEAN" ? 1 : a.getUint8(o.offset++);
		e ? (s = Array(d), n === "BOOLEAN" ? (X(o, e, s), s = s.map((e) => !!e)) : X(o, e, s, a.byteLength - o.offset)) : s = new Uint8Array(d);
	} else if (t.encoding === "BYTE_STREAM_SPLIT") s = De(o, d, n, r.type_length);
	else if (t.encoding === "DELTA_BINARY_PACKED") s = n === "INT32" ? new Int32Array(d) : new BigInt64Array(d), J(o, d, s);
	else if (t.encoding === "DELTA_LENGTH_BYTE_ARRAY") s = Array(d), Ce(o, d, s);
	else throw Error(`parquet unsupported encoding: ${t.encoding}`);
	return {
		definitionLevels: l,
		repetitionLevels: c,
		dataPage: s
	};
}
function Ve(e, t, n) {
	if (n.length > 1) {
		let r = x(n);
		if (r) {
			let n = Array(t.num_values);
			return X(e, Y(r), n), n;
		}
	}
	return [];
}
function He(e, t, n) {
	let r = S(n);
	if (!r) return {
		definitionLevels: [],
		numNulls: 0
	};
	let i = Array(t.num_values);
	X(e, Y(r), i);
	let a = t.num_values;
	for (let e of i) e === r && a--;
	return a === 0 && (i.length = 0), {
		definitionLevels: i,
		numNulls: a
	};
}
function $(e, t, n, r) {
	let i, a = r?.[n];
	if (n === "UNCOMPRESSED") i = e;
	else if (a) i = a(e, t);
	else if (n === "SNAPPY") i = new Uint8Array(t), ze(e, i);
	else throw Error(`parquet unsupported compression codec: ${n}`);
	if (i?.length !== t) throw Error(`parquet decompressed page length ${i?.length} does not match header ${t}`);
	return i;
}
function Ue(e, t, n) {
	let r = {
		view: new DataView(e.buffer, e.byteOffset, e.byteLength),
		offset: 0
	}, { type: i, element: a, schemaPath: o, codec: s, compressors: c } = n, l = t.data_page_header_v2;
	if (!l) throw Error("parquet data page header v2 is undefined");
	let u = We(r, l, o);
	r.offset = l.repetition_levels_byte_length;
	let d = Ge(r, l, o), f = t.uncompressed_page_size - l.definition_levels_byte_length - l.repetition_levels_byte_length, p = e.subarray(r.offset);
	l.is_compressed !== !1 && (p = $(p, f, s, c));
	let m = new DataView(p.buffer, p.byteOffset, p.byteLength), h = {
		view: m,
		offset: 0
	}, g, _ = l.num_values - l.num_nulls;
	if (l.encoding === "PLAIN") g = Z(h, i, _, a.type_length);
	else if (l.encoding === "RLE") g = Array(_), X(h, 1, g), g = g.map((e) => !!e);
	else if (l.encoding === "PLAIN_DICTIONARY" || l.encoding === "RLE_DICTIONARY") {
		let e = m.getUint8(h.offset++);
		g = Array(_), X(h, e, g, f - 1);
	} else if (l.encoding === "DELTA_BINARY_PACKED") g = i === "INT32" ? new Int32Array(_) : new BigInt64Array(_), J(h, _, g);
	else if (l.encoding === "DELTA_LENGTH_BYTE_ARRAY") g = Array(_), Ce(h, _, g);
	else if (l.encoding === "DELTA_BYTE_ARRAY") g = Array(_), we(h, _, g);
	else if (l.encoding === "BYTE_STREAM_SPLIT") g = De(h, _, i, a.type_length);
	else throw Error(`parquet unsupported encoding: ${l.encoding}`);
	return {
		definitionLevels: d,
		repetitionLevels: u,
		dataPage: g
	};
}
function We(e, t, n) {
	let r = x(n);
	if (!r) return [];
	let i = Array(t.num_values);
	return X(e, Y(r), i, t.repetition_levels_byte_length), i;
}
function Ge(e, t, n) {
	let r = S(n);
	if (r) {
		let n = Array(t.num_values);
		return X(e, Y(r), n, t.definition_levels_byte_length), n;
	}
}
//#endregion
//#region ../../node_modules/hyparquet/src/column.js
function Ke(e, { groupStart: t, selectStart: n, selectEnd: r }, i, a) {
	let { pathInSchema: o, schemaPath: s } = i, c = re(s), l = [], u, d, f = 0, p = 0, m = a && (() => {
		d && a({
			pathInSchema: o,
			columnData: d,
			rowStart: t + f - d.length,
			rowEnd: t + f
		});
	});
	for (; (c ? f < r : e.offset < e.view.byteLength - 1) && !(e.offset >= e.view.byteLength - 1);) {
		let t = Je(e);
		if (t.type === "DICTIONARY_PAGE") {
			let { data: n } = qe(e, t, i, u, void 0, 0);
			n && (u = h(n, i));
		} else {
			let r = d?.length || 0, a = qe(e, t, i, u, d, n - f);
			a.skipped ? (l.length || (p += a.skipped), f += a.skipped) : a.data && d === a.data ? f += a.data.length - r : a.data && a.data.length && (m?.(), l.push(a.data), f += a.data.length, d = a.data);
		}
	}
	return m?.(), {
		data: l,
		skipped: p
	};
}
function qe(e, t, n, r, i, a) {
	let { type: o, element: s, schemaPath: c, codec: l, compressors: u } = n, d = new Uint8Array(e.view.buffer, e.view.byteOffset + e.offset, t.compressed_page_size);
	if (e.offset += t.compressed_page_size, t.type === "DATA_PAGE") {
		let e = t.data_page_header;
		if (!e) throw Error("parquet data page header is undefined");
		if (a > e.num_values && re(c)) return { skipped: e.num_values };
		let { definitionLevels: o, repetitionLevels: s, dataPage: f } = Be($(d, Number(t.uncompressed_page_size), l, u), e, n), p = m(f, r, e.encoding, n);
		return {
			skipped: 0,
			data: G(Array.isArray(i) ? i : [], o, s, p, c)
		};
	} else if (t.type === "DATA_PAGE_V2") {
		let e = t.data_page_header_v2;
		if (!e) throw Error("parquet data page header v2 is undefined");
		if (a > e.num_rows) return { skipped: e.num_values };
		let { definitionLevels: o, repetitionLevels: s, dataPage: l } = Ue(d, t, n), u = m(l, r, e.encoding, n);
		return {
			skipped: 0,
			data: G(Array.isArray(i) ? i : [], o, s, u, c)
		};
	} else if (t.type === "DICTIONARY_PAGE") {
		let e = t.dictionary_page_header;
		if (!e) throw Error("parquet dictionary page header is undefined");
		let n = $(d, Number(t.uncompressed_page_size), l, u);
		return {
			skipped: 0,
			data: Z({
				view: new DataView(n.buffer, n.byteOffset, n.byteLength),
				offset: 0
			}, o, e.num_values, s.type_length)
		};
	} else throw Error(`parquet unsupported page type: ${t.type}`);
}
function Je(e) {
	let n = w(e);
	return {
		type: a[n.field_1],
		uncompressed_page_size: n.field_2,
		compressed_page_size: n.field_3,
		crc: n.field_4,
		data_page_header: n.field_5 && {
			num_values: n.field_5.field_1,
			encoding: t[n.field_5.field_2],
			definition_level_encoding: t[n.field_5.field_3],
			repetition_level_encoding: t[n.field_5.field_4],
			statistics: n.field_5.field_5 && {
				max: n.field_5.field_5.field_1,
				min: n.field_5.field_5.field_2,
				null_count: n.field_5.field_5.field_3,
				distinct_count: n.field_5.field_5.field_4,
				max_value: n.field_5.field_5.field_5,
				min_value: n.field_5.field_5.field_6
			}
		},
		index_page_header: n.field_6,
		dictionary_page_header: n.field_7 && {
			num_values: n.field_7.field_1,
			encoding: t[n.field_7.field_2],
			is_sorted: n.field_7.field_3
		},
		data_page_header_v2: n.field_8 && {
			num_values: n.field_8.field_1,
			num_nulls: n.field_8.field_2,
			num_rows: n.field_8.field_3,
			encoding: t[n.field_8.field_4],
			definition_levels_byte_length: n.field_8.field_5,
			repetition_levels_byte_length: n.field_8.field_6,
			is_compressed: n.field_8.field_7 === void 0 ? !0 : n.field_8.field_7,
			statistics: n.field_8.field_8
		}
	};
}
//#endregion
//#region ../../node_modules/hyparquet/src/indexes.js
function Ye(e) {
	let t = w(e);
	return {
		page_locations: t.field_1.map(Xe),
		unencoded_byte_array_data_bytes: t.field_2
	};
}
function Xe(e) {
	return {
		offset: e.field_1,
		compressed_page_size: e.field_2,
		first_row_index: e.field_3
	};
}
//#endregion
//#region ../../node_modules/hyparquet/src/rowgroup.js
function Ze(e, { metadata: t }, n) {
	let { file: r, compressors: i, utf8: a } = e, o = [], s = {
		...p,
		...e.parsers
	};
	for (let c of n.chunks) {
		let { columnMetadata: l } = c, u = b(t.schema, l.path_in_schema), d = {
			pathInSchema: l.path_in_schema,
			type: l.type,
			element: u[u.length - 1].element,
			schemaPath: u,
			codec: l.codec,
			parsers: s,
			compressors: i,
			utf8: a
		};
		if (!("offsetIndex" in c)) {
			o.push({
				pathInSchema: l.path_in_schema,
				data: Promise.resolve(r.slice(c.range.startByte, c.range.endByte)).then((t) => Ke({
					view: new DataView(t),
					offset: 0
				}, n, d, e.onPage))
			});
			continue;
		}
		o.push({
			pathInSchema: l.path_in_schema,
			data: Promise.resolve(r.slice(c.offsetIndex.startByte, c.offsetIndex.endByte)).then(async (t) => {
				let i = Ye({
					view: new DataView(t),
					offset: 0
				}), { selectStart: a, selectEnd: o } = n, s = i.page_locations, c = NaN, l = NaN, u = 0;
				for (let e = 0; e < s.length; e++) {
					let t = s[e], r = Number(t.first_row_index), i = e + 1 < s.length ? Number(s[e + 1].first_row_index) : n.groupRows;
					r < o && i > a && (Number.isNaN(c) && (c = Number(t.offset), u = r), l = Number(t.offset) + t.compressed_page_size);
				}
				let f = await r.slice(c, l), { data: p, skipped: m } = Ke({
					view: new DataView(f),
					offset: 0
				}, u ? {
					...n,
					groupStart: n.groupStart + u,
					selectStart: n.selectStart - u,
					selectEnd: n.selectEnd - u
				} : n, d, e.onPage);
				return {
					data: p,
					skipped: u + m
				};
			})
		});
	}
	return {
		groupStart: n.groupStart,
		groupRows: n.groupRows,
		asyncColumns: o
	};
}
function Qe(e, t, n) {
	let { asyncColumns: r } = e;
	n = {
		...p,
		...n
	};
	let i = [];
	for (let e of t.children) if (e.children.length) {
		let t = r.filter((t) => t.pathInSchema[0] === e.element.name);
		if (!t.length) continue;
		let a = /* @__PURE__ */ new Map(), o = Promise.all(t.map((e) => e.data.then(({ data: t }) => {
			a.set(e.pathInSchema.join("."), pe(t));
		}))).then(() => {
			K(a, e, n);
			let t = a.get(e.path.join("."));
			if (!t) throw Error("parquet column data not assembled");
			return {
				data: [t],
				skipped: 0
			};
		});
		i.push({
			pathInSchema: e.path,
			data: o
		});
	} else {
		let t = r.find((t) => t.pathInSchema[0] === e.element.name);
		t && i.push(t);
	}
	return {
		...e,
		asyncColumns: i
	};
}
//#endregion
//#region src/data/formats/parquetRead.js
var $e = /* @__PURE__ */ new Map(), et = 200;
function tt(e) {
	if (!e.metadata) throw Error("parquet requires metadata");
	let t = he(e);
	return e.file = ge(e.file, t), t.groups.map((n) => Ze(e, t, n));
}
function nt(e) {
	if (!e) return [];
	if (e.length === 1) return e[0];
	let t = 0;
	for (let n of e) t += n.length;
	let n = Array(t), r = 0;
	for (let t of e) {
		for (let e = 0; e < t.length; e++) n[r + e] = t[e];
		r += t.length;
	}
	return n;
}
function rt(e) {
	let t = e.join(""), n = $e.get(t);
	if (n) return n;
	let r = e.map((e, t) => JSON.stringify(e) + ": columnData[" + t + "][row - columnSkipped[" + t + "]]").join(",\n"), i = Function("groupData", "selectStart", "selectCount", "columnData", "columnSkipped", "for (let selectRow = 0; selectRow < selectCount; selectRow++) {\n    const row = selectStart + selectRow;\n    groupData[selectRow] = {\n" + r + "\n    };\n}\nreturn groupData;");
	return $e.set(t, i), i;
}
function it(e, t, n, r, i, a) {
	for (let o = 0; o < n; o++) {
		let n = t + o, s = {};
		for (let e = 0; e < r.length; e++) s[r[e]] = i[e][n - a[e]];
		e[o] = s;
	}
	return e;
}
async function at({ asyncColumns: e }, t, n) {
	let r = await Promise.all(e.map((e) => e.data)), i = e.length, a = Array(i), o = Array(i), s = Array(i);
	for (let t = 0; t < i; t++) a[t] = e[t].pathInSchema[0], o[t] = nt(r[t].data), s[t] = r[t].skipped;
	let c = n - t, l = Array(c);
	return i > et ? it(l, t, c, a, o, s) : rt(a)(l, t, c, o, s);
}
async function ot(e) {
	if ("rowFormat" in e) throw Error("parquetRead supports only object rows; use rowFormat: \"object\" implicitly");
	if ("filter" in e || "filterStrict" in e) throw Error("parquetRead does not support filtering");
	e.metadata ??= await le(e.file, e);
	let { rowStart: t = 0, rowEnd: n, onChunk: r, onComplete: i } = e, a = tt(e);
	if (!i && !r) {
		for (let { asyncColumns: e } of a) for (let { data: t } of e) await t;
		return;
	}
	let o = A(e.metadata), s = a.map((t) => Qe(t, o, e.parsers));
	if (r) for (let e of s) for (let t of e.asyncColumns) t.data.then((n) => {
		let i = e.groupStart + n.skipped;
		for (let e of n.data) r({
			columnName: t.pathInSchema[0],
			columnData: e,
			rowStart: i,
			rowEnd: i + e.length
		}), i += e.length;
	});
	if (i) {
		let e = [];
		for (let r of s) N(e, await at(r, Math.max(t - r.groupStart, 0), Math.min((n ?? Infinity) - r.groupStart, r.groupRows)));
		i(e);
	} else for (let { asyncColumns: e } of s) for (let { data: t } of e) await t;
}
function st(e) {
	return new Promise((t, n) => {
		ot({
			...e,
			onComplete: t
		}).catch(n);
	});
}
//#endregion
export { st as parquetReadObjects };
