capsule-lint
Version:
The official Capsule linting package.
1,373 lines • 85.4 kB
JavaScript
var Cr = Object.defineProperty;
var Lr = (f, n, s) => n in f ? Cr(f, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : f[n] = s;
var E = (f, n, s) => (Lr(f, typeof n != "symbol" ? n + "" : n, s), s);
var Oe = {}, je = {};
Object.defineProperty(je, "__esModule", { value: !0 });
class xr {
constructor() {
this._listeners = {}, this._mapCdataTags = this.makeMap("script,style"), this._arrBlocks = [], this.lastEvent = null;
}
makeMap(n) {
const s = {}, i = n.split(",");
for (let t = 0; t < i.length; t++)
s[i[t]] = !0;
return s;
}
parse(n) {
const s = this._mapCdataTags, i = /<(?:\/([^\s>]+)\s*|!--([\s\S]*?)--|!([^>]*?)|([\w\-:]+)((?:\s+[^\s"'>\/=\x00-\x0F\x7F\x80-\x9F]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]*))?)*?)\s*(\/?))>/g, t = /\s*([^\s"'>\/=\x00-\x0F\x7F\x80-\x9F]+)(?:\s*=\s*(?:(")([^"]*)"|(')([^']*)'|([^\s"'>]*)))?/g, o = /\r?\n/g;
let e, u, d = 0, p, v, A = null, x, _ = [], C = 0, L, P = 0, M = 1;
const U = this._arrBlocks;
this.fire("start", {
pos: 0,
line: 1,
col: 1
});
const S = () => {
const k = v.find((N) => N.name === "type") || {
value: ""
};
return s[p] && k.value.indexOf("text/ng-template") === -1;
}, q = (k, N, D, R) => {
const I = D - P + 1;
for (R === void 0 && (R = {}), R.raw = N, R.pos = D, R.line = M, R.col = I, U.push(R), this.fire(k, R); o.exec(N); )
M++, P = D + o.lastIndex;
};
for (; e = i.exec(n); ) {
if (u = e.index, u > d && (L = n.substring(d, u), A ? _.push(L) : q("text", L, d)), d = i.lastIndex, (p = e[1]) && (A && p === A && (L = _.join(""), q("cdata", L, C, {
tagName: A,
attrs: x
}), A = null, x = void 0, _ = []), !A)) {
q("tagend", e[0], u, {
tagName: p
});
continue;
}
if (A)
_.push(e[0]);
else if (p = e[4]) {
v = [];
const k = e[5];
let N, D = 0;
for (; N = t.exec(k); ) {
const R = N[1], I = N[2] ? N[2] : N[4] ? N[4] : "", V = N[3] ? N[3] : N[5] ? N[5] : N[6] ? N[6] : "";
v.push({
name: R,
value: V,
quote: I,
index: N.index,
raw: N[0]
}), D += N[0].length;
}
D === k.length ? (q("tagstart", e[0], u, {
tagName: p,
attrs: v,
close: e[6]
}), S() && (A = p, x = v.concat(), _ = [], C = d)) : q("text", e[0], u);
} else
(e[2] || e[3]) && q("comment", e[0], u, {
content: e[2] || e[3],
long: !!e[2]
});
}
n.length > d && (L = n.substring(d, n.length), q("text", L, d)), this.fire("end", {
pos: d,
line: M,
col: n.length - P + 1
});
}
addListener(n, s) {
const i = this._listeners, t = n.split(/[,\s]/);
let o;
for (let e = 0, u = t.length; e < u; e++)
o = t[e], i[o] === void 0 && (i[o] = []), i[o].push(s);
}
fire(n, s) {
s === void 0 && (s = {}), s.type = n;
let i = [];
const t = this._listeners[n], o = this._listeners.all;
t !== void 0 && (i = i.concat(t)), o !== void 0 && (i = i.concat(o));
const e = this.lastEvent;
e !== null && (delete e.lastEvent, s.lastEvent = e), this.lastEvent = s;
for (let u = 0, d = i.length; u < d; u++)
i[u].call(this, s);
}
removeListener(n, s) {
const i = this._listeners[n];
if (i !== void 0) {
for (let t = 0, o = i.length; t < o; t++)
if (i[t] === s) {
i.splice(t, 1);
break;
}
}
}
fixPos(n, s) {
const t = n.raw.substr(0, s).split(/\r?\n/), o = t.length - 1;
let e = n.line, u;
return o > 0 ? (e += o, u = t[o].length + 1) : u = n.col + s, {
line: e,
col: u
};
}
getMapAttrs(n) {
const s = {};
let i;
for (let t = 0, o = n.length; t < o; t++)
i = n[t], s[i.name] = i.value;
return s;
}
}
je.default = xr;
var Pe = {};
Object.defineProperty(Pe, "__esModule", { value: !0 });
class Nr {
constructor(n, s) {
this.html = n, this.lines = n.split(/\r?\n/);
const i = /\r?\n/.exec(n);
this.brLen = i !== null ? i[0].length : 0, this.ruleset = s, this.messages = [];
}
info(n, s, i, t, o) {
this.report("info", n, s, i, t, o);
}
warn(n, s, i, t, o) {
this.report("warning", n, s, i, t, o);
}
error(n, s, i, t, o) {
this.report("error", n, s, i, t, o);
}
report(n, s, i, t, o, e) {
const u = this.lines, d = this.brLen;
let p = "", v = 0;
for (let A = i - 1, x = u.length; A < x && (p = u[A], v = p.length, t > v && i < x); A++)
i++, t -= v, t !== 1 && (t -= d);
this.messages.push({
type: n,
message: s,
raw: e,
evidence: p,
line: i,
col: t,
rule: {
id: o.id,
description: o.description,
link: `https://htmlhint.com/docs/user-guide/rules/${o.id}`
}
});
}
}
Pe.default = Nr;
var ea = {}, Ee = {};
Object.defineProperty(Ee, "__esModule", { value: !0 });
Ee.default = {
id: "alt-require",
description: "The alt attribute of an <img> element must be present and alt attribute of area[href] and input[type=image] must have a value.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.tagName.toLowerCase(), t = f.getMapAttrs(s.attrs), o = s.col + i.length + 1;
let e;
i === "img" && !("alt" in t) ? n.warn("An alt attribute must be present on <img> elements.", s.line, o, this, s.raw) : (i === "area" && "href" in t || i === "input" && t.type === "image") && (!("alt" in t) || t.alt === "") && (e = i === "area" ? "area[href]" : "input[type=image]", n.warn(`The alt attribute of ${e} must have a value.`, s.line, o, this, s.raw));
});
}
};
var Me = {};
Object.defineProperty(Me, "__esModule", { value: !0 });
const Or = [
"allowReorder",
"attributeName",
"attributeType",
"autoReverse",
"baseFrequency",
"baseProfile",
"calcMode",
"clipPath",
"clipPathUnits",
"contentScriptType",
"contentStyleType",
"diffuseConstant",
"edgeMode",
"externalResourcesRequired",
"filterRes",
"filterUnits",
"glyphRef",
"gradientTransform",
"gradientUnits",
"kernelMatrix",
"kernelUnitLength",
"keyPoints",
"keySplines",
"keyTimes",
"lengthAdjust",
"limitingConeAngle",
"markerHeight",
"markerUnits",
"markerWidth",
"maskContentUnits",
"maskUnits",
"numOctaves",
"onBlur",
"onChange",
"onClick",
"onFocus",
"onKeyUp",
"onLoad",
"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"
];
function jr(f, n) {
if (n instanceof RegExp)
return n.test(f) ? { match: f, pattern: n } : !1;
const s = n[0], i = n[n.length - 1], t = n[n.length - 2], o = s === "/" && (i === "/" || t === "/" && i === "i"), e = o && i === "i";
return o ? e ? new RegExp(n.slice(1, -2), "i").test(f) : new RegExp(n.slice(1, -1)).test(f) : f === n;
}
Me.default = {
id: "attr-lowercase",
description: "All attribute names must be in lowercase.",
init(f, n, s) {
const i = (Array.isArray(s) ? s : []).concat(Or);
f.addListener("tagstart", (t) => {
const o = t.attrs;
let e;
const u = t.col + t.tagName.length + 1;
for (let d = 0, p = o.length; d < p; d++) {
e = o[d];
const v = e.name;
!i.find((A) => jr(v, A)) && v !== v.toLowerCase() && n.error(`The attribute name of [ ${v} ] must be in lowercase.`, t.line, u + e.index, this, e.raw);
}
});
}
};
var ke = {};
Object.defineProperty(ke, "__esModule", { value: !0 });
ke.default = {
id: "attr-sorted",
description: "Attribute tags must be in proper order.",
init(f, n) {
const s = {}, i = [
"class",
"id",
"name",
"src",
"for",
"type",
"href",
"value",
"title",
"alt",
"role"
];
for (let t = 0; t < i.length; t++)
s[i[t]] = t;
f.addListener("tagstart", (t) => {
const o = t.attrs, e = [];
for (let d = 0; d < o.length; d++)
e.push(o[d].name);
const u = JSON.stringify(e);
e.sort((d, p) => s[d] == null && s[p] == null ? 0 : s[d] == null ? 1 : s[p] == null ? -1 : s[d] - s[p] || d.localeCompare(p)), u !== JSON.stringify(e) && n.error(`Inaccurate order ${u} should be in hierarchy ${JSON.stringify(e)} `, t.line, t.col, this, t.raw);
});
}
};
var qe = {};
Object.defineProperty(qe, "__esModule", { value: !0 });
qe.default = {
id: "attr-no-duplication",
description: "Elements cannot have duplicate attributes.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.attrs;
let t, o;
const e = s.col + s.tagName.length + 1, u = {};
for (let d = 0, p = i.length; d < p; d++)
t = i[d], o = t.name, u[o] === !0 && n.error(`Duplicate of attribute name [ ${t.name} ] was found.`, s.line, e + t.index, this, t.raw), u[o] = !0;
});
}
};
var Re = {};
Object.defineProperty(Re, "__esModule", { value: !0 });
Re.default = {
id: "attr-unsafe-chars",
description: "Attribute values cannot contain unsafe chars.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.attrs;
let t;
const o = s.col + s.tagName.length + 1, e = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
let u;
for (let d = 0, p = i.length; d < p; d++)
if (t = i[d], u = e.exec(t.value), u !== null) {
const v = escape(u[0]).replace(/%u/, "\\u").replace(/%/, "\\x");
n.warn(`The value of attribute [ ${t.name} ] cannot contain an unsafe char [ ${v} ].`, s.line, o + t.index, this, t.raw);
}
});
}
};
var Se = {};
Object.defineProperty(Se, "__esModule", { value: !0 });
Se.default = {
id: "attr-value-double-quotes",
description: "Attribute values must be in double quotes.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.attrs;
let t;
const o = s.col + s.tagName.length + 1;
for (let e = 0, u = i.length; e < u; e++)
t = i[e], (t.value !== "" && t.quote !== '"' || t.value === "" && t.quote === "'") && n.error(`The value of attribute [ ${t.name} ] must be in double quotes.`, s.line, o + t.index, this, t.raw);
});
}
};
var De = {};
Object.defineProperty(De, "__esModule", { value: !0 });
De.default = {
id: "attr-value-not-empty",
description: "All attributes must have values.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.attrs;
let t;
const o = s.col + s.tagName.length + 1;
for (let e = 0, u = i.length; e < u; e++)
t = i[e], t.quote === "" && t.value === "" && n.warn(`The attribute [ ${t.name} ] must have a value.`, s.line, o + t.index, this, t.raw);
});
}
};
var Ie = {};
Object.defineProperty(Ie, "__esModule", { value: !0 });
Ie.default = {
id: "attr-value-single-quotes",
description: "Attribute values must be in single quotes.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.attrs;
let t;
const o = s.col + s.tagName.length + 1;
for (let e = 0, u = i.length; e < u; e++)
t = i[e], (t.value !== "" && t.quote !== "'" || t.value === "" && t.quote === '"') && n.error(`The value of attribute [ ${t.name} ] must be in single quotes.`, s.line, o + t.index, this, t.raw);
});
}
};
var Fe = {};
Object.defineProperty(Fe, "__esModule", { value: !0 });
Fe.default = {
id: "attr-whitespace",
description: "All attributes should be separated by only one space and not have leading/trailing whitespace.",
init(f, n, s) {
const i = Array.isArray(s) ? s : [];
f.addListener("tagstart", (t) => {
const o = t.attrs;
let e;
const u = t.col + t.tagName.length + 1;
o.forEach((d) => {
e = d;
const p = d.name;
i.indexOf(p) === -1 && (d.value.trim() !== d.value && n.error(`The attributes of [ ${p} ] must not have leading or trailing whitespace.`, t.line, u + e.index, this, e.raw), d.value.replace(/ +(?= )/g, "") !== d.value && n.error(`The attributes of [ ${p} ] must be separated by only one space.`, t.line, u + e.index, this, e.raw));
});
});
}
};
var ze = {};
Object.defineProperty(ze, "__esModule", { value: !0 });
ze.default = {
id: "doctype-first",
description: "Doctype must be declared first.",
init(f, n) {
const s = (i) => {
i.type === "start" || i.type === "text" && /^\s*$/.test(i.raw) || ((i.type !== "comment" && i.long === !1 || /^DOCTYPE\s+/i.test(i.content) === !1) && n.error("Doctype must be declared first.", i.line, i.col, this, i.raw), f.removeListener("all", s));
};
f.addListener("all", s);
}
};
var Ue = {};
Object.defineProperty(Ue, "__esModule", { value: !0 });
Ue.default = {
id: "doctype-html5",
description: 'Invalid doctype. Use: "<!DOCTYPE html>"',
init(f, n) {
const s = (t) => {
t.long === !1 && t.content.toLowerCase() !== "doctype html" && n.warn('Invalid doctype. Use: "<!DOCTYPE html>"', t.line, t.col, this, t.raw);
}, i = () => {
f.removeListener("comment", s), f.removeListener("tagstart", i);
};
f.addListener("all", s), f.addListener("tagstart", i);
}
};
var He = {};
Object.defineProperty(He, "__esModule", { value: !0 });
He.default = {
id: "head-script-disabled",
description: "The <script> tag cannot be used in a <head> tag.",
init(f, n) {
const s = /^(text\/javascript|application\/javascript)$/i;
let i = !1;
const t = (e) => {
const d = f.getMapAttrs(e.attrs).type, p = e.tagName.toLowerCase();
p === "head" && (i = !0), i === !0 && p === "script" && (!d || s.test(d) === !0) && n.warn("The <script> tag cannot be used in a <head> tag.", e.line, e.col, this, e.raw);
}, o = (e) => {
e.tagName.toLowerCase() === "head" && (f.removeListener("tagstart", t), f.removeListener("tagend", o));
};
f.addListener("tagstart", t), f.addListener("tagend", o);
}
};
var Be = {};
Object.defineProperty(Be, "__esModule", { value: !0 });
Be.default = {
id: "href-abs-or-rel",
description: "An href attribute must be either absolute or relative.",
init(f, n, s) {
const i = s === "abs" ? "absolute" : "relative";
f.addListener("tagstart", (t) => {
const o = t.attrs;
let e;
const u = t.col + t.tagName.length + 1;
for (let d = 0, p = o.length; d < p; d++)
if (e = o[d], e.name === "href") {
(i === "absolute" && /^\w+?:/.test(e.value) === !1 || i === "relative" && /^https?:\/\//.test(e.value) === !0) && n.warn(`The value of the href attribute [ ${e.value} ] must be ${i}.`, t.line, u + e.index, this, e.raw);
break;
}
});
}
};
var Ze = {};
Object.defineProperty(Ze, "__esModule", { value: !0 });
const Pr = "(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang)", Er = "(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)", Mr = `(?<grandfathered>${Er}|${Pr})`, kr = "(?<privateUse>x(-[A-Za-z0-9]{1,8})+)", qr = "(?<privateUse2>x(-[A-Za-z0-9]{1,8})+)", Rr = "[0-9A-WY-Za-wy-z]", Sr = `(?<extension>${Rr}(-[A-Za-z0-9]{2,8})+)`, Dr = "(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3})", Ir = "(?<region>[A-Za-z]{2}|[0-9]{3})", Fr = "(?<script>[A-Za-z]{4})", zr = "(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2})", Ur = `(?<language>([A-Za-z]{2,3}(-${zr})?)|[A-Za-z]{4}|[A-Za-z]{5,8})`, Hr = `(${Ur}(-${Fr})?(-${Ir})?(-${Dr})*(-${Sr})*(-${kr})?)`, Br = `(${Mr}|${Hr}|${qr})`;
Ze.default = {
id: "html-lang-require",
description: "The lang attribute of an <html> element must be present and should be valid.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.tagName.toLowerCase(), t = f.getMapAttrs(s.attrs), o = s.col + i.length + 1, e = new RegExp(Br, "g");
i === "html" && ("lang" in t ? t.lang ? e.test(t.lang) || n.warn("The lang attribute value of <html> element must be a valid BCP47.", s.line, o, this, s.raw) : n.warn("The lang attribute of <html> element must have a value.", s.line, o, this, s.raw) : n.warn("An lang attribute must be present on <html> elements.", s.line, o, this, s.raw));
});
}
};
var Ve = {};
Object.defineProperty(Ve, "__esModule", { value: !0 });
Ve.default = {
id: "id-class-ad-disabled",
description: "The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.attrs;
let t, o;
const e = s.col + s.tagName.length + 1;
for (let u = 0, d = i.length; u < d; u++)
t = i[u], o = t.name, /^(id|class)$/i.test(o) && /(^|[-_])ad([-_]|$)/i.test(t.value) && n.warn(`The value of attribute ${o} cannot use the ad keyword.`, s.line, e + t.index, this, t.raw);
});
}
};
var We = {};
Object.defineProperty(We, "__esModule", { value: !0 });
We.default = {
id: "id-class-value",
description: "The id and class attribute values must meet the specified rules.",
init(f, n, s) {
const i = {
underline: {
regId: /^[a-z\d]+(_[a-z\d]+)*$/,
message: "The id and class attribute values must be in lowercase and split by an underscore."
},
dash: {
regId: /^[a-z\d]+(-[a-z\d]+)*$/,
message: "The id and class attribute values must be in lowercase and split by a dash."
},
hump: {
regId: /^[a-z][a-zA-Z\d]*([A-Z][a-zA-Z\d]*)*$/,
message: "The id and class attribute values must meet the camelCase style."
}
};
let t;
if (typeof s == "string" ? t = i[s] : t = s, typeof t == "object" && t.regId) {
let o = t.regId;
const e = t.message;
o instanceof RegExp || (o = new RegExp(o)), f.addListener("tagstart", (u) => {
const d = u.attrs;
let p;
const v = u.col + u.tagName.length + 1;
for (let A = 0, x = d.length; A < x; A++)
if (p = d[A], p.name.toLowerCase() === "id" && o.test(p.value) === !1 && n.warn(e, u.line, v + p.index, this, p.raw), p.name.toLowerCase() === "class") {
const _ = p.value.split(/\s+/g);
let C;
for (let L = 0, P = _.length; L < P; L++)
C = _[L], C && o.test(C) === !1 && n.warn(e, u.line, v + p.index, this, C);
}
});
}
}
};
var Ye = {};
Object.defineProperty(Ye, "__esModule", { value: !0 });
Ye.default = {
id: "id-unique",
description: "The value of id attributes must be unique.",
init(f, n) {
const s = {};
f.addListener("tagstart", (i) => {
const t = i.attrs;
let o, e;
const u = i.col + i.tagName.length + 1;
for (let d = 0, p = t.length; d < p; d++)
if (o = t[d], o.name.toLowerCase() === "id") {
e = o.value, e && (s[e] === void 0 ? s[e] = 1 : s[e]++, s[e] > 1 && n.error(`The id value [ ${e} ] must be unique.`, i.line, u + o.index, this, o.raw));
break;
}
});
}
};
var Qe = {};
Object.defineProperty(Qe, "__esModule", { value: !0 });
Qe.default = {
id: "inline-script-disabled",
description: "Inline script cannot be used.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.attrs;
let t;
const o = s.col + s.tagName.length + 1;
let e;
const u = /^on(unload|message|submit|select|scroll|resize|mouseover|mouseout|mousemove|mouseleave|mouseenter|mousedown|load|keyup|keypress|keydown|focus|dblclick|click|change|blur|error)$/i;
for (let d = 0, p = i.length; d < p; d++)
t = i[d], e = t.name.toLowerCase(), u.test(e) === !0 ? n.warn(`Inline script [ ${t.raw} ] cannot be used.`, s.line, o + t.index, this, t.raw) : (e === "src" || e === "href") && /^\s*javascript:/i.test(t.value) && n.warn(`Inline script [ ${t.raw} ] cannot be used.`, s.line, o + t.index, this, t.raw);
});
}
};
var Ge = {};
Object.defineProperty(Ge, "__esModule", { value: !0 });
Ge.default = {
id: "inline-style-disabled",
description: "Inline style cannot be used.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.attrs;
let t;
const o = s.col + s.tagName.length + 1;
for (let e = 0, u = i.length; e < u; e++)
t = i[e], t.name.toLowerCase() === "style" && n.warn(`Inline style [ ${t.raw} ] cannot be used.`, s.line, o + t.index, this, t.raw);
});
}
};
var Je = {};
Object.defineProperty(Je, "__esModule", { value: !0 });
Je.default = {
id: "input-requires-label",
description: "All [ input ] tags must have a corresponding [ label ] tag. ",
init(f, n) {
const s = [], i = [];
f.addListener("tagstart", (o) => {
const e = o.tagName.toLowerCase(), u = f.getMapAttrs(o.attrs), d = o.col + e.length + 1;
e === "input" && u.type !== "hidden" && i.push({ event: o, col: d, id: u.id }), e === "label" && "for" in u && u.for !== "" && s.push({ event: o, col: d, forValue: u.for });
}), f.addListener("end", () => {
i.forEach((o) => {
t(o) || n.warn("No matching [ label ] tag found.", o.event.line, o.col, this, o.event.raw);
});
});
function t(o) {
let e = !1;
return s.forEach((u) => {
o.id && o.id === u.forValue && (e = !0);
}), e;
}
}
};
var Xe = {};
Object.defineProperty(Xe, "__esModule", { value: !0 });
Xe.default = {
id: "script-disabled",
description: "The <script> tag cannot be used.",
init(f, n) {
f.addListener("tagstart", (s) => {
s.tagName.toLowerCase() === "script" && n.error("The <script> tag cannot be used.", s.line, s.col, this, s.raw);
});
}
};
var Ke = {};
Object.defineProperty(Ke, "__esModule", { value: !0 });
Ke.default = {
id: "space-tab-mixed-disabled",
description: "Do not mix tabs and spaces for indentation.",
init(f, n, s) {
let i = "nomix", t = null;
if (typeof s == "string") {
const o = /^([a-z]+)(\d+)?/.exec(s);
o && (i = o[1], t = o[2] && parseInt(o[2], 10));
}
f.addListener("text", (o) => {
const e = o.raw, u = /(^|\r?\n)([ \t]+)/g;
let d;
for (; d = u.exec(e); ) {
const p = f.fixPos(o, d.index + d[1].length);
if (p.col !== 1)
continue;
const v = d[2];
i === "space" ? t ? (/^ +$/.test(v) === !1 || v.length % t !== 0) && n.warn(`Please use space for indentation and keep ${t} length.`, p.line, 1, this, o.raw) : /^ +$/.test(v) === !1 && n.warn("Please use space for indentation.", p.line, 1, this, o.raw) : i === "tab" && /^\t+$/.test(v) === !1 ? n.warn("Please use tab for indentation.", p.line, 1, this, o.raw) : / +\t|\t+ /.test(v) === !0 && n.warn("Do not mix tabs and spaces for indentation.", p.line, 1, this, o.raw);
}
});
}
};
var et = {};
Object.defineProperty(et, "__esModule", { value: !0 });
et.default = {
id: "spec-char-escape",
description: "Special characters must be escaped.",
init(f, n) {
f.addListener("text", (s) => {
const i = s.raw, t = /([<>])|( \& )/g;
let o;
for (; o = t.exec(i); ) {
const e = f.fixPos(s, o.index);
n.error(`Special characters must be escaped : [ ${o[0]} ].`, e.line, e.col, this, s.raw);
}
});
}
};
var tt = {};
Object.defineProperty(tt, "__esModule", { value: !0 });
tt.default = {
id: "src-not-empty",
description: "The src attribute of an img(script,link) must have a value.",
init(f, n) {
f.addListener("tagstart", (s) => {
const i = s.tagName, t = s.attrs;
let o;
const e = s.col + i.length + 1;
for (let u = 0, d = t.length; u < d; u++)
o = t[u], (/^(img|script|embed|bgsound|iframe)$/.test(i) === !0 && o.name === "src" || i === "link" && o.name === "href" || i === "object" && o.name === "data") && o.value === "" && n.error(`The attribute [ ${o.name} ] of the tag [ ${i} ] must have a value.`, s.line, e + o.index, this, o.raw);
});
}
};
var at = {};
Object.defineProperty(at, "__esModule", { value: !0 });
at.default = {
id: "style-disabled",
description: "<style> tags cannot be used.",
init(f, n) {
f.addListener("tagstart", (s) => {
s.tagName.toLowerCase() === "style" && n.warn("The <style> tag cannot be used.", s.line, s.col, this, s.raw);
});
}
};
var rt = {};
Object.defineProperty(rt, "__esModule", { value: !0 });
rt.default = {
id: "tag-pair",
description: "Tag must be paired.",
init(f, n) {
const s = [], i = f.makeMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed,track,command,source,keygen,wbr");
f.addListener("tagstart", (t) => {
const o = t.tagName.toLowerCase();
i[o] === void 0 && !t.close && s.push({
tagName: o,
line: t.line,
raw: t.raw
});
}), f.addListener("tagend", (t) => {
const o = t.tagName.toLowerCase();
let e;
for (e = s.length - 1; e >= 0 && s[e].tagName !== o; e--)
;
if (e >= 0) {
const u = [];
for (let d = s.length - 1; d > e; d--)
u.push(`</${s[d].tagName}>`);
if (u.length > 0) {
const d = s[s.length - 1];
n.error(`Tag must be paired, missing: [ ${u.join("")} ], start tag match failed [ ${d.raw} ] on line ${d.line}.`, t.line, t.col, this, t.raw);
}
s.length = e;
} else
n.error(`Tag must be paired, no start tag: [ ${t.raw} ]`, t.line, t.col, this, t.raw);
}), f.addListener("end", (t) => {
const o = [];
for (let e = s.length - 1; e >= 0; e--)
o.push(`</${s[e].tagName}>`);
if (o.length > 0) {
const e = s[s.length - 1];
n.error(`Tag must be paired, missing: [ ${o.join("")} ], open tag match failed [ ${e.raw} ] on line ${e.line}.`, t.line, t.col, this, "");
}
});
}
};
var st = {};
Object.defineProperty(st, "__esModule", { value: !0 });
st.default = {
id: "tag-self-close",
description: "Empty tags must be self closed.",
init(f, n) {
const s = f.makeMap("area,base,basefont,bgsound,br,col,frame,hr,img,input,isindex,link,meta,param,embed,track,command,source,keygen,wbr");
f.addListener("tagstart", (i) => {
const t = i.tagName.toLowerCase();
s[t] !== void 0 && (i.close || n.warn(`The empty tag : [ ${t} ] must be self closed.`, i.line, i.col, this, i.raw));
});
}
};
var it = {};
Object.defineProperty(it, "__esModule", { value: !0 });
it.default = {
id: "empty-tag-not-self-closed",
description: "Empty tags must not use self closed syntax.",
init(f, n) {
const s = f.makeMap("area,base,basefont,bgsound,br,col,frame,hr,img,input,isindex,link,meta,param,embed,track,command,source,keygen,wbr");
f.addListener("tagstart", (i) => {
const t = i.tagName.toLowerCase();
s[t] !== void 0 && i.close && n.error(`The empty tag : [ ${t} ] must not use self closed syntax.`, i.line, i.col, this, i.raw);
});
}
};
var nt = {};
Object.defineProperty(nt, "__esModule", { value: !0 });
nt.default = {
id: "tagname-lowercase",
description: "All html element names must be in lowercase.",
init(f, n, s) {
const i = Array.isArray(s) ? s : [];
f.addListener("tagstart,tagend", (t) => {
const o = t.tagName;
i.indexOf(o) === -1 && o !== o.toLowerCase() && n.error(`The html element name of [ ${o} ] must be in lowercase.`, t.line, t.col, this, t.raw);
});
}
};
var lt = {};
Object.defineProperty(lt, "__esModule", { value: !0 });
lt.default = {
id: "tagname-specialchars",
description: "All special characters must be escaped.",
init(f, n) {
const s = /[^a-zA-Z0-9\-:_]/;
f.addListener("tagstart,tagend", (i) => {
const t = i.tagName;
s.test(t) && n.error(`The html element name of [ ${t} ] contains special character.`, i.line, i.col, this, i.raw);
});
}
};
var ot = {};
Object.defineProperty(ot, "__esModule", { value: !0 });
ot.default = {
id: "title-require",
description: "<title> must be present in <head> tag.",
init(f, n) {
let s = !1, i = !1;
const t = (e) => {
const u = e.tagName.toLowerCase();
u === "head" ? s = !0 : u === "title" && s && (i = !0);
}, o = (e) => {
const u = e.tagName.toLowerCase();
if (i && u === "title") {
const d = e.lastEvent;
(d.type !== "text" || d.type === "text" && /^\s*$/.test(d.raw) === !0) && n.error("<title></title> must not be empty.", e.line, e.col, this, e.raw);
} else
u === "head" && (i === !1 && n.error("<title> must be present in <head> tag.", e.line, e.col, this, e.raw), f.removeListener("tagstart", t), f.removeListener("tagend", o));
};
f.addListener("tagstart", t), f.addListener("tagend", o);
}
};
var ct = {};
Object.defineProperty(ct, "__esModule", { value: !0 });
let me = {
a: {
selfclosing: !1,
attrsRequired: ["href", "title"],
redundantAttrs: ["alt"]
},
div: {
selfclosing: !1
},
main: {
selfclosing: !1,
redundantAttrs: ["role"]
},
nav: {
selfclosing: !1,
redundantAttrs: ["role"]
},
script: {
attrsOptional: [
["async", "async"],
["defer", "defer"]
]
},
img: {
selfclosing: !0,
attrsRequired: ["src", "alt", "title"]
}
};
ct.default = {
id: "tags-check",
description: "Checks html tags.",
init(f, n, s) {
me = Object.assign(Object.assign({}, me), s), f.addListener("tagstart", (i) => {
const t = i.attrs, o = i.col + i.tagName.length + 1, e = i.tagName.toLowerCase();
if (me[e]) {
const u = me[e];
u.selfclosing === !0 && !i.close ? n.warn(`The <${e}> tag must be selfclosing.`, i.line, i.col, this, i.raw) : u.selfclosing === !1 && i.close && n.warn(`The <${e}> tag must not be selfclosing.`, i.line, i.col, this, i.raw), Array.isArray(u.attrsRequired) && u.attrsRequired.forEach((p) => {
if (Array.isArray(p)) {
const v = p.map((_) => _), A = v.shift(), x = v;
t.some((_) => _.name === A) ? t.forEach((_) => {
_.name === A && x.indexOf(_.value) === -1 && n.error(`The <${e}> tag must have attr '${A}' with one value of '${x.join("' or '")}'.`, i.line, o, this, i.raw);
}) : n.error(`The <${e}> tag must have attr '${A}'.`, i.line, o, this, i.raw);
} else
t.some((v) => p.split("|").indexOf(v.name) !== -1) || n.error(`The <${e}> tag must have attr '${p}'.`, i.line, o, this, i.raw);
}), Array.isArray(u.attrsOptional) && u.attrsOptional.forEach((p) => {
if (Array.isArray(p)) {
const v = p.map((_) => _), A = v.shift(), x = v;
t.some((_) => _.name === A) && t.forEach((_) => {
_.name === A && x.indexOf(_.value) === -1 && n.error(`The <${e}> tag must have optional attr '${A}' with one value of '${x.join("' or '")}'.`, i.line, o, this, i.raw);
});
}
}), Array.isArray(u.redundantAttrs) && u.redundantAttrs.forEach((p) => {
t.some((v) => v.name === p) && n.error(`The attr '${p}' is redundant for <${e}> and should be omitted.`, i.line, o, this, i.raw);
});
}
});
}
};
var ft = {};
Object.defineProperty(ft, "__esModule", { value: !0 });
ft.default = {
id: "attr-no-unnecessary-whitespace",
description: "No spaces between attribute names and values.",
init(f, n, s) {
const i = Array.isArray(s) ? s : [];
f.addListener("tagstart", (t) => {
const o = t.attrs, e = t.col + t.tagName.length + 1;
for (let u = 0; u < o.length; u++)
if (i.indexOf(o[u].name) === -1) {
const d = /(\s*)=(\s*)/.exec(o[u].raw.trim());
d && (d[1].length !== 0 || d[2].length !== 0) && n.error(`The attribute '${o[u].name}' must not have spaces between the name and value.`, t.line, e + o[u].index, this, o[u].raw);
}
});
}
};
(function(f) {
Object.defineProperty(f, "__esModule", { value: !0 }), f.attrNoUnnecessaryWhitespace = f.tagsCheck = f.titleRequire = f.tagnameSpecialChars = f.tagnameLowercase = f.emptyTagNotSelfClosed = f.tagSelfClose = f.tagPair = f.styleDisabled = f.srcNotEmpty = f.specCharEscape = f.spaceTabMixedDisabled = f.scriptDisabled = f.inputRequiresLabel = f.inlineStyleDisabled = f.inlineScriptDisabled = f.idUnique = f.idClassValue = f.idClsasAdDisabled = f.htmlLangRequire = f.hrefAbsOrRel = f.headScriptDisabled = f.doctypeHTML5 = f.doctypeFirst = f.attrWhitespace = f.attrValueSingleQuotes = f.attrValueNotEmpty = f.attrValueDoubleQuotes = f.attrUnsafeChars = f.attrNoDuplication = f.attrSort = f.attrLowercase = f.altRequire = void 0;
var n = Ee;
Object.defineProperty(f, "altRequire", { enumerable: !0, get: function() {
return n.default;
} });
var s = Me;
Object.defineProperty(f, "attrLowercase", { enumerable: !0, get: function() {
return s.default;
} });
var i = ke;
Object.defineProperty(f, "attrSort", { enumerable: !0, get: function() {
return i.default;
} });
var t = qe;
Object.defineProperty(f, "attrNoDuplication", { enumerable: !0, get: function() {
return t.default;
} });
var o = Re;
Object.defineProperty(f, "attrUnsafeChars", { enumerable: !0, get: function() {
return o.default;
} });
var e = Se;
Object.defineProperty(f, "attrValueDoubleQuotes", { enumerable: !0, get: function() {
return e.default;
} });
var u = De;
Object.defineProperty(f, "attrValueNotEmpty", { enumerable: !0, get: function() {
return u.default;
} });
var d = Ie;
Object.defineProperty(f, "attrValueSingleQuotes", { enumerable: !0, get: function() {
return d.default;
} });
var p = Fe;
Object.defineProperty(f, "attrWhitespace", { enumerable: !0, get: function() {
return p.default;
} });
var v = ze;
Object.defineProperty(f, "doctypeFirst", { enumerable: !0, get: function() {
return v.default;
} });
var A = Ue;
Object.defineProperty(f, "doctypeHTML5", { enumerable: !0, get: function() {
return A.default;
} });
var x = He;
Object.defineProperty(f, "headScriptDisabled", { enumerable: !0, get: function() {
return x.default;
} });
var _ = Be;
Object.defineProperty(f, "hrefAbsOrRel", { enumerable: !0, get: function() {
return _.default;
} });
var C = Ze;
Object.defineProperty(f, "htmlLangRequire", { enumerable: !0, get: function() {
return C.default;
} });
var L = Ve;
Object.defineProperty(f, "idClsasAdDisabled", { enumerable: !0, get: function() {
return L.default;
} });
var P = We;
Object.defineProperty(f, "idClassValue", { enumerable: !0, get: function() {
return P.default;
} });
var M = Ye;
Object.defineProperty(f, "idUnique", { enumerable: !0, get: function() {
return M.default;
} });
var U = Qe;
Object.defineProperty(f, "inlineScriptDisabled", { enumerable: !0, get: function() {
return U.default;
} });
var S = Ge;
Object.defineProperty(f, "inlineStyleDisabled", { enumerable: !0, get: function() {
return S.default;
} });
var q = Je;
Object.defineProperty(f, "inputRequiresLabel", { enumerable: !0, get: function() {
return q.default;
} });
var k = Xe;
Object.defineProperty(f, "scriptDisabled", { enumerable: !0, get: function() {
return k.default;
} });
var N = Ke;
Object.defineProperty(f, "spaceTabMixedDisabled", { enumerable: !0, get: function() {
return N.default;
} });
var D = et;
Object.defineProperty(f, "specCharEscape", { enumerable: !0, get: function() {
return D.default;
} });
var R = tt;
Object.defineProperty(f, "srcNotEmpty", { enumerable: !0, get: function() {
return R.default;
} });
var I = at;
Object.defineProperty(f, "styleDisabled", { enumerable: !0, get: function() {
return I.default;
} });
var V = rt;
Object.defineProperty(f, "tagPair", { enumerable: !0, get: function() {
return V.default;
} });
var W = st;
Object.defineProperty(f, "tagSelfClose", { enumerable: !0, get: function() {
return W.default;
} });
var J = it;
Object.defineProperty(f, "emptyTagNotSelfClosed", { enumerable: !0, get: function() {
return J.default;
} });
var X = nt;
Object.defineProperty(f, "tagnameLowercase", { enumerable: !0, get: function() {
return X.default;
} });
var Y = lt;
Object.defineProperty(f, "tagnameSpecialChars", { enumerable: !0, get: function() {
return Y.default;
} });
var be = ot;
Object.defineProperty(f, "titleRequire", { enumerable: !0, get: function() {
return be.default;
} });
var $e = ct;
Object.defineProperty(f, "tagsCheck", { enumerable: !0, get: function() {
return $e.default;
} });
var ye = ft;
Object.defineProperty(f, "attrNoUnnecessaryWhitespace", { enumerable: !0, get: function() {
return ye.default;
} });
})(ea);
(function(f) {
Object.defineProperty(f, "__esModule", { value: !0 }), f.HTMLParser = f.Reporter = f.HTMLRules = f.HTMLHint = void 0;
const n = je;
f.HTMLParser = n.default;
const s = Pe;
f.Reporter = s.default;
const i = ea;
f.HTMLRules = i;
class t {
constructor() {
this.rules = {}, this.defaultRuleset = {
"tagname-lowercase": !0,
"attr-lowercase": !0,
"attr-value-double-quotes": !0,
"doctype-first": !0,
"tag-pair": !0,
"spec-char-escape": !0,
"id-unique": !0,
"src-not-empty": !0,
"attr-no-duplication": !0,
"title-require": !0
};
}
addRule(u) {
this.rules[u.id] = u;
}
verify(u, d = this.defaultRuleset) {
Object.keys(d).length === 0 && (d = this.defaultRuleset), u = u.replace(/^\s*<!--\s*htmlhint\s+([^\r\n]+?)\s*-->/i, (_, C) => (C.replace(/(?:^|,)\s*([^:,]+)\s*(?:\:\s*([^,\s]+))?/g, (L, P, M) => (d[P] = M !== void 0 && M.length > 0 ? JSON.parse(M) : !0, "")), ""));
const p = new n.default(), v = new s.default(u, d), A = this.rules;
let x;
for (const _ in d)
x = A[_], x !== void 0 && d[_] !== !1 && x.init(p, v, d[_]);
return p.parse(u), v.messages;
}
format(u, d = {}) {
const p = [], v = {
white: "",
grey: "",
red: "",
reset: ""
};
d.colors && (v.white = "\x1B[37m", v.grey = "\x1B[90m", v.red = "\x1B[31m", v.reset = "\x1B[39m");
const A = d.indent || 0;
return u.forEach((x) => {
let L = x.evidence;
const P = x.line, M = x.col, U = L.length;
let S = M > 40 + 1 ? M - 40 : 1, q = L.length > M + 60 ? M + 60 : U;
M < 40 + 1 && (q += 40 - M + 1), L = L.replace(/\t/g, " ").substring(S - 1, q), S > 1 && (L = `...${L}`, S -= 3), q < U && (L += "..."), p.push(`${v.white + o(A)}L${P} |${v.grey}${L}${v.reset}`);
let k = M - S;
const N = L.substring(0, k).match(/[^\u0000-\u00ff]/g);
N !== null && (k += N.length), p.push(`${v.white + o(A) + o(String(P).length + 3 + k)}^ ${v.red}${x.message} (${x.rule.id})${v.reset}`);
}), p;
}
}
function o(e, u) {
return new Array(e + 1).join(u || " ");
}
f.HTMLHint = new t(), Object.keys(i).forEach((e) => {
f.HTMLHint.addRule(i[e]);
});
})(Oe);
const Zr = {
"attr-whitespace": !1,
"attr-no-duplication": !0,
"body-no-duplicates": !0,
"freemarker-tags": !0,
"head-body-descendents-html": !0,
"head-no-duplicates": !0,
"head-valid-children": !0,
"html-no-duplicates": !0,
"html-root-node": !0,
"html-valid-children": !0,
"html-valid-children-order": !0,
"img-src-required": !0,
"invalid-attribute-char": !0,
"nested-paragraphs": !0,
"no-enties-in-attributes": ["style", "class", "id"],
"spec-char-escape": !0,
"src-not-empty": !0,
"tag-pair": !0,
"valid-path-format": [{
attr: "href",
formats: [
"absolute",
{
pattern: "\\${(\\s+)?Gears\\.unsubscribe\\(\\)(\\s+)?}",
name: "MessageGears unsubscribe"
},
{
pattern: "mailto:.+",
name: "Mailto link"
}
]
}, {
tag: "img",
attr: "src",
formats: [
"absolute"
]
}],
"valid-style-attrs": !0
}, Vr = [
"area",
"base",
"basefont",
"br",
"col",
"frame",
"hr",
"img",
"input",
"isindex",
"link",
"meta",
"param",
"embed",
"track",
"command",
"source",
"keygen",
"wbr"
];
class Xt {
constructor(n, s) {
E(this, "children");
E(this, "closed");
E(this, "root");
E(this, "tagName");
E(this, "attrs");
E(this, "from");
E(this, "to");
E(this, "col");
E(this, "line");
E(this, "raw");
this.event = n, this.parent = s;
const i = (n == null ? void 0 : n.tagName) && n.tagName.toLowerCase();
this.children = [], s ? (this.closed = !!n.close || Vr.indexOf(i) > -1, this.parent = s, this.tagName = i, this.attrs = n.attrs, this.from = n.pos, this.to = void 0, this.col = n.col, this.line = n.line, this.raw = n.raw) : this.root = this;
}
get depth() {
let n = 0, s = this.parent;
for (; s.parent; )
n++, s = s.parent;
return n;
}
close(n, s) {
this.to = n.pos + n.raw.length, this.raw = s.html.slice(this.from, this.to);
}
push(n) {
return this.children.push(n);
}
before(n) {
return this.children.slice(0, n);
}
after(n) {
return this.children.slice(n + 1);
}
find(...n) {
const s = (i) => i.reduce((t, o) => (o.match(...n) && t.push(o), o.children.length && (t = t.concat(s(o.children))), t), []);
return s(this.children);
}
findFirst(n) {
return this.find(n)[0];
}
index() {
return this.parent ? this.parent.children.indexOf(this) : 0;
}
isChildOf(n) {
return this.parent === n;
}
isBefore(n) {
return this.index() < n.index();
}
isAfter(n) {
return this.index() > n.index();
}
isFirst() {
return !this.parent || this.index() === 0;
}
isLast() {
return !this.parent || this.index() === this.parent.children.length - 1;
}
first() {
return this.children[0];
}
match(...n) {
return n.indexOf(this.tagName && this.tagName.toLowerCase()) > -1;
}
}
class Z {
constructor(n, s, i) {
this.parser = n, this.reporter = s;
const t = [], o = new Xt();
let e = o;
n.addListener("tagstart", (u) => {
const d = new Xt(u, e);
e.push(d), d.closed || t.push(e = d);
}), n.addListener("tagend", (u) => {
const d = u.tagName.toLowerCase();
let p;
for (p = t.length - 1; p >= 0 && t[p].tagName !== d; p--)
;
t[p] && (t[p].close(u, this.reporter), e = t[p].parent, t.splice(p, 1));
}), n.addListener("end", () => {
o.closed = !0, i && i(o);
});
}
}
const Wr = {
id: "body-no-duplicates",
description: "The body tag must not be a duplicate.",
init(f, n) {
new Z(f, n, (s) => {
let i;
for (let t of s.find("body")) {
if (!i) {
i = t;
continue;
}
n.error(
`The [ body ] tag already exists on line ${i.line}.`,
t.line,
t.col,
this,
t.raw
);
}
});
}
}, ut = (
// Generated by Peggy 3.0.2.
//
// https://peggyjs.org/
// @ts-ignore
function() {
function f(t, o) {
function e() {
this.constructor = t;
}
e.prototype = o.prototype, t.prototype = new e();
}
function n(t, o, e, u) {
var d = Error.call(this, t);
return Object.setPrototypeOf && Object.setPrototypeOf(d, n.prototype), d.expected = o, d.found = e, d.location = u, d.name = "SyntaxError", d;
}
f(n, Error);
function s(t, o, e) {
return e = e || " ", t.length > o ? t : (o -= t.length, e += e.repeat(o), t + e.slice(0, o));
}
n.prototype.format = function(t) {
var o = "Error: " + this.message;
if (this.location) {
var e = null, u;
for (u = 0; u < t.length; u++)
if (t[u].source === this.location.source) {
e = t[u].text.split(/\r\n|\n|\r/g);
break;
}
var d = this.location.start, p = this.location.source && typeof this.location.source.offset == "function" ? this.location.source.offset(d) : d, v = this.location.source + ":" + p.line + ":" + p.column;
if (e) {
var A = this.location.end, x = s("", p.line.toString().length, " "), _ = e[d.line - 1], C = d.line === A.line ? A.column : _.length + 1, L = C - d.column || 1;
o += `
--> ` + v + `
` + x + ` |
` + p.line + " | " + _ + `
` + x + " | " + s("", d.column - 1, " ") + s("", L, "^");
} else
o += `
at ` + v;
}
return o;
}, n.buildMessage = function(t, o) {
var e = {
// @ts-ignore
literal: function(_) {
return '"' + d(_.text) + '"';
},
// @ts-ignore
class: function(_) {
var C = _.parts.map(function(L) {
return Array.isArray(L) ? p(L[0]) + "-" + p(L[1]) : p(L);
});
return "[" + (_.inverted ? "^" : "") + C.join("") + "]";
},
// @ts-ignore
any: function() {
return "any character";
},
// @ts-ignore
end: function() {
return "end of input";
},
// @ts-ignore
other: function(_) {
return _.description;
}
};
function u(_) {
return _.charCodeAt(0).toString(16).toUpperCase();
}
function d(_) {
return _.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(C) {
return "\\x0" + u(C);
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(C) {
return "\\x" + u(C);
});
}
function p(_) {
return _.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(C) {
return "\\x0" + u(C);
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(C) {
return "\\x" + u(C);
});
}
function v(_) {
return e[_.type](_);
}
function A(_) {
var C = _.map(v), L, P;
if (C.sort(), C.length > 0) {
for (L = 1, P = 1; L < C.length; L++)
C[L - 1] !== C[L] && (C[P] = C[L], P++);
C.length = P;
}
switch (C.length) {
case 1:
return C[0];
case 2:
return C[0] + " or " + C[1];
default:
return C.slice(0, -1).join(", ") + ", or " + C[C.length - 1];
}
}
function x(_) {
return _ ? '"' + d(_) + '"' : "end of input";
}
return "Expected " + A(t) + " but " + x(o) + " found.";
};
function i(t, o) {
o = o !== void 0 ? o : {};
var e = {}, u = o.grammarSource, d = { start: Dt }, p = Dt, v = "<#", A = "</#", x = "${", _ = "}", C = "<#if", L = ">", P = "<#elseif", M = "<#else", U = "<#else>", S = "</#if", q = "</#if>", k = "<#list", N = "as", D = "</#list", R = "</#list>", I = "<#assign", V = "=", W = "!", J = "(", X = ")", Y = ".", be = "[", $e = "]", ye = "?", ra = "<", dt = "gt", gt = ">", ht = "gte", pt = ">e;", mt = "lt", bt = "<", $t = "lte", yt = "<e;", vt = "==", wt = "<=", _t = "!=", sa = "+", ia = "-", na = "/", la = "*", At = "&&", Tt = "||", Ct = ">=", K = '"', ee = "'", oa = "&", ca = ";", fa = ",", le = /^[a-zA-Z0-9_]/, oe = /^[ \t\n\r]/, ua = B("text"), da = B("string"), Lt = T("<#", !1), ga = T("</#", !1), ve = T("${", !1), te = gr(), ha = T("}", !1), xt = T("<#if", !1), ae = T(">", !1), Nt = T("<#elseif", !1), pa = T("<#else", !1), ma = T("<#else>", !1), ba = T("</#if", !1), $a = T("</#if>", !1), Ot = T("<#list", !1), ya = T("as", !1), va = T("</#list", !1), wa = T("</#list>", !1), jt = T("<#assign", !1), Pt = T("=", !1), we = B("expression"), ce = T("!", !1), _e = T("(", !1), Ae = T(")", !1), Et = B("equation"), fe = T(".", !1), _a = T("[", !1), Aa = T("]", !1), Ta = T("?", !1), Ca = B("modifier"), Mt = B("operator"), La = T("<", !1), xa = T("gt", !1), Na = T(">", !1), Oa = T("gte", !1), ja = T(">e;", !1), Pa = T("lt", !1), Ea = T("<", !1), Ma = T("lte", !1), ka = T("<e;", !1), qa = T("==", !1), Ra = T("<=", !1), Sa = T("!=", !1), Da = T("+", !1), Ia = T("-", !1), Fa = T("/", !1), za = T("*", !1), Ua = T("&&", !1), Ha = T("||", !1), Ba = T(">=", !1), re = T('"', !1), se = T("'", !1), ue = qt([["a", "z"], ["A", "Z"], ["0", "9"], "_"], !1, !1), Za = T("&", !1), Va = T(";", !1), Wa = B(","), Ya = T(",", !1), kt = B("whitespace"), de = qt([" ", " ", `
`, "\r"], !1, !1), Qa = function(r) {
return r.join("");
}, Ga = function(r) {
return r;
}, Ja = function(r) {
return r.flat(1 / 0).join("");
}, Xa = function(r) {
return r.flat(1 / 0).filter(Boolean).join("");
}, Ka = function(r) {
return r.flat(1 / 0).filter(Boolean).join("");
}, er = function(r) {
return r;
}, tr = function(r) {
return r;
}, ar = function(r) {
return r.flat(1 / 0).filter(Boolean).join("");
}, rr = function(r) {
return r;
}, sr = function(r) {
return r.flat(1 / 0).filter(Boolean).join("");
}, ir = function(r) {
return r.flat(1 / 0).join("");
}, nr = function(r) {
return r.flat(1 / 0).join("");
}, lr = function(r) {
return Array.isArray(r) ? r.flat(1 / 0).join("") : r;
}, or = function(r) {
return r.flat(2).join("");
}, cr = function(r) {
return r.