@react-email/tailwind
Version:
A React component to wrap emails with Tailwind CSS
1,514 lines (1,513 loc) • 492 kB
JavaScript
import { jsx as Ms } from "react/jsx-runtime";
import * as mr from "react";
import gt from "react";
var ni = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Qe(s) {
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
}
function Is(s) {
if (s.__esModule)
return s;
var e = s.default;
if (typeof e == "function") {
var t = function r() {
return this instanceof r ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
};
t.prototype = e.prototype;
} else
t = {};
return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(s).forEach(function(r) {
var n = Object.getOwnPropertyDescriptor(s, r);
Object.defineProperty(t, r, n.get ? n : {
enumerable: !0,
get: function() {
return s[r];
}
});
}), t;
}
var bn = { exports: {} }, Re = String, Di = function() {
return { isColorSupported: !1, reset: Re, bold: Re, dim: Re, italic: Re, underline: Re, inverse: Re, hidden: Re, strikethrough: Re, black: Re, red: Re, green: Re, yellow: Re, blue: Re, magenta: Re, cyan: Re, white: Re, gray: Re, bgBlack: Re, bgRed: Re, bgGreen: Re, bgYellow: Re, bgBlue: Re, bgMagenta: Re, bgCyan: Re, bgWhite: Re };
};
bn.exports = Di();
bn.exports.createColors = Di;
var Rs = bn.exports;
const $s = {}, Ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: $s
}, Symbol.toStringTag, { value: "Module" })), Le = /* @__PURE__ */ Is(Ds);
let ii = Rs, ai = Le, Dr = class Ni extends Error {
constructor(e, t, r, n, l, i) {
super(e), this.name = "CssSyntaxError", this.reason = e, l && (this.file = l), n && (this.source = n), i && (this.plugin = i), typeof t < "u" && typeof r < "u" && (typeof t == "number" ? (this.line = t, this.column = r) : (this.line = t.line, this.column = t.column, this.endLine = r.line, this.endColumn = r.column)), this.setMessage(), Error.captureStackTrace && Error.captureStackTrace(this, Ni);
}
setMessage() {
this.message = this.plugin ? this.plugin + ": " : "", this.message += this.file ? this.file : "<css input>", typeof this.line < "u" && (this.message += ":" + this.line + ":" + this.column), this.message += ": " + this.reason;
}
showSourceCode(e) {
if (!this.source)
return "";
let t = this.source;
e == null && (e = ii.isColorSupported), ai && e && (t = ai(t));
let r = t.split(/\r?\n/), n = Math.max(this.line - 3, 0), l = Math.min(this.line + 2, r.length), i = String(l).length, c, a;
if (e) {
let { bold: o, gray: f, red: u } = ii.createColors(!0);
c = (p) => o(u(p)), a = (p) => f(p);
} else
c = a = (o) => o;
return r.slice(n, l).map((o, f) => {
let u = n + 1 + f, p = " " + (" " + u).slice(-i) + " | ";
if (u === this.line) {
let _ = a(p.replace(/\d/g, " ")) + o.slice(0, this.column - 1).replace(/[^\t]/g, " ");
return c(">") + a(p) + o + `
` + _ + c("^");
}
return " " + a(p) + o;
}).join(`
`);
}
toString() {
let e = this.showSourceCode();
return e && (e = `
` + e + `
`), this.name + ": " + this.message + e;
}
};
var xn = Dr;
Dr.default = Dr;
var _t = {};
_t.isClean = Symbol("isClean");
_t.my = Symbol("my");
const si = {
after: `
`,
beforeClose: `
`,
beforeComment: `
`,
beforeDecl: `
`,
beforeOpen: " ",
beforeRule: `
`,
colon: ": ",
commentLeft: " ",
commentRight: " ",
emptyBody: "",
indent: " ",
semicolon: !1
};
function Ns(s) {
return s[0].toUpperCase() + s.slice(1);
}
let Nr = class {
constructor(e) {
this.builder = e;
}
atrule(e, t) {
let r = "@" + e.name, n = e.params ? this.rawValue(e, "params") : "";
if (typeof e.raws.afterName < "u" ? r += e.raws.afterName : n && (r += " "), e.nodes)
this.block(e, r + n);
else {
let l = (e.raws.between || "") + (t ? ";" : "");
this.builder(r + n + l, e);
}
}
beforeAfter(e, t) {
let r;
e.type === "decl" ? r = this.raw(e, null, "beforeDecl") : e.type === "comment" ? r = this.raw(e, null, "beforeComment") : t === "before" ? r = this.raw(e, null, "beforeRule") : r = this.raw(e, null, "beforeClose");
let n = e.parent, l = 0;
for (; n && n.type !== "root"; )
l += 1, n = n.parent;
if (r.includes(`
`)) {
let i = this.raw(e, null, "indent");
if (i.length)
for (let c = 0; c < l; c++)
r += i;
}
return r;
}
block(e, t) {
let r = this.raw(e, "between", "beforeOpen");
this.builder(t + r + "{", e, "start");
let n;
e.nodes && e.nodes.length ? (this.body(e), n = this.raw(e, "after")) : n = this.raw(e, "after", "emptyBody"), n && this.builder(n), this.builder("}", e, "end");
}
body(e) {
let t = e.nodes.length - 1;
for (; t > 0 && e.nodes[t].type === "comment"; )
t -= 1;
let r = this.raw(e, "semicolon");
for (let n = 0; n < e.nodes.length; n++) {
let l = e.nodes[n], i = this.raw(l, "before");
i && this.builder(i), this.stringify(l, t !== n || r);
}
}
comment(e) {
let t = this.raw(e, "left", "commentLeft"), r = this.raw(e, "right", "commentRight");
this.builder("/*" + t + e.text + r + "*/", e);
}
decl(e, t) {
let r = this.raw(e, "between", "colon"), n = e.prop + r + this.rawValue(e, "value");
e.important && (n += e.raws.important || " !important"), t && (n += ";"), this.builder(n, e);
}
document(e) {
this.body(e);
}
raw(e, t, r) {
let n;
if (r || (r = t), t && (n = e.raws[t], typeof n < "u"))
return n;
let l = e.parent;
if (r === "before" && (!l || l.type === "root" && l.first === e || l && l.type === "document"))
return "";
if (!l)
return si[r];
let i = e.root();
if (i.rawCache || (i.rawCache = {}), typeof i.rawCache[r] < "u")
return i.rawCache[r];
if (r === "before" || r === "after")
return this.beforeAfter(e, r);
{
let c = "raw" + Ns(r);
this[c] ? n = this[c](i, e) : i.walk((a) => {
if (n = a.raws[t], typeof n < "u")
return !1;
});
}
return typeof n > "u" && (n = si[r]), i.rawCache[r] = n, n;
}
rawBeforeClose(e) {
let t;
return e.walk((r) => {
if (r.nodes && r.nodes.length > 0 && typeof r.raws.after < "u")
return t = r.raws.after, t.includes(`
`) && (t = t.replace(/[^\n]+$/, "")), !1;
}), t && (t = t.replace(/\S/g, "")), t;
}
rawBeforeComment(e, t) {
let r;
return e.walkComments((n) => {
if (typeof n.raws.before < "u")
return r = n.raws.before, r.includes(`
`) && (r = r.replace(/[^\n]+$/, "")), !1;
}), typeof r > "u" ? r = this.raw(t, null, "beforeDecl") : r && (r = r.replace(/\S/g, "")), r;
}
rawBeforeDecl(e, t) {
let r;
return e.walkDecls((n) => {
if (typeof n.raws.before < "u")
return r = n.raws.before, r.includes(`
`) && (r = r.replace(/[^\n]+$/, "")), !1;
}), typeof r > "u" ? r = this.raw(t, null, "beforeRule") : r && (r = r.replace(/\S/g, "")), r;
}
rawBeforeOpen(e) {
let t;
return e.walk((r) => {
if (r.type !== "decl" && (t = r.raws.between, typeof t < "u"))
return !1;
}), t;
}
rawBeforeRule(e) {
let t;
return e.walk((r) => {
if (r.nodes && (r.parent !== e || e.first !== r) && typeof r.raws.before < "u")
return t = r.raws.before, t.includes(`
`) && (t = t.replace(/[^\n]+$/, "")), !1;
}), t && (t = t.replace(/\S/g, "")), t;
}
rawColon(e) {
let t;
return e.walkDecls((r) => {
if (typeof r.raws.between < "u")
return t = r.raws.between.replace(/[^\s:]/g, ""), !1;
}), t;
}
rawEmptyBody(e) {
let t;
return e.walk((r) => {
if (r.nodes && r.nodes.length === 0 && (t = r.raws.after, typeof t < "u"))
return !1;
}), t;
}
rawIndent(e) {
if (e.raws.indent)
return e.raws.indent;
let t;
return e.walk((r) => {
let n = r.parent;
if (n && n !== e && n.parent && n.parent === e && typeof r.raws.before < "u") {
let l = r.raws.before.split(`
`);
return t = l[l.length - 1], t = t.replace(/\S/g, ""), !1;
}
}), t;
}
rawSemicolon(e) {
let t;
return e.walk((r) => {
if (r.nodes && r.nodes.length && r.last.type === "decl" && (t = r.raws.semicolon, typeof t < "u"))
return !1;
}), t;
}
rawValue(e, t) {
let r = e[t], n = e.raws[t];
return n && n.value === r ? n.raw : r;
}
root(e) {
this.body(e), e.raws.after && this.builder(e.raws.after);
}
rule(e) {
this.block(e, this.rawValue(e, "selector")), e.raws.ownSemicolon && this.builder(e.raws.ownSemicolon, e, "end");
}
stringify(e, t) {
if (!this[e.type])
throw new Error(
"Unknown AST node type " + e.type + ". Maybe you need to change PostCSS stringifier."
);
this[e.type](e, t);
}
};
var Li = Nr;
Nr.default = Nr;
let Ls = Li;
function Lr(s, e) {
new Ls(e).stringify(s);
}
var Kt = Lr;
Lr.default = Lr;
let { isClean: Mt, my: Fs } = _t, zs = xn, Us = Li, js = Kt;
function Fr(s, e) {
let t = new s.constructor();
for (let r in s) {
if (!Object.prototype.hasOwnProperty.call(s, r) || r === "proxyCache")
continue;
let n = s[r], l = typeof n;
r === "parent" && l === "object" ? e && (t[r] = e) : r === "source" ? t[r] = n : Array.isArray(n) ? t[r] = n.map((i) => Fr(i, t)) : (l === "object" && n !== null && (n = Fr(n)), t[r] = n);
}
return t;
}
let zr = class {
constructor(e = {}) {
this.raws = {}, this[Mt] = !1, this[Fs] = !0;
for (let t in e)
if (t === "nodes") {
this.nodes = [];
for (let r of e[t])
typeof r.clone == "function" ? this.append(r.clone()) : this.append(r);
} else
this[t] = e[t];
}
addToError(e) {
if (e.postcssNode = this, e.stack && this.source && /\n\s{4}at /.test(e.stack)) {
let t = this.source;
e.stack = e.stack.replace(
/\n\s{4}at /,
`$&${t.input.from}:${t.start.line}:${t.start.column}$&`
);
}
return e;
}
after(e) {
return this.parent.insertAfter(this, e), this;
}
assign(e = {}) {
for (let t in e)
this[t] = e[t];
return this;
}
before(e) {
return this.parent.insertBefore(this, e), this;
}
cleanRaws(e) {
delete this.raws.before, delete this.raws.after, e || delete this.raws.between;
}
clone(e = {}) {
let t = Fr(this);
for (let r in e)
t[r] = e[r];
return t;
}
cloneAfter(e = {}) {
let t = this.clone(e);
return this.parent.insertAfter(this, t), t;
}
cloneBefore(e = {}) {
let t = this.clone(e);
return this.parent.insertBefore(this, t), t;
}
error(e, t = {}) {
if (this.source) {
let { end: r, start: n } = this.rangeBy(t);
return this.source.input.error(
e,
{ column: n.column, line: n.line },
{ column: r.column, line: r.line },
t
);
}
return new zs(e);
}
getProxyProcessor() {
return {
get(e, t) {
return t === "proxyOf" ? e : t === "root" ? () => e.root().toProxy() : e[t];
},
set(e, t, r) {
return e[t] === r || (e[t] = r, (t === "prop" || t === "value" || t === "name" || t === "params" || t === "important" || /* c8 ignore next */
t === "text") && e.markDirty()), !0;
}
};
}
markDirty() {
if (this[Mt]) {
this[Mt] = !1;
let e = this;
for (; e = e.parent; )
e[Mt] = !1;
}
}
next() {
if (!this.parent)
return;
let e = this.parent.index(this);
return this.parent.nodes[e + 1];
}
positionBy(e, t) {
let r = this.source.start;
if (e.index)
r = this.positionInside(e.index, t);
else if (e.word) {
t = this.toString();
let n = t.indexOf(e.word);
n !== -1 && (r = this.positionInside(n, t));
}
return r;
}
positionInside(e, t) {
let r = t || this.toString(), n = this.source.start.column, l = this.source.start.line;
for (let i = 0; i < e; i++)
r[i] === `
` ? (n = 1, l += 1) : n += 1;
return { column: n, line: l };
}
prev() {
if (!this.parent)
return;
let e = this.parent.index(this);
return this.parent.nodes[e - 1];
}
rangeBy(e) {
let t = {
column: this.source.start.column,
line: this.source.start.line
}, r = this.source.end ? {
column: this.source.end.column + 1,
line: this.source.end.line
} : {
column: t.column + 1,
line: t.line
};
if (e.word) {
let n = this.toString(), l = n.indexOf(e.word);
l !== -1 && (t = this.positionInside(l, n), r = this.positionInside(l + e.word.length, n));
} else
e.start ? t = {
column: e.start.column,
line: e.start.line
} : e.index && (t = this.positionInside(e.index)), e.end ? r = {
column: e.end.column,
line: e.end.line
} : typeof e.endIndex == "number" ? r = this.positionInside(e.endIndex) : e.index && (r = this.positionInside(e.index + 1));
return (r.line < t.line || r.line === t.line && r.column <= t.column) && (r = { column: t.column + 1, line: t.line }), { end: r, start: t };
}
raw(e, t) {
return new Us().raw(this, e, t);
}
remove() {
return this.parent && this.parent.removeChild(this), this.parent = void 0, this;
}
replaceWith(...e) {
if (this.parent) {
let t = this, r = !1;
for (let n of e)
n === this ? r = !0 : r ? (this.parent.insertAfter(t, n), t = n) : this.parent.insertBefore(t, n);
r || this.remove();
}
return this;
}
root() {
let e = this;
for (; e.parent && e.parent.type !== "document"; )
e = e.parent;
return e;
}
toJSON(e, t) {
let r = {}, n = t == null;
t = t || /* @__PURE__ */ new Map();
let l = 0;
for (let i in this) {
if (!Object.prototype.hasOwnProperty.call(this, i) || i === "parent" || i === "proxyCache")
continue;
let c = this[i];
if (Array.isArray(c))
r[i] = c.map((a) => typeof a == "object" && a.toJSON ? a.toJSON(null, t) : a);
else if (typeof c == "object" && c.toJSON)
r[i] = c.toJSON(null, t);
else if (i === "source") {
let a = t.get(c.input);
a == null && (a = l, t.set(c.input, l), l++), r[i] = {
end: c.end,
inputId: a,
start: c.start
};
} else
r[i] = c;
}
return n && (r.inputs = [...t.keys()].map((i) => i.toJSON())), r;
}
toProxy() {
return this.proxyCache || (this.proxyCache = new Proxy(this, this.getProxyProcessor())), this.proxyCache;
}
toString(e = js) {
e.stringify && (e = e.stringify);
let t = "";
return e(this, (r) => {
t += r;
}), t;
}
warn(e, t, r) {
let n = { node: this };
for (let l in r)
n[l] = r[l];
return e.warn(t, n);
}
get proxyOf() {
return this;
}
};
var Xt = zr;
zr.default = zr;
let Vs = Xt, Ur = class extends Vs {
constructor(e) {
e && typeof e.value < "u" && typeof e.value != "string" && (e = { ...e, value: String(e.value) }), super(e), this.type = "decl";
}
get variable() {
return this.prop.startsWith("--") || this.prop[0] === "$";
}
};
var Zt = Ur;
Ur.default = Ur;
let Ws = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", Bs = (s, e = 21) => (t = e) => {
let r = "", n = t;
for (; n--; )
r += s[Math.random() * s.length | 0];
return r;
}, qs = (s = 21) => {
let e = "", t = s;
for (; t--; )
e += Ws[Math.random() * 64 | 0];
return e;
};
var Gs = { nanoid: qs, customAlphabet: Bs };
let { SourceMapConsumer: oi, SourceMapGenerator: li } = Le, { existsSync: Ys, readFileSync: Hs } = Le, { dirname: gr, join: Qs } = Le;
function Js(s) {
return Buffer ? Buffer.from(s, "base64").toString() : window.atob(s);
}
let jr = class {
constructor(e, t) {
if (t.map === !1)
return;
this.loadAnnotation(e), this.inline = this.startWith(this.annotation, "data:");
let r = t.map ? t.map.prev : void 0, n = this.loadMap(t.from, r);
!this.mapFile && t.from && (this.mapFile = t.from), this.mapFile && (this.root = gr(this.mapFile)), n && (this.text = n);
}
consumer() {
return this.consumerCache || (this.consumerCache = new oi(this.text)), this.consumerCache;
}
decodeInline(e) {
let t = /^data:application\/json;charset=utf-?8;base64,/, r = /^data:application\/json;base64,/, n = /^data:application\/json;charset=utf-?8,/, l = /^data:application\/json,/;
if (n.test(e) || l.test(e))
return decodeURIComponent(e.substr(RegExp.lastMatch.length));
if (t.test(e) || r.test(e))
return Js(e.substr(RegExp.lastMatch.length));
let i = e.match(/data:application\/json;([^,]+),/)[1];
throw new Error("Unsupported source map encoding " + i);
}
getAnnotationURL(e) {
return e.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
}
isMap(e) {
return typeof e != "object" ? !1 : typeof e.mappings == "string" || typeof e._mappings == "string" || Array.isArray(e.sections);
}
loadAnnotation(e) {
let t = e.match(/\/\*\s*# sourceMappingURL=/gm);
if (!t)
return;
let r = e.lastIndexOf(t.pop()), n = e.indexOf("*/", r);
r > -1 && n > -1 && (this.annotation = this.getAnnotationURL(e.substring(r, n)));
}
loadFile(e) {
if (this.root = gr(e), Ys(e))
return this.mapFile = e, Hs(e, "utf-8").toString().trim();
}
loadMap(e, t) {
if (t === !1)
return !1;
if (t) {
if (typeof t == "string")
return t;
if (typeof t == "function") {
let r = t(e);
if (r) {
let n = this.loadFile(r);
if (!n)
throw new Error(
"Unable to load previous source map: " + r.toString()
);
return n;
}
} else {
if (t instanceof oi)
return li.fromSourceMap(t).toString();
if (t instanceof li)
return t.toString();
if (this.isMap(t))
return JSON.stringify(t);
throw new Error(
"Unsupported previous source map format: " + t.toString()
);
}
} else {
if (this.inline)
return this.decodeInline(this.annotation);
if (this.annotation) {
let r = this.annotation;
return e && (r = Qs(gr(e), r)), this.loadFile(r);
}
}
}
startWith(e, t) {
return e ? e.substr(0, t.length) === t : !1;
}
withContent() {
return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
}
};
var Fi = jr;
jr.default = jr;
let { SourceMapConsumer: Ks, SourceMapGenerator: Xs } = Le, { fileURLToPath: ui, pathToFileURL: It } = Le, { isAbsolute: Vr, resolve: Wr } = Le, { nanoid: Zs } = Gs, vr = Le, fi = xn, eo = Fi, yr = Symbol("fromOffsetCache"), to = !!(Ks && Xs), ci = !!(Wr && Vr), qt = class {
constructor(e, t = {}) {
if (e === null || typeof e > "u" || typeof e == "object" && !e.toString)
throw new Error(`PostCSS received ${e} instead of CSS string`);
if (this.css = e.toString(), this.css[0] === "\uFEFF" || this.css[0] === "" ? (this.hasBOM = !0, this.css = this.css.slice(1)) : this.hasBOM = !1, t.from && (!ci || /^\w+:\/\//.test(t.from) || Vr(t.from) ? this.file = t.from : this.file = Wr(t.from)), ci && to) {
let r = new eo(this.css, t);
if (r.text) {
this.map = r;
let n = r.consumer().file;
!this.file && n && (this.file = this.mapResolve(n));
}
}
this.file || (this.id = "<input css " + Zs(6) + ">"), this.map && (this.map.file = this.from);
}
error(e, t, r, n = {}) {
let l, i, c;
if (t && typeof t == "object") {
let o = t, f = r;
if (typeof o.offset == "number") {
let u = this.fromOffset(o.offset);
t = u.line, r = u.col;
} else
t = o.line, r = o.column;
if (typeof f.offset == "number") {
let u = this.fromOffset(f.offset);
i = u.line, c = u.col;
} else
i = f.line, c = f.column;
} else if (!r) {
let o = this.fromOffset(t);
t = o.line, r = o.col;
}
let a = this.origin(t, r, i, c);
return a ? l = new fi(
e,
a.endLine === void 0 ? a.line : { column: a.column, line: a.line },
a.endLine === void 0 ? a.column : { column: a.endColumn, line: a.endLine },
a.source,
a.file,
n.plugin
) : l = new fi(
e,
i === void 0 ? t : { column: r, line: t },
i === void 0 ? r : { column: c, line: i },
this.css,
this.file,
n.plugin
), l.input = { column: r, endColumn: c, endLine: i, line: t, source: this.css }, this.file && (It && (l.input.url = It(this.file).toString()), l.input.file = this.file), l;
}
fromOffset(e) {
let t, r;
if (this[yr])
r = this[yr];
else {
let l = this.css.split(`
`);
r = new Array(l.length);
let i = 0;
for (let c = 0, a = l.length; c < a; c++)
r[c] = i, i += l[c].length + 1;
this[yr] = r;
}
t = r[r.length - 1];
let n = 0;
if (e >= t)
n = r.length - 1;
else {
let l = r.length - 2, i;
for (; n < l; )
if (i = n + (l - n >> 1), e < r[i])
l = i - 1;
else if (e >= r[i + 1])
n = i + 1;
else {
n = i;
break;
}
}
return {
col: e - r[n] + 1,
line: n + 1
};
}
mapResolve(e) {
return /^\w+:\/\//.test(e) ? e : Wr(this.map.consumer().sourceRoot || this.map.root || ".", e);
}
origin(e, t, r, n) {
if (!this.map)
return !1;
let l = this.map.consumer(), i = l.originalPositionFor({ column: t, line: e });
if (!i.source)
return !1;
let c;
typeof r == "number" && (c = l.originalPositionFor({ column: n, line: r }));
let a;
Vr(i.source) ? a = It(i.source) : a = new URL(
i.source,
this.map.consumer().sourceRoot || It(this.map.mapFile)
);
let o = {
column: i.column,
endColumn: c && c.column,
endLine: c && c.line,
line: i.line,
url: a.toString()
};
if (a.protocol === "file:")
if (ui)
o.file = ui(a);
else
throw new Error("file: protocol is not available in this PostCSS build");
let f = l.sourceContentFor(i.source);
return f && (o.source = f), o;
}
toJSON() {
let e = {};
for (let t of ["hasBOM", "css", "file", "id"])
this[t] != null && (e[t] = this[t]);
return this.map && (e.map = { ...this.map }, e.map.consumerCache && (e.map.consumerCache = void 0)), e;
}
get from() {
return this.file || this.id;
}
};
var er = qt;
qt.default = qt;
vr && vr.registerInput && vr.registerInput(qt);
let { SourceMapConsumer: zi, SourceMapGenerator: Wt } = Le, { dirname: Bt, relative: Ui, resolve: ji, sep: Vi } = Le, { pathToFileURL: di } = Le, ro = er, no = !!(zi && Wt), io = !!(Bt && ji && Ui && Vi), ao = class {
constructor(e, t, r, n) {
this.stringify = e, this.mapOpts = r.map || {}, this.root = t, this.opts = r, this.css = n, this.originalCSS = n, this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute, this.memoizedFileURLs = /* @__PURE__ */ new Map(), this.memoizedPaths = /* @__PURE__ */ new Map(), this.memoizedURLs = /* @__PURE__ */ new Map();
}
addAnnotation() {
let e;
this.isInline() ? e = "data:application/json;base64," + this.toBase64(this.map.toString()) : typeof this.mapOpts.annotation == "string" ? e = this.mapOpts.annotation : typeof this.mapOpts.annotation == "function" ? e = this.mapOpts.annotation(this.opts.to, this.root) : e = this.outputFile() + ".map";
let t = `
`;
this.css.includes(`\r
`) && (t = `\r
`), this.css += t + "/*# sourceMappingURL=" + e + " */";
}
applyPrevMaps() {
for (let e of this.previous()) {
let t = this.toUrl(this.path(e.file)), r = e.root || Bt(e.file), n;
this.mapOpts.sourcesContent === !1 ? (n = new zi(e.text), n.sourcesContent && (n.sourcesContent = null)) : n = e.consumer(), this.map.applySourceMap(n, t, this.toUrl(this.path(r)));
}
}
clearAnnotation() {
if (this.mapOpts.annotation !== !1)
if (this.root) {
let e;
for (let t = this.root.nodes.length - 1; t >= 0; t--)
e = this.root.nodes[t], e.type === "comment" && e.text.indexOf("# sourceMappingURL=") === 0 && this.root.removeChild(t);
} else
this.css && (this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, ""));
}
generate() {
if (this.clearAnnotation(), io && no && this.isMap())
return this.generateMap();
{
let e = "";
return this.stringify(this.root, (t) => {
e += t;
}), [e];
}
}
generateMap() {
if (this.root)
this.generateString();
else if (this.previous().length === 1) {
let e = this.previous()[0].consumer();
e.file = this.outputFile(), this.map = Wt.fromSourceMap(e, {
ignoreInvalidMapping: !0
});
} else
this.map = new Wt({
file: this.outputFile(),
ignoreInvalidMapping: !0
}), this.map.addMapping({
generated: { column: 0, line: 1 },
original: { column: 0, line: 1 },
source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
});
return this.isSourcesContent() && this.setSourcesContent(), this.root && this.previous().length > 0 && this.applyPrevMaps(), this.isAnnotation() && this.addAnnotation(), this.isInline() ? [this.css] : [this.css, this.map];
}
generateString() {
this.css = "", this.map = new Wt({
file: this.outputFile(),
ignoreInvalidMapping: !0
});
let e = 1, t = 1, r = "<no source>", n = {
generated: { column: 0, line: 0 },
original: { column: 0, line: 0 },
source: ""
}, l, i;
this.stringify(this.root, (c, a, o) => {
if (this.css += c, a && o !== "end" && (n.generated.line = e, n.generated.column = t - 1, a.source && a.source.start ? (n.source = this.sourcePath(a), n.original.line = a.source.start.line, n.original.column = a.source.start.column - 1, this.map.addMapping(n)) : (n.source = r, n.original.line = 1, n.original.column = 0, this.map.addMapping(n))), l = c.match(/\n/g), l ? (e += l.length, i = c.lastIndexOf(`
`), t = c.length - i) : t += c.length, a && o !== "start") {
let f = a.parent || { raws: {} };
(!(a.type === "decl" || a.type === "atrule" && !a.nodes) || a !== f.last || f.raws.semicolon) && (a.source && a.source.end ? (n.source = this.sourcePath(a), n.original.line = a.source.end.line, n.original.column = a.source.end.column - 1, n.generated.line = e, n.generated.column = t - 2, this.map.addMapping(n)) : (n.source = r, n.original.line = 1, n.original.column = 0, n.generated.line = e, n.generated.column = t - 1, this.map.addMapping(n)));
}
});
}
isAnnotation() {
return this.isInline() ? !0 : typeof this.mapOpts.annotation < "u" ? this.mapOpts.annotation : this.previous().length ? this.previous().some((e) => e.annotation) : !0;
}
isInline() {
if (typeof this.mapOpts.inline < "u")
return this.mapOpts.inline;
let e = this.mapOpts.annotation;
return typeof e < "u" && e !== !0 ? !1 : this.previous().length ? this.previous().some((t) => t.inline) : !0;
}
isMap() {
return typeof this.opts.map < "u" ? !!this.opts.map : this.previous().length > 0;
}
isSourcesContent() {
return typeof this.mapOpts.sourcesContent < "u" ? this.mapOpts.sourcesContent : this.previous().length ? this.previous().some((e) => e.withContent()) : !0;
}
outputFile() {
return this.opts.to ? this.path(this.opts.to) : this.opts.from ? this.path(this.opts.from) : "to.css";
}
path(e) {
if (this.mapOpts.absolute || e.charCodeAt(0) === 60 || /^\w+:\/\//.test(e))
return e;
let t = this.memoizedPaths.get(e);
if (t)
return t;
let r = this.opts.to ? Bt(this.opts.to) : ".";
typeof this.mapOpts.annotation == "string" && (r = Bt(ji(r, this.mapOpts.annotation)));
let n = Ui(r, e);
return this.memoizedPaths.set(e, n), n;
}
previous() {
if (!this.previousMaps)
if (this.previousMaps = [], this.root)
this.root.walk((e) => {
if (e.source && e.source.input.map) {
let t = e.source.input.map;
this.previousMaps.includes(t) || this.previousMaps.push(t);
}
});
else {
let e = new ro(this.originalCSS, this.opts);
e.map && this.previousMaps.push(e.map);
}
return this.previousMaps;
}
setSourcesContent() {
let e = {};
if (this.root)
this.root.walk((t) => {
if (t.source) {
let r = t.source.input.from;
if (r && !e[r]) {
e[r] = !0;
let n = this.usesFileUrls ? this.toFileUrl(r) : this.toUrl(this.path(r));
this.map.setSourceContent(n, t.source.input.css);
}
}
});
else if (this.css) {
let t = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
this.map.setSourceContent(t, this.css);
}
}
sourcePath(e) {
return this.mapOpts.from ? this.toUrl(this.mapOpts.from) : this.usesFileUrls ? this.toFileUrl(e.source.input.from) : this.toUrl(this.path(e.source.input.from));
}
toBase64(e) {
return Buffer ? Buffer.from(e).toString("base64") : window.btoa(unescape(encodeURIComponent(e)));
}
toFileUrl(e) {
let t = this.memoizedFileURLs.get(e);
if (t)
return t;
if (di) {
let r = di(e).toString();
return this.memoizedFileURLs.set(e, r), r;
} else
throw new Error(
"`map.absolute` option is not available in this PostCSS build"
);
}
toUrl(e) {
let t = this.memoizedURLs.get(e);
if (t)
return t;
Vi === "\\" && (e = e.replace(/\\/g, "/"));
let r = encodeURI(e).replace(/[#?]/g, encodeURIComponent);
return this.memoizedURLs.set(e, r), r;
}
};
var Wi = ao;
let so = Xt, Br = class extends so {
constructor(e) {
super(e), this.type = "comment";
}
};
var tr = Br;
Br.default = Br;
let { isClean: Bi, my: qi } = _t, Gi = Zt, Yi = tr, oo = Xt, Hi, _n, Sn, Qi;
function Ji(s) {
return s.map((e) => (e.nodes && (e.nodes = Ji(e.nodes)), delete e.source, e));
}
function Ki(s) {
if (s[Bi] = !1, s.proxyOf.nodes)
for (let e of s.proxyOf.nodes)
Ki(e);
}
let Ze = class Xi extends oo {
append(...e) {
for (let t of e) {
let r = this.normalize(t, this.last);
for (let n of r)
this.proxyOf.nodes.push(n);
}
return this.markDirty(), this;
}
cleanRaws(e) {
if (super.cleanRaws(e), this.nodes)
for (let t of this.nodes)
t.cleanRaws(e);
}
each(e) {
if (!this.proxyOf.nodes)
return;
let t = this.getIterator(), r, n;
for (; this.indexes[t] < this.proxyOf.nodes.length && (r = this.indexes[t], n = e(this.proxyOf.nodes[r], r), n !== !1); )
this.indexes[t] += 1;
return delete this.indexes[t], n;
}
every(e) {
return this.nodes.every(e);
}
getIterator() {
this.lastEach || (this.lastEach = 0), this.indexes || (this.indexes = {}), this.lastEach += 1;
let e = this.lastEach;
return this.indexes[e] = 0, e;
}
getProxyProcessor() {
return {
get(e, t) {
return t === "proxyOf" ? e : e[t] ? t === "each" || typeof t == "string" && t.startsWith("walk") ? (...r) => e[t](
...r.map((n) => typeof n == "function" ? (l, i) => n(l.toProxy(), i) : n)
) : t === "every" || t === "some" ? (r) => e[t](
(n, ...l) => r(n.toProxy(), ...l)
) : t === "root" ? () => e.root().toProxy() : t === "nodes" ? e.nodes.map((r) => r.toProxy()) : t === "first" || t === "last" ? e[t].toProxy() : e[t] : e[t];
},
set(e, t, r) {
return e[t] === r || (e[t] = r, (t === "name" || t === "params" || t === "selector") && e.markDirty()), !0;
}
};
}
index(e) {
return typeof e == "number" ? e : (e.proxyOf && (e = e.proxyOf), this.proxyOf.nodes.indexOf(e));
}
insertAfter(e, t) {
let r = this.index(e), n = this.normalize(t, this.proxyOf.nodes[r]).reverse();
r = this.index(e);
for (let i of n)
this.proxyOf.nodes.splice(r + 1, 0, i);
let l;
for (let i in this.indexes)
l = this.indexes[i], r < l && (this.indexes[i] = l + n.length);
return this.markDirty(), this;
}
insertBefore(e, t) {
let r = this.index(e), n = r === 0 ? "prepend" : !1, l = this.normalize(
t,
this.proxyOf.nodes[r],
n
).reverse();
r = this.index(e);
for (let c of l)
this.proxyOf.nodes.splice(r, 0, c);
let i;
for (let c in this.indexes)
i = this.indexes[c], r <= i && (this.indexes[c] = i + l.length);
return this.markDirty(), this;
}
normalize(e, t) {
if (typeof e == "string")
e = Ji(Hi(e).nodes);
else if (typeof e > "u")
e = [];
else if (Array.isArray(e)) {
e = e.slice(0);
for (let n of e)
n.parent && n.parent.removeChild(n, "ignore");
} else if (e.type === "root" && this.type !== "document") {
e = e.nodes.slice(0);
for (let n of e)
n.parent && n.parent.removeChild(n, "ignore");
} else if (e.type)
e = [e];
else if (e.prop) {
if (typeof e.value > "u")
throw new Error("Value field is missed in node creation");
typeof e.value != "string" && (e.value = String(e.value)), e = [new Gi(e)];
} else if (e.selector)
e = [new _n(e)];
else if (e.name)
e = [new Sn(e)];
else if (e.text)
e = [new Yi(e)];
else
throw new Error("Unknown node type in node creation");
return e.map((n) => (n[qi] || Xi.rebuild(n), n = n.proxyOf, n.parent && n.parent.removeChild(n), n[Bi] && Ki(n), typeof n.raws.before > "u" && t && typeof t.raws.before < "u" && (n.raws.before = t.raws.before.replace(/\S/g, "")), n.parent = this.proxyOf, n));
}
prepend(...e) {
e = e.reverse();
for (let t of e) {
let r = this.normalize(t, this.first, "prepend").reverse();
for (let n of r)
this.proxyOf.nodes.unshift(n);
for (let n in this.indexes)
this.indexes[n] = this.indexes[n] + r.length;
}
return this.markDirty(), this;
}
push(e) {
return e.parent = this, this.proxyOf.nodes.push(e), this;
}
removeAll() {
for (let e of this.proxyOf.nodes)
e.parent = void 0;
return this.proxyOf.nodes = [], this.markDirty(), this;
}
removeChild(e) {
e = this.index(e), this.proxyOf.nodes[e].parent = void 0, this.proxyOf.nodes.splice(e, 1);
let t;
for (let r in this.indexes)
t = this.indexes[r], t >= e && (this.indexes[r] = t - 1);
return this.markDirty(), this;
}
replaceValues(e, t, r) {
return r || (r = t, t = {}), this.walkDecls((n) => {
t.props && !t.props.includes(n.prop) || t.fast && !n.value.includes(t.fast) || (n.value = n.value.replace(e, r));
}), this.markDirty(), this;
}
some(e) {
return this.nodes.some(e);
}
walk(e) {
return this.each((t, r) => {
let n;
try {
n = e(t, r);
} catch (l) {
throw t.addToError(l);
}
return n !== !1 && t.walk && (n = t.walk(e)), n;
});
}
walkAtRules(e, t) {
return t ? e instanceof RegExp ? this.walk((r, n) => {
if (r.type === "atrule" && e.test(r.name))
return t(r, n);
}) : this.walk((r, n) => {
if (r.type === "atrule" && r.name === e)
return t(r, n);
}) : (t = e, this.walk((r, n) => {
if (r.type === "atrule")
return t(r, n);
}));
}
walkComments(e) {
return this.walk((t, r) => {
if (t.type === "comment")
return e(t, r);
});
}
walkDecls(e, t) {
return t ? e instanceof RegExp ? this.walk((r, n) => {
if (r.type === "decl" && e.test(r.prop))
return t(r, n);
}) : this.walk((r, n) => {
if (r.type === "decl" && r.prop === e)
return t(r, n);
}) : (t = e, this.walk((r, n) => {
if (r.type === "decl")
return t(r, n);
}));
}
walkRules(e, t) {
return t ? e instanceof RegExp ? this.walk((r, n) => {
if (r.type === "rule" && e.test(r.selector))
return t(r, n);
}) : this.walk((r, n) => {
if (r.type === "rule" && r.selector === e)
return t(r, n);
}) : (t = e, this.walk((r, n) => {
if (r.type === "rule")
return t(r, n);
}));
}
get first() {
if (this.proxyOf.nodes)
return this.proxyOf.nodes[0];
}
get last() {
if (this.proxyOf.nodes)
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
}
};
Ze.registerParse = (s) => {
Hi = s;
};
Ze.registerRule = (s) => {
_n = s;
};
Ze.registerAtRule = (s) => {
Sn = s;
};
Ze.registerRoot = (s) => {
Qi = s;
};
var st = Ze;
Ze.default = Ze;
Ze.rebuild = (s) => {
s.type === "atrule" ? Object.setPrototypeOf(s, Sn.prototype) : s.type === "rule" ? Object.setPrototypeOf(s, _n.prototype) : s.type === "decl" ? Object.setPrototypeOf(s, Gi.prototype) : s.type === "comment" ? Object.setPrototypeOf(s, Yi.prototype) : s.type === "root" && Object.setPrototypeOf(s, Qi.prototype), s[qi] = !0, s.nodes && s.nodes.forEach((e) => {
Ze.rebuild(e);
});
};
let lo = st, Zi, ea, vt = class extends lo {
constructor(e) {
super({ type: "document", ...e }), this.nodes || (this.nodes = []);
}
toResult(e = {}) {
return new Zi(new ea(), this, e).stringify();
}
};
vt.registerLazyResult = (s) => {
Zi = s;
};
vt.registerProcessor = (s) => {
ea = s;
};
var On = vt;
vt.default = vt;
let pi = {};
var ta = function(e) {
pi[e] || (pi[e] = !0, typeof console < "u" && console.warn && console.warn(e));
};
let qr = class {
constructor(e, t = {}) {
if (this.type = "warning", this.text = e, t.node && t.node.source) {
let r = t.node.rangeBy(t);
this.line = r.start.line, this.column = r.start.column, this.endLine = r.end.line, this.endColumn = r.end.column;
}
for (let r in t)
this[r] = t[r];
}
toString() {
return this.node ? this.node.error(this.text, {
index: this.index,
plugin: this.plugin,
word: this.word
}).message : this.plugin ? this.plugin + ": " + this.text : this.text;
}
};
var ra = qr;
qr.default = qr;
let uo = ra, Gr = class {
constructor(e, t, r) {
this.processor = e, this.messages = [], this.root = t, this.opts = r, this.css = void 0, this.map = void 0;
}
toString() {
return this.css;
}
warn(e, t = {}) {
t.plugin || this.lastPlugin && this.lastPlugin.postcssPlugin && (t.plugin = this.lastPlugin.postcssPlugin);
let r = new uo(e, t);
return this.messages.push(r), r;
}
warnings() {
return this.messages.filter((e) => e.type === "warning");
}
get content() {
return this.css;
}
};
var kn = Gr;
Gr.default = Gr;
const wr = 39, hi = 34, Rt = 92, mi = 47, $t = 10, ht = 32, Dt = 12, Nt = 9, Lt = 13, fo = 91, co = 93, po = 40, ho = 41, mo = 123, go = 125, vo = 59, yo = 42, wo = 58, bo = 64, Ft = /[\t\n\f\r "#'()/;[\\\]{}]/g, zt = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g, xo = /.[\r\n"'(/\\]/, gi = /[\da-f]/i;
var _o = function(e, t = {}) {
let r = e.css.valueOf(), n = t.ignoreErrors, l, i, c, a, o, f, u, p, _, x, h = r.length, m = 0, C = [], S = [];
function k() {
return m;
}
function O(P) {
throw e.error("Unclosed " + P, m);
}
function E() {
return S.length === 0 && m >= h;
}
function M(P) {
if (S.length)
return S.pop();
if (m >= h)
return;
let b = P ? P.ignoreUnclosed : !1;
switch (l = r.charCodeAt(m), l) {
case $t:
case ht:
case Nt:
case Lt:
case Dt: {
i = m;
do
i += 1, l = r.charCodeAt(i);
while (l === ht || l === $t || l === Nt || l === Lt || l === Dt);
x = ["space", r.slice(m, i)], m = i - 1;
break;
}
case fo:
case co:
case mo:
case go:
case wo:
case vo:
case ho: {
let A = String.fromCharCode(l);
x = [A, A, m];
break;
}
case po: {
if (p = C.length ? C.pop()[1] : "", _ = r.charCodeAt(m + 1), p === "url" && _ !== wr && _ !== hi && _ !== ht && _ !== $t && _ !== Nt && _ !== Dt && _ !== Lt) {
i = m;
do {
if (f = !1, i = r.indexOf(")", i + 1), i === -1)
if (n || b) {
i = m;
break;
} else
O("bracket");
for (u = i; r.charCodeAt(u - 1) === Rt; )
u -= 1, f = !f;
} while (f);
x = ["brackets", r.slice(m, i + 1), m, i], m = i;
} else
i = r.indexOf(")", m + 1), a = r.slice(m, i + 1), i === -1 || xo.test(a) ? x = ["(", "(", m] : (x = ["brackets", a, m, i], m = i);
break;
}
case wr:
case hi: {
c = l === wr ? "'" : '"', i = m;
do {
if (f = !1, i = r.indexOf(c, i + 1), i === -1)
if (n || b) {
i = m + 1;
break;
} else
O("string");
for (u = i; r.charCodeAt(u - 1) === Rt; )
u -= 1, f = !f;
} while (f);
x = ["string", r.slice(m, i + 1), m, i], m = i;
break;
}
case bo: {
Ft.lastIndex = m + 1, Ft.test(r), Ft.lastIndex === 0 ? i = r.length - 1 : i = Ft.lastIndex - 2, x = ["at-word", r.slice(m, i + 1), m, i], m = i;
break;
}
case Rt: {
for (i = m, o = !0; r.charCodeAt(i + 1) === Rt; )
i += 1, o = !o;
if (l = r.charCodeAt(i + 1), o && l !== mi && l !== ht && l !== $t && l !== Nt && l !== Lt && l !== Dt && (i += 1, gi.test(r.charAt(i)))) {
for (; gi.test(r.charAt(i + 1)); )
i += 1;
r.charCodeAt(i + 1) === ht && (i += 1);
}
x = ["word", r.slice(m, i + 1), m, i], m = i;
break;
}
default: {
l === mi && r.charCodeAt(m + 1) === yo ? (i = r.indexOf("*/", m + 2) + 1, i === 0 && (n || b ? i = r.length : O("comment")), x = ["comment", r.slice(m, i + 1), m, i], m = i) : (zt.lastIndex = m + 1, zt.test(r), zt.lastIndex === 0 ? i = r.length - 1 : i = zt.lastIndex - 2, x = ["word", r.slice(m, i + 1), m, i], C.push(x), m = i);
break;
}
}
return m++, x;
}
function D(P) {
S.push(P);
}
return {
back: D,
endOfFile: E,
nextToken: M,
position: k
};
};
let na = st, Gt = class extends na {
constructor(e) {
super(e), this.type = "atrule";
}
append(...e) {
return this.proxyOf.nodes || (this.nodes = []), super.append(...e);
}
prepend(...e) {
return this.proxyOf.nodes || (this.nodes = []), super.prepend(...e);
}
};
var An = Gt;
Gt.default = Gt;
na.registerAtRule(Gt);
let ia = st, aa, sa, ut = class extends ia {
constructor(e) {
super(e), this.type = "root", this.nodes || (this.nodes = []);
}
normalize(e, t, r) {
let n = super.normalize(e);
if (t) {
if (r === "prepend")
this.nodes.length > 1 ? t.raws.before = this.nodes[1].raws.before : delete t.raws.before;
else if (this.first !== t)
for (let l of n)
l.raws.before = t.raws.before;
}
return n;
}
removeChild(e, t) {
let r = this.index(e);
return !t && r === 0 && this.nodes.length > 1 && (this.nodes[1].raws.before = this.nodes[r].raws.before), super.removeChild(e);
}
toResult(e = {}) {
return new aa(new sa(), this, e).stringify();
}
};
ut.registerLazyResult = (s) => {
aa = s;
};
ut.registerProcessor = (s) => {
sa = s;
};
var St = ut;
ut.default = ut;
ia.registerRoot(ut);
let yt = {
comma(s) {
return yt.split(s, [","], !0);
},
space(s) {
let e = [" ", `
`, " "];
return yt.split(s, e);
},
split(s, e, t) {
let r = [], n = "", l = !1, i = 0, c = !1, a = "", o = !1;
for (let f of s)
o ? o = !1 : f === "\\" ? o = !0 : c ? f === a && (c = !1) : f === '"' || f === "'" ? (c = !0, a = f) : f === "(" ? i += 1 : f === ")" ? i > 0 && (i -= 1) : i === 0 && e.includes(f) && (l = !0), l ? (n !== "" && r.push(n.trim()), n = "", l = !1) : n += f;
return (t || n !== "") && r.push(n.trim()), r;
}
};
var oa = yt;
yt.default = yt;
let la = st, So = oa, Yt = class extends la {
constructor(e) {
super(e), this.type = "rule", this.nodes || (this.nodes = []);
}
get selectors() {
return So.comma(this.selector);
}
set selectors(e) {
let t = this.selector ? this.selector.match(/,\s*/) : null, r = t ? t[0] : "," + this.raw("between", "beforeOpen");
this.selector = e.join(r);
}
};
var Cn = Yt;
Yt.default = Yt;
la.registerRule(Yt);
let Oo = Zt, ko = _o, Ao = tr, Co = An, Eo = St, vi = Cn;
const yi = {
empty: !0,
space: !0
};
function Po(s) {
for (let e = s.length - 1; e >= 0; e--) {
let t = s[e], r = t[3] || t[2];
if (r)
return r;
}
}
let To = class {
constructor(e) {
this.input = e, this.root = new Eo(), this.current = this.root, this.spaces = "", this.semicolon = !1, this.createTokenizer(), this.root.source = { input: e, start: { column: 1, line: 1, offset: 0 } };
}
atrule(e) {
let t = new Co();
t.name = e[1].slice(1), t.name === "" && this.unnamedAtrule(t, e), this.init(t, e[2]);
let r, n, l, i = !1, c = !1, a = [], o = [];
for (; !this.tokenizer.endOfFile(); ) {
if (e = this.tokenizer.nextToken(), r = e[0], r === "(" || r === "[" ? o.push(r === "(" ? ")" : "]") : r === "{" && o.length > 0 ? o.push("}") : r === o[o.length - 1] && o.pop(), o.length === 0)
if (r === ";") {
t.source.end = this.getPosition(e[2]), t.source.end.offset++, this.semicolon = !0;
break;
} else if (r === "{") {
c = !0;
break;
} else if (r === "}") {
if (a.length > 0) {
for (l = a.length - 1, n = a[l]; n && n[0] === "space"; )
n = a[--l];
n && (t.source.end = this.getPosition(n[3] || n[2]), t.source.end.offset++);
}
this.end(e);
break;
} else
a.push(e);
else
a.push(e);
if (this.tokenizer.endOfFile()) {
i = !0;
break;
}
}
t.raws.between = this.spacesAndCommentsFromEnd(a), a.length ? (t.raws.afterName = this.spacesAndCommentsFromStart(a), this.raw(t, "params", a), i && (e = a[a.length - 1], t.source.end = this.getPosition(e[3] || e[2]), t.source.end.offset++, this.spaces = t.raws.between, t.raws.between = "")) : (t.raws.afterName = "", t.params = ""), c && (t.nodes = [], this.current = t);
}
checkMissedSemicolon(e) {
let t = this.colon(e);
if (t === !1)
return;
let r = 0, n;
for (let l = t - 1; l >= 0 && (n = e[l], !(n[0] !== "space" && (r += 1, r === 2))); l--)
;
throw this.input.error(
"Missed semicolon",
n[0] === "word" ? n[3] + 1 : n[2]
);
}
colon(e) {
let t = 0, r, n, l;
for (let [i, c] of e.entries()) {
if (r = c, n = r[0], n === "(" && (t += 1), n === ")" && (t -= 1), t === 0 && n === ":")
if (!l)
this.doubleColon(r);
else {
if (l[0] === "word" && l[1] === "progid")
continue;
return i;
}
l = r;
}
return !1;
}
comment(e) {
let t = new Ao();
this.init(t, e[2]), t.source.end = this.getPosition(e[3] || e[2]), t.source.end.offset++;
let r = e[1].slice(2, -2);
if (/^\s*$/.test(r))
t.text = "", t.raws.left = r, t.raws.right = "";
else {
let n = r.match(/^(\s*)([^]*\S)(\s*)$/);
t.text = n[2], t.raws.left = n[1], t.raws.right = n[3];
}
}
createTokenizer() {
this.tokenizer = ko(this.input);
}
decl(e, t) {
let r = new Oo();
this.init(r, e[0][2]);
let n = e[e.length - 1];
for (n[0] === ";" && (this.semicolon = !0, e.pop()), r.source.end = this.getPosition(
n[3] || n[2] || Po(e)
), r.source.end.offset++; e[0][0] !== "word"; )
e.length === 1 && this.unknownWord(e), r.raws.before += e.shift()[1];
for (r.source.start = this.getPosition(e[0][2]), r.prop = ""; e.length; ) {
let o = e[0][0];
if (o === ":" || o === "space" || o === "comment")
break;
r.prop += e.shift()[1];
}
r.raws.between = "";
let l;
for (; e.length; )
if (l = e.shift(), l[0] === ":") {
r.raws.between += l[1];
break;
} else
l[0] === "word" && /\w/.test(l[1]) && this.unknownWord([l]), r.raws.between += l[1];
(r.prop[0] === "_" || r.prop[0] === "*") && (r.raws.before += r.prop[0], r.prop = r.prop.slice(1));
let i = [], c;
for (; e.length && (c = e[0][0], !(c !== "space" && c !== "comment")); )
i.push(e.shift());
this.precheckMissedSemicolon(e);
for (let o = e.length - 1; o >= 0; o--) {
if (l = e[o], l[1].toLowerCase() === "!important") {
r.important = !0;
let f = this.stringFrom(e, o);
f = this.spacesFromEnd(e) + f, f !== " !important" && (r.raws.important = f);
break;
} else if (l[1].toLowerCase() === "important") {
let f = e.slice(0), u = "";
for (let p = o; p > 0; p--) {
let _ = f[p][0];
if (u.trim().indexOf("!") === 0 && _ !== "space")
break;
u = f.pop()[1] + u;
}
u.trim().indexOf("!") === 0 && (r.important = !0, r.raws.important = u, e = f);
}
if (l[0] !== "space" && l[0] !== "comment")
break;
}
e.some((o) => o[0] !== "space" && o[0] !== "comment") && (r.raws.between += i.map((o) => o[1]).join(""), i = []), this.raw(r, "value", i.concat(e), t), r.value.includes(":") && !t && this.checkMissedSemicolon(e);
}
doubleColon(e) {
throw this.input.error(
"Double colon",
{ offset: e[2] },
{ offset: e[2] + e[1].length }
);
}
emptyRule(e) {
let t =