
//#region ../../node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
*    may be used to endorse or promote products derived from this software without
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function e(e$1, t$1) {
	let n$1 = e$1.slice(0, t$1).split(/\r\n|\n|\r/g);
	return [n$1.length, n$1.pop().length + 1];
}
function t(e$1, t$1, n$1) {
	let r$1 = e$1.split(/\r\n|\n|\r/g), i$1 = ``, a$1 = (Math.log10(t$1 + 1) | 0) + 1;
	for (let e$2 = t$1 - 1; e$2 <= t$1 + 1; e$2++) {
		let o$1 = r$1[e$2 - 1];
		o$1 && (i$1 += e$2.toString().padEnd(a$1, ` `), i$1 += `:  `, i$1 += o$1, i$1 += `
`, e$2 === t$1 && (i$1 += ` `.repeat(a$1 + n$1 + 2), i$1 += `^
`));
	}
	return i$1;
}
var n = class extends Error {
	line;
	column;
	codeblock;
	constructor(n$1, r$1) {
		let [i$1, a$1] = e(r$1.toml, r$1.ptr), o$1 = t(r$1.toml, i$1, a$1);
		super(`Invalid TOML document: ${n$1}\n\n${o$1}`, r$1), this.line = i$1, this.column = a$1, this.codeblock = o$1;
	}
};
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
*    may be used to endorse or promote products derived from this software without
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function r(e$1, t$1) {
	let n$1 = 0;
	for (; e$1[t$1 - ++n$1] === `\\`;);
	return --n$1 && n$1 % 2;
}
function i(e$1, t$1 = 0, n$1 = e$1.length) {
	let r$1 = e$1.indexOf(`
`, t$1);
	return e$1[r$1 - 1] === `\r` && r$1--, r$1 <= n$1 ? r$1 : -1;
}
function a(e$1, t$1) {
	for (let r$1 = t$1; r$1 < e$1.length; r$1++) {
		let i$1 = e$1[r$1];
		if (i$1 === `
`) return r$1;
		if (i$1 === `\r` && e$1[r$1 + 1] === `
`) return r$1 + 1;
		if (i$1 < ` ` && i$1 !== `	` || i$1 === ``) throw new n(`control characters are not allowed in comments`, {
			toml: e$1,
			ptr: t$1
		});
	}
	return e$1.length;
}
function o(e$1, t$1, n$1, r$1) {
	let i$1;
	for (; (i$1 = e$1[t$1]) === ` ` || i$1 === `	` || !n$1 && (i$1 === `
` || i$1 === `\r` && e$1[t$1 + 1] === `
`);) t$1++;
	return r$1 || i$1 !== `#` ? t$1 : o(e$1, a(e$1, t$1), n$1);
}
function s(e$1, t$1, r$1, a$1, o$1 = !1) {
	if (!a$1) return t$1 = i(e$1, t$1), t$1 < 0 ? e$1.length : t$1;
	for (let n$1 = t$1; n$1 < e$1.length; n$1++) {
		let t$2 = e$1[n$1];
		if (t$2 === `#`) n$1 = i(e$1, n$1);
		else if (t$2 === r$1) return n$1 + 1;
		else if (t$2 === a$1 || o$1 && (t$2 === `
` || t$2 === `\r` && e$1[n$1 + 1] === `
`)) return n$1;
	}
	throw new n(`cannot find end of structure`, {
		toml: e$1,
		ptr: t$1
	});
}
function c(e$1, t$1) {
	let n$1 = e$1[t$1], i$1 = n$1 === e$1[t$1 + 1] && e$1[t$1 + 1] === e$1[t$1 + 2] ? e$1.slice(t$1, t$1 + 3) : n$1;
	t$1 += i$1.length - 1;
	do
		t$1 = e$1.indexOf(i$1, ++t$1);
	while (t$1 > -1 && n$1 !== `'` && r(e$1, t$1));
	return t$1 > -1 && (t$1 += i$1.length, i$1.length > 1 && (e$1[t$1] === n$1 && t$1++, e$1[t$1] === n$1 && t$1++)), t$1;
}
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
*    may be used to endorse or promote products derived from this software without
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
let l = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
var u = class e$1 extends Date {
	#e = !1;
	#t = !1;
	#n = null;
	constructor(e$2) {
		let t$1 = !0, n$1 = !0, r$1 = `Z`;
		if (typeof e$2 == `string`) {
			let i$1 = e$2.match(l);
			i$1 ? (i$1[1] || (t$1 = !1, e$2 = `0000-01-01T${e$2}`), n$1 = !!i$1[2], n$1 && e$2[10] === ` ` && (e$2 = e$2.replace(` `, `T`)), i$1[2] && +i$1[2] > 23 ? e$2 = `` : (r$1 = i$1[3] || null, e$2 = e$2.toUpperCase(), !r$1 && n$1 && (e$2 += `Z`))) : e$2 = ``;
		}
		super(e$2), isNaN(this.getTime()) || (this.#e = t$1, this.#t = n$1, this.#n = r$1);
	}
	isDateTime() {
		return this.#e && this.#t;
	}
	isLocal() {
		return !this.#e || !this.#t || !this.#n;
	}
	isDate() {
		return this.#e && !this.#t;
	}
	isTime() {
		return this.#t && !this.#e;
	}
	isValid() {
		return this.#e || this.#t;
	}
	toISOString() {
		let e$2 = super.toISOString();
		if (this.isDate()) return e$2.slice(0, 10);
		if (this.isTime()) return e$2.slice(11, 23);
		if (this.#n === null) return e$2.slice(0, -1);
		if (this.#n === `Z`) return e$2;
		let t$1 = this.#n.slice(1, 3) * 60 + +this.#n.slice(4, 6);
		return t$1 = this.#n[0] === `-` ? t$1 : -t$1, (/* @__PURE__ */ new Date(this.getTime() - t$1 * 6e4)).toISOString().slice(0, -1) + this.#n;
	}
	static wrapAsOffsetDateTime(t$1, n$1 = `Z`) {
		let r$1 = new e$1(t$1);
		return r$1.#n = n$1, r$1;
	}
	static wrapAsLocalDateTime(t$1) {
		let n$1 = new e$1(t$1);
		return n$1.#n = null, n$1;
	}
	static wrapAsLocalDate(t$1) {
		let n$1 = new e$1(t$1);
		return n$1.#t = !1, n$1.#n = null, n$1;
	}
	static wrapAsLocalTime(t$1) {
		let n$1 = new e$1(t$1);
		return n$1.#e = !1, n$1.#n = null, n$1;
	}
};
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
*    may be used to endorse or promote products derived from this software without
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
let d = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/, f = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/, p = /^[+-]?0[0-9_]/, m = /^[0-9a-f]{2,8}$/i, h = {
	b: `\b`,
	t: `	`,
	n: `
`,
	f: `\f`,
	r: `\r`,
	e: `\x1B`,
	"\"": `"`,
	"\\": `\\`
};
function g(e$1, t$1 = 0, r$1 = e$1.length) {
	let i$1 = e$1[t$1] === `'`, a$1 = e$1[t$1++] === e$1[t$1] && e$1[t$1] === e$1[t$1 + 1];
	a$1 && (r$1 -= 2, e$1[t$1 += 2] === `\r` && t$1++, e$1[t$1] === `
` && t$1++);
	let s$1 = 0, c$1, l$1 = ``, u$1 = t$1;
	for (; t$1 < r$1 - 1;) {
		let r$2 = e$1[t$1++];
		if (r$2 === `
` || r$2 === `\r` && e$1[t$1] === `
`) {
			if (!a$1) throw new n(`newlines are not allowed in strings`, {
				toml: e$1,
				ptr: t$1 - 1
			});
		} else if (r$2 < ` ` && r$2 !== `	` || r$2 === ``) throw new n(`control characters are not allowed in strings`, {
			toml: e$1,
			ptr: t$1 - 1
		});
		if (c$1) {
			if (c$1 = !1, r$2 === `x` || r$2 === `u` || r$2 === `U`) {
				let i$2 = e$1.slice(t$1, t$1 += r$2 === `x` ? 2 : r$2 === `u` ? 4 : 8);
				if (!m.test(i$2)) throw new n(`invalid unicode escape`, {
					toml: e$1,
					ptr: s$1
				});
				try {
					l$1 += String.fromCodePoint(parseInt(i$2, 16));
				} catch {
					throw new n(`invalid unicode escape`, {
						toml: e$1,
						ptr: s$1
					});
				}
			} else if (a$1 && (r$2 === `
` || r$2 === ` ` || r$2 === `	` || r$2 === `\r`)) {
				if (t$1 = o(e$1, t$1 - 1, !0), e$1[t$1] !== `
` && e$1[t$1] !== `\r`) throw new n(`invalid escape: only line-ending whitespace may be escaped`, {
					toml: e$1,
					ptr: s$1
				});
				t$1 = o(e$1, t$1);
			} else if (r$2 in h) l$1 += h[r$2];
			else throw new n(`unrecognized escape sequence`, {
				toml: e$1,
				ptr: s$1
			});
			u$1 = t$1;
		} else !i$1 && r$2 === `\\` && (s$1 = t$1 - 1, c$1 = !0, l$1 += e$1.slice(u$1, s$1));
	}
	return l$1 + e$1.slice(u$1, r$1 - 1);
}
function _(e$1, t$1, r$1, i$1) {
	if (e$1 === `true`) return !0;
	if (e$1 === `false`) return !1;
	if (e$1 === `-inf`) return -Infinity;
	if (e$1 === `inf` || e$1 === `+inf`) return Infinity;
	if (e$1 === `nan` || e$1 === `+nan` || e$1 === `-nan`) return NaN;
	if (e$1 === `-0`) return i$1 ? 0n : 0;
	let a$1 = d.test(e$1);
	if (a$1 || f.test(e$1)) {
		if (p.test(e$1)) throw new n(`leading zeroes are not allowed`, {
			toml: t$1,
			ptr: r$1
		});
		e$1 = e$1.replace(/_/g, ``);
		let o$2 = +e$1;
		if (isNaN(o$2)) throw new n(`invalid number`, {
			toml: t$1,
			ptr: r$1
		});
		if (a$1) {
			if ((a$1 = !Number.isSafeInteger(o$2)) && !i$1) throw new n(`integer value cannot be represented losslessly`, {
				toml: t$1,
				ptr: r$1
			});
			(a$1 || i$1 === !0) && (o$2 = BigInt(e$1));
		}
		return o$2;
	}
	let o$1 = new u(e$1);
	if (!o$1.isValid()) throw new n(`invalid value`, {
		toml: t$1,
		ptr: r$1
	});
	return o$1;
}
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
*    may be used to endorse or promote products derived from this software without
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function v(e$1, t$1, n$1) {
	let r$1 = e$1.slice(t$1, n$1), i$1 = r$1.indexOf(`#`);
	return i$1 > -1 && (a(e$1, i$1), r$1 = r$1.slice(0, i$1)), [r$1.trimEnd(), i$1];
}
function y(e$1, t$1, r$1, i$1, a$1) {
	if (i$1 === 0) throw new n(`document contains excessively nested structures. aborting.`, {
		toml: e$1,
		ptr: t$1
	});
	let l$1 = e$1[t$1];
	if (l$1 === `[` || l$1 === `{`) {
		let [s$1, c$1] = l$1 === `[` ? C(e$1, t$1, i$1, a$1) : S(e$1, t$1, i$1, a$1);
		if (r$1) {
			if (c$1 = o(e$1, c$1), e$1[c$1] === `,`) c$1++;
			else if (e$1[c$1] !== r$1) throw new n(`expected comma or end of structure`, {
				toml: e$1,
				ptr: c$1
			});
		}
		return [s$1, c$1];
	}
	let u$1;
	if (l$1 === `"` || l$1 === `'`) {
		u$1 = c(e$1, t$1);
		let i$2 = g(e$1, t$1, u$1);
		if (r$1) {
			if (u$1 = o(e$1, u$1), e$1[u$1] && e$1[u$1] !== `,` && e$1[u$1] !== r$1 && e$1[u$1] !== `
` && e$1[u$1] !== `\r`) throw new n(`unexpected character encountered`, {
				toml: e$1,
				ptr: u$1
			});
			u$1 += +(e$1[u$1] === `,`);
		}
		return [i$2, u$1];
	}
	u$1 = s(e$1, t$1, `,`, r$1);
	let d$1 = v(e$1, t$1, u$1 - +(e$1[u$1 - 1] === `,`));
	if (!d$1[0]) throw new n(`incomplete key-value declaration: no value specified`, {
		toml: e$1,
		ptr: t$1
	});
	return r$1 && d$1[1] > -1 && (u$1 = o(e$1, t$1 + d$1[1]), u$1 += +(e$1[u$1] === `,`)), [_(d$1[0], e$1, t$1, a$1), u$1];
}
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
*    may be used to endorse or promote products derived from this software without
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
let b = /^[a-zA-Z0-9-_]+[ \t]*$/;
function x(e$1, t$1, r$1 = `=`) {
	let a$1 = t$1 - 1, s$1 = [], l$1 = e$1.indexOf(r$1, t$1);
	if (l$1 < 0) throw new n(`incomplete key-value: cannot find end of key`, {
		toml: e$1,
		ptr: t$1
	});
	do {
		let o$1 = e$1[t$1 = ++a$1];
		if (o$1 !== ` ` && o$1 !== `	`) if (o$1 === `"` || o$1 === `'`) {
			if (o$1 === e$1[t$1 + 1] && o$1 === e$1[t$1 + 2]) throw new n(`multiline strings are not allowed in keys`, {
				toml: e$1,
				ptr: t$1
			});
			let u$1 = c(e$1, t$1);
			if (u$1 < 0) throw new n(`unfinished string encountered`, {
				toml: e$1,
				ptr: t$1
			});
			a$1 = e$1.indexOf(`.`, u$1);
			let d$1 = e$1.slice(u$1, a$1 < 0 || a$1 > l$1 ? l$1 : a$1), f$1 = i(d$1);
			if (f$1 > -1) throw new n(`newlines are not allowed in keys`, {
				toml: e$1,
				ptr: t$1 + a$1 + f$1
			});
			if (d$1.trimStart()) throw new n(`found extra tokens after the string part`, {
				toml: e$1,
				ptr: u$1
			});
			if (l$1 < u$1 && (l$1 = e$1.indexOf(r$1, u$1), l$1 < 0)) throw new n(`incomplete key-value: cannot find end of key`, {
				toml: e$1,
				ptr: t$1
			});
			s$1.push(g(e$1, t$1, u$1));
		} else {
			a$1 = e$1.indexOf(`.`, t$1);
			let r$2 = e$1.slice(t$1, a$1 < 0 || a$1 > l$1 ? l$1 : a$1);
			if (!b.test(r$2)) throw new n(`only letter, numbers, dashes and underscores are allowed in keys`, {
				toml: e$1,
				ptr: t$1
			});
			s$1.push(r$2.trimEnd());
		}
	} while (a$1 + 1 && a$1 < l$1);
	return [s$1, o(e$1, l$1 + 1, !0, !0)];
}
function S(e$1, t$1, r$1, i$1) {
	let o$1 = {}, s$1 = /* @__PURE__ */ new Set(), c$1;
	for (t$1++; (c$1 = e$1[t$1++]) !== `}` && c$1;) if (c$1 === `,`) throw new n(`expected value, found comma`, {
		toml: e$1,
		ptr: t$1 - 1
	});
	else if (c$1 === `#`) t$1 = a(e$1, t$1);
	else if (c$1 !== ` ` && c$1 !== `	` && c$1 !== `
` && c$1 !== `\r`) {
		let a$1, c$2 = o$1, l$1 = !1, [u$1, d$1] = x(e$1, t$1 - 1);
		for (let r$2 = 0; r$2 < u$1.length; r$2++) {
			if (r$2 && (c$2 = l$1 ? c$2[a$1] : c$2[a$1] = {}), a$1 = u$1[r$2], (l$1 = Object.hasOwn(c$2, a$1)) && (typeof c$2[a$1] != `object` || s$1.has(c$2[a$1]))) throw new n(`trying to redefine an already defined value`, {
				toml: e$1,
				ptr: t$1
			});
			!l$1 && a$1 === `__proto__` && Object.defineProperty(c$2, a$1, {
				enumerable: !0,
				configurable: !0,
				writable: !0
			});
		}
		if (l$1) throw new n(`trying to redefine an already defined value`, {
			toml: e$1,
			ptr: t$1
		});
		let [f$1, p$1] = y(e$1, d$1, `}`, r$1 - 1, i$1);
		s$1.add(f$1), c$2[a$1] = f$1, t$1 = p$1;
	}
	if (!c$1) throw new n(`unfinished table encountered`, {
		toml: e$1,
		ptr: t$1
	});
	return [o$1, t$1];
}
function C(e$1, t$1, r$1, i$1) {
	let o$1 = [], s$1;
	for (t$1++; (s$1 = e$1[t$1++]) !== `]` && s$1;) if (s$1 === `,`) throw new n(`expected value, found comma`, {
		toml: e$1,
		ptr: t$1 - 1
	});
	else if (s$1 === `#`) t$1 = a(e$1, t$1);
	else if (s$1 !== ` ` && s$1 !== `	` && s$1 !== `
` && s$1 !== `\r`) {
		let n$1 = y(e$1, t$1 - 1, `]`, r$1 - 1, i$1);
		o$1.push(n$1[0]), t$1 = n$1[1];
	}
	if (!s$1) throw new n(`unfinished array encountered`, {
		toml: e$1,
		ptr: t$1
	});
	return [o$1, t$1];
}
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
*    list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
*    may be used to endorse or promote products derived from this software without
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function w(e$1, t$1, n$1, r$1) {
	let i$1 = t$1, a$1 = n$1, o$1, s$1 = !1, c$1;
	for (let t$2 = 0; t$2 < e$1.length; t$2++) {
		if (t$2) {
			if (i$1 = s$1 ? i$1[o$1] : i$1[o$1] = {}, a$1 = (c$1 = a$1[o$1]).c, r$1 === 0 && (c$1.t === 1 || c$1.t === 2)) return null;
			if (c$1.t === 2) {
				let e$2 = i$1.length - 1;
				i$1 = i$1[e$2], a$1 = a$1[e$2].c;
			}
		}
		if (o$1 = e$1[t$2], (s$1 = Object.hasOwn(i$1, o$1)) && a$1[o$1]?.t === 0 && a$1[o$1]?.d) return null;
		s$1 || (o$1 === `__proto__` && (Object.defineProperty(i$1, o$1, {
			enumerable: !0,
			configurable: !0,
			writable: !0
		}), Object.defineProperty(a$1, o$1, {
			enumerable: !0,
			configurable: !0,
			writable: !0
		})), a$1[o$1] = {
			t: t$2 < e$1.length - 1 && r$1 === 2 ? 3 : r$1,
			d: !1,
			i: 0,
			c: {}
		});
	}
	if (c$1 = a$1[o$1], c$1.t !== r$1 && !(r$1 === 1 && c$1.t === 3) || (r$1 === 2 && (c$1.d || (c$1.d = !0, i$1[o$1] = []), i$1[o$1].push(i$1 = {}), c$1.c[c$1.i++] = c$1 = {
		t: 1,
		d: !1,
		i: 0,
		c: {}
	}), c$1.d)) return null;
	if (c$1.d = !0, r$1 === 1) i$1 = s$1 ? i$1[o$1] : i$1[o$1] = {};
	else if (r$1 === 0 && s$1) return null;
	return [
		o$1,
		i$1,
		c$1.c
	];
}
function T(e$1, { maxDepth: t$1 = 1e3, integersAsBigInt: r$1 } = {}) {
	let i$1 = {}, a$1 = {}, s$1 = i$1, c$1 = a$1;
	for (let l$1 = o(e$1, 0); l$1 < e$1.length;) {
		if (e$1[l$1] === `[`) {
			let t$2 = e$1[++l$1] === `[`, r$2 = x(e$1, l$1 += +t$2, `]`);
			if (t$2) {
				if (e$1[r$2[1] - 1] !== `]`) throw new n(`expected end of table declaration`, {
					toml: e$1,
					ptr: r$2[1] - 1
				});
				r$2[1]++;
			}
			let o$1 = w(r$2[0], i$1, a$1, t$2 ? 2 : 1);
			if (!o$1) throw new n(`trying to redefine an already defined table or value`, {
				toml: e$1,
				ptr: l$1
			});
			c$1 = o$1[2], s$1 = o$1[1], l$1 = r$2[1];
		} else {
			let i$2 = x(e$1, l$1), a$2 = w(i$2[0], s$1, c$1, 0);
			if (!a$2) throw new n(`trying to redefine an already defined table or value`, {
				toml: e$1,
				ptr: l$1
			});
			let o$1 = y(e$1, i$2[1], void 0, t$1, r$1);
			a$2[1][a$2[0]] = o$1[0], l$1 = o$1[1];
		}
		if (l$1 = o(e$1, l$1, !0), e$1[l$1] && e$1[l$1] !== `
` && e$1[l$1] !== `\r`) throw new n(`each key-value declaration must be followed by an end-of-line`, {
			toml: e$1,
			ptr: l$1
		});
		l$1 = o(e$1, l$1);
	}
	return i$1;
}

//#endregion
exports.T = T;