UNPKG

@oddbird/css-anchor-positioning

Version:

Polyfill for the proposed CSS anchor positioning spec

1,788 lines 169 kB
var po = Object.defineProperty, go = Object.defineProperties; var mo = Object.getOwnPropertyDescriptors; var An = Object.getOwnPropertySymbols; var ko = Object.prototype.hasOwnProperty, So = Object.prototype.propertyIsEnumerable; var vn = (t, e, n) => e in t ? po(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, W = (t, e) => { for (var n in e || (e = {})) ko.call(e, n) && vn(t, n, e[n]); if (An) for (var n of An(e)) So.call(e, n) && vn(t, n, e[n]); return t; }, q = (t, e) => go(t, mo(e)); var R = (t, e, n) => new Promise((r, s) => { var o = (u) => { try { l(n.next(u)); } catch (i) { s(i); } }, a = (u) => { try { l(n.throw(u)); } catch (i) { s(i); } }, l = (u) => u.done ? r(u.value) : Promise.resolve(u.value).then(o, a); l((n = n.apply(t, e)).next()); }); const Ze = Math.min, Vt = Math.max, Ce = Math.round, he = Math.floor, kt = (t) => ({ x: t, y: t }); function yo(t, e) { return typeof t == "function" ? t(e) : t; } function bo(t) { return W({ top: 0, right: 0, bottom: 0, left: 0 }, t); } function xo(t) { return typeof t != "number" ? bo(t) : { top: t, right: t, bottom: t, left: t }; } function we(t) { const { x: e, y: n, width: r, height: s } = t; return { width: r, height: s, top: n, left: e, right: e + r, bottom: n + s, x: e, y: n }; } function Co(t, e) { return R(this, null, function* () { var n; e === void 0 && (e = {}); const { x: r, y: s, platform: o, rects: a, elements: l, strategy: u } = t, { boundary: i = "clippingAncestors", rootBoundary: c = "viewport", elementContext: h = "floating", altBoundary: f = !1, padding: p = 0 } = yo(e, t), g = xo(p), S = l[f ? h === "floating" ? "reference" : "floating" : h], b = we(yield o.getClippingRect({ element: (n = yield o.isElement == null ? void 0 : o.isElement(S)) == null || n ? S : S.contextElement || (yield o.getDocumentElement == null ? void 0 : o.getDocumentElement(l.floating)), boundary: i, rootBoundary: c, strategy: u })), C = h === "floating" ? { x: r, y: s, width: a.floating.width, height: a.floating.height } : a.reference, v = yield o.getOffsetParent == null ? void 0 : o.getOffsetParent(l.floating), M = (yield o.isElement == null ? void 0 : o.isElement(v)) ? (yield o.getScale == null ? void 0 : o.getScale(v)) || { x: 1, y: 1 } : { x: 1, y: 1 }, k = we(o.convertOffsetParentRelativeRectToViewportRelativeRect ? yield o.convertOffsetParentRelativeRectToViewportRelativeRect({ elements: l, rect: C, offsetParent: v, strategy: u }) : C); return { top: (b.top - k.top + g.top) / M.y, bottom: (k.bottom - b.bottom + g.bottom) / M.y, left: (b.left - k.left + g.left) / M.x, right: (k.right - b.right + g.right) / M.x }; }); } function Pe() { return typeof window != "undefined"; } function Zt(t) { return Or(t) ? (t.nodeName || "").toLowerCase() : "#document"; } function st(t) { var e; return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window; } function yt(t) { var e; return (e = (Or(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement; } function Or(t) { return Pe() ? t instanceof Node || t instanceof st(t).Node : !1; } function lt(t) { return Pe() ? t instanceof Element || t instanceof st(t).Element : !1; } function St(t) { return Pe() ? t instanceof HTMLElement || t instanceof st(t).HTMLElement : !1; } function En(t) { return !Pe() || typeof ShadowRoot == "undefined" ? !1 : t instanceof ShadowRoot || t instanceof st(t).ShadowRoot; } function ce(t) { const { overflow: e, overflowX: n, overflowY: r, display: s } = ct(t); return /auto|scroll|overlay|hidden|clip/.test(e + r + n) && !["inline", "contents"].includes(s); } function wo(t) { return ["table", "td", "th"].includes(Zt(t)); } function Oe(t) { return [":popover-open", ":modal"].some((e) => { try { return t.matches(e); } catch (n) { return !1; } }); } function dn(t) { const e = gn(), n = lt(t) ? ct(t) : t; return ["transform", "translate", "scale", "rotate", "perspective"].some((r) => n[r] ? n[r] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((r) => (n.willChange || "").includes(r)) || ["paint", "layout", "strict", "content"].some((r) => (n.contain || "").includes(r)); } function To(t) { let e = Lt(t); for (; St(e) && !Kt(e); ) { if (dn(e)) return e; if (Oe(e)) return null; e = Lt(e); } return null; } function gn() { return typeof CSS == "undefined" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none"); } function Kt(t) { return ["html", "body", "#document"].includes(Zt(t)); } function ct(t) { return st(t).getComputedStyle(t); } function Re(t) { return lt(t) ? { scrollLeft: t.scrollLeft, scrollTop: t.scrollTop } : { scrollLeft: t.scrollX, scrollTop: t.scrollY }; } function Lt(t) { if (Zt(t) === "html") return t; const e = ( // Step into the shadow DOM of the parent of a slotted node. t.assignedSlot || // DOM Element detected. t.parentNode || // ShadowRoot detected. En(t) && t.host || // Fallback. yt(t) ); return En(e) ? e.host : e; } function Rr(t) { const e = Lt(t); return Kt(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : St(e) && ce(e) ? e : Rr(e); } function oe(t, e, n) { var r; e === void 0 && (e = []), n === void 0 && (n = !0); const s = Rr(t), o = s === ((r = t.ownerDocument) == null ? void 0 : r.body), a = st(s); if (o) { const l = tn(a); return e.concat(a, a.visualViewport || [], ce(s) ? s : [], l && n ? oe(l) : []); } return e.concat(s, oe(s, [], n)); } function tn(t) { return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null; } function Ir(t) { const e = ct(t); let n = parseFloat(e.width) || 0, r = parseFloat(e.height) || 0; const s = St(t), o = s ? t.offsetWidth : n, a = s ? t.offsetHeight : r, l = Ce(n) !== o || Ce(r) !== a; return l && (n = o, r = a), { width: n, height: r, $: l }; } function mn(t) { return lt(t) ? t : t.contextElement; } function Gt(t) { const e = mn(t); if (!St(e)) return kt(1); const n = e.getBoundingClientRect(), { width: r, height: s, $: o } = Ir(e); let a = (o ? Ce(n.width) : n.width) / r, l = (o ? Ce(n.height) : n.height) / s; return (!a || !Number.isFinite(a)) && (a = 1), (!l || !Number.isFinite(l)) && (l = 1), { x: a, y: l }; } const Ao = /* @__PURE__ */ kt(0); function _r(t) { const e = st(t); return !gn() || !e.visualViewport ? Ao : { x: e.visualViewport.offsetLeft, y: e.visualViewport.offsetTop }; } function vo(t, e, n) { return e === void 0 && (e = !1), !n || e && n !== st(t) ? !1 : e; } function Nt(t, e, n, r) { e === void 0 && (e = !1), n === void 0 && (n = !1); const s = t.getBoundingClientRect(), o = mn(t); let a = kt(1); e && (r ? lt(r) && (a = Gt(r)) : a = Gt(t)); const l = vo(o, n, r) ? _r(o) : kt(0); let u = (s.left + l.x) / a.x, i = (s.top + l.y) / a.y, c = s.width / a.x, h = s.height / a.y; if (o) { const f = st(o), p = r && lt(r) ? st(r) : r; let g = f, m = tn(g); for (; m && r && p !== g; ) { const S = Gt(m), b = m.getBoundingClientRect(), C = ct(m), v = b.left + (m.clientLeft + parseFloat(C.paddingLeft)) * S.x, M = b.top + (m.clientTop + parseFloat(C.paddingTop)) * S.y; u *= S.x, i *= S.y, c *= S.x, h *= S.y, u += v, i += M, g = st(m), m = tn(g); } } return we({ width: c, height: h, x: u, y: i }); } function kn(t, e) { const n = Re(t).scrollLeft; return e ? e.left + n : Nt(yt(t)).left + n; } function Nr(t, e, n) { n === void 0 && (n = !1); const r = t.getBoundingClientRect(), s = r.left + e.scrollLeft - (n ? 0 : ( // RTL <body> scrollbar. kn(t, r) )), o = r.top + e.scrollTop; return { x: s, y: o }; } function Eo(t) { let { elements: e, rect: n, offsetParent: r, strategy: s } = t; const o = s === "fixed", a = yt(r), l = e ? Oe(e.floating) : !1; if (r === a || l && o) return n; let u = { scrollLeft: 0, scrollTop: 0 }, i = kt(1); const c = kt(0), h = St(r); if ((h || !h && !o) && ((Zt(r) !== "body" || ce(a)) && (u = Re(r)), St(r))) { const p = Nt(r); i = Gt(r), c.x = p.x + r.clientLeft, c.y = p.y + r.clientTop; } const f = a && !h && !o ? Nr(a, u, !0) : kt(0); return { width: n.width * i.x, height: n.height * i.y, x: n.x * i.x - u.scrollLeft * i.x + c.x + f.x, y: n.y * i.y - u.scrollTop * i.y + c.y + f.y }; } function $o(t) { return Array.from(t.getClientRects()); } function Lo(t) { const e = yt(t), n = Re(t), r = t.ownerDocument.body, s = Vt(e.scrollWidth, e.clientWidth, r.scrollWidth, r.clientWidth), o = Vt(e.scrollHeight, e.clientHeight, r.scrollHeight, r.clientHeight); let a = -n.scrollLeft + kn(t); const l = -n.scrollTop; return ct(r).direction === "rtl" && (a += Vt(e.clientWidth, r.clientWidth) - s), { width: s, height: o, x: a, y: l }; } function Po(t, e) { const n = st(t), r = yt(t), s = n.visualViewport; let o = r.clientWidth, a = r.clientHeight, l = 0, u = 0; if (s) { o = s.width, a = s.height; const i = gn(); (!i || i && e === "fixed") && (l = s.offsetLeft, u = s.offsetTop); } return { width: o, height: a, x: l, y: u }; } function Oo(t, e) { const n = Nt(t, !0, e === "fixed"), r = n.top + t.clientTop, s = n.left + t.clientLeft, o = St(t) ? Gt(t) : kt(1), a = t.clientWidth * o.x, l = t.clientHeight * o.y, u = s * o.x, i = r * o.y; return { width: a, height: l, x: u, y: i }; } function $n(t, e, n) { let r; if (e === "viewport") r = Po(t, n); else if (e === "document") r = Lo(yt(t)); else if (lt(e)) r = Oo(e, n); else { const s = _r(t); r = { x: e.x - s.x, y: e.y - s.y, width: e.width, height: e.height }; } return we(r); } function Dr(t, e) { const n = Lt(t); return n === e || !lt(n) || Kt(n) ? !1 : ct(n).position === "fixed" || Dr(n, e); } function Ro(t, e) { const n = e.get(t); if (n) return n; let r = oe(t, [], !1).filter((l) => lt(l) && Zt(l) !== "body"), s = null; const o = ct(t).position === "fixed"; let a = o ? Lt(t) : t; for (; lt(a) && !Kt(a); ) { const l = ct(a), u = dn(a); !u && l.position === "fixed" && (s = null), (o ? !u && !s : !u && l.position === "static" && !!s && ["absolute", "fixed"].includes(s.position) || ce(a) && !u && Dr(t, a)) ? r = r.filter((c) => c !== a) : s = l, a = Lt(a); } return e.set(t, r), r; } function Io(t) { let { element: e, boundary: n, rootBoundary: r, strategy: s } = t; const a = [...n === "clippingAncestors" ? Oe(e) ? [] : Ro(e, this._c) : [].concat(n), r], l = a[0], u = a.reduce((i, c) => { const h = $n(e, c, s); return i.top = Vt(h.top, i.top), i.right = Ze(h.right, i.right), i.bottom = Ze(h.bottom, i.bottom), i.left = Vt(h.left, i.left), i; }, $n(e, l, s)); return { width: u.right - u.left, height: u.bottom - u.top, x: u.left, y: u.top }; } function _o(t) { const { width: e, height: n } = Ir(t); return { width: e, height: n }; } function No(t, e, n) { const r = St(e), s = yt(e), o = n === "fixed", a = Nt(t, !0, o, e); let l = { scrollLeft: 0, scrollTop: 0 }; const u = kt(0); function i() { u.x = kn(s); } if (r || !r && !o) if ((Zt(e) !== "body" || ce(s)) && (l = Re(e)), r) { const p = Nt(e, !0, o, e); u.x = p.x + e.clientLeft, u.y = p.y + e.clientTop; } else s && i(); o && !r && s && i(); const c = s && !r && !o ? Nr(s, l) : kt(0), h = a.left + l.scrollLeft - u.x - c.x, f = a.top + l.scrollTop - u.y - c.y; return { x: h, y: f, width: a.width, height: a.height }; } function _e(t) { return ct(t).position === "static"; } function Ln(t, e) { if (!St(t) || ct(t).position === "fixed") return null; if (e) return e(t); let n = t.offsetParent; return yt(t) === n && (n = n.ownerDocument.body), n; } function Fr(t, e) { const n = st(t); if (Oe(t)) return n; if (!St(t)) { let s = Lt(t); for (; s && !Kt(s); ) { if (lt(s) && !_e(s)) return s; s = Lt(s); } return n; } let r = Ln(t, e); for (; r && wo(r) && _e(r); ) r = Ln(r, e); return r && Kt(r) && _e(r) && !dn(r) ? n : r || To(t) || n; } const Do = function(t) { return R(this, null, function* () { const e = this.getOffsetParent || Fr, n = this.getDimensions, r = yield n(t.floating); return { reference: No(t.reference, yield e(t.floating), t.strategy), floating: { x: 0, y: 0, width: r.width, height: r.height } }; }); }; function Fo(t) { return ct(t).direction === "rtl"; } const H = { convertOffsetParentRelativeRectToViewportRelativeRect: Eo, getDocumentElement: yt, getClippingRect: Io, getOffsetParent: Fr, getElementRects: Do, getClientRects: $o, getDimensions: _o, getScale: Gt, isElement: lt, isRTL: Fo }; function Mr(t, e) { return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height; } function Mo(t, e) { let n = null, r; const s = yt(t); function o() { var l; clearTimeout(r), (l = n) == null || l.disconnect(), n = null; } function a(l, u) { l === void 0 && (l = !1), u === void 0 && (u = 1), o(); const i = t.getBoundingClientRect(), { left: c, top: h, width: f, height: p } = i; if (l || e(), !f || !p) return; const g = he(h), m = he(s.clientWidth - (c + f)), S = he(s.clientHeight - (h + p)), b = he(c), v = { rootMargin: -g + "px " + -m + "px " + -S + "px " + -b + "px", threshold: Vt(0, Ze(1, u)) || 1 }; let M = !0; function k(O) { const w = O[0].intersectionRatio; if (w !== u) { if (!M) return a(); w ? a(!1, w) : r = setTimeout(() => { a(!1, 1e-7); }, 1e3); } w === 1 && !Mr(i, t.getBoundingClientRect()) && a(), M = !1; } try { n = new IntersectionObserver(k, q(W({}, v), { // Handle <iframe>s root: s.ownerDocument })); } catch (O) { n = new IntersectionObserver(k, v); } n.observe(t); } return a(!0), o; } function en(t, e, n, r) { r === void 0 && (r = {}); const { ancestorScroll: s = !0, ancestorResize: o = !0, elementResize: a = typeof ResizeObserver == "function", layoutShift: l = typeof IntersectionObserver == "function", animationFrame: u = !1 } = r, i = mn(t), c = s || o ? [...i ? oe(i) : [], ...oe(e)] : []; c.forEach((b) => { s && b.addEventListener("scroll", n, { passive: !0 }), o && b.addEventListener("resize", n); }); const h = i && l ? Mo(i, n) : null; let f = -1, p = null; a && (p = new ResizeObserver((b) => { let [C] = b; C && C.target === i && p && (p.unobserve(e), cancelAnimationFrame(f), f = requestAnimationFrame(() => { var v; (v = p) == null || v.observe(e); })), n(); }), i && !u && p.observe(i), p.observe(e)); let g, m = u ? Nt(t) : null; u && S(); function S() { const b = Nt(t); m && !Mr(m, b) && n(), m = b, g = requestAnimationFrame(S); } return n(), () => { var b; c.forEach((C) => { s && C.removeEventListener("scroll", n), o && C.removeEventListener("resize", n); }), h == null || h(), (b = p) == null || b.disconnect(), p = null, u && cancelAnimationFrame(g); }; } const jo = Co, { hasOwnProperty: Sn } = Object.prototype, ee = function() { }; function Pn(t) { return typeof t == "function" ? t : ee; } function On(t, e) { return function(n, r, s) { n.type === e && t.call(this, n, r, s); }; } function Bo(t, e) { const n = e.structure, r = []; for (const s in n) { if (Sn.call(n, s) === !1) continue; let o = n[s]; const a = { name: s, type: !1, nullable: !1 }; Array.isArray(o) || (o = [o]); for (const l of o) l === null ? a.nullable = !0 : typeof l == "string" ? a.type = "node" : Array.isArray(l) && (a.type = "list"); a.type && r.push(a); } return r.length ? { context: e.walkContext, fields: r } : null; } function Uo(t) { const e = {}; for (const n in t.node) if (Sn.call(t.node, n)) { const r = t.node[n]; if (!r.structure) throw new Error("Missed `structure` field in `" + n + "` node type definition"); e[n] = Bo(n, r); } return e; } function Rn(t, e) { const n = t.fields.slice(), r = t.context, s = typeof r == "string"; return e && n.reverse(), function(o, a, l, u) { let i; s && (i = a[r], a[r] = o); for (const c of n) { const h = o[c.name]; if (!c.nullable || h) { if (c.type === "list") { if (e ? h.reduceRight(u, !1) : h.reduce(u, !1)) return !0; } else if (l(h)) return !0; } } s && (a[r] = i); }; } function In({ StyleSheet: t, Atrule: e, Rule: n, Block: r, DeclarationList: s }) { return { Atrule: { StyleSheet: t, Atrule: e, Rule: n, Block: r }, Rule: { StyleSheet: t, Atrule: e, Rule: n, Block: r }, Declaration: { StyleSheet: t, Atrule: e, Rule: n, Block: r, DeclarationList: s } }; } function Wo(t) { const e = Uo(t), n = {}, r = {}, s = Symbol("break-walk"), o = Symbol("skip-node"); for (const i in e) Sn.call(e, i) && e[i] !== null && (n[i] = Rn(e[i], !1), r[i] = Rn(e[i], !0)); const a = In(n), l = In(r), u = function(i, c) { function h(b, C, v) { const M = f.call(S, b, C, v); return M === s ? !0 : M === o ? !1 : !!(g.hasOwnProperty(b.type) && g[b.type](b, S, h, m) || p.call(S, b, C, v) === s); } let f = ee, p = ee, g = n, m = (b, C, v, M) => b || h(C, v, M); const S = { break: s, skip: o, root: i, stylesheet: null, atrule: null, atrulePrelude: null, rule: null, selector: null, block: null, declaration: null, function: null }; if (typeof c == "function") f = c; else if (c && (f = Pn(c.enter), p = Pn(c.leave), c.reverse && (g = r), c.visit)) { if (a.hasOwnProperty(c.visit)) g = c.reverse ? l[c.visit] : a[c.visit]; else if (!e.hasOwnProperty(c.visit)) throw new Error("Bad value `" + c.visit + "` for `visit` option (should be: " + Object.keys(e).sort().join(", ") + ")"); f = On(f, c.visit), p = On(p, c.visit); } if (f === ee && p === ee) throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function"); h(i); }; return u.break = s, u.skip = o, u.find = function(i, c) { let h = null; return u(i, function(f, p, g) { if (c.call(this, f, p, g)) return h = f, s; }), h; }, u.findLast = function(i, c) { let h = null; return u(i, { reverse: !0, enter(f, p, g) { if (c.call(this, f, p, g)) return h = f, s; } }), h; }, u.findAll = function(i, c) { const h = []; return u(i, function(f, p, g) { c.call(this, f, p, g) && h.push(f); }), h; }, u; } const At = 0, d = 1, T = 2, z = 3, N = 4, wt = 5, zo = 6, Q = 7, ot = 8, P = 9, x = 10, F = 11, $ = 12, U = 13, Ie = 14, et = 15, X = 16, tt = 17, ht = 18, te = 19, ae = 20, I = 21, y = 22, ut = 23, Qt = 24, Y = 25, Ho = 0; function rt(t) { return t >= 48 && t <= 57; } function Yt(t) { return rt(t) || // 0 .. 9 t >= 65 && t <= 70 || // A .. F t >= 97 && t <= 102; } function yn(t) { return t >= 65 && t <= 90; } function Vo(t) { return t >= 97 && t <= 122; } function Go(t) { return yn(t) || Vo(t); } function qo(t) { return t >= 128; } function Te(t) { return Go(t) || qo(t) || t === 95; } function jr(t) { return Te(t) || rt(t) || t === 45; } function Ko(t) { return t >= 0 && t <= 8 || t === 11 || t >= 14 && t <= 31 || t === 127; } function Ae(t) { return t === 10 || t === 13 || t === 12; } function Dt(t) { return Ae(t) || t === 32 || t === 9; } function mt(t, e) { return !(t !== 92 || Ae(e) || e === Ho); } function Ne(t, e, n) { return t === 45 ? Te(e) || e === 45 || mt(e, n) : Te(t) ? !0 : t === 92 ? mt(t, e) : !1; } function De(t, e, n) { return t === 43 || t === 45 ? rt(e) ? 2 : e === 46 && rt(n) ? 3 : 0 : t === 46 ? rt(e) ? 2 : 0 : rt(t) ? 1 : 0; } function Br(t) { return t === 65279 || t === 65534 ? 1 : 0; } const nn = new Array(128), Qo = 128, ke = 130, Ur = 131, bn = 132, Wr = 133; for (let t = 0; t < nn.length; t++) nn[t] = Dt(t) && ke || rt(t) && Ur || Te(t) && bn || Ko(t) && Wr || t || Qo; function Fe(t) { return t < 128 ? nn[t] : bn; } function qt(t, e) { return e < t.length ? t.charCodeAt(e) : 0; } function rn(t, e, n) { return n === 13 && qt(t, e + 1) === 10 ? 2 : 1; } function zr(t, e, n) { let r = t.charCodeAt(e); return yn(r) && (r = r | 32), r === n; } function ve(t, e, n, r) { if (n - e !== r.length || e < 0 || n > t.length) return !1; for (let s = e; s < n; s++) { const o = r.charCodeAt(s - e); let a = t.charCodeAt(s); if (yn(a) && (a = a | 32), a !== o) return !1; } return !0; } function Yo(t, e) { for (; e >= 0 && Dt(t.charCodeAt(e)); e--) ; return e + 1; } function fe(t, e) { for (; e < t.length && Dt(t.charCodeAt(e)); e++) ; return e; } function Me(t, e) { for (; e < t.length && rt(t.charCodeAt(e)); e++) ; return e; } function Xt(t, e) { if (e += 2, Yt(qt(t, e - 1))) { for (const r = Math.min(t.length, e + 5); e < r && Yt(qt(t, e)); e++) ; const n = qt(t, e); Dt(n) && (e += rn(t, e, n)); } return e; } function pe(t, e) { for (; e < t.length; e++) { const n = t.charCodeAt(e); if (!jr(n)) { if (mt(n, qt(t, e + 1))) { e = Xt(t, e) - 1; continue; } break; } } return e; } function Hr(t, e) { let n = t.charCodeAt(e); if ((n === 43 || n === 45) && (n = t.charCodeAt(e += 1)), rt(n) && (e = Me(t, e + 1), n = t.charCodeAt(e)), n === 46 && rt(t.charCodeAt(e + 1)) && (e += 2, e = Me(t, e)), zr( t, e, 101 /* e */ )) { let r = 0; n = t.charCodeAt(e + 1), (n === 45 || n === 43) && (r = 1, n = t.charCodeAt(e + 2)), rt(n) && (e = Me(t, e + 1 + r + 1)); } return e; } function je(t, e) { for (; e < t.length; e++) { const n = t.charCodeAt(e); if (n === 41) { e++; break; } mt(n, qt(t, e + 1)) && (e = Xt(t, e)); } return e; } function Vr(t) { if (t.length === 1 && !Yt(t.charCodeAt(0))) return t[0]; let e = parseInt(t, 16); return (e === 0 || // If this number is zero, e >= 55296 && e <= 57343 || // or is for a surrogate, e > 1114111) && (e = 65533), String.fromCodePoint(e); } const Gr = [ "EOF-token", "ident-token", "function-token", "at-keyword-token", "hash-token", "string-token", "bad-string-token", "url-token", "bad-url-token", "delim-token", "number-token", "percentage-token", "dimension-token", "whitespace-token", "CDO-token", "CDC-token", "colon-token", "semicolon-token", "comma-token", "[-token", "]-token", "(-token", ")-token", "{-token", "}-token", "comment-token" ], Xo = 16 * 1024; function Ee(t = null, e) { return t === null || t.length < e ? new Uint32Array(Math.max(e + 1024, Xo)) : t; } const _n = 10, Jo = 12, Nn = 13; function Dn(t) { const e = t.source, n = e.length, r = e.length > 0 ? Br(e.charCodeAt(0)) : 0, s = Ee(t.lines, n), o = Ee(t.columns, n); let a = t.startLine, l = t.startColumn; for (let u = r; u < n; u++) { const i = e.charCodeAt(u); s[u] = a, o[u] = l++, (i === _n || i === Nn || i === Jo) && (i === Nn && u + 1 < n && e.charCodeAt(u + 1) === _n && (u++, s[u] = a, o[u] = l), a++, l = 1); } s[n] = a, o[n] = l, t.lines = s, t.columns = o, t.computed = !0; } class Zo { constructor(e, n, r, s) { this.setSource(e, n, r, s), this.lines = null, this.columns = null; } setSource(e = "", n = 0, r = 1, s = 1) { this.source = e, this.startOffset = n, this.startLine = r, this.startColumn = s, this.computed = !1; } getLocation(e, n) { return this.computed || Dn(this), { source: n, offset: this.startOffset + e, line: this.lines[e], column: this.columns[e] }; } getLocationRange(e, n, r) { return this.computed || Dn(this), { source: r, start: { offset: this.startOffset + e, line: this.lines[e], column: this.columns[e] }, end: { offset: this.startOffset + n, line: this.lines[n], column: this.columns[n] } }; } } const pt = 16777215, dt = 24, Ft = new Uint8Array(32); Ft[T] = y; Ft[I] = y; Ft[te] = ae; Ft[ut] = Qt; function Fn(t) { return Ft[t] !== 0; } class ta { constructor(e, n) { this.setSource(e, n); } reset() { this.eof = !1, this.tokenIndex = -1, this.tokenType = 0, this.tokenStart = this.firstCharOffset, this.tokenEnd = this.firstCharOffset; } setSource(e = "", n = () => { }) { e = String(e || ""); const r = e.length, s = Ee(this.offsetAndType, e.length + 1), o = Ee(this.balance, e.length + 1); let a = 0, l = -1, u = 0, i = e.length; this.offsetAndType = null, this.balance = null, o.fill(0), n(e, (c, h, f) => { const p = a++; if (s[p] = c << dt | f, l === -1 && (l = h), o[p] = i, c === u) { const g = o[i]; o[i] = p, i = g, u = Ft[s[g] >> dt]; } else Fn(c) && (i = p, u = Ft[c]); }), s[a] = At << dt | r, o[a] = a; for (let c = 0; c < a; c++) { const h = o[c]; if (h <= c) { const f = o[h]; f !== c && (o[c] = f); } else h > a && (o[c] = a); } this.source = e, this.firstCharOffset = l === -1 ? 0 : l, this.tokenCount = a, this.offsetAndType = s, this.balance = o, this.reset(), this.next(); } lookupType(e) { return e += this.tokenIndex, e < this.tokenCount ? this.offsetAndType[e] >> dt : At; } lookupTypeNonSC(e) { for (let n = this.tokenIndex; n < this.tokenCount; n++) { const r = this.offsetAndType[n] >> dt; if (r !== U && r !== Y && e-- === 0) return r; } return At; } lookupOffset(e) { return e += this.tokenIndex, e < this.tokenCount ? this.offsetAndType[e - 1] & pt : this.source.length; } lookupOffsetNonSC(e) { for (let n = this.tokenIndex; n < this.tokenCount; n++) { const r = this.offsetAndType[n] >> dt; if (r !== U && r !== Y && e-- === 0) return n - this.tokenIndex; } return At; } lookupValue(e, n) { return e += this.tokenIndex, e < this.tokenCount ? ve( this.source, this.offsetAndType[e - 1] & pt, this.offsetAndType[e] & pt, n ) : !1; } getTokenStart(e) { return e === this.tokenIndex ? this.tokenStart : e > 0 ? e < this.tokenCount ? this.offsetAndType[e - 1] & pt : this.offsetAndType[this.tokenCount] & pt : this.firstCharOffset; } substrToCursor(e) { return this.source.substring(e, this.tokenStart); } isBalanceEdge(e) { return this.balance[this.tokenIndex] < e; } isDelim(e, n) { return n ? this.lookupType(n) === P && this.source.charCodeAt(this.lookupOffset(n)) === e : this.tokenType === P && this.source.charCodeAt(this.tokenStart) === e; } skip(e) { let n = this.tokenIndex + e; n < this.tokenCount ? (this.tokenIndex = n, this.tokenStart = this.offsetAndType[n - 1] & pt, n = this.offsetAndType[n], this.tokenType = n >> dt, this.tokenEnd = n & pt) : (this.tokenIndex = this.tokenCount, this.next()); } next() { let e = this.tokenIndex + 1; e < this.tokenCount ? (this.tokenIndex = e, this.tokenStart = this.tokenEnd, e = this.offsetAndType[e], this.tokenType = e >> dt, this.tokenEnd = e & pt) : (this.eof = !0, this.tokenIndex = this.tokenCount, this.tokenType = At, this.tokenStart = this.tokenEnd = this.source.length); } skipSC() { for (; this.tokenType === U || this.tokenType === Y; ) this.next(); } skipUntilBalanced(e, n) { let r = e, s = 0, o = 0; t: for (; r < this.tokenCount; r++) { if (s = this.balance[r], s < e) break t; switch (o = r > 0 ? this.offsetAndType[r - 1] & pt : this.firstCharOffset, n(this.source.charCodeAt(o))) { case 1: break t; case 2: r++; break t; default: Fn(this.offsetAndType[r] >> dt) && (r = s); } } this.skip(r - this.tokenIndex); } forEachToken(e) { for (let n = 0, r = this.firstCharOffset; n < this.tokenCount; n++) { const s = r, o = this.offsetAndType[n], a = o & pt, l = o >> dt; r = a, e(l, s, a, n); } } dump() { const e = new Array(this.tokenCount); return this.forEachToken((n, r, s, o) => { e[o] = { idx: o, type: Gr[n], chunk: this.source.substring(r, s), balance: this.balance[o] }; }), e; } } function qr(t, e) { function n(h) { return h < l ? t.charCodeAt(h) : 0; } function r() { if (i = Hr(t, i), Ne(n(i), n(i + 1), n(i + 2))) { c = $, i = pe(t, i); return; } if (n(i) === 37) { c = F, i++; return; } c = x; } function s() { const h = i; if (i = pe(t, i), ve(t, h, i, "url") && n(i) === 40) { if (i = fe(t, i + 1), n(i) === 34 || n(i) === 39) { c = T, i = h + 4; return; } a(); return; } if (n(i) === 40) { c = T, i++; return; } c = d; } function o(h) { for (h || (h = n(i++)), c = wt; i < t.length; i++) { const f = t.charCodeAt(i); switch (Fe(f)) { // ending code point case h: i++; return; // EOF // case EofCategory: // This is a parse error. Return the <string-token>. // return; // newline case ke: if (Ae(f)) { i += rn(t, i, f), c = zo; return; } break; // U+005C REVERSE SOLIDUS (\) case 92: if (i === t.length - 1) break; const p = n(i + 1); Ae(p) ? i += rn(t, i + 1, p) : mt(f, p) && (i = Xt(t, i) - 1); break; } } } function a() { for (c = Q, i = fe(t, i); i < t.length; i++) { const h = t.charCodeAt(i); switch (Fe(h)) { // U+0029 RIGHT PARENTHESIS ()) case 41: i++; return; // EOF // case EofCategory: // This is a parse error. Return the <url-token>. // return; // whitespace case ke: if (i = fe(t, i), n(i) === 41 || i >= t.length) { i < t.length && i++; return; } i = je(t, i), c = ot; return; // U+0022 QUOTATION MARK (") // U+0027 APOSTROPHE (') // U+0028 LEFT PARENTHESIS (() // non-printable code point case 34: case 39: case 40: case Wr: i = je(t, i), c = ot; return; // U+005C REVERSE SOLIDUS (\) case 92: if (mt(h, n(i + 1))) { i = Xt(t, i) - 1; break; } i = je(t, i), c = ot; return; } } } t = String(t || ""); const l = t.length; let u = Br(n(0)), i = u, c; for (; i < l; ) { const h = t.charCodeAt(i); switch (Fe(h)) { // whitespace case ke: c = U, i = fe(t, i + 1); break; // U+0022 QUOTATION MARK (") case 34: o(); break; // U+0023 NUMBER SIGN (#) case 35: jr(n(i + 1)) || mt(n(i + 1), n(i + 2)) ? (c = N, i = pe(t, i + 1)) : (c = P, i++); break; // U+0027 APOSTROPHE (') case 39: o(); break; // U+0028 LEFT PARENTHESIS (() case 40: c = I, i++; break; // U+0029 RIGHT PARENTHESIS ()) case 41: c = y, i++; break; // U+002B PLUS SIGN (+) case 43: De(h, n(i + 1), n(i + 2)) ? r() : (c = P, i++); break; // U+002C COMMA (,) case 44: c = ht, i++; break; // U+002D HYPHEN-MINUS (-) case 45: De(h, n(i + 1), n(i + 2)) ? r() : n(i + 1) === 45 && n(i + 2) === 62 ? (c = et, i = i + 3) : Ne(h, n(i + 1), n(i + 2)) ? s() : (c = P, i++); break; // U+002E FULL STOP (.) case 46: De(h, n(i + 1), n(i + 2)) ? r() : (c = P, i++); break; // U+002F SOLIDUS (/) case 47: n(i + 1) === 42 ? (c = Y, i = t.indexOf("*/", i + 2), i = i === -1 ? t.length : i + 2) : (c = P, i++); break; // U+003A COLON (:) case 58: c = X, i++; break; // U+003B SEMICOLON (;) case 59: c = tt, i++; break; // U+003C LESS-THAN SIGN (<) case 60: n(i + 1) === 33 && n(i + 2) === 45 && n(i + 3) === 45 ? (c = Ie, i = i + 4) : (c = P, i++); break; // U+0040 COMMERCIAL AT (@) case 64: Ne(n(i + 1), n(i + 2), n(i + 3)) ? (c = z, i = pe(t, i + 1)) : (c = P, i++); break; // U+005B LEFT SQUARE BRACKET ([) case 91: c = te, i++; break; // U+005C REVERSE SOLIDUS (\) case 92: mt(h, n(i + 1)) ? s() : (c = P, i++); break; // U+005D RIGHT SQUARE BRACKET (]) case 93: c = ae, i++; break; // U+007B LEFT CURLY BRACKET ({) case 123: c = ut, i++; break; // U+007D RIGHT CURLY BRACKET (}) case 125: c = Qt, i++; break; // digit case Ur: r(); break; // name-start code point case bn: s(); break; // EOF // case EofCategory: // Return an <EOF-token>. // break; // anything else default: c = P, i++; } e(c, u, u = i); } } const gt = 43, nt = 45, Se = 110, Rt = !0, ea = !1; function ye(t, e) { let n = this.tokenStart + t; const r = this.charCodeAt(n); for ((r === gt || r === nt) && (e && this.error("Number sign is not allowed"), n++); n < this.tokenEnd; n++) rt(this.charCodeAt(n)) || this.error("Integer is expected", n); } function zt(t) { return ye.call(this, 0, t); } function Tt(t, e) { if (!this.cmpChar(this.tokenStart + t, e)) { let n = ""; switch (e) { case Se: n = "N is expected"; break; case nt: n = "HyphenMinus is expected"; break; } this.error(n, this.tokenStart + t); } } function Be() { let t = 0, e = 0, n = this.tokenType; for (; n === U || n === Y; ) n = this.lookupType(++t); if (n !== x) if (this.isDelim(gt, t) || this.isDelim(nt, t)) { e = this.isDelim(gt, t) ? gt : nt; do n = this.lookupType(++t); while (n === U || n === Y); n !== x && (this.skip(t), zt.call(this, Rt)); } else return null; return t > 0 && this.skip(t), e === 0 && (n = this.charCodeAt(this.tokenStart), n !== gt && n !== nt && this.error("Number sign is expected")), zt.call(this, e !== 0), e === nt ? "-" + this.consume(x) : this.consume(x); } const na = "AnPlusB", ra = { a: [String, null], b: [String, null] }; function Kr() { const t = this.tokenStart; let e = null, n = null; if (this.tokenType === x) zt.call(this, ea), n = this.consume(x); else if (this.tokenType === d && this.cmpChar(this.tokenStart, nt)) switch (e = "-1", Tt.call(this, 1, Se), this.tokenEnd - this.tokenStart) { // -n // -n <signed-integer> // -n ['+' | '-'] <signless-integer> case 2: this.next(), n = Be.call(this); break; // -n- <signless-integer> case 3: Tt.call(this, 2, nt), this.next(), this.skipSC(), zt.call(this, Rt), n = "-" + this.consume(x); break; // <dashndashdigit-ident> default: Tt.call(this, 2, nt), ye.call(this, 3, Rt), this.next(), n = this.substrToCursor(t + 2); } else if (this.tokenType === d || this.isDelim(gt) && this.lookupType(1) === d) { let r = 0; switch (e = "1", this.isDelim(gt) && (r = 1, this.next()), Tt.call(this, 0, Se), this.tokenEnd - this.tokenStart) { // '+'? n // '+'? n <signed-integer> // '+'? n ['+' | '-'] <signless-integer> case 1: this.next(), n = Be.call(this); break; // '+'? n- <signless-integer> case 2: Tt.call(this, 1, nt), this.next(), this.skipSC(), zt.call(this, Rt), n = "-" + this.consume(x); break; // '+'? <ndashdigit-ident> default: Tt.call(this, 1, nt), ye.call(this, 2, Rt), this.next(), n = this.substrToCursor(t + r + 1); } } else if (this.tokenType === $) { const r = this.charCodeAt(this.tokenStart), s = r === gt || r === nt; let o = this.tokenStart + s; for (; o < this.tokenEnd && rt(this.charCodeAt(o)); o++) ; o === this.tokenStart + s && this.error("Integer is expected", this.tokenStart + s), Tt.call(this, o - this.tokenStart, Se), e = this.substring(t, o), o + 1 === this.tokenEnd ? (this.next(), n = Be.call(this)) : (Tt.call(this, o - this.tokenStart + 1, nt), o + 2 === this.tokenEnd ? (this.next(), this.skipSC(), zt.call(this, Rt), n = "-" + this.consume(x)) : (ye.call(this, o - this.tokenStart + 2, Rt), this.next(), n = this.substrToCursor(o + 1))); } else this.error(); return e !== null && e.charCodeAt(0) === gt && (e = e.substr(1)), n !== null && n.charCodeAt(0) === gt && (n = n.substr(1)), { type: "AnPlusB", loc: this.getLocation(t, this.tokenStart), a: e, b: n }; } function Qr(t) { if (t.a) { const e = t.a === "+1" && "n" || t.a === "1" && "n" || t.a === "-1" && "-n" || t.a + "n"; if (t.b) { const n = t.b[0] === "-" || t.b[0] === "+" ? t.b : "+" + t.b; this.tokenize(e + n); } else this.tokenize(e); } else this.tokenize(t.b); } const sa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: Qr, name: na, parse: Kr, structure: ra }, Symbol.toStringTag, { value: "Module" })); function Mn() { return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon, !0); } function ia() { for (let t = 1, e; e = this.lookupType(t); t++) { if (e === Qt) return !0; if (e === ut || e === z) return !1; } return !1; } const oa = "Atrule", aa = "atrule", la = { name: String, prelude: ["AtrulePrelude", "Raw", null], block: ["Block", null] }; function Yr(t = !1) { const e = this.tokenStart; let n, r, s = null, o = null; switch (this.eat(z), n = this.substrToCursor(e + 1), r = n.toLowerCase(), this.skipSC(), this.eof === !1 && this.tokenType !== ut && this.tokenType !== tt && (this.parseAtrulePrelude ? s = this.parseWithFallback(this.AtrulePrelude.bind(this, n, t), Mn) : s = Mn.call(this, this.tokenIndex), this.skipSC()), this.tokenType) { case tt: this.next(); break; case ut: hasOwnProperty.call(this.atrule, r) && typeof this.atrule[r].block == "function" ? o = this.atrule[r].block.call(this, t) : o = this.Block(ia.call(this)); break; } return { type: "Atrule", loc: this.getLocation(e, this.tokenStart), name: n, prelude: s, block: o }; } function Xr(t) { this.token(z, "@" + t.name), t.prelude !== null && this.node(t.prelude), t.block ? this.node(t.block) : this.token(tt, ";"); } const ca = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: Xr, name: oa, parse: Yr, structure: la, walkContext: aa }, Symbol.toStringTag, { value: "Module" })), ua = "AtrulePrelude", ha = "atrulePrelude", fa = { children: [[]] }; function Jr(t) { let e = null; return t !== null && (t = t.toLowerCase()), this.skipSC(), hasOwnProperty.call(this.atrule, t) && typeof this.atrule[t].prelude == "function" ? e = this.atrule[t].prelude.call(this) : e = this.readSequence(this.scope.AtrulePrelude), this.skipSC(), this.eof !== !0 && this.tokenType !== ut && this.tokenType !== tt && this.error("Semicolon or block is expected"), { type: "AtrulePrelude", loc: this.getLocationFromList(e), children: e }; } function Zr(t) { this.children(t); } const pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: Zr, name: ua, parse: Jr, structure: fa, walkContext: ha }, Symbol.toStringTag, { value: "Module" })), da = 36, ts = 42, be = 61, ga = 94, sn = 124, ma = 126; function ka() { this.eof && this.error("Unexpected end of input"); const t = this.tokenStart; let e = !1; return this.isDelim(ts) ? (e = !0, this.next()) : this.isDelim(sn) || this.eat(d), this.isDelim(sn) ? this.charCodeAt(this.tokenStart + 1) !== be ? (this.next(), this.eat(d)) : e && this.error("Identifier is expected", this.tokenEnd) : e && this.error("Vertical line is expected"), { type: "Identifier", loc: this.getLocation(t, this.tokenStart), name: this.substrToCursor(t) }; } function Sa() { const t = this.tokenStart, e = this.charCodeAt(t); return e !== be && // = e !== ma && // ~= e !== ga && // ^= e !== da && // $= e !== ts && // *= e !== sn && this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"), this.next(), e !== be && (this.isDelim(be) || this.error("Equal sign is expected"), this.next()), this.substrToCursor(t); } const ya = "AttributeSelector", ba = { name: "Identifier", matcher: [String, null], value: ["String", "Identifier", null], flags: [String, null] }; function es() { const t = this.tokenStart; let e, n = null, r = null, s = null; return this.eat(te), this.skipSC(), e = ka.call(this), this.skipSC(), this.tokenType !== ae && (this.tokenType !== d && (n = Sa.call(this), this.skipSC(), r = this.tokenType === wt ? this.String() : this.Identifier(), this.skipSC()), this.tokenType === d && (s = this.consume(d), this.skipSC())), this.eat(ae), { type: "AttributeSelector", loc: this.getLocation(t, this.tokenStart), name: e, matcher: n, value: r, flags: s }; } function ns(t) { this.token(P, "["), this.node(t.name), t.matcher !== null && (this.tokenize(t.matcher), this.node(t.value)), t.flags !== null && this.token(d, t.flags), this.token(P, "]"); } const xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: ns, name: ya, parse: es, structure: ba }, Symbol.toStringTag, { value: "Module" })), Ca = 38; function rs() { return this.Raw(null, !0); } function jn() { return this.parseWithFallback(this.Rule, rs); } function Bn() { return this.Raw(this.consumeUntilSemicolonIncluded, !0); } function wa() { if (this.tokenType === tt) return Bn.call(this, this.tokenIndex); const t = this.parseWithFallback(this.Declaration, Bn); return this.tokenType === tt && this.next(), t; } const Ta = "Block", Aa = "block", va = { children: [[ "Atrule", "Rule", "Declaration" ]] }; function ss(t) { const e = t ? wa : jn, n = this.tokenStart; let r = this.createList(); this.eat(ut); t: for (; !this.eof; ) switch (this.tokenType) { case Qt: break t; case U: case Y: this.next(); break; case z: r.push(this.parseWithFallback(this.Atrule.bind(this, t), rs)); break; default: t && this.isDelim(Ca) ? r.push(jn.call(this)) : r.push(e.call(this)); } return this.eof || this.eat(Qt), { type: "Block", loc: this.getLocation(n, this.tokenStart), children: r }; } function is(t) { this.token(ut, "{"), this.children(t, (e) => { e.type === "Declaration" && this.token(tt, ";"); }), this.token(Qt, "}"); } const Ea = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: is, name: Ta, parse: ss, structure: va, walkContext: Aa }, Symbol.toStringTag, { value: "Module" })), $a = "Brackets", La = { children: [[]] }; function os(t, e) { const n = this.tokenStart; let r = null; return this.eat(te), r = t.call(this, e), this.eof || this.eat(ae), { type: "Brackets", loc: this.getLocation(n, this.tokenStart), children: r }; } function as(t) { this.token(P, "["), this.children(t), this.token(P, "]"); } const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: as, name: $a, parse: os, structure: La }, Symbol.toStringTag, { value: "Module" })), Oa = "CDC", Ra = []; function ls() { const t = this.tokenStart; return this.eat(et), { type: "CDC", loc: this.getLocation(t, this.tokenStart) }; } function cs() { this.token(et, "-->"); } const Ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: cs, name: Oa, parse: ls, structure: Ra }, Symbol.toStringTag, { value: "Module" })), _a = "CDO", Na = []; function us() { const t = this.tokenStart; return this.eat(Ie), { type: "CDO", loc: this.getLocation(t, this.tokenStart) }; } function hs() { this.token(Ie, "<!--"); } const Da = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: hs, name: _a, parse: us, structure: Na }, Symbol.toStringTag, { value: "Module" })), Fa = 46, Ma = "ClassSelector", ja = { name: String }; function fs() { return this.eatDelim(Fa), { type: "ClassSelector", loc: this.getLocation(this.tokenStart - 1, this.tokenEnd), name: this.consume(d) }; } function ps(t) { this.token(P, "."), this.token(d, t.name); } const Ba = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: ps, name: Ma, parse: fs, structure: ja }, Symbol.toStringTag, { value: "Module" })), Ua = 43, Un = 47, Wa = 62, za = 126, Ha = "Combinator", Va = { name: String }; function ds() { const t = this.tokenStart; let e; switch (this.tokenType) { case U: e = " "; break; case P: switch (this.charCodeAt(this.tokenStart)) { case Wa: case Ua: case za: this.next(); break; case Un: this.next(), this.eatIdent("deep"), this.eatDelim(Un); break; default: this.error("Combinator is expected"); } e = this.substrToCursor(t); break; } return { type: "Combinator", loc: this.getLocation(t, this.tokenStart), name: e }; } function gs(t) { this.tokenize(t.name); } const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: gs, name: Ha, parse: ds, structure: Va }, Symbol.toStringTag, { value: "Module" })), qa = 42, Ka = 47, Qa = "Comment", Ya = { value: String }; function ms() { const t = this.tokenStart; let e = this.tokenEnd; return this.eat(Y), e - t + 2 >= 2 && this.charCodeAt(e - 2) === qa && this.charCodeAt(e - 1) === Ka && (e -= 2), { type: "Comment", loc: this.getLocation(t, this.tokenStart), value: this.substring(t + 2, e) }; } function ks(t) { this.token(Y, "/*" + t.value + "*/"); } const Xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: ks, name: Qa, parse: ms, structure: Ya }, Symbol.toStringTag, { value: "Module" })), Ja = /* @__PURE__ */ new Set([X, y, At]), Za = "Condition", tl = { kind: String, children: [[ "Identifier", "Feature", "FeatureFunction", "FeatureRange", "SupportsDeclaration" ]] }; function Wn(t) { return this.lookupTypeNonSC(1) === d && Ja.has(this.lookupTypeNonSC(2)) ? this.Feature(t) : this.FeatureRange(t); } const el = { media: Wn, container: Wn, supports() { return this.SupportsDeclaration(); } }; function Ss(t = "media") { const e = this.createList(); t: for (; !this.eof; ) switch (this.tokenType) { case Y: case U: this.next(); continue; case d: e.push(this.Identifier()); break; case I: { let n = this.parseWithFallback( () => el[t].call(this, t), () => null ); n || (n = this.parseWithFallback( () => { this.eat(I); const r = this.Condition(t); return this.eat(y), r; }, () => this.GeneralEnclosed(t) )), e.push(n); break; } case T: { let n = this.parseWithFallback( () => this.FeatureFunction(t), () => null ); n || (n = this.GeneralEnclosed(t)), e.push(n); break; } default: break t; } return e.isEmpty && this.error("Condition is expected"), { type: "Condition", loc: this.getLocationFromList(e), kind: t, children: e }; } function ys(t) { t.children.forEach((e) => { e.type === "Condition" ? (this.token(I, "("), this.node(e), this.token(y, ")")) : this.node(e); }); } const nl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, generate: ys, name: Z