New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@adguard/extended-css

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adguard/extended-css - npm Package Compare versions

Comparing version 2.0.5 to 2.0.7

2

dist/build.txt

@@ -1,1 +0,1 @@

version=2.0.5
version=2.0.7

@@ -1,5 +0,5 @@

/*! @adguard/extended-css - v2.0.5 - Mon Nov 07 2022
/*! @adguard/extended-css - v2.0.7 - Thu Nov 10 2022
* https://github.com/AdguardTeam/ExtendedCss#homepage
* Copyright (c) 2022 AdGuard. Licensed GPL-3.0
*/
var ExtendedCss=function(e){"use strict";const t={LEFT:"[",RIGHT:"]"},r={LEFT:"(",RIGHT:")"},o={LEFT:"{",RIGHT:"}"},s="/",n=",",a=":",c='"',l=[" ","\t","\r","\n","\f"],i="*",d=" ",u=">",p="+",h="~",f=[d,u,p,h],m=["[","]","(",")","{","}",s,"\\",";",a,n,"'",c,"^","$",i,"#",".",d,u,p,h,"\t","\r","\n","\f"],g="contains",w="has-text",v="-abp-contains",E="matches-css",b="matches-css-before",y="matches-css-after",S="matches-attr",x="matches-property",k="xpath",T="nth-ancestor",N="upward",P="remove",R="-abp-has",C=["has","if",R],O="if-not",A="is",I="not",L=[g,w,v,E,b,y,S,x,k,T,N],M=[...C,O,A,I],B=[...L,...M],D="scope",F={AFTER:"after",BACKDROP:"backdrop",BEFORE:"before",CUE:"cue",CUE_REGION:"cue-region",FIRST_LETTER:"first-letter",FIRST_LINE:"first-line",FILE_SELECTION_BUTTON:"file-selector-button",GRAMMAR_ERROR:"grammar-error",MARKER:"marker",PART:"part",PLACEHOLDER:"placeholder",SELECTION:"selection",SLOTTED:"slotted",SPELLING_ERROR:"spelling-error",TARGET_TEXT:"target-text"},W="true",_="global",$="No style declaration at stylesheet part",j="Invalid style declaration at stylesheet part",V="Unclosed style declaration at stylesheet part",U="Missing style property in declaration at stylesheet part",q="Missing style value in declaration at stylesheet part",G="Invalid :remove() pseudo-class in selector",H="Invalid stylesheet - no style declared or :remove() pseudo-class used",K=(e,t,r)=>e?e.split(t).join(r):e,X=e=>{if(e.startsWith(s)&&e.endsWith(s))return new RegExp(e.slice(1,-1));const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(t)},z=e=>{let t;switch(e){case void 0:t="undefined";break;case null:t="null";break;default:t=e.toString()}return t},Y=e=>{const t=Number(e);let r;if(Number.isNaN(t))switch(e){case"undefined":r=void 0;break;case"null":r=null;break;case"true":r=!0;break;case"false":r=!1;break;default:r=e}else r=t;return r},J={error:"undefined"!=typeof console&&console.error&&console.error.bind?console.error.bind(window.console):console.error,info:"undefined"!=typeof console&&console.info&&console.info.bind?console.info.bind(window.console):console.info};var Q;!function(e){e.Chrome="Chrome",e.Firefox="Firefox",e.Edge="Edg",e.Opera="Opera",e.Safari="Safari"}(Q||(Q={}));const Z="Chromium",ee="Google Chrome",te="Apple Computer, Inc."===navigator.vendor,re={[Q.Chrome]:{MASK:/\s(Chrome)\/(\d+)\..+\s(?!.*Edg\/)/,MIN_VERSION:55},[Q.Firefox]:{MASK:/\s(Firefox)\/(\d+)\./,MIN_VERSION:52},[Q.Edge]:{MASK:/\s(Edg)\/(\d+)\./,MIN_VERSION:80},[Q.Opera]:{MASK:/\s(OPR)\/(\d+)\./,MIN_VERSION:80},[Q.Safari]:{MASK:/\sVersion\/(\d{2}\.\d)(.+\s|\s)(Safari)\//,MIN_VERSION:11.1}},oe=()=>{const e=(()=>{var e;const t=null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands;return t&&t.find((e=>e.brand===Z||e.brand===ee))||null})();if(!e){const e=(()=>{let e,t;const r=Object.values(Q);for(let o=0;o<r.length;o+=1){const s=re[r[o]].MASK.exec(navigator.userAgent);if(s)return s[3]===r[o]?(e=s[3],t=Number(s[1])):(e=s[1],t=Number(s[2])),{browserName:e,currentVersion:t}}return null})();if(!e)return null;return{browserName:e.browserName,currentVersion:e.currentVersion}}const t=e.brand,r=e.version;return{browserName:t===Z||t===ee?Q.Chrome:t,currentVersion:Number(r)}},se={MutationObserver:window.MutationObserver||window.WebKitMutationObserver},ne=(()=>{var e;const t=window.Node||Node;return null===(e=Object.getOwnPropertyDescriptor(t.prototype,"textContent"))||void 0===e?void 0:e.get})(),ae=e=>{let t=e.tagName.toLowerCase();return t+=Array.from(e.attributes).map((t=>"[".concat(t.name,'="').concat(e.getAttribute(t.name),'"]'))).join(""),t},ce=e=>e instanceof HTMLElement;var le;!function(e){e.Background="background",e.BackgroundImage="background-image",e.Content="content",e.Opacity="opacity"}(le||(le={}));const ie=".*",de=/^\s*\/.*\/[gmisuy]*\s*$/,ue=e=>{if(!e.includes('url("')){const t=/url\((.*?)\)/g;return e.replace(t,'url("$1")')}return e},pe=e=>e.replace(/(\^)?url(\\)?\\\((\w|\[\w)/g,'$1url$2\\(\\"?$3'),he=ue,fe=e=>{let t;return e.startsWith(s)&&e.endsWith(s)?(t=pe(e),t=t.slice(1,-1)):(t=he(e),t=t.replace(/\\([\\()[\]"])/g,"$1"),t=(e=>{const t=new RegExp("[".concat([".","+","?","$","{","}","(",")","[","]","\\","/"].join("\\"),"]"),"g");return e.replace(t,"\\$&")})(t),t=K(t,i,ie)),new RegExp(t,"i")},me=(e,t,r)=>((e,t)=>{let r="";switch(e){case le.Background:case le.BackgroundImage:r=ue(t);break;case le.Content:r=t.replace(/^(["'])([\s\S]*)\1$/,"$2");break;case le.Opacity:r=te?(Math.round(100*parseFloat(t))/100).toString():t;break;default:r=t}return r})(t,getComputedStyle(e,r).getPropertyValue(t)),ge=(e,t)=>{const r=e.indexOf(t);let o,s;return r>-1?(o=e.substring(0,r).trim(),s=e.substring(r+1).trim()):o=e,{name:o,value:s}},we=e=>{const t=e.pseudoName,r=e.pseudoArg,o=e.domElement,s=((e,t)=>{const r=ge(t,n),o=r.name;let s=o,a=r.value;if(Object.values(F).includes(o)||(s=null,a=t),!a)throw new Error("Required style property argument part is missing in :".concat(e,"() arg: '").concat(t,"'"));return{regularPseudoElement:s,styleMatchArg:a}})(t,r),c=s.regularPseudoElement,l=s.styleMatchArg,i=ge(l,a),d=i.name,u=i.value;if(!d||!u)throw new Error("Required property name or value is missing in :".concat(t,"() arg: '").concat(l,"'"));let p;try{p=fe(u)}catch(e){throw J.error(e),new Error("Invalid argument of :".concat(t,"() pseudo-class: '").concat(l,"'"))}const h=me(o,d,c);return p&&p.test(h)},ve=e=>!e.includes(s)&&!!/^[\w-]+$/.test(e),Ee=function(e){let t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e.length>1&&e.startsWith(c)&&e.endsWith(c)&&(e=e.slice(1,-1)),""===e)throw new Error("Argument should be specified. Empty arg is invalid.");if(e.startsWith(s)&&e.endsWith(s)){if(!(e.length>2))throw new Error("Invalid regexp: '".concat(e,"'"));t=X(e)}else if(e.includes(i)){if(e===i&&!r)throw new Error("Argument should be more specific than ".concat(e));t=K(e,i,ie),t=new RegExp(t)}else{if(!ve(e))throw new Error("Invalid argument: '".concat(e,"'"));t=e}return t},be=(e,t)=>{const r=ge(t,"="),o=r.name,s=r.value;if(!o)throw new Error("Required attribute name is missing in :".concat(e," arg: ").concat(t));return{rawName:o,rawValue:s}},ye=e=>{const t=e.pseudoName,r=e.pseudoArg,o=e.domElement.attributes;if(0===o.length)return!1;const s=be(t,r),n=s.rawName,a=s.rawValue;let c;try{c=Ee(n)}catch(e){throw J.error(e),new SyntaxError(e.message)}let l=!1,i=0;for(;i<o.length&&!l;){const e=o[i],t=c instanceof RegExp?c.test(e.name):c===e.name;if(a){let r;try{r=Ee(a)}catch(e){throw J.error(e),new SyntaxError(e.message)}const o=r instanceof RegExp?r.test(e.value):r===e.value;l=t&&o}else l=t;i+=1}return l},Se=function e(t,r){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const s=r[0];if(1===r.length){let e;for(e in t)s instanceof RegExp?s.test(e)&&o.push({base:t,prop:e,value:t[e]}):s===e&&o.push({base:t,prop:s,value:t[e]});return o}if(s instanceof RegExp){const n=r.slice(1),a=[];for(const e in t)s.test(e)&&a.push(e);a.forEach((r=>{var s;const a=null===(s=Object.getOwnPropertyDescriptor(t,r))||void 0===s?void 0:s.value;e(a,n,o)}))}if(t&&"string"==typeof s){var n;const a=null===(n=Object.getOwnPropertyDescriptor(t,s))||void 0===n?void 0:n.value;r=r.slice(1),void 0!==a&&e(a,r,o)}return o},xe=e=>{const t=e.pseudoName,r=e.pseudoArg,o=e.domElement,n=be(t,r),a=n.rawName,l=n.rawValue;if(a.includes("\\/")||a.includes("\\."))throw new Error("Invalid :".concat(t," name pattern: ").concat(a));let i;try{i=(e=>{e.length>1&&e.startsWith(c)&&e.endsWith(c)&&(e=e.slice(1,-1));const t=e.split("."),r=[];let o="",n=!1,a=0;for(;a<t.length;){const e=t[a];e.startsWith(s)&&e.endsWith(s)&&e.length>2?r.push(e):e.startsWith(s)?(n=!0,o+=e):e.endsWith(s)?(n=!1,o+=".".concat(e),r.push(o),o=""):n?o+=e:r.push(e),a+=1}if(o.length>0)throw new Error("Invalid regexp property pattern '".concat(e,"'"));return r.map((t=>{if(0===t.length)throw new Error("Empty pattern '".concat(t,"' is invalid in chain '").concat(e,"'"));let r;try{r=Ee(t,!0)}catch(r){throw J.error(r),new Error("Invalid property pattern '".concat(t,"' in property chain '").concat(e,"'"))}return r}))})(a)}catch(e){throw J.error(e),new SyntaxError(e.message)}const d=Se(o,i);if(0===d.length)return!1;let u=!0;if(l){let e;try{e=Ee(l)}catch(e){throw J.error(e),new SyntaxError(e.message)}if(e)for(let t=0;t<d.length;t+=1){const r=d[t].value;if(e instanceof RegExp)u=e.test(z(r));else{if("null"===r||"undefined"===r){u=e===r;break}u=Y(e)===r}if(u)break}}return u},ke=e=>{const t=e.pseudoName,r=e.pseudoArg,o=(e=>(null==ne?void 0:ne.apply(e))||"")(e.domElement);let n,a=r;if(a.startsWith(s)&&de.test(a)){const e=a.lastIndexOf("/"),s=a.substring(e+1);let c;a=a.substring(0,e+1).slice(1,-1).replace(/\\([\\"])/g,"$1");try{c=new RegExp(a,s)}catch(e){throw new Error("Invalid argument of :".concat(t,"() pseudo-class: ").concat(r))}n=c.test(o)}else a=a.replace(/\\([\\()[\]"])/g,"$1"),n=o.includes(a);return n};function Te(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let Ne;!function(e){e.SelectorList="SelectorList",e.Selector="Selector",e.RegularSelector="RegularSelector",e.ExtendedSelector="ExtendedSelector",e.AbsolutePseudoClass="AbsolutePseudoClass",e.RelativePseudoClass="RelativePseudoClass"}(Ne||(Ne={}));class Pe{constructor(e){Te(this,"children",[]),this.type=e}addChild(e){this.children.push(e)}}class Re extends Pe{constructor(e){super(Ne.RegularSelector),this.value=e}}class Ce extends Pe{constructor(e){super(Ne.RelativePseudoClass),this.name=e}}class Oe extends Pe{constructor(e){super(Ne.AbsolutePseudoClass),Te(this,"value",""),this.name=e}}const Ae=/\[-(?:ext)-([a-z-_]+)=(["'])((?:(?=(\\?))\4.)*?)\2\]/g,Ie=(e,t,r,o)=>{const s=new RegExp("([^\\\\]|^)\\\\".concat(r),"g"),n=o.replace(s,"$1".concat(r));return":".concat(t,"(").concat(n,")")},Le=/\(:scope >/g,Me=/(:matches-css)-(before|after)\(/g,Be=(e,t,o)=>"".concat(t).concat(r.LEFT).concat(o).concat(n),De=e=>(e=>{const t=e.replace(Ae,Ie).replace(Le,"(>").replace(Me,Be);if(t.includes("[-ext-"))throw new Error("Invalid extended-css old syntax selector: '".concat(e,"'"));return t})(e.trim());let Fe;!function(e){e.Mark="mark",e.Word="word"}(Fe||(Fe={}));const We=e=>{const t=[];e.forEach((e=>t.push(e)));const r=[];for(;t.length;){const e=t.pop();if(!e)throw new Error("Unable to make array flat");Array.isArray(e)?e.forEach((e=>t.push(e))):r.push(e)}return r.reverse()},_e=e=>e[e.length-1],$e="html ".concat(i),je=e=>B.includes(e),Ve=(e,r)=>f.includes(r)||e===Fe.Word||r===i||"#"===r||"."===r||r===a||"'"===r||r===c||r===t.LEFT,Ue=e=>0===e.pathToBufferNode.length?null:_e(e.pathToBufferNode),qe=e=>{const t=Ue(e);if(!t)throw new Error("No bufferNode found");if(t.type!==Ne.Selector)throw new Error("Unsupported bufferNode type");const r=t.children.filter((e=>e.type===Ne.RegularSelector));if(0===r.length)throw new Error("No RegularSelector node found");const o=_e(r);return e.pathToBufferNode.push(o),o},Ge=(e,t)=>{const r=Ue(e);if(null===r)throw new Error("No bufferNode to update");const o=r.type;if(o!==Ne.RegularSelector&&o!==Ne.AbsolutePseudoClass)throw new Error("".concat(r.type," node can not be updated. Only RegularSelector and AbsolutePseudoClass are supported."));r.value+=t},He=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=Ue(e);if(null===o)throw new Error("No buffer node");let s;s=t===Ne.RegularSelector?new Re(r):t===Ne.AbsolutePseudoClass?new Oe(r):t===Ne.RelativePseudoClass?new Ce(r):new Pe(t),o.addChild(s),e.pathToBufferNode.push(s)},Ke=(e,t)=>{(e=>{const t=new Pe(Ne.SelectorList);e.ast=t,e.pathToBufferNode.push(t)})(e),He(e,Ne.Selector),He(e,Ne.RegularSelector,t)},Xe=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";He(e,Ne.SelectorList),He(e,Ne.Selector),He(e,Ne.RegularSelector,t)},ze=(e,t)=>{for(let r=e.pathToBufferNode.length-1;r>=0;r-=1)if(e.pathToBufferNode[r].type===t){e.pathToBufferNode=e.pathToBufferNode.slice(0,r+1);break}},Ye=e=>{ze(e,Ne.Selector);const t=Ue(e);if(!t)throw new Error("No SelectorNode, impossible to continue selector parsing");const r=_e(t.children),o=r.type===Ne.ExtendedSelector&&0===e.standardPseudoBracketsStack.length,s=o&&r.children[0].name,n=s&&M.includes(s),a=s&&L.includes(s),c=n&&e.extendedPseudoBracketsStack.length>0&&e.extendedPseudoBracketsStack.length===e.extendedPseudoNamesStack.length,l=a&&s===_e(e.extendedPseudoNamesStack);let i=t;return c||l?(e.pathToBufferNode.push(r),i=r.children[0]):i=o?t:qe(e),e.pathToBufferNode.push(i),i},Je=(e,t,o,s,n)=>{if(je(s.toLowerCase())){if(C.includes(s)&&e.standardPseudoNamesStack.length>0)throw new Error("Usage of :".concat(s,"() pseudo-class is not allowed inside regular pseudo: '").concat(_e(e.standardPseudoNamesStack),"'"));ze(e,Ne.Selector),He(e,Ne.ExtendedSelector)}else{if(s.toLowerCase()===P)throw new Error("Selector parser error: invalid :remove() pseudo-class in selector: '".concat(t,"'"));Ge(e,o),n!==r.LEFT||e.isAttributeBracketsOpen||e.standardPseudoNamesStack.push(s)}},Qe=e=>{var g,w,v,E,b,y,S,x,R,O,M,D,W,_,$,j,V,U,q;const G=(e=>{const t=De(e);let r,o="";const s=[];for(let e=0;e<t.length;e+=1){if(r=t[e],m.includes(r)){s.push({type:Fe.Mark,value:r});continue}o+=r;const n=t[e+1];n&&!m.includes(n)||(s.push({type:Fe.Word,value:o}),o="")}return s})(e),H={ast:null,pathToBufferNode:[],extendedPseudoNamesStack:[],extendedPseudoBracketsStack:[],standardPseudoNamesStack:[],standardPseudoBracketsStack:[],isAttributeBracketsOpen:!1,isRegexpOpen:!1};let K=0;for(;K<G.length;){const m=G[K],X=m.type,z=m.value,Y=G[K+1]||[],J=Y.type,Q=Y.value,Z=G[K+2]||[],ee=Z.value,te=G[K-1]||[],re=te.type,oe=te.value;let se=Ue(H);switch(X){case Fe.Word:if(null===se)Ke(H,z);else if(se.type===Ne.SelectorList)He(H,Ne.Selector),He(H,Ne.RegularSelector,z);else if(se.type===Ne.RegularSelector)Ge(H,z);else if(se.type===Ne.ExtendedSelector){if(l.includes(Q)&&ee===r.LEFT)throw new Error("No white space is allowed before or after extended pseudo-class name in selector: '".concat(e,"'"));H.extendedPseudoNamesStack.push(z.toLowerCase()),L.includes(z.toLowerCase())?He(H,Ne.AbsolutePseudoClass,z.toLowerCase()):He(H,Ne.RelativePseudoClass,z.toLowerCase())}else se.type===Ne.AbsolutePseudoClass?Ge(H,z):se.type===Ne.RelativePseudoClass&&Xe(H,z);break;case Fe.Mark:switch(z){case n:if(!se||void 0!==se&&!Q)throw new Error("'".concat(e,"' is not a valid selector"));se.type===Ne.RegularSelector?H.isAttributeBracketsOpen?Ge(H,z):ze(H,Ne.SelectorList):se.type===Ne.AbsolutePseudoClass?Ge(H,z):(null===(g=se)||void 0===g?void 0:g.type)===Ne.Selector&&ze(H,Ne.SelectorList);break;case" ":if((null===(w=se)||void 0===w?void 0:w.type)===Ne.RegularSelector&&(se=Ye(H)),(null===(v=se)||void 0===v?void 0:v.type)===Ne.RegularSelector){if(!H.isAttributeBracketsOpen&&(oe===a&&J===Fe.Word||re===Fe.Word&&Q===r.LEFT))throw new Error("'".concat(e,"' is not a valid selector."));Q&&!Ve(J,Q)||Ge(H,z)}(null===(E=se)||void 0===E?void 0:E.type)===Ne.AbsolutePseudoClass&&Ge(H,z),(null===(b=se)||void 0===b?void 0:b.type)===Ne.RelativePseudoClass&&Xe(H),(null===(y=se)||void 0===y?void 0:y.type)===Ne.Selector&&Q&&Ve(J,Q)&&He(H,Ne.RegularSelector);break;case d:case u:case p:case h:case";":case s:case"\\":case"'":case c:case"^":case"$":case o.LEFT:case o.RIGHT:case i:case"#":case".":case t.LEFT:f.includes(z)&&(se=Ye(H)),null===se?Ke(H,z!==i||Q!==a||ee!==A&&ee!==I?z:$e):se.type===Ne.RegularSelector?(Ge(H,z),z===t.LEFT&&(H.isAttributeBracketsOpen=!0)):se.type===Ne.AbsolutePseudoClass?(Ge(H,z),z===s&&"\\"!==oe&&(H.isRegexpOpen=H.extendedPseudoNamesStack.length>0&&!H.isRegexpOpen)):se.type===Ne.RelativePseudoClass?(Xe(H,z),z===t.LEFT&&(H.isAttributeBracketsOpen=!0)):se.type===Ne.Selector?f.includes(z)?He(H,Ne.RegularSelector,z):H.isRegexpOpen||(se=qe(H),Ge(H,z)):se.type===Ne.SelectorList&&(He(H,Ne.Selector),He(H,Ne.RegularSelector,z));break;case t.RIGHT:(null===(S=se)||void 0===S?void 0:S.type)===Ne.RegularSelector&&(H.isAttributeBracketsOpen=!1,Ge(H,z)),(null===(x=se)||void 0===x?void 0:x.type)===Ne.AbsolutePseudoClass&&Ge(H,z);break;case a:if(l.includes(Q)&&B.includes(ee))throw new Error("No white space is allowed before or after extended pseudo-class name in selector: '".concat(e,"'"));if(null===se){if(Q===k)Ke(H,"body");else if(Q===A||Q===I)Ke(H,$e);else{if(Q===N||Q===T)throw new Error("Selector should be specified before :".concat(Q,"() pseudo-class"));Ke(H,i)}se=Ue(H)}if(!se)throw new Error("bufferNode has to be specified by now");if(se.type===Ne.SelectorList&&(He(H,Ne.Selector),He(H,Ne.RegularSelector),se=Ue(H)),(null===(R=se)||void 0===R?void 0:R.type)===Ne.RegularSelector&&((f.includes(oe)||oe===n)&&Ge(H,i),Je(H,e,z,Q,ee)),(null===(O=se)||void 0===O?void 0:O.type)===Ne.Selector)if(je(Q.toLowerCase()))He(H,Ne.ExtendedSelector);else{if(Q.toLowerCase()===P)throw new Error("Selector parser error: invalid :remove() pseudo-class in selector: '".concat(e,"'"));se=qe(H),Je(H,e,z,J,ee)}if((null===(M=se)||void 0===M?void 0:M.type)===Ne.AbsolutePseudoClass){if(se.name===k&&B.includes(Y.value)&&Z.value===r.LEFT)throw new Error(":xpath() pseudo-class should be at the end of selector: '".concat(e,"'"));Ge(H,z)}(null===(D=se)||void 0===D?void 0:D.type)===Ne.RelativePseudoClass&&(Xe(H,i),je(Q.toLowerCase())?(ze(H,Ne.Selector),He(H,Ne.ExtendedSelector)):(Ge(H,z),ee===r.LEFT&&H.standardPseudoNamesStack.push(Q)));break;case r.LEFT:(null===(W=se)||void 0===W?void 0:W.type)===Ne.AbsolutePseudoClass&&(se.name!==k&&H.isRegexpOpen?Ge(H,z):(H.extendedPseudoBracketsStack.push(z),H.extendedPseudoBracketsStack.length>H.extendedPseudoNamesStack.length&&Ge(H,z))),(null===(_=se)||void 0===_?void 0:_.type)===Ne.RegularSelector&&(H.standardPseudoNamesStack.length>0&&(Ge(H,z),H.standardPseudoBracketsStack.push(z)),H.isAttributeBracketsOpen&&Ge(H,z)),(null===($=se)||void 0===$?void 0:$.type)===Ne.RelativePseudoClass&&H.extendedPseudoBracketsStack.push(z);break;case r.RIGHT:if((null===(j=se)||void 0===j?void 0:j.type)===Ne.AbsolutePseudoClass&&(se.name!==k&&H.isRegexpOpen?Ge(H,z):(H.extendedPseudoBracketsStack.pop(),se.name!==k?(H.extendedPseudoNamesStack.pop(),H.extendedPseudoBracketsStack.length>H.extendedPseudoNamesStack.length?Ge(H,z):H.extendedPseudoBracketsStack.length>=0&&H.extendedPseudoNamesStack.length>=0&&ze(H,Ne.Selector)):H.extendedPseudoBracketsStack.length<H.extendedPseudoNamesStack.length?H.extendedPseudoNamesStack.pop():Ge(H,z))),(null===(V=se)||void 0===V?void 0:V.type)===Ne.RegularSelector)if(H.isAttributeBracketsOpen)Ge(H,z);else if(H.standardPseudoNamesStack.length>0&&H.standardPseudoBracketsStack.length>0){Ge(H,z),H.standardPseudoBracketsStack.pop();const t=H.standardPseudoNamesStack.pop();if(!t)throw new Error("Parsing error. Invalid selector: ".concat(e));if(Object.values(F).includes(t)&&Q===a&&ee&&C.includes(ee))throw new Error("Usage of :".concat(ee,"() pseudo-class is not allowed after any regular pseudo-element: '").concat(t,"'"))}else H.extendedPseudoBracketsStack.pop(),H.extendedPseudoNamesStack.pop(),ze(H,Ne.ExtendedSelector),ze(H,Ne.Selector);(null===(U=se)||void 0===U?void 0:U.type)===Ne.Selector&&(H.extendedPseudoBracketsStack.pop(),H.extendedPseudoNamesStack.pop(),ze(H,Ne.ExtendedSelector),ze(H,Ne.Selector)),(null===(q=se)||void 0===q?void 0:q.type)===Ne.RelativePseudoClass&&H.extendedPseudoNamesStack.length>0&&H.extendedPseudoBracketsStack.length>0&&(H.extendedPseudoBracketsStack.pop(),H.extendedPseudoNamesStack.pop());break;case"\t":case"\n":case"\f":case"\r":throw new Error("'".concat(e,"' is not a valid selector."))}break;default:throw new Error("Unknown type of token: '".concat(z,"'."))}K+=1}if(null===H.ast)throw new Error("'".concat(e,"' is not a valid selector"));if(H.extendedPseudoNamesStack.length>0||H.extendedPseudoBracketsStack.length>0)throw new Error("Unbalanced brackets for extended pseudo-class: '".concat(_e(H.extendedPseudoNamesStack),"'"));if(H.isAttributeBracketsOpen)throw new Error("Unbalanced brackets for attributes is selector: '".concat(e,"'"));return H.ast};function Ze(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function et(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,s,n=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(o=r.next()).done)&&(n.push(o.value),!t||n.length!==t);a=!0);}catch(e){c=!0,s=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw s}}return n}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ze(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ze(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const tt=(e,t,r)=>{let o,s,n;switch(t){case g:case w:case v:n=ke,o={pseudoName:t,pseudoArg:r,domElement:e},s="Error while matching element text content by arg '".concat(r,"'.");break;case E:case y:case b:n=we,o={pseudoName:t,pseudoArg:r,domElement:e},s="Error while matching element style by arg '".concat(r,"'.");break;case S:n=ye,o={domElement:e,pseudoName:t,pseudoArg:r},s="Error while matching element attributes by arg '".concat(r,"'.");break;case x:n=xe,o={domElement:e,pseudoName:t,pseudoArg:r},s="Error while matching element properties by arg '".concat(r,"'.");break;default:throw new Error("Unknown absolute pseudo-class :".concat(t,"()"))}return((e,t,r)=>{let o;try{o=e(t)}catch(e){throw J.error(e),new Error(r)}return o})(n,o,s)},rt=(e,t,r)=>{const o=((e,t)=>{const r=Number(e);if(Number.isNaN(r)||r<1||r>=256)throw new Error("Invalid argument of :".concat(t," pseudo-class: '").concat(e,"'"));return r})(t,r),s=e.map((e=>{let t=null;try{t=((e,t,r)=>{let o=null,s=0;for(;s<t;){if(o=e.parentElement,!o)throw new Error("Argument of :".concat(r,"() pseudo-class is too big — '").concat(t,"', out of DOM elements root."));e=o,s+=1}return o})(e,o,r)}catch(e){J.error(e)}return t})).filter(ce);return s},ot=(e,t)=>{const r=e.map((e=>{const r=[];let o;try{o=document.evaluate(t,e,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE,null)}catch(e){throw J.error(e),new Error("Invalid argument of :xpath pseudo-class: '".concat(t,"'"))}let s=o.iterateNext();for(;s;)ce(s)&&r.push(s),s=o.iterateNext();return r}));return We(r)},st=(e,t)=>{if(!(e=>{let t;try{document.querySelectorAll(e),t=!0}catch(e){t=!1}return t})(t))throw new Error("Invalid argument of :upward pseudo-class: '".concat(t,"'"));return e.map((e=>{const r=e.parentElement;return r?r.closest(t):null})).filter(ce)},nt=e=>{const t=e.element,r=e.relativeSelectorList,o=e.pseudoName;return r.children.every((e=>{var r,s;const n=et(e.children,1)[0];if(!n)throw new Error("RegularSelector is missing for :".concat(o," pseudo-class."));let c,l="",i=null;if(null!==(r=n.value)&&void 0!==r&&r.startsWith(p)||null!==(s=n.value)&&void 0!==s&&s.startsWith(h)){i=t.parentElement;const e=t.tagName.toLowerCase();l="".concat(a).concat(D).concat(u).concat(e)}else l="".concat(a).concat(D).concat(d),i=t;if(!i)throw new Error("Selection by :".concat(o," pseudo-class is not possible."));try{c=dt(e,i,l)}catch(e){throw J.error(e),new Error("Invalid selector for :".concat(o," pseudo-class: '").concat(n.value,"'"))}return c.length>0}))},at=e=>{const t=e.element,r=e.relativeSelectorList,o=e.pseudoName,s=e.errorOnInvalidSelector;return r.children.some((e=>{const r=et(e.children,1)[0];if(!r)throw new Error("RegularSelector is missing for :".concat(o," pseudo-class."));const n=t.parentElement;if(!n)throw new Error("Selection by :".concat(o," pseudo-class is not possible."));const c=ae(t),l="".concat(a).concat(D).concat(u).concat(c);let i;try{i=dt(e,n,l)}catch(e){if(s)throw J.error(e),new Error("Invalid selector for :".concat(o," pseudo-class: '").concat(r.value,"'"));return!1}return i.length>0}))},ct=(e,t,r)=>{if(!e.value)throw new Error("RegularSelector value should be specified");const o=r?"".concat(r).concat(e.value):e.value;let s=[];try{s=Array.from(t.querySelectorAll(o))}catch(e){throw new Error("Error: unable to select by '".concat(o,"' — ").concat(e.message))}return s},lt=(e,t)=>{let r=[];const o=t.children[0].name;if(!o)throw new Error("Extended pseudo-class should have a name");if(L.includes(o)){const s=t.children[0].value;if(!s)throw new Error("Missing arg for :".concat(o," pseudo-class"));if(o===T)r=rt(e,s,o);else if(o===k){try{document.createExpression(s,null)}catch(e){throw new Error("Invalid argument of :".concat(o," pseudo-class: '").concat(s,"'"))}r=ot(e,s)}else r=o===N?Number.isNaN(Number(s))?st(e,s):rt(e,s,o):e.filter((e=>tt(e,o,s)))}else{if(!M.includes(o))throw new Error("Unknown extended pseudo-class: ':".concat(o,"'"));{const s=t.children[0].children;if(0===s.length)throw new Error("Missing arg for :".concat(o," pseudo-class"));const n=et(s,1)[0];let a,c=!1;switch(o){case"has":case"if":case R:a=e=>nt({element:e,relativeSelectorList:n,pseudoName:o});break;case O:a=e=>!nt({element:e,relativeSelectorList:n,pseudoName:o});break;case A:a=e=>at({element:e,relativeSelectorList:n,pseudoName:o});break;case I:c=!0,a=e=>!at({element:e,relativeSelectorList:n,pseudoName:o,errorOnInvalidSelector:c});break;default:throw new Error("Unknown relative pseudo-class :".concat(o,"()"))}r=e.filter(a)}}return r},it=(e,t)=>{let r=[];const o=t.value;if(!o)throw new Error("RegularSelector should have a value.");return r=o.startsWith(u)?e.map((e=>{const r="".concat(a).concat(D);return ct(t,e,r)})):o.startsWith(p)||o.startsWith(h)?e.map((e=>{const r=e.parentElement;if(!r)return[];const o=ae(e),s="".concat(a).concat(D).concat(u).concat(o);return ct(t,r,s)})):e.map((e=>{const r="".concat(a).concat(D).concat(d);return ct(t,e,r)})),We(r)},dt=(e,t,r)=>{let o=[],s=0;for(;s<e.children.length;){const n=e.children[s];0===s?o=ct(n,t,r):n.type===Ne.ExtendedSelector?o=lt(o,n):n.type===Ne.RegularSelector&&(o=it(o,n)),s+=1}return o},ut=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;const r=[];e.children.forEach((e=>{r.push(...dt(e,t))}));const o=[...new Set(We(r))];return o};const pt=new class{constructor(){this.astCache=new Map}saveAstToCache(e,t){this.astCache.set(e,t)}getAstFromCache(e){return this.astCache.get(e)||null}getSelectorAst(e){let t=this.getAstFromCache(e);return t||(t=Qe(e)),this.saveAstToCache(e,t),t}querySelectorAll(e){const t=this.getSelectorAst(e);return ut(t)}},ht="debug",ft=/[;}]/g,mt=/[;:}]/g,gt=/\S/g,wt={selector:""},vt=e=>{e.rawRuleData=wt},Et=(e,t)=>{let o,s=e.selectorBuffer.trim();if(s.startsWith("@"))throw new Error("At-rules are not supported: '".concat(s,"'."));try{o=(e=>{const t="".concat(a).concat(P).concat(r.LEFT).concat(r.RIGHT),o="".concat(a).concat(P).concat(r.LEFT);let s,n=!1;const c=e.indexOf(t);if(0===c)throw new Error("Selector should be specified before :remove() pseudo-class: '".concat(e,"'"));if(c>0){if(c!==e.lastIndexOf(t))throw new Error("Pseudo-class :remove() appears more than once in selector: '".concat(e,"'"));if(c+t.length<e.length)throw new Error("Pseudo-class :remove() should be at the end of selector: '".concat(e,"'"));s=e.substring(0,c),n=!0}else{if(e.includes(o))throw new Error("".concat(G,": '").concat(e,"'"));s=e}return{selector:s,stylesOfSelector:n?[{property:P,value:String(n)}]:[]}})(s)}catch(e){throw J.error(e.message),new Error("".concat(G,": '").concat(s,"'"))}if(-1===e.nextIndex){if(s===o.selector)throw new Error("".concat(H,": '").concat(e.cssToParse,"'"));e.cssToParse=""}let n,c=[],l=!1;try{s=o.selector,c=o.stylesOfSelector,n=t.getSelectorAst(s),l=!0}catch(e){l=!1}return e.nextIndex>0&&(e.cssToParse=e.cssToParse.slice(e.nextIndex)),{success:l,selector:s,ast:n,stylesOfSelector:c}},bt=(e,t)=>{mt.lastIndex=e.nextIndex;let r=mt.exec(e.cssToParse);if(null===r)throw new Error("".concat(j,": '").concat(e.cssToParse,"'"));let s=r.index,n=r[0];if(n===o.RIGHT){if(0!==e.cssToParse.slice(e.nextIndex,s).trim().length)throw new Error("".concat(j,": '").concat(e.cssToParse,"'"));if(0===t.length)throw new Error("".concat($,": '").concat(e.cssToParse,"'"));return s}if(n===a){const a=s;if(ft.lastIndex=a,r=ft.exec(e.cssToParse),null===r)throw new Error("".concat(V,": '").concat(e.cssToParse,"'"));s=r.index,n=r[0];const c=e.cssToParse.slice(e.nextIndex,a).trim();if(0===c.length)throw new Error("".concat(U,": '").concat(e.cssToParse,"'"));const l=e.cssToParse.slice(a+1,s).trim();if(0===l.length)throw new Error("".concat(q,": '").concat(e.cssToParse,"'"));if(t.push({property:c,value:l}),n===o.RIGHT)return s}return e.cssToParse=e.cssToParse.slice(s+1),e.nextIndex=0,bt(e,t)},yt=e=>{const t=[],r=bt(e,t);gt.lastIndex=r+1;const o=gt.exec(e.cssToParse);if(null===o)return e.cssToParse="",t;const s=o.index;return e.cssToParse=e.cssToParse.slice(s),t},St=(e,t,r)=>{const o={selector:e,ast:t},s=(e=>{const t=e.find((e=>e.property===ht));return null==t?void 0:t.value})(r),n=(e=>e.some((e=>e.property===P&&e.value===W)))(r);let a=r;if(s&&(a=r.filter((e=>e.property!==ht)),s!==W&&s!==_||(o.debug=s)),n)o.style={[P]:W};else if(a.length>0){const e=a.map((e=>[e.property,e.value])),t=e.reduce(((e,t)=>{const r=t[0],o=t[1];return e[r]=o,e}),{});o.style=t}return o},xt=(e,t)=>{const r=t.selector,o=t.ast,s=t.styles;if(!s)throw new Error("No style declaration for selector: '".concat(r,"'"));if(!o)throw new Error("No ast parsed for selector: '".concat(r,"'"));const n=e.get(r);n?n.styles.push(...s):e.set(r,{ast:o,styles:s})},kt=(e,t)=>{const r=e.trim();if(r.includes("".concat(s).concat(i))&&r.includes("".concat(i).concat(s)))throw new Error("Comments in stylesheet are not supported: '".concat(r,"'"));const n={isSelector:!0,nextIndex:0,cssToParse:r,selectorBuffer:"",rawRuleData:wt},a=new Map;let c;for(;n.cssToParse;)if(n.isSelector){if(n.nextIndex=n.cssToParse.indexOf(o.LEFT),0===n.selectorBuffer.length&&0===n.nextIndex)throw new Error("Selector should be defined before style declaration in stylesheet: '".concat(n.cssToParse,"'"));-1===n.nextIndex?n.selectorBuffer=n.cssToParse:n.selectorBuffer+=n.cssToParse.slice(0,n.nextIndex),c=Et(n,t),c.success?(n.rawRuleData.selector=c.selector.trim(),n.rawRuleData.ast=c.ast,n.rawRuleData.styles=c.stylesOfSelector,n.isSelector=!1,-1===n.nextIndex?(xt(a,n.rawRuleData),vt(n)):(n.nextIndex=1,n.selectorBuffer="")):(n.selectorBuffer+=o.LEFT,n.cssToParse=n.cssToParse.slice(1))}else{var l;const e=yt(n);null===(l=n.rawRuleData.styles)||void 0===l||l.push(...e),xt(a,n.rawRuleData),n.nextIndex=0,vt(n),n.isSelector=!0}const d=[];return a.forEach(((e,t)=>{const r=t,o=e.ast,s=e.styles;d.push(St(r,o,s))})),d},Tt=e=>"number"==typeof e&&!Number.isNaN(e),Nt=void 0!==window.requestAnimationFrame,Pt=Nt?requestAnimationFrame:window.setTimeout,Rt=Nt?cancelAnimationFrame:clearTimeout,Ct=Nt?performance:Date;class Ot{constructor(e,t,r){this.context=e,this.callback=t,this.throttleDelayMs=r||150,this.wrappedCb=this.wrappedCallback.bind(this)}wrappedCallback(e){this.lastRunTime=Tt(e)?e:Ct.now(),this.timeoutId&&(Rt(this.timeoutId),delete this.timeoutId),clearTimeout(this.timerId),delete this.timerId,this.callback&&this.callback(this.context)}hasPendingCallback(){return Tt(this.timeoutId)||Tt(this.timerId)}run(){if(!this.hasPendingCallback()){if(void 0!==this.lastRunTime){const e=Ct.now()-this.lastRunTime;if(e<this.throttleDelayMs)return void(this.timerId=window.setTimeout(this.wrappedCb,this.throttleDelayMs-e))}this.timeoutId=Pt(this.wrappedCb)}}static now(){return Ct.now()}}const At=["mouseover","mouseleave","mouseenter","mouseout"],It=["keydown","keypress","keyup","auxclick","click","contextmenu","dblclick","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseout","mouseup","pointerlockchange","pointerlockerror","select","wheel"],Lt=["wheel"];class Mt{constructor(){Te(this,"getLastEventType",(()=>this.lastEventType)),Te(this,"getTimeSinceLastEvent",(()=>this.lastEventTime?Date.now()-this.lastEventTime:null)),this.trackedEvents=te?It.filter((e=>!Lt.includes(e))):It,this.trackedEvents.forEach((e=>{document.documentElement.addEventListener(e,this.trackEvent,!0)}))}trackEvent(e){this.lastEventType=e.type,this.lastEventTime=Date.now()}isIgnoredEventType(){const e=this.getLastEventType(),t=this.getTimeSinceLastEvent();return!!e&&At.includes(e)&&!!t&&t<10}stopTracking(){this.trackedEvents.forEach((e=>{document.documentElement.removeEventListener(e,this.trackEvent,!0)}))}}const Bt=void 0!==window.addEventListener,Dt=(e,t)=>{e.isDomObserved||(e.isDomObserved=!0,((e,t)=>{se.MutationObserver?(e.domMutationObserver=new se.MutationObserver((r=>{if(!r||0===r.length)return;const o=new Mt;o.isIgnoredEventType()&&(e=>e.every((e=>"attributes"===e.type)))(r)||(e.eventTracker=o,t())})),e.domMutationObserver.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["id","class"]})):Bt&&(document.addEventListener("DOMNodeInserted",t,!1),document.addEventListener("DOMNodeRemoved",t,!1),document.addEventListener("DOMAttrModified",t,!1))})(e,t))},Ft=(e,t)=>{e.isDomObserved&&(e.isDomObserved=!1,((e,t)=>{var r;e.domMutationObserver?e.domMutationObserver.disconnect():Bt&&(document.removeEventListener("DOMNodeInserted",t,!1),document.removeEventListener("DOMNodeRemoved",t,!1),document.removeEventListener("DOMAttrModified",t,!1)),null===(r=e.eventTracker)||void 0===r||r.stopTracking()})(e,t))},Wt=(e,t)=>{const r=t.node;t.removed=!0;const o=(e=>{if(!(e instanceof Element))throw new Error("Function received argument with wrong type");let t;t=e;const r=[];for(;t&&t.nodeType===Node.ELEMENT_NODE;){let e=t.nodeName.toLowerCase();if(t.id&&"string"==typeof t.id){e+="#".concat(t.id),r.unshift(e);break}let o=t,s=1;for(;o.previousElementSibling;)o=o.previousElementSibling,o.nodeType===Node.ELEMENT_NODE&&o.nodeName.toLowerCase()===e&&(s+=1);1!==s&&(e+=":nth-of-type(".concat(s,")")),r.unshift(e),t=t.parentElement}return r.join(" > ")})(r),s=e.removalsStatistic[o]||0;s>50?J.error("ExtendedCss: infinite loop protection for selector: '".concat(o,"'")):r.parentElement&&(r.parentElement.removeChild(r),e.removalsStatistic[o]=s+1)},_t=(e,t)=>{e instanceof HTMLElement&&Object.keys(t).forEach((r=>{if(void 0!==e.style.getPropertyValue(r)){let o=t[r];o=((e,t)=>{const r=e.indexOf(t,e.length-t.length);return r>=0?e.substring(0,r):e})(o.trim(),"!important").trim(),e.style.setProperty(r,o,"important")}}))},$t=(e,t)=>{if(t.protectionObserver)return;if(e.beforeStyleApplied&&!(t=e.beforeStyleApplied(t)))return;const r=t,o=r.node,s=r.rules;for(let r=0;r<s.length;r+=1){const n=s[r],a=n.selector,c=n.style,l=n.debug;if(c){if(c.remove===W)return void Wt(e,t);_t(o,c)}else if(!l)throw new Error("No style declaration in rule for selector: '".concat(a,"'"))}},jt=e=>{e.protectionObserver&&e.protectionObserver.disconnect(),e.node.style.cssText=e.originalStyle};class Vt{constructor(e){this.styleProtectionCount=0,this.observer=new se.MutationObserver((t=>{t.length&&(this.styleProtectionCount+=1,e(t,this))}))}observe(e,t){this.styleProtectionCount<50?this.observer.observe(e,t):J.error("ExtendedCss: infinite loop protection for style")}disconnect(){this.observer.disconnect()}}const Ut={attributes:!0,attributeOldValue:!0,attributeFilter:["style"]},qt=(e,t)=>{if(!se.MutationObserver)return null;const r=[];t.forEach((e=>{const t=e.style;t&&r.push(t)}));const o=new Vt((e=>(t,r)=>{const o=t[0].target;r.disconnect(),e.forEach((e=>{_t(o,e)})),r.observe(o,Ut)})(r));return o.observe(e,Ut),o};class Gt{constructor(){this.appliesTimings=[],this.appliesCount=0,this.timingsSum=0,this.meanTiming=0,this.squaredSum=0,this.standardDeviation=0}push(e){this.appliesTimings.push(e),this.appliesCount+=1,this.timingsSum+=e,this.meanTiming=this.timingsSum/this.appliesCount,this.squaredSum+=e*e,this.standardDeviation=Math.sqrt(this.squaredSum/this.appliesCount-Math.pow(this.meanTiming,2))}}const Ht=e=>Number(e.toFixed(4)),Kt=e=>{const t=[];Ft(e,e.mainCallback),e.parsedRules.forEach((r=>{const o=((e,t)=>{const r=!!t.debug||e.debug;let o;r&&(o=Ot.now());const s=t.ast,n=ut(s);if(n.forEach((r=>{let o=(s=e.affectedElements,n=r,s.find((e=>e.node===n)));var s,n;if(o)o.rules.push(t),$t(e,o);else{const s=r.style.cssText;o={node:r,rules:[t],originalStyle:s,protectionObserver:null},$t(e,o),e.affectedElements.push(o)}})),r&&o){const e=Ot.now()-o;t.timingStats||(t.timingStats=new Gt),t.timingStats.push(e)}return n})(e,r);Array.prototype.push.apply(t,o),r.debug&&(r.matchedElements=o)}));let r=e.affectedElements.length;for(;r;){const o=e.affectedElements[r-1];t.includes(o.node)?o.removed||o.protectionObserver||(o.protectionObserver=qt(o.node,o.rules)):(jt(o),e.affectedElements.splice(r-1,1)),r-=1}Dt(e,e.mainCallback),(e=>{if(e.areTimingsPrinted)return;e.areTimingsPrinted=!0;const t={};e.parsedRules.forEach((e=>{if(e.timingStats){const o=e.selector,s=e.style,n=e.debug,a=e.matchedElements;if(!s&&!n)throw new Error("Rule should have style declaration for selector: '".concat(o,"'"));const c={selectorParsed:o,timings:(r=e.timingStats,{appliesTimings:r.appliesTimings.map((e=>Ht(e))),appliesCount:Ht(r.appliesCount),timingsSum:Ht(r.timingsSum),meanTiming:Ht(r.meanTiming),standardDeviation:Ht(r.standardDeviation)})};s&&s.remove===W?c.removed=!0:(c.styleApplied=s||null,c.matchedElements=a),t[o]=c}var r})),0!==Object.keys(t).length&&J.info("[ExtendedCss] Timings in milliseconds for %o:\n%o",window.location.href,t)})(e)};class Xt{constructor(e){if(!(()=>{const e=navigator.userAgent;if(e.includes("MSIE")||e.includes("Trident/"))return!1;if(e.includes("jsdom"))return!0;const t=oe();if(!t)return!1;const r=t.browserName;return t.currentVersion>=re[r].MIN_VERSION})())throw new Error("Browser is not supported by ExtendedCss.");if(!e)throw new Error("ExtendedCss configuration should be provided.");if(this.context={beforeStyleApplied:e.beforeStyleApplied,debug:!1,affectedElements:[],isDomObserved:!1,removalsStatistic:{},parsedRules:kt(e.styleSheet,pt),mainCallback:()=>{}},this.context.debug=e.debug||this.context.parsedRules.some((e=>e.debug===_)),this.applyRulesScheduler=new Ot(this.context,Kt,150),this.context.mainCallback=this.applyRulesScheduler.run.bind(this.applyRulesScheduler),this.context.beforeStyleApplied&&"function"!=typeof this.context.beforeStyleApplied)throw new Error("Invalid configuration. Type of 'beforeStyleApplied' should be a function, received: '".concat(typeof this.context.beforeStyleApplied,"'"));this.applyRulesCallbackListener=()=>{Kt(this.context)}}apply(){Kt(this.context),"complete"!==document.readyState&&document.addEventListener("DOMContentLoaded",this.applyRulesCallbackListener,!1)}dispose(){Ft(this.context,this.context.mainCallback),this.context.affectedElements.forEach((e=>{jt(e)})),document.removeEventListener("DOMContentLoaded",this.applyRulesCallbackListener,!1)}getAffectedElements(){return this.context.affectedElements}static query(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("string"!=typeof e)throw new Error("Selector should be defined as a string.");const r=Ot.now();try{return pt.querySelectorAll(e)}finally{const e=Ot.now();t||J.info("[ExtendedCss] Elapsed: ".concat(Math.round(1e3*(e-r))," μs."))}}static validate(e){try{return Xt.query(e),{ok:!0,error:null}}catch(t){return{ok:!1,error:'Error: selector "'.concat(e,'" is invalid — ').concat(t.message,")")}}}}return e.ExtendedCss=Xt,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
var ExtendedCss=function(e){"use strict";const t={LEFT:"[",RIGHT:"]"},r={LEFT:"(",RIGHT:")"},o={LEFT:"{",RIGHT:"}"},s="/",n=",",a=":",c='"',l=[" ","\t","\r","\n","\f"],i="*",u=" ",d=">",p="+",h="~",f=[u,d,p,h],m=["[","]","(",")","{","}",s,"\\",";",a,n,"'",c,"^","$",i,"#",".",u,d,p,h,"\t","\r","\n","\f"],w="contains",g="has-text",v="-abp-contains",E="matches-css",b="matches-css-before",y="matches-css-after",S="matches-attr",x="matches-property",k="xpath",T="nth-ancestor",N="upward",P="remove",R="-abp-has",C=["has","if",R],O="if-not",A="is",I="not",L=[w,g,v,E,b,y,S,x,k,T,N],M=[...C,O,A,I],B=[...L,...M],D=":scope",F={AFTER:"after",BACKDROP:"backdrop",BEFORE:"before",CUE:"cue",CUE_REGION:"cue-region",FIRST_LETTER:"first-letter",FIRST_LINE:"first-line",FILE_SELECTION_BUTTON:"file-selector-button",GRAMMAR_ERROR:"grammar-error",MARKER:"marker",PART:"part",PLACEHOLDER:"placeholder",SELECTION:"selection",SLOTTED:"slotted",SPELLING_ERROR:"spelling-error",TARGET_TEXT:"target-text"},W="true",_="global",$="No style declaration at stylesheet part",j="Invalid style declaration at stylesheet part",V="Unclosed style declaration at stylesheet part",U="Missing style property in declaration at stylesheet part",q="Missing style value in declaration at stylesheet part",G="Invalid :remove() pseudo-class in selector",H="Invalid stylesheet - no style declared or :remove() pseudo-class used",K=(e,t,r)=>e?e.split(t).join(r):e,X=e=>{if(e.startsWith(s)&&e.endsWith(s))return new RegExp(e.slice(1,-1));const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(t)},z=e=>{let t;switch(e){case void 0:t="undefined";break;case null:t="null";break;default:t=e.toString()}return t},Y=e=>{const t=Number(e);let r;if(Number.isNaN(t))switch(e){case"undefined":r=void 0;break;case"null":r=null;break;case"true":r=!0;break;case"false":r=!1;break;default:r=e}else r=t;return r},J={error:"undefined"!=typeof console&&console.error&&console.error.bind?console.error.bind(window.console):console.error,info:"undefined"!=typeof console&&console.info&&console.info.bind?console.info.bind(window.console):console.info};var Q;!function(e){e.Chrome="Chrome",e.Firefox="Firefox",e.Edge="Edg",e.Opera="Opera",e.Safari="Safari"}(Q||(Q={}));const Z="Chromium",ee="Google Chrome",te="Apple Computer, Inc."===navigator.vendor,re={[Q.Chrome]:{MASK:/\s(Chrome)\/(\d+)\..+\s(?!.*Edg\/)/,MIN_VERSION:55},[Q.Firefox]:{MASK:/\s(Firefox)\/(\d+)\./,MIN_VERSION:52},[Q.Edge]:{MASK:/\s(Edg)\/(\d+)\./,MIN_VERSION:80},[Q.Opera]:{MASK:/\s(OPR)\/(\d+)\./,MIN_VERSION:80},[Q.Safari]:{MASK:/\sVersion\/(\d{2}\.\d)(.+\s|\s)(Safari)\//,MIN_VERSION:11.1}},oe=()=>{const e=(()=>{var e;const t=null===(e=navigator.userAgentData)||void 0===e?void 0:e.brands;return t&&t.find((e=>e.brand===Z||e.brand===ee))||null})();if(!e){const e=(()=>{let e,t;const r=Object.values(Q);for(let o=0;o<r.length;o+=1){const s=re[r[o]].MASK.exec(navigator.userAgent);if(s)return s[3]===r[o]?(e=s[3],t=Number(s[1])):(e=s[1],t=Number(s[2])),{browserName:e,currentVersion:t}}return null})();if(!e)return null;return{browserName:e.browserName,currentVersion:e.currentVersion}}const t=e.brand,r=e.version;return{browserName:t===Z||t===ee?Q.Chrome:t,currentVersion:Number(r)}},se={MutationObserver:window.MutationObserver||window.WebKitMutationObserver},ne=(()=>{var e;const t=window.Node||Node;return null===(e=Object.getOwnPropertyDescriptor(t.prototype,"textContent"))||void 0===e?void 0:e.get})(),ae=e=>{let t=e.tagName.toLowerCase();return t+=Array.from(e.attributes).map((t=>"[".concat(t.name,'="').concat(e.getAttribute(t.name),'"]'))).join(""),t},ce=e=>e instanceof HTMLElement;var le;!function(e){e.Background="background",e.BackgroundImage="background-image",e.Content="content",e.Opacity="opacity"}(le||(le={}));const ie=".*",ue=/^\s*\/.*\/[gmisuy]*\s*$/,de=e=>{if(!e.includes('url("')){const t=/url\((.*?)\)/g;return e.replace(t,'url("$1")')}return e},pe=e=>e.replace(/(\^)?url(\\)?\\\((\w|\[\w)/g,'$1url$2\\(\\"?$3'),he=de,fe=e=>{let t;return e.startsWith(s)&&e.endsWith(s)?(t=pe(e),t=t.slice(1,-1)):(t=he(e),t=t.replace(/\\([\\()[\]"])/g,"$1"),t=(e=>{const t=new RegExp("[".concat([".","+","?","$","{","}","(",")","[","]","\\","/"].join("\\"),"]"),"g");return e.replace(t,"\\$&")})(t),t=K(t,i,ie)),new RegExp(t,"i")},me=(e,t,r)=>((e,t)=>{let r="";switch(e){case le.Background:case le.BackgroundImage:r=de(t);break;case le.Content:r=t.replace(/^(["'])([\s\S]*)\1$/,"$2");break;case le.Opacity:r=te?(Math.round(100*parseFloat(t))/100).toString():t;break;default:r=t}return r})(t,getComputedStyle(e,r).getPropertyValue(t)),we=(e,t)=>{const r=e.indexOf(t);let o,s;return r>-1?(o=e.substring(0,r).trim(),s=e.substring(r+1).trim()):o=e,{name:o,value:s}},ge=e=>{const t=e.pseudoName,r=e.pseudoArg,o=e.domElement,s=((e,t)=>{const r=we(t,n),o=r.name;let s=o,a=r.value;if(Object.values(F).includes(o)||(s=null,a=t),!a)throw new Error("Required style property argument part is missing in :".concat(e,"() arg: '").concat(t,"'"));return{regularPseudoElement:s,styleMatchArg:a}})(t,r),c=s.regularPseudoElement,l=s.styleMatchArg,i=we(l,a),u=i.name,d=i.value;if(!u||!d)throw new Error("Required property name or value is missing in :".concat(t,"() arg: '").concat(l,"'"));let p;try{p=fe(d)}catch(e){throw J.error(e),new Error("Invalid argument of :".concat(t,"() pseudo-class: '").concat(l,"'"))}const h=me(o,u,c);return p&&p.test(h)},ve=e=>!e.includes(s)&&!!/^[\w-]+$/.test(e),Ee=function(e){let t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e.length>1&&e.startsWith(c)&&e.endsWith(c)&&(e=e.slice(1,-1)),""===e)throw new Error("Argument should be specified. Empty arg is invalid.");if(e.startsWith(s)&&e.endsWith(s)){if(!(e.length>2))throw new Error("Invalid regexp: '".concat(e,"'"));t=X(e)}else if(e.includes(i)){if(e===i&&!r)throw new Error("Argument should be more specific than ".concat(e));t=K(e,i,ie),t=new RegExp(t)}else{if(!ve(e))throw new Error("Invalid argument: '".concat(e,"'"));t=e}return t},be=(e,t)=>{const r=we(t,"="),o=r.name,s=r.value;if(!o)throw new Error("Required attribute name is missing in :".concat(e," arg: ").concat(t));return{rawName:o,rawValue:s}},ye=e=>{const t=e.pseudoName,r=e.pseudoArg,o=e.domElement.attributes;if(0===o.length)return!1;const s=be(t,r),n=s.rawName,a=s.rawValue;let c;try{c=Ee(n)}catch(e){throw J.error(e),new SyntaxError(e.message)}let l=!1,i=0;for(;i<o.length&&!l;){const e=o[i],t=c instanceof RegExp?c.test(e.name):c===e.name;if(a){let r;try{r=Ee(a)}catch(e){throw J.error(e),new SyntaxError(e.message)}const o=r instanceof RegExp?r.test(e.value):r===e.value;l=t&&o}else l=t;i+=1}return l},Se=function e(t,r){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const s=r[0];if(1===r.length){let e;for(e in t)s instanceof RegExp?s.test(e)&&o.push({base:t,prop:e,value:t[e]}):s===e&&o.push({base:t,prop:s,value:t[e]});return o}if(s instanceof RegExp){const n=r.slice(1),a=[];for(const e in t)s.test(e)&&a.push(e);a.forEach((r=>{var s;const a=null===(s=Object.getOwnPropertyDescriptor(t,r))||void 0===s?void 0:s.value;e(a,n,o)}))}if(t&&"string"==typeof s){var n;const a=null===(n=Object.getOwnPropertyDescriptor(t,s))||void 0===n?void 0:n.value;r=r.slice(1),void 0!==a&&e(a,r,o)}return o},xe=e=>{const t=e.pseudoName,r=e.pseudoArg,o=e.domElement,n=be(t,r),a=n.rawName,l=n.rawValue;if(a.includes("\\/")||a.includes("\\."))throw new Error("Invalid :".concat(t," name pattern: ").concat(a));let i;try{i=(e=>{e.length>1&&e.startsWith(c)&&e.endsWith(c)&&(e=e.slice(1,-1));const t=e.split("."),r=[];let o="",n=!1,a=0;for(;a<t.length;){const e=t[a];e.startsWith(s)&&e.endsWith(s)&&e.length>2?r.push(e):e.startsWith(s)?(n=!0,o+=e):e.endsWith(s)?(n=!1,o+=".".concat(e),r.push(o),o=""):n?o+=e:r.push(e),a+=1}if(o.length>0)throw new Error("Invalid regexp property pattern '".concat(e,"'"));return r.map((t=>{if(0===t.length)throw new Error("Empty pattern '".concat(t,"' is invalid in chain '").concat(e,"'"));let r;try{r=Ee(t,!0)}catch(r){throw J.error(r),new Error("Invalid property pattern '".concat(t,"' in property chain '").concat(e,"'"))}return r}))})(a)}catch(e){throw J.error(e),new SyntaxError(e.message)}const u=Se(o,i);if(0===u.length)return!1;let d=!0;if(l){let e;try{e=Ee(l)}catch(e){throw J.error(e),new SyntaxError(e.message)}if(e)for(let t=0;t<u.length;t+=1){const r=u[t].value;if(e instanceof RegExp)d=e.test(z(r));else{if("null"===r||"undefined"===r){d=e===r;break}d=Y(e)===r}if(d)break}}return d},ke=e=>{const t=e.pseudoName,r=e.pseudoArg,o=(e=>(null==ne?void 0:ne.apply(e))||"")(e.domElement);let n,a=r;if(a.startsWith(s)&&ue.test(a)){const e=a.lastIndexOf("/"),s=a.substring(e+1);let c;a=a.substring(0,e+1).slice(1,-1).replace(/\\([\\"])/g,"$1");try{c=new RegExp(a,s)}catch(e){throw new Error("Invalid argument of :".concat(t,"() pseudo-class: ").concat(r))}n=c.test(o)}else a=a.replace(/\\([\\()[\]"])/g,"$1"),n=o.includes(a);return n};function Te(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let Ne;!function(e){e.SelectorList="SelectorList",e.Selector="Selector",e.RegularSelector="RegularSelector",e.ExtendedSelector="ExtendedSelector",e.AbsolutePseudoClass="AbsolutePseudoClass",e.RelativePseudoClass="RelativePseudoClass"}(Ne||(Ne={}));class Pe{constructor(e){Te(this,"children",[]),this.type=e}addChild(e){this.children.push(e)}}class Re extends Pe{constructor(e){super(Ne.RegularSelector),this.value=e}}class Ce extends Pe{constructor(e){super(Ne.RelativePseudoClass),this.name=e}}class Oe extends Pe{constructor(e){super(Ne.AbsolutePseudoClass),Te(this,"value",""),this.name=e}}const Ae=/\[-(?:ext)-([a-z-_]+)=(["'])((?:(?=(\\?))\4.)*?)\2\]/g,Ie=(e,t,r,o)=>{const s=new RegExp("([^\\\\]|^)\\\\".concat(r),"g"),n=o.replace(s,"$1".concat(r));return":".concat(t,"(").concat(n,")")},Le=/\(:scope >/g,Me=/(:matches-css)-(before|after)\(/g,Be=(e,t,o)=>"".concat(t).concat(r.LEFT).concat(o).concat(n),De=e=>(e=>{const t=e.replace(Ae,Ie).replace(Le,"(>").replace(Me,Be);if(t.includes("[-ext-"))throw new Error("Invalid extended-css old syntax selector: '".concat(e,"'"));return t})(e.trim());let Fe;!function(e){e.Mark="mark",e.Word="word"}(Fe||(Fe={}));const We=e=>{const t=[];e.forEach((e=>t.push(e)));const r=[];for(;t.length;){const e=t.pop();if(!e)throw new Error("Unable to make array flat");Array.isArray(e)?e.forEach((e=>t.push(e))):r.push(e)}return r.reverse()},_e=e=>e[e.length-1],$e="html ".concat(i),je=e=>B.includes(e),Ve=(e,r)=>f.includes(r)||e===Fe.Word||r===i||"#"===r||"."===r||r===a||"'"===r||r===c||r===t.LEFT,Ue=e=>0===e.pathToBufferNode.length?null:_e(e.pathToBufferNode),qe=e=>{const t=Ue(e);if(!t)throw new Error("No bufferNode found");if(t.type!==Ne.Selector)throw new Error("Unsupported bufferNode type");const r=t.children.filter((e=>e.type===Ne.RegularSelector));if(0===r.length)throw new Error("No RegularSelector node found");const o=_e(r);return e.pathToBufferNode.push(o),o},Ge=(e,t)=>{const r=Ue(e);if(null===r)throw new Error("No bufferNode to update");const o=r.type;if(o!==Ne.RegularSelector&&o!==Ne.AbsolutePseudoClass)throw new Error("".concat(r.type," node can not be updated. Only RegularSelector and AbsolutePseudoClass are supported."));r.value+=t},He=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const o=Ue(e);if(null===o)throw new Error("No buffer node");let s;s=t===Ne.RegularSelector?new Re(r):t===Ne.AbsolutePseudoClass?new Oe(r):t===Ne.RelativePseudoClass?new Ce(r):new Pe(t),o.addChild(s),e.pathToBufferNode.push(s)},Ke=(e,t)=>{(e=>{const t=new Pe(Ne.SelectorList);e.ast=t,e.pathToBufferNode.push(t)})(e),He(e,Ne.Selector),He(e,Ne.RegularSelector,t)},Xe=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";He(e,Ne.SelectorList),He(e,Ne.Selector),He(e,Ne.RegularSelector,t)},ze=(e,t)=>{for(let r=e.pathToBufferNode.length-1;r>=0;r-=1)if(e.pathToBufferNode[r].type===t){e.pathToBufferNode=e.pathToBufferNode.slice(0,r+1);break}},Ye=e=>{ze(e,Ne.Selector);const t=Ue(e);if(!t)throw new Error("No SelectorNode, impossible to continue selector parsing");const r=_e(t.children),o=r.type===Ne.ExtendedSelector&&0===e.standardPseudoBracketsStack.length,s=o&&r.children[0].name,n=s&&M.includes(s),a=s&&L.includes(s),c=n&&e.extendedPseudoBracketsStack.length>0&&e.extendedPseudoBracketsStack.length===e.extendedPseudoNamesStack.length,l=a&&s===_e(e.extendedPseudoNamesStack);let i=t;return c||l?(e.pathToBufferNode.push(r),i=r.children[0]):i=o?t:qe(e),e.pathToBufferNode.push(i),i},Je=(e,t,o,s,n)=>{if(je(s.toLowerCase())){if(C.includes(s)&&e.standardPseudoNamesStack.length>0)throw new Error("Usage of :".concat(s,"() pseudo-class is not allowed inside regular pseudo: '").concat(_e(e.standardPseudoNamesStack),"'"));ze(e,Ne.Selector),He(e,Ne.ExtendedSelector)}else{if(s.toLowerCase()===P)throw new Error("Selector parser error: invalid :remove() pseudo-class in selector: '".concat(t,"'"));Ge(e,o),n!==r.LEFT||e.isAttributeBracketsOpen||e.standardPseudoNamesStack.push(s)}},Qe=e=>{var w,g,v,E,b,y,S,x,R,O,M,D,W,_,$,j,V,U,q;const G=(e=>{const t=De(e);let r,o="";const s=[];for(let e=0;e<t.length;e+=1){if(r=t[e],m.includes(r)){s.push({type:Fe.Mark,value:r});continue}o+=r;const n=t[e+1];n&&!m.includes(n)||(s.push({type:Fe.Word,value:o}),o="")}return s})(e),H={ast:null,pathToBufferNode:[],extendedPseudoNamesStack:[],extendedPseudoBracketsStack:[],standardPseudoNamesStack:[],standardPseudoBracketsStack:[],isAttributeBracketsOpen:!1,isRegexpOpen:!1};let K=0;for(;K<G.length;){const m=G[K],X=m.type,z=m.value,Y=G[K+1]||[],J=Y.type,Q=Y.value,Z=G[K+2]||[],ee=Z.value,te=G[K-1]||[],re=te.type,oe=te.value;let se=Ue(H);switch(X){case Fe.Word:if(null===se)Ke(H,z);else if(se.type===Ne.SelectorList)He(H,Ne.Selector),He(H,Ne.RegularSelector,z);else if(se.type===Ne.RegularSelector)Ge(H,z);else if(se.type===Ne.ExtendedSelector){if(l.includes(Q)&&ee===r.LEFT)throw new Error("No white space is allowed before or after extended pseudo-class name in selector: '".concat(e,"'"));H.extendedPseudoNamesStack.push(z.toLowerCase()),L.includes(z.toLowerCase())?He(H,Ne.AbsolutePseudoClass,z.toLowerCase()):He(H,Ne.RelativePseudoClass,z.toLowerCase())}else se.type===Ne.AbsolutePseudoClass?Ge(H,z):se.type===Ne.RelativePseudoClass&&Xe(H,z);break;case Fe.Mark:switch(z){case n:if(!se||void 0!==se&&!Q)throw new Error("'".concat(e,"' is not a valid selector"));se.type===Ne.RegularSelector?H.isAttributeBracketsOpen?Ge(H,z):ze(H,Ne.SelectorList):se.type===Ne.AbsolutePseudoClass?Ge(H,z):(null===(w=se)||void 0===w?void 0:w.type)===Ne.Selector&&ze(H,Ne.SelectorList);break;case" ":if((null===(g=se)||void 0===g?void 0:g.type)===Ne.RegularSelector&&(se=Ye(H)),(null===(v=se)||void 0===v?void 0:v.type)===Ne.RegularSelector){if(!H.isAttributeBracketsOpen&&(oe===a&&J===Fe.Word||re===Fe.Word&&Q===r.LEFT))throw new Error("'".concat(e,"' is not a valid selector."));Q&&!Ve(J,Q)||Ge(H,z)}(null===(E=se)||void 0===E?void 0:E.type)===Ne.AbsolutePseudoClass&&Ge(H,z),(null===(b=se)||void 0===b?void 0:b.type)===Ne.RelativePseudoClass&&Xe(H),(null===(y=se)||void 0===y?void 0:y.type)===Ne.Selector&&Q&&Ve(J,Q)&&He(H,Ne.RegularSelector);break;case u:case d:case p:case h:case";":case s:case"\\":case"'":case c:case"^":case"$":case o.LEFT:case o.RIGHT:case i:case"#":case".":case t.LEFT:f.includes(z)&&(se=Ye(H)),null===se?Ke(H,z!==i||Q!==a||ee!==A&&ee!==I?z:$e):se.type===Ne.RegularSelector?(Ge(H,z),z===t.LEFT&&(H.isAttributeBracketsOpen=!0)):se.type===Ne.AbsolutePseudoClass?(Ge(H,z),z===s&&"\\"!==oe&&(H.isRegexpOpen=H.extendedPseudoNamesStack.length>0&&!H.isRegexpOpen)):se.type===Ne.RelativePseudoClass?(Xe(H,z),z===t.LEFT&&(H.isAttributeBracketsOpen=!0)):se.type===Ne.Selector?f.includes(z)?He(H,Ne.RegularSelector,z):H.isRegexpOpen||(se=qe(H),Ge(H,z)):se.type===Ne.SelectorList&&(He(H,Ne.Selector),He(H,Ne.RegularSelector,z));break;case t.RIGHT:(null===(S=se)||void 0===S?void 0:S.type)===Ne.RegularSelector&&(H.isAttributeBracketsOpen=!1,Ge(H,z)),(null===(x=se)||void 0===x?void 0:x.type)===Ne.AbsolutePseudoClass&&Ge(H,z);break;case a:if(l.includes(Q)&&B.includes(ee))throw new Error("No white space is allowed before or after extended pseudo-class name in selector: '".concat(e,"'"));if(null===se){if(Q===k)Ke(H,"body");else if(Q===A||Q===I)Ke(H,$e);else{if(Q===N||Q===T)throw new Error("Selector should be specified before :".concat(Q,"() pseudo-class"));Ke(H,i)}se=Ue(H)}if(!se)throw new Error("bufferNode has to be specified by now");if(se.type===Ne.SelectorList&&(He(H,Ne.Selector),He(H,Ne.RegularSelector),se=Ue(H)),(null===(R=se)||void 0===R?void 0:R.type)===Ne.RegularSelector&&((f.includes(oe)||oe===n)&&Ge(H,i),Je(H,e,z,Q,ee)),(null===(O=se)||void 0===O?void 0:O.type)===Ne.Selector)if(je(Q.toLowerCase()))He(H,Ne.ExtendedSelector);else{if(Q.toLowerCase()===P)throw new Error("Selector parser error: invalid :remove() pseudo-class in selector: '".concat(e,"'"));se=qe(H),Je(H,e,z,J,ee)}if((null===(M=se)||void 0===M?void 0:M.type)===Ne.AbsolutePseudoClass){if(se.name===k&&B.includes(Y.value)&&Z.value===r.LEFT)throw new Error(":xpath() pseudo-class should be at the end of selector: '".concat(e,"'"));Ge(H,z)}(null===(D=se)||void 0===D?void 0:D.type)===Ne.RelativePseudoClass&&(Xe(H,i),je(Q.toLowerCase())?(ze(H,Ne.Selector),He(H,Ne.ExtendedSelector)):(Ge(H,z),ee===r.LEFT&&H.standardPseudoNamesStack.push(Q)));break;case r.LEFT:(null===(W=se)||void 0===W?void 0:W.type)===Ne.AbsolutePseudoClass&&(se.name!==k&&H.isRegexpOpen?Ge(H,z):(H.extendedPseudoBracketsStack.push(z),H.extendedPseudoBracketsStack.length>H.extendedPseudoNamesStack.length&&Ge(H,z))),(null===(_=se)||void 0===_?void 0:_.type)===Ne.RegularSelector&&(H.standardPseudoNamesStack.length>0&&(Ge(H,z),H.standardPseudoBracketsStack.push(z)),H.isAttributeBracketsOpen&&Ge(H,z)),(null===($=se)||void 0===$?void 0:$.type)===Ne.RelativePseudoClass&&H.extendedPseudoBracketsStack.push(z);break;case r.RIGHT:if((null===(j=se)||void 0===j?void 0:j.type)===Ne.AbsolutePseudoClass&&(se.name!==k&&H.isRegexpOpen?Ge(H,z):(H.extendedPseudoBracketsStack.pop(),se.name!==k?(H.extendedPseudoNamesStack.pop(),H.extendedPseudoBracketsStack.length>H.extendedPseudoNamesStack.length?Ge(H,z):H.extendedPseudoBracketsStack.length>=0&&H.extendedPseudoNamesStack.length>=0&&ze(H,Ne.Selector)):H.extendedPseudoBracketsStack.length<H.extendedPseudoNamesStack.length?H.extendedPseudoNamesStack.pop():Ge(H,z))),(null===(V=se)||void 0===V?void 0:V.type)===Ne.RegularSelector)if(H.isAttributeBracketsOpen)Ge(H,z);else if(H.standardPseudoNamesStack.length>0&&H.standardPseudoBracketsStack.length>0){Ge(H,z),H.standardPseudoBracketsStack.pop();const t=H.standardPseudoNamesStack.pop();if(!t)throw new Error("Parsing error. Invalid selector: ".concat(e));if(Object.values(F).includes(t)&&Q===a&&ee&&C.includes(ee))throw new Error("Usage of :".concat(ee,"() pseudo-class is not allowed after any regular pseudo-element: '").concat(t,"'"))}else H.extendedPseudoBracketsStack.pop(),H.extendedPseudoNamesStack.pop(),ze(H,Ne.ExtendedSelector),ze(H,Ne.Selector);(null===(U=se)||void 0===U?void 0:U.type)===Ne.Selector&&(H.extendedPseudoBracketsStack.pop(),H.extendedPseudoNamesStack.pop(),ze(H,Ne.ExtendedSelector),ze(H,Ne.Selector)),(null===(q=se)||void 0===q?void 0:q.type)===Ne.RelativePseudoClass&&H.extendedPseudoNamesStack.length>0&&H.extendedPseudoBracketsStack.length>0&&(H.extendedPseudoBracketsStack.pop(),H.extendedPseudoNamesStack.pop());break;case"\t":case"\n":case"\f":case"\r":throw new Error("'".concat(e,"' is not a valid selector."))}break;default:throw new Error("Unknown type of token: '".concat(z,"'."))}K+=1}if(null===H.ast)throw new Error("'".concat(e,"' is not a valid selector"));if(H.extendedPseudoNamesStack.length>0||H.extendedPseudoBracketsStack.length>0)throw new Error("Unbalanced brackets for extended pseudo-class: '".concat(_e(H.extendedPseudoNamesStack),"'"));if(H.isAttributeBracketsOpen)throw new Error("Unbalanced brackets for attributes is selector: '".concat(e,"'"));return H.ast};function Ze(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function et(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,s,n=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(o=r.next()).done)&&(n.push(o.value),!t||n.length!==t);a=!0);}catch(e){c=!0,s=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw s}}return n}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Ze(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ze(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const tt=(e,t,r)=>{let o,s,n;switch(t){case w:case g:case v:n=ke,o={pseudoName:t,pseudoArg:r,domElement:e},s="Error while matching element text content by arg '".concat(r,"'.");break;case E:case y:case b:n=ge,o={pseudoName:t,pseudoArg:r,domElement:e},s="Error while matching element style by arg '".concat(r,"'.");break;case S:n=ye,o={domElement:e,pseudoName:t,pseudoArg:r},s="Error while matching element attributes by arg '".concat(r,"'.");break;case x:n=xe,o={domElement:e,pseudoName:t,pseudoArg:r},s="Error while matching element properties by arg '".concat(r,"'.");break;default:throw new Error("Unknown absolute pseudo-class :".concat(t,"()"))}return((e,t,r)=>{let o;try{o=e(t)}catch(e){throw J.error(e),new Error(r)}return o})(n,o,s)},rt=(e,t,r)=>{const o=((e,t)=>{const r=Number(e);if(Number.isNaN(r)||r<1||r>=256)throw new Error("Invalid argument of :".concat(t," pseudo-class: '").concat(e,"'"));return r})(t,r),s=e.map((e=>{let t=null;try{t=((e,t,r)=>{let o=null,s=0;for(;s<t;){if(o=e.parentElement,!o)throw new Error("Argument of :".concat(r,"() pseudo-class is too big — '").concat(t,"', out of DOM elements root."));e=o,s+=1}return o})(e,o,r)}catch(e){J.error(e)}return t})).filter(ce);return s},ot=(e,t)=>{const r=e.map((e=>{const r=[];let o;try{o=document.evaluate(t,e,null,XPathResult.UNORDERED_NODE_ITERATOR_TYPE,null)}catch(e){throw J.error(e),new Error("Invalid argument of :xpath pseudo-class: '".concat(t,"'"))}let s=o.iterateNext();for(;s;)ce(s)&&r.push(s),s=o.iterateNext();return r}));return We(r)},st=(e,t)=>{if(!(e=>{let t;try{document.querySelectorAll(e),t=!0}catch(e){t=!1}return t})(t))throw new Error("Invalid argument of :upward pseudo-class: '".concat(t,"'"));return e.map((e=>{const r=e.parentElement;return r?r.closest(t):null})).filter(ce)},nt=e=>{const t=e.element,r=e.relativeSelectorList,o=e.pseudoName;return r.children.every((e=>{var r,s;const n=et(e.children,1)[0];if(!n)throw new Error("RegularSelector is missing for :".concat(o," pseudo-class."));let a,c="",l=null;if(null!==(r=n.value)&&void 0!==r&&r.startsWith(p)||null!==(s=n.value)&&void 0!==s&&s.startsWith(h)){l=t.parentElement;const e=ae(t);c="".concat(D).concat(d).concat(e).concat(n.value)}else n.value===i?(l=t,c="".concat(D).concat(u).concat(i)):(c="".concat(D).concat(u).concat(n.value),l=t);if(!l)throw new Error("Selection by :".concat(o," pseudo-class is not possible."));try{a=it(e,l,c)}catch(e){throw J.error(e),new Error("Invalid selector for :".concat(o," pseudo-class: '").concat(n.value,"'"))}return a.length>0}))},at=(e,t,r)=>{if(!e.value)throw new Error("RegularSelector value should be specified");const o=r||e.value;let s=[];try{s=Array.from(t.querySelectorAll(o))}catch(e){throw new Error("Error: unable to select by '".concat(o,"' — ").concat(e.message))}return s},ct=(e,t)=>{let r=[];const o=t.children[0].name;if(!o)throw new Error("Extended pseudo-class should have a name");if(L.includes(o)){const s=t.children[0].value;if(!s)throw new Error("Missing arg for :".concat(o," pseudo-class"));if(o===T)r=rt(e,s,o);else if(o===k){try{document.createExpression(s,null)}catch(e){throw new Error("Invalid argument of :".concat(o," pseudo-class: '").concat(s,"'"))}r=ot(e,s)}else r=o===N?Number.isNaN(Number(s))?st(e,s):rt(e,s,o):e.filter((e=>tt(e,o,s)))}else{if(!M.includes(o))throw new Error("Unknown extended pseudo-class: ':".concat(o,"()'"));{const s=t.children[0].children;if(0===s.length)throw new Error("Missing arg for :".concat(o," pseudo-class"));const n=et(s,1)[0];let a;switch(o){case"has":case"if":case R:a=e=>nt({element:e,relativeSelectorList:n,pseudoName:o});break;case O:a=e=>!nt({element:e,relativeSelectorList:n,pseudoName:o});break;case A:a=e=>(e=>{const t=e.element,r=e.relativeSelectorList,o=e.pseudoName;return r.children.some((e=>{const r=et(e.children,1)[0];if(!r)throw new Error("RegularSelector is missing for :".concat(o," pseudo-class."));const s=t.parentElement;if(!s)throw new Error("Selection by :".concat(o," pseudo-class is not possible."));const n="".concat(D).concat(d).concat(r.value);let a;try{a=it(e,s,n)}catch(e){return!1}return a.includes(t)}))})({element:e,relativeSelectorList:n,pseudoName:o});break;case I:a=e=>(e=>{const t=e.element,r=e.relativeSelectorList,o=e.pseudoName;return r.children.every((e=>{const r=et(e.children,1)[0];if(!r)throw new Error("RegularSelector is missing for :".concat(o," pseudo-class."));const s=t.parentElement;if(!s)throw new Error("Selection by :".concat(o," pseudo-class is not possible."));const n="".concat(D).concat(d).concat(r.value);let a;try{a=it(e,s,n)}catch(e){throw J.error(e),new Error("Invalid selector for :".concat(o," pseudo-class: '").concat(r.value,"'"))}return!a.includes(t)}))})({element:e,relativeSelectorList:n,pseudoName:o});break;default:throw new Error("Unknown relative pseudo-class: ':".concat(o,"()'"))}r=e.filter(a)}}return r},lt=(e,t)=>{let r=[];const o=t.value;if(!o)throw new Error("RegularSelector should have a value.");return r=o.startsWith(d)?e.map((e=>{const r="".concat(D).concat(o);return at(t,e,r)})):o.startsWith(p)||o.startsWith(h)?e.map((e=>{const r=e.parentElement;if(!r)return[];const s=ae(e),n="".concat(D).concat(d).concat(s).concat(o);return at(t,r,n)})):e.map((e=>{const r="".concat(D).concat(u).concat(t.value);return at(t,e,r)})),We(r)},it=(e,t,r)=>{let o=[],s=0;for(;s<e.children.length;){const n=e.children[s];0===s?o=at(n,t,r):n.type===Ne.ExtendedSelector?o=ct(o,n):n.type===Ne.RegularSelector&&(o=lt(o,n)),s+=1}return o},ut=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;const r=[];e.children.forEach((e=>{r.push(...it(e,t))}));const o=[...new Set(We(r))];return o};const dt=new class{constructor(){this.astCache=new Map}saveAstToCache(e,t){this.astCache.set(e,t)}getAstFromCache(e){return this.astCache.get(e)||null}getSelectorAst(e){let t=this.getAstFromCache(e);return t||(t=Qe(e)),this.saveAstToCache(e,t),t}querySelectorAll(e){const t=this.getSelectorAst(e);return ut(t)}},pt="debug",ht=/[;}]/g,ft=/[;:}]/g,mt=/\S/g,wt={selector:""},gt=e=>{e.rawRuleData=wt},vt=(e,t)=>{let o,s=e.selectorBuffer.trim();if(s.startsWith("@"))throw new Error("At-rules are not supported: '".concat(s,"'."));try{o=(e=>{const t="".concat(a).concat(P).concat(r.LEFT).concat(r.RIGHT),o="".concat(a).concat(P).concat(r.LEFT);let s,n=!1;const c=e.indexOf(t);if(0===c)throw new Error("Selector should be specified before :remove() pseudo-class: '".concat(e,"'"));if(c>0){if(c!==e.lastIndexOf(t))throw new Error("Pseudo-class :remove() appears more than once in selector: '".concat(e,"'"));if(c+t.length<e.length)throw new Error("Pseudo-class :remove() should be at the end of selector: '".concat(e,"'"));s=e.substring(0,c),n=!0}else{if(e.includes(o))throw new Error("".concat(G,": '").concat(e,"'"));s=e}return{selector:s,stylesOfSelector:n?[{property:P,value:String(n)}]:[]}})(s)}catch(e){throw J.error(e.message),new Error("".concat(G,": '").concat(s,"'"))}if(-1===e.nextIndex){if(s===o.selector)throw new Error("".concat(H,": '").concat(e.cssToParse,"'"));e.cssToParse=""}let n,c=[],l=!1;try{s=o.selector,c=o.stylesOfSelector,n=t.getSelectorAst(s),l=!0}catch(e){l=!1}return e.nextIndex>0&&(e.cssToParse=e.cssToParse.slice(e.nextIndex)),{success:l,selector:s,ast:n,stylesOfSelector:c}},Et=(e,t)=>{ft.lastIndex=e.nextIndex;let r=ft.exec(e.cssToParse);if(null===r)throw new Error("".concat(j,": '").concat(e.cssToParse,"'"));let s=r.index,n=r[0];if(n===o.RIGHT){if(0!==e.cssToParse.slice(e.nextIndex,s).trim().length)throw new Error("".concat(j,": '").concat(e.cssToParse,"'"));if(0===t.length)throw new Error("".concat($,": '").concat(e.cssToParse,"'"));return s}if(n===a){const a=s;if(ht.lastIndex=a,r=ht.exec(e.cssToParse),null===r)throw new Error("".concat(V,": '").concat(e.cssToParse,"'"));s=r.index,n=r[0];const c=e.cssToParse.slice(e.nextIndex,a).trim();if(0===c.length)throw new Error("".concat(U,": '").concat(e.cssToParse,"'"));const l=e.cssToParse.slice(a+1,s).trim();if(0===l.length)throw new Error("".concat(q,": '").concat(e.cssToParse,"'"));if(t.push({property:c,value:l}),n===o.RIGHT)return s}return e.cssToParse=e.cssToParse.slice(s+1),e.nextIndex=0,Et(e,t)},bt=e=>{const t=[],r=Et(e,t);mt.lastIndex=r+1;const o=mt.exec(e.cssToParse);if(null===o)return e.cssToParse="",t;const s=o.index;return e.cssToParse=e.cssToParse.slice(s),t},yt=(e,t,r)=>{const o={selector:e,ast:t},s=(e=>{const t=e.find((e=>e.property===pt));return null==t?void 0:t.value})(r),n=(e=>e.some((e=>e.property===P&&e.value===W)))(r);let a=r;if(s&&(a=r.filter((e=>e.property!==pt)),s!==W&&s!==_||(o.debug=s)),n)o.style={[P]:W};else if(a.length>0){const e=a.map((e=>[e.property,e.value])),t=e.reduce(((e,t)=>{const r=t[0],o=t[1];return e[r]=o,e}),{});o.style=t}return o},St=(e,t)=>{const r=t.selector,o=t.ast,s=t.styles;if(!s)throw new Error("No style declaration for selector: '".concat(r,"'"));if(!o)throw new Error("No ast parsed for selector: '".concat(r,"'"));const n=e.get(r);n?n.styles.push(...s):e.set(r,{ast:o,styles:s})},xt=(e,t)=>{const r=e.trim();if(r.includes("".concat(s).concat(i))&&r.includes("".concat(i).concat(s)))throw new Error("Comments in stylesheet are not supported: '".concat(r,"'"));const n={isSelector:!0,nextIndex:0,cssToParse:r,selectorBuffer:"",rawRuleData:wt},a=new Map;let c;for(;n.cssToParse;)if(n.isSelector){if(n.nextIndex=n.cssToParse.indexOf(o.LEFT),0===n.selectorBuffer.length&&0===n.nextIndex)throw new Error("Selector should be defined before style declaration in stylesheet: '".concat(n.cssToParse,"'"));-1===n.nextIndex?n.selectorBuffer=n.cssToParse:n.selectorBuffer+=n.cssToParse.slice(0,n.nextIndex),c=vt(n,t),c.success?(n.rawRuleData.selector=c.selector.trim(),n.rawRuleData.ast=c.ast,n.rawRuleData.styles=c.stylesOfSelector,n.isSelector=!1,-1===n.nextIndex?(St(a,n.rawRuleData),gt(n)):(n.nextIndex=1,n.selectorBuffer="")):(n.selectorBuffer+=o.LEFT,n.cssToParse=n.cssToParse.slice(1))}else{var l;const e=bt(n);null===(l=n.rawRuleData.styles)||void 0===l||l.push(...e),St(a,n.rawRuleData),n.nextIndex=0,gt(n),n.isSelector=!0}const u=[];return a.forEach(((e,t)=>{const r=t,o=e.ast,s=e.styles;u.push(yt(r,o,s))})),u},kt=e=>"number"==typeof e&&!Number.isNaN(e),Tt=void 0!==window.requestAnimationFrame,Nt=Tt?requestAnimationFrame:window.setTimeout,Pt=Tt?cancelAnimationFrame:clearTimeout,Rt=Tt?performance:Date;class Ct{constructor(e,t,r){this.context=e,this.callback=t,this.throttleDelayMs=r||150,this.wrappedCb=this.wrappedCallback.bind(this)}wrappedCallback(e){this.lastRunTime=kt(e)?e:Rt.now(),this.timeoutId&&(Pt(this.timeoutId),delete this.timeoutId),clearTimeout(this.timerId),delete this.timerId,this.callback&&this.callback(this.context)}hasPendingCallback(){return kt(this.timeoutId)||kt(this.timerId)}run(){if(!this.hasPendingCallback()){if(void 0!==this.lastRunTime){const e=Rt.now()-this.lastRunTime;if(e<this.throttleDelayMs)return void(this.timerId=window.setTimeout(this.wrappedCb,this.throttleDelayMs-e))}this.timeoutId=Nt(this.wrappedCb)}}static now(){return Rt.now()}}const Ot=["mouseover","mouseleave","mouseenter","mouseout"],At=["keydown","keypress","keyup","auxclick","click","contextmenu","dblclick","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseout","mouseup","pointerlockchange","pointerlockerror","select","wheel"],It=["wheel"];class Lt{constructor(){Te(this,"getLastEventType",(()=>this.lastEventType)),Te(this,"getTimeSinceLastEvent",(()=>this.lastEventTime?Date.now()-this.lastEventTime:null)),this.trackedEvents=te?At.filter((e=>!It.includes(e))):At,this.trackedEvents.forEach((e=>{document.documentElement.addEventListener(e,this.trackEvent,!0)}))}trackEvent(e){this.lastEventType=e.type,this.lastEventTime=Date.now()}isIgnoredEventType(){const e=this.getLastEventType(),t=this.getTimeSinceLastEvent();return!!e&&Ot.includes(e)&&!!t&&t<10}stopTracking(){this.trackedEvents.forEach((e=>{document.documentElement.removeEventListener(e,this.trackEvent,!0)}))}}const Mt=void 0!==window.addEventListener,Bt=(e,t)=>{e.isDomObserved||(e.isDomObserved=!0,((e,t)=>{se.MutationObserver?(e.domMutationObserver=new se.MutationObserver((r=>{if(!r||0===r.length)return;const o=new Lt;o.isIgnoredEventType()&&(e=>e.every((e=>"attributes"===e.type)))(r)||(e.eventTracker=o,t())})),e.domMutationObserver.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["id","class"]})):Mt&&(document.addEventListener("DOMNodeInserted",t,!1),document.addEventListener("DOMNodeRemoved",t,!1),document.addEventListener("DOMAttrModified",t,!1))})(e,t))},Dt=(e,t)=>{e.isDomObserved&&(e.isDomObserved=!1,((e,t)=>{var r;e.domMutationObserver?e.domMutationObserver.disconnect():Mt&&(document.removeEventListener("DOMNodeInserted",t,!1),document.removeEventListener("DOMNodeRemoved",t,!1),document.removeEventListener("DOMAttrModified",t,!1)),null===(r=e.eventTracker)||void 0===r||r.stopTracking()})(e,t))},Ft=(e,t)=>{const r=t.node;t.removed=!0;const o=(e=>{if(!(e instanceof Element))throw new Error("Function received argument with wrong type");let t;t=e;const r=[];for(;t&&t.nodeType===Node.ELEMENT_NODE;){let e=t.nodeName.toLowerCase();if(t.id&&"string"==typeof t.id){e+="#".concat(t.id),r.unshift(e);break}let o=t,s=1;for(;o.previousElementSibling;)o=o.previousElementSibling,o.nodeType===Node.ELEMENT_NODE&&o.nodeName.toLowerCase()===e&&(s+=1);1!==s&&(e+=":nth-of-type(".concat(s,")")),r.unshift(e),t=t.parentElement}return r.join(" > ")})(r),s=e.removalsStatistic[o]||0;s>50?J.error("ExtendedCss: infinite loop protection for selector: '".concat(o,"'")):r.parentElement&&(r.parentElement.removeChild(r),e.removalsStatistic[o]=s+1)},Wt=(e,t)=>{e instanceof HTMLElement&&Object.keys(t).forEach((r=>{if(void 0!==e.style.getPropertyValue(r)){let o=t[r];o=((e,t)=>{const r=e.indexOf(t,e.length-t.length);return r>=0?e.substring(0,r):e})(o.trim(),"!important").trim(),e.style.setProperty(r,o,"important")}}))},_t=(e,t)=>{if(t.protectionObserver)return;if(e.beforeStyleApplied&&!(t=e.beforeStyleApplied(t)))return;const r=t,o=r.node,s=r.rules;for(let r=0;r<s.length;r+=1){const n=s[r],a=n.selector,c=n.style,l=n.debug;if(c){if(c.remove===W)return void Ft(e,t);Wt(o,c)}else if(!l)throw new Error("No style declaration in rule for selector: '".concat(a,"'"))}},$t=e=>{e.protectionObserver&&e.protectionObserver.disconnect(),e.node.style.cssText=e.originalStyle};class jt{constructor(e){this.styleProtectionCount=0,this.observer=new se.MutationObserver((t=>{t.length&&(this.styleProtectionCount+=1,e(t,this))}))}observe(e,t){this.styleProtectionCount<50?this.observer.observe(e,t):J.error("ExtendedCss: infinite loop protection for style")}disconnect(){this.observer.disconnect()}}const Vt={attributes:!0,attributeOldValue:!0,attributeFilter:["style"]},Ut=(e,t)=>{if(!se.MutationObserver)return null;const r=[];t.forEach((e=>{const t=e.style;t&&r.push(t)}));const o=new jt((e=>(t,r)=>{const o=t[0].target;r.disconnect(),e.forEach((e=>{Wt(o,e)})),r.observe(o,Vt)})(r));return o.observe(e,Vt),o};class qt{constructor(){this.appliesTimings=[],this.appliesCount=0,this.timingsSum=0,this.meanTiming=0,this.squaredSum=0,this.standardDeviation=0}push(e){this.appliesTimings.push(e),this.appliesCount+=1,this.timingsSum+=e,this.meanTiming=this.timingsSum/this.appliesCount,this.squaredSum+=e*e,this.standardDeviation=Math.sqrt(this.squaredSum/this.appliesCount-Math.pow(this.meanTiming,2))}}const Gt=e=>Number(e.toFixed(4)),Ht=e=>{const t=[];Dt(e,e.mainCallback),e.parsedRules.forEach((r=>{const o=((e,t)=>{const r=!!t.debug||e.debug;let o;r&&(o=Ct.now());const s=t.ast,n=ut(s);if(n.forEach((r=>{let o=(s=e.affectedElements,n=r,s.find((e=>e.node===n)));var s,n;if(o)o.rules.push(t),_t(e,o);else{const s=r.style.cssText;o={node:r,rules:[t],originalStyle:s,protectionObserver:null},_t(e,o),e.affectedElements.push(o)}})),r&&o){const e=Ct.now()-o;t.timingStats||(t.timingStats=new qt),t.timingStats.push(e)}return n})(e,r);Array.prototype.push.apply(t,o),r.debug&&(r.matchedElements=o)}));let r=e.affectedElements.length;for(;r;){const o=e.affectedElements[r-1];t.includes(o.node)?o.removed||o.protectionObserver||(o.protectionObserver=Ut(o.node,o.rules)):($t(o),e.affectedElements.splice(r-1,1)),r-=1}Bt(e,e.mainCallback),(e=>{if(e.areTimingsPrinted)return;e.areTimingsPrinted=!0;const t={};e.parsedRules.forEach((e=>{if(e.timingStats){const o=e.selector,s=e.style,n=e.debug,a=e.matchedElements;if(!s&&!n)throw new Error("Rule should have style declaration for selector: '".concat(o,"'"));const c={selectorParsed:o,timings:(r=e.timingStats,{appliesTimings:r.appliesTimings.map((e=>Gt(e))),appliesCount:Gt(r.appliesCount),timingsSum:Gt(r.timingsSum),meanTiming:Gt(r.meanTiming),standardDeviation:Gt(r.standardDeviation)})};s&&s.remove===W?c.removed=!0:(c.styleApplied=s||null,c.matchedElements=a),t[o]=c}var r})),0!==Object.keys(t).length&&J.info("[ExtendedCss] Timings in milliseconds for %o:\n%o",window.location.href,t)})(e)};class Kt{constructor(e){if(!(()=>{const e=navigator.userAgent;if(e.includes("MSIE")||e.includes("Trident/"))return!1;if(e.includes("jsdom"))return!0;const t=oe();if(!t)return!1;const r=t.browserName;return t.currentVersion>=re[r].MIN_VERSION})())throw new Error("Browser is not supported by ExtendedCss.");if(!e)throw new Error("ExtendedCss configuration should be provided.");if(this.context={beforeStyleApplied:e.beforeStyleApplied,debug:!1,affectedElements:[],isDomObserved:!1,removalsStatistic:{},parsedRules:xt(e.styleSheet,dt),mainCallback:()=>{}},this.context.debug=e.debug||this.context.parsedRules.some((e=>e.debug===_)),this.applyRulesScheduler=new Ct(this.context,Ht,150),this.context.mainCallback=this.applyRulesScheduler.run.bind(this.applyRulesScheduler),this.context.beforeStyleApplied&&"function"!=typeof this.context.beforeStyleApplied)throw new Error("Invalid configuration. Type of 'beforeStyleApplied' should be a function, received: '".concat(typeof this.context.beforeStyleApplied,"'"));this.applyRulesCallbackListener=()=>{Ht(this.context)}}apply(){Ht(this.context),"complete"!==document.readyState&&document.addEventListener("DOMContentLoaded",this.applyRulesCallbackListener,!1)}dispose(){Dt(this.context,this.context.mainCallback),this.context.affectedElements.forEach((e=>{$t(e)})),document.removeEventListener("DOMContentLoaded",this.applyRulesCallbackListener,!1)}getAffectedElements(){return this.context.affectedElements}static query(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("string"!=typeof e)throw new Error("Selector should be defined as a string.");const r=Ct.now();try{return dt.querySelectorAll(e)}finally{const e=Ct.now();t||J.info("[ExtendedCss] Elapsed: ".concat(Math.round(1e3*(e-r))," μs."))}}static validate(e){try{return Kt.query(e),{ok:!0,error:null}}catch(t){return{ok:!1,error:"Selector is not valid: '".concat(e,"' -- ").concat(t.message)}}}}return e.ExtendedCss=Kt,Object.defineProperty(e,"__esModule",{value:!0}),e}({});

@@ -78,10 +78,4 @@ export declare const BRACKETS: {

* ':scope' is used for extended pseudo-class :has(), if-not(), :is() and :not().
*
* ':where' is needed for limitation it's using inside :has() arg.
*
* @see {@link https://bugs.chromium.org/p/chromium/issues/detail?id=669058#c54} [case 1]
*/
export declare const REGULAR_PSEUDO_CLASSES: {
SCOPE: string;
};
export declare const SCOPE_CSS_PSEUDO_CLASS = ":scope";
/**

@@ -88,0 +82,0 @@ * ':after' and ':before' are needed for :matches-css() pseudo-class

import { AnySelectorNodeInterface } from '../nodes';
/**
* Additional calculated selector part which is needed to :has(), :if-not(), :is() and :not() pseudo-classes.
* Calculated selector text which is needed to :has(), :if-not(), :is() and :not() pseudo-classes.
* Contains calculated part (depends on the processed element)
* and value of RegularSelector which is next to selector by.
*

@@ -12,3 +14,3 @@ * Native Document.querySelectorAll() does not select exact descendant elements

*/
export declare type Specificity = string;
export declare type SpecifiedSelector = string;
/**

@@ -19,3 +21,3 @@ * Selects dom elements by value of RegularSelector.

* @param root Root DOM element.
* @param specificity @see {@link Specificity}.
* @param specifiedSelector @see {@link SpecifiedSelector}.
*

@@ -25,3 +27,3 @@ * @throws An error if RegularSelector has no value

*/
export declare const getByRegularSelector: (regularSelectorNode: AnySelectorNodeInterface, root: Document | Element, specificity?: Specificity) => HTMLElement[];
export declare const getByRegularSelector: (regularSelectorNode: AnySelectorNodeInterface, root: Document | Element, specifiedSelector?: SpecifiedSelector) => HTMLElement[];
/**

@@ -55,3 +57,3 @@ * Returns list of dom elements filtered or selected by ExtendedSelector node.

*
* 'specificity' is needed for :has(), :is(), and :not() pseudo-classes
* 'specifiedSelector' is needed for :has(), :is(), and :not() pseudo-classes
* as native querySelectorAll() does not select exact element descendants even if it is called on 'div'

@@ -63,4 +65,4 @@ * e.g. ':scope' specification is needed for proper descendants selection for 'div:has(> img)'.

* @param root Root DOM element.
* @param specificity Needed element specification.
* @param specifiedSelector Needed element specification.
*/
export declare const getElementsForSelectorNode: (selectorNode: AnySelectorNodeInterface, root: Document | Element | HTMLElement, specificity?: Specificity) => HTMLElement[];
export declare const getElementsForSelectorNode: (selectorNode: AnySelectorNodeInterface, root: Document | Element | HTMLElement, specifiedSelector?: SpecifiedSelector) => HTMLElement[];
{
"name": "@adguard/extended-css",
"version": "2.0.5",
"version": "2.0.7",
"description": "AdGuard's TypeScript library for non-standard element selecting and applying CSS styles with extended properties.",

@@ -5,0 +5,0 @@ "main": "dist/extended-css.umd.js",

@@ -46,4 +46,4 @@ # <a id="homepage"></a> ExtendedCss ![npm](https://img.shields.io/npm/v/@adguard/extended-css) [![install size](https://packagephobia.com/badge?p=@adguard/extended-css)](https://packagephobia.com/result?p=@adguard/extended-css) ![GitHub](https://img.shields.io/github/license/AdGuardTeam/ExtendedCss)

2. Specific pseudo-class might have its own limitations:
[`:has()`](#extended-css-has-limitations), [`:xpath()`](#extended-css-xpath-limitations), [`:is()`](#extended-css-is-limitations), [`:not()`](#extended-css-not-limitations), and [`:remove()`](#extended-css-remove-limitations).
2. Specific pseudo-class may have its own limitations:
[`:has()`](#extended-css-has-limitations), [`:xpath()`](#extended-css-xpath-limitations), [`:nth-ancestor()`](#extended-css-nth-ancestor-limitations), [`:upward()`](#extended-css-upward-limitations), [`:is()`](#extended-css-is-limitations), [`:not()`](#extended-css-not-limitations), and [`:remove()`](#extended-css-remove-limitations).

@@ -382,2 +382,6 @@

<a id="extended-css-nth-ancestor-limitations"></a> **Limitations**
> Pseudo-class `:nth-ancestor()` is not supported inside [`:not()` pseudo-class](#extended-css-not) argument.
**Examples**

@@ -419,2 +423,6 @@

<a id="extended-css-upward-limitations"></a> **Limitations**
> Pseudo-class `:upward()` is not supported inside [`:not()` pseudo-class](#extended-css-not) argument.
**Examples**

@@ -499,3 +507,3 @@

- `target` — optional, standard or extended css selector, can be missed for checking *any* element
- `selectors` — [*forgiving selector list*](https://drafts.csswg.org/selectors-4/#typedef-forgiving-selector-list) of standard or extended selectors
- `selectors` — [*forgiving selector list*](https://drafts.csswg.org/selectors-4/#typedef-forgiving-selector-list) of standard or extended selectors. For extended selectors only compound selectors are supported, not complex.

@@ -506,5 +514,7 @@ <a id="extended-css-is-limitations"></a> **Limitations**

> [Complex selectors](https://www.w3.org/TR/selectors-4/#complex) with extended pseudo-classes are not supported as `selectors` argument for `:is()` pseudo-class, only [compound ones](https://www.w3.org/TR/selectors-4/#compound) are allowed. Check examples below.
**Examples**
`#container *:is(.inner, .footer)` will select only `div#target1`
`#container *:is(.inner, .footer)` will select only `div#target1`:
```html

@@ -521,3 +531,13 @@ <!-- HTML code -->

Due to limitations `:is(*:not([class]) > .banner)'` will not work
but `:is(*:not([class]):has(> .banner))` can be used instead of it to select `div#target2`:
```html
<!-- HTML code -->
<span class="span">text</span>
<div id="target2">
<p class="banner">inner paragraph</p>
</div>
```
### <a id="extended-css-not"></a> Pseudo-class `:not()`

@@ -541,2 +561,4 @@

> "Up-looking" pseudo-classes which are [`:nth-ancestor()`](#extended-css-nth-ancestor) and [`:upward()`](#extended-css-upward) are not supported inside `selectors` argument for `:not()` pseudo-class.
**Examples**

@@ -543,0 +565,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc