From 7c9d70b6d96e00cb90b038be7c392fd0ec162c30 Mon Sep 17 00:00:00 2001 From: Roy Revelt Date: Sun, 21 Feb 2021 14:47:30 +0000 Subject: [PATCH] fix: improvements to malformed `!important` recognition --- .../coverage/coverage-summary.json | 2 +- .../dist/codsen-tokenizer.cjs.js | 8 +- .../dist/codsen-tokenizer.dev.umd.js | 8 +- .../dist/codsen-tokenizer.esm.js | 8 +- .../dist/codsen-tokenizer.mjs | 2 +- .../dist/codsen-tokenizer.umd.js | 2 +- packages/codsen-tokenizer/src/main.ts | 412 +++++++++--------- .../codsen-tokenizer/test/css-broken-rule.js | 67 +++ 8 files changed, 293 insertions(+), 216 deletions(-) diff --git a/packages/codsen-tokenizer/coverage/coverage-summary.json b/packages/codsen-tokenizer/coverage/coverage-summary.json index a33d2df52b..fecbe7d500 100644 --- a/packages/codsen-tokenizer/coverage/coverage-summary.json +++ b/packages/codsen-tokenizer/coverage/coverage-summary.json @@ -1 +1 @@ -{"total":{"lines":{"total":864,"covered":805,"skipped":0,"pct":93.17},"statements":{"total":892,"covered":831,"skipped":0,"pct":93.16},"functions":{"total":43,"covered":41,"skipped":0,"pct":95.35},"branches":{"total":1390,"covered":1282,"skipped":0,"pct":92.23}}} \ No newline at end of file +{"total":{"lines":{"total":864,"covered":805,"skipped":0,"pct":93.17},"statements":{"total":892,"covered":831,"skipped":0,"pct":93.16},"functions":{"total":43,"covered":41,"skipped":0,"pct":95.35},"branches":{"total":1392,"covered":1284,"skipped":0,"pct":92.24}}} \ No newline at end of file diff --git a/packages/codsen-tokenizer/dist/codsen-tokenizer.cjs.js b/packages/codsen-tokenizer/dist/codsen-tokenizer.cjs.js index 86d9c6963b..99558e2bb5 100644 --- a/packages/codsen-tokenizer/dist/codsen-tokenizer.cjs.js +++ b/packages/codsen-tokenizer/dist/codsen-tokenizer.cjs.js @@ -1871,7 +1871,9 @@ function tokenizer(str, originalOpts) { /* istanbul ignore else */ - if (!doNothing && property && (property.valueStarts && !property.valueEnds && str[rightVal] !== "!" || property.importantStarts && !property.importantEnds) && (!property.valueEnds || str[rightVal] !== ";") && ( // either end of string was reached + if (!doNothing && property && (property.valueStarts && !property.valueEnds && str[rightVal] !== "!" && ( // either non-whitespace character doesn't exist on the right + !rightVal || // or at that character !important does not start + !str.slice(rightVal).match(importantStartsRegexp)) || property.importantStarts && !property.importantEnds) && (!property.valueEnds || str[rightVal] !== ";") && ( // either end of string was reached !str[_i] || // or it's a whitespace !str[_i].trim() || // or it's a semicolon after a value !property.valueEnds && str[_i] === ";" || // or we reached the end of the attribute @@ -1938,7 +1940,7 @@ function tokenizer(str, originalOpts) { property.importantStarts = _i; } else if (str[_i] === ";") { property.semi = _i; - } else if (rightVal && str[rightVal] === "!" || importantStartsRegexp.test(str.slice(_i))) { + } else if (rightVal && str[rightVal] === "!" || str.slice(_i).match(importantStartsRegexp)) { property.importantStarts = stringLeftRight.right(str, _i); } else if (!rightVal || str[rightVal] !== ";") { property.end = stringLeftRight.left(str, _i + 1) + 1; @@ -1978,7 +1980,7 @@ function tokenizer(str, originalOpts) { /* istanbul ignore else */ - if (!doNothing && property && property.valueEnds && !property.importantStarts && (str[_i] === "!" || isLatinLetter(str[_i])) && importantStartsRegexp.test(str.slice(_i))) { + if (!doNothing && property && property.valueEnds && !property.importantStarts && (str[_i] === "!" || isLatinLetter(str[_i])) && str.slice(_i).match(importantStartsRegexp)) { property.importantStarts = _i; } // catch the start of a css property's value // ------------------------------------------------------------------------- diff --git a/packages/codsen-tokenizer/dist/codsen-tokenizer.dev.umd.js b/packages/codsen-tokenizer/dist/codsen-tokenizer.dev.umd.js index 3d9114b0eb..7ce2b74664 100644 --- a/packages/codsen-tokenizer/dist/codsen-tokenizer.dev.umd.js +++ b/packages/codsen-tokenizer/dist/codsen-tokenizer.dev.umd.js @@ -5410,7 +5410,9 @@ function tokenizer(str, originalOpts) { /* istanbul ignore else */ - if (!doNothing && property && (property.valueStarts && !property.valueEnds && str[rightVal] !== "!" || property.importantStarts && !property.importantEnds) && (!property.valueEnds || str[rightVal] !== ";") && ( // either end of string was reached + if (!doNothing && property && (property.valueStarts && !property.valueEnds && str[rightVal] !== "!" && ( // either non-whitespace character doesn't exist on the right + !rightVal || // or at that character !important does not start + !str.slice(rightVal).match(importantStartsRegexp)) || property.importantStarts && !property.importantEnds) && (!property.valueEnds || str[rightVal] !== ";") && ( // either end of string was reached !str[_i] || // or it's a whitespace !str[_i].trim() || // or it's a semicolon after a value !property.valueEnds && str[_i] === ";" || // or we reached the end of the attribute @@ -5477,7 +5479,7 @@ function tokenizer(str, originalOpts) { property.importantStarts = _i; } else if (str[_i] === ";") { property.semi = _i; - } else if (rightVal && str[rightVal] === "!" || importantStartsRegexp.test(str.slice(_i))) { + } else if (rightVal && str[rightVal] === "!" || str.slice(_i).match(importantStartsRegexp)) { property.importantStarts = right(str, _i); } else if (!rightVal || str[rightVal] !== ";") { property.end = left(str, _i + 1) + 1; @@ -5517,7 +5519,7 @@ function tokenizer(str, originalOpts) { /* istanbul ignore else */ - if (!doNothing && property && property.valueEnds && !property.importantStarts && (str[_i] === "!" || isLatinLetter(str[_i])) && importantStartsRegexp.test(str.slice(_i))) { + if (!doNothing && property && property.valueEnds && !property.importantStarts && (str[_i] === "!" || isLatinLetter(str[_i])) && str.slice(_i).match(importantStartsRegexp)) { property.importantStarts = _i; } // catch the start of a css property's value // ------------------------------------------------------------------------- diff --git a/packages/codsen-tokenizer/dist/codsen-tokenizer.esm.js b/packages/codsen-tokenizer/dist/codsen-tokenizer.esm.js index 4dd969a562..061a1813af 100644 --- a/packages/codsen-tokenizer/dist/codsen-tokenizer.esm.js +++ b/packages/codsen-tokenizer/dist/codsen-tokenizer.esm.js @@ -1842,7 +1842,9 @@ function tokenizer(str, originalOpts) { /* istanbul ignore else */ - if (!doNothing && property && (property.valueStarts && !property.valueEnds && str[rightVal] !== "!" || property.importantStarts && !property.importantEnds) && (!property.valueEnds || str[rightVal] !== ";") && ( // either end of string was reached + if (!doNothing && property && (property.valueStarts && !property.valueEnds && str[rightVal] !== "!" && ( // either non-whitespace character doesn't exist on the right + !rightVal || // or at that character !important does not start + !str.slice(rightVal).match(importantStartsRegexp)) || property.importantStarts && !property.importantEnds) && (!property.valueEnds || str[rightVal] !== ";") && ( // either end of string was reached !str[i] || // or it's a whitespace !str[i].trim() || // or it's a semicolon after a value !property.valueEnds && str[i] === ";" || // or we reached the end of the attribute @@ -1909,7 +1911,7 @@ function tokenizer(str, originalOpts) { property.importantStarts = i; } else if (str[i] === ";") { property.semi = i; - } else if (rightVal && str[rightVal] === "!" || importantStartsRegexp.test(str.slice(i))) { + } else if (rightVal && str[rightVal] === "!" || str.slice(i).match(importantStartsRegexp)) { property.importantStarts = right(str, i); } else if (!rightVal || str[rightVal] !== ";") { property.end = left(str, i + 1) + 1; @@ -1949,7 +1951,7 @@ function tokenizer(str, originalOpts) { /* istanbul ignore else */ - if (!doNothing && property && property.valueEnds && !property.importantStarts && (str[i] === "!" || isLatinLetter(str[i])) && importantStartsRegexp.test(str.slice(i))) { + if (!doNothing && property && property.valueEnds && !property.importantStarts && (str[i] === "!" || isLatinLetter(str[i])) && str.slice(i).match(importantStartsRegexp)) { property.importantStarts = i; } // catch the start of a css property's value // ------------------------------------------------------------------------- diff --git a/packages/codsen-tokenizer/dist/codsen-tokenizer.mjs b/packages/codsen-tokenizer/dist/codsen-tokenizer.mjs index 39448866e3..df6f50e86f 100644 --- a/packages/codsen-tokenizer/dist/codsen-tokenizer.mjs +++ b/packages/codsen-tokenizer/dist/codsen-tokenizer.mjs @@ -7,4 +7,4 @@ * Homepage: https://codsen.com/os/codsen-tokenizer/ */ -import{matchRight as t,matchLeft as e,matchRightIncl as a,matchLeftIncl as r}from"string-match-left-right";import l from"lodash.clonedeep";import{right as i,left as n}from"string-left-right";import{isAttrClosing as s}from"is-html-attribute-closing";import{allHtmlAttribs as u}from"html-all-known-attributes";import{isAttrNameChar as o}from"is-char-suitable-for-html-attr-name";import{isOpening as p}from"is-html-tag-opening";const d=new Set(["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","bgsound","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","content","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","element","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","image","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","main","map","mark","marquee","menu","menuitem","meta","meter","multicol","nav","nextid","nobr","noembed","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","plaintext","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xmp"]),g="{}%-$_()*|#",c="{}|#",b="%()$_*#",h="({",m="})",y=[")|(","|(",")(","()","}{","{}","%)","*)","||","--"],f=".,;!?";function A(t){return!(!t||!(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function V(t){let e="";for(let a=0,r=t.length;a${e}`:">"===t[a]?`<${e}`:"“"===t[a]?`”${e}`:"”"===t[a]?`“${e}`:`${t[a]}${e}`;return e}function S(t){return d.has(t.toLowerCase())||["doctype","cdata","xml"].includes(t.toLowerCase())}function v(t,e,a,r){for(let l=e,i=t.length;l1&&(r.includes("<")||r.includes("{")||r.includes("[")||r.includes("("))&&"("===t[n])&&(g.includes(t[n])||i&&i.guessedClosingLump.includes(t[n])||"<"===t[e]&&"/"===t[n]||">"===t[n]&&"--"===r&&Array.isArray(a)&&a.length&&"esp"===a[a.length-1].type&&"<"===a[a.length-1].openingLump[0]&&"-"===a[a.length-1].openingLump[2]&&"-"===a[a.length-1].openingLump[3]||!i&&n>e&&"!=@".includes(t[n]));n++)r+=t[n];if(r&&Array.isArray(a)&&a.length&&"esp"===a[a.length-1].type&&a[a.length-1].guessedClosingLump&&r.length>a[a.length-1].guessedClosingLump.length){if(r.endsWith(a[a.length-1].openingLump))return r.slice(0,r.length-a[a.length-1].openingLump.length);let t=new Set(a[a.length-1].guessedClosingLump),e=0;for(let a=0,l=r.length;a1)return r.slice(0,a);t.has(r[a])&&(e+=1,t=new Set([...t].filter((t=>t!==r[a]))))}}return r}function M(a,r,l,i){return!(("<"!==a[r]||!t(a,r,["!--"],{maxMismatches:1,firstMustMatch:!0,trimBeforeMatching:!0})&&!t(a,r,["![endif]"],{i:!0,maxMismatches:2,trimBeforeMatching:!0})||t(a,r,["![cdata","<"],{i:!0,maxMismatches:1,trimBeforeMatching:!0})||"comment"===l.type&&"not"===l.kind)&&("-"!==a[r]||!t(a,r,["->"],{trimBeforeMatching:!0})||"comment"===l.type&&(l.closing||"not"===l.kind)||e(a,r,"<",{trimBeforeMatching:!0,trimCharsBeforeMatching:["-","!"]})||Array.isArray(i)&&i.length&&"esp"===i[i.length-1].type&&"<"===i[i.length-1].openingLump[0]&&"-"===i[i.length-1].openingLump[2]&&"-"===i[i.length-1].openingLump[3]))}function Q(t,e,a,r,l){return l&&("/"===t[e]&&"*"===t[e+1]||"*"===t[e]&&"/"===t[e+1])}function $(t,e,a=!1){if(!e.length)return;const r=a?e[0]:e[e.length-1];return"esp"===r.type&&(t.includes(r.guessedClosingLump)||Array.from(t).every((t=>r.guessedClosingLump.includes(t)))||r.guessedClosingLump&&r.guessedClosingLump.length>2&&r.guessedClosingLump[r.guessedClosingLump.length-1]===t[t.length-1]&&r.guessedClosingLump[r.guessedClosingLump.length-2]===t[t.length-2])?t.length:void 0}const F="\\";function q(e,a,r,l,s){return!(!e[a]||!e[a].trim().length||l.length&&"text"!==r.type||r.kind&&["doctype","xml"].includes(r.kind)||s&&"<"!==e[a]||!("<"===e[a]&&(p(e,a,{allowCustomTagNames:!0})||">"===e[i(e,a)]||t(e,a,["doctype","xml","cdata"],{i:!0,trimBeforeMatching:!0,trimCharsBeforeMatching:["?","!","["," ","-"]}))||A(e[a])&&(!e[a-1]||!A(e[a-1])&&!["<","/","!",F].includes(e[n(e,a)]))&&p(e,a,{allowCustomTagNames:!1,skipOpeningBracket:!0}))||!("esp"!==r.type||r.tail&&r.tail.includes(e[a])))}function B(t,e,a,r,l){return!!(g.includes(t[e])&&t[e+1]&&g.includes(t[e+1])&&!(b.includes(t[e])&&b.includes(t[e+1]))&&(t[e]!==t[e+1]||c.includes(t[e]))&&"rule"!==a.type&&"at"!==a.type&&!("-"===t[e]&&"-{(".includes(t[e+1]))&&!("})".includes(t[e])&&"-".includes(t[e+1]))&&!("%"===t[e]&&"%"===t[e+1]&&"0123456789".includes(t[e-1])&&(!t[e+2]||f.includes(t[e+2])||!t[e+2].trim().length))&&!(l&&("{}".includes(t[e])||"{}".includes(t[i(t,e)])))||"<"===t[e]&&("/"===t[e+1]&&g.includes(t[e+2])||g.includes(t[e+1])&&!["-"].includes(t[e+1]))||"<"===t[e]&&("%"===t[e+1]||t.startsWith("jsp:",e+1)||t.startsWith("cms:",e+1)||t.startsWith("c:",e+1))||t.startsWith("${jspProp",e)||">})".includes(t[e])&&Array.isArray(r)&&r.length&&"esp"===r[r.length-1].type&&r[r.length-1].openingLump.includes(V(t[e]))&&(">"!==t[e]||!v(t,e+1,">","<"))||"-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]&&Array.isArray(r)&&r.length&&"esp"===r[r.length-1].type&&"<"===r[r.length-1].openingLump[0]&&"-"===r[r.length-1].openingLump[2]&&"-"===r[r.length-1].openingLump[3])}const W="5.1.2",P=/^\s*!?\s*[a-zA-Z]+(?:[\s;}<>'"]|$)/gm,T={tagCb:null,tagCbLookahead:0,charCb:null,charCbLookahead:0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100};function R(p,d){const b=Date.now();if("string"!=typeof p)throw void 0===p?new Error("codsen-tokenizer: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`codsen-tokenizer: [THROW_ID_02] the first input argument must be string! It was given as "${typeof p}", equal to:\n${JSON.stringify(p,null,4)}`);if(d&&!E(d))throw new Error(`codsen-tokenizer: [THROW_ID_03] the second input argument, an options object, should be a plain object but it was given as type ${typeof d}, equal to ${JSON.stringify(d,null,4)}`);if(d&&E(d)&&d.tagCb&&"function"!=typeof d.tagCb)throw new Error(`codsen-tokenizer: [THROW_ID_04] the opts.tagCb, callback function, should be a function but it was given as type ${typeof d.tagCb}, equal to ${JSON.stringify(d.tagCb,null,4)}`);if(d&&E(d)&&d.charCb&&"function"!=typeof d.charCb)throw new Error(`codsen-tokenizer: [THROW_ID_05] the opts.charCb, callback function, should be a function but it was given as type ${typeof d.charCb}, equal to ${JSON.stringify(d.charCb,null,4)}`);if(d&&E(d)&&d.reportProgressFunc&&"function"!=typeof d.reportProgressFunc)throw new Error(`codsen-tokenizer: [THROW_ID_06] the opts.reportProgressFunc, callback function, should be a function but it was given as type ${typeof d.reportProgressFunc}, equal to ${JSON.stringify(d.reportProgressFunc,null,4)}`);const h={...T,...d};let m=0,f=0;const F=p.length,W=Math.floor(F/2);let R=0,_=!1,H=!1;const D=[],I=[];let z={};function j(){z={type:null,start:null,end:null,value:null},Z()}const J={attribName:"",attribNameRecognised:!1,attribNameStartsAt:null,attribNameEndsAt:null,attribOpeningQuoteAt:null,attribClosingQuoteAt:null,attribValueRaw:null,attribValue:[],attribValueStartsAt:null,attribValueEndsAt:null,attribStarts:null,attribEnds:null,attribLeft:null};let U={...J};function Z(){U=l(J)}function G(t){U.attribValue.length&&U.attribValue[~-U.attribValue.length].start&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].end=t.start,U.attribValue[~-U.attribValue.length].value=p.slice(U.attribValue[~-U.attribValue.length].start,t.start)),U.attribValue.push(t)}const K={start:null,end:null,property:null,propertyStarts:null,propertyEnds:null,value:null,valueStarts:null,valueEnds:null,importantStarts:null,importantEnds:null,important:null,colon:null,semi:null};let X,Y,tt,et={...K};function at(){et={...K}}function rt(t){U&&"style"===U.attribName?U.attribValue.push({...t}):z&&Array.isArray(z.properties)&&z.properties.push({...t})}j();let lt=null;const it=[];function nt(t){return!(!Array.isArray(it)||!it.length||it[~-it.length].type!==t)}function st(t){const e=(i(p,t)||t)+1;G({type:"comment",start:t,end:e,value:p.slice(t,e),closing:!0,kind:"block",language:"css"}),R=e,nt("block")&&it.pop()}function ut(t,e,a){const r=t.shift(),i=[];for(let e=0;eh.tagCbLookahead&&ut(D,h.tagCb,h.tagCbLookahead))}function pt(t,e){if(!["text","esp"].includes(t.type)&&null!==t.start&&t.start".includes(p[~-t.end]))ot(t),j(),p[~-e]&&!p[~-e].trim()&>("text",n(p,e)+1);else{let a=t.tagNameEndsAt||e;if(Array.isArray(t.attribs)&&t.attribs.length)for(let e=0,r=t.attribs.length;e1e3&&F<2e3?d===W&&h.reportProgressFunc(Math.floor((h.reportProgressFuncTo-h.reportProgressFuncFrom)/2)):F>=2e3&&(m=h.reportProgressFuncFrom+Math.floor(d/F*(h.reportProgressFuncTo-h.reportProgressFuncFrom)),m!==f&&(f=m,h.reportProgressFunc(m))));const b=n(p,d),T=i(p,d);if(_&&z.type&&!["rule","at","text","comment"].includes(z.type)&&(_=!1),R&&d>=R&&(R=0),A(p[d])&&A(p[~-d])&&A(p[d+1]))continue;if(" \t\r\n".includes(p[d])&&p[d]===p[~-d]&&p[d]===p[d+1])continue;if(!R&&nt("at")&&E(it[~-it.length].token)&&it[~-it.length].token.openingCurlyAt&&!it[~-it.length].token.closingCurlyAt)if("}"===p[d]){if(!z.type||"text"===z.type||"rule"===z.type&&null===z.openingCurlyAt){"rule"===z.type&&(z.end=b+1,z.value=p.slice(z.start,z.end),ot(z),nt("at")&&it[~-it.length].token.rules.push(z),j(),null!==b&&b<~-d&>("text",b+1)),pt(z,d);const t=it.pop();z=t.token,z.closingCurlyAt=d,z.end=d+1,z.value=p.slice(z.start,z.end),ot(z),nt("at")&&it[~-it.length].token.rules.push(z),j(),R=d+1}}else"text"===z.type&&p[d]&&p[d].trim()&&(z.end=d,z.value=p.slice(z.start,z.end),nt("at")?it[~-it.length].token.rules.push(z):ot(z),j());z.end&&z.end===d&&("style"!==z.tagName||z.closing||(_=!0),tt?(U=tt,U.attribValue.push(z),z=l(Y),tt=void 0,Y=void 0):(pt(z,d),it.length=0)),R||(["tag","rule","at"].includes(z.type)&&"cdata"!==z.kind?!p[d]||!x.includes(p[d])&&!"()".includes(p[d])||x.includes(p[b])&&p[b]===p[T]||!bt(d)||(nt("simple")&&it[~-it.length].value===V(p[d])?it.pop():it.push({type:"simple",value:p[d],position:d})):"comment"===z.type&&["only","not"].includes(z.kind)?["[","]"].includes(p[d])&&(nt("simple")&&it[~-it.length].value===V(p[d])?it.pop():it.push({type:"simple",value:p[d],position:d})):"esp"!==z.type||!"'\"`()".includes(p[d])||['"',"'","`"].includes(p[b])&&p[b]===p[T]||(nt("simple")&&it[~-it.length].value===V(p[d])?(it.pop(),R=d+1):"]})>".includes(p[d])||it.push({type:"simple",value:p[d],position:d}))),!R&&"at"===z.type&&null!=z.start&&d>=z.start&&!z.identifierStartsAt&&p[d]&&p[d].trim()&&"@"!==p[d]&&(z.identifierStartsAt=d),!R&&"at"===z.type&&z.queryStartsAt&&!z.queryEndsAt&&"{;".includes(p[d])&&(z.queryEndsAt="{"===p[d]?p[~-d]&&p[~-d].trim()?d:null!==b?b+1:d:n(p,d+1)||0,z.queryStartsAt&&z.queryEndsAt&&(z.query=p.slice(z.queryStartsAt,z.queryEndsAt)),z.end=";"===p[d]?d+1:d,z.value=p.slice(z.start,z.end),";"===p[d]?ot(z):(z.openingCurlyAt=d,it.push({type:"at",token:z})),j(),R=d+1),!R&&"at"===z.type&&z.identifier&&p[d]&&p[d].trim()&&!z.queryStartsAt&&(z.queryStartsAt=d),!R&&z&&"at"===z.type&&z.identifierStartsAt&&d>=z.start&&p[d]&&(!p[d].trim()||"()".includes(p[d]))&&!z.identifierEndsAt&&(z.identifierEndsAt=d,z.identifier=p.slice(z.identifierStartsAt,d)),"rule"===z.type&&X&&(N.includes(p[d])||p[d]&&!p[d].trim()&&N.includes(p[T]))&&(z.selectors.push({value:p.slice(X,d),selectorStarts:X,selectorEnds:d}),X=void 0,z.selectorsEnd=d);const D=O(it);if(!R&&p[d])if(q(p,d,z,it,_)){z.type&&null!==z.start&&("rule"===z.type&&et&&et.propertyStarts&&(et.propertyEnds=d,et.property=p.slice(et.propertyStarts,d),et.end||(et.end=d),rt(et),at()),pt(z,d),j()),gt("tag",d),_&&(_=!1);const t="?![-/";let e="",a=!1;if(T)for(let r=T;r1&&it[D].guessedClosingLump.includes(p[d])&&it[D].guessedClosingLump.includes(p[d+1])&&!(it[D+1]&&"'\"".includes(it[D+1].value)&&p.indexOf(it[D+1].value,d)>0&&it[D].guessedClosingLump.includes(p[i(p,p.indexOf(it[D+1].value,d))]))||B(p,d,z,it,_)&&(!nt("simple")||!["'",'"'].includes(it[~-it.length].value)||U&&U.attribStarts&&!U.attribEnds)){const t=w(p,d,it);if(!y.includes(t)){let e,a;if(it.length&&(e=$(t,it))){if("esp"===z.type){if(z.end||(z.end=d+e,z.value=p.slice(z.start,z.end),z.tail=p.slice(d,d+e),z.tailStartsAt=d,z.tailEndsAt=z.end,">"===p[d]&&"/"===p[b]&&(z.tailStartsAt=b,z.tail=p.slice(z.tailStartsAt,d+1))),R=z.tailEndsAt,Y){Array.isArray(Y.attribs)||(Y.attribs=[]),tt?(U=tt,U.attribValue.push({...z})):Y.attribs.push({...z}),z=l(Y),Y=void 0,tt=void 0,it.pop();continue}pt(z,d),j()}it.pop()}else if(it.length&&(e=$(t,it,!0)))"esp"===z.type&&(z.end||(z.end=d+(e||0),z.value=p.slice(z.start,z.end)),z.tailStartsAt||(z.tailStartsAt=d),!z.tailEndsAt&&e&&(z.tailEndsAt=z.tailStartsAt+e,z.tail=p.slice(d,d+e)),pt(z,d),j()),it.length=0;else if(U&&U.attribValue&&U.attribValue.length&&U.attribValue[~-U.attribValue.length].start&&Array.from(p.slice(U.attribValue[~-U.attribValue.length].start,d)).some(((e,r)=>t.includes(V(e))&&(c.includes(e)||!r)&&(a={char:e,idx:r})))&&"tag"===z.type&&U&&U.attribValueStartsAt&&!U.attribValueEndsAt&&U.attribValue[~-U.attribValue.length]&&"text"===U.attribValue[~-U.attribValue.length].type){z.pureHTML=!1;const e=U.attribValue[~-U.attribValue.length],r=dt("esp",e.start);a&&a.idx||(r.head=a.char,r.headStartsAt=e.start,r.headEndsAt=r.headStartsAt+1,r.tailStartsAt=d,r.tailEndsAt=d+t.length,r.tail=t,U.attribValue[~-U.attribValue.length]=r)}else nt("esp")&&it.pop(),tt&&(Array.isArray(tt.attribValue)||(tt.attribValue=[]),tt.attribValue.push(z)),it.push({type:"esp",openingLump:t,guessedClosingLump:V(t),position:d}),null!==z.start&&("tag"===z.type?(!z.tagNameStartsAt||z.tagName&&z.tagNameEndsAt||(z.tagNameEndsAt=d,z.tagName=p.slice(z.tagNameStartsAt,d),z.recognised=S(z.tagName)),Y=l(z),U.attribStarts&&!U.attribEnds&&(tt=l(U))):tt?tt&&Array.isArray(tt.attribValue)&&tt.attribValue.length&&"esp"===tt.attribValue[~-tt.attribValue.length].type&&!tt.attribValue[~-tt.attribValue.length].end&&(tt.attribValue[~-tt.attribValue.length].end=d,tt.attribValue[~-tt.attribValue.length].value=p.slice(tt.attribValue[~-tt.attribValue.length].start,d)):pt(z,d)),gt("esp",d),z.head=t,z.headStartsAt=d,z.headEndsAt=d+t.length,Y&&Y.pureHTML&&(Y.pureHTML=!1),tt&&Array.isArray(tt.attribValue)&&tt.attribValue.length&&(tt.attribValue[~-tt.attribValue.length].start===z.start?tt.attribValue.pop():"text"!==tt.attribValue[~-tt.attribValue.length].type||tt.attribValue[~-tt.attribValue.length].end||(tt.attribValue[~-tt.attribValue.length].end=d,tt.attribValue[~-tt.attribValue.length].value=p.slice(tt.attribValue[~-tt.attribValue.length].start,d)));R=d+(e||t.length)}}else!_||H||!p[d]||!p[d].trim()||"{}".includes(p[d])||z.type&&!["text"].includes(z.type)?z.type||gt("text",d):(z.type&&pt(z,d),gt("@"===p[d]?"at":"rule",d),z.left=lt,z.nested=it.some((t=>"at"===t.type)));if(R||!et||!(et.valueStarts&&!et.valueEnds&&"!"!==p[T]||et.importantStarts&&!et.importantEnds)||et.valueEnds&&";"===p[T]||p[d]&&p[d].trim()&&(et.valueEnds||";"!==p[d])&&((!";}/".includes(p[mt=d])||U&&U.attribName&&"style"===U.attribName)&&!("/;'\"><".includes(p[mt])&&U&&"style"===U.attribName&&bt(mt)))||(et.importantStarts&&!et.importantEnds&&(et.importantEnds=n(p,d)+1,et.important=p.slice(et.importantStarts,et.importantEnds)),et.valueStarts&&!et.valueEnds&&(et.valueEnds=d,et.value=p.slice(et.valueStarts,d)),";"===p[d]?(et.semi=d,et.end=d+1):";"===p[T]&&(et.semi=T,et.end=et.semi+1,R=et.end),et.end||(et.end=d),rt(et),at()),R||!et||!(et.valueStarts&&!et.valueEnds||et.propertyEnds&&!et.valueStarts&&!T)||!p[d]||p[d].trim()&&"!"!==p[d]&&";"!==p[d]||(et.valueStarts&&!et.valueEnds&&(et.valueEnds=d,et.value=p.slice(et.valueStarts,d)),"!"===p[d]?et.importantStarts=d:";"===p[d]?et.semi=d:T&&"!"===p[T]||P.test(p.slice(d))?et.importantStarts=i(p,d):T&&";"===p[T]||(et.end=n(p,d+1)+1,rt(et),at()),et.start||!p[d]||p[d].trim()||rt({type:"text",start:d,end:null,value:null})),!R&&et&&et.start&&!et.end&&";"===p[d]&&(et.semi=d,et.end=d+1,et.propertyEnds||(et.propertyEnds=d),et.propertyStarts&&et.propertyEnds&&!et.property&&(et.property=p.slice(et.propertyStarts,et.propertyEnds)),rt(et),at()),!R&&et&&et.valueEnds&&!et.importantStarts&&("!"===p[d]||A(p[d]))&&P.test(p.slice(d))&&(et.importantStarts=d),!R&&et&&et.colon&&!et.valueStarts&&p[d]&&p[d].trim())if(";}'\"".includes(p[d])&&bt(d)){let t;";"===p[d]&&(et.semi=d),et.end||(et.end=et.semi?et.semi+1:n(p,d)+1,t=et.end),rt(et),at(),t&&t"!==p[d])if("comment"===z.type&&"html"===z.language&&!it.length&&"simple"===z.kind&&("<"===p[z.start]&&"-"===p[d]&&(e(p,d,"!-",{trimBeforeMatching:!0})||r(p,d,"!-",{trimBeforeMatching:!0})&&"-"!==p[d+1])||"-"===p[z.start]&&">"===p[d]&&e(p,d,"--",{trimBeforeMatching:!0,maxMismatches:1})))"-"===p[d]&&(t(p,d,["[if","(if","{if"],{i:!0,trimBeforeMatching:!0})||t(p,d,["if"],{i:!0,trimBeforeMatching:!0})&&(v(p,d,"]",">")||p.includes("mso",d)&&!p.slice(d,p.indexOf("mso")).includes("<")&&!p.slice(d,p.indexOf("mso")).includes(">")))?z.kind="only":"-"!==p[z.start]&&a(p,d,["-"!==p[T]?"html"===z.language&&(z.end=d+1,"!"===p[b]&&"-"===p[T]&&(z.end=T+1),z.value=p.slice(z.start,z.end)):(z.end=T+1,z.kind="simplet",z.closing=null);else if("comment"!==z.type||"html"!==z.language||">"!==p[d]||it.length&&"<"!==p[T]){if("comment"===z.type&&"css"===z.language&&"*"===p[d]&&"/"===p[d+1])z.end=d+1,z.value=p.slice(z.start,z.end);else if("esp"===z.type&&null===z.end&&"string"==typeof z.head&&"string"==typeof z.tail&&z.tail.includes(p[d])){let t="";for(let e=d;ez.head.length){const e=z.head[0];if(t.endsWith(z.head))z.end=d+t.length-z.head.length,z.value=p.slice(z.start,z.end),R=z.end;else if(t.startsWith(z.tail))z.end=d+z.tail.length,z.value=p.slice(z.start,z.end),R=z.end;else if(!z.tail.includes(e)&&t.includes(e)||t.endsWith(z.head)||t.startsWith(z.tail)){const a=t.slice(0,t.indexOf(e)),r=t.slice(t.indexOf(e));a.length&&r.length&&z.tail.split("").every((t=>a.includes(t)))&&(z.end=d+a.length,z.value=p.slice(z.start,z.end),R=z.end)}else z.end=d+t.length,z.value=p.slice(z.start,z.end),R=z.end}else z.end=d+t.length,z.value=p.slice(z.start,z.end),nt("esp")&&it.pop(),R=z.end}}else Array.isArray(it)&&it.length&&"["===it[~-it.length].value&&it.pop(),!["simplet","not"].includes(z.kind)&&t(p,d,["\x3c!--\x3e","\x3c!----\x3e"],{trimBeforeMatching:!0,maxMismatches:1,lastMustMatch:!0})?z.kind="not":(z.end=d+1,z.value=p.slice(z.start,z.end));else z.end=d+1,z.value=p.slice(z.start,z.end);if(R||"tag"!==z.type||!z.tagNameStartsAt||z.tagNameEndsAt||p[d]&&/[.\-_a-z0-9\u00B7\u00C0-\uFFFD]/i.test(p[d])||(z.tagNameEndsAt=d,z.tagName=p.slice(z.tagNameStartsAt,d).toLowerCase(),"xml"===z.tagName&&z.closing&&!z.kind&&(z.kind="xml"),C.includes(z.tagName)&&(z.void=!0),z.recognised=S(z.tagName)),R||"tag"!==z.type||z.tagNameStartsAt||null==z.start||!(z.startU.attribNameStartsAt&&null===U.attribNameEndsAt&&!o(p[d])&&(U.attribNameEndsAt=d,U.attribName=p.slice(U.attribNameStartsAt,d),U.attribNameRecognised=u.has(U.attribName),U.attribName.startsWith("mc:")&&(z.pureHTML=!1),p[d]&&!p[d].trim()&&"="===p[T]||(p[d]&&!p[d].trim()||">"===p[d]||"/"===p[d]&&">"===p[T])&&("'\"".includes(p[T])||(U.attribEnds=d,z.attribs.push(l(U)),Z()))),!R&&p[d]&&"tag"===z.type&&"cdata"!==z.kind&&z.tagNameEndsAt&&d>z.tagNameEndsAt&&null===U.attribStarts&&o(p[d])&&(U.attribStarts=d,U.attribLeft=lt,U.attribNameStartsAt=d),R||"rule"!==z.type||("{"!==p[d]||z.openingCurlyAt?"}"===p[d]&&z.openingCurlyAt&&!z.closingCurlyAt&&(z.closingCurlyAt=d,z.end=d+1,z.value=p.slice(z.start,z.end),Array.isArray(z.properties)&&z.properties.length&&z.properties[~-z.properties.length].start&&!z.properties[~-z.properties.length].end&&(z.properties[~-z.properties.length].end=d,z.properties[~-z.properties.length].value=p.slice(z.properties[~-z.properties.length].start,d)),ot(z),nt("at")&&it[~-it.length].token.rules.push(z),j()):z.openingCurlyAt=d),!R&&U.attribName&&Array.isArray(U.attribValue)&&U.attribValue.length&&!U.attribValue[~-U.attribValue.length].end&&"*"===p[d]&&"/"===p[T]&&st(d),(!R&&U&&U.attribValueStartsAt&&!U.attribValueEndsAt&&!et.propertyStarts&&d>=U.attribValueStartsAt&&Array.isArray(U.attribValue)&&(!U.attribValue.length||U.attribValue[~-U.attribValue.length].end&&U.attribValue[~-U.attribValue.length].end<=d)||!R&&"rule"===z.type&&z.openingCurlyAt&&!z.closingCurlyAt&&!et.propertyStarts)&&(p[d]&&!p[d].trim()||nt("block"))&&(U.attribName?U.attribValue.push({type:"text",start:d,end:null,value:null}):"rule"!==z.type||Array.isArray(z.properties)&&z.properties.length&&!z.properties[~-z.properties.length].end||z.properties.push({type:"text",start:d,end:null,value:null})),!R&&"tag"===z.type&&U.attribValueStartsAt&&d>=U.attribValueStartsAt&&null===U.attribValueEndsAt)if(x.includes(p[d]))it.some((t=>"esp"===t.type))||p[d]&&p.includes(">",d)&&!s(p,U.attribOpeningQuoteAt||U.attribValueStartsAt,d)?Array.isArray(U.attribValue)&&U.attribValue.length&&"text"===U.attribValue[~-U.attribValue.length].type||et.propertyStarts||U.attribValue.push({type:"text",start:d,end:null,value:null}):(U.attribClosingQuoteAt=d,U.attribValueEndsAt=d,U.attribValueStartsAt&&(U.attribValueRaw=p.slice(U.attribValueStartsAt,d)),U.attribEnds=d+1,et.propertyStarts&&(U.attribValue.push(l(et)),at()),Array.isArray(U.attribValue)&&U.attribValue.length&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].property||(U.attribValue[~-U.attribValue.length].end=d,U.attribValue[~-U.attribValue.length].value=p.slice(U.attribValue[~-U.attribValue.length].start,d))),p[U.attribOpeningQuoteAt]!==p[d]&&(it.pop(),it.pop()),U.attribValue[~-U.attribValue.length]&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].end=d),z.attribs.push(l(U)),Z());else if(null===U.attribOpeningQuoteAt&&(p[d]&&!p[d].trim()||["/",">"].includes(p[d])||g.includes(p[d])&&g.includes(p[d+1])))U.attribValueEndsAt=d,U.attribValueRaw=p.slice(U.attribValueStartsAt,d),Array.isArray(U.attribValue)&&U.attribValue.length&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].end=d,U.attribValue[~-U.attribValue.length].value=p.slice(U.attribValue[~-U.attribValue.length].start,U.attribValue[~-U.attribValue.length].end)),U.attribEnds=d,z.attribs.push(l(U)),Z(),it.pop(),">"===p[d]&&(z.end=d+1,z.value=p.slice(z.start,z.end));else if("="!==p[d]||null===b||!T||!("'\"".includes(p[T])||p[~-d]&&A(p[~-d]))||U&&U.attribOpeningQuoteAt&&(/\//.test(p.slice(U.attribOpeningQuoteAt+1,d))||/mailto:/.test(p.slice(U.attribOpeningQuoteAt+1,d))||/\w\?\w/.test(p.slice(U.attribOpeningQuoteAt+1,d))))!U||"style"===U.attribName||!U.attribStarts||U.attribEnds||et.propertyStarts||Array.isArray(U.attribValue)&&U.attribValue.length&&!(U.attribValue[~-U.attribValue.length].end&&U.attribValue[~-U.attribValue.length].end<=d)||U.attribValue.push({type:"text",start:d,end:null,value:null});else{let t,e;for(let a=b;a>=U.attribValueStartsAt;a--)t||!p[a]||p[a].trim()||(t=!0,e&&p.slice(a,e)),t&&p[a]&&p[a].trim()&&(t=!1,e||(e=a+1));if(e){U.attribValueEndsAt=e,U.attribValueStartsAt&&(U.attribValueRaw=p.slice(U.attribValueStartsAt,e),Array.isArray(U.attribValue)&&U.attribValue.length&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].end=U.attribValueEndsAt,U.attribValue[~-U.attribValue.length].value=p.slice(U.attribValue[~-U.attribValue.length].start,U.attribValueEndsAt))),U.attribEnds=e,p[U.attribOpeningQuoteAt]!==p[d]&&it.pop(),z.attribs.push(l(U)),Z(),d=~-e;continue}if(U.attribOpeningQuoteAt&&("'\"".includes(p[T])||u.has(p.slice(U.attribOpeningQuoteAt+1,d).trim()))){d=U.attribOpeningQuoteAt,U.attribEnds=U.attribOpeningQuoteAt+1,U.attribValueStartsAt=null,it.pop(),z.attribs.push(l(U)),Z();continue}}else"esp"===z.type&&tt&&Y&&tt.attribOpeningQuoteAt&&tt.attribValueStartsAt&&"'\"".includes(p[d])&&p[tt.attribOpeningQuoteAt]===p[d]&&s(p,tt.attribOpeningQuoteAt,d)&&(z.end=d,z.value=p.slice(z.start,d),tt&&!Array.isArray(tt.attribValue)&&(tt.attribValue=[]),tt.attribValue.push(z),tt.attribValueEndsAt=d,tt.attribValueRaw=p.slice(tt.attribValueStartsAt,d),tt.attribClosingQuoteAt=d,tt.attribEnds=d+1,z=l(Y),z.attribs.push(tt),tt=void 0,Y=void 0,it.pop(),it.pop(),it.pop());if(!R&&"tag"===z.type&&!U.attribValueStartsAt&&U.attribNameEndsAt&&U.attribNameEndsAt<=d&&p[d]&&p[d].trim())if("="!==p[d]||x.includes(p[T])||"=".includes(p[T])||g.includes(p[T])){if(x.includes(p[d])){const t=T;!(t&&x.includes(p[t])&&p[d]!==p[t]&&p.length>t+2&&p.slice(t+1).includes(p[t]))||p.indexOf(p[t],t+1)&&i(p,p.indexOf(p[t],t+1))&&p[d]===p[i(p,p.indexOf(p[t],t+1))]||Array.from(p.slice(t+1,p.indexOf(p[t]))).some((t=>`<>=${p[d]}`.includes(t)))?U.attribOpeningQuoteAt?(s(p,U.attribOpeningQuoteAt,d)&&(U.attribClosingQuoteAt=d),U.attribOpeningQuoteAt&&U.attribClosingQuoteAt&&(U.attribValueRaw=U.attribOpeningQuoteAt<~-U.attribClosingQuoteAt?p.slice(U.attribOpeningQuoteAt+1,U.attribClosingQuoteAt):"",U.attribEnds=d+1,z.attribs.push(l(U)),Z())):(U.attribOpeningQuoteAt=d,!p[d+1]||p[d+1]===p[d]&&bt(d+1)||(U.attribValueStartsAt=d+1)):it.pop()}}else{const t=x.split("").map((t=>p.indexOf(t,T))).filter((t=>t>0)).length?Math.min(...x.split("").map((t=>p.indexOf(t,T))).filter((t=>t>0))):void 0;T&&p.slice(T).includes("=")&&u.has(p.slice(T,T+p.slice(T).indexOf("=")).trim().toLowerCase())?(U.attribEnds=d+1,z.attribs.push({...U}),Z()):t&&!p.slice(T,t).includes("=")&&p.includes(p[t],t+1)&&!Array.from(p.slice(t+1,p.indexOf(p[t],t+1))).some((t=>"<>=".includes(t)))||(U.attribValueStartsAt=T,it.push({type:"simple",value:null,position:U.attribValueStartsAt}))}if(!R&&">"===p[d]&&"%"!==p[d-1]&&"tag"===z.type&&U.attribStarts&&!U.attribEnds){let t=!1;if(p[d+1])for(let e=d+1;e"===p[e])break;if("<"===p[e]){t=!0,it.pop();break}if(!p[e+1]){t=!0;break}}else t=!0;t&&(z.end=d+1,z.value=p.slice(z.start,z.end),U.attribValueStartsAt&&d&&U.attribValueStartsAth.charCbLookahead&&ut(I,h.charCb,h.charCbLookahead))),p[d]||null===z.start||(z.end=d,z.value=p.slice(z.start,z.end),U&&U.attribName&&(U.attribEnds||(U.attribEnds=d),z.attribs.push({...U}),Z()),z&&Array.isArray(z.properties)&&z.properties.length&&!z.properties[~-z.properties.length].end&&(z.properties[~-z.properties.length].end=d,z.properties[~-z.properties.length].start&&!z.properties[~-z.properties.length].value&&(z.properties[~-z.properties.length].value=p.slice(z.properties[~-z.properties.length].start,d))),et&&et.propertyStarts&&(et.end||(et.end=d),rt(et),at()),ot(z)),p[d]&&p[d].trim()&&(lt=d)}var ht,mt;if(I.length)for(let t=0,e=I.length;t64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function V(t){let e="";for(let a=0,r=t.length;a${e}`:">"===t[a]?`<${e}`:"“"===t[a]?`”${e}`:"”"===t[a]?`“${e}`:`${t[a]}${e}`;return e}function S(t){return d.has(t.toLowerCase())||["doctype","cdata","xml"].includes(t.toLowerCase())}function v(t,e,a,r){for(let l=e,i=t.length;l1&&(r.includes("<")||r.includes("{")||r.includes("[")||r.includes("("))&&"("===t[n])&&(g.includes(t[n])||i&&i.guessedClosingLump.includes(t[n])||"<"===t[e]&&"/"===t[n]||">"===t[n]&&"--"===r&&Array.isArray(a)&&a.length&&"esp"===a[a.length-1].type&&"<"===a[a.length-1].openingLump[0]&&"-"===a[a.length-1].openingLump[2]&&"-"===a[a.length-1].openingLump[3]||!i&&n>e&&"!=@".includes(t[n]));n++)r+=t[n];if(r&&Array.isArray(a)&&a.length&&"esp"===a[a.length-1].type&&a[a.length-1].guessedClosingLump&&r.length>a[a.length-1].guessedClosingLump.length){if(r.endsWith(a[a.length-1].openingLump))return r.slice(0,r.length-a[a.length-1].openingLump.length);let t=new Set(a[a.length-1].guessedClosingLump),e=0;for(let a=0,l=r.length;a1)return r.slice(0,a);t.has(r[a])&&(e+=1,t=new Set([...t].filter((t=>t!==r[a]))))}}return r}function M(a,r,l,i){return!(("<"!==a[r]||!t(a,r,["!--"],{maxMismatches:1,firstMustMatch:!0,trimBeforeMatching:!0})&&!t(a,r,["![endif]"],{i:!0,maxMismatches:2,trimBeforeMatching:!0})||t(a,r,["![cdata","<"],{i:!0,maxMismatches:1,trimBeforeMatching:!0})||"comment"===l.type&&"not"===l.kind)&&("-"!==a[r]||!t(a,r,["->"],{trimBeforeMatching:!0})||"comment"===l.type&&(l.closing||"not"===l.kind)||e(a,r,"<",{trimBeforeMatching:!0,trimCharsBeforeMatching:["-","!"]})||Array.isArray(i)&&i.length&&"esp"===i[i.length-1].type&&"<"===i[i.length-1].openingLump[0]&&"-"===i[i.length-1].openingLump[2]&&"-"===i[i.length-1].openingLump[3]))}function Q(t,e,a,r,l){return l&&("/"===t[e]&&"*"===t[e+1]||"*"===t[e]&&"/"===t[e+1])}function $(t,e,a=!1){if(!e.length)return;const r=a?e[0]:e[e.length-1];return"esp"===r.type&&(t.includes(r.guessedClosingLump)||Array.from(t).every((t=>r.guessedClosingLump.includes(t)))||r.guessedClosingLump&&r.guessedClosingLump.length>2&&r.guessedClosingLump[r.guessedClosingLump.length-1]===t[t.length-1]&&r.guessedClosingLump[r.guessedClosingLump.length-2]===t[t.length-2])?t.length:void 0}const F="\\";function q(e,a,r,l,s){return!(!e[a]||!e[a].trim().length||l.length&&"text"!==r.type||r.kind&&["doctype","xml"].includes(r.kind)||s&&"<"!==e[a]||!("<"===e[a]&&(p(e,a,{allowCustomTagNames:!0})||">"===e[i(e,a)]||t(e,a,["doctype","xml","cdata"],{i:!0,trimBeforeMatching:!0,trimCharsBeforeMatching:["?","!","["," ","-"]}))||A(e[a])&&(!e[a-1]||!A(e[a-1])&&!["<","/","!",F].includes(e[n(e,a)]))&&p(e,a,{allowCustomTagNames:!1,skipOpeningBracket:!0}))||!("esp"!==r.type||r.tail&&r.tail.includes(e[a])))}function B(t,e,a,r,l){return!!(g.includes(t[e])&&t[e+1]&&g.includes(t[e+1])&&!(b.includes(t[e])&&b.includes(t[e+1]))&&(t[e]!==t[e+1]||c.includes(t[e]))&&"rule"!==a.type&&"at"!==a.type&&!("-"===t[e]&&"-{(".includes(t[e+1]))&&!("})".includes(t[e])&&"-".includes(t[e+1]))&&!("%"===t[e]&&"%"===t[e+1]&&"0123456789".includes(t[e-1])&&(!t[e+2]||f.includes(t[e+2])||!t[e+2].trim().length))&&!(l&&("{}".includes(t[e])||"{}".includes(t[i(t,e)])))||"<"===t[e]&&("/"===t[e+1]&&g.includes(t[e+2])||g.includes(t[e+1])&&!["-"].includes(t[e+1]))||"<"===t[e]&&("%"===t[e+1]||t.startsWith("jsp:",e+1)||t.startsWith("cms:",e+1)||t.startsWith("c:",e+1))||t.startsWith("${jspProp",e)||">})".includes(t[e])&&Array.isArray(r)&&r.length&&"esp"===r[r.length-1].type&&r[r.length-1].openingLump.includes(V(t[e]))&&(">"!==t[e]||!v(t,e+1,">","<"))||"-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]&&Array.isArray(r)&&r.length&&"esp"===r[r.length-1].type&&"<"===r[r.length-1].openingLump[0]&&"-"===r[r.length-1].openingLump[2]&&"-"===r[r.length-1].openingLump[3])}const W="5.1.2",P=/^\s*!?\s*[a-zA-Z]+(?:[\s;}<>'"]|$)/gm,T={tagCb:null,tagCbLookahead:0,charCb:null,charCbLookahead:0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100};function R(p,d){const b=Date.now();if("string"!=typeof p)throw void 0===p?new Error("codsen-tokenizer: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`codsen-tokenizer: [THROW_ID_02] the first input argument must be string! It was given as "${typeof p}", equal to:\n${JSON.stringify(p,null,4)}`);if(d&&!E(d))throw new Error(`codsen-tokenizer: [THROW_ID_03] the second input argument, an options object, should be a plain object but it was given as type ${typeof d}, equal to ${JSON.stringify(d,null,4)}`);if(d&&E(d)&&d.tagCb&&"function"!=typeof d.tagCb)throw new Error(`codsen-tokenizer: [THROW_ID_04] the opts.tagCb, callback function, should be a function but it was given as type ${typeof d.tagCb}, equal to ${JSON.stringify(d.tagCb,null,4)}`);if(d&&E(d)&&d.charCb&&"function"!=typeof d.charCb)throw new Error(`codsen-tokenizer: [THROW_ID_05] the opts.charCb, callback function, should be a function but it was given as type ${typeof d.charCb}, equal to ${JSON.stringify(d.charCb,null,4)}`);if(d&&E(d)&&d.reportProgressFunc&&"function"!=typeof d.reportProgressFunc)throw new Error(`codsen-tokenizer: [THROW_ID_06] the opts.reportProgressFunc, callback function, should be a function but it was given as type ${typeof d.reportProgressFunc}, equal to ${JSON.stringify(d.reportProgressFunc,null,4)}`);const h={...T,...d};let m=0,f=0;const F=p.length,W=Math.floor(F/2);let R=0,_=!1,H=!1;const D=[],I=[];let z={};function j(){z={type:null,start:null,end:null,value:null},Z()}const J={attribName:"",attribNameRecognised:!1,attribNameStartsAt:null,attribNameEndsAt:null,attribOpeningQuoteAt:null,attribClosingQuoteAt:null,attribValueRaw:null,attribValue:[],attribValueStartsAt:null,attribValueEndsAt:null,attribStarts:null,attribEnds:null,attribLeft:null};let U={...J};function Z(){U=l(J)}function G(t){U.attribValue.length&&U.attribValue[~-U.attribValue.length].start&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].end=t.start,U.attribValue[~-U.attribValue.length].value=p.slice(U.attribValue[~-U.attribValue.length].start,t.start)),U.attribValue.push(t)}const K={start:null,end:null,property:null,propertyStarts:null,propertyEnds:null,value:null,valueStarts:null,valueEnds:null,importantStarts:null,importantEnds:null,important:null,colon:null,semi:null};let X,Y,tt,et={...K};function at(){et={...K}}function rt(t){U&&"style"===U.attribName?U.attribValue.push({...t}):z&&Array.isArray(z.properties)&&z.properties.push({...t})}j();let lt=null;const it=[];function nt(t){return!(!Array.isArray(it)||!it.length||it[~-it.length].type!==t)}function st(t){const e=(i(p,t)||t)+1;G({type:"comment",start:t,end:e,value:p.slice(t,e),closing:!0,kind:"block",language:"css"}),R=e,nt("block")&&it.pop()}function ut(t,e,a){const r=t.shift(),i=[];for(let e=0;eh.tagCbLookahead&&ut(D,h.tagCb,h.tagCbLookahead))}function pt(t,e){if(!["text","esp"].includes(t.type)&&null!==t.start&&t.start".includes(p[~-t.end]))ot(t),j(),p[~-e]&&!p[~-e].trim()&>("text",n(p,e)+1);else{let a=t.tagNameEndsAt||e;if(Array.isArray(t.attribs)&&t.attribs.length)for(let e=0,r=t.attribs.length;e1e3&&F<2e3?d===W&&h.reportProgressFunc(Math.floor((h.reportProgressFuncTo-h.reportProgressFuncFrom)/2)):F>=2e3&&(m=h.reportProgressFuncFrom+Math.floor(d/F*(h.reportProgressFuncTo-h.reportProgressFuncFrom)),m!==f&&(f=m,h.reportProgressFunc(m))));const b=n(p,d),T=i(p,d);if(_&&z.type&&!["rule","at","text","comment"].includes(z.type)&&(_=!1),R&&d>=R&&(R=0),A(p[d])&&A(p[~-d])&&A(p[d+1]))continue;if(" \t\r\n".includes(p[d])&&p[d]===p[~-d]&&p[d]===p[d+1])continue;if(!R&&nt("at")&&E(it[~-it.length].token)&&it[~-it.length].token.openingCurlyAt&&!it[~-it.length].token.closingCurlyAt)if("}"===p[d]){if(!z.type||"text"===z.type||"rule"===z.type&&null===z.openingCurlyAt){"rule"===z.type&&(z.end=b+1,z.value=p.slice(z.start,z.end),ot(z),nt("at")&&it[~-it.length].token.rules.push(z),j(),null!==b&&b<~-d&>("text",b+1)),pt(z,d);const t=it.pop();z=t.token,z.closingCurlyAt=d,z.end=d+1,z.value=p.slice(z.start,z.end),ot(z),nt("at")&&it[~-it.length].token.rules.push(z),j(),R=d+1}}else"text"===z.type&&p[d]&&p[d].trim()&&(z.end=d,z.value=p.slice(z.start,z.end),nt("at")?it[~-it.length].token.rules.push(z):ot(z),j());z.end&&z.end===d&&("style"!==z.tagName||z.closing||(_=!0),tt?(U=tt,U.attribValue.push(z),z=l(Y),tt=void 0,Y=void 0):(pt(z,d),it.length=0)),R||(["tag","rule","at"].includes(z.type)&&"cdata"!==z.kind?!p[d]||!x.includes(p[d])&&!"()".includes(p[d])||x.includes(p[b])&&p[b]===p[T]||!bt(d)||(nt("simple")&&it[~-it.length].value===V(p[d])?it.pop():it.push({type:"simple",value:p[d],position:d})):"comment"===z.type&&["only","not"].includes(z.kind)?["[","]"].includes(p[d])&&(nt("simple")&&it[~-it.length].value===V(p[d])?it.pop():it.push({type:"simple",value:p[d],position:d})):"esp"!==z.type||!"'\"`()".includes(p[d])||['"',"'","`"].includes(p[b])&&p[b]===p[T]||(nt("simple")&&it[~-it.length].value===V(p[d])?(it.pop(),R=d+1):"]})>".includes(p[d])||it.push({type:"simple",value:p[d],position:d}))),!R&&"at"===z.type&&null!=z.start&&d>=z.start&&!z.identifierStartsAt&&p[d]&&p[d].trim()&&"@"!==p[d]&&(z.identifierStartsAt=d),!R&&"at"===z.type&&z.queryStartsAt&&!z.queryEndsAt&&"{;".includes(p[d])&&(z.queryEndsAt="{"===p[d]?p[~-d]&&p[~-d].trim()?d:null!==b?b+1:d:n(p,d+1)||0,z.queryStartsAt&&z.queryEndsAt&&(z.query=p.slice(z.queryStartsAt,z.queryEndsAt)),z.end=";"===p[d]?d+1:d,z.value=p.slice(z.start,z.end),";"===p[d]?ot(z):(z.openingCurlyAt=d,it.push({type:"at",token:z})),j(),R=d+1),!R&&"at"===z.type&&z.identifier&&p[d]&&p[d].trim()&&!z.queryStartsAt&&(z.queryStartsAt=d),!R&&z&&"at"===z.type&&z.identifierStartsAt&&d>=z.start&&p[d]&&(!p[d].trim()||"()".includes(p[d]))&&!z.identifierEndsAt&&(z.identifierEndsAt=d,z.identifier=p.slice(z.identifierStartsAt,d)),"rule"===z.type&&X&&(N.includes(p[d])||p[d]&&!p[d].trim()&&N.includes(p[T]))&&(z.selectors.push({value:p.slice(X,d),selectorStarts:X,selectorEnds:d}),X=void 0,z.selectorsEnd=d);const D=O(it);if(!R&&p[d])if(q(p,d,z,it,_)){z.type&&null!==z.start&&("rule"===z.type&&et&&et.propertyStarts&&(et.propertyEnds=d,et.property=p.slice(et.propertyStarts,d),et.end||(et.end=d),rt(et),at()),pt(z,d),j()),gt("tag",d),_&&(_=!1);const t="?![-/";let e="",a=!1;if(T)for(let r=T;r1&&it[D].guessedClosingLump.includes(p[d])&&it[D].guessedClosingLump.includes(p[d+1])&&!(it[D+1]&&"'\"".includes(it[D+1].value)&&p.indexOf(it[D+1].value,d)>0&&it[D].guessedClosingLump.includes(p[i(p,p.indexOf(it[D+1].value,d))]))||B(p,d,z,it,_)&&(!nt("simple")||!["'",'"'].includes(it[~-it.length].value)||U&&U.attribStarts&&!U.attribEnds)){const t=w(p,d,it);if(!y.includes(t)){let e,a;if(it.length&&(e=$(t,it))){if("esp"===z.type){if(z.end||(z.end=d+e,z.value=p.slice(z.start,z.end),z.tail=p.slice(d,d+e),z.tailStartsAt=d,z.tailEndsAt=z.end,">"===p[d]&&"/"===p[b]&&(z.tailStartsAt=b,z.tail=p.slice(z.tailStartsAt,d+1))),R=z.tailEndsAt,Y){Array.isArray(Y.attribs)||(Y.attribs=[]),tt?(U=tt,U.attribValue.push({...z})):Y.attribs.push({...z}),z=l(Y),Y=void 0,tt=void 0,it.pop();continue}pt(z,d),j()}it.pop()}else if(it.length&&(e=$(t,it,!0)))"esp"===z.type&&(z.end||(z.end=d+(e||0),z.value=p.slice(z.start,z.end)),z.tailStartsAt||(z.tailStartsAt=d),!z.tailEndsAt&&e&&(z.tailEndsAt=z.tailStartsAt+e,z.tail=p.slice(d,d+e)),pt(z,d),j()),it.length=0;else if(U&&U.attribValue&&U.attribValue.length&&U.attribValue[~-U.attribValue.length].start&&Array.from(p.slice(U.attribValue[~-U.attribValue.length].start,d)).some(((e,r)=>t.includes(V(e))&&(c.includes(e)||!r)&&(a={char:e,idx:r})))&&"tag"===z.type&&U&&U.attribValueStartsAt&&!U.attribValueEndsAt&&U.attribValue[~-U.attribValue.length]&&"text"===U.attribValue[~-U.attribValue.length].type){z.pureHTML=!1;const e=U.attribValue[~-U.attribValue.length],r=dt("esp",e.start);a&&a.idx||(r.head=a.char,r.headStartsAt=e.start,r.headEndsAt=r.headStartsAt+1,r.tailStartsAt=d,r.tailEndsAt=d+t.length,r.tail=t,U.attribValue[~-U.attribValue.length]=r)}else nt("esp")&&it.pop(),tt&&(Array.isArray(tt.attribValue)||(tt.attribValue=[]),tt.attribValue.push(z)),it.push({type:"esp",openingLump:t,guessedClosingLump:V(t),position:d}),null!==z.start&&("tag"===z.type?(!z.tagNameStartsAt||z.tagName&&z.tagNameEndsAt||(z.tagNameEndsAt=d,z.tagName=p.slice(z.tagNameStartsAt,d),z.recognised=S(z.tagName)),Y=l(z),U.attribStarts&&!U.attribEnds&&(tt=l(U))):tt?tt&&Array.isArray(tt.attribValue)&&tt.attribValue.length&&"esp"===tt.attribValue[~-tt.attribValue.length].type&&!tt.attribValue[~-tt.attribValue.length].end&&(tt.attribValue[~-tt.attribValue.length].end=d,tt.attribValue[~-tt.attribValue.length].value=p.slice(tt.attribValue[~-tt.attribValue.length].start,d)):pt(z,d)),gt("esp",d),z.head=t,z.headStartsAt=d,z.headEndsAt=d+t.length,Y&&Y.pureHTML&&(Y.pureHTML=!1),tt&&Array.isArray(tt.attribValue)&&tt.attribValue.length&&(tt.attribValue[~-tt.attribValue.length].start===z.start?tt.attribValue.pop():"text"!==tt.attribValue[~-tt.attribValue.length].type||tt.attribValue[~-tt.attribValue.length].end||(tt.attribValue[~-tt.attribValue.length].end=d,tt.attribValue[~-tt.attribValue.length].value=p.slice(tt.attribValue[~-tt.attribValue.length].start,d)));R=d+(e||t.length)}}else!_||H||!p[d]||!p[d].trim()||"{}".includes(p[d])||z.type&&!["text"].includes(z.type)?z.type||gt("text",d):(z.type&&pt(z,d),gt("@"===p[d]?"at":"rule",d),z.left=lt,z.nested=it.some((t=>"at"===t.type)));if(R||!et||(!et.valueStarts||et.valueEnds||"!"===p[T]||T&&p.slice(T).match(P))&&(!et.importantStarts||et.importantEnds)||et.valueEnds&&";"===p[T]||p[d]&&p[d].trim()&&(et.valueEnds||";"!==p[d])&&((!";}/".includes(p[mt=d])||U&&U.attribName&&"style"===U.attribName)&&!("/;'\"><".includes(p[mt])&&U&&"style"===U.attribName&&bt(mt)))||(et.importantStarts&&!et.importantEnds&&(et.importantEnds=n(p,d)+1,et.important=p.slice(et.importantStarts,et.importantEnds)),et.valueStarts&&!et.valueEnds&&(et.valueEnds=d,et.value=p.slice(et.valueStarts,d)),";"===p[d]?(et.semi=d,et.end=d+1):";"===p[T]&&(et.semi=T,et.end=et.semi+1,R=et.end),et.end||(et.end=d),rt(et),at()),R||!et||!(et.valueStarts&&!et.valueEnds||et.propertyEnds&&!et.valueStarts&&!T)||!p[d]||p[d].trim()&&"!"!==p[d]&&";"!==p[d]||(et.valueStarts&&!et.valueEnds&&(et.valueEnds=d,et.value=p.slice(et.valueStarts,d)),"!"===p[d]?et.importantStarts=d:";"===p[d]?et.semi=d:T&&"!"===p[T]||p.slice(d).match(P)?et.importantStarts=i(p,d):T&&";"===p[T]||(et.end=n(p,d+1)+1,rt(et),at()),et.start||!p[d]||p[d].trim()||rt({type:"text",start:d,end:null,value:null})),!R&&et&&et.start&&!et.end&&";"===p[d]&&(et.semi=d,et.end=d+1,et.propertyEnds||(et.propertyEnds=d),et.propertyStarts&&et.propertyEnds&&!et.property&&(et.property=p.slice(et.propertyStarts,et.propertyEnds)),rt(et),at()),!R&&et&&et.valueEnds&&!et.importantStarts&&("!"===p[d]||A(p[d]))&&p.slice(d).match(P)&&(et.importantStarts=d),!R&&et&&et.colon&&!et.valueStarts&&p[d]&&p[d].trim())if(";}'\"".includes(p[d])&&bt(d)){let t;";"===p[d]&&(et.semi=d),et.end||(et.end=et.semi?et.semi+1:n(p,d)+1,t=et.end),rt(et),at(),t&&t"!==p[d])if("comment"===z.type&&"html"===z.language&&!it.length&&"simple"===z.kind&&("<"===p[z.start]&&"-"===p[d]&&(e(p,d,"!-",{trimBeforeMatching:!0})||r(p,d,"!-",{trimBeforeMatching:!0})&&"-"!==p[d+1])||"-"===p[z.start]&&">"===p[d]&&e(p,d,"--",{trimBeforeMatching:!0,maxMismatches:1})))"-"===p[d]&&(t(p,d,["[if","(if","{if"],{i:!0,trimBeforeMatching:!0})||t(p,d,["if"],{i:!0,trimBeforeMatching:!0})&&(v(p,d,"]",">")||p.includes("mso",d)&&!p.slice(d,p.indexOf("mso")).includes("<")&&!p.slice(d,p.indexOf("mso")).includes(">")))?z.kind="only":"-"!==p[z.start]&&a(p,d,["-"!==p[T]?"html"===z.language&&(z.end=d+1,"!"===p[b]&&"-"===p[T]&&(z.end=T+1),z.value=p.slice(z.start,z.end)):(z.end=T+1,z.kind="simplet",z.closing=null);else if("comment"!==z.type||"html"!==z.language||">"!==p[d]||it.length&&"<"!==p[T]){if("comment"===z.type&&"css"===z.language&&"*"===p[d]&&"/"===p[d+1])z.end=d+1,z.value=p.slice(z.start,z.end);else if("esp"===z.type&&null===z.end&&"string"==typeof z.head&&"string"==typeof z.tail&&z.tail.includes(p[d])){let t="";for(let e=d;ez.head.length){const e=z.head[0];if(t.endsWith(z.head))z.end=d+t.length-z.head.length,z.value=p.slice(z.start,z.end),R=z.end;else if(t.startsWith(z.tail))z.end=d+z.tail.length,z.value=p.slice(z.start,z.end),R=z.end;else if(!z.tail.includes(e)&&t.includes(e)||t.endsWith(z.head)||t.startsWith(z.tail)){const a=t.slice(0,t.indexOf(e)),r=t.slice(t.indexOf(e));a.length&&r.length&&z.tail.split("").every((t=>a.includes(t)))&&(z.end=d+a.length,z.value=p.slice(z.start,z.end),R=z.end)}else z.end=d+t.length,z.value=p.slice(z.start,z.end),R=z.end}else z.end=d+t.length,z.value=p.slice(z.start,z.end),nt("esp")&&it.pop(),R=z.end}}else Array.isArray(it)&&it.length&&"["===it[~-it.length].value&&it.pop(),!["simplet","not"].includes(z.kind)&&t(p,d,["\x3c!--\x3e","\x3c!----\x3e"],{trimBeforeMatching:!0,maxMismatches:1,lastMustMatch:!0})?z.kind="not":(z.end=d+1,z.value=p.slice(z.start,z.end));else z.end=d+1,z.value=p.slice(z.start,z.end);if(R||"tag"!==z.type||!z.tagNameStartsAt||z.tagNameEndsAt||p[d]&&/[.\-_a-z0-9\u00B7\u00C0-\uFFFD]/i.test(p[d])||(z.tagNameEndsAt=d,z.tagName=p.slice(z.tagNameStartsAt,d).toLowerCase(),"xml"===z.tagName&&z.closing&&!z.kind&&(z.kind="xml"),C.includes(z.tagName)&&(z.void=!0),z.recognised=S(z.tagName)),R||"tag"!==z.type||z.tagNameStartsAt||null==z.start||!(z.startU.attribNameStartsAt&&null===U.attribNameEndsAt&&!o(p[d])&&(U.attribNameEndsAt=d,U.attribName=p.slice(U.attribNameStartsAt,d),U.attribNameRecognised=u.has(U.attribName),U.attribName.startsWith("mc:")&&(z.pureHTML=!1),p[d]&&!p[d].trim()&&"="===p[T]||(p[d]&&!p[d].trim()||">"===p[d]||"/"===p[d]&&">"===p[T])&&("'\"".includes(p[T])||(U.attribEnds=d,z.attribs.push(l(U)),Z()))),!R&&p[d]&&"tag"===z.type&&"cdata"!==z.kind&&z.tagNameEndsAt&&d>z.tagNameEndsAt&&null===U.attribStarts&&o(p[d])&&(U.attribStarts=d,U.attribLeft=lt,U.attribNameStartsAt=d),R||"rule"!==z.type||("{"!==p[d]||z.openingCurlyAt?"}"===p[d]&&z.openingCurlyAt&&!z.closingCurlyAt&&(z.closingCurlyAt=d,z.end=d+1,z.value=p.slice(z.start,z.end),Array.isArray(z.properties)&&z.properties.length&&z.properties[~-z.properties.length].start&&!z.properties[~-z.properties.length].end&&(z.properties[~-z.properties.length].end=d,z.properties[~-z.properties.length].value=p.slice(z.properties[~-z.properties.length].start,d)),ot(z),nt("at")&&it[~-it.length].token.rules.push(z),j()):z.openingCurlyAt=d),!R&&U.attribName&&Array.isArray(U.attribValue)&&U.attribValue.length&&!U.attribValue[~-U.attribValue.length].end&&"*"===p[d]&&"/"===p[T]&&st(d),(!R&&U&&U.attribValueStartsAt&&!U.attribValueEndsAt&&!et.propertyStarts&&d>=U.attribValueStartsAt&&Array.isArray(U.attribValue)&&(!U.attribValue.length||U.attribValue[~-U.attribValue.length].end&&U.attribValue[~-U.attribValue.length].end<=d)||!R&&"rule"===z.type&&z.openingCurlyAt&&!z.closingCurlyAt&&!et.propertyStarts)&&(p[d]&&!p[d].trim()||nt("block"))&&(U.attribName?U.attribValue.push({type:"text",start:d,end:null,value:null}):"rule"!==z.type||Array.isArray(z.properties)&&z.properties.length&&!z.properties[~-z.properties.length].end||z.properties.push({type:"text",start:d,end:null,value:null})),!R&&"tag"===z.type&&U.attribValueStartsAt&&d>=U.attribValueStartsAt&&null===U.attribValueEndsAt)if(x.includes(p[d]))it.some((t=>"esp"===t.type))||p[d]&&p.includes(">",d)&&!s(p,U.attribOpeningQuoteAt||U.attribValueStartsAt,d)?Array.isArray(U.attribValue)&&U.attribValue.length&&"text"===U.attribValue[~-U.attribValue.length].type||et.propertyStarts||U.attribValue.push({type:"text",start:d,end:null,value:null}):(U.attribClosingQuoteAt=d,U.attribValueEndsAt=d,U.attribValueStartsAt&&(U.attribValueRaw=p.slice(U.attribValueStartsAt,d)),U.attribEnds=d+1,et.propertyStarts&&(U.attribValue.push(l(et)),at()),Array.isArray(U.attribValue)&&U.attribValue.length&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].property||(U.attribValue[~-U.attribValue.length].end=d,U.attribValue[~-U.attribValue.length].value=p.slice(U.attribValue[~-U.attribValue.length].start,d))),p[U.attribOpeningQuoteAt]!==p[d]&&(it.pop(),it.pop()),U.attribValue[~-U.attribValue.length]&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].end=d),z.attribs.push(l(U)),Z());else if(null===U.attribOpeningQuoteAt&&(p[d]&&!p[d].trim()||["/",">"].includes(p[d])||g.includes(p[d])&&g.includes(p[d+1])))U.attribValueEndsAt=d,U.attribValueRaw=p.slice(U.attribValueStartsAt,d),Array.isArray(U.attribValue)&&U.attribValue.length&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].end=d,U.attribValue[~-U.attribValue.length].value=p.slice(U.attribValue[~-U.attribValue.length].start,U.attribValue[~-U.attribValue.length].end)),U.attribEnds=d,z.attribs.push(l(U)),Z(),it.pop(),">"===p[d]&&(z.end=d+1,z.value=p.slice(z.start,z.end));else if("="!==p[d]||null===b||!T||!("'\"".includes(p[T])||p[~-d]&&A(p[~-d]))||U&&U.attribOpeningQuoteAt&&(/\//.test(p.slice(U.attribOpeningQuoteAt+1,d))||/mailto:/.test(p.slice(U.attribOpeningQuoteAt+1,d))||/\w\?\w/.test(p.slice(U.attribOpeningQuoteAt+1,d))))!U||"style"===U.attribName||!U.attribStarts||U.attribEnds||et.propertyStarts||Array.isArray(U.attribValue)&&U.attribValue.length&&!(U.attribValue[~-U.attribValue.length].end&&U.attribValue[~-U.attribValue.length].end<=d)||U.attribValue.push({type:"text",start:d,end:null,value:null});else{let t,e;for(let a=b;a>=U.attribValueStartsAt;a--)t||!p[a]||p[a].trim()||(t=!0,e&&p.slice(a,e)),t&&p[a]&&p[a].trim()&&(t=!1,e||(e=a+1));if(e){U.attribValueEndsAt=e,U.attribValueStartsAt&&(U.attribValueRaw=p.slice(U.attribValueStartsAt,e),Array.isArray(U.attribValue)&&U.attribValue.length&&!U.attribValue[~-U.attribValue.length].end&&(U.attribValue[~-U.attribValue.length].end=U.attribValueEndsAt,U.attribValue[~-U.attribValue.length].value=p.slice(U.attribValue[~-U.attribValue.length].start,U.attribValueEndsAt))),U.attribEnds=e,p[U.attribOpeningQuoteAt]!==p[d]&&it.pop(),z.attribs.push(l(U)),Z(),d=~-e;continue}if(U.attribOpeningQuoteAt&&("'\"".includes(p[T])||u.has(p.slice(U.attribOpeningQuoteAt+1,d).trim()))){d=U.attribOpeningQuoteAt,U.attribEnds=U.attribOpeningQuoteAt+1,U.attribValueStartsAt=null,it.pop(),z.attribs.push(l(U)),Z();continue}}else"esp"===z.type&&tt&&Y&&tt.attribOpeningQuoteAt&&tt.attribValueStartsAt&&"'\"".includes(p[d])&&p[tt.attribOpeningQuoteAt]===p[d]&&s(p,tt.attribOpeningQuoteAt,d)&&(z.end=d,z.value=p.slice(z.start,d),tt&&!Array.isArray(tt.attribValue)&&(tt.attribValue=[]),tt.attribValue.push(z),tt.attribValueEndsAt=d,tt.attribValueRaw=p.slice(tt.attribValueStartsAt,d),tt.attribClosingQuoteAt=d,tt.attribEnds=d+1,z=l(Y),z.attribs.push(tt),tt=void 0,Y=void 0,it.pop(),it.pop(),it.pop());if(!R&&"tag"===z.type&&!U.attribValueStartsAt&&U.attribNameEndsAt&&U.attribNameEndsAt<=d&&p[d]&&p[d].trim())if("="!==p[d]||x.includes(p[T])||"=".includes(p[T])||g.includes(p[T])){if(x.includes(p[d])){const t=T;!(t&&x.includes(p[t])&&p[d]!==p[t]&&p.length>t+2&&p.slice(t+1).includes(p[t]))||p.indexOf(p[t],t+1)&&i(p,p.indexOf(p[t],t+1))&&p[d]===p[i(p,p.indexOf(p[t],t+1))]||Array.from(p.slice(t+1,p.indexOf(p[t]))).some((t=>`<>=${p[d]}`.includes(t)))?U.attribOpeningQuoteAt?(s(p,U.attribOpeningQuoteAt,d)&&(U.attribClosingQuoteAt=d),U.attribOpeningQuoteAt&&U.attribClosingQuoteAt&&(U.attribValueRaw=U.attribOpeningQuoteAt<~-U.attribClosingQuoteAt?p.slice(U.attribOpeningQuoteAt+1,U.attribClosingQuoteAt):"",U.attribEnds=d+1,z.attribs.push(l(U)),Z())):(U.attribOpeningQuoteAt=d,!p[d+1]||p[d+1]===p[d]&&bt(d+1)||(U.attribValueStartsAt=d+1)):it.pop()}}else{const t=x.split("").map((t=>p.indexOf(t,T))).filter((t=>t>0)).length?Math.min(...x.split("").map((t=>p.indexOf(t,T))).filter((t=>t>0))):void 0;T&&p.slice(T).includes("=")&&u.has(p.slice(T,T+p.slice(T).indexOf("=")).trim().toLowerCase())?(U.attribEnds=d+1,z.attribs.push({...U}),Z()):t&&!p.slice(T,t).includes("=")&&p.includes(p[t],t+1)&&!Array.from(p.slice(t+1,p.indexOf(p[t],t+1))).some((t=>"<>=".includes(t)))||(U.attribValueStartsAt=T,it.push({type:"simple",value:null,position:U.attribValueStartsAt}))}if(!R&&">"===p[d]&&"%"!==p[d-1]&&"tag"===z.type&&U.attribStarts&&!U.attribEnds){let t=!1;if(p[d+1])for(let e=d+1;e"===p[e])break;if("<"===p[e]){t=!0,it.pop();break}if(!p[e+1]){t=!0;break}}else t=!0;t&&(z.end=d+1,z.value=p.slice(z.start,z.end),U.attribValueStartsAt&&d&&U.attribValueStartsAth.charCbLookahead&&ut(I,h.charCb,h.charCbLookahead))),p[d]||null===z.start||(z.end=d,z.value=p.slice(z.start,z.end),U&&U.attribName&&(U.attribEnds||(U.attribEnds=d),z.attribs.push({...U}),Z()),z&&Array.isArray(z.properties)&&z.properties.length&&!z.properties[~-z.properties.length].end&&(z.properties[~-z.properties.length].end=d,z.properties[~-z.properties.length].start&&!z.properties[~-z.properties.length].value&&(z.properties[~-z.properties.length].value=p.slice(z.properties[~-z.properties.length].start,d))),et&&et.propertyStarts&&(et.end||(et.end=d),rt(et),at()),ot(z)),p[d]&&p[d].trim()&&(lt=d)}var ht,mt;if(I.length)for(let t=0,e=I.length;t=t.length&&!i)return!1;for(var p=i?1:r.length,d=!1,m=!1,g=c.maxMismatches,h=e,f=!1,b=!1,y=!1;t[h];){var v=l(h);if(c.trimBeforeMatching&&""===t[h].trim()){if(!t[v]&&i&&"EOL"===r)return!0;h=l(h)}else if(c&&!c.i&&c.trimCharsBeforeMatching&&c.trimCharsBeforeMatching.includes(t[h])||c&&c.i&&c.trimCharsBeforeMatching&&c.trimCharsBeforeMatching.map((function(t){return t.toLowerCase()})).includes(t[h].toLowerCase())){if(i&&"EOL"===r&&!t[v])return!0;h=l(h)}else{var A=v>h?r[r.length-p]:r[p-1];if(!c.i&&t[h]===A||c.i&&t[h].toLowerCase()===A.toLowerCase()){if(f||(f=!0),m||(m=!0),p===r.length?b=!0:1===p&&(y=!0),(p-=1)<1)return h}else{if(!(c.maxMismatches&&g&&h))return!(0!==h||1!==p||c.lastMustMatch||!m)&&0;g-=1;for(var w=0;w<=g;w++){var V=v>h?r[r.length-p+1+w]:r[p-2-w],k=t[l(h)];if(V&&(!c.i&&t[h]===V||c.i&&t[h].toLowerCase()===V.toLowerCase())&&(!c.firstMustMatch||p!==r.length)){p-=2,f=!0;break}if(k&&V&&(!c.i&&k===V||c.i&&k.toLowerCase()===V.toLowerCase())&&(!c.firstMustMatch||p!==r.length)){p-=1,f=!0;break}if(void 0===V&&g>=0&&f&&(!c.firstMustMatch||b)&&(!c.lastMustMatch||y))return h}f||(d=h)}if(!1!==d&&d!==h&&(d=!1),p<1)return h;h=l(h)}}return p>0?!(!i||"EOL"!==u)||!!(c&&c.maxMismatches>=p&&m)&&(d||0):void 0}function u(t,e,r,s,u){if(a(u)&&Object.prototype.hasOwnProperty.call(u,"trimBeforeMatching")&&"boolean"!=typeof u.trimBeforeMatching)throw new Error("string-match-left-right/"+t+"(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!"+(Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));var c,p,d,m=n(n({},o),u);if("string"==typeof m.trimCharsBeforeMatching&&(m.trimCharsBeforeMatching="string"==typeof(c=m.trimCharsBeforeMatching)?c.length?[c]:[]:c),m.trimCharsBeforeMatching=m.trimCharsBeforeMatching.map((function(t){return i(t)?t:String(t)})),!i(e))return!1;if(!e.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error("string-match-left-right/"+t+"(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: "+typeof r+", equal to:\n"+JSON.stringify(r,null,4));if(i(s))p=[s];else if(Array.isArray(s))p=s;else if(s){if("function"!=typeof s)throw new Error("string-match-left-right/"+t+"(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's "+typeof s+", equal to:\n"+JSON.stringify(s,null,4));(p=[]).push(s)}else p=s;if(u&&!a(u))throw new Error("string-match-left-right/"+t+"(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type \""+typeof u+'", and equal to:\n'+JSON.stringify(u,null,4));var g=0,h="";if(m&&m.trimCharsBeforeMatching&&m.trimCharsBeforeMatching.some((function(t,e){return t.length>1&&(g=e,h=t,!0)})))throw new Error("string-match-left-right/"+t+"(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index "+g+" is longer than 1 character, "+h.length+" (equals to "+h+"). Please split it into separate characters and put into array as separate elements.");if(!p||!Array.isArray(p)||Array.isArray(p)&&!p.length||Array.isArray(p)&&1===p.length&&i(p[0])&&!p[0].trim()){if("function"==typeof m.cb){var f,b=r;if("matchLeftIncl"!==t&&"matchRight"!==t||(b+=1),"L"===t[5])for(var y=b;y--;){var v=e[y];if((!m.trimBeforeMatching||m.trimBeforeMatching&&void 0!==v&&v.trim())&&(!m.trimCharsBeforeMatching||!m.trimCharsBeforeMatching.length||void 0!==v&&!m.trimCharsBeforeMatching.includes(v))){f=y;break}}else if(t.startsWith("matchRight"))for(var A=b;A0&&(_=e.slice(0,k)),"L"===t[5]?m.cb(V,_,f):(f&&f>0&&(_=e.slice(f)),m.cb(V,_,f))}var S="";throw u||(S=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/"+t+'(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!'+S)}for(var x=0,C=p.length;x-1},xt.prototype.set=function(t,e){var r=this.__data__,n=Nt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Ct.prototype.clear=function(){this.__data__={hash:new St,map:new(mt||xt),string:new St}},Ct.prototype.delete=function(t){return Rt(this,t).delete(t)},Ct.prototype.get=function(t){return Rt(this,t).get(t)},Ct.prototype.has=function(t){return Rt(this,t).has(t)},Ct.prototype.set=function(t,e){return Rt(this,t).set(t,e),this},Et.prototype.clear=function(){this.__data__=new xt},Et.prototype.delete=function(t){return this.__data__.delete(t)},Et.prototype.get=function(t){return this.__data__.get(t)},Et.prototype.has=function(t){return this.__data__.has(t)},Et.prototype.set=function(t,e){var r=this.__data__;if(r instanceof xt){var n=r.__data__;if(!mt||n.length<199)return n.push([t,e]),this;r=this.__data__=new Ct(n)}return r.set(t,e),this};var Wt=ut?D(ut,Object):function(){return[]},zt=function(t){return tt.call(t)};function It(t,e){return!!(e=null==e?n:e)&&("number"==typeof t||j.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=n}(t.length)&&!Jt(t)}var $t=ct||function(){return!1};function Jt(t){var e=Ut(t)?tt.call(t):"";return e==s||e==l}function Ut(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Zt(t){return Ht(t)?Ot(t):function(t){if(!Qt(t))return pt(t);var e=[];for(var r in Object(t))Y.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return jt(t,!0,!0)}}));Function.prototype.toString.call(Object);var h=" ";function f(t,e){return void 0===e&&(e=0),function(t){var e=t.str,r=t.idx,n=void 0===r?0:r,a=t.stopAtNewlines,i=void 0!==a&&a,o=t.stopAtRawNbsp,s=void 0!==o&&o;if("string"!=typeof e||!e.length)return null;if(n&&"number"==typeof n||(n=0),!e[n+1])return null;if(e[n+1]&&(e[n+1].trim()||i&&"\n\r".includes(e[n+1])||s&&e[n+1]===h))return n+1;if(e[n+2]&&(e[n+2].trim()||i&&"\n\r".includes(e[n+2])||s&&e[n+2]===h))return n+2;for(var l=n+1,u=e.length;l96&&t.charCodeAt(0)<123||t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>47&&t.charCodeAt(0)<58||":"===t||"-"===t)}function A(t){return"'"===t?'"':"'"}function w(t,e,r,n){void 0===n&&(n=[]);for(var a=function(e,a){return n.some((function(r){return t.startsWith(r,e)}))?{v:!0}:t[e]===r?{v:!1}:void 0},i=e,o=t.length;i'"=]*['"])/.test(t.slice(e))}function _(t,e){if(!e||!v(t[e]))return!1;return/^[a-zA-Z0-9:-]*=(((?:'[^']*')|(?:"[^"]*"))|((?:['"][^'"]*['"]\s*\/?>)))/.test(t.slice(e))}function S(t,e){if(v(t[b(t,e)]))for(var r=e;r--;)if(t[r].trim().length&&!v(t[r]))return t.slice(r+1,e)}function x(t,e,r){if("string"!=typeof t||!t.trim()||!Number.isInteger(e)||!Number.isInteger(r)||!t[e]||!t[r]||e>=r)return!1;var n,a="'\"".includes(t[e])?t[e]:null,i=null;a&&(i=A(a));for(var o,s,l,u,c=(new Map).set("'",0).set('"',0).set("matchedPairs",0),p=null,m=0,g=!1,h=!1,x=!1,C=!1,E=e,O=t.length;E=r){var M=E!==r||_(t,f(t,r))||"/>".includes(t[f(t,E)]),N=!(E>r&&t[e]===t[r]&&t[e]===t[E]&&k(t,E+1)),j=E===r&&k(t,r+1),L=n&&n".includes(t[f(t,E)])&&w(t,E+1,"=",["'",'"']),P=void 0;E===r&&(P=S(t,E));var R=E===r&&(!v(t[b(t,E)])||P&&!y.has(P))&&"="!==t[b(t,E)],T="/>".includes(t[f(t,E)])&&E===r,W=v(t[f(t,E)]),z=g&&E!==r,I=!(E>=r&&":"===t[b(t,r)]);return!!(M&&N&&(j||L||B||R)&&(T||W||z)&&I)}if("'\"".includes(t[E])){if("'"===t[E]&&'"'===t[E-1]&&'"'===t[E+1]||'"'===t[E]&&"'"===t[E-1]&&"'"===t[E+1])continue;p&&t[E]===t[p]?(c.set("matchedPairs",c.get("matchedPairs")+1),o=p,s=E,p=null,g=!0):g=!1,c.set(t[E],c.get(t[E])+1),m=c.get('"')+c.get("'")}if(">"===t[E]&&!x&&(x=!0,m&&c.get("matchedPairs")&&m===2*c.get("matchedPairs")&&E=r,"'\"".includes(t[E])&&0===c.get("matchedPairs")&&3===m&&t[e]===t[E]&&y.has(l)&&!"'\"".includes(t[f(t,E)])){var Q=E>r,q=!p,F=p+1>=E,D=t.slice(p+1,E).trim().split(/\s+/).every((function(t){return y.has(t)})),H=!l||!u||!u.endsWith(":"),$=E===r,J=m<3,U=!!g,Z=!p,G=p+1>=E,K=!t.slice(p+1,E).trim().split(/\s+/).every((function(t){return y.has(t)}));return Q&&(q||F||D)&&H||$&&(J||U||Z||G||K)}if(l&&y.has(l)&&o===e&&s===r)return!0}if("'\"".includes(t[E])&&(!(c.get('"')%2)||!(c.get("'")%2))&&(c.get('"')+c.get("'"))%2&&(l&&y.has(l)||E>r+1&&y.has(t.slice(r+1,E).trim()))&&(t[E+1]!==t[E]||t[E]!==t[e])&&!(E>r+1&&":"===t[b(t,r)])&&!(l&&u&&u.trim().endsWith(":"))){var X=E>r,Y=!!a,tt=t[e]!==t[r],et=y.has(t.slice(e+1,r).trim()),rt=!V(t,E+1,t[r],A(t[r]));return X&&!(Y&&tt&&et&&rt)}if(("="===t[E]||!t[E].length&&"="===t[f(t,E)])&&l&&y.has(l)){var nt=E>r,at=!(!(g&&o===e&&s===r||_(t,n))&&g&&void 0!==o&&o<=r);return nt&&at}if(E>r){if(a&&t[E]===a){var it=!!p,ot=p===r,st=p+1=r,ct=!t[f(t,E)]||!"'\"".includes(t[f(t,E)]);return!!(it&&ot&&st&<&&ut&&ct)}if(a&&t[r]===i&&t[E]===i)return!1;if("/"===t[E]||">"===t[E]||"<"===t[E]){var pt=t[e]===t[r]&&p===r&&!t.slice(e+1,r).includes(t[e]),dt=c.get("matchedPairs")<2,mt=S(t,E),gt=(!mt||!y.has(mt))&&(!(E>r&&c.get("'")&&c.get('"')&&c.get("matchedPairs")>1)||"/>".includes(t[f(t,E)])),ht=m<3||c.get('"')+c.get("'")-2*c.get("matchedPairs")!=2,ft=!g||g&&!(void 0!==o&&Array.from(t.slice(e+1,o).trim()).every((function(t){return v(t)}))&&y.has(t.slice(e+1,o).trim())),bt=!f(t,E)&&m%2==0,yt=t[e-2]&&"="===t[e-1]&&v(t[e-2]),vt=!w(t,E+1,"<",["='",'="']);return pt||(dt||gt)&&ht&&(ft||bt||yt||vt)}if("="===t[E]&&d(t,E,["'",'"'],{trimBeforeMatching:!0,trimCharsBeforeMatching:["="]}))return!0}else{var At=void 0;if(t[E-1]&&t[E-1].trim()&&"="!==t[E-1])At=E-1;else for(var wt=E;wt--;)if(t[wt].trim()&&"="!==t[wt]){At=wt;break}if("="===t[E]&&d(t,E,["'",'"'],{cb:function(t){return!"/>".includes(t)},trimBeforeMatching:!0,trimCharsBeforeMatching:["="]})&&v(t[At])&&!t.slice(e+1).startsWith("http")&&!t.slice(e+1,E).includes("/")&&!t.endsWith("src=",e)&&!t.endsWith("href=",e))return!1;if(E===r&&_(t,E+1))return!0;if(Er)return!!(h&&l&&y.has(l));"'\"".includes(t[E])&&(p=E),n&&!v(t[E])&&(n=null)}return!1}var C=new Set(["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","bgsound","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","content","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","element","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","image","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","main","map","mark","marquee","menu","menuitem","meta","meter","multicol","nav","nextid","nobr","noembed","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","plaintext","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xmp"]),E="{}%-$_()*|#",O="{}|#",M="%()$_*#",N=[")|(","|(",")(","()","}{","{}","%)","*)","||","--"];function j(t){return!(!t||!(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function L(t){for(var e="",r=0,n=t.length;r"+e:">"===t[r]?"<"+e:"“"===t[r]?"”"+e:"”"===t[r]?"“"+e:""+t[r]+e;return e}function B(t){return C.has(t.toLowerCase())||["doctype","cdata","xml"].includes(t.toLowerCase())}function P(t,e,r,n){for(var a=e,i=t.length;a2&&n.guessedClosingLump[n.guessedClosingLump.length-1]===t[t.length-1]&&n.guessedClosingLump[n.guessedClosingLump.length-2]===t[t.length-2]?t.length:void 0}}var D={allowCustomTagNames:!1,skipOpeningBracket:!1},H=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h1 - h6","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xml"];function $(t){return void 0===t||t.toUpperCase()===t.toLowerCase()&&!/\d/.test(t)&&"="!==t}function J(t,e){return"<"===t[e]||"<"===t[b(t,e)]}function U(t,e,r){if(void 0===e&&(e=0),"string"!=typeof t)throw new Error('is-html-tag-opening: [THROW_ID_01] the first input argument should have been a string but it was given as "'+typeof t+'", value being '+JSON.stringify(t,null,4));if(!Number.isInteger(e)||e<0)throw new Error('is-html-tag-opening: [THROW_ID_02] the second input argument should have been a natural number string index but it was given as "'+typeof e+'", value being '+JSON.stringify(e,null,4));var a=n(n({},D),r),i="._a-z0-9·À-ÖØ-öø-ͽͿ-῿‌-‍‿-⁀⁰-￿",o=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"[\\\\ \\t\\r\\n/]*\\w+"+"[\\\\ \\t\\r\\n/]*\\/?"+"[\\\\ \\t\\r\\n/]*>","g"),s=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"[\\\\ \\t\\r\\n/]*["+i+"]+[-"+i+"]*"+"[\\\\ \\t\\r\\n/]*>","g"),l=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"\\s*\\w+\\s+\\w+(?:-\\w+)?\\s*=\\s*['\"\\w]","g"),u=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"\\s*\\w+\\s+["+i+"]+[-"+i+"]*(?:-\\w+)?\\s*=\\s*['\"\\w]"),c=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"\\s*\\/?\\s*\\w+\\s*\\/?\\s*>","g"),m=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"\\s*\\/?\\s*["+i+"]+[-"+i+"]*\\s*\\/?\\s*>","g"),g=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"[\\\\ \\t\\r\\n/]*\\w+(?:\\s*\\w+)?\\s*\\w+=['\"]","g"),h=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"[\\\\ \\t\\r\\n/]*["+i+"]+[-"+i+"]*\\s+(?:\\s*\\w+)?\\s*\\w+=['\"]","g"),f=new RegExp("^<"+(a.skipOpeningBracket?"?\\/?":"")+"("+"[\\\\ \\t\\r\\n/]*["+i+"]+)+"+"[\\\\ \\t\\r\\n/]*[\\\\/=>]",""),y=e?t.slice(e):t,v=!1,A=!1,w={cb:$,i:!0,trimCharsBeforeMatching:["/","\\","!"," ","\t","\n","\r"]};return a.allowCustomTagNames?((a.skipOpeningBracket&&("<"===t[e-1]||"/"===t[e-1]&&"<"===t[b(t,b(t,e))])||"<"===y[0]&&y[1]&&y[1].trim())&&(f.test(y)||/^<\w+$/.test(y))||s.test(y)&&J(t,e)||u.test(y)||m.test(y)&&J(t,e)||h.test(y))&&(A=!0):(((a.skipOpeningBracket&&("<"===t[e-1]||"/"===t[e-1]&&"<"===t[b(t,b(t,e))])||"<"===y[0]&&y[1]&&y[1].trim())&&f.test(y)||o.test(y)&&J(t,e)||l.test(y)||c.test(y)&&J(t,e)||g.test(y))&&(v=!0),v&&p(t,e,H,{cb:function(r){return void 0===r?(("<"===t[e]&&t[e+1]&&t[e+1].trim()||"<"===t[e-1])&&(A=!0),!0):r.toUpperCase()===r.toLowerCase()&&!/\d/.test(r)&&"="!==r},i:!0,trimCharsBeforeMatching:["<","/","\\","!"," ","\t","\n","\r"]})&&(A=!0)),!A&&"<"===t[e]&&t[e+1]&&t[e+1].trim()&&d(t,e,H,w)&&(A=!0),"string"==typeof t&&e'"]|$)/gm,K={tagCb:null,tagCbLookahead:0,charCb:null,charCbLookahead:0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100};var X={matchLayerLast:F};t.defaults=K,t.tokenizer=function(t,e){var r=Date.now();if("string"!=typeof t)throw void 0===t?new Error("codsen-tokenizer: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error('codsen-tokenizer: [THROW_ID_02] the first input argument must be string! It was given as "'+typeof t+'", equal to:\n'+JSON.stringify(t,null,4));if(e&&!R(e))throw new Error("codsen-tokenizer: [THROW_ID_03] the second input argument, an options object, should be a plain object but it was given as type "+typeof e+", equal to "+JSON.stringify(e,null,4));if(e&&R(e)&&e.tagCb&&"function"!=typeof e.tagCb)throw new Error("codsen-tokenizer: [THROW_ID_04] the opts.tagCb, callback function, should be a function but it was given as type "+typeof e.tagCb+", equal to "+JSON.stringify(e.tagCb,null,4));if(e&&R(e)&&e.charCb&&"function"!=typeof e.charCb)throw new Error("codsen-tokenizer: [THROW_ID_05] the opts.charCb, callback function, should be a function but it was given as type "+typeof e.charCb+", equal to "+JSON.stringify(e.charCb,null,4));if(e&&R(e)&&e.reportProgressFunc&&"function"!=typeof e.reportProgressFunc)throw new Error("codsen-tokenizer: [THROW_ID_06] the opts.reportProgressFunc, callback function, should be a function but it was given as type "+typeof e.reportProgressFunc+", equal to "+JSON.stringify(e.reportProgressFunc,null,4));var a=n(n({},K),e),i=0,o=0,s=t.length,l=Math.floor(s/2),m=0,h=!1,A=!1,w=[],V=[],k={};function _(){k={type:null,start:null,end:null,value:null},D()}var S={attribName:"",attribNameRecognised:!1,attribNameStartsAt:null,attribNameEndsAt:null,attribOpeningQuoteAt:null,attribClosingQuoteAt:null,attribValueRaw:null,attribValue:[],attribValueStartsAt:null,attribValueEndsAt:null,attribStarts:null,attribEnds:null,attribLeft:null},C=n({},S);function D(){C=g(S)}function H(e){C.attribValue.length&&C.attribValue[~-C.attribValue.length].start&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].end=e.start,C.attribValue[~-C.attribValue.length].value=t.slice(C.attribValue[~-C.attribValue.length].start,e.start)),C.attribValue.push(e)}var $,J,X,Y={start:null,end:null,property:null,propertyStarts:null,propertyEnds:null,value:null,valueStarts:null,valueEnds:null,importantStarts:null,importantEnds:null,important:null,colon:null,semi:null},tt=n({},Y);function et(){tt=n({},Y)}function rt(t){C&&"style"===C.attribName?C.attribValue.push(n({},t)):k&&Array.isArray(k.properties)&&k.properties.push(n({},t))}_();var nt=null,at=[];function it(t){return!(!Array.isArray(at)||!at.length||at[~-at.length].type!==t)}function ot(e){var r=(f(t,e)||e)+1;H({type:"comment",start:e,end:r,value:t.slice(e,r),closing:!0,kind:"block",language:"css"}),m=r,it("block")&&at.pop()}function st(t,e,r){for(var n=t.shift(),a=[],i=0;ia.tagCbLookahead&&st(w,a.tagCb,a.tagCbLookahead))}function ut(e,r){if(!["text","esp"].includes(e.type)&&null!==e.start&&e.start".includes(t[~-e.end]))lt(e),_(),t[~-r]&&!t[~-r].trim()&&pt("text",b(t,r)+1);else{var n=e.tagNameEndsAt||r;if(Array.isArray(e.attribs)&&e.attribs.length)for(var a=0,i=e.attribs.length;a1e3&&s<2e3?e===l&&a.reportProgressFunc(Math.floor((a.reportProgressFuncTo-a.reportProgressFuncFrom)/2)):s>=2e3&&(i=a.reportProgressFuncFrom+Math.floor(e/s*(a.reportProgressFuncTo-a.reportProgressFuncFrom)))!==o&&(o=i,a.reportProgressFunc(i)));var r=b(t,e),w=f(t,e);if(h&&k.type&&!["rule","at","text","comment"].includes(k.type)&&(h=!1),m&&e>=m&&(m=0),j(t[e])&&j(t[~-e])&&j(t[e+1]))return ht=e,"continue";if(" \t\r\n".includes(t[e])&&t[e]===t[~-e]&&t[e]===t[e+1])return ht=e,"continue";if(!m&&it("at")&&R(at[~-at.length].token)&&at[~-at.length].token.openingCurlyAt&&!at[~-at.length].token.closingCurlyAt)if("}"===t[e]){if(!k.type||"text"===k.type||"rule"===k.type&&null===k.openingCurlyAt){"rule"===k.type&&(k.end=r+1,k.value=t.slice(k.start,k.end),lt(k),it("at")&&at[~-at.length].token.rules.push(k),_(),null!==r&&r<~-e&&pt("text",r+1)),ut(k,e);var S=at.pop();(k=S.token).closingCurlyAt=e,k.end=e+1,k.value=t.slice(k.start,k.end),lt(k),it("at")&&at[~-at.length].token.rules.push(k),_(),m=e+1}}else"text"===k.type&&t[e]&&t[e].trim()&&(k.end=e,k.value=t.slice(k.start,k.end),it("at")?at[~-at.length].token.rules.push(k):lt(k),_());k.end&&k.end===e&&("style"!==k.tagName||k.closing||(h=!0),X?((C=X).attribValue.push(k),k=g(J),X=void 0,J=void 0):(ut(k,e),at.length=0)),m||(["tag","rule","at"].includes(k.type)&&"cdata"!==k.kind?!t[e]||!I.includes(t[e])&&!"()".includes(t[e])||I.includes(t[r])&&t[r]===t[w]||!mt(e)||(it("simple")&&at[~-at.length].value===L(t[e])?at.pop():at.push({type:"simple",value:t[e],position:e})):"comment"===k.type&&["only","not"].includes(k.kind)?["[","]"].includes(t[e])&&(it("simple")&&at[~-at.length].value===L(t[e])?at.pop():at.push({type:"simple",value:t[e],position:e})):"esp"!==k.type||!"'\"`()".includes(t[e])||['"',"'","`"].includes(t[r])&&t[r]===t[w]||(it("simple")&&at[~-at.length].value===L(t[e])?(at.pop(),m=e+1):"]})>".includes(t[e])||at.push({type:"simple",value:t[e],position:e}))),!m&&"at"===k.type&&null!=k.start&&e>=k.start&&!k.identifierStartsAt&&t[e]&&t[e].trim()&&"@"!==t[e]&&(k.identifierStartsAt=e),!m&&"at"===k.type&&k.queryStartsAt&&!k.queryEndsAt&&"{;".includes(t[e])&&(k.queryEndsAt="{"===t[e]?t[~-e]&&t[~-e].trim()?e:null!==r?r+1:e:b(t,e+1)||0,k.queryStartsAt&&k.queryEndsAt&&(k.query=t.slice(k.queryStartsAt,k.queryEndsAt)),k.end=";"===t[e]?e+1:e,k.value=t.slice(k.start,k.end),";"===t[e]?lt(k):(k.openingCurlyAt=e,at.push({type:"at",token:k})),_(),m=e+1),!m&&"at"===k.type&&k.identifier&&t[e]&&t[e].trim()&&!k.queryStartsAt&&(k.queryStartsAt=e),!m&&k&&"at"===k.type&&k.identifierStartsAt&&e>=k.start&&t[e]&&(!t[e].trim()||"()".includes(t[e]))&&!k.identifierEndsAt&&(k.identifierEndsAt=e,k.identifier=t.slice(k.identifierStartsAt,e)),"rule"===k.type&&$&&(z.includes(t[e])||t[e]&&!t[e].trim()&&z.includes(t[w]))&&(k.selectors.push({value:t.slice($,e),selectorStarts:$,selectorEnds:e}),$=void 0,k.selectorsEnd=e);var K,Y,gt,ft=q(at);if(!m&&t[e])if(function(t,e,r,n,a){return!(!t[e]||!t[e].trim().length||n.length&&"text"!==r.type||r.kind&&["doctype","xml"].includes(r.kind)||a&&"<"!==t[e]||!("<"===t[e]&&(U(t,e,{allowCustomTagNames:!0})||">"===t[f(t,e)]||d(t,e,["doctype","xml","cdata"],{i:!0,trimBeforeMatching:!0,trimCharsBeforeMatching:["?","!","["," ","-"]}))||j(t[e])&&(!t[e-1]||!j(t[e-1])&&!["<","/","!",Z].includes(t[b(t,e)]))&&U(t,e,{allowCustomTagNames:!1,skipOpeningBracket:!0}))||!("esp"!==r.type||r.tail&&r.tail.includes(t[e])))}(t,e,k,at,h)){k.type&&null!==k.start&&("rule"===k.type&&tt&&tt.propertyStarts&&(tt.propertyEnds=e,tt.property=t.slice(tt.propertyStarts,e),tt.end||(tt.end=e),rt(tt),et()),ut(k,e),_()),pt("tag",e),h&&(h=!1);var bt="?![-/",yt="",vt=!1;if(w)for(var At=w;At"],{trimBeforeMatching:!0})||"comment"===r.type&&(r.closing||"not"===r.kind)||c(t,e,"<",{trimBeforeMatching:!0,trimCharsBeforeMatching:["-","!"]})||Array.isArray(n)&&n.length&&"esp"===n[n.length-1].type&&"<"===n[n.length-1].openingLump[0]&&"-"===n[n.length-1].openingLump[2]&&"-"===n[n.length-1].openingLump[3]))}(t,e,k,at))null!=k.start&&ut(k,e),pt("comment",e),"-"===t[e]?k.closing=!0:p(t,e,["1&&at[ft].guessedClosingLump.includes(t[e])&&at[ft].guessedClosingLump.includes(t[e+1])&&!(at[ft+1]&&"'\"".includes(at[ft+1].value)&&t.indexOf(at[ft+1].value,e)>0&&at[ft].guessedClosingLump.includes(t[f(t,t.indexOf(at[ft+1].value,e))]))||function(t,e,r,n,a){return!!(E.includes(t[e])&&t[e+1]&&E.includes(t[e+1])&&(!M.includes(t[e])||!M.includes(t[e+1]))&&(t[e]!==t[e+1]||O.includes(t[e]))&&"rule"!==r.type&&"at"!==r.type&&("-"!==t[e]||!"-{(".includes(t[e+1]))&&(!"})".includes(t[e])||!"-".includes(t[e+1]))&&("%"!==t[e]||"%"!==t[e+1]||!"0123456789".includes(t[e-1])||t[e+2]&&!".,;!?".includes(t[e+2])&&t[e+2].trim().length)&&(!a||!"{}".includes(t[e])&&!"{}".includes(t[f(t,e)]))||"<"===t[e]&&("/"===t[e+1]&&E.includes(t[e+2])||E.includes(t[e+1])&&!["-"].includes(t[e+1]))||"<"===t[e]&&("%"===t[e+1]||t.startsWith("jsp:",e+1)||t.startsWith("cms:",e+1)||t.startsWith("c:",e+1))||t.startsWith("${jspProp",e)||">})".includes(t[e])&&Array.isArray(n)&&n.length&&"esp"===n[n.length-1].type&&n[n.length-1].openingLump.includes(L(t[e]))&&(">"!==t[e]||!P(t,e+1,">","<"))||"-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]&&Array.isArray(n)&&n.length&&"esp"===n[n.length-1].type&&"<"===n[n.length-1].openingLump[0]&&"-"===n[n.length-1].openingLump[2]&&"-"===n[n.length-1].openingLump[3])}(t,e,k,at,h)&&(!it("simple")||!["'",'"'].includes(at[~-at.length].value)||C&&C.attribStarts&&!C.attribEnds)){var wt=function(t,e,r){for(var n=t[e],a=t.length,i=r[q(r)],o=e+1;o1&&(n.includes("<")||n.includes("{")||n.includes("[")||n.includes("("))&&"("===t[o])&&(E.includes(t[o])||i&&i.guessedClosingLump.includes(t[o])||"<"===t[e]&&"/"===t[o]||">"===t[o]&&"--"===n&&Array.isArray(r)&&r.length&&"esp"===r[r.length-1].type&&"<"===r[r.length-1].openingLump[0]&&"-"===r[r.length-1].openingLump[2]&&"-"===r[r.length-1].openingLump[3]||!i&&o>e&&"!=@".includes(t[o]));o++)n+=t[o];if(n&&Array.isArray(r)&&r.length&&"esp"===r[r.length-1].type&&r[r.length-1].guessedClosingLump&&n.length>r[r.length-1].guessedClosingLump.length){if(n.endsWith(r[r.length-1].openingLump))return n.slice(0,n.length-r[r.length-1].openingLump.length);for(var s=new Set(r[r.length-1].guessedClosingLump),l=0,u=function(t,e){if(!s.has(n[e])&&l>1)return{v:n.slice(0,e)};s.has(n[e])&&(l+=1,s=new Set([].concat(s).filter((function(t){return t!==n[e]}))))},c=0,p=n.length;c"===t[e]&&"/"===t[r]&&(k.tailStartsAt=r,k.tail=t.slice(k.tailStartsAt,e+1))),m=k.tailEndsAt,J)return Array.isArray(J.attribs)||(J.attribs=[]),X?(C=X).attribValue.push(n({},k)):J.attribs.push(n({},k)),k=g(J),J=void 0,X=void 0,at.pop(),ht=e,"continue";ut(k,e),_()}at.pop()}else if(at.length&&(Vt=F(wt,at,!0)))"esp"===k.type&&(k.end||(k.end=e+(Vt||0),k.value=t.slice(k.start,k.end)),k.tailStartsAt||(k.tailStartsAt=e),!k.tailEndsAt&&Vt&&(k.tailEndsAt=k.tailStartsAt+Vt,k.tail=t.slice(e,e+Vt)),ut(k,e),_()),at.length=0;else if(C&&C.attribValue&&C.attribValue.length&&C.attribValue[~-C.attribValue.length].start&&Array.from(t.slice(C.attribValue[~-C.attribValue.length].start,e)).some((function(t,e){return wt.includes(L(t))&&(O.includes(t)||!e)&&(kt={char:t,idx:e})}))&&"tag"===k.type&&C&&C.attribValueStartsAt&&!C.attribValueEndsAt&&C.attribValue[~-C.attribValue.length]&&"text"===C.attribValue[~-C.attribValue.length].type){k.pureHTML=!1;var _t=C.attribValue[~-C.attribValue.length],St=ct("esp",_t.start);kt&&kt.idx||(St.head=kt.char,St.headStartsAt=_t.start,St.headEndsAt=St.headStartsAt+1,St.tailStartsAt=e,St.tailEndsAt=e+wt.length,St.tail=wt,C.attribValue[~-C.attribValue.length]=St)}else it("esp")&&at.pop(),X&&(Array.isArray(X.attribValue)||(X.attribValue=[]),X.attribValue.push(k)),at.push({type:"esp",openingLump:wt,guessedClosingLump:L(wt),position:e}),null!==k.start&&("tag"===k.type?(!k.tagNameStartsAt||k.tagName&&k.tagNameEndsAt||(k.tagNameEndsAt=e,k.tagName=t.slice(k.tagNameStartsAt,e),k.recognised=B(k.tagName)),J=g(k),C.attribStarts&&!C.attribEnds&&(X=g(C))):X?X&&Array.isArray(X.attribValue)&&X.attribValue.length&&"esp"===X.attribValue[~-X.attribValue.length].type&&!X.attribValue[~-X.attribValue.length].end&&(X.attribValue[~-X.attribValue.length].end=e,X.attribValue[~-X.attribValue.length].value=t.slice(X.attribValue[~-X.attribValue.length].start,e)):ut(k,e)),pt("esp",e),k.head=wt,k.headStartsAt=e,k.headEndsAt=e+wt.length,J&&J.pureHTML&&(J.pureHTML=!1),X&&Array.isArray(X.attribValue)&&X.attribValue.length&&(X.attribValue[~-X.attribValue.length].start===k.start?X.attribValue.pop():"text"!==X.attribValue[~-X.attribValue.length].type||X.attribValue[~-X.attribValue.length].end||(X.attribValue[~-X.attribValue.length].end=e,X.attribValue[~-X.attribValue.length].value=t.slice(X.attribValue[~-X.attribValue.length].start,e)));m=e+(Vt||wt.length)}}else!h||A||!t[e]||!t[e].trim()||"{}".includes(t[e])||k.type&&!["text"].includes(k.type)?k.type||pt("text",e):(k.type&&ut(k,e),pt("@"===t[e]?"at":"rule",e),k.left=nt,k.nested=at.some((function(t){return"at"===t.type})));(m||!tt||!(tt.valueStarts&&!tt.valueEnds&&"!"!==t[w]||tt.importantStarts&&!tt.importantEnds)||tt.valueEnds&&";"===t[w]||t[e]&&t[e].trim()&&(tt.valueEnds||";"!==t[e])&&((!";}/".includes(t[K=e])||C&&C.attribName&&"style"===C.attribName)&&!("/;'\"><".includes(t[K])&&C&&"style"===C.attribName&&mt(K)))||(tt.importantStarts&&!tt.importantEnds&&(tt.importantEnds=b(t,e)+1,tt.important=t.slice(tt.importantStarts,tt.importantEnds)),tt.valueStarts&&!tt.valueEnds&&(tt.valueEnds=e,tt.value=t.slice(tt.valueStarts,e)),";"===t[e]?(tt.semi=e,tt.end=e+1):";"===t[w]&&(tt.semi=w,tt.end=tt.semi+1,m=tt.end),tt.end||(tt.end=e),rt(tt),et()),m||!tt||!(tt.valueStarts&&!tt.valueEnds||tt.propertyEnds&&!tt.valueStarts&&!w)||!t[e]||t[e].trim()&&"!"!==t[e]&&";"!==t[e]||(tt.valueStarts&&!tt.valueEnds&&(tt.valueEnds=e,tt.value=t.slice(tt.valueStarts,e)),"!"===t[e]?tt.importantStarts=e:";"===t[e]?tt.semi=e:w&&"!"===t[w]||G.test(t.slice(e))?tt.importantStarts=f(t,e):w&&";"===t[w]||(tt.end=b(t,e+1)+1,rt(tt),et()),tt.start||!t[e]||t[e].trim()||rt({type:"text",start:e,end:null,value:null})),!m&&tt&&tt.start&&!tt.end&&";"===t[e]&&(tt.semi=e,tt.end=e+1,tt.propertyEnds||(tt.propertyEnds=e),tt.propertyStarts&&tt.propertyEnds&&!tt.property&&(tt.property=t.slice(tt.propertyStarts,tt.propertyEnds)),rt(tt),et()),!m&&tt&&tt.valueEnds&&!tt.importantStarts&&("!"===t[e]||j(t[e]))&&G.test(t.slice(e))&&(tt.importantStarts=e),!m&&tt&&tt.colon&&!tt.valueStarts&&t[e]&&t[e].trim())&&(";}'\"".includes(t[e])&&mt(e)?(";"===t[e]&&(tt.semi=e),tt.end||(tt.end=tt.semi?tt.semi+1:b(t,e)+1,Y=tt.end),rt(tt),et(),Y&&Y"!==t[e])if("comment"===k.type&&"html"===k.language&&!at.length&&"simple"===k.kind&&("<"===t[k.start]&&"-"===t[e]&&(c(t,e,"!-",{trimBeforeMatching:!0})||function(t,e,r,n){return u("matchLeftIncl",t,e,r,n)}(t,e,"!-",{trimBeforeMatching:!0})&&"-"!==t[e+1])||"-"===t[k.start]&&">"===t[e]&&c(t,e,"--",{trimBeforeMatching:!0,maxMismatches:1})))"-"===t[e]&&(d(t,e,["[if","(if","{if"],{i:!0,trimBeforeMatching:!0})||d(t,e,["if"],{i:!0,trimBeforeMatching:!0})&&(P(t,e,"]",">")||t.includes("mso",e)&&!t.slice(e,t.indexOf("mso")).includes("<")&&!t.slice(e,t.indexOf("mso")).includes(">")))?k.kind="only":"-"!==t[k.start]&&p(t,e,["-"!==t[w]?"html"===k.language&&(k.end=e+1,"!"===t[r]&&"-"===t[w]&&(k.end=w+1),k.value=t.slice(k.start,k.end)):(k.end=w+1,k.kind="simplet",k.closing=null);else if("comment"!==k.type||"html"!==k.language||">"!==t[e]||at.length&&"<"!==t[w]){if("comment"===k.type&&"css"===k.language&&"*"===t[e]&&"/"===t[e+1])k.end=e+1,k.value=t.slice(k.start,k.end);else if("esp"===k.type&&null===k.end&&"string"==typeof k.head&&"string"==typeof k.tail&&k.tail.includes(t[e])){for(var xt="",Ct=e;Ctk.head.length){var Et=k.head[0];if(xt.endsWith(k.head))k.end=e+xt.length-k.head.length,k.value=t.slice(k.start,k.end),m=k.end;else if(xt.startsWith(k.tail))k.end=e+k.tail.length,k.value=t.slice(k.start,k.end),m=k.end;else if(!k.tail.includes(Et)&&xt.includes(Et)||xt.endsWith(k.head)||xt.startsWith(k.tail)){var Ot=xt.slice(0,xt.indexOf(Et)),Mt=xt.slice(xt.indexOf(Et));Ot.length&&Mt.length&&k.tail.split("").every((function(t){return Ot.includes(t)}))&&(k.end=e+Ot.length,k.value=t.slice(k.start,k.end),m=k.end)}else k.end=e+xt.length,k.value=t.slice(k.start,k.end),m=k.end}else k.end=e+xt.length,k.value=t.slice(k.start,k.end),it("esp")&&at.pop(),m=k.end}}else Array.isArray(at)&&at.length&&"["===at[~-at.length].value&&at.pop(),!["simplet","not"].includes(k.kind)&&d(t,e,["\x3c!--\x3e","\x3c!----\x3e"],{trimBeforeMatching:!0,maxMismatches:1,lastMustMatch:!0})?k.kind="not":(k.end=e+1,k.value=t.slice(k.start,k.end));else k.end=e+1,k.value=t.slice(k.start,k.end);if(m||"tag"!==k.type||!k.tagNameStartsAt||k.tagNameEndsAt||t[e]&&/[.\-_a-z0-9\u00B7\u00C0-\uFFFD]/i.test(t[e])||(k.tagNameEndsAt=e,k.tagName=t.slice(k.tagNameStartsAt,e).toLowerCase(),"xml"===k.tagName&&k.closing&&!k.kind&&(k.kind="xml"),T.includes(k.tagName)&&(k.void=!0),k.recognised=B(k.tagName)),m||"tag"!==k.type||k.tagNameStartsAt||null==k.start||!(k.startC.attribNameStartsAt&&null===C.attribNameEndsAt&&!v(t[e])&&(C.attribNameEndsAt=e,C.attribName=t.slice(C.attribNameStartsAt,e),C.attribNameRecognised=y.has(C.attribName),C.attribName.startsWith("mc:")&&(k.pureHTML=!1),t[e]&&!t[e].trim()&&"="===t[w]||(t[e]&&!t[e].trim()||">"===t[e]||"/"===t[e]&&">"===t[w])&&("'\"".includes(t[w])||(C.attribEnds=e,k.attribs.push(g(C)),D()))),!m&&t[e]&&"tag"===k.type&&"cdata"!==k.kind&&k.tagNameEndsAt&&e>k.tagNameEndsAt&&null===C.attribStarts&&v(t[e])&&(C.attribStarts=e,C.attribLeft=nt,C.attribNameStartsAt=e),m||"rule"!==k.type||("{"!==t[e]||k.openingCurlyAt?"}"===t[e]&&k.openingCurlyAt&&!k.closingCurlyAt&&(k.closingCurlyAt=e,k.end=e+1,k.value=t.slice(k.start,k.end),Array.isArray(k.properties)&&k.properties.length&&k.properties[~-k.properties.length].start&&!k.properties[~-k.properties.length].end&&(k.properties[~-k.properties.length].end=e,k.properties[~-k.properties.length].value=t.slice(k.properties[~-k.properties.length].start,e)),lt(k),it("at")&&at[~-at.length].token.rules.push(k),_()):k.openingCurlyAt=e),!m&&C.attribName&&Array.isArray(C.attribValue)&&C.attribValue.length&&!C.attribValue[~-C.attribValue.length].end&&"*"===t[e]&&"/"===t[w]&&ot(e),(!m&&C&&C.attribValueStartsAt&&!C.attribValueEndsAt&&!tt.propertyStarts&&e>=C.attribValueStartsAt&&Array.isArray(C.attribValue)&&(!C.attribValue.length||C.attribValue[~-C.attribValue.length].end&&C.attribValue[~-C.attribValue.length].end<=e)||!m&&"rule"===k.type&&k.openingCurlyAt&&!k.closingCurlyAt&&!tt.propertyStarts)&&(t[e]&&!t[e].trim()||it("block"))&&(C.attribName?C.attribValue.push({type:"text",start:e,end:null,value:null}):"rule"!==k.type||Array.isArray(k.properties)&&k.properties.length&&!k.properties[~-k.properties.length].end||k.properties.push({type:"text",start:e,end:null,value:null})),!m&&"tag"===k.type&&C.attribValueStartsAt&&e>=C.attribValueStartsAt&&null===C.attribValueEndsAt)if(I.includes(t[e]))at.some((function(t){return"esp"===t.type}))||t[e]&&t.includes(">",e)&&!x(t,C.attribOpeningQuoteAt||C.attribValueStartsAt,e)?Array.isArray(C.attribValue)&&C.attribValue.length&&"text"===C.attribValue[~-C.attribValue.length].type||tt.propertyStarts||C.attribValue.push({type:"text",start:e,end:null,value:null}):(C.attribClosingQuoteAt=e,C.attribValueEndsAt=e,C.attribValueStartsAt&&(C.attribValueRaw=t.slice(C.attribValueStartsAt,e)),C.attribEnds=e+1,tt.propertyStarts&&(C.attribValue.push(g(tt)),et()),Array.isArray(C.attribValue)&&C.attribValue.length&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].property||(C.attribValue[~-C.attribValue.length].end=e,C.attribValue[~-C.attribValue.length].value=t.slice(C.attribValue[~-C.attribValue.length].start,e))),t[C.attribOpeningQuoteAt]!==t[e]&&(at.pop(),at.pop()),C.attribValue[~-C.attribValue.length]&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].end=e),k.attribs.push(g(C)),D());else if(null===C.attribOpeningQuoteAt&&(t[e]&&!t[e].trim()||["/",">"].includes(t[e])||E.includes(t[e])&&E.includes(t[e+1])))C.attribValueEndsAt=e,C.attribValueRaw=t.slice(C.attribValueStartsAt,e),Array.isArray(C.attribValue)&&C.attribValue.length&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].end=e,C.attribValue[~-C.attribValue.length].value=t.slice(C.attribValue[~-C.attribValue.length].start,C.attribValue[~-C.attribValue.length].end)),C.attribEnds=e,k.attribs.push(g(C)),D(),at.pop(),">"===t[e]&&(k.end=e+1,k.value=t.slice(k.start,k.end));else if("="!==t[e]||null===r||!w||!("'\"".includes(t[w])||t[~-e]&&j(t[~-e]))||C&&C.attribOpeningQuoteAt&&(/\//.test(t.slice(C.attribOpeningQuoteAt+1,e))||/mailto:/.test(t.slice(C.attribOpeningQuoteAt+1,e))||/\w\?\w/.test(t.slice(C.attribOpeningQuoteAt+1,e))))!C||"style"===C.attribName||!C.attribStarts||C.attribEnds||tt.propertyStarts||Array.isArray(C.attribValue)&&C.attribValue.length&&!(C.attribValue[~-C.attribValue.length].end&&C.attribValue[~-C.attribValue.length].end<=e)||C.attribValue.push({type:"text",start:e,end:null,value:null});else{for(var Nt,jt,Lt=r;Lt>=C.attribValueStartsAt;Lt--)Nt||!t[Lt]||t[Lt].trim()||(Nt=!0,jt&&t.slice(Lt,jt)),Nt&&t[Lt]&&t[Lt].trim()&&(Nt=!1,jt||(jt=Lt+1));if(jt)return C.attribValueEndsAt=jt,C.attribValueStartsAt&&(C.attribValueRaw=t.slice(C.attribValueStartsAt,jt),Array.isArray(C.attribValue)&&C.attribValue.length&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].end=C.attribValueEndsAt,C.attribValue[~-C.attribValue.length].value=t.slice(C.attribValue[~-C.attribValue.length].start,C.attribValueEndsAt))),C.attribEnds=jt,t[C.attribOpeningQuoteAt]!==t[e]&&at.pop(),k.attribs.push(g(C)),D(),ht=e=~-jt,"continue";if(C.attribOpeningQuoteAt&&("'\"".includes(t[w])||y.has(t.slice(C.attribOpeningQuoteAt+1,e).trim())))return e=C.attribOpeningQuoteAt,C.attribEnds=C.attribOpeningQuoteAt+1,C.attribValueStartsAt=null,at.pop(),k.attribs.push(g(C)),D(),ht=e,"continue"}else"esp"===k.type&&X&&J&&X.attribOpeningQuoteAt&&X.attribValueStartsAt&&"'\"".includes(t[e])&&t[X.attribOpeningQuoteAt]===t[e]&&x(t,X.attribOpeningQuoteAt,e)&&(k.end=e,k.value=t.slice(k.start,e),X&&!Array.isArray(X.attribValue)&&(X.attribValue=[]),X.attribValue.push(k),X.attribValueEndsAt=e,X.attribValueRaw=t.slice(X.attribValueStartsAt,e),X.attribClosingQuoteAt=e,X.attribEnds=e+1,(k=g(J)).attribs.push(X),X=void 0,J=void 0,at.pop(),at.pop(),at.pop());if(!m&&"tag"===k.type&&!C.attribValueStartsAt&&C.attribNameEndsAt&&C.attribNameEndsAt<=e&&t[e]&&t[e].trim())if("="!==t[e]||I.includes(t[w])||"=".includes(t[w])||E.includes(t[w])){if(I.includes(t[e])){var Bt=w;!(Bt&&I.includes(t[Bt])&&t[e]!==t[Bt]&&t.length>Bt+2&&t.slice(Bt+1).includes(t[Bt]))||t.indexOf(t[Bt],Bt+1)&&f(t,t.indexOf(t[Bt],Bt+1))&&t[e]===t[f(t,t.indexOf(t[Bt],Bt+1))]||Array.from(t.slice(Bt+1,t.indexOf(t[Bt]))).some((function(r){return("<>="+t[e]).includes(r)}))?C.attribOpeningQuoteAt?(x(t,C.attribOpeningQuoteAt,e)&&(C.attribClosingQuoteAt=e),C.attribOpeningQuoteAt&&C.attribClosingQuoteAt&&(C.attribValueRaw=C.attribOpeningQuoteAt<~-C.attribClosingQuoteAt?t.slice(C.attribOpeningQuoteAt+1,C.attribClosingQuoteAt):"",C.attribEnds=e+1,k.attribs.push(g(C)),D())):(C.attribOpeningQuoteAt=e,!t[e+1]||t[e+1]===t[e]&&mt(e+1)||(C.attribValueStartsAt=e+1)):at.pop()}}else{var Pt=I.split("").map((function(e){return t.indexOf(e,w)})).filter((function(t){return t>0})).length?Math.min.apply(Math,I.split("").map((function(e){return t.indexOf(e,w)})).filter((function(t){return t>0}))):void 0;w&&t.slice(w).includes("=")&&y.has(t.slice(w,w+t.slice(w).indexOf("=")).trim().toLowerCase())?(C.attribEnds=e+1,k.attribs.push(n({},C)),D()):Pt&&!t.slice(w,Pt).includes("=")&&t.includes(t[Pt],Pt+1)&&!Array.from(t.slice(Pt+1,t.indexOf(t[Pt],Pt+1))).some((function(t){return"<>=".includes(t)}))||(C.attribValueStartsAt=w,at.push({type:"simple",value:null,position:C.attribValueStartsAt}))}if(!m&&">"===t[e]&&"%"!==t[e-1]&&"tag"===k.type&&C.attribStarts&&!C.attribEnds){var Rt=!1;if(t[e+1])for(var Tt=e+1;Tt"===t[Tt])break;if("<"===t[Tt]){Rt=!0,at.pop();break}if(!t[Tt+1]){Rt=!0;break}}else Rt=!0;Rt&&(k.end=e+1,k.value=t.slice(k.start,k.end),C.attribValueStartsAt&&e&&C.attribValueStartsAta.charCbLookahead&&st(V,a.charCb,a.charCbLookahead))),t[e]||null===k.start||(k.end=e,k.value=t.slice(k.start,k.end),C&&C.attribName&&(C.attribEnds||(C.attribEnds=e),k.attribs.push(n({},C)),D()),k&&Array.isArray(k.properties)&&k.properties.length&&!k.properties[~-k.properties.length].end&&(k.properties[~-k.properties.length].end=e,k.properties[~-k.properties.length].start&&!k.properties[~-k.properties.length].value&&(k.properties[~-k.properties.length].value=t.slice(k.properties[~-k.properties.length].start,e))),tt&&tt.propertyStarts&&(tt.end||(tt.end=e),rt(tt),et()),lt(k)),t[e]&&t[e].trim()&&(nt=e),ht=e},ht=0;ht<=s;ht++)gt(ht);if(V.length)for(var ft=0,bt=V.length;ft=t.length&&!i)return!1;for(var p=i?1:r.length,d=!1,m=!1,g=c.maxMismatches,h=e,f=!1,b=!1,y=!1;t[h];){var v=l(h);if(c.trimBeforeMatching&&""===t[h].trim()){if(!t[v]&&i&&"EOL"===r)return!0;h=l(h)}else if(c&&!c.i&&c.trimCharsBeforeMatching&&c.trimCharsBeforeMatching.includes(t[h])||c&&c.i&&c.trimCharsBeforeMatching&&c.trimCharsBeforeMatching.map((function(t){return t.toLowerCase()})).includes(t[h].toLowerCase())){if(i&&"EOL"===r&&!t[v])return!0;h=l(h)}else{var A=v>h?r[r.length-p]:r[p-1];if(!c.i&&t[h]===A||c.i&&t[h].toLowerCase()===A.toLowerCase()){if(f||(f=!0),m||(m=!0),p===r.length?b=!0:1===p&&(y=!0),(p-=1)<1)return h}else{if(!(c.maxMismatches&&g&&h))return!(0!==h||1!==p||c.lastMustMatch||!m)&&0;g-=1;for(var w=0;w<=g;w++){var V=v>h?r[r.length-p+1+w]:r[p-2-w],k=t[l(h)];if(V&&(!c.i&&t[h]===V||c.i&&t[h].toLowerCase()===V.toLowerCase())&&(!c.firstMustMatch||p!==r.length)){p-=2,f=!0;break}if(k&&V&&(!c.i&&k===V||c.i&&k.toLowerCase()===V.toLowerCase())&&(!c.firstMustMatch||p!==r.length)){p-=1,f=!0;break}if(void 0===V&&g>=0&&f&&(!c.firstMustMatch||b)&&(!c.lastMustMatch||y))return h}f||(d=h)}if(!1!==d&&d!==h&&(d=!1),p<1)return h;h=l(h)}}return p>0?!(!i||"EOL"!==u)||!!(c&&c.maxMismatches>=p&&m)&&(d||0):void 0}function u(t,e,r,s,u){if(a(u)&&Object.prototype.hasOwnProperty.call(u,"trimBeforeMatching")&&"boolean"!=typeof u.trimBeforeMatching)throw new Error("string-match-left-right/"+t+"(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!"+(Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));var c,p,d,m=n(n({},o),u);if("string"==typeof m.trimCharsBeforeMatching&&(m.trimCharsBeforeMatching="string"==typeof(c=m.trimCharsBeforeMatching)?c.length?[c]:[]:c),m.trimCharsBeforeMatching=m.trimCharsBeforeMatching.map((function(t){return i(t)?t:String(t)})),!i(e))return!1;if(!e.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error("string-match-left-right/"+t+"(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: "+typeof r+", equal to:\n"+JSON.stringify(r,null,4));if(i(s))p=[s];else if(Array.isArray(s))p=s;else if(s){if("function"!=typeof s)throw new Error("string-match-left-right/"+t+"(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's "+typeof s+", equal to:\n"+JSON.stringify(s,null,4));(p=[]).push(s)}else p=s;if(u&&!a(u))throw new Error("string-match-left-right/"+t+"(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type \""+typeof u+'", and equal to:\n'+JSON.stringify(u,null,4));var g=0,h="";if(m&&m.trimCharsBeforeMatching&&m.trimCharsBeforeMatching.some((function(t,e){return t.length>1&&(g=e,h=t,!0)})))throw new Error("string-match-left-right/"+t+"(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index "+g+" is longer than 1 character, "+h.length+" (equals to "+h+"). Please split it into separate characters and put into array as separate elements.");if(!p||!Array.isArray(p)||Array.isArray(p)&&!p.length||Array.isArray(p)&&1===p.length&&i(p[0])&&!p[0].trim()){if("function"==typeof m.cb){var f,b=r;if("matchLeftIncl"!==t&&"matchRight"!==t||(b+=1),"L"===t[5])for(var y=b;y--;){var v=e[y];if((!m.trimBeforeMatching||m.trimBeforeMatching&&void 0!==v&&v.trim())&&(!m.trimCharsBeforeMatching||!m.trimCharsBeforeMatching.length||void 0!==v&&!m.trimCharsBeforeMatching.includes(v))){f=y;break}}else if(t.startsWith("matchRight"))for(var A=b;A0&&(_=e.slice(0,k)),"L"===t[5]?m.cb(V,_,f):(f&&f>0&&(_=e.slice(f)),m.cb(V,_,f))}var S="";throw u||(S=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/"+t+'(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!'+S)}for(var x=0,C=p.length;x-1},xt.prototype.set=function(t,e){var r=this.__data__,n=Nt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Ct.prototype.clear=function(){this.__data__={hash:new St,map:new(mt||xt),string:new St}},Ct.prototype.delete=function(t){return Rt(this,t).delete(t)},Ct.prototype.get=function(t){return Rt(this,t).get(t)},Ct.prototype.has=function(t){return Rt(this,t).has(t)},Ct.prototype.set=function(t,e){return Rt(this,t).set(t,e),this},Et.prototype.clear=function(){this.__data__=new xt},Et.prototype.delete=function(t){return this.__data__.delete(t)},Et.prototype.get=function(t){return this.__data__.get(t)},Et.prototype.has=function(t){return this.__data__.has(t)},Et.prototype.set=function(t,e){var r=this.__data__;if(r instanceof xt){var n=r.__data__;if(!mt||n.length<199)return n.push([t,e]),this;r=this.__data__=new Ct(n)}return r.set(t,e),this};var Wt=ut?D(ut,Object):function(){return[]},zt=function(t){return tt.call(t)};function It(t,e){return!!(e=null==e?n:e)&&("number"==typeof t||j.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=n}(t.length)&&!Jt(t)}var $t=ct||function(){return!1};function Jt(t){var e=Ut(t)?tt.call(t):"";return e==s||e==l}function Ut(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Zt(t){return Ht(t)?Ot(t):function(t){if(!Qt(t))return pt(t);var e=[];for(var r in Object(t))Y.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return jt(t,!0,!0)}}));Function.prototype.toString.call(Object);var h=" ";function f(t,e){return void 0===e&&(e=0),function(t){var e=t.str,r=t.idx,n=void 0===r?0:r,a=t.stopAtNewlines,i=void 0!==a&&a,o=t.stopAtRawNbsp,s=void 0!==o&&o;if("string"!=typeof e||!e.length)return null;if(n&&"number"==typeof n||(n=0),!e[n+1])return null;if(e[n+1]&&(e[n+1].trim()||i&&"\n\r".includes(e[n+1])||s&&e[n+1]===h))return n+1;if(e[n+2]&&(e[n+2].trim()||i&&"\n\r".includes(e[n+2])||s&&e[n+2]===h))return n+2;for(var l=n+1,u=e.length;l96&&t.charCodeAt(0)<123||t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>47&&t.charCodeAt(0)<58||":"===t||"-"===t)}function A(t){return"'"===t?'"':"'"}function w(t,e,r,n){void 0===n&&(n=[]);for(var a=function(e,a){return n.some((function(r){return t.startsWith(r,e)}))?{v:!0}:t[e]===r?{v:!1}:void 0},i=e,o=t.length;i'"=]*['"])/.test(t.slice(e))}function _(t,e){if(!e||!v(t[e]))return!1;return/^[a-zA-Z0-9:-]*=(((?:'[^']*')|(?:"[^"]*"))|((?:['"][^'"]*['"]\s*\/?>)))/.test(t.slice(e))}function S(t,e){if(v(t[b(t,e)]))for(var r=e;r--;)if(t[r].trim().length&&!v(t[r]))return t.slice(r+1,e)}function x(t,e,r){if("string"!=typeof t||!t.trim()||!Number.isInteger(e)||!Number.isInteger(r)||!t[e]||!t[r]||e>=r)return!1;var n,a="'\"".includes(t[e])?t[e]:null,i=null;a&&(i=A(a));for(var o,s,l,u,c=(new Map).set("'",0).set('"',0).set("matchedPairs",0),p=null,m=0,g=!1,h=!1,x=!1,C=!1,E=e,O=t.length;E=r){var M=E!==r||_(t,f(t,r))||"/>".includes(t[f(t,E)]),N=!(E>r&&t[e]===t[r]&&t[e]===t[E]&&k(t,E+1)),j=E===r&&k(t,r+1),L=n&&n".includes(t[f(t,E)])&&w(t,E+1,"=",["'",'"']),P=void 0;E===r&&(P=S(t,E));var R=E===r&&(!v(t[b(t,E)])||P&&!y.has(P))&&"="!==t[b(t,E)],T="/>".includes(t[f(t,E)])&&E===r,W=v(t[f(t,E)]),z=g&&E!==r,I=!(E>=r&&":"===t[b(t,r)]);return!!(M&&N&&(j||L||B||R)&&(T||W||z)&&I)}if("'\"".includes(t[E])){if("'"===t[E]&&'"'===t[E-1]&&'"'===t[E+1]||'"'===t[E]&&"'"===t[E-1]&&"'"===t[E+1])continue;p&&t[E]===t[p]?(c.set("matchedPairs",c.get("matchedPairs")+1),o=p,s=E,p=null,g=!0):g=!1,c.set(t[E],c.get(t[E])+1),m=c.get('"')+c.get("'")}if(">"===t[E]&&!x&&(x=!0,m&&c.get("matchedPairs")&&m===2*c.get("matchedPairs")&&E=r,"'\"".includes(t[E])&&0===c.get("matchedPairs")&&3===m&&t[e]===t[E]&&y.has(l)&&!"'\"".includes(t[f(t,E)])){var Q=E>r,q=!p,F=p+1>=E,D=t.slice(p+1,E).trim().split(/\s+/).every((function(t){return y.has(t)})),H=!l||!u||!u.endsWith(":"),$=E===r,J=m<3,U=!!g,Z=!p,G=p+1>=E,K=!t.slice(p+1,E).trim().split(/\s+/).every((function(t){return y.has(t)}));return Q&&(q||F||D)&&H||$&&(J||U||Z||G||K)}if(l&&y.has(l)&&o===e&&s===r)return!0}if("'\"".includes(t[E])&&(!(c.get('"')%2)||!(c.get("'")%2))&&(c.get('"')+c.get("'"))%2&&(l&&y.has(l)||E>r+1&&y.has(t.slice(r+1,E).trim()))&&(t[E+1]!==t[E]||t[E]!==t[e])&&!(E>r+1&&":"===t[b(t,r)])&&!(l&&u&&u.trim().endsWith(":"))){var X=E>r,Y=!!a,tt=t[e]!==t[r],et=y.has(t.slice(e+1,r).trim()),rt=!V(t,E+1,t[r],A(t[r]));return X&&!(Y&&tt&&et&&rt)}if(("="===t[E]||!t[E].length&&"="===t[f(t,E)])&&l&&y.has(l)){var nt=E>r,at=!(!(g&&o===e&&s===r||_(t,n))&&g&&void 0!==o&&o<=r);return nt&&at}if(E>r){if(a&&t[E]===a){var it=!!p,ot=p===r,st=p+1=r,ct=!t[f(t,E)]||!"'\"".includes(t[f(t,E)]);return!!(it&&ot&&st&<&&ut&&ct)}if(a&&t[r]===i&&t[E]===i)return!1;if("/"===t[E]||">"===t[E]||"<"===t[E]){var pt=t[e]===t[r]&&p===r&&!t.slice(e+1,r).includes(t[e]),dt=c.get("matchedPairs")<2,mt=S(t,E),gt=(!mt||!y.has(mt))&&(!(E>r&&c.get("'")&&c.get('"')&&c.get("matchedPairs")>1)||"/>".includes(t[f(t,E)])),ht=m<3||c.get('"')+c.get("'")-2*c.get("matchedPairs")!=2,ft=!g||g&&!(void 0!==o&&Array.from(t.slice(e+1,o).trim()).every((function(t){return v(t)}))&&y.has(t.slice(e+1,o).trim())),bt=!f(t,E)&&m%2==0,yt=t[e-2]&&"="===t[e-1]&&v(t[e-2]),vt=!w(t,E+1,"<",["='",'="']);return pt||(dt||gt)&&ht&&(ft||bt||yt||vt)}if("="===t[E]&&d(t,E,["'",'"'],{trimBeforeMatching:!0,trimCharsBeforeMatching:["="]}))return!0}else{var At=void 0;if(t[E-1]&&t[E-1].trim()&&"="!==t[E-1])At=E-1;else for(var wt=E;wt--;)if(t[wt].trim()&&"="!==t[wt]){At=wt;break}if("="===t[E]&&d(t,E,["'",'"'],{cb:function(t){return!"/>".includes(t)},trimBeforeMatching:!0,trimCharsBeforeMatching:["="]})&&v(t[At])&&!t.slice(e+1).startsWith("http")&&!t.slice(e+1,E).includes("/")&&!t.endsWith("src=",e)&&!t.endsWith("href=",e))return!1;if(E===r&&_(t,E+1))return!0;if(Er)return!!(h&&l&&y.has(l));"'\"".includes(t[E])&&(p=E),n&&!v(t[E])&&(n=null)}return!1}var C=new Set(["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","bgsound","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","command","content","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","dt","element","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","image","img","input","ins","isindex","kbd","keygen","label","legend","li","link","listing","main","map","mark","marquee","menu","menuitem","meta","meter","multicol","nav","nextid","nobr","noembed","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","plaintext","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xmp"]),E="{}%-$_()*|#",O="{}|#",M="%()$_*#",N=[")|(","|(",")(","()","}{","{}","%)","*)","||","--"];function j(t){return!(!t||!(t.charCodeAt(0)>64&&t.charCodeAt(0)<91||t.charCodeAt(0)>96&&t.charCodeAt(0)<123))}function L(t){for(var e="",r=0,n=t.length;r"+e:">"===t[r]?"<"+e:"“"===t[r]?"”"+e:"”"===t[r]?"“"+e:""+t[r]+e;return e}function B(t){return C.has(t.toLowerCase())||["doctype","cdata","xml"].includes(t.toLowerCase())}function P(t,e,r,n){for(var a=e,i=t.length;a2&&n.guessedClosingLump[n.guessedClosingLump.length-1]===t[t.length-1]&&n.guessedClosingLump[n.guessedClosingLump.length-2]===t[t.length-2]?t.length:void 0}}var D={allowCustomTagNames:!1,skipOpeningBracket:!1},H=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h1 - h6","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xml"];function $(t){return void 0===t||t.toUpperCase()===t.toLowerCase()&&!/\d/.test(t)&&"="!==t}function J(t,e){return"<"===t[e]||"<"===t[b(t,e)]}function U(t,e,r){if(void 0===e&&(e=0),"string"!=typeof t)throw new Error('is-html-tag-opening: [THROW_ID_01] the first input argument should have been a string but it was given as "'+typeof t+'", value being '+JSON.stringify(t,null,4));if(!Number.isInteger(e)||e<0)throw new Error('is-html-tag-opening: [THROW_ID_02] the second input argument should have been a natural number string index but it was given as "'+typeof e+'", value being '+JSON.stringify(e,null,4));var a=n(n({},D),r),i="._a-z0-9·À-ÖØ-öø-ͽͿ-῿‌-‍‿-⁀⁰-￿",o=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"[\\\\ \\t\\r\\n/]*\\w+"+"[\\\\ \\t\\r\\n/]*\\/?"+"[\\\\ \\t\\r\\n/]*>","g"),s=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"[\\\\ \\t\\r\\n/]*["+i+"]+[-"+i+"]*"+"[\\\\ \\t\\r\\n/]*>","g"),l=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"\\s*\\w+\\s+\\w+(?:-\\w+)?\\s*=\\s*['\"\\w]","g"),u=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"\\s*\\w+\\s+["+i+"]+[-"+i+"]*(?:-\\w+)?\\s*=\\s*['\"\\w]"),c=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"\\s*\\/?\\s*\\w+\\s*\\/?\\s*>","g"),m=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"\\s*\\/?\\s*["+i+"]+[-"+i+"]*\\s*\\/?\\s*>","g"),g=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"[\\\\ \\t\\r\\n/]*\\w+(?:\\s*\\w+)?\\s*\\w+=['\"]","g"),h=new RegExp("^<"+(a.skipOpeningBracket?"?":"")+"[\\\\ \\t\\r\\n/]*["+i+"]+[-"+i+"]*\\s+(?:\\s*\\w+)?\\s*\\w+=['\"]","g"),f=new RegExp("^<"+(a.skipOpeningBracket?"?\\/?":"")+"("+"[\\\\ \\t\\r\\n/]*["+i+"]+)+"+"[\\\\ \\t\\r\\n/]*[\\\\/=>]",""),y=e?t.slice(e):t,v=!1,A=!1,w={cb:$,i:!0,trimCharsBeforeMatching:["/","\\","!"," ","\t","\n","\r"]};return a.allowCustomTagNames?((a.skipOpeningBracket&&("<"===t[e-1]||"/"===t[e-1]&&"<"===t[b(t,b(t,e))])||"<"===y[0]&&y[1]&&y[1].trim())&&(f.test(y)||/^<\w+$/.test(y))||s.test(y)&&J(t,e)||u.test(y)||m.test(y)&&J(t,e)||h.test(y))&&(A=!0):(((a.skipOpeningBracket&&("<"===t[e-1]||"/"===t[e-1]&&"<"===t[b(t,b(t,e))])||"<"===y[0]&&y[1]&&y[1].trim())&&f.test(y)||o.test(y)&&J(t,e)||l.test(y)||c.test(y)&&J(t,e)||g.test(y))&&(v=!0),v&&p(t,e,H,{cb:function(r){return void 0===r?(("<"===t[e]&&t[e+1]&&t[e+1].trim()||"<"===t[e-1])&&(A=!0),!0):r.toUpperCase()===r.toLowerCase()&&!/\d/.test(r)&&"="!==r},i:!0,trimCharsBeforeMatching:["<","/","\\","!"," ","\t","\n","\r"]})&&(A=!0)),!A&&"<"===t[e]&&t[e+1]&&t[e+1].trim()&&d(t,e,H,w)&&(A=!0),"string"==typeof t&&e'"]|$)/gm,K={tagCb:null,tagCbLookahead:0,charCb:null,charCbLookahead:0,reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100};var X={matchLayerLast:F};t.defaults=K,t.tokenizer=function(t,e){var r=Date.now();if("string"!=typeof t)throw void 0===t?new Error("codsen-tokenizer: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error('codsen-tokenizer: [THROW_ID_02] the first input argument must be string! It was given as "'+typeof t+'", equal to:\n'+JSON.stringify(t,null,4));if(e&&!R(e))throw new Error("codsen-tokenizer: [THROW_ID_03] the second input argument, an options object, should be a plain object but it was given as type "+typeof e+", equal to "+JSON.stringify(e,null,4));if(e&&R(e)&&e.tagCb&&"function"!=typeof e.tagCb)throw new Error("codsen-tokenizer: [THROW_ID_04] the opts.tagCb, callback function, should be a function but it was given as type "+typeof e.tagCb+", equal to "+JSON.stringify(e.tagCb,null,4));if(e&&R(e)&&e.charCb&&"function"!=typeof e.charCb)throw new Error("codsen-tokenizer: [THROW_ID_05] the opts.charCb, callback function, should be a function but it was given as type "+typeof e.charCb+", equal to "+JSON.stringify(e.charCb,null,4));if(e&&R(e)&&e.reportProgressFunc&&"function"!=typeof e.reportProgressFunc)throw new Error("codsen-tokenizer: [THROW_ID_06] the opts.reportProgressFunc, callback function, should be a function but it was given as type "+typeof e.reportProgressFunc+", equal to "+JSON.stringify(e.reportProgressFunc,null,4));var a=n(n({},K),e),i=0,o=0,s=t.length,l=Math.floor(s/2),m=0,h=!1,A=!1,w=[],V=[],k={};function _(){k={type:null,start:null,end:null,value:null},D()}var S={attribName:"",attribNameRecognised:!1,attribNameStartsAt:null,attribNameEndsAt:null,attribOpeningQuoteAt:null,attribClosingQuoteAt:null,attribValueRaw:null,attribValue:[],attribValueStartsAt:null,attribValueEndsAt:null,attribStarts:null,attribEnds:null,attribLeft:null},C=n({},S);function D(){C=g(S)}function H(e){C.attribValue.length&&C.attribValue[~-C.attribValue.length].start&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].end=e.start,C.attribValue[~-C.attribValue.length].value=t.slice(C.attribValue[~-C.attribValue.length].start,e.start)),C.attribValue.push(e)}var $,J,X,Y={start:null,end:null,property:null,propertyStarts:null,propertyEnds:null,value:null,valueStarts:null,valueEnds:null,importantStarts:null,importantEnds:null,important:null,colon:null,semi:null},tt=n({},Y);function et(){tt=n({},Y)}function rt(t){C&&"style"===C.attribName?C.attribValue.push(n({},t)):k&&Array.isArray(k.properties)&&k.properties.push(n({},t))}_();var nt=null,at=[];function it(t){return!(!Array.isArray(at)||!at.length||at[~-at.length].type!==t)}function ot(e){var r=(f(t,e)||e)+1;H({type:"comment",start:e,end:r,value:t.slice(e,r),closing:!0,kind:"block",language:"css"}),m=r,it("block")&&at.pop()}function st(t,e,r){for(var n=t.shift(),a=[],i=0;ia.tagCbLookahead&&st(w,a.tagCb,a.tagCbLookahead))}function ut(e,r){if(!["text","esp"].includes(e.type)&&null!==e.start&&e.start".includes(t[~-e.end]))lt(e),_(),t[~-r]&&!t[~-r].trim()&&pt("text",b(t,r)+1);else{var n=e.tagNameEndsAt||r;if(Array.isArray(e.attribs)&&e.attribs.length)for(var a=0,i=e.attribs.length;a1e3&&s<2e3?e===l&&a.reportProgressFunc(Math.floor((a.reportProgressFuncTo-a.reportProgressFuncFrom)/2)):s>=2e3&&(i=a.reportProgressFuncFrom+Math.floor(e/s*(a.reportProgressFuncTo-a.reportProgressFuncFrom)))!==o&&(o=i,a.reportProgressFunc(i)));var r=b(t,e),w=f(t,e);if(h&&k.type&&!["rule","at","text","comment"].includes(k.type)&&(h=!1),m&&e>=m&&(m=0),j(t[e])&&j(t[~-e])&&j(t[e+1]))return ht=e,"continue";if(" \t\r\n".includes(t[e])&&t[e]===t[~-e]&&t[e]===t[e+1])return ht=e,"continue";if(!m&&it("at")&&R(at[~-at.length].token)&&at[~-at.length].token.openingCurlyAt&&!at[~-at.length].token.closingCurlyAt)if("}"===t[e]){if(!k.type||"text"===k.type||"rule"===k.type&&null===k.openingCurlyAt){"rule"===k.type&&(k.end=r+1,k.value=t.slice(k.start,k.end),lt(k),it("at")&&at[~-at.length].token.rules.push(k),_(),null!==r&&r<~-e&&pt("text",r+1)),ut(k,e);var S=at.pop();(k=S.token).closingCurlyAt=e,k.end=e+1,k.value=t.slice(k.start,k.end),lt(k),it("at")&&at[~-at.length].token.rules.push(k),_(),m=e+1}}else"text"===k.type&&t[e]&&t[e].trim()&&(k.end=e,k.value=t.slice(k.start,k.end),it("at")?at[~-at.length].token.rules.push(k):lt(k),_());k.end&&k.end===e&&("style"!==k.tagName||k.closing||(h=!0),X?((C=X).attribValue.push(k),k=g(J),X=void 0,J=void 0):(ut(k,e),at.length=0)),m||(["tag","rule","at"].includes(k.type)&&"cdata"!==k.kind?!t[e]||!I.includes(t[e])&&!"()".includes(t[e])||I.includes(t[r])&&t[r]===t[w]||!mt(e)||(it("simple")&&at[~-at.length].value===L(t[e])?at.pop():at.push({type:"simple",value:t[e],position:e})):"comment"===k.type&&["only","not"].includes(k.kind)?["[","]"].includes(t[e])&&(it("simple")&&at[~-at.length].value===L(t[e])?at.pop():at.push({type:"simple",value:t[e],position:e})):"esp"!==k.type||!"'\"`()".includes(t[e])||['"',"'","`"].includes(t[r])&&t[r]===t[w]||(it("simple")&&at[~-at.length].value===L(t[e])?(at.pop(),m=e+1):"]})>".includes(t[e])||at.push({type:"simple",value:t[e],position:e}))),!m&&"at"===k.type&&null!=k.start&&e>=k.start&&!k.identifierStartsAt&&t[e]&&t[e].trim()&&"@"!==t[e]&&(k.identifierStartsAt=e),!m&&"at"===k.type&&k.queryStartsAt&&!k.queryEndsAt&&"{;".includes(t[e])&&(k.queryEndsAt="{"===t[e]?t[~-e]&&t[~-e].trim()?e:null!==r?r+1:e:b(t,e+1)||0,k.queryStartsAt&&k.queryEndsAt&&(k.query=t.slice(k.queryStartsAt,k.queryEndsAt)),k.end=";"===t[e]?e+1:e,k.value=t.slice(k.start,k.end),";"===t[e]?lt(k):(k.openingCurlyAt=e,at.push({type:"at",token:k})),_(),m=e+1),!m&&"at"===k.type&&k.identifier&&t[e]&&t[e].trim()&&!k.queryStartsAt&&(k.queryStartsAt=e),!m&&k&&"at"===k.type&&k.identifierStartsAt&&e>=k.start&&t[e]&&(!t[e].trim()||"()".includes(t[e]))&&!k.identifierEndsAt&&(k.identifierEndsAt=e,k.identifier=t.slice(k.identifierStartsAt,e)),"rule"===k.type&&$&&(z.includes(t[e])||t[e]&&!t[e].trim()&&z.includes(t[w]))&&(k.selectors.push({value:t.slice($,e),selectorStarts:$,selectorEnds:e}),$=void 0,k.selectorsEnd=e);var K,Y,gt,ft=q(at);if(!m&&t[e])if(function(t,e,r,n,a){return!(!t[e]||!t[e].trim().length||n.length&&"text"!==r.type||r.kind&&["doctype","xml"].includes(r.kind)||a&&"<"!==t[e]||!("<"===t[e]&&(U(t,e,{allowCustomTagNames:!0})||">"===t[f(t,e)]||d(t,e,["doctype","xml","cdata"],{i:!0,trimBeforeMatching:!0,trimCharsBeforeMatching:["?","!","["," ","-"]}))||j(t[e])&&(!t[e-1]||!j(t[e-1])&&!["<","/","!",Z].includes(t[b(t,e)]))&&U(t,e,{allowCustomTagNames:!1,skipOpeningBracket:!0}))||!("esp"!==r.type||r.tail&&r.tail.includes(t[e])))}(t,e,k,at,h)){k.type&&null!==k.start&&("rule"===k.type&&tt&&tt.propertyStarts&&(tt.propertyEnds=e,tt.property=t.slice(tt.propertyStarts,e),tt.end||(tt.end=e),rt(tt),et()),ut(k,e),_()),pt("tag",e),h&&(h=!1);var bt="?![-/",yt="",vt=!1;if(w)for(var At=w;At"],{trimBeforeMatching:!0})||"comment"===r.type&&(r.closing||"not"===r.kind)||c(t,e,"<",{trimBeforeMatching:!0,trimCharsBeforeMatching:["-","!"]})||Array.isArray(n)&&n.length&&"esp"===n[n.length-1].type&&"<"===n[n.length-1].openingLump[0]&&"-"===n[n.length-1].openingLump[2]&&"-"===n[n.length-1].openingLump[3]))}(t,e,k,at))null!=k.start&&ut(k,e),pt("comment",e),"-"===t[e]?k.closing=!0:p(t,e,["1&&at[ft].guessedClosingLump.includes(t[e])&&at[ft].guessedClosingLump.includes(t[e+1])&&!(at[ft+1]&&"'\"".includes(at[ft+1].value)&&t.indexOf(at[ft+1].value,e)>0&&at[ft].guessedClosingLump.includes(t[f(t,t.indexOf(at[ft+1].value,e))]))||function(t,e,r,n,a){return!!(E.includes(t[e])&&t[e+1]&&E.includes(t[e+1])&&(!M.includes(t[e])||!M.includes(t[e+1]))&&(t[e]!==t[e+1]||O.includes(t[e]))&&"rule"!==r.type&&"at"!==r.type&&("-"!==t[e]||!"-{(".includes(t[e+1]))&&(!"})".includes(t[e])||!"-".includes(t[e+1]))&&("%"!==t[e]||"%"!==t[e+1]||!"0123456789".includes(t[e-1])||t[e+2]&&!".,;!?".includes(t[e+2])&&t[e+2].trim().length)&&(!a||!"{}".includes(t[e])&&!"{}".includes(t[f(t,e)]))||"<"===t[e]&&("/"===t[e+1]&&E.includes(t[e+2])||E.includes(t[e+1])&&!["-"].includes(t[e+1]))||"<"===t[e]&&("%"===t[e+1]||t.startsWith("jsp:",e+1)||t.startsWith("cms:",e+1)||t.startsWith("c:",e+1))||t.startsWith("${jspProp",e)||">})".includes(t[e])&&Array.isArray(n)&&n.length&&"esp"===n[n.length-1].type&&n[n.length-1].openingLump.includes(L(t[e]))&&(">"!==t[e]||!P(t,e+1,">","<"))||"-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]&&Array.isArray(n)&&n.length&&"esp"===n[n.length-1].type&&"<"===n[n.length-1].openingLump[0]&&"-"===n[n.length-1].openingLump[2]&&"-"===n[n.length-1].openingLump[3])}(t,e,k,at,h)&&(!it("simple")||!["'",'"'].includes(at[~-at.length].value)||C&&C.attribStarts&&!C.attribEnds)){var wt=function(t,e,r){for(var n=t[e],a=t.length,i=r[q(r)],o=e+1;o1&&(n.includes("<")||n.includes("{")||n.includes("[")||n.includes("("))&&"("===t[o])&&(E.includes(t[o])||i&&i.guessedClosingLump.includes(t[o])||"<"===t[e]&&"/"===t[o]||">"===t[o]&&"--"===n&&Array.isArray(r)&&r.length&&"esp"===r[r.length-1].type&&"<"===r[r.length-1].openingLump[0]&&"-"===r[r.length-1].openingLump[2]&&"-"===r[r.length-1].openingLump[3]||!i&&o>e&&"!=@".includes(t[o]));o++)n+=t[o];if(n&&Array.isArray(r)&&r.length&&"esp"===r[r.length-1].type&&r[r.length-1].guessedClosingLump&&n.length>r[r.length-1].guessedClosingLump.length){if(n.endsWith(r[r.length-1].openingLump))return n.slice(0,n.length-r[r.length-1].openingLump.length);for(var s=new Set(r[r.length-1].guessedClosingLump),l=0,u=function(t,e){if(!s.has(n[e])&&l>1)return{v:n.slice(0,e)};s.has(n[e])&&(l+=1,s=new Set([].concat(s).filter((function(t){return t!==n[e]}))))},c=0,p=n.length;c"===t[e]&&"/"===t[r]&&(k.tailStartsAt=r,k.tail=t.slice(k.tailStartsAt,e+1))),m=k.tailEndsAt,J)return Array.isArray(J.attribs)||(J.attribs=[]),X?(C=X).attribValue.push(n({},k)):J.attribs.push(n({},k)),k=g(J),J=void 0,X=void 0,at.pop(),ht=e,"continue";ut(k,e),_()}at.pop()}else if(at.length&&(Vt=F(wt,at,!0)))"esp"===k.type&&(k.end||(k.end=e+(Vt||0),k.value=t.slice(k.start,k.end)),k.tailStartsAt||(k.tailStartsAt=e),!k.tailEndsAt&&Vt&&(k.tailEndsAt=k.tailStartsAt+Vt,k.tail=t.slice(e,e+Vt)),ut(k,e),_()),at.length=0;else if(C&&C.attribValue&&C.attribValue.length&&C.attribValue[~-C.attribValue.length].start&&Array.from(t.slice(C.attribValue[~-C.attribValue.length].start,e)).some((function(t,e){return wt.includes(L(t))&&(O.includes(t)||!e)&&(kt={char:t,idx:e})}))&&"tag"===k.type&&C&&C.attribValueStartsAt&&!C.attribValueEndsAt&&C.attribValue[~-C.attribValue.length]&&"text"===C.attribValue[~-C.attribValue.length].type){k.pureHTML=!1;var _t=C.attribValue[~-C.attribValue.length],St=ct("esp",_t.start);kt&&kt.idx||(St.head=kt.char,St.headStartsAt=_t.start,St.headEndsAt=St.headStartsAt+1,St.tailStartsAt=e,St.tailEndsAt=e+wt.length,St.tail=wt,C.attribValue[~-C.attribValue.length]=St)}else it("esp")&&at.pop(),X&&(Array.isArray(X.attribValue)||(X.attribValue=[]),X.attribValue.push(k)),at.push({type:"esp",openingLump:wt,guessedClosingLump:L(wt),position:e}),null!==k.start&&("tag"===k.type?(!k.tagNameStartsAt||k.tagName&&k.tagNameEndsAt||(k.tagNameEndsAt=e,k.tagName=t.slice(k.tagNameStartsAt,e),k.recognised=B(k.tagName)),J=g(k),C.attribStarts&&!C.attribEnds&&(X=g(C))):X?X&&Array.isArray(X.attribValue)&&X.attribValue.length&&"esp"===X.attribValue[~-X.attribValue.length].type&&!X.attribValue[~-X.attribValue.length].end&&(X.attribValue[~-X.attribValue.length].end=e,X.attribValue[~-X.attribValue.length].value=t.slice(X.attribValue[~-X.attribValue.length].start,e)):ut(k,e)),pt("esp",e),k.head=wt,k.headStartsAt=e,k.headEndsAt=e+wt.length,J&&J.pureHTML&&(J.pureHTML=!1),X&&Array.isArray(X.attribValue)&&X.attribValue.length&&(X.attribValue[~-X.attribValue.length].start===k.start?X.attribValue.pop():"text"!==X.attribValue[~-X.attribValue.length].type||X.attribValue[~-X.attribValue.length].end||(X.attribValue[~-X.attribValue.length].end=e,X.attribValue[~-X.attribValue.length].value=t.slice(X.attribValue[~-X.attribValue.length].start,e)));m=e+(Vt||wt.length)}}else!h||A||!t[e]||!t[e].trim()||"{}".includes(t[e])||k.type&&!["text"].includes(k.type)?k.type||pt("text",e):(k.type&&ut(k,e),pt("@"===t[e]?"at":"rule",e),k.left=nt,k.nested=at.some((function(t){return"at"===t.type})));(m||!tt||(!tt.valueStarts||tt.valueEnds||"!"===t[w]||w&&t.slice(w).match(G))&&(!tt.importantStarts||tt.importantEnds)||tt.valueEnds&&";"===t[w]||t[e]&&t[e].trim()&&(tt.valueEnds||";"!==t[e])&&((!";}/".includes(t[K=e])||C&&C.attribName&&"style"===C.attribName)&&!("/;'\"><".includes(t[K])&&C&&"style"===C.attribName&&mt(K)))||(tt.importantStarts&&!tt.importantEnds&&(tt.importantEnds=b(t,e)+1,tt.important=t.slice(tt.importantStarts,tt.importantEnds)),tt.valueStarts&&!tt.valueEnds&&(tt.valueEnds=e,tt.value=t.slice(tt.valueStarts,e)),";"===t[e]?(tt.semi=e,tt.end=e+1):";"===t[w]&&(tt.semi=w,tt.end=tt.semi+1,m=tt.end),tt.end||(tt.end=e),rt(tt),et()),m||!tt||!(tt.valueStarts&&!tt.valueEnds||tt.propertyEnds&&!tt.valueStarts&&!w)||!t[e]||t[e].trim()&&"!"!==t[e]&&";"!==t[e]||(tt.valueStarts&&!tt.valueEnds&&(tt.valueEnds=e,tt.value=t.slice(tt.valueStarts,e)),"!"===t[e]?tt.importantStarts=e:";"===t[e]?tt.semi=e:w&&"!"===t[w]||t.slice(e).match(G)?tt.importantStarts=f(t,e):w&&";"===t[w]||(tt.end=b(t,e+1)+1,rt(tt),et()),tt.start||!t[e]||t[e].trim()||rt({type:"text",start:e,end:null,value:null})),!m&&tt&&tt.start&&!tt.end&&";"===t[e]&&(tt.semi=e,tt.end=e+1,tt.propertyEnds||(tt.propertyEnds=e),tt.propertyStarts&&tt.propertyEnds&&!tt.property&&(tt.property=t.slice(tt.propertyStarts,tt.propertyEnds)),rt(tt),et()),!m&&tt&&tt.valueEnds&&!tt.importantStarts&&("!"===t[e]||j(t[e]))&&t.slice(e).match(G)&&(tt.importantStarts=e),!m&&tt&&tt.colon&&!tt.valueStarts&&t[e]&&t[e].trim())&&(";}'\"".includes(t[e])&&mt(e)?(";"===t[e]&&(tt.semi=e),tt.end||(tt.end=tt.semi?tt.semi+1:b(t,e)+1,Y=tt.end),rt(tt),et(),Y&&Y"!==t[e])if("comment"===k.type&&"html"===k.language&&!at.length&&"simple"===k.kind&&("<"===t[k.start]&&"-"===t[e]&&(c(t,e,"!-",{trimBeforeMatching:!0})||function(t,e,r,n){return u("matchLeftIncl",t,e,r,n)}(t,e,"!-",{trimBeforeMatching:!0})&&"-"!==t[e+1])||"-"===t[k.start]&&">"===t[e]&&c(t,e,"--",{trimBeforeMatching:!0,maxMismatches:1})))"-"===t[e]&&(d(t,e,["[if","(if","{if"],{i:!0,trimBeforeMatching:!0})||d(t,e,["if"],{i:!0,trimBeforeMatching:!0})&&(P(t,e,"]",">")||t.includes("mso",e)&&!t.slice(e,t.indexOf("mso")).includes("<")&&!t.slice(e,t.indexOf("mso")).includes(">")))?k.kind="only":"-"!==t[k.start]&&p(t,e,["-"!==t[w]?"html"===k.language&&(k.end=e+1,"!"===t[r]&&"-"===t[w]&&(k.end=w+1),k.value=t.slice(k.start,k.end)):(k.end=w+1,k.kind="simplet",k.closing=null);else if("comment"!==k.type||"html"!==k.language||">"!==t[e]||at.length&&"<"!==t[w]){if("comment"===k.type&&"css"===k.language&&"*"===t[e]&&"/"===t[e+1])k.end=e+1,k.value=t.slice(k.start,k.end);else if("esp"===k.type&&null===k.end&&"string"==typeof k.head&&"string"==typeof k.tail&&k.tail.includes(t[e])){for(var xt="",Ct=e;Ctk.head.length){var Et=k.head[0];if(xt.endsWith(k.head))k.end=e+xt.length-k.head.length,k.value=t.slice(k.start,k.end),m=k.end;else if(xt.startsWith(k.tail))k.end=e+k.tail.length,k.value=t.slice(k.start,k.end),m=k.end;else if(!k.tail.includes(Et)&&xt.includes(Et)||xt.endsWith(k.head)||xt.startsWith(k.tail)){var Ot=xt.slice(0,xt.indexOf(Et)),Mt=xt.slice(xt.indexOf(Et));Ot.length&&Mt.length&&k.tail.split("").every((function(t){return Ot.includes(t)}))&&(k.end=e+Ot.length,k.value=t.slice(k.start,k.end),m=k.end)}else k.end=e+xt.length,k.value=t.slice(k.start,k.end),m=k.end}else k.end=e+xt.length,k.value=t.slice(k.start,k.end),it("esp")&&at.pop(),m=k.end}}else Array.isArray(at)&&at.length&&"["===at[~-at.length].value&&at.pop(),!["simplet","not"].includes(k.kind)&&d(t,e,["\x3c!--\x3e","\x3c!----\x3e"],{trimBeforeMatching:!0,maxMismatches:1,lastMustMatch:!0})?k.kind="not":(k.end=e+1,k.value=t.slice(k.start,k.end));else k.end=e+1,k.value=t.slice(k.start,k.end);if(m||"tag"!==k.type||!k.tagNameStartsAt||k.tagNameEndsAt||t[e]&&/[.\-_a-z0-9\u00B7\u00C0-\uFFFD]/i.test(t[e])||(k.tagNameEndsAt=e,k.tagName=t.slice(k.tagNameStartsAt,e).toLowerCase(),"xml"===k.tagName&&k.closing&&!k.kind&&(k.kind="xml"),T.includes(k.tagName)&&(k.void=!0),k.recognised=B(k.tagName)),m||"tag"!==k.type||k.tagNameStartsAt||null==k.start||!(k.startC.attribNameStartsAt&&null===C.attribNameEndsAt&&!v(t[e])&&(C.attribNameEndsAt=e,C.attribName=t.slice(C.attribNameStartsAt,e),C.attribNameRecognised=y.has(C.attribName),C.attribName.startsWith("mc:")&&(k.pureHTML=!1),t[e]&&!t[e].trim()&&"="===t[w]||(t[e]&&!t[e].trim()||">"===t[e]||"/"===t[e]&&">"===t[w])&&("'\"".includes(t[w])||(C.attribEnds=e,k.attribs.push(g(C)),D()))),!m&&t[e]&&"tag"===k.type&&"cdata"!==k.kind&&k.tagNameEndsAt&&e>k.tagNameEndsAt&&null===C.attribStarts&&v(t[e])&&(C.attribStarts=e,C.attribLeft=nt,C.attribNameStartsAt=e),m||"rule"!==k.type||("{"!==t[e]||k.openingCurlyAt?"}"===t[e]&&k.openingCurlyAt&&!k.closingCurlyAt&&(k.closingCurlyAt=e,k.end=e+1,k.value=t.slice(k.start,k.end),Array.isArray(k.properties)&&k.properties.length&&k.properties[~-k.properties.length].start&&!k.properties[~-k.properties.length].end&&(k.properties[~-k.properties.length].end=e,k.properties[~-k.properties.length].value=t.slice(k.properties[~-k.properties.length].start,e)),lt(k),it("at")&&at[~-at.length].token.rules.push(k),_()):k.openingCurlyAt=e),!m&&C.attribName&&Array.isArray(C.attribValue)&&C.attribValue.length&&!C.attribValue[~-C.attribValue.length].end&&"*"===t[e]&&"/"===t[w]&&ot(e),(!m&&C&&C.attribValueStartsAt&&!C.attribValueEndsAt&&!tt.propertyStarts&&e>=C.attribValueStartsAt&&Array.isArray(C.attribValue)&&(!C.attribValue.length||C.attribValue[~-C.attribValue.length].end&&C.attribValue[~-C.attribValue.length].end<=e)||!m&&"rule"===k.type&&k.openingCurlyAt&&!k.closingCurlyAt&&!tt.propertyStarts)&&(t[e]&&!t[e].trim()||it("block"))&&(C.attribName?C.attribValue.push({type:"text",start:e,end:null,value:null}):"rule"!==k.type||Array.isArray(k.properties)&&k.properties.length&&!k.properties[~-k.properties.length].end||k.properties.push({type:"text",start:e,end:null,value:null})),!m&&"tag"===k.type&&C.attribValueStartsAt&&e>=C.attribValueStartsAt&&null===C.attribValueEndsAt)if(I.includes(t[e]))at.some((function(t){return"esp"===t.type}))||t[e]&&t.includes(">",e)&&!x(t,C.attribOpeningQuoteAt||C.attribValueStartsAt,e)?Array.isArray(C.attribValue)&&C.attribValue.length&&"text"===C.attribValue[~-C.attribValue.length].type||tt.propertyStarts||C.attribValue.push({type:"text",start:e,end:null,value:null}):(C.attribClosingQuoteAt=e,C.attribValueEndsAt=e,C.attribValueStartsAt&&(C.attribValueRaw=t.slice(C.attribValueStartsAt,e)),C.attribEnds=e+1,tt.propertyStarts&&(C.attribValue.push(g(tt)),et()),Array.isArray(C.attribValue)&&C.attribValue.length&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].property||(C.attribValue[~-C.attribValue.length].end=e,C.attribValue[~-C.attribValue.length].value=t.slice(C.attribValue[~-C.attribValue.length].start,e))),t[C.attribOpeningQuoteAt]!==t[e]&&(at.pop(),at.pop()),C.attribValue[~-C.attribValue.length]&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].end=e),k.attribs.push(g(C)),D());else if(null===C.attribOpeningQuoteAt&&(t[e]&&!t[e].trim()||["/",">"].includes(t[e])||E.includes(t[e])&&E.includes(t[e+1])))C.attribValueEndsAt=e,C.attribValueRaw=t.slice(C.attribValueStartsAt,e),Array.isArray(C.attribValue)&&C.attribValue.length&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].end=e,C.attribValue[~-C.attribValue.length].value=t.slice(C.attribValue[~-C.attribValue.length].start,C.attribValue[~-C.attribValue.length].end)),C.attribEnds=e,k.attribs.push(g(C)),D(),at.pop(),">"===t[e]&&(k.end=e+1,k.value=t.slice(k.start,k.end));else if("="!==t[e]||null===r||!w||!("'\"".includes(t[w])||t[~-e]&&j(t[~-e]))||C&&C.attribOpeningQuoteAt&&(/\//.test(t.slice(C.attribOpeningQuoteAt+1,e))||/mailto:/.test(t.slice(C.attribOpeningQuoteAt+1,e))||/\w\?\w/.test(t.slice(C.attribOpeningQuoteAt+1,e))))!C||"style"===C.attribName||!C.attribStarts||C.attribEnds||tt.propertyStarts||Array.isArray(C.attribValue)&&C.attribValue.length&&!(C.attribValue[~-C.attribValue.length].end&&C.attribValue[~-C.attribValue.length].end<=e)||C.attribValue.push({type:"text",start:e,end:null,value:null});else{for(var Nt,jt,Lt=r;Lt>=C.attribValueStartsAt;Lt--)Nt||!t[Lt]||t[Lt].trim()||(Nt=!0,jt&&t.slice(Lt,jt)),Nt&&t[Lt]&&t[Lt].trim()&&(Nt=!1,jt||(jt=Lt+1));if(jt)return C.attribValueEndsAt=jt,C.attribValueStartsAt&&(C.attribValueRaw=t.slice(C.attribValueStartsAt,jt),Array.isArray(C.attribValue)&&C.attribValue.length&&!C.attribValue[~-C.attribValue.length].end&&(C.attribValue[~-C.attribValue.length].end=C.attribValueEndsAt,C.attribValue[~-C.attribValue.length].value=t.slice(C.attribValue[~-C.attribValue.length].start,C.attribValueEndsAt))),C.attribEnds=jt,t[C.attribOpeningQuoteAt]!==t[e]&&at.pop(),k.attribs.push(g(C)),D(),ht=e=~-jt,"continue";if(C.attribOpeningQuoteAt&&("'\"".includes(t[w])||y.has(t.slice(C.attribOpeningQuoteAt+1,e).trim())))return e=C.attribOpeningQuoteAt,C.attribEnds=C.attribOpeningQuoteAt+1,C.attribValueStartsAt=null,at.pop(),k.attribs.push(g(C)),D(),ht=e,"continue"}else"esp"===k.type&&X&&J&&X.attribOpeningQuoteAt&&X.attribValueStartsAt&&"'\"".includes(t[e])&&t[X.attribOpeningQuoteAt]===t[e]&&x(t,X.attribOpeningQuoteAt,e)&&(k.end=e,k.value=t.slice(k.start,e),X&&!Array.isArray(X.attribValue)&&(X.attribValue=[]),X.attribValue.push(k),X.attribValueEndsAt=e,X.attribValueRaw=t.slice(X.attribValueStartsAt,e),X.attribClosingQuoteAt=e,X.attribEnds=e+1,(k=g(J)).attribs.push(X),X=void 0,J=void 0,at.pop(),at.pop(),at.pop());if(!m&&"tag"===k.type&&!C.attribValueStartsAt&&C.attribNameEndsAt&&C.attribNameEndsAt<=e&&t[e]&&t[e].trim())if("="!==t[e]||I.includes(t[w])||"=".includes(t[w])||E.includes(t[w])){if(I.includes(t[e])){var Bt=w;!(Bt&&I.includes(t[Bt])&&t[e]!==t[Bt]&&t.length>Bt+2&&t.slice(Bt+1).includes(t[Bt]))||t.indexOf(t[Bt],Bt+1)&&f(t,t.indexOf(t[Bt],Bt+1))&&t[e]===t[f(t,t.indexOf(t[Bt],Bt+1))]||Array.from(t.slice(Bt+1,t.indexOf(t[Bt]))).some((function(r){return("<>="+t[e]).includes(r)}))?C.attribOpeningQuoteAt?(x(t,C.attribOpeningQuoteAt,e)&&(C.attribClosingQuoteAt=e),C.attribOpeningQuoteAt&&C.attribClosingQuoteAt&&(C.attribValueRaw=C.attribOpeningQuoteAt<~-C.attribClosingQuoteAt?t.slice(C.attribOpeningQuoteAt+1,C.attribClosingQuoteAt):"",C.attribEnds=e+1,k.attribs.push(g(C)),D())):(C.attribOpeningQuoteAt=e,!t[e+1]||t[e+1]===t[e]&&mt(e+1)||(C.attribValueStartsAt=e+1)):at.pop()}}else{var Pt=I.split("").map((function(e){return t.indexOf(e,w)})).filter((function(t){return t>0})).length?Math.min.apply(Math,I.split("").map((function(e){return t.indexOf(e,w)})).filter((function(t){return t>0}))):void 0;w&&t.slice(w).includes("=")&&y.has(t.slice(w,w+t.slice(w).indexOf("=")).trim().toLowerCase())?(C.attribEnds=e+1,k.attribs.push(n({},C)),D()):Pt&&!t.slice(w,Pt).includes("=")&&t.includes(t[Pt],Pt+1)&&!Array.from(t.slice(Pt+1,t.indexOf(t[Pt],Pt+1))).some((function(t){return"<>=".includes(t)}))||(C.attribValueStartsAt=w,at.push({type:"simple",value:null,position:C.attribValueStartsAt}))}if(!m&&">"===t[e]&&"%"!==t[e-1]&&"tag"===k.type&&C.attribStarts&&!C.attribEnds){var Rt=!1;if(t[e+1])for(var Tt=e+1;Tt"===t[Tt])break;if("<"===t[Tt]){Rt=!0,at.pop();break}if(!t[Tt+1]){Rt=!0;break}}else Rt=!0;Rt&&(k.end=e+1,k.value=t.slice(k.start,k.end),C.attribValueStartsAt&&e&&C.attribValueStartsAta.charCbLookahead&&st(V,a.charCb,a.charCbLookahead))),t[e]||null===k.start||(k.end=e,k.value=t.slice(k.start,k.end),C&&C.attribName&&(C.attribEnds||(C.attribEnds=e),k.attribs.push(n({},C)),D()),k&&Array.isArray(k.properties)&&k.properties.length&&!k.properties[~-k.properties.length].end&&(k.properties[~-k.properties.length].end=e,k.properties[~-k.properties.length].start&&!k.properties[~-k.properties.length].value&&(k.properties[~-k.properties.length].value=t.slice(k.properties[~-k.properties.length].start,e))),tt&&tt.propertyStarts&&(tt.end||(tt.end=e),rt(tt),et()),lt(k)),t[e]&&t[e].trim()&&(nt=e),ht=e},ht=0;ht<=s;ht++)gt(ht);if(V.length)for(var ft=0,bt=V.length;ft): Res { property && ((property.valueStarts && !property.valueEnds && - str[rightVal as number] !== "!") || + str[rightVal as number] !== "!" && + // either non-whitespace character doesn't exist on the right + (!rightVal || + // or at that character !important does not start + !str.slice(rightVal).match(importantStartsRegexp))) || (property.importantStarts && !property.importantEnds)) && (!property.valueEnds || str[rightVal as number] !== ";") && // either end of string was reached @@ -2799,7 +2803,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // or we reached the end of the attribute attrEndsAt(i)) ) { - console.log(`2802 ${`\u001b[${32}m${`css property ends`}\u001b[${39}m`}`); + console.log(`2806 ${`\u001b[${32}m${`css property ends`}\u001b[${39}m`}`); /* istanbul ignore else */ if (property.importantStarts && !property.importantEnds) { @@ -2809,7 +2813,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { property.importantEnds ); console.log( - `2812 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.importantEnds`}\u001b[${39}m`} = ${JSON.stringify( + `2816 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.importantEnds`}\u001b[${39}m`} = ${JSON.stringify( property.importantEnds, null, 4 @@ -2826,7 +2830,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { property.valueEnds = i; property.value = str.slice(property.valueStarts, i); console.log( - `2829 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.valueEnds`}\u001b[${39}m`} = ${JSON.stringify( + `2833 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.valueEnds`}\u001b[${39}m`} = ${JSON.stringify( property.valueEnds, null, 4 @@ -2842,7 +2846,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { if (str[i] === ";") { property.semi = i; console.log( - `2845 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( + `2849 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( property.semi, null, 4 @@ -2850,7 +2854,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { ); property.end = i + 1; console.log( - `2853 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( + `2857 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( property.end, null, 4 @@ -2860,7 +2864,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { property.semi = rightVal; property.end = (property.semi as number) + 1; console.log( - `2863 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( + `2867 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( property.semi, null, 4 @@ -2873,7 +2877,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { doNothing = property.end; console.log( - `2876 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${31}m${`doNothing`}\u001b[${39}m`} = ${JSON.stringify( + `2880 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${31}m${`doNothing`}\u001b[${39}m`} = ${JSON.stringify( doNothing, null, 4 @@ -2884,7 +2888,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { if (!property.end) { property.end = i; console.log( - `2887 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( + `2891 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( property.end, null, 4 @@ -2894,7 +2898,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { pushProperty(property); console.log( - `2897 push ${JSON.stringify( + `2901 push ${JSON.stringify( property, null, 4 @@ -2915,13 +2919,13 @@ function tokenizer(str: string, originalOpts?: Partial): Res { (!str[i].trim() || str[i] === "!" || str[i] === ";") ) { console.log( - `2918 ${`\u001b[${32}m${`css property's value ends`}\u001b[${39}m`}` + `2922 ${`\u001b[${32}m${`css property's value ends`}\u001b[${39}m`}` ); if (property.valueStarts && !property.valueEnds) { property.valueEnds = i; property.value = str.slice(property.valueStarts, i); console.log( - `2924 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.valueEnds`}\u001b[${39}m`} = ${JSON.stringify( + `2928 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.valueEnds`}\u001b[${39}m`} = ${JSON.stringify( property.valueEnds, null, 4 @@ -2949,7 +2953,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // we're here console.log( - `2952 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`idxOnTheRight`}\u001b[${39}m`} = ${JSON.stringify( + `2956 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`idxOnTheRight`}\u001b[${39}m`} = ${JSON.stringify( rightVal, null, 4 @@ -2959,7 +2963,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { if (str[i] === "!") { property.importantStarts = i; console.log( - `2962 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.importantStarts`}\u001b[${39}m`} = ${JSON.stringify( + `2966 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.importantStarts`}\u001b[${39}m`} = ${JSON.stringify( property.importantStarts, null, 4 @@ -2968,7 +2972,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { } else if (str[i] === ";") { property.semi = i; console.log( - `2971 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( + `2975 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( property.semi, null, 4 @@ -2976,11 +2980,11 @@ function tokenizer(str: string, originalOpts?: Partial): Res { ); } else if ( (rightVal && str[rightVal] === "!") || - importantStartsRegexp.test(str.slice(i)) + str.slice(i).match(importantStartsRegexp) ) { property.importantStarts = right(str, i); console.log( - `2983 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.importantStarts`}\u001b[${39}m`} = ${JSON.stringify( + `2987 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.importantStarts`}\u001b[${39}m`} = ${JSON.stringify( property.importantStarts, null, 4 @@ -2989,7 +2993,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { } else if (!rightVal || str[rightVal] !== ";") { property.end = (left(str, i + 1) as number) + 1; console.log( - `2992 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( + `2996 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( property.end, null, 4 @@ -2998,7 +3002,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { pushProperty(property); console.log( - `3001 push ${JSON.stringify( + `3005 push ${JSON.stringify( property, null, 4 @@ -3009,7 +3013,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { if (!property.start && str[i] && !str[i].trim()) { console.log( - `3012 PUSH ${JSON.stringify( + `3016 PUSH ${JSON.stringify( { type: "text", start: i, @@ -3041,7 +3045,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { property.semi = i; property.end = i + 1; console.log( - `3044 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( + `3048 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( property.semi, null, 4 @@ -3054,7 +3058,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { if (!property.propertyEnds) { property.propertyEnds = i; console.log( - `3057 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.propertyEnds`}\u001b[${39}m`} = ${JSON.stringify( + `3061 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.propertyEnds`}\u001b[${39}m`} = ${JSON.stringify( property.propertyEnds, null, 4 @@ -3071,7 +3075,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { property.propertyEnds ); console.log( - `3074 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.property`}\u001b[${39}m`} = ${JSON.stringify( + `3078 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.property`}\u001b[${39}m`} = ${JSON.stringify( property.property, null, 4 @@ -3081,7 +3085,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { pushProperty(property); console.log( - `3084 push ${JSON.stringify( + `3088 push ${JSON.stringify( property, null, 4 @@ -3099,14 +3103,14 @@ function tokenizer(str: string, originalOpts?: Partial): Res { property.valueEnds && !property.importantStarts && (str[i] === "!" || isLatinLetter(str[i])) && - importantStartsRegexp.test(str.slice(i)) + str.slice(i).match(importantStartsRegexp) ) { console.log( - `3105 ${`\u001b[${32}m${`css property's !important starts`}\u001b[${39}m`}` + `3109 ${`\u001b[${32}m${`css property's !important starts`}\u001b[${39}m`}` ); property.importantStarts = i; console.log( - `3109 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.importantStarts`}\u001b[${39}m`} = ${JSON.stringify( + `3113 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.importantStarts`}\u001b[${39}m`} = ${JSON.stringify( property.importantStarts, null, 4 @@ -3125,7 +3129,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { str[i] && str[i].trim() ) { - console.log(`3128`); + console.log(`3132`); /* istanbul ignore else */ if ( // stopper character met: @@ -3133,12 +3137,12 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // either it's real closing quote or not a quote ifQuoteThenAttrClosingQuote(i) ) { - console.log(`3136 ${`\u001b[${31}m${`broken code!`}\u001b[${39}m`}`); + console.log(`3140 ${`\u001b[${31}m${`broken code!`}\u001b[${39}m`}`); /* istanbul ignore else */ if (str[i] === ";") { property.semi = i; console.log( - `3141 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( + `3145 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( property.semi, null, 4 @@ -3155,7 +3159,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { ? property.semi + 1 : (left(str, i) as number) + 1; console.log( - `3158 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( + `3162 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( property.end, null, 4 @@ -3168,11 +3172,11 @@ function tokenizer(str: string, originalOpts?: Partial): Res { pushProperty(property); propertyReset(); console.log( - `3171 push, then ${`\u001b[${31}m${`WIPE`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`}` + `3175 push, then ${`\u001b[${31}m${`WIPE`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`}` ); console.log( - `3175 FIY, ${`\u001b[${33}m${`temp`}\u001b[${39}m`} = ${JSON.stringify( + `3179 FIY, ${`\u001b[${33}m${`temp`}\u001b[${39}m`} = ${JSON.stringify( temp, null, 4 @@ -3191,11 +3195,11 @@ function tokenizer(str: string, originalOpts?: Partial): Res { } } else { console.log( - `3194 ${`\u001b[${32}m${`css property's value starts`}\u001b[${39}m`}` + `3198 ${`\u001b[${32}m${`css property's value starts`}\u001b[${39}m`}` ); property.valueStarts = i; console.log( - `3198 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.valueStarts`}\u001b[${39}m`} = ${JSON.stringify( + `3202 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.valueStarts`}\u001b[${39}m`} = ${JSON.stringify( property.valueStarts, null, 4 @@ -3218,13 +3222,13 @@ function tokenizer(str: string, originalOpts?: Partial): Res { if (!",".includes(str[i])) { selectorChunkStartedAt = i; console.log( - `3221 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`selectorChunkStartedAt`}\u001b[${39}m`} = ${selectorChunkStartedAt}` + `3225 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`selectorChunkStartedAt`}\u001b[${39}m`} = ${selectorChunkStartedAt}` ); if (token.selectorsStart === null) { token.selectorsStart = i; console.log( - `3227 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.selectorsStart`}\u001b[${39}m`} = ${ + `3231 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.selectorsStart`}\u001b[${39}m`} = ${ token.selectorsStart }` ); @@ -3234,7 +3238,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // correctly broken chunk range, [selectorsStart, selectorsEnd] token.selectorsEnd = i + 1; console.log( - `3237 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.selectorsEnd`}\u001b[${39}m`} = ${ + `3241 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.selectorsEnd`}\u001b[${39}m`} = ${ token.selectorsEnd }` ); @@ -3282,12 +3286,12 @@ function tokenizer(str: string, originalOpts?: Partial): Res { (str[i] !== "/" || str[i - 1] !== "/") ) { console.log( - `3285 ${`\u001b[${32}m${`css property's name ends`}\u001b[${39}m`}` + `3289 ${`\u001b[${32}m${`css property's name ends`}\u001b[${39}m`}` ); property.propertyEnds = i; property.property = str.slice(property.propertyStarts, i); console.log( - `3290 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`} = ${JSON.stringify( + `3294 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`} = ${JSON.stringify( property, null, 4 @@ -3300,7 +3304,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // imagine we're here - valueStarts is not set! property.end = i; console.log( - `3303 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( + `3307 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( property.end, null, 4 @@ -3319,7 +3323,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { if (str[i] === ";") { property.semi = i; console.log( - `3322 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( + `3326 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.semi`}\u001b[${39}m`} = ${JSON.stringify( property.semi, null, 4 @@ -3333,7 +3337,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { if (!property.end) { property.end = property.semi ? property.semi + 1 : i; console.log( - `3336 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( + `3340 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.end`}\u001b[${39}m`} = ${JSON.stringify( property.end, null, 4 @@ -3345,7 +3349,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { pushProperty(property); propertyReset(); console.log( - `3348 push, then ${`\u001b[${31}m${`WIPE`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`}` + `3352 push, then ${`\u001b[${31}m${`WIPE`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`}` ); } } @@ -3367,7 +3371,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { ) { property.colon = i; console.log( - `3370 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.colon`}\u001b[${39}m`} = ${JSON.stringify( + `3374 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`property.colon`}\u001b[${39}m`} = ${JSON.stringify( property.colon, null, 4 @@ -3393,7 +3397,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { !property.importantStarts ) { console.log( - `3396 ${`\u001b[${32}m${`css property's name starts`}\u001b[${39}m`}` + `3400 ${`\u001b[${32}m${`css property's name starts`}\u001b[${39}m`}` ); // first, check maybe there's unfinished text token before it @@ -3409,7 +3413,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { i ); console.log( - `3412 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} last elem of ${`\u001b[${33}m${`token.properties[]`}\u001b[${39}m`} to: ${JSON.stringify( + `3416 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} last elem of ${`\u001b[${33}m${`token.properties[]`}\u001b[${39}m`} to: ${JSON.stringify( token.properties[~-token.properties.length], null, 4 @@ -3435,7 +3439,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { initProperty(i); } console.log( - `3438 ${`\u001b[${32}m${`INIT`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`} = ${JSON.stringify( + `3442 ${`\u001b[${32}m${`INIT`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`} = ${JSON.stringify( property, null, 4 @@ -3472,7 +3476,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // it's not inside CSS block comment !lastLayerIs("block") ) { - console.log(`3475 inside start of css property/comment token`); + console.log(`3479 inside start of css property/comment token`); // It's either css comment or a css property. // Dirty characters go as property name, then later we validate and // catch them. @@ -3485,7 +3489,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { str[rightVal as number] === "*" ) { console.log( - `3488 ${`\u001b[${32}m${`BLOCK COMMENT OPENING`}\u001b[${39}m`}` + `3492 ${`\u001b[${32}m${`BLOCK COMMENT OPENING`}\u001b[${39}m`}` ); attribPush({ @@ -3505,7 +3509,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { position: i, }); console.log( - `3508 ${`\u001b[${32}m${`PUSH`}\u001b[${39}m`} new layer, ${JSON.stringify( + `3512 ${`\u001b[${32}m${`PUSH`}\u001b[${39}m`} new layer, ${JSON.stringify( { type: "block", value: str[i], @@ -3519,7 +3523,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // skip the next char, consider there might be whitespace in front doNothing = (rightVal as number) + 1; console.log( - `3522 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${31}m${`doNothing`}\u001b[${39}m`} = ${JSON.stringify( + `3526 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${31}m${`doNothing`}\u001b[${39}m`} = ${JSON.stringify( doNothing, null, 4 @@ -3528,10 +3532,10 @@ function tokenizer(str: string, originalOpts?: Partial): Res { } // if it's a closing comment else if (str[i] === "*" && str[rightVal as number] === "/") { - console.log(`3531 call closingComment()`); + console.log(`3535 call closingComment()`); closingComment(i); } else { - console.log(`3534`); + console.log(`3538`); // first, close the text token if it's not ended if ( Array.isArray(attrib.attribValue) && @@ -3544,7 +3548,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { i ); console.log( - `3547 complete last attrib object: ${JSON.stringify( + `3551 complete last attrib object: ${JSON.stringify( attrib.attribValue[~-attrib.attribValue.length], null, 4 @@ -3555,7 +3559,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // initiate a property initProperty(i); console.log( - `3558 ${`\u001b[${32}m${`INIT`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`} = ${JSON.stringify( + `3562 ${`\u001b[${32}m${`INIT`}\u001b[${39}m`} ${`\u001b[${33}m${`property`}\u001b[${39}m`} = ${JSON.stringify( property, null, 4 @@ -3582,7 +3586,7 @@ function tokenizer(str: string, originalOpts?: Partial): Res { token.end = i + 1; token.value = str.slice(token.start, token.end); console.log( - `3585 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.end`}\u001b[${39}m`} = ${ + `3589 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.end`}\u001b[${39}m`} = ${ token.end }` ); @@ -3633,11 +3637,11 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // we're here // console.log( - `3636 ${`\u001b[${32}m${`OUTLOOK CONDITIONAL "ONLY" DETECTED`}\u001b[${39}m`}` + `3640 ${`\u001b[${32}m${`OUTLOOK CONDITIONAL "ONLY" DETECTED`}\u001b[${39}m`}` ); token.kind = "only"; console.log( - `3640 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.kind`}\u001b[${39}m`} = ${ + `3644 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.kind`}\u001b[${39}m`} = ${ token.kind }` ); @@ -3660,12 +3664,12 @@ function tokenizer(str: string, originalOpts?: Partial): Res { // we're here // console.log( - `3663 ${`\u001b[${32}m${`OUTLOOK CONDITIONAL "NOT" DETECTED`}\u001b[${39}m`}` + `3667 ${`\u001b[${32}m${`OUTLOOK CONDITIONAL "NOT" DETECTED`}\u001b[${39}m`}` ); token.kind = "not"; token.closing = true; console.log( - `3668 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.kind`}\u001b[${39}m`} = ${ + `3672 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.kind`}\u001b[${39}m`} = ${ token.kind }; ${`\u001b[${33}m${`token.closing`}\u001b[${39}m`} = ${ token.closing @@ -3678,30 +3682,30 @@ function tokenizer(str: string, originalOpts?: Partial): Res { str[rightVal as number] === ">" ) { console.log( - `3681 ${`\u001b[${32}m${`simplet-kind comment token's ending caught`}\u001b[${39}m`}` + `3685 ${`\u001b[${32}m${`simplet-kind comment token's ending caught`}\u001b[${39}m`}` ); token.end = (rightVal as number) + 1; token.kind = "simplet"; token.closing = null; console.log( - `3687 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.end`}\u001b[${39}m`} = ${ + `3691 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.end`}\u001b[${39}m`} = ${ token.end }` ); console.log( - `3692 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.kind`}\u001b[${39}m`} = ${ + `3696 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.kind`}\u001b[${39}m`} = ${ token.kind }` ); console.log( - `3697 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.closing`}\u001b[${39}m`} = ${ + `3701 ${`\u001b[${32}m${`SET`}\u001b[${39}m`} ${`\u001b[${33}m${`token.closing`}\u001b[${39}m`} = ${ token.closing }` ); } else if (token.language === "html") { // if it's a simple HTML comment,