UNPKG

@tricoteuses/assemblee

Version:

Retrieve, clean up & handle French Assemblée nationale's open data

1,833 lines 299 kB
var L; (function(e) { e.Root = "root", e.Text = "text", e.Directive = "directive", e.Comment = "comment", e.Script = "script", e.Style = "style", e.Tag = "tag", e.CDATA = "cdata", e.Doctype = "doctype"; })(L || (L = {})); function ka(e) { return e.type === L.Tag || e.type === L.Script || e.type === L.Style; } const gu = L.Root, Fa = L.Text, Ua = L.Directive, Ha = L.Comment, wa = L.Script, va = L.Style, bt = L.Tag, Ya = L.CDATA, qa = L.Doctype; class Nu { constructor() { this.parent = null, this.prev = null, this.next = null, this.startIndex = null, this.endIndex = null; } // Read-write aliases for properties /** * Same as {@link parent}. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias. */ get parentNode() { return this.parent; } set parentNode(t) { this.parent = t; } /** * Same as {@link prev}. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias. */ get previousSibling() { return this.prev; } set previousSibling(t) { this.prev = t; } /** * Same as {@link next}. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias. */ get nextSibling() { return this.next; } set nextSibling(t) { this.next = t; } /** * Clone this node, and optionally its children. * * @param recursive Clone child nodes as well. * @returns A clone of the node. */ cloneNode(t = !1) { return ge(this, t); } } class Ot extends Nu { /** * @param data The content of the data node */ constructor(t) { super(), this.data = t; } /** * Same as {@link data}. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias. */ get nodeValue() { return this.data; } set nodeValue(t) { this.data = t; } } class Cu extends Ot { constructor() { super(...arguments), this.type = L.Text; } get nodeType() { return 3; } } class Wa extends Ot { constructor() { super(...arguments), this.type = L.Comment; } get nodeType() { return 8; } } class Qa extends Ot { constructor(t, u) { super(u), this.name = t, this.type = L.Directive; } get nodeType() { return 1; } } class Lt extends Nu { /** * @param children Children of the node. Only certain node types can have children. */ constructor(t) { super(), this.children = t; } // Aliases /** First child of the node. */ get firstChild() { var t; return (t = this.children[0]) !== null && t !== void 0 ? t : null; } /** Last child of the node. */ get lastChild() { return this.children.length > 0 ? this.children[this.children.length - 1] : null; } /** * Same as {@link children}. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias. */ get childNodes() { return this.children; } set childNodes(t) { this.children = t; } } class Ga extends Lt { constructor() { super(...arguments), this.type = L.CDATA; } get nodeType() { return 4; } } class Dt extends Lt { constructor() { super(...arguments), this.type = L.Root; } get nodeType() { return 9; } } class Va extends Lt { /** * @param name Name of the tag, eg. `div`, `span`. * @param attribs Object mapping attribute names to attribute values. * @param children Children of the node. */ constructor(t, u, a = [], r = t === "script" ? L.Script : t === "style" ? L.Style : L.Tag) { super(a), this.name = t, this.attribs = u, this.type = r; } get nodeType() { return 1; } // DOM Level 1 aliases /** * Same as {@link name}. * [DOM spec](https://dom.spec.whatwg.org)-compatible alias. */ get tagName() { return this.name; } set tagName(t) { this.name = t; } get attributes() { return Object.keys(this.attribs).map((t) => { var u, a; return { name: t, value: this.attribs[t], namespace: (u = this["x-attribsNamespace"]) === null || u === void 0 ? void 0 : u[t], prefix: (a = this["x-attribsPrefix"]) === null || a === void 0 ? void 0 : a[t] }; }); } } function p(e) { return ka(e); } function Xe(e) { return e.type === L.CDATA; } function Z(e) { return e.type === L.Text; } function Rt(e) { return e.type === L.Comment; } function Xa(e) { return e.type === L.Directive; } function te(e) { return e.type === L.Root; } function P(e) { return Object.prototype.hasOwnProperty.call(e, "children"); } function ge(e, t = !1) { let u; if (Z(e)) u = new Cu(e.data); else if (Rt(e)) u = new Wa(e.data); else if (p(e)) { const a = t ? rt(e.children) : [], r = new Va(e.name, { ...e.attribs }, a); a.forEach((n) => n.parent = r), e.namespace != null && (r.namespace = e.namespace), e["x-attribsNamespace"] && (r["x-attribsNamespace"] = { ...e["x-attribsNamespace"] }), e["x-attribsPrefix"] && (r["x-attribsPrefix"] = { ...e["x-attribsPrefix"] }), u = r; } else if (Xe(e)) { const a = t ? rt(e.children) : [], r = new Ga(a); a.forEach((n) => n.parent = r), u = r; } else if (te(e)) { const a = t ? rt(e.children) : [], r = new Dt(a); a.forEach((n) => n.parent = r), e["x-mode"] && (r["x-mode"] = e["x-mode"]), u = r; } else if (Xa(e)) { const a = new Qa(e.name, e.data); e["x-name"] != null && (a["x-name"] = e["x-name"], a["x-publicId"] = e["x-publicId"], a["x-systemId"] = e["x-systemId"]), u = a; } else throw new Error(`Not implemented yet: ${e.type}`); return u.startIndex = e.startIndex, u.endIndex = e.endIndex, e.sourceCodeLocation != null && (u.sourceCodeLocation = e.sourceCodeLocation), u; } function rt(e) { const t = e.map((u) => ge(u, !0)); for (let u = 1; u < t.length; u++) t[u].prev = t[u - 1], t[u - 1].next = t[u]; return t; } const $t = /["&'<>$\x80-\uFFFF]/g, Ka = /* @__PURE__ */ new Map([ [34, "&quot;"], [38, "&amp;"], [39, "&apos;"], [60, "&lt;"], [62, "&gt;"] ]), ja = ( // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition String.prototype.codePointAt != null ? (e, t) => e.codePointAt(t) : ( // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae (e, t) => (e.charCodeAt(t) & 64512) === 55296 ? (e.charCodeAt(t) - 55296) * 1024 + e.charCodeAt(t + 1) - 56320 + 65536 : e.charCodeAt(t) ) ); function Iu(e) { let t = "", u = 0, a; for (; (a = $t.exec(e)) !== null; ) { const r = a.index, n = e.charCodeAt(r), c = Ka.get(n); c !== void 0 ? (t += e.substring(u, r) + c, u = r + 1) : (t += `${e.substring(u, r)}&#x${ja(e, r).toString(16)};`, u = $t.lastIndex += +((n & 64512) === 55296)); } return t + e.substr(u); } function Su(e, t) { return function(a) { let r, n = 0, c = ""; for (; r = e.exec(a); ) n !== r.index && (c += a.substring(n, r.index)), c += t.get(r[0].charCodeAt(0)), n = r.index + 1; return c + a.substring(n); }; } const $a = Su(/["&\u00A0]/g, /* @__PURE__ */ new Map([ [34, "&quot;"], [38, "&amp;"], [160, "&nbsp;"] ])), za = Su(/[&<>\u00A0]/g, /* @__PURE__ */ new Map([ [38, "&amp;"], [60, "&lt;"], [62, "&gt;"], [160, "&nbsp;"] ])), Ja = new Map([ "altGlyph", "altGlyphDef", "altGlyphItem", "animateColor", "animateMotion", "animateTransform", "clipPath", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "foreignObject", "glyphRef", "linearGradient", "radialGradient", "textPath" ].map((e) => [e.toLowerCase(), e])), Za = new Map([ "definitionURL", "attributeName", "attributeType", "baseFrequency", "baseProfile", "calcMode", "clipPathUnits", "diffuseConstant", "edgeMode", "filterUnits", "glyphRef", "gradientTransform", "gradientUnits", "kernelMatrix", "kernelUnitLength", "keyPoints", "keySplines", "keyTimes", "lengthAdjust", "limitingConeAngle", "markerHeight", "markerUnits", "markerWidth", "maskContentUnits", "maskUnits", "numOctaves", "pathLength", "patternContentUnits", "patternTransform", "patternUnits", "pointsAtX", "pointsAtY", "pointsAtZ", "preserveAlpha", "preserveAspectRatio", "primitiveUnits", "refX", "refY", "repeatCount", "repeatDur", "requiredExtensions", "requiredFeatures", "specularConstant", "specularExponent", "spreadMethod", "startOffset", "stdDeviation", "stitchTiles", "surfaceScale", "systemLanguage", "tableValues", "targetX", "targetY", "textLength", "viewBox", "viewTarget", "xChannelSelector", "yChannelSelector", "zoomAndPan" ].map((e) => [e.toLowerCase(), e])), es = /* @__PURE__ */ new Set([ "style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript" ]); function ts(e) { return e.replace(/"/g, "&quot;"); } function us(e, t) { var u; if (!e) return; const a = ((u = t.encodeEntities) !== null && u !== void 0 ? u : t.decodeEntities) === !1 ? ts : t.xmlMode || t.encodeEntities !== "utf8" ? Iu : $a; return Object.keys(e).map((r) => { var n, c; const l = (n = e[r]) !== null && n !== void 0 ? n : ""; return t.xmlMode === "foreign" && (r = (c = Za.get(r)) !== null && c !== void 0 ? c : r), !t.emptyAttrs && !t.xmlMode && l === "" ? r : `${r}="${a(l)}"`; }).join(" "); } const zt = /* @__PURE__ */ new Set([ "area", "base", "basefont", "br", "col", "command", "embed", "frame", "hr", "img", "input", "isindex", "keygen", "link", "meta", "param", "source", "track", "wbr" ]); function Pt(e, t = {}) { const u = "length" in e ? e : [e]; let a = ""; for (let r = 0; r < u.length; r++) a += as(u[r], t); return a; } function as(e, t) { switch (e.type) { case gu: return Pt(e.children, t); // @ts-expect-error We don't use `Doctype` yet case qa: case Ua: return is(e); case Ha: return ds(e); case Ya: return os(e); case wa: case va: case bt: return ns(e, t); case Fa: return cs(e, t); } } const ss = /* @__PURE__ */ new Set([ "mi", "mo", "mn", "ms", "mtext", "annotation-xml", "foreignObject", "desc", "title" ]), rs = /* @__PURE__ */ new Set(["svg", "math"]); function ns(e, t) { var u; t.xmlMode === "foreign" && (e.name = (u = Ja.get(e.name)) !== null && u !== void 0 ? u : e.name, e.parent && ss.has(e.parent.name) && (t = { ...t, xmlMode: !1 })), !t.xmlMode && rs.has(e.name) && (t = { ...t, xmlMode: "foreign" }); let a = `<${e.name}`; const r = us(e.attribs, t); return r && (a += ` ${r}`), e.children.length === 0 && (t.xmlMode ? ( // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags t.selfClosingTags !== !1 ) : ( // User explicitly asked for self-closing tags, even in HTML mode t.selfClosingTags && zt.has(e.name) )) ? (t.xmlMode || (a += " "), a += "/>") : (a += ">", e.children.length > 0 && (a += Pt(e.children, t)), (t.xmlMode || !zt.has(e.name)) && (a += `</${e.name}>`)), a; } function is(e) { return `<${e.data}>`; } function cs(e, t) { var u; let a = e.data || ""; return ((u = t.encodeEntities) !== null && u !== void 0 ? u : t.decodeEntities) !== !1 && !(!t.xmlMode && e.parent && es.has(e.parent.name)) && (a = t.xmlMode || t.encodeEntities !== "utf8" ? Iu(a) : za(a)), a; } function os(e) { return `<![CDATA[${e.children[0].data}]]>`; } function ds(e) { return `<!--${e.data}-->`; } function Ou(e, t) { return Pt(e, t); } function ls(e, t) { return P(e) ? e.children.map((u) => Ou(u, t)).join("") : ""; } function Be(e) { return Array.isArray(e) ? e.map(Be).join("") : p(e) ? e.name === "br" ? ` ` : Be(e.children) : Xe(e) ? Be(e.children) : Z(e) ? e.data : ""; } function re(e) { return Array.isArray(e) ? e.map(re).join("") : P(e) && !Rt(e) ? re(e.children) : Z(e) ? e.data : ""; } function Fe(e) { return Array.isArray(e) ? e.map(Fe).join("") : P(e) && (e.type === L.Tag || Xe(e)) ? Fe(e.children) : Z(e) ? e.data : ""; } function Ke(e) { return P(e) ? e.children : []; } function Lu(e) { return e.parent || null; } function Du(e) { const t = Lu(e); if (t != null) return Ke(t); const u = [e]; let { prev: a, next: r } = e; for (; a != null; ) u.unshift(a), { prev: a } = a; for (; r != null; ) u.push(r), { next: r } = r; return u; } function fs(e, t) { var u; return (u = e.attribs) === null || u === void 0 ? void 0 : u[t]; } function hs(e, t) { return e.attribs != null && Object.prototype.hasOwnProperty.call(e.attribs, t) && e.attribs[t] != null; } function Es(e) { return e.name; } function Mt(e) { let { next: t } = e; for (; t !== null && !p(t); ) ({ next: t } = t); return t; } function xt(e) { let { prev: t } = e; for (; t !== null && !p(t); ) ({ prev: t } = t); return t; } function ue(e) { if (e.prev && (e.prev.next = e.next), e.next && (e.next.prev = e.prev), e.parent) { const t = e.parent.children, u = t.lastIndexOf(e); u >= 0 && t.splice(u, 1); } e.next = null, e.prev = null, e.parent = null; } function Ts(e, t) { const u = t.prev = e.prev; u && (u.next = t); const a = t.next = e.next; a && (a.prev = t); const r = t.parent = e.parent; if (r) { const n = r.children; n[n.lastIndexOf(e)] = t, e.parent = null; } } function bs(e, t) { if (ue(t), t.next = null, t.parent = e, e.children.push(t) > 1) { const u = e.children[e.children.length - 2]; u.next = t, t.prev = u; } else t.prev = null; } function ms(e, t) { ue(t); const { parent: u } = e, a = e.next; if (t.next = a, t.prev = e, e.next = t, t.parent = u, a) { if (a.prev = t, u) { const r = u.children; r.splice(r.lastIndexOf(a), 0, t); } } else u && u.children.push(t); } function _s(e, t) { if (ue(t), t.parent = e, t.prev = null, e.children.unshift(t) !== 1) { const u = e.children[1]; u.prev = t, t.next = u; } else t.next = null; } function As(e, t) { ue(t); const { parent: u } = e; if (u) { const a = u.children; a.splice(a.indexOf(e), 0, t); } e.prev && (e.prev.next = t), t.parent = u, t.prev = e.prev, t.next = e, e.prev = t; } function Oe(e, t, u = !0, a = 1 / 0) { return yt(e, Array.isArray(t) ? t : [t], u, a); } function yt(e, t, u, a) { const r = [], n = [Array.isArray(t) ? t : [t]], c = [0]; for (; ; ) { if (c[0] >= n[0].length) { if (c.length === 1) return r; n.shift(), c.shift(); continue; } const l = n[0][c[0]++]; if (e(l) && (r.push(l), --a <= 0)) return r; u && P(l) && l.children.length > 0 && (c.unshift(0), n.unshift(l.children)); } } function ps(e, t) { return t.find(e); } function Bt(e, t, u = !0) { const a = Array.isArray(t) ? t : [t]; for (let r = 0; r < a.length; r++) { const n = a[r]; if (p(n) && e(n)) return n; if (u && P(n) && n.children.length > 0) { const c = Bt(e, n.children, !0); if (c) return c; } } return null; } function Ru(e, t) { return (Array.isArray(t) ? t : [t]).some((u) => p(u) && e(u) || P(u) && Ru(e, u.children)); } function gs(e, t) { const u = [], a = [Array.isArray(t) ? t : [t]], r = [0]; for (; ; ) { if (r[0] >= a[0].length) { if (a.length === 1) return u; a.shift(), r.shift(); continue; } const n = a[0][r[0]++]; p(n) && e(n) && u.push(n), P(n) && n.children.length > 0 && (r.unshift(0), a.unshift(n.children)); } } const Ue = { tag_name(e) { return typeof e == "function" ? (t) => p(t) && e(t.name) : e === "*" ? p : (t) => p(t) && t.name === e; }, tag_type(e) { return typeof e == "function" ? (t) => e(t.type) : (t) => t.type === e; }, tag_contains(e) { return typeof e == "function" ? (t) => Z(t) && e(t.data) : (t) => Z(t) && t.data === e; } }; function kt(e, t) { return typeof t == "function" ? (u) => p(u) && t(u.attribs[e]) : (u) => p(u) && u.attribs[e] === t; } function Ns(e, t) { return (u) => e(u) || t(u); } function Pu(e) { const t = Object.keys(e).map((u) => { const a = e[u]; return Object.prototype.hasOwnProperty.call(Ue, u) ? Ue[u](a) : kt(u, a); }); return t.length === 0 ? null : t.reduce(Ns); } function Cs(e, t) { const u = Pu(e); return u ? u(t) : !0; } function Is(e, t, u, a = 1 / 0) { const r = Pu(e); return r ? Oe(r, t, u, a) : []; } function Ss(e, t, u = !0) { return Array.isArray(t) || (t = [t]), Bt(kt("id", e), t, u); } function ie(e, t, u = !0, a = 1 / 0) { return Oe(Ue.tag_name(e), t, u, a); } function Os(e, t, u = !0, a = 1 / 0) { return Oe(kt("class", e), t, u, a); } function Ls(e, t, u = !0, a = 1 / 0) { return Oe(Ue.tag_type(e), t, u, a); } function Ds(e) { let t = e.length; for (; --t >= 0; ) { const u = e[t]; if (t > 0 && e.lastIndexOf(u, t - 1) >= 0) { e.splice(t, 1); continue; } for (let a = u.parent; a; a = a.parent) if (e.includes(a)) { e.splice(t, 1); break; } } return e; } var w; (function(e) { e[e.DISCONNECTED = 1] = "DISCONNECTED", e[e.PRECEDING = 2] = "PRECEDING", e[e.FOLLOWING = 4] = "FOLLOWING", e[e.CONTAINS = 8] = "CONTAINS", e[e.CONTAINED_BY = 16] = "CONTAINED_BY"; })(w || (w = {})); function Mu(e, t) { const u = [], a = []; if (e === t) return 0; let r = P(e) ? e : e.parent; for (; r; ) u.unshift(r), r = r.parent; for (r = P(t) ? t : t.parent; r; ) a.unshift(r), r = r.parent; const n = Math.min(u.length, a.length); let c = 0; for (; c < n && u[c] === a[c]; ) c++; if (c === 0) return w.DISCONNECTED; const l = u[c - 1], h = l.children, T = u[c], _ = a[c]; return h.indexOf(T) > h.indexOf(_) ? l === t ? w.FOLLOWING | w.CONTAINED_BY : w.FOLLOWING : l === e ? w.PRECEDING | w.CONTAINS : w.PRECEDING; } function ce(e) { return e = e.filter((t, u, a) => !a.includes(t, u + 1)), e.sort((t, u) => { const a = Mu(t, u); return a & w.PRECEDING ? -1 : a & w.FOLLOWING ? 1 : 0; }), e; } function Rs(e) { const t = He(Bs, e); return t ? t.name === "feed" ? Ps(t) : Ms(t) : null; } function Ps(e) { var t; const u = e.children, a = { type: "atom", items: ie("entry", u).map((c) => { var l; const { children: h } = c, T = { media: xu(h) }; U(T, "id", "id", h), U(T, "title", "title", h); const _ = (l = He("link", h)) === null || l === void 0 ? void 0 : l.attribs.href; _ && (T.link = _); const I = V("summary", h) || V("content", h); I && (T.description = I); const g = V("updated", h); return g && (T.pubDate = new Date(g)), T; }) }; U(a, "id", "id", u), U(a, "title", "title", u); const r = (t = He("link", u)) === null || t === void 0 ? void 0 : t.attribs.href; r && (a.link = r), U(a, "description", "subtitle", u); const n = V("updated", u); return n && (a.updated = new Date(n)), U(a, "author", "email", u, !0), a; } function Ms(e) { var t, u; const a = (u = (t = He("channel", e.children)) === null || t === void 0 ? void 0 : t.children) !== null && u !== void 0 ? u : [], r = { type: e.name.substr(0, 3), id: "", items: ie("item", e.children).map((c) => { const { children: l } = c, h = { media: xu(l) }; U(h, "id", "guid", l), U(h, "title", "title", l), U(h, "link", "link", l), U(h, "description", "description", l); const T = V("pubDate", l) || V("dc:date", l); return T && (h.pubDate = new Date(T)), h; }) }; U(r, "title", "title", a), U(r, "link", "link", a), U(r, "description", "description", a); const n = V("lastBuildDate", a); return n && (r.updated = new Date(n)), U(r, "author", "managingEditor", a, !0), r; } const xs = ["url", "type", "lang"], ys = [ "fileSize", "bitrate", "framerate", "samplingrate", "channels", "duration", "height", "width" ]; function xu(e) { return ie("media:content", e).map((t) => { const { attribs: u } = t, a = { medium: u.medium, isDefault: !!u.isDefault }; for (const r of xs) u[r] && (a[r] = u[r]); for (const r of ys) u[r] && (a[r] = parseInt(u[r], 10)); return u.expression && (a.expression = u.expression), a; }); } function He(e, t) { return ie(e, t, !0, 1)[0]; } function V(e, t, u = !1) { return re(ie(e, t, u, 1)).trim(); } function U(e, t, u, a, r = !1) { const n = V(u, a, r); n && (e[t] = n); } function Bs(e) { return e === "rss" || e === "feed" || e === "rdf:RDF"; } const je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, get DocumentPosition() { return w; }, append: ms, appendChild: bs, compareDocumentPosition: Mu, existsOne: Ru, filter: Oe, find: yt, findAll: gs, findOne: Bt, findOneChild: ps, getAttributeValue: fs, getChildren: Ke, getElementById: Ss, getElements: Is, getElementsByClassName: Os, getElementsByTagName: ie, getElementsByTagType: Ls, getFeed: Rs, getInnerHTML: ls, getName: Es, getOuterHTML: Ou, getParent: Lu, getSiblings: Du, getText: Be, hasAttrib: hs, hasChildren: P, innerText: Fe, isCDATA: Xe, isComment: Rt, isDocument: te, isTag: p, isText: Z, nextElementSibling: Mt, prepend: As, prependChild: _s, prevElementSibling: xt, removeElement: ue, removeSubsets: Ds, replaceElement: Ts, testElement: Cs, textContent: re, uniqueSort: ce }, Symbol.toStringTag, { value: "Module" })), ks = { _useHtmlParser2: !1 }; function Fs(e, t) { if (!e) return t ?? ks; const u = { _useHtmlParser2: !!e.xmlMode, ...t, ...e }; return e.xml ? (u._useHtmlParser2 = !0, u.xmlMode = !0, e.xml !== !0 && Object.assign(u, e.xml)) : e.xmlMode && (u._useHtmlParser2 = !0), u; } function yu(e, t, u) { return e ? e(t ?? e._root.children, null, void 0, u).toString() : ""; } function Us(e, t) { return typeof e == "object" && e != null && !("length" in e) && !("type" in e); } function Hs(e, t) { const u = Us(e) ? (t = e, void 0) : e, a = { ...this === null || this === void 0 ? void 0 : this._options, ...Fs(t) }; return yu(this, u, a); } function ws(e) { const t = { ...this._options, xmlMode: !0 }; return yu(this, e, t); } function Ne(e) { const t = e ?? (this ? this.root() : []); let u = ""; for (let a = 0; a < t.length; a++) u += re(t[a]); return u; } function vs(e, t, u = typeof t == "boolean" ? t : !1) { if (!e || typeof e != "string") return null; typeof t == "boolean" && (u = t); const a = this.load(e, this._options, !1); return u || a("script").remove(), [...a.root()[0].children]; } function Ys() { return this(this._root); } function Bu(e, t) { if (t === e) return !1; let u = t; for (; u && u !== u.parent; ) if (u = u.parent, u === e) return !0; return !1; } function qs(e) { return this.root().extract(e); } function Ws(e, t) { if (!Jt(e) || !Jt(t)) return; let u = e.length; const a = +t.length; for (let r = 0; r < a; r++) e[u++] = t[r]; return e.length = u, e; } function Jt(e) { if (Array.isArray(e)) return !0; if (typeof e != "object" || e === null || !("length" in e) || typeof e.length != "number" || e.length < 0) return !1; for (let t = 0; t < e.length; t++) if (!(t in e)) return !1; return !0; } const w0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, contains: Bu, extract: qs, html: Hs, merge: Ws, parseHTML: vs, root: Ys, text: Ne, xml: ws }, Symbol.toStringTag, { value: "Module" })); function oe(e) { return e.cheerio != null; } function Qs(e) { return e.replace(/[._-](\w|$)/g, (t, u) => u.toUpperCase()); } function Gs(e) { return e.replace(/[A-Z]/g, "-$&").toLowerCase(); } function R(e, t) { const u = e.length; for (let a = 0; a < u; a++) t(e[a], a); return e; } var z; (function(e) { e[e.LowerA = 97] = "LowerA", e[e.LowerZ = 122] = "LowerZ", e[e.UpperA = 65] = "UpperA", e[e.UpperZ = 90] = "UpperZ", e[e.Exclamation = 33] = "Exclamation"; })(z || (z = {})); function Vs(e) { const t = e.indexOf("<"); if (t === -1 || t > e.length - 3) return !1; const u = e.charCodeAt(t + 1); return (u >= z.LowerA && u <= z.LowerZ || u >= z.UpperA && u <= z.UpperZ || u === z.Exclamation) && e.includes(">", t + 2); } var nt; const Ce = ( // @ts-expect-error `hasOwn` is a standard object method (nt = Object.hasOwn) !== null && nt !== void 0 ? nt : (e, t) => Object.prototype.hasOwnProperty.call(e, t) ), Ie = /\s+/, mt = "data-", Ft = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, Xs = /^{[^]*}$|^\[[^]*]$/; function we(e, t, u) { var a; if (!(!e || !p(e))) { if ((a = e.attribs) !== null && a !== void 0 || (e.attribs = {}), !t) return e.attribs; if (Ce(e.attribs, t)) return !u && Ft.test(t) ? t : e.attribs[t]; if (e.name === "option" && t === "value") return Ne(e.children); if (e.name === "input" && (e.attribs.type === "radio" || e.attribs.type === "checkbox") && t === "value") return "on"; } } function se(e, t, u) { u === null ? Fu(e, t) : e.attribs[t] = `${u}`; } function Ks(e, t) { if (typeof e == "object" || t !== void 0) { if (typeof t == "function") { if (typeof e != "string") throw new Error("Bad combination of arguments."); return R(this, (u, a) => { p(u) && se(u, e, t.call(u, a, u.attribs[e])); }); } return R(this, (u) => { if (p(u)) if (typeof e == "object") for (const a of Object.keys(e)) { const r = e[a]; se(u, a, r); } else se(u, e, t); }); } return arguments.length > 1 ? this : we(this[0], e, this.options.xmlMode); } function Zt(e, t, u) { return t in e ? ( // @ts-expect-error TS doesn't like us accessing the value directly here. e[t] ) : !u && Ft.test(t) ? we(e, t, !1) !== void 0 : we(e, t, u); } function it(e, t, u, a) { t in e ? e[t] = u : se(e, t, !a && Ft.test(t) ? u ? "" : null : `${u}`); } function js(e, t) { var u; if (typeof e == "string" && t === void 0) { const a = this[0]; if (!a) return; switch (e) { case "style": { const r = this.css(), n = Object.keys(r); for (let c = 0; c < n.length; c++) r[c] = n[c]; return r.length = n.length, r; } case "tagName": case "nodeName": return p(a) ? a.name.toUpperCase() : void 0; case "href": case "src": { if (!p(a)) return; const r = (u = a.attribs) === null || u === void 0 ? void 0 : u[e]; return typeof URL < "u" && (e === "href" && (a.tagName === "a" || a.tagName === "link") || e === "src" && (a.tagName === "img" || a.tagName === "iframe" || a.tagName === "audio" || a.tagName === "video" || a.tagName === "source")) && r !== void 0 && this.options.baseURI ? new URL(r, this.options.baseURI).href : r; } case "innerText": return Fe(a); case "textContent": return re(a); case "outerHTML": return a.type === gu ? this.html() : this.clone().wrap("<container />").parent().html(); case "innerHTML": return this.html(); default: return p(a) ? Zt(a, e, this.options.xmlMode) : void 0; } } if (typeof e == "object" || t !== void 0) { if (typeof t == "function") { if (typeof e == "object") throw new TypeError("Bad combination of arguments."); return R(this, (a, r) => { p(a) && it(a, e, t.call(a, r, Zt(a, e, this.options.xmlMode)), this.options.xmlMode); }); } return R(this, (a) => { if (p(a)) if (typeof e == "object") for (const r of Object.keys(e)) { const n = e[r]; it(a, r, n, this.options.xmlMode); } else it(a, e, t, this.options.xmlMode); }); } } function eu(e, t, u) { var a; (a = e.data) !== null && a !== void 0 || (e.data = {}), typeof t == "object" ? Object.assign(e.data, t) : typeof t == "string" && u !== void 0 && (e.data[t] = u); } function $s(e) { for (const t of Object.keys(e.attribs)) { if (!t.startsWith(mt)) continue; const u = Qs(t.slice(mt.length)); Ce(e.data, u) || (e.data[u] = ku(e.attribs[t])); } return e.data; } function zs(e, t) { const u = mt + Gs(t), a = e.data; if (Ce(a, t)) return a[t]; if (Ce(e.attribs, u)) return a[t] = ku(e.attribs[u]); } function ku(e) { if (e === "null") return null; if (e === "true") return !0; if (e === "false") return !1; const t = Number(e); if (e === String(t)) return t; if (Xs.test(e)) try { return JSON.parse(e); } catch { } return e; } function Js(e, t) { var u; const a = this[0]; if (!a || !p(a)) return; const r = a; return (u = r.data) !== null && u !== void 0 || (r.data = {}), e == null ? $s(r) : typeof e == "object" || t !== void 0 ? (R(this, (n) => { p(n) && (typeof e == "object" ? eu(n, e) : eu(n, e, t)); }), this) : zs(r, e); } function Zs(e) { const t = arguments.length === 0, u = this[0]; if (!u || !p(u)) return t ? void 0 : this; switch (u.name) { case "textarea": return this.text(e); case "select": { const a = this.find("option:selected"); if (!t) { if (this.attr("multiple") == null && typeof e == "object") return this; this.find("option").removeAttr("selected"); const r = typeof e == "object" ? e : [e]; for (const n of r) this.find(`option[value="${n}"]`).attr("selected", ""); return this; } return this.attr("multiple") ? a.toArray().map((r) => Ne(r.children)) : a.attr("value"); } case "input": case "option": return t ? this.attr("value") : this.attr("value", e); } } function Fu(e, t) { !e.attribs || !Ce(e.attribs, t) || delete e.attribs[t]; } function ve(e) { return e ? e.trim().split(Ie) : []; } function er(e) { const t = ve(e); for (const u of t) R(this, (a) => { p(a) && Fu(a, u); }); return this; } function tr(e) { return this.toArray().some((t) => { const u = p(t) && t.attribs.class; let a = -1; if (u && e.length > 0) for (; (a = u.indexOf(e, a + 1)) > -1; ) { const r = a + e.length; if ((a === 0 || Ie.test(u[a - 1])) && (r === u.length || Ie.test(u[r]))) return !0; } return !1; }); } function Uu(e) { if (typeof e == "function") return R(this, (a, r) => { if (p(a)) { const n = a.attribs.class || ""; Uu.call([a], e.call(a, r, n)); } }); if (!e || typeof e != "string") return this; const t = e.split(Ie), u = this.length; for (let a = 0; a < u; a++) { const r = this[a]; if (!p(r)) continue; const n = we(r, "class", !1); if (n) { let c = ` ${n} `; for (const l of t) { const h = `${l} `; c.includes(` ${h}`) || (c += h); } se(r, "class", c.trim()); } else se(r, "class", t.join(" ").trim()); } return this; } function Hu(e) { if (typeof e == "function") return R(this, (r, n) => { p(r) && Hu.call([r], e.call(r, n, r.attribs.class || "")); }); const t = ve(e), u = t.length, a = arguments.length === 0; return R(this, (r) => { if (p(r)) if (a) r.attribs.class = ""; else { const n = ve(r.attribs.class); let c = !1; for (let l = 0; l < u; l++) { const h = n.indexOf(t[l]); h !== -1 && (n.splice(h, 1), c = !0, l--); } c && (r.attribs.class = n.join(" ")); } }); } function wu(e, t) { if (typeof e == "function") return R(this, (c, l) => { p(c) && wu.call([c], e.call(c, l, c.attribs.class || "", t), t); }); if (!e || typeof e != "string") return this; const u = e.split(Ie), a = u.length, r = typeof t == "boolean" ? t ? 1 : -1 : 0, n = this.length; for (let c = 0; c < n; c++) { const l = this[c]; if (!p(l)) continue; const h = ve(l.attribs.class); for (let T = 0; T < a; T++) { const _ = h.indexOf(u[T]); r >= 0 && _ === -1 ? h.push(u[T]) : r <= 0 && _ !== -1 && h.splice(_, 1); } l.attribs.class = h.join(" "); } return this; } const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, addClass: Uu, attr: Ks, data: Js, hasClass: tr, prop: js, removeAttr: er, removeClass: Hu, toggleClass: wu, val: Zs }, Symbol.toStringTag, { value: "Module" })); var A; (function(e) { e.Attribute = "attribute", e.Pseudo = "pseudo", e.PseudoElement = "pseudo-element", e.Tag = "tag", e.Universal = "universal", e.Adjacent = "adjacent", e.Child = "child", e.Descendant = "descendant", e.Parent = "parent", e.Sibling = "sibling", e.ColumnCombinator = "column-combinator"; })(A || (A = {})); var M; (function(e) { e.Any = "any", e.Element = "element", e.End = "end", e.Equals = "equals", e.Exists = "exists", e.Hyphen = "hyphen", e.Not = "not", e.Start = "start"; })(M || (M = {})); const tu = /^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/, ar = /\\([\da-f]{1,6}\s?|(\s)|.)/gi, sr = /* @__PURE__ */ new Map([ [126, M.Element], [94, M.Start], [36, M.End], [42, M.Any], [33, M.Not], [124, M.Hyphen] ]), rr = /* @__PURE__ */ new Set([ "has", "not", "matches", "is", "where", "host", "host-context" ]); function Te(e) { switch (e.type) { case A.Adjacent: case A.Child: case A.Descendant: case A.Parent: case A.Sibling: case A.ColumnCombinator: return !0; default: return !1; } } const nr = /* @__PURE__ */ new Set(["contains", "icontains"]); function ir(e, t, u) { const a = parseInt(t, 16) - 65536; return a !== a || u ? t : a < 0 ? ( // BMP codepoint String.fromCharCode(a + 65536) ) : ( // Supplemental Plane codepoint (surrogate pair) String.fromCharCode(a >> 10 | 55296, a & 1023 | 56320) ); } function le(e) { return e.replace(ar, ir); } function ct(e) { return e === 39 || e === 34; } function uu(e) { return e === 32 || e === 9 || e === 10 || e === 12 || e === 13; } function $e(e) { const t = [], u = vu(t, `${e}`, 0); if (u < e.length) throw new Error(`Unmatched selector: ${e.slice(u)}`); return t; } function vu(e, t, u) { let a = []; function r(g) { const N = t.slice(u + g).match(tu); if (!N) throw new Error(`Expected name, found ${t.slice(u)}`); const [S] = N; return u += g + S.length, le(S); } function n(g) { for (u += g; u < t.length && uu(t.charCodeAt(u)); ) u++; } function c() { u += 1; const g = u; let N = 1; for (; N > 0 && u < t.length; u++) t.charCodeAt(u) === 40 && !l(u) ? N++ : t.charCodeAt(u) === 41 && !l(u) && N--; if (N) throw new Error("Parenthesis not matched"); return le(t.slice(g, u - 1)); } function l(g) { let N = 0; for (; t.charCodeAt(--g) === 92; ) N++; return (N & 1) === 1; } function h() { if (a.length > 0 && Te(a[a.length - 1])) throw new Error("Did not expect successive traversals."); } function T(g) { if (a.length > 0 && a[a.length - 1].type === A.Descendant) { a[a.length - 1].type = g; return; } h(), a.push({ type: g }); } function _(g, N) { a.push({ type: A.Attribute, name: g, action: N, value: r(1), namespace: null, ignoreCase: "quirks" }); } function I() { if (a.length && a[a.length - 1].type === A.Descendant && a.pop(), a.length === 0) throw new Error("Empty sub-selector"); e.push(a); } if (n(0), t.length === u) return u; e: for (; u < t.length; ) { const g = t.charCodeAt(u); switch (g) { // Whitespace case 32: case 9: case 10: case 12: case 13: { (a.length === 0 || a[0].type !== A.Descendant) && (h(), a.push({ type: A.Descendant })), n(1); break; } // Traversals case 62: { T(A.Child), n(1); break; } case 60: { T(A.Parent), n(1); break; } case 126: { T(A.Sibling), n(1); break; } case 43: { T(A.Adjacent), n(1); break; } // Special attribute selectors: .class, #id case 46: { _("class", M.Element); break; } case 35: { _("id", M.Equals); break; } case 91: { n(1); let N, S = null; t.charCodeAt(u) === 124 ? N = r(1) : t.startsWith("*|", u) ? (S = "*", N = r(2)) : (N = r(0), t.charCodeAt(u) === 124 && t.charCodeAt(u + 1) !== 61 && (S = N, N = r(1))), n(0); let k = M.Exists; const Kt = sr.get(t.charCodeAt(u)); if (Kt) { if (k = Kt, t.charCodeAt(u + 1) !== 61) throw new Error("Expected `=`"); n(2); } else t.charCodeAt(u) === 61 && (k = M.Equals, n(1)); let at = "", st = null; if (k !== "exists") { if (ct(t.charCodeAt(u))) { const Pe = t.charCodeAt(u); let j = u + 1; for (; j < t.length && (t.charCodeAt(j) !== Pe || l(j)); ) j += 1; if (t.charCodeAt(j) !== Pe) throw new Error("Attribute value didn't end"); at = le(t.slice(u + 1, j)), u = j + 1; } else { const Pe = u; for (; u < t.length && (!uu(t.charCodeAt(u)) && t.charCodeAt(u) !== 93 || l(u)); ) u += 1; at = le(t.slice(Pe, u)); } n(0); const jt = t.charCodeAt(u) | 32; jt === 115 ? (st = !1, n(1)) : jt === 105 && (st = !0, n(1)); } if (t.charCodeAt(u) !== 93) throw new Error("Attribute selector didn't terminate"); u += 1; const Ba = { type: A.Attribute, name: N, action: k, value: at, namespace: S, ignoreCase: st }; a.push(Ba); break; } case 58: { if (t.charCodeAt(u + 1) === 58) { a.push({ type: A.PseudoElement, name: r(2).toLowerCase(), data: t.charCodeAt(u) === 40 ? c() : null }); continue; } const N = r(1).toLowerCase(); let S = null; if (t.charCodeAt(u) === 40) if (rr.has(N)) { if (ct(t.charCodeAt(u + 1))) throw new Error(`Pseudo-selector ${N} cannot be quoted`); if (S = [], u = vu(S, t, u + 1), t.charCodeAt(u) !== 41) throw new Error(`Missing closing parenthesis in :${N} (${t})`); u += 1; } else { if (S = c(), nr.has(N)) { const k = S.charCodeAt(0); k === S.charCodeAt(S.length - 1) && ct(k) && (S = S.slice(1, -1)); } S = le(S); } a.push({ type: A.Pseudo, name: N, data: S }); break; } case 44: { I(), a = [], n(1); break; } default: { if (t.startsWith("/*", u)) { const k = t.indexOf("*/", u + 2); if (k < 0) throw new Error("Comment was not terminated"); u = k + 2, a.length === 0 && n(0); break; } let N = null, S; if (g === 42) u += 1, S = "*"; else if (g === 124) { if (S = "", t.charCodeAt(u + 1) === 124) { T(A.ColumnCombinator), n(2); break; } } else if (tu.test(t.slice(u))) S = r(0); else break e; t.charCodeAt(u) === 124 && t.charCodeAt(u + 1) !== 124 && (N = S, t.charCodeAt(u + 1) === 42 ? (S = "*", u += 2) : S = r(1)), a.push(S === "*" ? { type: A.Universal, namespace: N } : { type: A.Tag, name: S, namespace: N }); } } } return I(), u; } function cr(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var ot, au; function or() { return au || (au = 1, ot = { trueFunc: function() { return !0; }, falseFunc: function() { return !1; } }), ot; } var Ye = or(); const C = /* @__PURE__ */ cr(Ye), Yu = /* @__PURE__ */ new Map([ [A.Universal, 50], [A.Tag, 30], [A.Attribute, 1], [A.Pseudo, 0] ]); function Ut(e) { return !Yu.has(e.type); } const dr = /* @__PURE__ */ new Map([ [M.Exists, 10], [M.Equals, 8], [M.Not, 7], [M.Start, 6], [M.End, 6], [M.Any, 5] ]); function lr(e) { const t = e.map(qu); for (let u = 1; u < e.length; u++) { const a = t[u]; if (!(a < 0)) for (let r = u - 1; r >= 0 && a < t[r]; r--) { const n = e[r + 1]; e[r + 1] = e[r], e[r] = n, t[r + 1] = t[r], t[r] = a; } } } function qu(e) { var t, u; let a = (t = Yu.get(e.type)) !== null && t !== void 0 ? t : -1; return e.type === A.Attribute ? (a = (u = dr.get(e.action)) !== null && u !== void 0 ? u : 4, e.action === M.Equals && e.name === "id" && (a = 9), e.ignoreCase && (a >>= 1)) : e.type === A.Pseudo && (e.data ? e.name === "has" || e.name === "contains" ? a = 0 : Array.isArray(e.data) ? (a = Math.min(...e.data.map((r) => Math.min(...r.map(qu)))), a < 0 && (a = 0)) : a = 2 : a = 3), a; } const fr = /[-[\]{}()*+?.,\\^$|#\s]/g; function su(e) { return e.replace(fr, "\\$&"); } const hr = /* @__PURE__ */ new Set([ "accept", "accept-charset", "align", "alink", "axis", "bgcolor", "charset", "checked", "clear", "codetype", "color", "compact", "declare", "defer", "dir", "direction", "disabled", "enctype", "face", "frame", "hreflang", "http-equiv", "lang", "language", "link", "media", "method", "multiple", "nohref", "noresize", "noshade", "nowrap", "readonly", "rel", "rev", "rules", "scope", "scrolling", "selected", "shape", "target", "text", "type", "valign", "valuetype", "vlink" ]); function $(e, t) { return typeof e.ignoreCase == "boolean" ? e.ignoreCase : e.ignoreCase === "quirks" ? !!t.quirksMode : !t.xmlMode && hr.has(e.name); } const Er = { equals(e, t, u) { const { adapter: a } = u, { name: r } = t; let { value: n } = t; return $(t, u) ? (n = n.toLowerCase(), (c) => { const l = a.getAttributeValue(c, r); return l != null && l.length === n.length && l.toLowerCase() === n && e(c); }) : (c) => a.getAttributeValue(c, r) === n && e(c); }, hyphen(e, t, u) { const { adapter: a } = u, { name: r } = t; let { value: n } = t; const c = n.length; return $(t, u) ? (n = n.toLowerCase(), function(h) { const T = a.getAttributeValue(h, r); return T != null && (T.length === c || T.charAt(c) === "-") && T.substr(0, c).toLowerCase() === n && e(h); }) : function(h) { const T = a.getAttributeValue(h, r); return T != null && (T.length === c || T.charAt(c) === "-") && T.substr(0, c) === n && e(h); }; }, element(e, t, u) { const { adapter: a } = u, { name: r, value: n } = t; if (/\s/.test(n)) return C.falseFunc; const c = new RegExp(`(?:^|\\s)${su(n)}(?:$|\\s)`, $(t, u) ? "i" : ""); return function(h) { const T = a.getAttributeValue(h, r); return T != null && T.length >= n.length && c.test(T) && e(h); }; }, exists(e, { name: t }, { adapter: u }) { return (a) => u.hasAttrib(a, t) && e(a); }, start(e, t, u) { const { adapter: a } = u, { name: r } = t; let { value: n } = t; const c = n.length; return c === 0 ? C.falseFunc : $(t, u) ? (n = n.toLowerCase(), (l) => { const h = a.getAttributeValue(l, r); return h != null && h.length >= c && h.substr(0, c).toLowerCase() === n && e(l); }) : (l) => { var h; return !!(!((h = a.getAttributeValue(l, r)) === null || h === void 0) && h.startsWith(n)) && e(l); }; }, end(e, t, u) { const { adapter: a } = u, { name: r } = t; let { value: n } = t; const c = -n.length; return c === 0 ? C.falseFunc : $(t, u) ? (n = n.toLowerCase(), (l) => { var h; return ((h = a.getAttributeValue(l, r)) === null || h === void 0 ? void 0 : h.substr(c).toLowerCase()) === n && e(l); }) : (l) => { var h; return !!(!((h = a.getAttributeValue(l, r)) === null || h === void 0) && h.endsWith(n)) && e(l); }; }, any(e, t, u) { const { adapter: a } = u, { name: r, value: n } = t; if (n === "") return C.falseFunc; if ($(t, u)) { const c = new RegExp(su(n), "i"); return function(h) { const T = a.getAttributeValue(h, r); return T != null && T.length >= n.length && c.test(T) && e(h); }; } return (c) => { var l; return !!(!((l = a.getAttributeValue(c, r)) === null || l === void 0) && l.includes(n)) && e(c); }; }, not(e, t, u) { const { adapter: a } = u, { name: r } = t; let { value: n } = t; return n === "" ? (c) => !!a.getAttributeValue(c, r) && e(c) : $(t, u) ? (n = n.toLowerCase(), (c) => { const l = a.getAttributeValue(c, r); return (l == null || l.length !== n.length || l.toLowerCase() !== n) && e(c); }) : (c) => a.getAttributeValue(c, r) !== n && e(c); } }, Tr = /* @__PURE__ */ new Set([9, 10, 12, 13, 32]), ru = 48, br = 57; function mr(e) { if (e = e.trim().toLowerCase(), e === "even") return [2, 0]; if (e === "odd") return [2, 1]; let t = 0, u = 0, a = n(), r = c(); if (t < e.length && e.charAt(t) === "n" && (t++, u = a * (r ?? 1), l(), t < e.length ? (a = n(), l(), r = c()) : a = r = 0), r === null || t < e.length) throw new Error(`n-th rule couldn't be parsed ('${e}')`); return [u, a * r]; function n() { return e.charAt(t) === "-" ? (t++, -1) : (e.charAt(t) === "+" && t++, 1); } function c() { const h = t; let T = 0; for (; t < e.length && e.charCodeAt(t) >= ru && e.charCodeAt(t) <= br; ) T = T * 10 + (e.charCodeAt(t) - ru), t++; return t === h ? null : T; } function l() { for (; t < e.length && Tr.has(e.charCodeAt(t)); ) t++; } } function _r(e) { const t = e[0], u = e[1] - 1; if (u < 0 && t <= 0) return C.falseFunc; if (t === -1) return (n) => n <= u; if (t === 0) return (n) => n === u; if (t === 1) return u < 0 ? C.trueFunc : (n) => n >= u; const a = Math.abs(t), r = (u % a + a) % a; return t > 1 ? (n) => n >= u && n % a === r : (n) => n <= u && n % a === r; } function Me(e) { return _r(mr(e)); } function xe(e, t) { return (u) => { const a = t.getParent(u); return a != null && t.isTag(a) && e(u); }; } const _t = { contains(e, t, { adapter: u }) { return function(r) { return e(r) && u.getText(r).includes(t); }; }, icontains(e, t, { adapter: u }) { const a = t.toLowerCase(); return function(n) { return e(n) && u.getText(n).toLowerCase().includes(a); }; }, // Location specific methods "nth-child"(e, t, { adapter: u, equals: a }) { const r = Me(t); return r === C.falseFunc ? C.falseFunc : r === C.trueFunc ? xe(e, u) : function(c) { const l = u.getSiblings(c); let h = 0; for (let T = 0; T < l.length && !a(c, l[T]); T++) u.isTag(l[T]) && h++; return r(h) && e(c); }; }, "nth-last-child"(e, t, { adapter: u, equals: a }) { const r = Me(t); return r === C.falseFunc ? C.falseFunc : r === C.trueFunc ? xe(e, u) : function(c) { const l = u.getSiblings(c); let h = 0; for (let T = l.length - 1; T >= 0 && !a(c, l[T]); T--) u.isTag(l[T]) && h++; return r(h) && e(c); }; }, "nth-of-type"(e, t, { adapter: u, equals: a }) { const r = Me(t); return r === C.falseFunc ? C.falseFunc : r === C.trueFunc ? xe(e, u) : function(c) { const l = u.getSiblings(c); let h = 0; for (let T = 0; T < l.length; T++) { const _ = l[T]; if (a(c, _)) break; u.isTag(_) && u.getName(_) === u.getName(c) && h++; } return r(h) && e(c); }; }, "nth-last-of-type"(e, t, { adapter: u, equals: a }) { const r = Me(t); return r === C.falseFunc ? C.falseFunc : r === C.trueFunc ? xe(e, u) : function(c) { const l = u.getSiblings(c); let h = 0; for (let T = l.length - 1; T >= 0; T--) { const _ = l[T]; if (a(c, _)) break; u.isTag(_) && u.getName(_) === u.getName(c) && h++; } return r(h) && e(c); }; }, // TODO determine the actual root element root(e, t, { adapter: u }) { return (a) => { const r = u.getParent(a); return (r == null || !u.isTag(r)) && e(a); }; }, scope(e, t, u, a) { const { equals: r } = u; return !a || a.length === 0 ? _t.root(e, t, u) : a.length === 1 ? (n) => r(a[0], n) && e(n) : (n) => a.includes(n) && e(n); }, hover: dt("isHovered"), visited: dt("isVisited"), active: dt("isActive") }; function dt(e) { return function(u, a, { adapter: r }) { const n = r[e]; return typeof n != "function" ? C.falseFunc : function(l) { return n(l) && u(l); }; }; } const nu = { empty(e, { adapter: t }) { return !t.getChildren(e).some((u) => ( // FIXME: `getText` call is potentially expensive. t.isTag(u) || t.getText(u) !== "" )); }, "first-child"(e, { adapter: t, equals: u }) { if (t.prevElementSibling) return t.prevElementSibling(e) == null; const a = t.getSiblings(e).find((r) => t.isTag(r)); return a != null && u(e, a); }, "last-child"(e, { adapter: t, equal