@solarpunkltd/comment-system
Version:
A library for writing and reading comments from the Swarm network.
1,432 lines • 114 kB
JavaScript
import { FeedIndex as q, Bee as H, PrivateKey as Dc, Topic as At, Bytes as Ot } from "@ethersphere/bee-js";
function Nc(s) {
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
}
var pr = {}, Jn;
function jc() {
return Jn || (Jn = 1, (function(s) {
var l;
Object.defineProperty(s, "__esModule", { value: !0 }), s.Vector = s.Cache = s.Assertions = s.Strings = s.Types = s.Objects = s.Dates = s.Promises = s.Numbers = s.System = s.Arrays = s.Random = s.Elliptic = s.Binary = s.Lock = s.Solver = s.RollingValueProvider = s.TrieRouter = s.AsyncQueue = s.PubSubChannel = s.FixedPointNumber = s.MerkleTree = s.Chunk = s.Uint8ArrayWriter = s.Uint8ArrayReader = s.AsyncLazy = s.Lazy = s.Optional = void 0;
async function d(t) {
return new Promise((e, r) => t.then(r, e));
}
async function h(t) {
return d(Promise.all(t.map(d)));
}
async function w(t, e = 1) {
const r = wn(t, e), n = [], i = r.map(async (o) => {
for (const a of o) n.push(await a());
});
return await Promise.all(i), n;
}
async function g(t) {
return new Promise(
(e) => setTimeout(() => {
e(!0);
}, t)
);
}
function p(t, e = Math.random) {
for (let r = t.length - 1; r > 0; r--) {
const n = Math.floor(e() * (r + 1)), i = t[r];
t[r] = t[n], t[n] = i;
}
return t;
}
function y(t) {
if (t.length === 1) return t[0];
throw Error(`Expected exactly one element, actual: ${t.length}`);
}
function m(t) {
return t.length === 1 ? t[0] : null;
}
function x(t) {
return t.length > 0 ? t[0] : null;
}
function C(t) {
if (!t.length) throw Error("Received empty array");
return t[0];
}
function B(t, e) {
const r = [];
for (let n = 0; n < t; n++) r.push(e(n));
return r;
}
function D(t) {
const e = [];
for (let r = 0; r < t[0].length; r++) {
e.push([]);
for (let n = 0; n < t.length; n++) e[r].push(t[n][r]);
}
return e;
}
function F(t, e, r) {
const n = [];
for (let i = 0; i < t; i++) {
n.push([]);
for (let o = 0; o < e; o++) n[i].push(r);
}
return n;
}
function v(t, e, r, n) {
if (r < 0 || n < 0 || n + e[0].length > t[0].length || r + e.length > t.length) return !1;
for (let i = 0; i < e.length; i++) for (let o = 0; o < e[i].length; o++) if (e[i][o] !== void 0 && t[r + i][n + o] !== e[i][o]) return !1;
return !0;
}
function A(t, e, r = Math.random) {
return p(Pr(0, t.length - 1), r).slice(0, e);
}
function K(t, e) {
return t.map((r) => r[e]);
}
function Kt(t) {
let e = t, r = 3405648695, n = 3735928559;
return function() {
return e += r, r ^= e << 7, e *= n, n ^= e << 13, e ^= r ^ n, (e >>> 0) / 4294967296;
};
}
function Jt(t, e, r = Math.random) {
return Math.floor(r() * (e - t + 1)) + t;
}
function ei(t, e, r = Math.random) {
return r() * (e - t) + t;
}
function ri() {
return Math.random() * 2 - 1;
}
function ni(t, e, r) {
return e >= t.x && e < t.x + t.width && r >= t.y && r < t.y + t.height;
}
function ii(t, e, r, n = Math.random) {
let i, o;
do
i = Jt(0, t - 1, n), o = Jt(0, e - 1, n);
while (r && ni(r, i, o));
return [i, o];
}
function oi(t, e = Math.random) {
const r = Math.floor(t), n = t - r;
return Sr(n, e) ? r + 1 : r;
}
function Sr(t, e = Math.random) {
return e() < t;
}
function Zt(t, e = Math.random) {
return t[Math.floor(t.length * e())];
}
function si(t, e, r = Math.random) {
if (e > t.length) throw new Error(`Count (${e}) is greater than array length (${t.length})`);
return A(t, e, r).map((n) => t[n]);
}
function ai(t, e, r, n = Math.random) {
if (e > t.length) throw new Error(`Count (${e}) is greater than array length (${t.length})`);
const i = [];
for (; i.length < e; ) {
const o = Zt(t, n);
i.some((a) => r(a, o)) || i.push(o);
}
return i;
}
function ui(t, e, r, n, i, o = Math.random) {
const a = t.filter((u) => u !== e && u !== r), c = [];
for (e !== null && c.push(e); a.length && c.length < n; ) {
const u = s.Random.intBetween(0, a.length - 1, o);
i(a[u], c) && c.push(a[u]), a.splice(u, 1);
}
return p(c, o), { values: c, indexOfGuaranteed: e !== null ? c.indexOf(e) : -1 };
}
function st(t) {
if (!t.length) throw Error("Received empty array");
return t[t.length - 1];
}
function vr(t, e, r) {
return r(e.reduce((n, i) => i(n), t));
}
function ci(t, e) {
return (r) => vr(r, t, e);
}
function li(t, e, r) {
if (r === void 0 && (r = Math.random()), t.length !== e.length) throw new Error("Array length mismatch");
let n = e.reduce((o, a) => o + a, 0);
const i = r * n;
for (let o = 0; o < t.length - 1; o++) if (n -= e[o], i >= n) return t[o];
return st(t);
}
function fi(t, e, r = Math.random) {
const n = e.map((o) => r() * o), i = [];
for (let o = 0; o < t.length; o++) i.push([t[o], n[o]]);
return i.sort((o, a) => a[1] - o[1]).map((o) => o[0]);
}
function J(t, e) {
if (t == null) return null;
const r = e.split(".");
let n = t;
for (const i of r) {
if (n[i] === null || n[i] === void 0) return null;
n = n[i];
}
return n;
}
function Z(t, e, r) {
const n = e.split(/\.|\[/);
let i = t;
for (let o = 0; o < n.length; o++) {
const a = n[o], c = o < n.length - 1 && n[o + 1].includes("]"), u = a.includes("]") ? a.replace(/\[|\]/g, "") : a;
if (o === n.length - 1) return i[u] = r, r;
P(i[u]) || (c ? i[u] = [] : i[u] = {}), i = i[u];
}
return r;
}
function hi(t, e, r = 1) {
const n = J(t, e) || 0;
return Z(t, e, n + r), n;
}
function di(t, e, r) {
return J(t, e) || Z(t, e, r);
}
function gi(t, e) {
const r = ee(e, "."), n = Rr(e, ".");
if (!r || !n) return;
const i = J(t, r);
i && delete i[n];
}
function mi(t, e, r) {
const n = J(t, e);
if (!n) throw new Error("Key '" + e + "' does not exist.");
return Z(t, e, r), n;
}
function pi(t, e, r) {
for (const n of e) {
const i = J(t, n);
if (i) return i;
}
if (r) {
const n = Object.values(t);
if (n.length) return n[0];
}
return null;
}
async function yi(t, e, r) {
for (; ; ) {
try {
await t();
} catch (n) {
r && r("Error in forever", n);
}
await g(e);
}
}
function wi(t, e) {
t();
const r = setInterval(() => {
t();
}, e);
return () => clearInterval(r);
}
function bi() {
const t = globalThis.process;
return t ? t.browser === !0 ? "browser" : "node" : "browser";
}
async function xi(t, e, r, n, i, o) {
let a = null;
for (let c = 0; c <= e; c++)
try {
return await t();
} catch (u) {
if (a = u, c === e) break;
const f = r + (n - r) * (c / (e - 1));
i && i("Error in withRetries, retrying", { attempt: c + 1, allowedFailures: e, delayMillis: f, error: u }), o && o(), await g(f);
}
throw a;
}
function Ei(t) {
return t / 1024 / 1024;
}
function Si(t, e = 1024) {
return t >= e * e * e * e ? (t / e / e / e / e).toFixed(3) + " TB" : t >= e * e * e ? (t / e / e / e).toFixed(3) + " GB" : t >= e * e ? (t / e / e).toFixed(3) + " MB" : t >= e ? (t / e).toFixed(3) + " KB" : t + " B";
}
function vi(t) {
const e = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t.toLowerCase());
if (!e) throw new Error("Invalid hex color: " + t);
return [parseInt(e[1], 16), parseInt(e[2], 16), parseInt(e[3], 16)];
}
function Ai(t) {
return "#" + t.map((e) => e.toString(16).padStart(2, "0")).join("");
}
function $i(t, e, r, n) {
const i = t * Math.PI / 180, o = r * Math.PI / 180, a = (r - t) * Math.PI / 180, c = (n - e) * Math.PI / 180, u = Math.sin(a / 2) * Math.sin(a / 2) + Math.cos(i) * Math.cos(o) * Math.sin(c / 2) * Math.sin(c / 2);
return 6371e3 * (2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)));
}
function kt(t, e) {
return Math.round(t / e) * e;
}
function Mi(t) {
return t > 1e3 ? (t / 1e3).toFixed(0) + " km" : t >= 500 ? kt(t, 100) + " m" : t >= 100 ? kt(t, 50) + " m" : kt(t, 10) + " m";
}
function Oi(t) {
return t * (t + 1) / 2;
}
function ki(t) {
const e = t.match(/-?\d+(\.\d+)?/);
if (!e) throw Error("No float found in " + t);
return parseFloat(e[0]);
}
function Ti(t, e, r = Math.random) {
const n = t * e, i = Math.sqrt(t * e * (1 - e)), o = (r() + r() + r() + r() + r() + r() - 3) * Math.SQRT2, a = Math.round(n + i * o);
return Math.max(0, Math.min(t, a));
}
function Ii(t, e) {
if (!t.includes(".")) return t;
if (parseFloat(t) === 0) return "0";
const [r, n] = t.split("."), i = r.replace("-", ""), o = i.length;
if (o >= e) return r;
if (i !== "0") {
const u = e - o, f = n.slice(0, u);
return /[1-9]/.test(f) ? `${r}.${f.replace(/0+$/, "")}` : r;
}
const a = n.match(/^0*/)?.[0].length ?? 0, c = e + a;
return `${r}.${n.slice(0, c)}`;
}
function P(t, e = !0) {
return !t || e && !Qt(t._readableState) || e && t.constructor && (t.constructor.isBuffer || t.constructor.name == "AbortController" || t.constructor.name == "AbortSignal" || t.constructor.name == "Uint8Array" || t.constructor.name === "ArrayBuffer" || t.constructor.name === "ReadableStream") ? !1 : typeof t == "object";
}
function _(t) {
return P(t) && !Array.isArray(t);
}
function Ar(t) {
return Array.isArray(t) && t.length === 0;
}
function Ci(t) {
return _(t) && Object.keys(t).length === 0;
}
function Qt(t) {
return t === void 0;
}
function Tt(t) {
return Object.prototype.toString.call(t) === "[object Function]" || Object.prototype.toString.call(t) === "[object AsyncFunction]";
}
function T(t) {
return Object.prototype.toString.call(t) === "[object String]";
}
function R(t) {
return typeof t == "number" && isFinite(t);
}
function $r(t) {
return t === !0 || t === !1;
}
function tt(t) {
return Object.prototype.toString.call(t) === "[object Date]";
}
function It(t) {
return !T(t) || t.trim().length === 0;
}
function Xt(t) {
return R(t) && Number.isInteger(t) && t >= 1;
}
function Mr(t) {
return T(t) && t.match(/^-?\d+$/) !== null;
}
function Or(t) {
return T(t) && t.match(/^(0x)?[0-9a-f]+$/i) !== null;
}
const Ui = "!@#$%^&*()_+-=[]{}|;:<>?,./", Bi = "!@#$%^&*()_+-=[]{}|;:<>?,./".split(""), Gt = "abcdefghijklmnopqrstuvwxyz", Di = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", Ni = "1234567890", Yt = Gt + Di + Ni, kr = Yt + Ui, Tr = ["—", "\\", "東", "京", "都", "𝖆", "𝖇", "𝖈", "👾", "🙇", "💁", "🙅", "ᚠ", "ᛇ", "ᚻ", "ᛦ"], Ir = "0123456789abcdef";
function ji(t, e = Math.random) {
let r = "";
for (let n = 0; n < t; n++) r += Gt[Math.floor(e() * Gt.length)];
return r;
}
function Fi(t, e = Math.random) {
let r = "";
for (let n = 0; n < t; n++) r += Yt[Math.floor(e() * Yt.length)];
return r;
}
function Pi(t, e = Math.random) {
let r = "";
for (let n = 0; n < t; n++) r += kr[Math.floor(e() * kr.length)];
return r;
}
function Ri(t, e = Math.random) {
let r = "";
for (let n = 0; n < t; n++) r += Tr[Math.floor(e() * Tr.length)];
return r;
}
function Li(t, e) {
const r = new RegExp(`[0-9a-f]{${e}}`, "i"), n = t.match(r);
return n ? n[0] : null;
}
function zi(t, e, r = Bi) {
const n = Lr(t, r);
for (const i of n) if (e(i)) return i;
return null;
}
function Wi(t, e = Math.random) {
let r = "";
for (let n = 0; n < t; n++) r += Ir[Math.floor(e() * Ir.length)];
return r;
}
function Vi(t, e) {
if (!Mr(t)) throw new TypeError(`Expected integer string${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
const r = BigInt(t);
if (e && (e.min && r < e.min || e.max && r > e.max)) throw RangeError(`Expected integer string${e?.name ? ` for ${e.name}` : ""} in range: ${e.min ?? "-inf"}..${e.max ?? "inf"}; got: ` + r);
return t;
}
function Cr(t, e) {
if (It(t)) throw new TypeError(`Expected string${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
if (e && (e.min !== void 0 && t.length < e.min || e.max !== void 0 && t.length > e.max)) throw RangeError(`Expected string${e?.name ? ` for ${e.name}` : ""} length in range: ${e.min ?? "-inf"}..${e.max ?? "inf"}; got: ${t.length}`);
return t;
}
function qi(t, e) {
if (!Or(t)) throw new TypeError(`Expected hex string${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
if (e?.strictPrefix && !t.startsWith("0x") && !t.startsWith("0X")) throw new TypeError(`Expected hex string with 0x prefix${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
const r = t.replace(/^0x/i, "");
if (r.length % 2 !== 0 && !e?.uneven) throw RangeError(`Expected even number of hex digits${e?.name ? ` for ${e.name}` : ""}; got: ` + t);
if (e && e.byteLength && r.length !== e.byteLength * 2) throw RangeError(`Expected hex string${e?.name ? ` for ${e.name}` : ""} of byte length ${e.byteLength}; got: ` + r);
return `0x${r}`;
}
function Hi(t, e) {
if (!Cr(t, e).split("").every((r) => r === "_" || lt(r)))
throw new TypeError(`Expected safe string${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return t;
}
function Ur(t, e) {
if (e.min !== void 0 && t < e.min || e.max !== void 0 && t > e.max) throw RangeError(`Expected value${e?.name ? ` for ${e.name}` : ""} in range: ${e.min ?? "-inf"}..${e.max ?? "inf"}; got: ${t}`);
}
function Ki(t, e) {
if (!Tt(t)) throw new TypeError(`Expected function${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return t;
}
function at(t, e) {
if (R(t)) return e && Ur(t, e), t;
if (!T(t) || !t.match(/^-?\d+(\.\d+)?$/)) throw new TypeError(`Expected number${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
const r = parseFloat(t);
return e && Ur(r, e), r;
}
function Ct(t, e) {
return Math.trunc(at(t, e));
}
function Ji(t, e) {
if (t === "true") return !0;
if (t === "false") return !1;
if (!$r(t)) throw new TypeError(`Expected boolean${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return t;
}
function Zi(t, e) {
if (!tt(t)) throw new TypeError(`Expected date${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return t;
}
function Qi(t) {
return It(t) ? null : t;
}
function Xi(t, e) {
if (!T(t)) throw new TypeError(`Expected string${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return t;
}
function Gi(t, e) {
if (Xt(t)) return t;
const r = parseInt(t, 10);
if (!Xt(r)) throw new TypeError(`Expected id${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return r;
}
function Yi(t, e) {
if (!T(t)) throw new TypeError(`Expected time${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
const r = t.split(":");
if (r.length !== 2) throw new TypeError(`Expected time${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
const n = parseInt(r[0], 10), i = parseInt(r[1], 10);
if (!R(n) || !R(i) || n < 0 || n > 23 || i < 0 || i > 59) throw new TypeError(`Expected time, got${e?.name ? ` for ${e.name}` : ""}: ` + t);
return `${String(n).padStart(2, "0")}:${String(i).padStart(2, "0")}`;
}
function _i(t, e) {
if (!Array.isArray(t)) throw new TypeError(`Expected array${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return t;
}
function Ut(t, e) {
if (!_(t)) throw new TypeError(`Expected object${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return t;
}
function to(t, e) {
return t === null ? null : Ut(t, e);
}
function eo(t, e) {
const r = Ut(t, e);
for (const n of Object.keys(r)) if (!T(r[n])) throw new TypeError(`Expected string map${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return r;
}
function ro(t, e) {
const r = Ut(t), n = Object.keys(r), i = Object.values(r);
if (!n.every(T) || !i.every(R)) throw new TypeError(`Expected numeric dictionary${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return r;
}
function Br(t) {
return T(t) && t.match(/^https?:\/\/.+/) !== null;
}
function no(t, e) {
if (!Br(t)) throw new TypeError(`Expected url${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
return t;
}
function Dr(t) {
return typeof t == "bigint";
}
function Nr(t, e) {
if (!Dr(t)) throw new TypeError(`Expected bigint${e?.name ? ` for ${e.name}` : ""}, got: ` + t);
if (e?.min !== void 0 && t < e?.min || e?.max !== void 0 && t > e?.max) throw RangeError(`Expected value${e?.name ? ` for ${e.name}` : ""} in range: ${e.min ?? "-inf"}..${e.max ?? "inf"}; got: ${t}`);
return t;
}
function io(t, e) {
return e == null ? !0 : t(e);
}
function oo(t, e) {
return e == null ? null : t(e);
}
function so(t, e) {
return e === "" ? void 0 : t(e);
}
function ao(t, e) {
return e == null ? void 0 : t(e);
}
function jr(t, e) {
for (const [r, n] of Object.entries(e)) if (!n(t[r])) throw TypeError(`${r} in value does not exist or match shape`);
for (const r of Object.keys(t)) if (!e[r]) throw TypeError(`${r} exists in value but not in shape`);
return !0;
}
function uo(t, e) {
return t.every((r) => jr(r, e));
}
function ut(t, e = "json", r = 0) {
if (t && Tt(t.represent)) {
const n = t.represent();
if (T(n)) return e === "json" && r === 0 ? JSON.stringify(n) : n;
}
if (P(t, !1)) {
if (r > 1) return "[object Object]";
if (e === "json") {
if (Array.isArray(t)) {
const i = t.map((o) => ut(o, "json", r + 1));
return r === 0 ? JSON.stringify(i) : i;
}
const n = {};
t.message && (n.message = ut(t.message, "json", r + 1));
for (const [i, o] of Object.entries(t)) n[i] = ut(o, "json", r + 1);
return r === 0 ? JSON.stringify(n) : n;
} else if (e === "key-value") {
const n = Object.keys(t);
return t.message && !n.includes("message") && n.unshift("message"), n.map((i) => `${i}=${JSON.stringify(ut(t[i], "json", r + 1))}`).join(" ");
}
}
return Qt(t) && (t = "undefined"), r === 0 ? JSON.stringify(t) : t;
}
function co(t, e) {
if (T(t)) return t;
const r = Object.keys(t);
t.message && !r.includes("message") && r.push("message");
const n = r.map((i) => `${i}: ${t[i]}`).join("; ");
return e && t.stack ? n + `
` + t.stack : n;
}
function Q(t, e) {
if (_(t) && _(e)) for (const r in e) _(e[r]) ? (t[r] || (t[r] = {}), Q(t[r], e[r])) : Array.isArray(e[r]) ? t[r] = [...e[r]] : (e[r] !== null && e[r] !== void 0 || t[r] === null || t[r] === void 0) && (t[r] = e[r]);
return t;
}
function lo(t, e) {
const r = {};
return Q(r, t), Q(r, e), r;
}
function fo(t, e, r) {
const n = {};
return Q(n, t), Q(n, e), Q(n, r), n;
}
function Fr(t, e) {
const r = {};
for (const n of t) for (const i of Object.keys(n)) r[i] ? r[i] = e(r[i], n[i]) : r[i] = n[i];
return r;
}
function ho(t) {
return Fr(t, (e, r) => e + r);
}
function go(t, e, r) {
t[e] || (t[e] = []), t[e].push(r);
}
function mo(t, e, r) {
for (t.unshift(e); t.length > r; ) t.pop();
}
function po(t, e) {
let r = e % t.length;
return r < 0 && (r += t.length), t[r];
}
function Bt(t, e) {
Array.prototype.push.apply(t, e);
}
function yo(t, e) {
Array.prototype.unshift.apply(t, e);
}
async function wo(t, e) {
const r = [];
for (const n of t) r.push(await e(n));
return r;
}
function bo(t, e) {
const r = [];
for (let n = 0; n < t.length; n++) r.push(t[n]), n < t.length - 1 && (Tt(e) ? r.push(e()) : r.push(e));
return r;
}
function xo(t, e) {
if (t !== e) throw Error(`Expected [${t}] to equal [${e}]`);
return [t, e];
}
function Eo(t) {
if (t !== !0) throw Error(`Expected [true], got: [${t}]`);
return t;
}
function So(t) {
if (!t) throw Error(`Expected truthy value, got: [${t}]`);
return t;
}
function vo(t) {
if (t !== !1) throw Error(`Expected [false], got: [${t}]`);
return t;
}
function Ao(t) {
if (t) throw Error(`Expected falsy value, got: [${t}]`);
return t;
}
function $o(t, e) {
if (!e.includes(t)) throw Error(`Expected any of [${e.join(", ")}], got: [${t}]`);
return t;
}
function Mo(t, e) {
for (let r = 0; r < t.length; r++) {
const n = t[r], i = e[r], o = Math.max(0, i.getTime() - Date.now());
setTimeout(n, o);
}
}
function Oo(t, e, r) {
return t + (e - t) * r;
}
function ko(t) {
return t.reduce((e, r) => e + r, 0);
}
function To(t) {
return t.reduce((e, r) => e + r, 0) / t.length;
}
function Io(t) {
const e = [...t].sort((n, i) => n - i), r = Math.floor(e.length / 2);
return e.length % 2 === 0 ? (e[r] + e[r - 1]) / 2 : e[r];
}
function Co(t, e) {
return t - (e - 1) / 2;
}
function Pr(t, e) {
const r = [];
for (let n = t; n <= e; n++) r.push(n);
return r;
}
function Uo(t, e) {
return e.some((r) => t.includes(r));
}
function Bo(t) {
return /^[\u4E00-\u9FA5]+$/.test(t);
}
function _t(t, e = () => !1) {
return t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").split("").map((r) => /[a-z0-9]/.test(r) || e(r) ? r : "-").join("").replace(/-+/g, "-").replace(/^-|-$/g, "");
}
function Do(t) {
return _t(t).replaceAll("-", "");
}
function No(t) {
return jt(t.replace(/([A-Z])/g, " $1"));
}
function jo(t) {
return t.split("-").map(jt).join(" ");
}
function Fo(t) {
return Wr(t.split("-").map(jt).join(""));
}
function Po(t, e = ", ", r = " and ") {
return !t || !t.length ? "" : t.length === 1 ? t[0] : t.length === 2 ? `${t[0]}${r}${t[1]}` : `${t.slice(0, t.length - 1).join(e)}${r}${t[t.length - 1]}`;
}
function Ro(t, e) {
return e + t.split("").join(e) + e;
}
function Lo(t) {
return _t(t).replace(/-/g, "_").toUpperCase();
}
function Dt(t, e) {
if (e.length === 0) return 0;
const r = t.toLowerCase(), n = e.toLowerCase();
return t === e ? 1e4 : r.startsWith(n) ? 1e4 - t.length : r.includes(n) ? 5e3 - t.length : new RegExp(".*" + n.split("").join(".*") + ".*").test(r) ? 1e3 - t.length : 0;
}
function zo(t, e) {
return t.filter((r) => Dt(r, e)).sort((r, n) => Dt(n, e) - Dt(r, e));
}
function Wo(t) {
return t.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
}
const Vo = { "&": "&", """: '"', "'": "'", ">": ">", "<": "<" };
function qo(t) {
let e = t.replace(/&#(\d+);/g, (r, n) => String.fromCharCode(n)).replace(/&#x(\d+);/g, (r, n) => String.fromCharCode(parseInt(n, 16)));
for (const [r, n] of Object.entries(Vo)) e = e.replaceAll(r, n);
return e;
}
function te(t, e) {
const r = t.indexOf(e);
return r === -1 ? null : t.slice(0, r);
}
function Nt(t, e) {
const r = t.indexOf(e);
return r === -1 ? null : t.slice(r + e.length);
}
function ee(t, e) {
const r = t.lastIndexOf(e);
return r === -1 ? null : t.slice(0, r);
}
function Rr(t, e) {
const r = t.lastIndexOf(e);
return r === -1 ? null : t.slice(r + e.length);
}
function Ho(t, e, r) {
const n = ee(t, r);
return n ? Nt(n, e) : null;
}
function Ko(t, e, r) {
const n = Nt(t, e);
return n ? te(n, r) : null;
}
function re(t, e, r = !1) {
const n = r ? t.lastIndexOf(e) : t.indexOf(e);
return n === -1 ? r ? [null, t] : [t, null] : [t.slice(0, n), t.slice(n + e.length)];
}
function Lr(t, e) {
let r = [t];
for (const n of e) r = r.flatMap((i) => i.split(n));
return r.filter((n) => n);
}
function ne(t) {
const e = st(t.split(/\\|\//g)), r = e.lastIndexOf(".", e.length - 1);
return r <= 0 ? "" : e.slice(r + 1);
}
function ie(t) {
const e = st(t.split(/\\|\//g)), r = e.lastIndexOf(".", e.length - 1);
return r <= 0 ? e : e.slice(0, r);
}
function Jo(t) {
let [e, r] = t.split("@");
e = ct(e.replaceAll(".", "").toLowerCase()).replaceAll(" ", "");
const [n] = e.split("+");
if (!n || !r || r.indexOf(".") === -1 || r.indexOf(".") === r.length - 1) throw new Error("Invalid email");
return r = ct(r.toLowerCase()).replaceAll(" ", ""), `${n}@${r}`;
}
function Zo(t) {
const e = ie(t), r = ne(t);
return r ? `${e}.${r}` : e;
}
function Qo(t) {
const e = ie(t), r = ne(t);
return { basename: e, extension: r, filename: r ? `${e}.${r}` : e };
}
function Xo(t, e = Math.random) {
return t.replace(/\{(.+?)\}/g, (r, n) => Zt(n.split("|"), e));
}
function zr(t) {
const e = /\{(.+?)\}/, r = t.match(e);
if (!r || !r.index) return [t];
const n = r[1].split(","), i = t.slice(0, r.index), o = t.slice(r.index + r[0].length);
let a = [];
for (const c of n) {
const u = zr(i + c + o);
a = a.concat(u);
}
return a;
}
function ct(t) {
return t.split(
`
`
).map((e) => e.trim().replace(/\s+/g, " ")).filter((e) => e.length > 0).join(`
`);
}
function jt(t) {
return t.charAt(0).toUpperCase() + t.slice(1);
}
function Wr(t) {
return t.charAt(0).toLowerCase() + t.slice(1);
}
function Vr(t) {
if (!t) return !1;
const e = t.charCodeAt(0);
return e >= 65 && e <= 90 || e >= 97 && e <= 122;
}
function qr(t) {
if (!t) return !1;
const e = t.charCodeAt(0);
return e >= 48 && e <= 57;
}
function lt(t) {
return Vr(t) || qr(t);
}
const Go = `
\r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");
function Yo(t) {
return Go.includes(t);
}
function _o(t) {
return lt(t) || t === "." || t === "[" || t === "]" || t === "_";
}
function ts(t, e, r, n, i) {
return t.slice(0, e) + n + t.slice(e, e + r) + i + t.slice(e + r);
}
function Hr(t, e, r = 0) {
const n = e.exec(t.slice(r));
return n ? { index: n.index, match: n[0] } : null;
}
function Kr(t, e, r = !0) {
if (!r) return e.every((i) => i instanceof RegExp ? i.test(t) : t.indexOf(i, 0) !== -1);
let n = 0;
for (const i of e)
if (i instanceof RegExp) {
const o = Hr(t, i, n);
if (!o) return !1;
n = o.index + o.match.length;
} else {
const o = t.indexOf(i, n);
if (o === -1) return !1;
n = o + i.length;
}
return !0;
}
function es(t, e, r = !0) {
let n = 0;
for (const i of e) {
let o = !1;
for (; !o && n < t.length; ) Kr(t[n], i, r) && (o = !0), n++;
if (!o) return !1;
}
return !0;
}
function rs(t) {
return t.match(/"|,/) ? `"${t.replace(/"/g, '""')}"` : t;
}
function Jr(t, e, r = 0) {
const n = [];
let i = t.indexOf(e, r);
for (; i !== -1; ) n.push(i), i = t.indexOf(e, i + e.length);
return n;
}
function et(t, e, r = 0) {
let n = -1;
for (const i of e) {
const o = t.indexOf(i, r);
o !== -1 && (n === -1 || o < n) && (n = o);
}
return n;
}
function ns(t, e = 0) {
for (let r = e; r < t.length; r++) if (Yo(t[r])) return r;
return -1;
}
function is(t, e = 0) {
for (let r = e; r < t.length; r++) if (t[r] === "#" && lt(t[r + 1])) return r;
return -1;
}
function Zr(t, e, r = 0) {
return t.slice(0, r).lastIndexOf(e);
}
function Qr(t, e = 0, r = "{", n = "}") {
let i = 1;
for (let o = e; o < t.length; o++)
if (t.slice(o, o + n.length) === n) {
if (--i === 0) return o;
} else t.slice(o, o + r.length) === r && i++;
return -1;
}
function Xr(t, e) {
const r = e.wordBoundary ? et(
t,
[
`${e.opening} `,
`${e.opening}
`
],
e.start || 0
) : t.indexOf(e.opening, e.start || 0);
if (r === -1) return null;
const n = Qr(t, r + e.opening.length, e.opening, e.closing);
return n === -1 ? null : e.exclusive ? t.slice(r + e.opening.length, n) : t.slice(r, n + e.closing.length);
}
function os(t, e) {
const r = [];
let n = e.wordBoundary ? et(
t,
[
`${e.opening} `,
`${e.opening}
`
],
e.start || 0
) : t.indexOf(e.opening, e.start || 0);
for (; ; ) {
if (n === -1) return r;
const i = Xr(t, { ...e, start: n });
if (!i) return r;
r.push(i), n = e.wordBoundary ? et(
t,
[
`${e.opening} `,
`${e.opening}
`
],
n + i.length
) : t.indexOf(e.opening, n + i.length);
}
}
function ss(t, e, r) {
let n = 0;
for (; ; ) {
const i = s.Strings.extractBlock(t, { ...r, start: n });
if (!i) return t;
const o = e(i);
n = t.indexOf(i, n) + o.length, t = t.replace(i, o);
}
}
function as(t, e) {
const r = [];
let n = 0;
for (; n < t.length; ) {
const i = t.indexOf(e, n);
if (i === -1) {
r.push({ string: t.slice(n), symbol: null });
break;
}
const o = t.indexOf(e, i + e.length);
if (i > n && o !== -1 && r.push({ string: t.slice(n, i), symbol: null }), o === -1) {
r.push({ string: t.slice(n), symbol: null });
break;
}
r.push({ string: t.slice(i + e.length, o), symbol: e }), n = o + e.length;
}
return r;
}
function us(t) {
const e = [];
let r = 0;
for (; r < t.length; ) {
const n = is(t, r);
if (n === -1) {
e.push({ string: t.slice(r), symbol: null });
break;
}
const i = ns(t, n + 1);
if (i === -1) {
e.push({ string: t.slice(r, n), symbol: null }), e.push({ string: t.slice(n + 1), symbol: "#" });
break;
}
n > r && e.push({ string: t.slice(r, n), symbol: null }), e.push({ string: t.slice(n + 1, i), symbol: "#" }), r = i;
}
return e;
}
function cs(t) {
const e = [];
let r = 0;
for (; r < t.length; ) {
const n = et(t, ["http://", "https://"], r);
if (n === -1) {
e.push({ string: t.slice(r), symbol: null });
break;
}
const i = et(
t,
[
" ",
`
`
],
n
);
if (i === -1) {
n > r && e.push({ string: t.slice(r, n), symbol: null }), e.push({ string: t.slice(n), symbol: "http" });
break;
}
n > r && e.push({ string: t.slice(r, n), symbol: null }), e.push({ string: t.slice(n, i), symbol: "http" }), r = i;
}
return e;
}
const Gr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Yr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
function ls(t) {
return _r(t, Gr);
}
function fs(t) {
return tn(t, Gr);
}
function hs(t) {
return _r(t, Yr);
}
function ds(t) {
return tn(t, Yr);
}
function _r(t, e) {
const n = e.length;
let i = 0, o = 0;
const a = [];
for (let c = 0; c < t.length; c++) {
const u = t[c];
if (u === "=") break;
const f = e.indexOf(u);
if (f === -1) throw new Error(`Invalid character: ${u}`);
o = o << Math.log2(n) | f, i += Math.log2(n), i >= 8 && (i -= 8, a.push(o >> i & 255));
}
return new Uint8Array(a);
}
function tn(t, e) {
const r = e.length;
let n = 0, i = 0, o = "";
for (let a = 0; a < t.length; a++) for (i = i << 8 | t[a], n += 8; n >= Math.log2(r); ) n -= Math.log2(r), o += e[i >> n & r - 1];
return n > 0 && (o += e[i << Math.log2(r) - n & r - 1]), o.length % 4 !== 0 && (o += "=".repeat(4 - o.length % 4)), o;
}
function gs(t) {
(t.startsWith("0x") || t.startsWith("0X")) && (t = t.slice(2));
const e = t.length / 2, r = new Uint8Array(e);
for (let n = 0; n < e; n++) {
const i = parseInt(t.slice(n * 2, n * 2 + 2), 16);
r[n] = i;
}
return r;
}
function ms(t) {
return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
}
function ps(t) {
return Array.from(t).map((e) => e.toString(2).padStart(8, "0")).join("");
}
function ys(t) {
const e = Math.ceil(t.length / 8), r = new Uint8Array(e);
for (let n = 0; n < e; n++) {
const i = parseInt(t.slice(n * 8, n * 8 + 8), 2);
r[n] = i;
}
return r;
}
function ws(t, e) {
const r = t.split("/").filter((o) => o), n = e.split("/").filter((o) => o);
if (r.length !== n.length) return null;
const i = {};
for (let o = 0; o < r.length; o++) {
const a = r[o];
if (a.startsWith(":")) i[a.slice(1)] = n[o];
else if (a !== n[o]) return null;
}
return i;
}
function oe(t, e, r) {
const n = [];
for (const i of r) i !== e && n.push(t.replace(e, i));
return n;
}
function bs(t, e, r, n = Math.random) {
const i = s.Arrays.shuffle(
e.map((a) => ({
variants: s.Arrays.shuffle(
a.variants.map((c) => c),
n
),
avoid: a.avoid
})),
n
), o = [];
for (const a of i) {
const c = a.variants.filter((f) => f !== a.avoid), u = c.find((f) => t.includes(f));
if (u && (Bt(o, oe(t, u, c)), o.length >= r)) break;
}
if (o.length < r)
for (const a of i) {
const c = a.variants.find((u) => t.includes(u));
if (c && (Bt(o, oe(t, c, a.variants)), o.length >= r)) break;
}
return o.slice(0, r);
}
function xs(t, e, r, n = !1) {
const i = new RegExp(n ? `(?<=\\s|^)${e}(?=\\s|$)` : `\\b${e}\\b`, "g");
return t.replace(i, r);
}
function Es(t, e) {
const r = /\b[A-Z][a-zA-Z0-9]*\b/g;
return t.replace(r, (n) => n.toUpperCase() === n ? n : e(n));
}
function Ss(t) {
return t.replace(/<[^>]*>/g, "");
}
function en(t) {
const e = t.lastIndexOf(" ");
if (e === -1) return { line: t, rest: "" };
const r = t.slice(0, e), n = t.slice(e + 1);
return { line: r, rest: n };
}
function vs(t, e = {}) {
return [...t].reduce((r, n) => r + (e[n] || 1), 0);
}
function As(t, e, r = {}) {
const n = [];
let i = "", o = 0;
for (let a = 0; a < t.length; a++) {
const c = t[a], u = r[c] || 1;
if (i += c, o += u, o > e) {
const { line: f, rest: $ } = en(i);
n.push(f), i = $, o = $.split("").map((I) => r[I] || 1).reduce((I, ot) => I + ot, 0);
}
}
return i && n.push(i), n;
}
function $s(t, e) {
const r = [];
for (let n = 0; n <= t.length; n++) r[n] = [n];
for (let n = 0; n <= e.length; n++) r[0][n] = n;
for (let n = 1; n <= t.length; n++)
for (let i = 1; i <= e.length; i++) {
const o = t[n - 1] === e[i - 1] ? 0 : 1;
r[n][i] = Math.min(r[n - 1][i] + 1, r[n][i - 1] + 1, r[n - 1][i - 1] + o);
}
return r[t.length][e.length];
}
function rn(t) {
const e = t.reduce((n, i) => n.length < i.length ? n : i);
let r = "";
for (let n = 0; n < e.length; n++) {
const i = e[n];
if (t.every((o) => o[n] === i)) r += i;
else break;
}
return r;
}
function Ms(t) {
const e = rn(t), r = e.lastIndexOf("/");
return r === -1 ? "" : e.slice(0, r + 1);
}
function se(t, e) {
return new RegExp(`\\b${e}\\b`).test(t);
}
function Os(t, e, r) {
return r === "any" ? e.some((n) => se(t, n)) : e.every((n) => se(t, n));
}
function ks(t) {
const e = {}, r = t.match(/([a-z\-]+)="([^"]+)"/g);
if (r)
for (const n of r) {
const [i, o] = re(n, "=");
e[i] = o.slice(1, o.length - 1);
}
return e;
}
function ft(t, e, r = []) {
let n = "";
for (; e < t.length && (lt(t[e]) || r.includes(t[e])); ) n += t[e++];
return n;
}
function Ts(t, e, r = []) {
const n = Jr(t, e), i = [];
for (const o of n) i.push(ft(t, o + e.length, r));
return i;
}
function Is(t, e, r = "$", n = ":") {
for (const i in e) t = nn(t, i, e[i], r, n);
return t = on(t), t;
}
function nn(t, e, r, n = "$", i = ":") {
if (r === "") return t;
let o = t.indexOf(`${n}${e}`);
for (; o !== -1; ) {
if (t[o + e.length + 1] === i)
if (t[o + e.length + 2] === i) t = t.replace(`${n}${e}${i}${i}`, r);
else {
const a = ft(t, o + e.length + 2, ["_"]);
t = t.replace(`${n}${e}${i}${a}`, r);
}
else t = t.replace(`${n}${e}`, r);
o = t.indexOf(`${n}${e}`, o + r.length);
}
return t;
}
function on(t, e = "$", r = ":") {
let n = t.indexOf(e);
for (; n !== -1; ) {
const i = ft(t, n + 1);
if (t[n + i.length + 1] === r)
if (t[n + i.length + 2] === r) t = t.replace(`${e}${i}${r}${r}`, "");
else {
const o = ft(t, n + i.length + 2);
t = t.replace(`${e}${i}${r}${o}`, o);
}
n = t.indexOf(e, n + 1);
}
return t;
}
function Cs(t, e) {
let r = t.indexOf("](");
for (; r !== -1; ) {
const n = Zr(t, "[", r), i = t.indexOf(")", r);
if (n !== -1 && i !== -1) {
const [o, a] = t.slice(n + 1, i).split("]("), c = e(o, a);
t = t.slice(0, n) + c + t.slice(i + 1);
}
r = t.indexOf("](", r + 1);
}
return t;
}
function sn(t, e = !0) {
const r = Object.entries(t).filter(([n, i]) => i != null).map(([n, i]) => `${n}=${encodeURIComponent(i)}`).join("&");
return r ? (e ? "?" : "") + r : "";
}
function Us(t) {
const e = {}, r = t.split("&");
for (const n of r) {
const [i, o] = n.split("=");
i && o && (e[i] = decodeURIComponent(o));
}
return e;
}
function Bs(t, e) {
return Object.prototype.hasOwnProperty.call(t, e);
}
function Ds(t, e) {
let r = null, n = -1 / 0;
for (const [i, o] of Object.entries(t)) {
const a = e(o);
a > n && (n = a, r = i);
}
return r ? [r, t[r]] : null;
}
function Ns(t, e, r, n) {
const i = t.find((a) => a[e] === r), o = t.find((a) => a[e] === r + n);
i && o ? (i[e] = r + n, o[e] = r) : i && (i[e] = r + n), t.sort((a, c) => at(a[e]) - at(c[e])), t.forEach((a, c) => a[e] = c + 1);
}
function js(t) {
const e = Object.keys(t);
if (e.length === 1) return t[e[0]];
throw new Error("Expected object to have a single key");
}
function Fs(t, e = ":") {
return Object.fromEntries(
t.map((r) => re(r, e)).map((r) => r[0] && r[1] ? [ct(r[0]), ct(r[1])] : null).filter((r) => r)
);
}
function Ps(t, e) {
if (!t) return !1;
const r = t.message;
return typeof r == "string" && r.includes(e);
}
function Rs(t, e, r) {
return ln([t, e]) + sn(r || {});
}
function Ls(t, e = ",", r = '"') {
const n = [];
let i = "", o = !1;
const a = t.split("");
for (const c of a) c === e && !o ? (n.push(i), i = "") : c === r && (!i && !o || o) ? o = !o : i += c;
return n.push(i), n;
}
function zs(t) {
return `[${Math.floor(t.progress * 100)}%] ${Ft(t.deltaMs)} out of ${Ft(t.totalTimeMs)} (${Ft(t.remainingTimeMs)} left) [${Math.round(t.baseTimeMs)} ms each]`;
}
async function Ws(t, e) {
let r = e.requiredConsecutivePasses || 1, n = 0;
for (let i = 0; i < e.attempts; i++) {
try {
if (await t()) {
if (n++, n >= r) return;
} else n = 0;
} catch {
n = 0;
}
i < e.attempts - 1 && await g(e.waitMillis);
}
throw Error("Timed out waiting for predicate");
}
function Vs(t, e) {
const r = [];
for (let n = t.length - 1; n >= 0; n--) e(t[n]) && r.push(t.splice(n, 1)[0]);
return r;
}
function qs(t) {
return JSON.parse(JSON.stringify(t));
}
function Hs(t) {
return Math.ceil((t || Date.now()) / 1e3);
}
function Ks(t) {
return (t || /* @__PURE__ */ new Date()).toISOString().slice(0, 10);
}
function Js(t) {
return (t || /* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/T|:/g, "-");
}
function Zs(t) {
const e = new Date(t);
return new Date(e.getTime() - e.getTimezoneOffset() * 6e4);
}
function Qs(t) {
return new Date(t);
}
function N(t) {
return String(Math.floor(t)).padStart(2, "0");
}
function Xs(t) {
let [e, r] = t.split(":");
R(parseInt(e, 10)) || (e = "0"), R(parseInt(r, 10)) || (r = "0");
let n = le(Ct(e), 0, 23), i = le(Ct(r), 0, 59);
return `${N(n)}:${N(i)}`;
}
function Ft(t) {
const e = Math.floor(t / 36e5);
t = t % 36e5;
const r = Math.floor(t / 6e4);
t = t % 6e4;
const n = Math.floor(t / 1e3);
return e ? `${N(e)}:${N(r)}:${N(n)}` : `${N(r)}:${N(n)}`;
}
function X(t) {
return Math.floor((tt(t) ? t.getTime() : t) / 864e5);
}
const Gs = { today: (t, e) => N(t) + ":" + N(e), yesterday: () => "Yesterday", monday: () => "Mon", tuesday: () => "Tue", wednesday: () => "Wed", thursday: () => "Thu", friday: () => "Fri", saturday: () => "Sat", sunday: () => "Sun", weeks: (t) => `${t}w` };
function Ys(t, e) {
const r = new Date(e?.now || Date.now()), n = e?.labels || Gs, i = tt(t) ? t : new Date(t);
if (X(r) === X(i)) return n.today(i.getUTCHours(), i.getUTCMinutes(), i.getUTCHours() > 12);
if (X(r) - X(i) === 1) return n.yesterday();
const o = ue(i);
return X(r) - X(i) < 7 ? n[o.day]() : n.weeks(Math.round((r.getTime() - i.getTime()) / 6048e5));
}
const an = { now: () => "A few seconds", seconds: (t) => `${t} seconds`, minutes: (t) => `${t} minutes`, hours: (t) => `${t} hours`, days: (t) => `${t} days`, weeks: (t) => `${t} weeks` };
function un(t, e) {
const r = e?.now ?? Date.now(), n = e?.labels || an, i = s.Types.isDate(t) ? t.getTime() : t;
let o = (r - i) / 1e3;
return o < 10 ? n.now() : o < 120 ? n.seconds(Math.floor(o)) : (o /= 60, o < 120 ? n.minutes(Math.floor(o)) : (o /= 60, o < 48 ? n.hours(Math.floor(o)) : (o /= 24, o < 14 ? n.days(Math.floor(o)) : (o /= 7, n.weeks(Math.floor(o))))));
}
function _s(t, e = an) {
return un(0, { now: t * 1e3, labels: e });
}
function ta(t, e, r) {
const n = (r?.now ?? Date.now()) - t, i = Math.floor(n / e), o = e / (r?.precision ?? 1) - Math.ceil(n % e / (r?.precision ?? 1));
return { cycles: i, remaining: o };
}
const ae = {};
function ea(t, e) {
return !ae[t] || Date.now() > ae[t] ? (ae[t] = Date.now() + e, !0) : !1;
}
const ra = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
function na(t, e, r) {
return e = tt(e) ? e.getTime() : e, r = r ? tt(r) ? r.getTime() : r : Date.now(), (r - e) / ra[t];
}
function ia(t, e, r, n) {
n || (n = Date.now());
const i = e / r, o = n - t, a = o / e, c = a * r, u = c - o;
return { deltaMs: o, progress: i, baseTimeMs: a, totalTimeMs: c, remainingTimeMs: u };
}
const oa = { 0: "sunday", 1: "monday", 2: "tuesday", 3: "wednesday", 4: "thursday", 5: "friday", 6: "saturday" };
function cn(t) {
return { zeroBasedIndex: t, day: oa[t] };
}
function ue(t) {
return cn(t.getDay());
}
function sa(t) {
return ue(new Date(t));
}
function aa(t) {
return t * 1e3;
}
function ua(t) {
return t * 6e4;
}
function ca(t) {
return t * 36e5;
}
function la(t) {
return t * 864e5;
}
const fa = { ms: 1, milli: 1, millis: 1, millisecond: 1, milliseconds: 1, s: 1e3, sec: 1e3, second: 1e3, seconds: 1e3, m: 6e4, min: 6e4, minute: 6e4, minutes: 6e4, h: 36e5, hour: 36e5, hours: 36e5, d: 864e5, day: 864e5, days: 864e5, w: 6048e5, week: 6048e5, weeks: 6048e5, month: 2592e6, months: 2592e6, y: 31536e6, year: 31536e6, years: 31536e6 };
function ha(t) {
const e = parseFloat(t);
if (isNaN(e)) throw Error("makeDate got NaN for input");
const r = t.replace(/^-?[0-9.]+/, "").trim().toLowerCase(), n = r === "" ? 1 : fa[r];
if (!n) throw Error(`Unknown unit: "${r}"`);
return Math.ceil(e * n);
}
const da = { b: 0, byte: 0, bytes: 0, kb: 1, kilobyte: 1, kilobytes: 1, mb: 2, megabyte: 2, megabytes: 2, gb: 3, gigabyte: 3, gigabytes: 3, tb: 4, terabyte: 4, terabytes: 4 };
function ga(t, e = 1024) {
const r = parseFloat(t);
if (isNaN(r)) throw Error("makeStorage got NaN for input");
const n = t.replace(/^-?[0-9.]+/, "").trim().toLowerCase(), i = n === "" ? 0 : da[n];
if (i == null) throw Error(`Unknown unit: "${n}"`);
return Math.ceil(r * e ** i);
}
function ma(t) {
return t.replace(/ +/g, " ").replace(/^ /gm, "");
}
const j = /* @__PURE__ */ new Map();
async function pa(t, e, r, n) {
const i = Date.now(), o = j.get(t);
if (o && o.validUntil > i) return o.value;
n?.onMiss?.();
try {
const a = await r();
return j.set(t, { value: a, validUntil: i + e }), a;
} catch (a) {
throw n?.onFailure?.(a), a;
}
}
function ya(t, e, r, n) {
const i = Date.now(), o = j.get(t);
if (o && o.validUntil > i) return o.value;
n?.onMiss?.();
const a = r();
return j.set(t, { value: a, validUntil: i + e }), a.catch((c) => {
j.delete(t), n?.onFailure?.(c);
}), a;
}
function wa(t) {
j.delete(t);
}
function ba() {
j.clear();
}
function xa() {
const t = Date.now();
for (const [e, r] of j.entries()) r.validUntil <= t && j.delete(e);
}
function Ea() {
return j.size;
}
function ln(t, e = !1) {
t = t.filter((o) => o), e && T(t[1]) && (t[1] = "../" + t[1]);
let r = "";
T(t[0]) && t[0].includes("://") && (r = te(t[0], "://") ?? "", t[0] = Nt(t[0], "://") ?? "");
const n = t.map((o) => String(o)).flatMap((o) => o.split("/")), i = [];
for (let o = 0; o < n.length; o++) n[o] !== "." && (n[o] === ".." ? (!r || i.length > 1) && i.pop() : i.push(n[o]));
return (r ? r + "://" : "") + i.join("/").replaceAll(/\/{2,}/g, "/");
}
function Sa(t, e, r, n, i = !0) {
const o = t.indexOf(e), a = t.indexOf(r, o + e.length);
if (o === -1 || a === -1) throw Error("Start or end not found");
return i ? t.substring(0, o + e.length) + n + t.substring(a) : t.substring(0, o) + n + t.substring(a + r.length);
}
function va(t) {
let e = "p";
t.startsWith("#") ? (e = "h1", t = t.slice(1).trim()) : t.startsWith("-") && (e = "li", t = t.slice(1).trim());
const r = t[0] === t[0].toUpperCase(), n = /[.?!]$/.test(t), i = /:$/.test(t);
return { type: e, isCapitalized: r, hasPunctuation: n, endsWithColon: i };
}
function Aa(t, e = "(", r = ")") {
let n = 0, i = 0;
for (; i < t.length; ) if (t.startsWith(e, i) ? (n++, i += e.length) : t.startsWith(r, i) ? (n--, i += r.length) : i++, n < 0) return !1;
return e === r ? n % 2 === 0 : n === 0;
}
function $a(t) {
t = t.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
let e = t.length;
for (; t = t.replace(/(\w+)[\s,']+\w+/g, "$1"), t.length !== e; ) e = t.length;
return t = t.replaceAll(/[A-Z][a-zA-Z0-9]*/g, "A"), t = t.replaceAll(/[a-z][a-zA-Z0-9]*/g, "a"), t = t.replaceAll(/[\u4E00-\u9FA5]+/g, "Z"), t;
}
function fn(t) {
const e = Object.keys(t).sort((n, i) => n.localeCompare(i)), r = {};
for (const n of e) r[n] = G(t[n]);
return r;
}
function hn(t) {
const e = [];
return t.sort((r, n) => JSON.stringify(G(r)).localeCompare(JSON.stringify(G(n)))).forEach((r) => e.push(G(r))), e;
}
function G(t)