Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asamuzakjp/dom-selector

Package Overview
Dependencies
Maintainers
1
Versions
191
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asamuzakjp/dom-selector - npm Package Compare versions

Comparing version 5.2.2 to 5.3.0

4

dist/cjs/index.js

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

var p=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var m=(f,r)=>{for(var t in r)p(f,t,{get:r[t],enumerable:!0})},a=(f,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of l(r))!T.call(f,i)&&i!==t&&p(f,i,{get:()=>r[i],enumerable:!(n=E(r,i))||n.enumerable});return f};var u=f=>a(p({},"__esModule",{value:!0}),f);var x={};m(x,{DOMSelector:()=>d});module.exports=u(x);var y=require("./js/finder.js"),h=require("./js/utility.js"),s=require("./js/constant.js");/*!
var f=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var u=(p,r)=>{for(var e in r)f(p,e,{get:r[e],enumerable:!0})},d=(p,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of m(r))!a.call(p,n)&&n!==e&&f(p,n,{get:()=>r[n],enumerable:!(i=T(r,n))||i.enumerable});return p};var x=p=>d(f({},"__esModule",{value:!0}),p);var N={};u(N,{DOMSelector:()=>D});module.exports=x(N);var l=require("./js/finder.js"),o=require("./js/utility.js"),s=require("./js/constant.js");/*!
* DOM Selector - A CSS selector engine.

@@ -6,3 +6,3 @@ * @license MIT

* @see {@link https://github.com/asamuzaK/domSelector/blob/main/LICENSE}
*/class d{#e;#r;#t;#s;constructor(r,t){this.#e=r,this.#r=t??r.document,this.#t=new y.Finder(r),this.#s=(0,h.initNwsapi)(r,t)}matches(r,t,n){if(t?.nodeType){if(t.nodeType!==s.ELEMENT_NODE){const e=new this.#e.TypeError(`Unexpected node ${t.nodeName}`);this.#t.onError(e,n)}}else{const e=new this.#e.TypeError(`Unexpected type ${(0,h.getType)(t)}`);this.#t.onError(e,n)}const i=t.ownerDocument;if(i===this.#r&&i.contentType==="text/html"){const e={complex:s.REG_COMPLEX.test(r),descend:!1,target:s.TARGET_SELF};if((0,h.filterSelector)(r,e))try{return this.#s.match(r,t)}catch{}}let o;try{this.#t.setup(r,t,n),o=this.#t.find(s.TARGET_SELF).size}catch(e){this.#t.onError(e,n)}return!!o}closest(r,t,n){if(t?.nodeType){if(t.nodeType!==s.ELEMENT_NODE){const e=new this.#e.TypeError(`Unexpected node ${t.nodeName}`);this.#t.onError(e,n)}}else{const e=new this.#e.TypeError(`Unexpected type ${(0,h.getType)(t)}`);this.#t.onError(e,n)}const i=t.ownerDocument;if(i===this.#r&&i.contentType==="text/html"){const e={complex:s.REG_COMPLEX.test(r),descend:!1,target:s.TARGET_LINEAL};if((0,h.filterSelector)(r,e))try{return this.#s.closest(r,t)}catch{}}let o;try{this.#t.setup(r,t,n);const e=this.#t.find(s.TARGET_LINEAL);if(e.size){let c=t;for(;c;){if(e.has(c)){o=c;break}c=c.parentNode}}}catch(e){this.#t.onError(e,n)}return o??null}querySelector(r,t,n){if(!t?.nodeType){const e=new this.#e.TypeError(`Unexpected type ${(0,h.getType)(t)}`);this.#t.onError(e,n)}let i;if(t.nodeType===s.DOCUMENT_NODE?i=t:i=t.ownerDocument,i===this.#r&&i.contentType==="text/html"){const e={complex:!1,descend:s.REG_DESCEND.test(r),target:s.TARGET_FIRST};if((0,h.filterSelector)(r,e))try{return this.#s.first(r,t)}catch{}}let o;try{this.#t.setup(r,t,n);const e=this.#t.find(s.TARGET_FIRST);e.size&&([o]=e)}catch(e){this.#t.onError(e,n)}return o??null}querySelectorAll(r,t,n){if(!t?.nodeType){const e=new this.#e.TypeError(`Unexpected type ${(0,h.getType)(t)}`);this.#t.onError(e,n)}let i;if(t.nodeType===s.DOCUMENT_NODE?i=t:i=t.ownerDocument,i===this.#r&&i.contentType==="text/html"){const e={complex:!1,descend:s.REG_DESCEND.test(r),target:s.TARGET_ALL};if((0,h.filterSelector)(r,e))try{return this.#s.select(r,t)}catch{}}let o;try{this.#t.setup(r,t,n);const e=this.#t.find(s.TARGET_ALL);e.size&&(o=[...e])}catch(e){this.#t.onError(e,n)}return o??[]}}0&&(module.exports={DOMSelector});
*/const E=new RegExp(`${s.COMBO}${s.COMPOUND_I}`,"i"),y=new RegExp(`${s.DESCEND}${s.COMPOUND_I}`,"i");class D{#t;#r;#e;#s;constructor(r,e){this.#t=r,this.#r=e??r.document,this.#e=new l.Finder(r),this.#s=(0,o.initNwsapi)(r,e)}matches(r,e,i){if(e?.nodeType){if(e.nodeType!==s.ELEMENT_NODE){const t=new this.#t.TypeError(`Unexpected node ${e.nodeName}`);this.#e.onError(t,i)}}else{const t=new this.#t.TypeError(`Unexpected type ${(0,o.getType)(e)}`);this.#e.onError(t,i)}const n=e.ownerDocument;if(n===this.#r&&n.contentType==="text/html"){const t={complex:E.test(r),descend:!1,target:s.TARGET_SELF};if((0,o.filterSelector)(r,t))try{return this.#s.match(r,e)}catch{}}let h;try{this.#e.setup(r,e,i),h=this.#e.find(s.TARGET_SELF).size}catch(t){this.#e.onError(t,i)}return!!h}closest(r,e,i){if(e?.nodeType){if(e.nodeType!==s.ELEMENT_NODE){const t=new this.#t.TypeError(`Unexpected node ${e.nodeName}`);this.#e.onError(t,i)}}else{const t=new this.#t.TypeError(`Unexpected type ${(0,o.getType)(e)}`);this.#e.onError(t,i)}const n=e.ownerDocument;if(n===this.#r&&n.contentType==="text/html"){const t={complex:E.test(r),descend:!1,target:s.TARGET_LINEAL};if((0,o.filterSelector)(r,t))try{return this.#s.closest(r,e)}catch{}}let h;try{this.#e.setup(r,e,i);const t=this.#e.find(s.TARGET_LINEAL);if(t.size){let c=e;for(;c;){if(t.has(c)){h=c;break}c=c.parentNode}}}catch(t){this.#e.onError(t,i)}return h??null}querySelector(r,e,i){if(!e?.nodeType){const t=new this.#t.TypeError(`Unexpected type ${(0,o.getType)(e)}`);this.#e.onError(t,i)}let n;if(e.nodeType===s.DOCUMENT_NODE?n=e:n=e.ownerDocument,n===this.#r&&n.contentType==="text/html"){const t={complex:!1,descend:y.test(r),target:s.TARGET_FIRST};if((0,o.filterSelector)(r,t))try{return this.#s.first(r,e)}catch{}}let h;try{this.#e.setup(r,e,i);const t=this.#e.find(s.TARGET_FIRST);t.size&&([h]=t)}catch(t){this.#e.onError(t,i)}return h??null}querySelectorAll(r,e,i){if(!e?.nodeType){const t=new this.#t.TypeError(`Unexpected type ${(0,o.getType)(e)}`);this.#e.onError(t,i)}let n;if(e.nodeType===s.DOCUMENT_NODE?n=e:n=e.ownerDocument,n===this.#r&&n.contentType==="text/html"){const t={complex:!1,descend:y.test(r),target:s.TARGET_ALL};if((0,o.filterSelector)(r,t))try{return this.#s.select(r,e)}catch{}}let h;try{this.#e.setup(r,e,i);const t=this.#e.find(s.TARGET_ALL);t.size&&(h=[...t])}catch(t){this.#e.onError(t,i)}return h??[]}}0&&(module.exports={DOMSelector});
//# sourceMappingURL=index.js.map

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

var T=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var m=(o,t)=>{for(var n in t)T(o,n,{get:t[n],enumerable:!0})},Y=(o,t,n,C)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of d(t))!u.call(o,s)&&s!==n&&T(o,s,{get:()=>t[s],enumerable:!(C=U(t,s))||C.enumerable});return o};var B=o=>Y(T({},"__esModule",{value:!0}),o);var to={};m(to,{ALPHA_NUM:()=>O,ANB:()=>P,AN_PLUS_B:()=>H,BIT_01:()=>st,BIT_02:()=>rt,BIT_04:()=>Et,BIT_08:()=>nt,BIT_16:()=>ct,BIT_32:()=>xt,BIT_FFFF:()=>pt,BIT_HYPHEN:()=>_t,CHILD_IDX:()=>G,COMBINATOR:()=>w,COMBO:()=>_,COMPLEX:()=>$,COMPLEX_L:()=>A,COMPOUND:()=>E,COMPOUND_A:()=>S,COMPOUND_B:()=>N,COMPOUND_I:()=>L,DESCEND:()=>l,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>At,DOCUMENT_NODE:()=>Lt,DOCUMENT_POSITION_CONTAINED_BY:()=>Gt,DOCUMENT_POSITION_CONTAINS:()=>Ct,DOCUMENT_POSITION_PRECEDING:()=>It,DUO:()=>Tt,ELEMENT_NODE:()=>St,EMPTY:()=>h,HEX:()=>Ot,IDENTIFIER:()=>g,KEY_IS_NOT:()=>I,LANG_PART:()=>D,LOGICAL_COMPLEX:()=>M,LOGICAL_COMPOUND:()=>F,NESTED_LOGICAL_A:()=>i,NESTED_LOGICAL_B:()=>a,NOT_SUPPORTED_ERR:()=>b,NTH:()=>f,N_TH:()=>p,PSEUDO_CLASSES:()=>x,RAW:()=>X,REG_ANCHOR:()=>Mt,REG_COMPLEX:()=>Ft,REG_DESCEND:()=>Ut,REG_DIR:()=>dt,REG_FILTER_COMPLEX:()=>ut,REG_FILTER_COMPOUND:()=>mt,REG_FILTER_SIMPLE:()=>Yt,REG_FORM:()=>Bt,REG_FORM_CTRL:()=>Ht,REG_FORM_VALID:()=>wt,REG_HEX:()=>ht,REG_INTERACT:()=>gt,REG_INVALID_SELECTOR:()=>bt,REG_LANG:()=>ft,REG_LANG_QUOTED:()=>Xt,REG_LOGICAL_EMPTY:()=>Wt,REG_LOGICAL_PSEUDO:()=>yt,REG_SHADOW_HOST:()=>kt,REG_SHADOW_MODE:()=>Zt,REG_SHADOW_PSEUDO:()=>Kt,REG_TAG_NAME:()=>vt,REG_TYPE_CHECK:()=>zt,REG_TYPE_INPUT:()=>Vt,REG_TYPE_RANGE:()=>Qt,REG_TYPE_RESET:()=>jt,REG_TYPE_SUBMIT:()=>qt,REG_TYPE_TEXT:()=>Jt,SELECTOR:()=>W,SELECTOR_ATTR:()=>y,SELECTOR_CLASS:()=>k,SELECTOR_ID:()=>Z,SELECTOR_LIST:()=>K,SELECTOR_PSEUDO_CLASS:()=>v,SELECTOR_PSEUDO_ELEMENT:()=>z,SELECTOR_TYPE:()=>V,SHOW_ALL:()=>Dt,SHOW_DOCUMENT:()=>Pt,SHOW_DOCUMENT_FRAGMENT:()=>lt,SHOW_ELEMENT:()=>it,STRING:()=>Q,SUB_TYPE:()=>r,SYNTAX_ERR:()=>j,TAG_TYPE:()=>e,TAG_TYPE_I:()=>R,TARGET_ALL:()=>q,TARGET_FIRST:()=>J,TARGET_LINEAL:()=>tt,TARGET_SELF:()=>ot,TEXT_NODE:()=>Nt,TYPE_FROM:()=>Rt,TYPE_TO:()=>$t,U_FFFD:()=>et,WALKER_FILTER:()=>at});module.exports=B(to);const H="AnPlusB",w="Combinator",h="__EMPTY__",g="Identifier",b="NotSupportedError",f="Nth",X="Raw",W="Selector",y="AttributeSelector",k="ClassSelector",Z="IdSelector",K="SelectorList",v="PseudoClassSelector",z="PseudoElementSelector",V="TypeSelector",Q="String",j="SyntaxError",q="all",J="first",tt="lineal",ot="self",et="\uFFFD",st=1,rt=2,Et=4,nt=8,ct=16,xt=32,pt=65535,_t=45,Tt=2,Ot=16,Rt=8,$t=-1,St=1,Nt=3,Lt=9,At=11,It=2,Ct=8,Gt=16,Dt=4294967295,Pt=256,lt=1024,it=1,at=1281,O="[A-Z\\d]+",G="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",D=`(?:-${O})*`,x=`(?:any-)?link|${G}|checked|empty|indeterminate|root|target|visited`,P=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,p=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${P})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",R="\\*|[A-Z][\\w-]*",E=`(?:${e}|(?:${e})?(?:${r})+)`,_="\\s?[\\s>~+]\\s?",$=`${E}(?:${_}${E})*`,l="\\s?[\\s>]\\s?",i=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,a=`:is\\(\\s*${$}(?:\\s*,\\s*${$})*\\s*\\)`,S=`(?:${e}|(?:${e})?(?:${r}|${i})+)`,N=`(?:${e}|(?:${e})?(?:${r}|${a})+)`,L=`(?:${R}|(?:${R})?(?:${r})+)`,A=`${N}(?:${_}${N})*`,I="(?:is|not)",M=`${I}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,F=`${I}\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,Mt=/^a(?:rea)?$/,Ft=new RegExp(`${_}${L}`,"i"),Ut=new RegExp(`${l}${L}`,"i"),dt=/^(?:ltr|rtl)$/,ut=new RegExp(`:(?!${x}|${p}|${M})`),mt=new RegExp(`:(?!${x}|${p}|${F})`),Yt=new RegExp(`:(?!${x}|${p})`),Bt=/^(?:button|fieldset|form|input|select|textarea)$/,Ht=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,wt=/^(?:button|form|input|select|textarea)$/,ht=/^([\da-f]{1,6}\s?)/i,gt=/^(?:details|dialog)$/,bt=/^$|^\s*>|,\s*$/,ft=new RegExp(`^(?:\\*-)?${O}${D}$`,"i"),Xt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,Wt=/(:(is|where)\(\s*\))/,yt=/^(?:has|is|not|where)$/,kt=/^host(?:-context)?$/,Zt=/^(?:close|open)$/,Kt=/^part|slotted$/,vt=/[A-Z][\\w-]*/i,zt=/^(?:checkbox|radio)$/,Vt=/^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|week)$/,Qt=/^(?:date(?:time-local)?|month|number|range|time|week)$/,jt=/^(?:button|reset)$/,qt=/^(?:image|submit)$/,Jt=/^(?:email|number|password|search|tel|text|url)$/;0&&(module.exports={ALPHA_NUM,ANB,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,CHILD_IDX,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DESCEND,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,KEY_IS_NOT,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_COMPLEX,REG_DESCEND,REG_DIR,REG_FILTER_COMPLEX,REG_FILTER_COMPOUND,REG_FILTER_SIMPLE,REG_FORM,REG_FORM_CTRL,REG_FORM_VALID,REG_HEX,REG_INTERACT,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_EMPTY,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TAG_NAME,REG_TYPE_CHECK,REG_TYPE_INPUT,REG_TYPE_RANGE,REG_TYPE_RESET,REG_TYPE_SUBMIT,REG_TYPE_TEXT,SELECTOR,SELECTOR_ATTR,SELECTOR_CLASS,SELECTOR_ID,SELECTOR_LIST,SELECTOR_PSEUDO_CLASS,SELECTOR_PSEUDO_ELEMENT,SELECTOR_TYPE,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER});
var E=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var M=(o,t)=>{for(var c in t)E(o,c,{get:t[c],enumerable:!0})},i=(o,t,c,C)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!F.call(o,s)&&s!==c&&E(o,s,{get:()=>t[s],enumerable:!(C=R(t,s))||C.enumerable});return o};var U=o=>i(E({},"__esModule",{value:!0}),o);var Gt={};M(Gt,{ALPHA_NUM:()=>A,ANB:()=>$,AN_PLUS_B:()=>a,ATTR_SELECTOR:()=>G,BIT_01:()=>q,BIT_02:()=>J,BIT_04:()=>Q,BIT_08:()=>V,BIT_16:()=>tt,BIT_32:()=>ot,BIT_FFFF:()=>et,CHILD_IDX:()=>I,CLASS_SELECTOR:()=>d,COMBINATOR:()=>B,COMBO:()=>T,COMPLEX:()=>_,COMPLEX_L:()=>S,COMPOUND:()=>n,COMPOUND_A:()=>O,COMPOUND_B:()=>N,COMPOUND_I:()=>Ft,DESCEND:()=>lt,DIGIT:()=>x,DOCUMENT_FRAGMENT_NODE:()=>_t,DOCUMENT_NODE:()=>Tt,DOCUMENT_POSITION_CONTAINED_BY:()=>St,DOCUMENT_POSITION_CONTAINS:()=>Nt,DOCUMENT_POSITION_PRECEDING:()=>Ot,DUO:()=>st,ELEMENT_NODE:()=>Et,EMPTY:()=>Y,HEX:()=>rt,HYPHEN:()=>nt,IDENT:()=>H,ID_SELECTOR:()=>h,KEY_IS_NOT:()=>L,LANG_PART:()=>Pt,LOGICAL_COMPLEX:()=>Mt,LOGICAL_COMPOUND:()=>it,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>D,NOT_SUPPORTED_ERR:()=>m,NTH:()=>u,N_TH:()=>Rt,PSEUDO_CLASS:()=>Dt,PS_CLASS_SELECTOR:()=>w,PS_ELEMENT_SELECTOR:()=>y,RAW:()=>X,REG_INPUT_TYPE:()=>at,REG_LOGICAL:()=>Ut,SELECTOR:()=>f,SELECTOR_LIST:()=>W,SHOW_ALL:()=>Lt,SHOW_DOCUMENT:()=>Ct,SHOW_DOCUMENT_FRAGMENT:()=>At,SHOW_ELEMENT:()=>It,STRING:()=>b,SUB_TYPE:()=>r,SYNTAX_ERR:()=>k,TAG_TYPE:()=>e,TAG_TYPE_I:()=>p,TARGET_ALL:()=>Z,TARGET_FIRST:()=>g,TARGET_LINEAL:()=>v,TARGET_SELF:()=>K,TEXT_NODE:()=>pt,TYPE_FROM:()=>ct,TYPE_SELECTOR:()=>z,TYPE_TO:()=>xt,U_FFFD:()=>j,WALKER_FILTER:()=>$t});module.exports=U(Gt);const a="AnPlusB",G="AttributeSelector",d="ClassSelector",B="Combinator",Y="__EMPTY__",H="Identifier",h="IdSelector",m="NotSupportedError",u="Nth",w="PseudoClassSelector",y="PseudoElementSelector",X="Raw",f="Selector",W="SelectorList",b="String",k="SyntaxError",Z="all",g="first",v="lineal",K="self",z="TypeSelector",j="\uFFFD",q=1,J=2,Q=4,V=8,tt=16,ot=32,et=65535,st=2,rt=16,nt=45,ct=8,xt=-1,Et=1,pt=3,Tt=9,_t=11,Ot=2,Nt=8,St=16,Lt=4294967295,Ct=256,At=1024,It=1,$t=1281,A="[A-Z\\d]+",I="(?:first|last|only)-(?:child|of-type)",x="(?:0|[1-9]\\d*)",Pt=`(?:-${A})*`,Dt=`(?:any-)?link|${I}|checked|empty|indeterminate|root|target|visited`,$=`[+-]?(?:${x}n?|n)|(?:[+-]?${x})?n\\s*[+-]\\s*${x}`,Rt=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${$})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",p="\\*|[A-Z][\\w-]*",n=`(?:${e}|(?:${e})?(?:${r})+)`,T="\\s?[\\s>~+]\\s?",_=`${n}(?:${T}${n})*`,lt="\\s?[\\s>]\\s?",P=`:is\\(\\s*${n}(?:\\s*,\\s*${n})*\\s*\\)`,D=`:is\\(\\s*${_}(?:\\s*,\\s*${_})*\\s*\\)`,O=`(?:${e}|(?:${e})?(?:${r}|${P})+)`,N=`(?:${e}|(?:${e})?(?:${r}|${D})+)`,Ft=`(?:${p}|(?:${p})?(?:${r})+)`,S=`${N}(?:${T}${N})*`,L="(?:is|not)",Mt=`${L}\\(\\s*${S}(?:\\s*,\\s*${S})*\\s*\\)`,it=`${L}\\(\\s*${O}(?:\\s*,\\s*${O})*\\s*\\)`,Ut=/^(?:has|is|not|where)$/,at=/^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|week)$/;0&&(module.exports={ALPHA_NUM,ANB,AN_PLUS_B,ATTR_SELECTOR,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,CHILD_IDX,CLASS_SELECTOR,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DESCEND,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,HYPHEN,IDENT,ID_SELECTOR,KEY_IS_NOT,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASS,PS_CLASS_SELECTOR,PS_ELEMENT_SELECTOR,RAW,REG_INPUT_TYPE,REG_LOGICAL,SELECTOR,SELECTOR_LIST,SHOW_ALL,SHOW_DOCUMENT,SHOW_DOCUMENT_FRAGMENT,SHOW_ELEMENT,STRING,SUB_TYPE,SYNTAX_ERR,TAG_TYPE,TAG_TYPE_I,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_SELECTOR,TYPE_TO,U_FFFD,WALKER_FILTER});
//# sourceMappingURL=constant.js.map

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

var T=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var $=(S,c)=>{for(var e in c)T(S,e,{get:c[e],enumerable:!0})},F=(S,c,e,h)=>{if(c&&typeof c=="object"||typeof c=="function")for(let n of D(c))!U.call(S,n)&&n!==e&&T(S,n,{get:()=>c[n],enumerable:!(h=I(c,n))||h.enumerable});return S};var G=S=>F(T({},"__esModule",{value:!0}),S);var z={};$(z,{Finder:()=>H});module.exports=G(z);var C=require("./matcher.js"),g=require("./parser.js"),k=require("./utility.js"),a=require("./constant.js");const v="next",x="prev",W="Tab";class H{#a;#n;#w;#t;#f;#c;#k;#o;#u;#h;#e;#d;#_;#m;#N;#s;#b;#r;#p;#i;#l;constructor(c){this.#l=c,this.#h=new C.Matcher,this.#n=new WeakMap,this.#f=new WeakMap,this.#u=new WeakMap,this.#N=new WeakMap,this.#c=null,this.#k=null,this._registerEventListeners()}onError(c,e={}){if(!(e.noexcept??this.#_))if(c instanceof DOMException||c instanceof this.#l.DOMException)if(c.name===a.NOT_SUPPORTED_ERR)this.#i&&console.warn(c.message);else throw new this.#l.DOMException(c.message,c.name);else throw c}setup(c,e,h={}){const{event:n,noexcept:l,warn:r}=h;return this.#_=!!l,this.#i=!!r,this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#b=(0,k.isInShadowTree)(e),[this.#a,this.#d]=this._correspond(c),this.#u=new WeakMap,this.#p=new WeakMap,this._setEvent(n),e}_registerEventListeners(){const c={capture:!0,passive:!0},e=[],h=["mouseover","mousedown","mouseup","mouseout"];for(const l of h)e.push(this.#l.addEventListener(l,r=>{this.#c=r},c));const n=["keydown","keyup"];for(const l of n)e.push(this.#l.addEventListener(l,r=>{r.key===W&&(this.#c=r)},c));return e.push(this.#l.addEventListener("focusin",l=>{this.#k=l},c)),e}_setEvent(c){return(c instanceof this.#l.KeyboardEvent||c instanceof this.#l.MouseEvent)&&(this.#c=c),this.#c}_correspond(c){const e=[];this.#w=!1,this.#o=!1;let h;if(this.#f.has(this.#t)){const n=this.#f.get(this.#t);if(n&&n.has(`${c}`)){const l=n.get(`${c}`);h=l.ast,this.#w=l.descendant,this.#o=l.invalidate}}if(h){const n=h.length;for(let l=0;l<n;l++)h[l].collected=!1,h[l].dir=null,h[l].filtered=!1,h[l].find=!1,e[l]=[]}else{let n;try{n=(0,g.parseSelector)(c)}catch(s){this.onError(s)}const{branches:l,info:{hasHasPseudoFunc:r}}=(0,g.walkAST)(n);let f=!!r,b=!1,d=0;h=[];for(const[...s]of l){const t=[];let o=s.shift();if(o&&o.type!==a.COMBINATOR){const u=new Set;for(;o;){if(o.type===a.COMBINATOR){const[m]=s;if(m.type===a.COMBINATOR)throw new DOMException(`Invalid selector ${c}`,a.SYNTAX_ERR);const w=o.name;/^[\s>]$/.test(w)?b=!0:f=!0,t.push({combo:o,leaves:(0,g.sortAST)(u)}),u.clear()}else if(o){let{name:m}=o;m&&typeof m=="string"&&(m=(0,g.unescapeSelector)(m),typeof m=="string"&&m!==o.name&&(o.name=m),/[|:]/.test(m)&&(o.namespace=!0)),u.add(o)}if(s.length)o=s.shift();else{t.push({combo:null,leaves:(0,g.sortAST)(u)}),u.clear();break}}}h.push({branch:t,collected:!1,dir:null,filtered:!1,find:!1}),e[d]=[],d++}let i;this.#f.has(this.#t)?i=this.#f.get(this.#t):i=new Map,i.set(`${c}`,{ast:h,descendant:b,invalidate:f}),this.#f.set(this.#t,i),this.#w=b,this.#o=f}return[h,e]}_createTreeWalker(c){let e;return this.#p.has(c)?e=this.#p.get(c):(e=this.#t.createTreeWalker(c,a.WALKER_FILTER),this.#p.set(c,e)),e}_prepareQuerySelectorWalker(){return this.#m=this._createTreeWalker(this.#e),this.#m}_collectNthChild(c,e,h){const{a:n,b:l,reverse:r,selector:f}=c,{parentNode:b}=e,d=new Set;let i;if(f)if(this.#n.has(f))i=this.#n.get(f);else{const{branches:s,info:t}=(0,g.walkAST)(f);i=s,this.#n.set(f,i),t.hasLogicalPseudoFunc&&(this.#o=!0)}if(b){const s=this.#r;let t=(0,k.traverseNode)(b,s);t=s.firstChild();let o=0;for(;t;)o++,t=s.nextSibling();const u=new Set;if(i)for(t=(0,k.traverseNode)(b,s),t=s.firstChild();t;){if((0,k.isVisible)(t)){let m;for(const w of i)if(m=this._matchLeaves(w,t,h),!m)break;m&&u.add(t)}t=s.nextSibling()}if(n===0){if(l>0&&l<=o){if(u.size){t=(0,k.traverseNode)(b,s),r?t=s.lastChild():t=s.firstChild();let m=0;for(;t;){if(u.has(t)){if(m===l-1){d.add(t);break}m++}r?t=s.previousSibling():t=s.nextSibling()}}else if(!f){t=(0,k.traverseNode)(b,s),r?t=s.lastChild():t=s.firstChild();let m=0;for(;t;){if(m===l-1){d.add(t);break}r?t=s.previousSibling():t=s.nextSibling(),m++}}}}else{let m=l-1;if(n>0)for(;m<0;)m+=n;if(m>=0&&m<o){t=(0,k.traverseNode)(b,s),r?t=s.lastChild():t=s.firstChild();let w=0,p=n>0?0:l-1;for(;t&&(t&&m>=0&&m<o);)u.size?u.has(t)&&(p===m&&(d.add(t),m+=n),n>0?p++:p--):w===m&&(f||d.add(t),m+=n),r?t=s.previousSibling():t=s.nextSibling(),w++}}if(r&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&n+l===1)if(i){let s;for(const t of i)if(s=this._matchLeaves(t,e,h),s)break;s&&d.add(e)}else d.add(e);return d}_collectNthOfType(c,e){const{a:h,b:n,reverse:l}=c,{localName:r,namespaceURI:f,parentNode:b,prefix:d}=e,i=new Set;if(b){const s=this.#r;let t=(0,k.traverseNode)(b,s);t=s.firstChild();let o=0;for(;t;)o++,t=s.nextSibling();if(h===0){if(n>0&&n<=o){t=(0,k.traverseNode)(b,s),l?t=s.lastChild():t=s.firstChild();let u=0;for(;t;){const{localName:m,namespaceURI:w,prefix:p}=t;if(m===r&&p===d&&w===f){if(u===n-1){i.add(t);break}u++}l?t=s.previousSibling():t=s.nextSibling()}}}else{let u=n-1;if(h>0)for(;u<0;)u+=h;if(u>=0&&u<o){t=(0,k.traverseNode)(b,s),l?t=s.lastChild():t=s.firstChild();let m=h>0?0:n-1;for(;t;){const{localName:w,namespaceURI:p,prefix:N}=t;if(w===r&&N===d&&p===f){if(m===u&&(i.add(t),u+=h),u<0||u>=o)break;h>0?m++:m--}l?t=s.previousSibling():t=s.nextSibling()}}}if(l&&i.size>1){const u=[...i];return new Set(u.reverse())}}else e===this.#s&&h+n===1&&i.add(e);return i}_matchAnPlusB(c,e,h,n){const{nth:{a:l,b:r,name:f},selector:b}=c,d=new Map;if(f?(f==="even"?(d.set("a",2),d.set("b",0)):f==="odd"&&(d.set("a",2),d.set("b",1)),h.indexOf("last")>-1&&d.set("reverse",!0)):(typeof l=="string"&&/-?\d+/.test(l)?d.set("a",l*1):d.set("a",0),typeof r=="string"&&/-?\d+/.test(r)?d.set("b",r*1):d.set("b",0),h.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(h)){b&&d.set("selector",b);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(c,e,h={}){let n;if(Array.isArray(c)&&c.length){const l=c.map(t=>t),[r]=l,{type:f}=r;let b;f===a.COMBINATOR?b=l.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;l.length;){const[t]=l,{type:o}=t;if(o===a.COMBINATOR)break;d.push(l.shift())}const i={combo:b,leaves:d};h.dir=v;const s=this._matchCombinator(i,e,h);if(s.size)if(l.length){for(const t of s)if(n=this._matchHasPseudoFunc(l,t,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(c,e,h={}){const{astName:n="",branches:l=[],selector:r="",twigBranches:f=[]}=c;let b;if(n==="has")if(r.includes(":has("))b=null;else{let d;for(const i of l)if(d=this._matchHasPseudoFunc(i,e,h),d)break;d&&(b=e)}else{const d=/^(?:is|where)$/.test(n);h.forgive=d;const i=f.length;let s;for(let t=0;t<i;t++){const o=f[t],u=o.length-1,{leaves:m}=o[u];if(s=this._matchLeaves(m,e,h),s&&u>0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=o[p],_=[];h.dir=x;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?s=!0:w=new Set(_);else{s=!1;break}}}if(s)break}n==="not"?s||(b=e):s&&(b=e)}return b??null}_matchPseudoClassSelector(c,e,h={}){const{children:n,name:l}=c,{localName:r,parentNode:f}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(l)){let s;if(this.#n.has(c))s=this.#n.get(c);else{const{branches:o}=(0,g.walkAST)(c),u=[],m=[];for(const[...w]of o){for(const y of w){const E=(0,g.generateCSS)(y);u.push(E)}const p=[],N=new Set;let _=w.shift();for(;_;)if(_.type===a.COMBINATOR?(p.push({combo:_,leaves:[...N]}),N.clear()):_&&N.add(_),w.length)_=w.shift();else{p.push({combo:null,leaves:[...N]}),N.clear();break}m.push(p)}s={astName:l,branches:o,twigBranches:m,selector:u.join(",")},this.#n.set(c,s)}const t=this._matchLogicalPseudoFunc(s,e,h);t&&i.add(t)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[s]=n;return this._matchAnPlusB(s,e,l,h)}else switch(l){case"dir":case"lang":{const s=this.#h.matchSelector(c,e,h,!0);s&&i.add(s);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:s}]=n;if(s)if(e[s])i.add(e);else for(const t in e){const o=e[t];if(o instanceof this.#l.ElementInternals){o?.states?.has(s)&&i.add(e);break}}}break}case"current":case"nth-col":case"nth-last-col":{if(d)throw new DOMException(`Unsupported pseudo-class :${l}()`,a.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(d)throw new DOMException(`Unknown pseudo-class :${l}()`,a.NOT_SUPPORTED_ERR);break}default:if(!b)throw new DOMException(`Unknown pseudo-class :${l}()`,a.SYNTAX_ERR)}else switch(l){case"any-link":case"link":{a.REG_ANCHOR.test(r)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(a.REG_ANCHOR.test(r)&&e.hasAttribute("href")){const{href:s,origin:t,pathname:o}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),s);u.origin===t&&u.pathname===o&&i.add(e)}break}case"visited":break;case"hover":{const{target:s,type:t}=this.#c??{};/^(?:mouse|pointer)(?:down|over|up)$/.test(t)&&e.contains(s)&&i.add(e);break}case"active":{const{buttons:s,target:t,type:o}=this.#c??{};/(?:mouse|pointer)down/.test(o)&&s&a.BIT_01&&e.contains(t)&&i.add(e);break}case"target":{const{hash:s}=new URL(this.#t.URL);e.id&&s===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:s}=new URL(this.#t.URL);if(s){const t=s.replace(/^#/,"");let o=this.#t.getElementById(t);for(;o;){if(o===e){i.add(e);break}o=o.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#b&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":{e===this.#t.activeElement&&e.tabIndex>=0&&(0,k.isFocusable)(e)&&i.add(e);break}case"focus-visible":{if(e===this.#t.activeElement&&e.tabIndex>=0){let s;if((0,k.isFocusVisible)(e))s=!0;else{const{target:t,type:o}=this.#c??{},{target:u,relatedTarget:m}=this.#k??{};(/^key(?:down|up)$/.test(o)&&e.contains(t)||m&&(0,k.isFocusVisible)(m)&&e.contains(u))&&(s=!0)}s&&(0,k.isFocusable)(e)&&i.add(e)}break}case"focus-within":{let s,t=this.#t.activeElement;if(t.tabIndex>=0)for(;t;){if(t===e){s=!0;break}t=t.parentNode}s&&(0,k.isFocusable)(e)&&i.add(e);break}case"open":{a.REG_INTERACT.test(r)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{a.REG_INTERACT.test(r)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(a.REG_FORM_CTRL.test(r)||(0,k.isCustomElement)(e,{formAssociated:!0})){if(e.disabled||e.hasAttribute("disabled"))i.add(e);else if(e.localName==="option")f.localName==="optgroup"&&(f.disabled||f.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let s,t=f;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const o=this.#r;let u=(0,k.traverseNode)(t,o);for(u=o.firstChild();u&&u.localName!=="legend";)u=o.nextSibling();u&&u.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===a.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s&&i.add(e)}}break}case"enabled":{if((a.REG_FORM_CTRL.test(r)||(0,k.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled")))if(e.localName==="optgroup")i.add(e);else if(e.localName==="option")(f.localName!=="optgroup"||!(f.disabled||f.hasAttribute("disabled")))&&i.add(e);else{let s,t=f;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const o=this.#r;let u=(0,k.traverseNode)(t,o);for(u=o.firstChild();u&&u.localName!=="legend";)u=o.nextSibling();u&&u.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===a.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s||i.add(e)}break}case"read-only":{switch(r){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||a.REG_TYPE_INPUT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(r){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||a.REG_TYPE_INPUT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let s;if(e.placeholder?s=e.placeholder:e.hasAttribute("placeholder")&&(s=e.getAttribute("placeholder")),typeof s=="string"&&!/[\r\n]/.test(s)){let t;r==="textarea"?t=e:r==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(t=e):t=e),t&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&r==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&r==="input"&&e.type==="checkbox"||r==="progress"&&!e.hasAttribute("value"))i.add(e);else if(r==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const s=e.name;let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;t||(t=this.#t.documentElement);const o=t.getElementsByTagName("input"),u=o.length;let m;for(let w=0;w<u;w++){const p=o[w];if(p.getAttribute("type")==="radio"&&(s?p.getAttribute("name")===s&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(r==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;if(s){const t=this.#r;let o=(0,k.traverseNode)(s,t);for(o=t.firstChild();o&&s.contains(o);){const u=o.localName;let m;if(u==="button"?m=!(o.hasAttribute("type")&&a.REG_TYPE_RESET.test(o.getAttribute("type"))):u==="input"&&(m=o.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(o.getAttribute("type"))),m){o===e&&i.add(e);break}o=t.nextNode()}}}else(r==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||r==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(r==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let o;if(!t)o=!0;else for(;t&&e.contains(t)&&!(a.REG_FORM_VALID.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?o=t.maxLength>=t.value.length:o=!0:o=!1,!o));)t=s.nextNode();o&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(r))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(r==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let o;if(!t)o=!0;else for(;t&&e.contains(t)&&!(a.REG_FORM_VALID.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?o=t.maxLength>=t.value.length:o=!0:o=!1,!o));)t=s.nextNode();o||i.add(e)}break}case"in-range":{r==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&i.add(e);break}case"out-of-range":{r==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&a.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let s;if(/^(?:select|textarea)$/.test(r))s=e;else if(r==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||a.REG_TYPE_CHECK.test(t)||a.REG_TYPE_INPUT.test(t))&&(s=e)}else s=e;s&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let s;if(/^(?:select|textarea)$/.test(r))s=e;else if(r==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||a.REG_TYPE_CHECK.test(t)||a.REG_TYPE_INPUT.test(t))&&(s=e)}else s=e;s&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#t.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const s=this.#t.createTreeWalker(e,a.SHOW_ALL);let t=s.firstChild(),o;for(;t&&(o=t.nodeType!==a.ELEMENT_NODE&&t.nodeType!==a.TEXT_NODE,!!o);)t=s.nextSibling();o&&i.add(e)}else i.add(e);break}case"first-child":{(f&&e===f.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(f&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(f&&e===f.firstElementChild&&e===f.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(f){const[s]=this._collectNthOfType({a:0,b:1},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(f){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(f){const[s]=this._collectNthOfType({a:0,b:1},e);if(s===e){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t===e&&i.add(e)}}else e===this.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||r.includes("-")?(0,k.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&i.add(e);break}case"popover-open":{e.popover&&(0,k.isVisible)(e)&&i.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d)throw new DOMException(`Unsupported pseudo-element ::${l}`,a.NOT_SUPPORTED_ERR);break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(d)throw new DOMException(`Unsupported pseudo-class :${l}`,a.NOT_SUPPORTED_ERR);break}default:if(l.startsWith("-webkit-")){if(d)throw new DOMException(`Unsupported pseudo-class :${l}`,a.NOT_SUPPORTED_ERR)}else if(!b)throw new DOMException(`Unknown pseudo-class :${l}`,a.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(c,e){const{children:h,name:n}=c;let l;if(Array.isArray(h)){const{branches:r}=(0,g.walkAST)(h[0]),[f]=r,[...b]=f,{host:d}=e;if(n==="host"){let i;for(const s of b){const{type:t}=s;if(t===a.COMBINATOR){const o=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${o}`,a.SYNTAX_ERR)}if(i=this._matchSelector(s,d).has(d),!i)break}i&&(l=e)}else if(n==="host-context"){let i=d,s;for(;i;){for(const t of b){const{type:o}=t;if(o===a.COMBINATOR){const u=(0,g.generateCSS)(c);throw new DOMException(`Invalid selector ${u}`,a.SYNTAX_ERR)}if(s=this._matchSelector(t,i).has(i),!s)break}if(s)break;i=i.parentNode}s&&(l=e)}}else if(n==="host")l=e;else throw new DOMException(`Invalid selector :${n}`,a.SYNTAX_ERR);return l??null}_matchSelector(c,e,h){const{type:n}=c,l=new Set;if(c.name===a.EMPTY)return l;const r=(0,g.unescapeSelector)(c.name);if(typeof r=="string"&&r!==c.name&&(c.name=r),e.nodeType===a.ELEMENT_NODE)switch(n){case a.SELECTOR_PSEUDO_ELEMENT:{this.#h.matchPseudoElementSelector(r,h);break}case a.SELECTOR_ID:{e.id===r&&l.add(e);break}case a.SELECTOR_CLASS:{e.classList.contains(r)&&l.add(e);break}case a.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(c,e,h);default:{const f=this.#h.matchSelector(c,e,h,!0);f&&l.add(f)}}else if(this.#b&&n===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(r!=="has"&&a.REG_LOGICAL_PSEUDO.test(r))return this._matchPseudoClassSelector(c,e,h);if(a.REG_SHADOW_HOST.test(r)){const f=this._matchShadowHostPseudoClass(c,e,h);f&&l.add(f)}}return l}_matchLeaves(c,e,h){let n,l;if(this.#o?l=this.#u.get(c):l=this.#N.get(c),l&&l.has(e)){const{matched:r}=l.get(e);n=r}if(typeof n!="boolean"){let r=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(r=!1);for(const f of c){switch(f.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{r=!1;break}case a.SELECTOR_PSEUDO_CLASS:{/^(?:(?:any-)?link|defined|dir)$/.test(f.name)&&(r=!1);break}default:}if(n=this._matchSelector(f,e,h).has(e),!n)break}r&&(l||(l=new WeakMap),l.set(e,{matched:n}),this.#o?this.#u.set(c,l):this.#N.set(c,l))}return!!n}_matchHTMLCollection(c,e={}){const{compound:h,filterLeaves:n}=e,l=new Set,r=c.length;if(r)if(h)for(let f=0;f<r;f++){const b=c[f];this._matchLeaves(n,b,e)&&l.add(b)}else{const f=[].slice.call(c);return new Set(f)}return l}_findDescendantNodes(c,e,h){const[n,...l]=c,r=l.length>0,{type:f}=n,b=(0,g.unescapeSelector)(n.name);typeof b=="string"&&b!==n.name&&(n.name=b);let d=new Set,i=!1;if(this.#b)i=!0;else switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{this.#h.matchPseudoElementSelector(b,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const s=this.#s.getElementById(b);s&&s!==e&&e.contains(s)&&(r?this._matchLeaves(l,s,h)&&d.add(s):d.add(s))}break}case a.SELECTOR_CLASS:{const s=e.getElementsByClassName(b);d=this._matchHTMLCollection(s,{compound:r,filterLeaves:l});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const s=e.getElementsByTagName(b);d=this._matchHTMLCollection(s,{compound:r,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(c,e,h={}){const{combo:n,leaves:l}=c,{name:r}=n,{parentNode:f}=e,{dir:b}=h,d=new Set;if(b===v)switch(r){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let s=(0,k.traverseNode)(e,i);for(s=i.nextSibling();s;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let s=(0,k.traverseNode)(e,i);for(s=i.firstChild();s;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling();break}case" ":default:{const{nodes:i,pending:s}=this._findDescendantNodes(l,e);if(i.size)return i;if(s){const t=this._createTreeWalker(e);let o=(0,k.traverseNode)(e,t);for(o=t.nextNode();o&&e.contains(o);)this._matchLeaves(l,o,h)&&d.add(o),o=t.nextNode()}}}else switch(r){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let s=(0,k.traverseNode)(f,i);for(s=i.firstChild();s&&s!==e;)this._matchLeaves(l,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{f&&this._matchLeaves(l,f,h)&&d.add(f);break}case" ":default:{const i=[];let s=f;for(;s;)this._matchLeaves(l,s,h)&&i.push(s),s=s.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(c,e){const{node:h}=e,n=this.#m;let l=(0,k.traverseNode)(h,n),r;if(l)for((l.nodeType!==a.ELEMENT_NODE||l===h&&l!==this.#s)&&(l=n.nextNode());l;){if(this._matchLeaves(c,l,{warn:this.#i})){r=l;break}l=n.nextNode()}return r??null}_matchSelf(c){const e=[],h=this._matchLeaves(c,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(c,e={}){const{complex:h}=e,n=[];let l=this._matchLeaves(c,this.#e,{warn:this.#i}),r=!1;if(l&&(n.push(this.#e),r=!0),!l||h){let f=this.#e.parentNode;for(;f&&(l=this._matchLeaves(c,f,{warn:this.#i}),l&&(n.push(f),r=!0),f.parentNode);)f=f.parentNode}return[n,r]}_findFirst(c){const e=[],h=this._findNode(c,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(c,e={}){const{complex:h,compound:n,filterLeaves:l,targetType:r}=e;let f=[],b=!1,d=!1;const i=c.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let s=0;s<i;s++){const t=c[s];if(t!==this.#e&&(this.#e.contains(t)||t.contains(this.#e))){if(n){if(this._matchLeaves(l,t,{warn:this.#i})&&(f.push(t),b=!0,r===a.TARGET_FIRST))break}else if(f.push(t),b=!0,r===a.TARGET_FIRST)break}}else if(h)if(n)for(let s=0;s<i;s++){const t=c[s];if(this._matchLeaves(l,t,{warn:this.#i})&&(f.push(t),b=!0,r===a.TARGET_FIRST))break}else f=[].slice.call(c),b=!0,d=!0;else if(n)for(let s=0;s<i;s++){const t=c[s];if(this._matchLeaves(l,t,{warn:this.#i})&&(f.push(t),b=!0,r===a.TARGET_FIRST))break}else f=[].slice.call(c),b=!0,d=!0;return[f,b,d]}_findEntryNodes(c,e,h){const{leaves:n}=c,[l,...r]=n,f=r.length>0,{name:b,type:d}=l;let i=[],s=!1,t=!1,o=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{this.#h.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const u=this.#s.getElementById(b);u&&(f?this._matchLeaves(r,u,{warn:this.#i})&&(i.push(u),t=!0):(i.push(u),t=!0))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(n):o=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const u=this.#s.getElementsByClassName(b);u.length&&([i,t,s]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(n):o=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:h});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===a.DOCUMENT_NODE&&!/[*|]/.test(b)){const u=this.#s.getElementsByTagName(b);u.length&&([i,t,s]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:r,targetType:e}))}else e===a.TARGET_FIRST?[i,t]=this._findFirst(n):o=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#b&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const u=this._matchShadowHostPseudoClass(l,this.#e);u&&(i.push(u),t=!0)}}else e===a.TARGET_SELF?[i,t]=this._matchSelf(n):e===a.TARGET_LINEAL?[i,t]=this._findLineal(n,{complex:h}):e===a.TARGET_FIRST?[i,t]=this._findFirst(n):o=!0}return{collected:s,compound:f,filtered:t,nodes:i,pending:o}}_collectNodes(c){const e=this.#a.values();if(c===a.TARGET_ALL||c===a.TARGET_FIRST){const h=new Set;let n=0;for(const{branch:l}of e){const r=l.length,f=r>1,b=l[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=l[r-1],{leaves:[{name:y,type:E}]}=_;if(E===a.SELECTOR_PSEUDO_ELEMENT||E===a.SELECTOR_ID)d=x,i=_;else if(N===a.SELECTOR_PSEUDO_ELEMENT||N===a.SELECTOR_ID)d=v,i=b;else if(c===a.TARGET_ALL)if(p==="*"&&N===a.SELECTOR_TYPE)d=x,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(r===2){const{name:A}=w;/^[+~]$/.test(A)?(d=x,i=_):(d=v,i=b)}else d=v,i=b;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(p==="*"&&N===a.SELECTOR_TYPE)d=x,i=_;else{let A;for(const{combo:L,leaves:[R]}of l){const{name:O,type:M}=R;if(M===a.SELECTOR_PSEUDO_CLASS&&O==="dir"){A=!1;break}if(!A&&L){const{name:P}=L;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=b):(d=x,i=_)}}else d=x,i=b;const{collected:s,compound:t,filtered:o,nodes:u,pending:m}=this._findEntryNodes(i,c,f);u.length?(this.#a[n].find=!0,this.#d[n]=u):m&&h.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=s,this.#a[n].dir=d,this.#a[n].filtered=o||!t,n++}if(h.size){let l,r;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(l=this.#e,r=this.#m):(l=this.#s,r=this.#r);let f=(0,k.traverseNode)(l,r);for(;f;){let b=!1;if(this.#e.nodeType===a.ELEMENT_NODE?f===this.#e?b=!0:b=this.#e.contains(f):b=!0,b)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,f,{warn:this.#i})){const t=d.get("index");this.#a[t].filtered=!0,this.#a[t].find=!0,this.#d[t].push(f)}}f!==r.currentNode&&(f=(0,k.traverseNode)(f,r)),f=r.nextNode()}}}else{let h=0;for(const{branch:n}of e){const l=n[n.length-1],r=n.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(l,c,r);d.length&&(this.#a[h].find=!0,this.#d[h]=d),this.#a[h].dir=x,this.#a[h].filtered=b||!f,h++}}return[this.#a,this.#d]}_getCombinedNodes(c,e,h){const n=[];for(const l of e){const r=this._matchCombinator(c,l,{dir:h,warn:this.#i});r.size&&n.push(...r)}return n.length?new Set(n):new Set}_matchNodeNext(c,e,h){const{combo:n,index:l}=h,{combo:r,leaves:f}=c[l],b={combo:n,leaves:f},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(l===c.length-1){const[s]=(0,k.sortNodes)(d);i=s}else i=this._matchNodeNext(c,d,{combo:r,index:l+1});return i??null}_matchNodePrev(c,e,h){const{index:n}=h,l=c[n],r=new Set([e]),f=this._getCombinedNodes(l,r,x);let b;if(f.size){if(n===0)b=e;else for(const d of f)if(this._matchNodePrev(c,d,{index:n-1}))return e}return b??null}find(c){(c===a.TARGET_ALL||c===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(c),n=e.length;let l,r=new Set;for(let f=0;f<n;f++){const{branch:b,collected:d,dir:i,find:s}=e[f],t=b.length;if(t&&s){const o=h[f],u=o.length,m=t-1;if(m===0)if((c===a.TARGET_ALL||c===a.TARGET_FIRST)&&this.#e.nodeType===a.ELEMENT_NODE)for(let w=0;w<u;w++){const p=o[w];if(p!==this.#e&&this.#e.contains(p)&&(r.add(p),c!==a.TARGET_ALL))break}else if(c===a.TARGET_ALL)if(r.size){const w=[...r];r=new Set([...w,...o]),l=!0}else r=new Set(o);else{const[w]=o;r.add(w)}else if(c===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of o){let N=new Set([p]);for(let _=1;_<t;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(r.size){const L=[...r];r=new Set([...L,...N]),l=!0}else r=N;else w=y;else break}}}else for(const w of o){let p=new Set([w]);for(let N=m-1;N>=0;N--){const _=b[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(r.add(w),t>1&&r.size>1&&(l=!0));else break}}else if(c===a.TARGET_FIRST&&i===v){const{combo:w}=b[0];let p;for(const N of o)if(p=this._matchNodeNext(b,new Set([N]),{combo:w,index:1}),p){r.add(p);break}if(!p&&!d){const{leaves:N}=b[0],[_]=o;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(b,new Set([y]),{combo:w,index:1}),p){r.add(p);break}y=this._findNode(N,{node:y})}}}else{let w;for(const p of o)if(w=this._matchNodePrev(b,p,{index:m-1}),w){r.add(p);break}if(!w&&!d&&c===a.TARGET_FIRST){const{leaves:p}=b[m],[N]=o;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(b,_,{index:m-1}),w){r.add(_);break}_=this._findNode(p,{node:_})}}}}}return c===a.TARGET_FIRST?(r.delete(this.#e),r.size>1&&(r=new Set((0,k.sortNodes)(r)))):c===a.TARGET_ALL&&(r.delete(this.#e),l&&r.size>1&&(r=new Set((0,k.sortNodes)(r)))),r}}0&&(module.exports={Finder});
var R=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var Y=(S,r)=>{for(var e in r)R(S,e,{get:r[e],enumerable:!0})},q=(S,r,e,h)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of j(r))!V.call(S,n)&&n!==e&&R(S,n,{get:()=>r[n],enumerable:!(h=B(r,n))||h.enumerable});return S};var K=S=>q(R({},"__esModule",{value:!0}),S);var Z={};Y(Z,{Finder:()=>J});module.exports=K(Z);var F=require("./matcher.js"),g=require("./parser.js"),k=require("./utility.js"),c=require("./constant.js");const v="next",x="prev",X="Tab",O=/^a(?:rea)?$/,M=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,T=/^(?:button|form|input|select|textarea)$/,I=/^(?:details|dialog)$/,P=/^host(?:-context)?$/,C=/^(?:checkbox|radio)$/,$=/^(?:date(?:time-local)?|month|number|range|time|week)$/,D=/^(?:button|reset)$/,U=/^(?:image|submit)$/,Q=/^(?:email|number|password|search|tel|text|url)$/;class J{#l;#c;#w;#t;#o;#n;#k;#f;#b;#h;#e;#d;#_;#m;#N;#s;#u;#r;#p;#i;#a;constructor(r){this.#a=r,this.#h=new F.Matcher,this.#c=new WeakMap,this.#o=new WeakMap,this.#b=new WeakMap,this.#N=new WeakMap,this.#n=null,this.#k=null,this._registerEventListeners()}onError(r,e={}){if(!(e.noexcept??this.#_))if(r instanceof DOMException||r instanceof this.#a.DOMException)if(r.name===c.NOT_SUPPORTED_ERR)this.#i&&console.warn(r.message);else throw new this.#a.DOMException(r.message,r.name);else throw r.name in this.#a?new this.#a[r.name](r.message):r}setup(r,e,h={}){const{event:n,noexcept:a,warn:l}=h;return this.#_=!!a,this.#i=!!l,this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#u=(0,k.isInShadowTree)(e),[this.#l,this.#d]=this._correspond(r),this.#b=new WeakMap,this.#p=new WeakMap,this._setEvent(n),e}_registerEventListeners(){const r={capture:!0,passive:!0},e=[],h=["mouseover","mousedown","mouseup","mouseout"];for(const a of h)e.push(this.#a.addEventListener(a,l=>{this.#n=l},r));const n=["keydown","keyup"];for(const a of n)e.push(this.#a.addEventListener(a,l=>{l.key===X&&(this.#n=l)},r));return e.push(this.#a.addEventListener("focusin",a=>{this.#k=a},r)),e}_setEvent(r){return(r instanceof this.#a.KeyboardEvent||r instanceof this.#a.MouseEvent)&&(this.#n=r),this.#n}_correspond(r){const e=[];this.#w=!1,this.#f=!1;let h;if(this.#o.has(this.#t)){const n=this.#o.get(this.#t);if(n&&n.has(`${r}`)){const a=n.get(`${r}`);h=a.ast,this.#w=a.descendant,this.#f=a.invalidate}}if(h){const n=h.length;for(let a=0;a<n;a++)h[a].collected=!1,h[a].dir=null,h[a].filtered=!1,h[a].find=!1,e[a]=[]}else{let n;try{n=(0,g.parseSelector)(r)}catch(s){this.onError(s)}const{branches:a,info:{hasHasPseudoFunc:l}}=(0,g.walkAST)(n);let o=!!l,u=!1,d=0;h=[];for(const[...s]of a){const t=[];let f=s.shift();if(f&&f.type!==c.COMBINATOR){const b=new Set;for(;f;){if(f.type===c.COMBINATOR){const[m]=s;if(m.type===c.COMBINATOR)throw new DOMException(`Invalid selector ${r}`,c.SYNTAX_ERR);const w=f.name;/^[\s>]$/.test(w)?u=!0:o=!0,t.push({combo:f,leaves:(0,g.sortAST)(b)}),b.clear()}else if(f){let{name:m}=f;m&&typeof m=="string"&&(m=(0,g.unescapeSelector)(m),typeof m=="string"&&m!==f.name&&(f.name=m),/[|:]/.test(m)&&(f.namespace=!0)),b.add(f)}if(s.length)f=s.shift();else{t.push({combo:null,leaves:(0,g.sortAST)(b)}),b.clear();break}}}h.push({branch:t,collected:!1,dir:null,filtered:!1,find:!1}),e[d]=[],d++}let i;this.#o.has(this.#t)?i=this.#o.get(this.#t):i=new Map,i.set(`${r}`,{ast:h,descendant:u,invalidate:o}),this.#o.set(this.#t,i),this.#w=u,this.#f=o}return[h,e]}_createTreeWalker(r){let e;return this.#p.has(r)?e=this.#p.get(r):(e=this.#t.createTreeWalker(r,c.WALKER_FILTER),this.#p.set(r,e)),e}_prepareQuerySelectorWalker(){return this.#m=this._createTreeWalker(this.#e),this.#m}_collectNthChild(r,e,h){const{a:n,b:a,reverse:l,selector:o}=r,{parentNode:u}=e,d=new Set;let i;if(o)if(this.#c.has(o))i=this.#c.get(o);else{const{branches:s,info:t}=(0,g.walkAST)(o);i=s,this.#c.set(o,i),t.hasLogicalPseudoFunc&&(this.#f=!0)}if(u){const s=this.#r;let t=(0,k.traverseNode)(u,s);t=s.firstChild();let f=0;for(;t;)f++,t=s.nextSibling();const b=new Set;if(i)for(t=(0,k.traverseNode)(u,s),t=s.firstChild();t;){if((0,k.isVisible)(t)){let m;for(const w of i)if(m=this._matchLeaves(w,t,h),!m)break;m&&b.add(t)}t=s.nextSibling()}if(n===0){if(a>0&&a<=f){if(b.size){t=(0,k.traverseNode)(u,s),l?t=s.lastChild():t=s.firstChild();let m=0;for(;t;){if(b.has(t)){if(m===a-1){d.add(t);break}m++}l?t=s.previousSibling():t=s.nextSibling()}}else if(!o){t=(0,k.traverseNode)(u,s),l?t=s.lastChild():t=s.firstChild();let m=0;for(;t;){if(m===a-1){d.add(t);break}l?t=s.previousSibling():t=s.nextSibling(),m++}}}}else{let m=a-1;if(n>0)for(;m<0;)m+=n;if(m>=0&&m<f){t=(0,k.traverseNode)(u,s),l?t=s.lastChild():t=s.firstChild();let w=0,p=n>0?0:a-1;for(;t&&(t&&m>=0&&m<f);)b.size?b.has(t)&&(p===m&&(d.add(t),m+=n),n>0?p++:p--):w===m&&(o||d.add(t),m+=n),l?t=s.previousSibling():t=s.nextSibling(),w++}}if(l&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&n+a===1)if(i){let s;for(const t of i)if(s=this._matchLeaves(t,e,h),s)break;s&&d.add(e)}else d.add(e);return d}_collectNthOfType(r,e){const{a:h,b:n,reverse:a}=r,{localName:l,namespaceURI:o,parentNode:u,prefix:d}=e,i=new Set;if(u){const s=this.#r;let t=(0,k.traverseNode)(u,s);t=s.firstChild();let f=0;for(;t;)f++,t=s.nextSibling();if(h===0){if(n>0&&n<=f){t=(0,k.traverseNode)(u,s),a?t=s.lastChild():t=s.firstChild();let b=0;for(;t;){const{localName:m,namespaceURI:w,prefix:p}=t;if(m===l&&p===d&&w===o){if(b===n-1){i.add(t);break}b++}a?t=s.previousSibling():t=s.nextSibling()}}}else{let b=n-1;if(h>0)for(;b<0;)b+=h;if(b>=0&&b<f){t=(0,k.traverseNode)(u,s),a?t=s.lastChild():t=s.firstChild();let m=h>0?0:n-1;for(;t;){const{localName:w,namespaceURI:p,prefix:N}=t;if(w===l&&N===d&&p===o){if(m===b&&(i.add(t),b+=h),b<0||b>=f)break;h>0?m++:m--}a?t=s.previousSibling():t=s.nextSibling()}}}if(a&&i.size>1){const b=[...i];return new Set(b.reverse())}}else e===this.#s&&h+n===1&&i.add(e);return i}_matchAnPlusB(r,e,h,n){const{nth:{a,b:l,name:o},selector:u}=r,d=new Map;if(o?(o==="even"?(d.set("a",2),d.set("b",0)):o==="odd"&&(d.set("a",2),d.set("b",1)),h.indexOf("last")>-1&&d.set("reverse",!0)):(typeof a=="string"&&/-?\d+/.test(a)?d.set("a",a*1):d.set("a",0),typeof l=="string"&&/-?\d+/.test(l)?d.set("b",l*1):d.set("b",0),h.indexOf("last")>-1&&d.set("reverse",!0)),/^nth-(?:last-)?child$/.test(h)){u&&d.set("selector",u);const i=Object.fromEntries(d);return this._collectNthChild(i,e,n)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(r,e,h={}){let n;if(Array.isArray(r)&&r.length){const a=r.map(t=>t),[l]=a,{type:o}=l;let u;o===c.COMBINATOR?u=a.shift():u={name:" ",type:c.COMBINATOR};const d=[];for(;a.length;){const[t]=a,{type:f}=t;if(f===c.COMBINATOR)break;d.push(a.shift())}const i={combo:u,leaves:d};h.dir=v;const s=this._matchCombinator(i,e,h);if(s.size)if(a.length){for(const t of s)if(n=this._matchHasPseudoFunc(a,t,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(r,e,h={}){const{astName:n="",branches:a=[],selector:l="",twigBranches:o=[]}=r;let u;if(n==="has")if(l.includes(":has("))u=null;else{let d;for(const i of a)if(d=this._matchHasPseudoFunc(i,e,h),d)break;d&&(u=e)}else{const d=/^(?:is|where)$/.test(n);h.forgive=d;const i=o.length;let s;for(let t=0;t<i;t++){const f=o[t],b=f.length-1,{leaves:m}=f[b];if(s=this._matchLeaves(m,e,h),s&&b>0){let w=new Set([e]);for(let p=b-1;p>=0;p--){const N=f[p],_=[];h.dir=x;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?s=!0:w=new Set(_);else{s=!1;break}}}if(s)break}n==="not"?s||(u=e):s&&(u=e)}return u??null}_matchPseudoClassSelector(r,e,h={}){const{children:n,name:a}=r,{localName:l,parentNode:o}=e,{forgive:u,warn:d=this.#i}=h,i=new Set;if(c.REG_LOGICAL.test(a)){let s;if(this.#c.has(r))s=this.#c.get(r);else{const{branches:f}=(0,g.walkAST)(r),b=[],m=[];for(const[...w]of f){for(const y of w){const E=(0,g.generateCSS)(y);b.push(E)}const p=[],N=new Set;let _=w.shift();for(;_;)if(_.type===c.COMBINATOR?(p.push({combo:_,leaves:[...N]}),N.clear()):_&&N.add(_),w.length)_=w.shift();else{p.push({combo:null,leaves:[...N]}),N.clear();break}m.push(p)}s={astName:a,branches:f,twigBranches:m,selector:b.join(",")},this.#c.set(r,s)}const t=this._matchLogicalPseudoFunc(s,e,h);t&&i.add(t)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(a)){const[s]=n;return this._matchAnPlusB(s,e,a,h)}else switch(a){case"dir":case"lang":{const s=this.#h.matchSelector(r,e,h,!0);s&&i.add(s);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:s}]=n;if(s)if(e[s])i.add(e);else for(const t in e){const f=e[t];if(f instanceof this.#a.ElementInternals){f?.states?.has(s)&&i.add(e);break}}}break}case"current":case"nth-col":case"nth-last-col":{if(d)throw new DOMException(`Unsupported pseudo-class :${a}()`,c.NOT_SUPPORTED_ERR);break}case"host":case"host-context":break;case"contains":{if(d)throw new DOMException(`Unknown pseudo-class :${a}()`,c.NOT_SUPPORTED_ERR);break}default:if(!u)throw new DOMException(`Unknown pseudo-class :${a}()`,c.SYNTAX_ERR)}else switch(a){case"any-link":case"link":{O.test(l)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(O.test(l)&&e.hasAttribute("href")){const{href:s,origin:t,pathname:f}=new URL(this.#t.URL),b=new URL(e.getAttribute("href"),s);b.origin===t&&b.pathname===f&&i.add(e)}break}case"visited":break;case"hover":{const{target:s,type:t}=this.#n??{};/^(?:mouse|pointer)(?:down|over|up)$/.test(t)&&e.contains(s)&&i.add(e);break}case"active":{const{buttons:s,target:t,type:f}=this.#n??{};/(?:mouse|pointer)down/.test(f)&&s&c.BIT_01&&e.contains(t)&&i.add(e);break}case"target":{const{hash:s}=new URL(this.#t.URL);e.id&&s===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:s}=new URL(this.#t.URL);if(s){const t=s.replace(/^#/,"");let f=this.#t.getElementById(t);for(;f;){if(f===e){i.add(e);break}f=f.parentNode}}break}case"scope":{this.#e.nodeType===c.ELEMENT_NODE?!this.#u&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":{e===this.#t.activeElement&&e.tabIndex>=0&&(0,k.isFocusable)(e)&&i.add(e);break}case"focus-visible":{if(e===this.#t.activeElement&&e.tabIndex>=0){let s;if((0,k.isFocusVisible)(e))s=!0;else{const{target:t,type:f}=this.#n??{},{target:b,relatedTarget:m}=this.#k??{};(/^key(?:down|up)$/.test(f)&&e.contains(t)||m&&(0,k.isFocusVisible)(m)&&e.contains(b))&&(s=!0)}s&&(0,k.isFocusable)(e)&&i.add(e)}break}case"focus-within":{let s,t=this.#t.activeElement;if(t.tabIndex>=0)for(;t;){if(t===e){s=!0;break}t=t.parentNode}s&&(0,k.isFocusable)(e)&&i.add(e);break}case"open":{I.test(l)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{I.test(l)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(M.test(l)||(0,k.isCustomElement)(e,{formAssociated:!0})){if(e.disabled||e.hasAttribute("disabled"))i.add(e);else if(e.localName==="option")o.localName==="optgroup"&&(o.disabled||o.hasAttribute("disabled"))&&i.add(e);else if(e.localName!=="optgroup"){let s,t=o;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const f=this.#r;let b=(0,k.traverseNode)(t,f);for(b=f.firstChild();b&&b.localName!=="legend";)b=f.nextSibling();b&&b.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===c.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s&&i.add(e)}}break}case"enabled":{if((M.test(l)||(0,k.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled")))if(e.localName==="optgroup")i.add(e);else if(e.localName==="option")(o.localName!=="optgroup"||!(o.disabled||o.hasAttribute("disabled")))&&i.add(e);else{let s,t=o;for(;t;)if(t.localName==="fieldset"&&(t.disabled||t.hasAttribute("disabled"))){const f=this.#r;let b=(0,k.traverseNode)(t,f);for(b=f.firstChild();b&&b.localName!=="legend";)b=f.nextSibling();b&&b.contains(e)||(s=!0);break}else{if(t.localName==="form")break;if(t.parentNode?.nodeType===c.ELEMENT_NODE){if(t.parentNode.localName==="form")break;t=t.parentNode}else break}s||i.add(e)}break}case"read-only":{switch(l){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||c.REG_INPUT_TYPE.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(l){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||c.REG_INPUT_TYPE.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,k.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let s;if(e.placeholder?s=e.placeholder:e.hasAttribute("placeholder")&&(s=e.getAttribute("placeholder")),typeof s=="string"&&!/[\r\n]/.test(s)){let t;l==="textarea"?t=e:l==="input"&&(e.hasAttribute("type")?Q.test(e.getAttribute("type"))&&(t=e):t=e),t&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&l==="input"&&e.hasAttribute("type")&&C.test(e.getAttribute("type"))||e.selected&&l==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&l==="input"&&e.type==="checkbox"||l==="progress"&&!e.hasAttribute("value"))i.add(e);else if(l==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const s=e.name;let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;t||(t=this.#t.documentElement);const f=t.getElementsByTagName("input"),b=f.length;let m;for(let w=0;w<b;w++){const p=f[w];if(p.getAttribute("type")==="radio"&&(s?p.getAttribute("name")===s&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(l==="button"&&!(e.hasAttribute("type")&&D.test(e.getAttribute("type")))||l==="input"&&e.hasAttribute("type")&&U.test(e.getAttribute("type"))){let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;if(s){const t=this.#r;let f=(0,k.traverseNode)(s,t);for(f=t.firstChild();f&&s.contains(f);){const b=f.localName;let m;if(b==="button"?m=!(f.hasAttribute("type")&&D.test(f.getAttribute("type"))):b==="input"&&(m=f.hasAttribute("type")&&U.test(f.getAttribute("type"))),m){f===e&&i.add(e);break}f=t.nextNode()}}}else(l==="input"&&e.hasAttribute("type")&&C.test(e.getAttribute("type"))&&e.hasAttribute("checked")||l==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(T.test(l))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(l==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let f;if(!t)f=!0;else for(;t&&e.contains(t)&&!(T.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?f=t.maxLength>=t.value.length:f=!0:f=!1,!f));)t=s.nextNode();f&&i.add(e)}break}case"invalid":{if(T.test(l))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(l==="fieldset"){const s=this.#r;let t=(0,k.traverseNode)(e,s);t=s.firstChild();let f;if(!t)f=!0;else for(;t&&e.contains(t)&&!(T.test(t.localName)&&(t.checkValidity()?t.maxLength>=0?f=t.maxLength>=t.value.length:f=!0:f=!1,!f));)t=s.nextNode();f||i.add(e)}break}case"in-range":{l==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&$.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&i.add(e);break}case"out-of-range":{l==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&$.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let s;if(/^(?:select|textarea)$/.test(l))s=e;else if(l==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||C.test(t)||c.REG_INPUT_TYPE.test(t))&&(s=e)}else s=e;s&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let s;if(/^(?:select|textarea)$/.test(l))s=e;else if(l==="input")if(e.hasAttribute("type")){const t=e.getAttribute("type");(t==="file"||C.test(t)||c.REG_INPUT_TYPE.test(t))&&(s=e)}else s=e;s&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#t.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const s=this.#t.createTreeWalker(e,c.SHOW_ALL);let t=s.firstChild(),f;for(;t&&(f=t.nodeType!==c.ELEMENT_NODE&&t.nodeType!==c.TEXT_NODE,!!f);)t=s.nextSibling();f&&i.add(e)}else i.add(e);break}case"first-child":{(o&&e===o.firstElementChild||e===this.#s)&&i.add(e);break}case"last-child":{(o&&e===o.lastElementChild||e===this.#s)&&i.add(e);break}case"only-child":{(o&&e===o.firstElementChild&&e===o.lastElementChild||e===this.#s)&&i.add(e);break}case"first-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s&&i.add(s)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(o){const[s]=this._collectNthOfType({a:0,b:1},e);if(s===e){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t===e&&i.add(e)}}else e===this.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||l.includes("-")?(0,k.isCustomElement)(e)&&i.add(e):(e instanceof this.#a.HTMLElement||e instanceof this.#a.SVGElement)&&i.add(e);break}case"popover-open":{e.popover&&(0,k.isVisible)(e)&&i.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d)throw new DOMException(`Unsupported pseudo-element ::${a}`,c.NOT_SUPPORTED_ERR);break}case"autofill":case"blank":case"buffering":case"current":case"fullscreen":case"future":case"modal":case"muted":case"past":case"paused":case"picture-in-picture":case"playing":case"seeking":case"stalled":case"user-invalid":case"user-valid":case"volume-locked":case"-webkit-autofill":{if(d)throw new DOMException(`Unsupported pseudo-class :${a}`,c.NOT_SUPPORTED_ERR);break}default:if(a.startsWith("-webkit-")){if(d)throw new DOMException(`Unsupported pseudo-class :${a}`,c.NOT_SUPPORTED_ERR)}else if(!u)throw new DOMException(`Unknown pseudo-class :${a}`,c.SYNTAX_ERR)}return i}_matchShadowHostPseudoClass(r,e){const{children:h,name:n}=r;let a;if(Array.isArray(h)){const{branches:l}=(0,g.walkAST)(h[0]),[o]=l,[...u]=o,{host:d}=e;if(n==="host"){let i;for(const s of u){const{type:t}=s;if(t===c.COMBINATOR){const f=(0,g.generateCSS)(r);throw new DOMException(`Invalid selector ${f}`,c.SYNTAX_ERR)}if(i=this._matchSelector(s,d).has(d),!i)break}i&&(a=e)}else if(n==="host-context"){let i=d,s;for(;i;){for(const t of u){const{type:f}=t;if(f===c.COMBINATOR){const b=(0,g.generateCSS)(r);throw new DOMException(`Invalid selector ${b}`,c.SYNTAX_ERR)}if(s=this._matchSelector(t,i).has(i),!s)break}if(s)break;i=i.parentNode}s&&(a=e)}}else if(n==="host")a=e;else throw new DOMException(`Invalid selector :${n}`,c.SYNTAX_ERR);return a??null}_matchSelector(r,e,h){const{type:n}=r,a=new Set;if(r.name===c.EMPTY)return a;const l=(0,g.unescapeSelector)(r.name);if(typeof l=="string"&&l!==r.name&&(r.name=l),e.nodeType===c.ELEMENT_NODE)switch(n){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(l,h);break}case c.ID_SELECTOR:{e.id===l&&a.add(e);break}case c.CLASS_SELECTOR:{e.classList.contains(l)&&a.add(e);break}case c.PS_CLASS_SELECTOR:return this._matchPseudoClassSelector(r,e,h);default:{const o=this.#h.matchSelector(r,e,h,!0);o&&a.add(o)}}else if(this.#u&&n===c.PS_CLASS_SELECTOR&&e.nodeType===c.DOCUMENT_FRAGMENT_NODE){if(l!=="has"&&c.REG_LOGICAL.test(l))return this._matchPseudoClassSelector(r,e,h);if(P.test(l)){const o=this._matchShadowHostPseudoClass(r,e,h);o&&a.add(o)}}return a}_matchLeaves(r,e,h){let n,a;if(this.#f?a=this.#b.get(r):a=this.#N.get(r),a&&a.has(e)){const{matched:l}=a.get(e);n=l}if(typeof n!="boolean"){let l=!0;e.nodeType===c.ELEMENT_NODE&&/^(?:button|fieldset|form|input|select|textarea)$/.test(e.localName)&&(l=!1);for(const o of r){switch(o.type){case c.ATTR_SELECTOR:case c.ID_SELECTOR:{l=!1;break}case c.PS_CLASS_SELECTOR:{/^(?:(?:any-)?link|defined|dir)$/.test(o.name)&&(l=!1);break}default:}if(n=this._matchSelector(o,e,h).has(e),!n)break}l&&(a||(a=new WeakMap),a.set(e,{matched:n}),this.#f?this.#b.set(r,a):this.#N.set(r,a))}return!!n}_matchHTMLCollection(r,e={}){const{compound:h,filterLeaves:n}=e,a=new Set,l=r.length;if(l)if(h)for(let o=0;o<l;o++){const u=r[o];this._matchLeaves(n,u,e)&&a.add(u)}else{const o=[].slice.call(r);return new Set(o)}return a}_findDescendantNodes(r,e,h){const[n,...a]=r,l=a.length>0,{type:o}=n,u=(0,g.unescapeSelector)(n.name);typeof u=="string"&&u!==n.name&&(n.name=u);let d=new Set,i=!1;if(this.#u)i=!0;else switch(o){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(u,h);break}case c.ID_SELECTOR:{if(this.#s.nodeType===c.ELEMENT_NODE)i=!0;else{const s=this.#s.getElementById(u);s&&s!==e&&e.contains(s)&&(l?this._matchLeaves(a,s,h)&&d.add(s):d.add(s))}break}case c.CLASS_SELECTOR:{const s=e.getElementsByClassName(u);d=this._matchHTMLCollection(s,{compound:l,filterLeaves:a});break}case c.TYPE_SELECTOR:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(u)){const s=e.getElementsByTagName(u);d=this._matchHTMLCollection(s,{compound:l,filterLeaves:a})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(r,e,h={}){const{combo:n,leaves:a}=r,{name:l}=n,{parentNode:o}=e,{dir:u}=h,d=new Set;if(u===v)switch(l){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(a,i,h)&&d.add(i);break}case"~":{if(o){const i=this._createTreeWalker(o);let s=(0,k.traverseNode)(e,i);for(s=i.nextSibling();s;)this._matchLeaves(a,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let s=(0,k.traverseNode)(e,i);for(s=i.firstChild();s;)this._matchLeaves(a,s,h)&&d.add(s),s=i.nextSibling();break}case" ":default:{const{nodes:i,pending:s}=this._findDescendantNodes(a,e);if(i.size)return i;if(s){const t=this._createTreeWalker(e);let f=(0,k.traverseNode)(e,t);for(f=t.nextNode();f&&e.contains(f);)this._matchLeaves(a,f,h)&&d.add(f),f=t.nextNode()}}}else switch(l){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(a,i,h)&&d.add(i);break}case"~":{if(o){const i=this._createTreeWalker(o);let s=(0,k.traverseNode)(o,i);for(s=i.firstChild();s&&s!==e;)this._matchLeaves(a,s,h)&&d.add(s),s=i.nextSibling()}break}case">":{o&&this._matchLeaves(a,o,h)&&d.add(o);break}case" ":default:{const i=[];let s=o;for(;s;)this._matchLeaves(a,s,h)&&i.push(s),s=s.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(r,e){const{node:h}=e,n=this.#m;let a=(0,k.traverseNode)(h,n),l;if(a)for((a.nodeType!==c.ELEMENT_NODE||a===h&&a!==this.#s)&&(a=n.nextNode());a;){if(this._matchLeaves(r,a,{warn:this.#i})){l=a;break}a=n.nextNode()}return l??null}_matchSelf(r){const e=[],h=this._matchLeaves(r,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(r,e={}){const{complex:h}=e,n=[];let a=this._matchLeaves(r,this.#e,{warn:this.#i}),l=!1;if(a&&(n.push(this.#e),l=!0),!a||h){let o=this.#e.parentNode;for(;o&&(a=this._matchLeaves(r,o,{warn:this.#i}),a&&(n.push(o),l=!0),o.parentNode);)o=o.parentNode}return[n,l]}_findFirst(r){const e=[],h=this._findNode(r,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(r,e={}){const{complex:h,compound:n,filterLeaves:a,targetType:l}=e;let o=[],u=!1,d=!1;const i=r.length;if(i)if(this.#e.nodeType===c.ELEMENT_NODE)for(let s=0;s<i;s++){const t=r[s];if(t!==this.#e&&(this.#e.contains(t)||t.contains(this.#e))){if(n){if(this._matchLeaves(a,t,{warn:this.#i})&&(o.push(t),u=!0,l===c.TARGET_FIRST))break}else if(o.push(t),u=!0,l===c.TARGET_FIRST)break}}else if(h)if(n)for(let s=0;s<i;s++){const t=r[s];if(this._matchLeaves(a,t,{warn:this.#i})&&(o.push(t),u=!0,l===c.TARGET_FIRST))break}else o=[].slice.call(r),u=!0,d=!0;else if(n)for(let s=0;s<i;s++){const t=r[s];if(this._matchLeaves(a,t,{warn:this.#i})&&(o.push(t),u=!0,l===c.TARGET_FIRST))break}else o=[].slice.call(r),u=!0,d=!0;return[o,u,d]}_findEntryNodes(r,e,h){const{leaves:n}=r,[a,...l]=n,o=l.length>0,{name:u,type:d}=a;let i=[],s=!1,t=!1,f=!1;switch(d){case c.PS_ELEMENT_SELECTOR:{this.#h.matchPseudoElementSelector(u,{warn:this.#i});break}case c.ID_SELECTOR:{if(e===c.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:h});else if(e===c.TARGET_FIRST&&this.#s.nodeType!==c.ELEMENT_NODE){const b=this.#s.getElementById(u);b&&(o?this._matchLeaves(l,b,{warn:this.#i})&&(i.push(b),t=!0):(i.push(b),t=!0))}else e===c.TARGET_FIRST?[i,t]=this._findFirst(n):f=!0;break}case c.CLASS_SELECTOR:{if(e===c.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:h});else if(this.#s.nodeType===c.DOCUMENT_NODE){const b=this.#s.getElementsByClassName(u);b.length&&([i,t,s]=this._findFromHTMLCollection(b,{complex:h,compound:o,filterLeaves:l,targetType:e}))}else e===c.TARGET_FIRST?[i,t]=this._findFirst(n):f=!0;break}case c.TYPE_SELECTOR:{if(e===c.TARGET_SELF)[i,t]=this._matchSelf(n);else if(e===c.TARGET_LINEAL)[i,t]=this._findLineal(n,{complex:h});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===c.DOCUMENT_NODE&&!/[*|]/.test(u)){const b=this.#s.getElementsByTagName(u);b.length&&([i,t,s]=this._findFromHTMLCollection(b,{complex:h,compound:o,filterLeaves:l,targetType:e}))}else e===c.TARGET_FIRST?[i,t]=this._findFirst(n):f=!0;break}default:if(e!==c.TARGET_LINEAL&&P.test(u)){if(this.#u&&this.#e.nodeType===c.DOCUMENT_FRAGMENT_NODE){const b=this._matchShadowHostPseudoClass(a,this.#e);b&&(i.push(b),t=!0)}}else e===c.TARGET_SELF?[i,t]=this._matchSelf(n):e===c.TARGET_LINEAL?[i,t]=this._findLineal(n,{complex:h}):e===c.TARGET_FIRST?[i,t]=this._findFirst(n):f=!0}return{collected:s,compound:o,filtered:t,nodes:i,pending:f}}_collectNodes(r){const e=this.#l.values();if(r===c.TARGET_ALL||r===c.TARGET_FIRST){const h=new Set;let n=0;for(const{branch:a}of e){const l=a.length,o=l>1,u=a[0];let d,i;if(o){const{combo:w,leaves:[{name:p,type:N}]}=u,_=a[l-1],{leaves:[{name:y,type:E}]}=_;if(E===c.PS_ELEMENT_SELECTOR||E===c.ID_SELECTOR)d=x,i=_;else if(N===c.PS_ELEMENT_SELECTOR||N===c.ID_SELECTOR)d=v,i=u;else if(r===c.TARGET_ALL)if(p==="*"&&N===c.TYPE_SELECTOR)d=x,i=_;else if(y==="*"&&E===c.TYPE_SELECTOR)d=v,i=u;else if(l===2){const{name:A}=w;/^[+~]$/.test(A)?(d=x,i=_):(d=v,i=u)}else d=v,i=u;else if(y==="*"&&E===c.TYPE_SELECTOR)d=v,i=u;else if(p==="*"&&N===c.TYPE_SELECTOR)d=x,i=_;else{let A;for(const{combo:L,leaves:[W]}of a){const{name:G,type:H}=W;if(H===c.PS_CLASS_SELECTOR&&G==="dir"){A=!1;break}if(!A&&L){const{name:z}=L;/^[+~]$/.test(z)&&(A=!0)}}A?(d=v,i=u):(d=x,i=_)}}else d=x,i=u;const{collected:s,compound:t,filtered:f,nodes:b,pending:m}=this._findEntryNodes(i,r,o);b.length?(this.#l[n].find=!0,this.#d[n]=b):m&&h.add(new Map([["index",n],["twig",i]])),this.#l[n].collected=s,this.#l[n].dir=d,this.#l[n].filtered=f||!t,n++}if(h.size){let a,l;this.#e!==this.#s&&this.#e.nodeType===c.ELEMENT_NODE?(a=this.#e,l=this.#m):(a=this.#s,l=this.#r);let o=(0,k.traverseNode)(a,l);for(;o;){let u=!1;if(this.#e.nodeType===c.ELEMENT_NODE?o===this.#e?u=!0:u=this.#e.contains(o):u=!0,u)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,o,{warn:this.#i})){const t=d.get("index");this.#l[t].filtered=!0,this.#l[t].find=!0,this.#d[t].push(o)}}o!==l.currentNode&&(o=(0,k.traverseNode)(o,l)),o=l.nextNode()}}}else{let h=0;for(const{branch:n}of e){const a=n[n.length-1],l=n.length>1,{compound:o,filtered:u,nodes:d}=this._findEntryNodes(a,r,l);d.length&&(this.#l[h].find=!0,this.#d[h]=d),this.#l[h].dir=x,this.#l[h].filtered=u||!o,h++}}return[this.#l,this.#d]}_getCombinedNodes(r,e,h){const n=[];for(const a of e){const l=this._matchCombinator(r,a,{dir:h,warn:this.#i});l.size&&n.push(...l)}return n.length?new Set(n):new Set}_matchNodeNext(r,e,h){const{combo:n,index:a}=h,{combo:l,leaves:o}=r[a],u={combo:n,leaves:o},d=this._getCombinedNodes(u,e,v);let i;if(d.size)if(a===r.length-1){const[s]=(0,k.sortNodes)(d);i=s}else i=this._matchNodeNext(r,d,{combo:l,index:a+1});return i??null}_matchNodePrev(r,e,h){const{index:n}=h,a=r[n],l=new Set([e]),o=this._getCombinedNodes(a,l,x);let u;if(o.size){if(n===0)u=e;else for(const d of o)if(this._matchNodePrev(r,d,{index:n-1}))return e}return u??null}find(r){(r===c.TARGET_ALL||r===c.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(r),n=e.length;let a,l=new Set;for(let o=0;o<n;o++){const{branch:u,collected:d,dir:i,find:s}=e[o],t=u.length;if(t&&s){const f=h[o],b=f.length,m=t-1;if(m===0)if((r===c.TARGET_ALL||r===c.TARGET_FIRST)&&this.#e.nodeType===c.ELEMENT_NODE)for(let w=0;w<b;w++){const p=f[w];if(p!==this.#e&&this.#e.contains(p)&&(l.add(p),r!==c.TARGET_ALL))break}else if(r===c.TARGET_ALL)if(l.size){const w=[...l];l=new Set([...w,...f]),a=!0}else l=new Set(f);else{const[w]=f;l.add(w)}else if(r===c.TARGET_ALL)if(i===v){let{combo:w}=u[0];for(const p of f){let N=new Set([p]);for(let _=1;_<t;_++){const{combo:y,leaves:E}=u[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(l.size){const L=[...l];l=new Set([...L,...N]),a=!0}else l=N;else w=y;else break}}}else for(const w of f){let p=new Set([w]);for(let N=m-1;N>=0;N--){const _=u[N];if(p=this._getCombinedNodes(_,p,i),p.size)N===0&&(l.add(w),t>1&&l.size>1&&(a=!0));else break}}else if(r===c.TARGET_FIRST&&i===v){const{combo:w}=u[0];let p;for(const N of f)if(p=this._matchNodeNext(u,new Set([N]),{combo:w,index:1}),p){l.add(p);break}if(!p&&!d){const{leaves:N}=u[0],[_]=f;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(u,new Set([y]),{combo:w,index:1}),p){l.add(p);break}y=this._findNode(N,{node:y})}}}else{let w;for(const p of f)if(w=this._matchNodePrev(u,p,{index:m-1}),w){l.add(p);break}if(!w&&!d&&r===c.TARGET_FIRST){const{leaves:p}=u[m],[N]=f;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(u,_,{index:m-1}),w){l.add(_);break}_=this._findNode(p,{node:_})}}}}}return r===c.TARGET_FIRST?(l.delete(this.#e),l.size>1&&(l=new Set((0,k.sortNodes)(l)))):r===c.TARGET_ALL&&(l.delete(this.#e),a&&l.size>1&&(l=new Set((0,k.sortNodes)(l)))),l}}0&&(module.exports={Finder});
//# sourceMappingURL=finder.js.map

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

var y=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var A=(x,t)=>{for(var e in t)y(x,e,{get:t[e],enumerable:!0})},S=(x,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of T(t))!L.call(x,l)&&l!==e&&y(x,l,{get:()=>t[l],enumerable:!(s=N(t,l))||s.enumerable});return x};var _=x=>S(y({},"__esModule",{value:!0}),x);var O={};A(O,{Matcher:()=>R});module.exports=_(O);var b=require("./parser.js"),$=require("./utility.js"),a=require("./constant.js");class R{matchPseudoElementSelector(t,e={}){if(!t||typeof t!="string")throw new TypeError(`Unexpected type ${(0,$.getType)(t)}`);const{forgive:s,warn:l}=e;switch(t){case"after":case"backdrop":case"before":case"cue":case"cue-region":case"first-letter":case"first-line":case"file-selector-button":case"marker":case"placeholder":case"selection":case"target-text":{if(l)throw new DOMException(`Unsupported pseudo-element ::${t}`,a.NOT_SUPPORTED_ERR);break}case"part":case"slotted":{if(l)throw new DOMException(`Unsupported pseudo-element ::${t}()`,a.NOT_SUPPORTED_ERR);break}default:if(t.startsWith("-webkit-")){if(l)throw new DOMException(`Unsupported pseudo-element ::${t}`,a.NOT_SUPPORTED_ERR)}else if(!s)throw new DOMException(`Unknown pseudo-element ::${t}`,a.SYNTAX_ERR)}}_matchAttributeSelector(t,e){const{flags:s,matcher:l,name:n,value:m}=t;if(typeof s=="string"&&!/^[is]$/i.test(s)){const g=(0,b.generateCSS)(t);throw new DOMException(`Invalid selector ${g}`,a.SYNTAX_ERR)}const{attributes:d}=e;let w;if(d&&d.length){const g=e.ownerDocument.contentType;let o;g==="text/html"?typeof s=="string"&&/^s$/i.test(s)?o=!1:o=!0:typeof s=="string"&&/^i$/i.test(s)?o=!0:o=!1;let h=(0,b.unescapeSelector)(n.name);o&&(h=h.toLowerCase());const f=new Set;if(h.indexOf("|")>-1){const{prefix:c,localName:u}=(0,b.parseAstName)(h);for(const i of d){let{name:r,value:p}=i;switch(o&&(r=r.toLowerCase(),p=p.toLowerCase()),c){case"":{u===r&&f.add(p);break}case"*":{r.indexOf(":")>-1?r.endsWith(`:${u}`)&&f.add(p):u===r&&f.add(p);break}default:if(r.indexOf(":")>-1){const[E,k]=r.split(":");if(E==="xml"&&k==="lang")continue;c===E&&u===k&&(0,$.isNamespaceDeclared)(c,e)&&f.add(p)}}}}else for(let{name:c,value:u}of d)if(o&&(c=c.toLowerCase(),u=u.toLowerCase()),c.indexOf(":")>-1){const[i,r]=c.split(":");if(i==="xml"&&r==="lang")continue;h===r&&f.add(u)}else h===c&&f.add(u);if(f.size){const{name:c,value:u}=m??{};let i;switch(c?o?i=c.toLowerCase():i=c:u?o?i=u.toLowerCase():i=u:u===""&&(i=u),l){case"=":{typeof i=="string"&&f.has(i)&&(w=e);break}case"~=":{if(i&&typeof i=="string"){for(const r of f)if(new Set(r.split(/\s+/)).has(i)){w=e;break}}break}case"|=":{if(i&&typeof i=="string"){let r;for(const p of f)if(p===i||p.startsWith(`${i}-`)){r=p;break}r&&(w=e)}break}case"^=":{if(i&&typeof i=="string"){let r;for(const p of f)if(p.startsWith(`${i}`)){r=p;break}r&&(w=e)}break}case"$=":{if(i&&typeof i=="string"){let r;for(const p of f)if(p.endsWith(`${i}`)){r=p;break}r&&(w=e)}break}case"*=":{if(i&&typeof i=="string"){let r;for(const p of f)if(p.includes(`${i}`)){r=p;break}r&&(w=e)}break}case null:default:w=e}}}return w??null}_matchTypeSelector(t,e,s={}){const l=(0,b.unescapeSelector)(t.name),{localName:n,namespaceURI:m,prefix:d}=e,{forgive:w}=s;let{prefix:g,localName:o}=(0,b.parseAstName)(l,e);e.ownerDocument.contentType==="text/html"&&a.REG_TAG_NAME.test(n)&&(g=g.toLowerCase(),o=o.toLowerCase());let h,f;n.indexOf(":")>-1?[h,f]=n.split(":"):(h=d||"",f=n);let c;switch(g){case"":{!h&&!m&&(o==="*"||o===f)&&(c=e);break}case"*":{(o==="*"||o===f)&&(c=e);break}default:{const u=e.lookupNamespaceURI(g),i=e.lookupNamespaceURI(h);if(u===i&&g===h)(o==="*"||o===f)&&(c=e);else if(!w&&!u)throw new DOMException(`Undeclared namespace ${g}`,a.SYNTAX_ERR)}}return c??null}_matchDirectionPseudoClass(t,e){const s=(0,$.getDirectionality)(e);let l;return t.name===s&&(l=e),l??null}_matchLanguagePseudoClass(t,e){if(t.name===a.EMPTY)return null;const s=(0,b.unescapeSelector)(t.name);typeof s=="string"&&s!==t.name&&(t.name=s);let l;if(s==="*")if(e.hasAttribute("lang"))e.getAttribute("lang")&&(l=e);else{let n=e.parentNode;for(;n&&n.nodeType===a.ELEMENT_NODE;){if(n.hasAttribute("lang")){n.getAttribute("lang")&&(l=e);break}n=n.parentNode}}else if(s&&a.REG_LANG.test(s)){let n;if(s.indexOf("-")>-1){const[m,d,...w]=s.split("-");let g;m==="*"?g=`${a.ALPHA_NUM}${a.LANG_PART}`:g=`${m}${a.LANG_PART}`;const o=`-${d}${a.LANG_PART}`,h=w.length;let f="";if(h)for(let c=0;c<h;c++)f+=`-${w[c]}${a.LANG_PART}`;n=new RegExp(`^${g}${o}${f}$`,"i")}else n=new RegExp(`^${s}${a.LANG_PART}$`,"i");if(e.hasAttribute("lang"))n.test(e.getAttribute("lang"))&&(l=e);else{let m=e.parentNode;for(;m&&m.nodeType===a.ELEMENT_NODE;){if(m.hasAttribute("lang")){const d=m.getAttribute("lang");n.test(d)&&(l=e);break}m=m.parentNode}}}return l??null}matchSelector(t,e,s={},l=!1){if(!l){if(!t||!t.type)throw new TypeError(`Unexpected ast type ${(0,$.getType)(t)}`);if(!e||!e.nodeType)throw new TypeError(`Unexpected node type ${(0,$.getType)(e)}`);if(e.nodeType!==a.ELEMENT_NODE)throw new TypeError(`Unexpected node ${e.nodeName}`)}let n;switch(t.type){case a.SELECTOR_ATTR:{n=this._matchAttributeSelector(t,e);break}case a.SELECTOR_TYPE:{n=this._matchTypeSelector(t,e,s??{});break}default:{const{children:[m],name:d}=t;d==="dir"?n=this._matchDirectionPseudoClass(m,e):d==="lang"&&(n=this._matchLanguagePseudoClass(m,e))}}return n}}0&&(module.exports={Matcher});
var y=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var S=(x,t)=>{for(var e in t)y(x,e,{get:t[e],enumerable:!0})},A=(x,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of N(t))!L.call(x,l)&&l!==e&&y(x,l,{get:()=>t[l],enumerable:!(s=T(t,l))||s.enumerable});return x};var O=x=>A(y({},"__esModule",{value:!0}),x);var C={};S(C,{Matcher:()=>R});module.exports=O(C);var b=require("./parser.js"),$=require("./utility.js"),i=require("./constant.js");class R{matchPseudoElementSelector(t,e={}){if(!t||typeof t!="string")throw new TypeError(`Unexpected type ${(0,$.getType)(t)}`);const{forgive:s,warn:l}=e;switch(t){case"after":case"backdrop":case"before":case"cue":case"cue-region":case"first-letter":case"first-line":case"file-selector-button":case"marker":case"placeholder":case"selection":case"target-text":{if(l)throw new DOMException(`Unsupported pseudo-element ::${t}`,i.NOT_SUPPORTED_ERR);break}case"part":case"slotted":{if(l)throw new DOMException(`Unsupported pseudo-element ::${t}()`,i.NOT_SUPPORTED_ERR);break}default:if(t.startsWith("-webkit-")){if(l)throw new DOMException(`Unsupported pseudo-element ::${t}`,i.NOT_SUPPORTED_ERR)}else if(!s)throw new DOMException(`Unknown pseudo-element ::${t}`,i.SYNTAX_ERR)}}_matchAttributeSelector(t,e){const{flags:s,matcher:l,name:p,value:d}=t;if(typeof s=="string"&&!/^[is]$/i.test(s)){const w=(0,b.generateCSS)(t);throw new DOMException(`Invalid selector ${w}`,i.SYNTAX_ERR)}const{attributes:m}=e;let h;if(m&&m.length){const w=e.ownerDocument.contentType;let n;w==="text/html"?typeof s=="string"&&/^s$/i.test(s)?n=!1:n=!0:typeof s=="string"&&/^i$/i.test(s)?n=!0:n=!1;let g=(0,b.unescapeSelector)(p.name);n&&(g=g.toLowerCase());const f=new Set;if(g.indexOf("|")>-1){const{prefix:o,localName:c}=(0,b.parseAstName)(g);for(const a of m){let{name:r,value:u}=a;switch(n&&(r=r.toLowerCase(),u=u.toLowerCase()),o){case"":{c===r&&f.add(u);break}case"*":{r.indexOf(":")>-1?r.endsWith(`:${c}`)&&f.add(u):c===r&&f.add(u);break}default:if(r.indexOf(":")>-1){const[k,E]=r.split(":");if(k==="xml"&&E==="lang")continue;o===k&&c===E&&(0,$.isNamespaceDeclared)(o,e)&&f.add(u)}}}}else for(let{name:o,value:c}of m)if(n&&(o=o.toLowerCase(),c=c.toLowerCase()),o.indexOf(":")>-1){const[a,r]=o.split(":");if(a==="xml"&&r==="lang")continue;g===r&&f.add(c)}else g===o&&f.add(c);if(f.size){const{name:o,value:c}=d??{};let a;switch(o?n?a=o.toLowerCase():a=o:c?n?a=c.toLowerCase():a=c:c===""&&(a=c),l){case"=":{typeof a=="string"&&f.has(a)&&(h=e);break}case"~=":{if(a&&typeof a=="string"){for(const r of f)if(new Set(r.split(/\s+/)).has(a)){h=e;break}}break}case"|=":{if(a&&typeof a=="string"){let r;for(const u of f)if(u===a||u.startsWith(`${a}-`)){r=u;break}r&&(h=e)}break}case"^=":{if(a&&typeof a=="string"){let r;for(const u of f)if(u.startsWith(`${a}`)){r=u;break}r&&(h=e)}break}case"$=":{if(a&&typeof a=="string"){let r;for(const u of f)if(u.endsWith(`${a}`)){r=u;break}r&&(h=e)}break}case"*=":{if(a&&typeof a=="string"){let r;for(const u of f)if(u.includes(`${a}`)){r=u;break}r&&(h=e)}break}case null:default:h=e}}}return h??null}_matchTypeSelector(t,e,s={}){const l=(0,b.unescapeSelector)(t.name),{localName:p,namespaceURI:d,prefix:m}=e,{forgive:h}=s;let{prefix:w,localName:n}=(0,b.parseAstName)(l,e);e.ownerDocument.contentType==="text/html"&&/[A-Z][\\w-]*/i.test(p)&&(w=w.toLowerCase(),n=n.toLowerCase());let g,f;p.indexOf(":")>-1?[g,f]=p.split(":"):(g=m||"",f=p);let o;switch(w){case"":{!g&&!d&&(n==="*"||n===f)&&(o=e);break}case"*":{(n==="*"||n===f)&&(o=e);break}default:{const c=e.lookupNamespaceURI(w),a=e.lookupNamespaceURI(g);if(c===a&&w===g)(n==="*"||n===f)&&(o=e);else if(!h&&!c)throw new DOMException(`Undeclared namespace ${w}`,i.SYNTAX_ERR)}}return o??null}_matchDirectionPseudoClass(t,e){const s=(0,$.getDirectionality)(e);let l;return t.name===s&&(l=e),l??null}_matchLanguagePseudoClass(t,e){if(t.name===i.EMPTY)return null;const s=(0,b.unescapeSelector)(t.name);typeof s=="string"&&s!==t.name&&(t.name=s);let l;if(s==="*")if(e.hasAttribute("lang"))e.getAttribute("lang")&&(l=e);else{let p=e.parentNode;for(;p&&p.nodeType===i.ELEMENT_NODE;){if(p.hasAttribute("lang")){p.getAttribute("lang")&&(l=e);break}p=p.parentNode}}else if(s&&new RegExp(`^(?:\\*-)?${i.ALPHA_NUM}${i.LANG_PART}$`,"i").test(s)){let d;if(s.indexOf("-")>-1){const[m,h,...w]=s.split("-");let n;m==="*"?n=`${i.ALPHA_NUM}${i.LANG_PART}`:n=`${m}${i.LANG_PART}`;const g=`-${h}${i.LANG_PART}`,f=w.length;let o="";if(f)for(let c=0;c<f;c++)o+=`-${w[c]}${i.LANG_PART}`;d=new RegExp(`^${n}${g}${o}$`,"i")}else d=new RegExp(`^${s}${i.LANG_PART}$`,"i");if(e.hasAttribute("lang"))d.test(e.getAttribute("lang"))&&(l=e);else{let m=e.parentNode;for(;m&&m.nodeType===i.ELEMENT_NODE;){if(m.hasAttribute("lang")){const h=m.getAttribute("lang");d.test(h)&&(l=e);break}m=m.parentNode}}}return l??null}matchSelector(t,e,s={},l=!1){if(!l){if(!t||!t.type)throw new TypeError(`Unexpected ast type ${(0,$.getType)(t)}`);if(!e||!e.nodeType)throw new TypeError(`Unexpected node type ${(0,$.getType)(e)}`);if(e.nodeType!==i.ELEMENT_NODE)throw new TypeError(`Unexpected node ${e.nodeName}`)}let p;switch(t.type){case i.ATTR_SELECTOR:{p=this._matchAttributeSelector(t,e);break}case i.TYPE_SELECTOR:{p=this._matchTypeSelector(t,e,s??{});break}default:{const{children:[d],name:m}=t;m==="dir"?p=this._matchDirectionPseudoClass(d,e):m==="lang"&&(p=this._matchLanguagePseudoClass(d,e))}}return p}}0&&(module.exports={Matcher});
//# sourceMappingURL=matcher.js.map

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

var g=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var m=(s,t)=>{for(var r in t)g(s,r,{get:t[r],enumerable:!0})},$=(s,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!_.call(s,n)&&n!==r&&g(s,n,{get:()=>t[n],enumerable:!(o=O(t,n))||o.enumerable});return s};var w=s=>$(g({},"__esModule",{value:!0}),s);var A={};m(A,{generateCSS:()=>x.generate,parseAstName:()=>b,parseSelector:()=>E,preprocess:()=>S,sortAST:()=>L,unescapeSelector:()=>y,walkAST:()=>I});module.exports=w(A);var h=require("css-tree"),u=require("./utility.js"),e=require("./constant.js"),x=require("css-tree");const y=(s="")=>{if(typeof s=="string"&&s.indexOf("\\",0)>=0){const t=s.split("\\"),r=t.length;for(let o=1;o<r;o++){let n=t[o];if(n===""&&o===r-1)n=e.U_FFFD;else{const c=e.REG_HEX.exec(n);if(c){const[,f]=c;let a;try{const i=parseInt("D800",e.HEX),p=parseInt("DFFF",e.HEX),d=parseInt(f,e.HEX);d===0||d>=i&&d<=p?a=e.U_FFFD:a=String.fromCodePoint(d)}catch{a=e.U_FFFD}let l="";n.length>f.length&&(l=n.substring(f.length)),n=`${a}${l}`}else/^[\n\r\f]/.test(n)&&(n="\\"+n)}t[o]=n}s=t.join("")}return s},S=(...s)=>{if(!s.length)throw new TypeError("1 argument required, but only 0 present.");let[t]=s;if(typeof t=="string"){let r=0;for(;r>=0&&(r=t.indexOf("#",r),!(r<0));){const o=t.substring(0,r+1);let n=t.substring(r+1);if(/^\d$/.test(n.substring(0,1)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);const c=n.codePointAt(0);if(c===e.BIT_HYPHEN){if(/^\d$/.test(n.substring(1,2)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR)}else if(c>e.BIT_FFFF){const f=`\\${c.toString(e.HEX)} `;n.length===e.DUO?n=f:n=`${f}${n.substring(e.DUO)}`}t=`${o}${n}`,r++}t=t.replace(/\f|\r\n?/g,`
`).replace(/[\0\uD800-\uDFFF]|\\$/g,e.U_FFFD)}else if(t==null)t=(0,u.getType)(t).toLowerCase();else if(Array.isArray(t))t=t.join(",");else if(Object.prototype.hasOwnProperty.call(t,"toString"))t=t.toString();else throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);return t},E=s=>{if(s=S(s),e.REG_INVALID_SELECTOR.test(s))throw new DOMException(`Invalid selector ${s}`,e.SYNTAX_ERR);let t;try{const r=(0,h.parse)(s,{context:"selectorList",parseCustomProperty:!0});t=(0,h.toPlainObject)(r)}catch(r){const{message:o}=r;if(o==="Identifier is expected"&&e.REG_LANG_QUOTED.test(s)){const[,n,c]=e.REG_LANG_QUOTED.exec(s),f=c.replaceAll("*","\\*").replace(/^"/,"").replace(/"$/,"");let a=n.replace(c,f);a===":lang()"&&(a=`:lang(${e.EMPTY})`),t=E(s.replace(n,a))}else if(/^(?:Identifier|Selector) is expected$/.test(o)&&e.REG_LOGICAL_EMPTY.test(s)){const[,n,c]=e.REG_LOGICAL_EMPTY.exec(s);t=E(s.replace(n,`:${c}(${e.EMPTY})`))}else if(/^(?:"\]"|Attribute selector [()\s,=~^$*|]+) is expected$/.test(o)&&!s.endsWith("]")){const n=s.lastIndexOf("["),c=s.substring(n);c.includes('"')?c.match(/"/g).length%2?t=E(`${s}"]`):t=E(`${s}]`):t=E(`${s}]`)}else if(o==='")" is expected'&&!s.endsWith(")"))t=E(`${s})`);else throw new DOMException(o,e.SYNTAX_ERR)}return t},I=(s={})=>{const t=new Set,r=new Map;return(0,h.walk)(s,{enter:n=>{switch(n.type){case e.SELECTOR:{t.add(n.children);break}case e.SELECTOR_PSEUDO_CLASS:{e.REG_LOGICAL_PSEUDO.test(n.name)&&(r.set("hasNestedSelector",!0),r.set("hasLogicalPseudoFunc",!0),n.name==="has"&&r.set("hasHasPseudoFunc",!0));break}case e.SELECTOR_PSEUDO_ELEMENT:{e.REG_SHADOW_PSEUDO.test(n.name)&&r.set("hasNestedSelector",!0);break}case e.NTH:{n.selector&&r.set("hasNestedSelector",!0);break}default:}}}),r.get("hasNestedSelector")&&(0,h.findAll)(s,(n,c,f)=>{if(f){if(n.type===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(n.name)){const a=f.filter(l=>{const{name:i,type:p}=l;return p===e.SELECTOR_PSEUDO_CLASS&&e.REG_LOGICAL_PSEUDO.test(i)});for(const{children:l}of a)for(const{children:i}of l)for(const{children:p}of i)t.has(p)&&t.delete(p)}else if(n.type===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(n.name)){const a=f.filter(l=>{const{name:i,type:p}=l;return p===e.SELECTOR_PSEUDO_ELEMENT&&e.REG_SHADOW_PSEUDO.test(i)});for(const{children:l}of a)for(const{children:i}of l)t.has(i)&&t.delete(i)}else if(n.type===e.NTH&&n.selector){const a=f.filter(l=>{const{selector:i,type:p}=l;return p===e.NTH&&i});for(const{selector:l}of a){const{children:i}=l;for(const{children:p}of i)t.has(p)&&t.delete(p)}}}}),{branches:[...t],info:Object.fromEntries(r)}},L=s=>{const t=[...s];if(t.length>1){const r=new Map([[e.SELECTOR_PSEUDO_ELEMENT,e.BIT_01],[e.SELECTOR_ID,e.BIT_02],[e.SELECTOR_CLASS,e.BIT_04],[e.SELECTOR_TYPE,e.BIT_08],[e.SELECTOR_ATTR,e.BIT_16],[e.SELECTOR_PSEUDO_CLASS,e.BIT_32]]);t.sort((o,n)=>{const{type:c}=o,{type:f}=n,a=r.get(c),l=r.get(f);let i;return a===l?i=0:a>l?i=1:i=-1,i})}return t},b=s=>{let t,r;if(s&&typeof s=="string")s.indexOf("|")>-1?[t,r]=s.split("|"):(t="*",r=s);else throw new DOMException(`Invalid selector ${s}`,e.SYNTAX_ERR);return{prefix:t,localName:r}};0&&(module.exports={generateCSS,parseAstName,parseSelector,preprocess,sortAST,unescapeSelector,walkAST});
var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var _=(s,t)=>{for(var r in t)u(s,r,{get:t[r],enumerable:!0})},L=(s,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of w(t))!y.call(s,n)&&n!==r&&u(s,n,{get:()=>t[n],enumerable:!(o=T(t,n))||o.enumerable});return s};var b=s=>L(u({},"__esModule",{value:!0}),s);var F={};_(F,{generateCSS:()=>O.generate,parseAstName:()=>D,parseSelector:()=>g,preprocess:()=>m,sortAST:()=>C,unescapeSelector:()=>I,walkAST:()=>A});module.exports=b(F);var d=require("css-tree"),$=require("./utility.js"),e=require("./constant.js"),O=require("css-tree");const S=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,x=/(:(is|where)\(\s*\))/,E=/^part|slotted$/,I=(s="")=>{if(typeof s=="string"&&s.indexOf("\\",0)>=0){const t=s.split("\\"),r=t.length;for(let o=1;o<r;o++){let n=t[o];if(n===""&&o===r-1)n=e.U_FFFD;else{const c=/^([\da-f]{1,6}\s?)/i.exec(n);if(c){const[,f]=c;let a;try{const i=parseInt("D800",e.HEX),p=parseInt("DFFF",e.HEX),h=parseInt(f,e.HEX);h===0||h>=i&&h<=p?a=e.U_FFFD:a=String.fromCodePoint(h)}catch{a=e.U_FFFD}let l="";n.length>f.length&&(l=n.substring(f.length)),n=`${a}${l}`}else/^[\n\r\f]/.test(n)&&(n="\\"+n)}t[o]=n}s=t.join("")}return s},m=(...s)=>{if(!s.length)throw new TypeError("1 argument required, but only 0 present.");let[t]=s;if(typeof t=="string"){let r=0;for(;r>=0&&(r=t.indexOf("#",r),!(r<0));){const o=t.substring(0,r+1);let n=t.substring(r+1);if(/^\d$/.test(n.substring(0,1)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);const c=n.codePointAt(0);if(c===e.HYPHEN){if(/^\d$/.test(n.substring(1,2)))throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR)}else if(c>e.BIT_FFFF){const f=`\\${c.toString(e.HEX)} `;n.length===e.DUO?n=f:n=`${f}${n.substring(e.DUO)}`}t=`${o}${n}`,r++}t=t.replace(/\f|\r\n?/g,`
`).replace(/[\0\uD800-\uDFFF]|\\$/g,e.U_FFFD)}else if(t==null)t=(0,$.getType)(t).toLowerCase();else if(Array.isArray(t))t=t.join(",");else if(Object.prototype.hasOwnProperty.call(t,"toString"))t=t.toString();else throw new DOMException(`Invalid selector ${t}`,e.SYNTAX_ERR);return t},g=s=>{if(s=m(s),/^$|^\s*>|,\s*$/.test(s))throw new DOMException(`Invalid selector ${s}`,e.SYNTAX_ERR);let t;try{const r=(0,d.parse)(s,{context:"selectorList",parseCustomProperty:!0});t=(0,d.toPlainObject)(r)}catch(r){const{message:o}=r;if(o==="Identifier is expected"&&S.test(s)){const[,n,c]=S.exec(s),f=c.replaceAll("*","\\*").replace(/^"/,"").replace(/"$/,"");let a=n.replace(c,f);a===":lang()"&&(a=`:lang(${e.EMPTY})`),t=g(s.replace(n,a))}else if(/^(?:Identifier|Selector) is expected$/.test(o)&&x.test(s)){const[,n,c]=x.exec(s);t=g(s.replace(n,`:${c}(${e.EMPTY})`))}else if(/^(?:"\]"|Attribute selector [()\s,=~^$*|]+) is expected$/.test(o)&&!s.endsWith("]")){const n=s.lastIndexOf("["),c=s.substring(n);c.includes('"')?c.match(/"/g).length%2?t=g(`${s}"]`):t=g(`${s}]`):t=g(`${s}]`)}else if(o==='")" is expected'&&!s.endsWith(")"))t=g(`${s})`);else throw new DOMException(o,e.SYNTAX_ERR)}return t},A=(s={})=>{const t=new Set,r=new Map;return(0,d.walk)(s,{enter:n=>{switch(n.type){case e.SELECTOR:{t.add(n.children);break}case e.PS_CLASS_SELECTOR:{e.REG_LOGICAL.test(n.name)&&(r.set("hasNestedSelector",!0),r.set("hasLogicalPseudoFunc",!0),n.name==="has"&&r.set("hasHasPseudoFunc",!0));break}case e.PS_ELEMENT_SELECTOR:{E.test(n.name)&&r.set("hasNestedSelector",!0);break}case e.NTH:{n.selector&&r.set("hasNestedSelector",!0);break}default:}}}),r.get("hasNestedSelector")&&(0,d.findAll)(s,(n,c,f)=>{if(f){if(n.type===e.PS_CLASS_SELECTOR&&e.REG_LOGICAL.test(n.name)){const a=f.filter(l=>{const{name:i,type:p}=l;return p===e.PS_CLASS_SELECTOR&&e.REG_LOGICAL.test(i)});for(const{children:l}of a)for(const{children:i}of l)for(const{children:p}of i)t.has(p)&&t.delete(p)}else if(n.type===e.PS_ELEMENT_SELECTOR&&E.test(n.name)){const a=f.filter(l=>{const{name:i,type:p}=l;return p===e.PS_ELEMENT_SELECTOR&&E.test(i)});for(const{children:l}of a)for(const{children:i}of l)t.has(i)&&t.delete(i)}else if(n.type===e.NTH&&n.selector){const a=f.filter(l=>{const{selector:i,type:p}=l;return p===e.NTH&&i});for(const{selector:l}of a){const{children:i}=l;for(const{children:p}of i)t.has(p)&&t.delete(p)}}}}),{branches:[...t],info:Object.fromEntries(r)}},C=s=>{const t=[...s];if(t.length>1){const r=new Map([[e.PS_ELEMENT_SELECTOR,e.BIT_01],[e.ID_SELECTOR,e.BIT_02],[e.CLASS_SELECTOR,e.BIT_04],[e.TYPE_SELECTOR,e.BIT_08],[e.ATTR_SELECTOR,e.BIT_16],[e.PS_CLASS_SELECTOR,e.BIT_32]]);t.sort((o,n)=>{const{type:c}=o,{type:f}=n,a=r.get(c),l=r.get(f);let i;return a===l?i=0:a>l?i=1:i=-1,i})}return t},D=s=>{let t,r;if(s&&typeof s=="string")s.indexOf("|")>-1?[t,r]=s.split("|"):(t="*",r=s);else throw new DOMException(`Invalid selector ${s}`,e.SYNTAX_ERR);return{prefix:t,localName:r}};0&&(module.exports={generateCSS,parseAstName,parseSelector,preprocess,sortAST,unescapeSelector,walkAST});
//# sourceMappingURL=parser.js.map

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

var _=Object.create;var c=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var i in t)c(e,i,{get:t[i],enumerable:!0})},w=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $(t))!I.call(e,o)&&o!==i&&c(e,o,{get:()=>t[o],enumerable:!(r=U(t,o))||r.enumerable});return e};var y=(e,t,i)=>(i=e!=null?_(R(e)):{},w(t||!e||!e.__esModule?c(i,"default",{value:e,enumerable:!0}):i,e)),M=e=>w(c({},"__esModule",{value:!0}),e);var j={};k(j,{filterSelector:()=>Y,getDirectionality:()=>m,getNamespaceURI:()=>O,getSlottedTextContent:()=>u,getType:()=>p,initNwsapi:()=>W,isContentEditable:()=>d,isCustomElement:()=>S,isFocusVisible:()=>F,isFocusable:()=>G,isInShadowTree:()=>D,isNamespaceDeclared:()=>A,isPreceding:()=>C,isVisible:()=>L,resolveContent:()=>v,sortNodes:()=>V,traverseNode:()=>P});module.exports=M(j);var h=y(require("@asamuzakjp/nwsapi"),1),g=y(require("bidi-js"),1),T=y(require("is-potential-custom-element-name"),1),s=require("./constant.js");const p=e=>Object.prototype.toString.call(e).slice(s.TYPE_FROM,s.TYPE_TO),v=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t,i;switch(e.nodeType){case s.DOCUMENT_NODE:{t=e,i=e;break}case s.DOCUMENT_FRAGMENT_NODE:{t=e.ownerDocument,i=e;break}case s.ELEMENT_NODE:{t=e.ownerDocument;let o=e;for(;o&&o.parentNode;)o=o.parentNode;i=o;break}default:throw new TypeError(`Unexpected node ${e.nodeName}`)}const r=t.createTreeWalker(i,s.WALKER_FILTER);return[t,i,r]},P=(e,t)=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let i;if(t?.currentNode){let r=t.currentNode;if(r===e)i=r;else if(r.contains(e))for(r=t.nextNode();r;){if(r===e){i=r;break}r=t.nextNode()}else{if(r!==t.root)for(;r&&!(r===t.root||r===e);)r=t.parentNode();if(e.nodeType===s.ELEMENT_NODE)for(;r;){if(r===e){i=r;break}r=t.nextNode()}else i=r}}return i??null},S=(e,t={})=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let i;if(e.nodeType===s.ELEMENT_NODE){const{localName:r,ownerDocument:o}=e,{formAssociated:a}=t,n=o.defaultView;let l;const f=e.getAttribute("is");f?l=(0,T.default)(f)&&n.customElements.get(f):l=(0,T.default)(r)&&n.customElements.get(r),l&&(a?i=l.formAssociated:i=!0)}return!!i},D=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE||e.nodeType===s.DOCUMENT_FRAGMENT_NODE){let i=e;for(;i;){const{host:r,mode:o,nodeType:a,parentNode:n}=i;if(r&&o&&a===s.DOCUMENT_FRAGMENT_NODE&&s.REG_SHADOW_MODE.test(o)){t=!0;break}i=n}}return!!t},u=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.localName==="slot"&&D(e)){const i=e.assignedNodes();if(i.length){for(const r of i)if(t=r.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},m=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE){const{dir:i,localName:r,parentNode:o}=e,{getEmbeddingLevels:a}=(0,g.default)();if(s.REG_DIR.test(i))t=i;else if(i==="auto"){let n;switch(r){case"input":{!e.type||/^(?:button|email|hidden|password|reset|search|submit|tel|text|url)$/.test(e.type)?n=e.value:/^(?:checkbox|color|date|image|number|radio|range|time)$/.test(e.type)&&(t="ltr");break}case"slot":{n=u(e);break}case"textarea":{n=e.value;break}default:{const l=[].slice.call(e.childNodes);for(const f of l){const{dir:E,localName:x,nodeType:b,textContent:N}=f;if(b===s.TEXT_NODE?n=N.trim():b===s.ELEMENT_NODE&&!/^(?:bdi|script|style|textarea)$/.test(x)&&(!E||!s.REG_DIR.test(E))&&(x==="slot"?n=u(f):n=N.trim()),n)break}}}if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}if(!t)if(o){const{nodeType:l}=o;l===s.ELEMENT_NODE?t=m(o):(l===s.DOCUMENT_NODE||l===s.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}else t="ltr"}else if(r==="bdi"){const n=e.textContent.trim();if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}t||o||(t="ltr")}else if(r==="input"&&e.type==="tel")t="ltr";else if(o){if(r==="slot"){const n=u(e);if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}}if(!t){const{nodeType:n}=o;n===s.ELEMENT_NODE?t=m(o):(n===s.DOCUMENT_NODE||n===s.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}}else t="ltr"}return t??null},d=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const i=e.getAttribute("contenteditable");if(i===""||/^(?:plaintext-only|true)$/.test(i))t=!0;else if(i==="inherit"){let r=e.parentNode;for(;r;){if(d(r)){t=!0;break}r=r.parentNode}}}}return!!t},L=e=>{let t;if(e?.nodeType===s.ELEMENT_NODE){const i=e.ownerDocument.defaultView,{display:r,visibility:o}=i.getComputedStyle(e);r!=="none"&&o==="visible"&&(t=!0)}return!!t},F=e=>{let t;if(e?.nodeType===s.ELEMENT_NODE){const{localName:i,type:r}=e;switch(i){case"input":{(!r||s.REG_TYPE_INPUT.test(r))&&(t=!0);break}case"textarea":{t=!0;break}default:t=d(e)}}return!!t},G=e=>{let t;if(e?.nodeType===s.ELEMENT_NODE){const i=e.ownerDocument.defaultView;let r=e;for(t=!0;r;){if(r.disabled||r.hasAttribute("disabled"))return!1;(r.hidden||r.hasAttribute("hidden"))&&(t=!1);const{contentVisibility:o,display:a,visibility:n}=i.getComputedStyle(r);if(a==="none"||n!=="visible"||o==="hidden"&&r!==e?t=!1:t=!0,t&&r?.parentNode?.nodeType===s.ELEMENT_NODE)r=r.parentNode;else break}}return!!t},O=(e,t)=>{if(typeof e!="string")throw new TypeError(`Unexpected type ${p(e)}`);if(!t?.nodeType)throw new TypeError(`Unexpected type ${p(t)}`);let i;if(e&&t.nodeType===s.ELEMENT_NODE){const{attributes:r}=t;for(const o of r){const{name:a,namespaceURI:n,prefix:l,value:f}=o;if(a===`xmlns:${e}`){i=f;break}else if(l===e){i=n;break}}}return i??null},A=(e="",t={})=>{let i;if(e&&typeof e=="string"&&t.nodeType===s.ELEMENT_NODE&&(i=t.lookupNamespaceURI(e),!i)){const r=t.ownerDocument.documentElement;let o=t;for(;o&&(i=O(e,o),!(i||o===r));)o=o.parentNode}return!!i},C=(e,t)=>{if(e?.nodeType){if(!t?.nodeType)throw new TypeError(`Unexpected type ${p(t)}`)}else throw new TypeError(`Unexpected type ${p(e)}`);let i;if(e.nodeType===s.ELEMENT_NODE&&t.nodeType===s.ELEMENT_NODE){const r=t.compareDocumentPosition(e);i=r&s.DOCUMENT_POSITION_PRECEDING||r&s.DOCUMENT_POSITION_CONTAINS}return!!i},V=(e=[])=>{const t=[...e];return t.length>1&&t.sort((i,r)=>{let o;return C(r,i)?o=1:o=-1,o}),t},W=(e,t)=>{if(!e?.DOMException)throw new TypeError(`Unexpected global object ${p(e)}`);t?.nodeType!==s.DOCUMENT_NODE&&(t=e.document);const i=(0,h.default)({document:t,DOMException:e.DOMException});return i.configure({LOGERRORS:!1}),i},Y=(e,t={})=>{if(!e||typeof e!="string")return!1;if(e.includes("[")){const i=e.lastIndexOf("[");if(e.substring(i).indexOf("]")<0)return!1}if(/[|\\]|::|[^\u0021-\u007F\s]|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]|:(?:is|where)\(\s*\)/.test(e))return!1;if(e.includes(":")){const{complex:i,descend:r}=t;let o;if(/:(?:is|not)\(/.test(e))i?o=s.REG_FILTER_COMPLEX:o=s.REG_FILTER_COMPOUND;else{if(r)return!1;o=s.REG_FILTER_SIMPLE}if(o.test(e))return!1}return!0};0&&(module.exports={filterSelector,getDirectionality,getNamespaceURI,getSlottedTextContent,getType,initNwsapi,isContentEditable,isCustomElement,isFocusVisible,isFocusable,isInShadowTree,isNamespaceDeclared,isPreceding,isVisible,resolveContent,sortNodes,traverseNode});
var D=Object.create;var f=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var i in t)f(e,i,{get:t[i],enumerable:!0})},w=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!I.call(e,o)&&o!==i&&f(e,o,{get:()=>t[o],enumerable:!(r=U(t,o))||r.enumerable});return e};var y=(e,t,i)=>(i=e!=null?D(L(e)):{},w(t||!e||!e.__esModule?f(i,"default",{value:e,enumerable:!0}):i,e)),k=e=>w(f({},"__esModule",{value:!0}),e);var K={};R(K,{filterSelector:()=>H,getDirectionality:()=>m,getNamespaceURI:()=>g,getSlottedTextContent:()=>u,getType:()=>p,initNwsapi:()=>j,isContentEditable:()=>x,isCustomElement:()=>G,isFocusVisible:()=>V,isFocusable:()=>W,isInShadowTree:()=>$,isNamespaceDeclared:()=>X,isPreceding:()=>C,isVisible:()=>F,resolveContent:()=>A,sortNodes:()=>Y,traverseNode:()=>S});module.exports=k(K);var h=y(require("@asamuzakjp/nwsapi"),1),O=y(require("bidi-js"),1),T=y(require("is-potential-custom-element-name"),1),s=require("./constant.js");const M=new RegExp(`:(?!${s.PSEUDO_CLASS}|${s.N_TH}|${s.LOGICAL_COMPLEX})`),P=new RegExp(`:(?!${s.PSEUDO_CLASS}|${s.N_TH}|${s.LOGICAL_COMPOUND})`),v=new RegExp(`:(?!${s.PSEUDO_CLASS}|${s.N_TH})`),p=e=>Object.prototype.toString.call(e).slice(s.TYPE_FROM,s.TYPE_TO),A=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t,i;switch(e.nodeType){case s.DOCUMENT_NODE:{t=e,i=e;break}case s.DOCUMENT_FRAGMENT_NODE:{t=e.ownerDocument,i=e;break}case s.ELEMENT_NODE:{t=e.ownerDocument;let o=e;for(;o&&o.parentNode;)o=o.parentNode;i=o;break}default:throw new TypeError(`Unexpected node ${e.nodeName}`)}const r=t.createTreeWalker(i,s.WALKER_FILTER);return[t,i,r]},S=(e,t)=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let i;if(t?.currentNode){let r=t.currentNode;if(r===e)i=r;else if(r.contains(e))for(r=t.nextNode();r;){if(r===e){i=r;break}r=t.nextNode()}else{if(r!==t.root)for(;r&&!(r===t.root||r===e);)r=t.parentNode();if(e.nodeType===s.ELEMENT_NODE)for(;r;){if(r===e){i=r;break}r=t.nextNode()}else i=r}}return i??null},G=(e,t={})=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let i;if(e.nodeType===s.ELEMENT_NODE){const{localName:r,ownerDocument:o}=e,{formAssociated:a}=t,n=o.defaultView;let l;const c=e.getAttribute("is");c?l=(0,T.default)(c)&&n.customElements.get(c):l=(0,T.default)(r)&&n.customElements.get(r),l&&(a?i=l.formAssociated:i=!0)}return!!i},$=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE||e.nodeType===s.DOCUMENT_FRAGMENT_NODE){let i=e;for(;i;){const{host:r,mode:o,nodeType:a,parentNode:n}=i;if(r&&o&&a===s.DOCUMENT_FRAGMENT_NODE&&/^(?:close|open)$/.test(o)){t=!0;break}i=n}}return!!t},u=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.localName==="slot"&&$(e)){const i=e.assignedNodes();if(i.length){for(const r of i)if(t=r.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},m=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE){const{dir:i,localName:r,parentNode:o}=e,{getEmbeddingLevels:a}=(0,O.default)();if(/^(?:ltr|rtl)$/.test(i))t=i;else if(i==="auto"){let n;switch(r){case"input":{!e.type||/^(?:button|email|hidden|password|reset|search|submit|tel|text|url)$/.test(e.type)?n=e.value:/^(?:checkbox|color|date|image|number|radio|range|time)$/.test(e.type)&&(t="ltr");break}case"slot":{n=u(e);break}case"textarea":{n=e.value;break}default:{const l=[].slice.call(e.childNodes);for(const c of l){const{dir:d,localName:b,nodeType:E,textContent:N}=c;if(E===s.TEXT_NODE?n=N.trim():E===s.ELEMENT_NODE&&!/^(?:bdi|script|style|textarea)$/.test(b)&&(!d||!/^(?:ltr|rtl)$/.test(d))&&(b==="slot"?n=u(c):n=N.trim()),n)break}}}if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}if(!t)if(o){const{nodeType:l}=o;l===s.ELEMENT_NODE?t=m(o):(l===s.DOCUMENT_NODE||l===s.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}else t="ltr"}else if(r==="bdi"){const n=e.textContent.trim();if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}t||o||(t="ltr")}else if(r==="input"&&e.type==="tel")t="ltr";else if(o){if(r==="slot"){const n=u(e);if(n){const{paragraphs:[{level:l}]}=a(n);l%2===1?t="rtl":t="ltr"}}if(!t){const{nodeType:n}=o;n===s.ELEMENT_NODE?t=m(o):(n===s.DOCUMENT_NODE||n===s.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}}else t="ltr"}return t??null},x=e=>{if(!e?.nodeType)throw new TypeError(`Unexpected type ${p(e)}`);let t;if(e.nodeType===s.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const i=e.getAttribute("contenteditable");if(i===""||/^(?:plaintext-only|true)$/.test(i))t=!0;else if(i==="inherit"){let r=e.parentNode;for(;r;){if(x(r)){t=!0;break}r=r.parentNode}}}}return!!t},F=e=>{let t;if(e?.nodeType===s.ELEMENT_NODE){const i=e.ownerDocument.defaultView,{display:r,visibility:o}=i.getComputedStyle(e);r!=="none"&&o==="visible"&&(t=!0)}return!!t},V=e=>{let t;if(e?.nodeType===s.ELEMENT_NODE){const{localName:i,type:r}=e;switch(i){case"input":{(!r||s.REG_INPUT_TYPE.test(r))&&(t=!0);break}case"textarea":{t=!0;break}default:t=x(e)}}return!!t},W=e=>{let t;if(e?.nodeType===s.ELEMENT_NODE){const i=e.ownerDocument.defaultView;let r=e;for(t=!0;r;){if(r.disabled||r.hasAttribute("disabled"))return!1;(r.hidden||r.hasAttribute("hidden"))&&(t=!1);const{contentVisibility:o,display:a,visibility:n}=i.getComputedStyle(r);if(a==="none"||n!=="visible"||o==="hidden"&&r!==e?t=!1:t=!0,t&&r?.parentNode?.nodeType===s.ELEMENT_NODE)r=r.parentNode;else break}}return!!t},g=(e,t)=>{if(typeof e!="string")throw new TypeError(`Unexpected type ${p(e)}`);if(!t?.nodeType)throw new TypeError(`Unexpected type ${p(t)}`);let i;if(e&&t.nodeType===s.ELEMENT_NODE){const{attributes:r}=t;for(const o of r){const{name:a,namespaceURI:n,prefix:l,value:c}=o;if(a===`xmlns:${e}`){i=c;break}else if(l===e){i=n;break}}}return i??null},X=(e="",t={})=>{let i;if(e&&typeof e=="string"&&t.nodeType===s.ELEMENT_NODE&&(i=t.lookupNamespaceURI(e),!i)){const r=t.ownerDocument.documentElement;let o=t;for(;o&&(i=g(e,o),!(i||o===r));)o=o.parentNode}return!!i},C=(e,t)=>{if(e?.nodeType){if(!t?.nodeType)throw new TypeError(`Unexpected type ${p(t)}`)}else throw new TypeError(`Unexpected type ${p(e)}`);let i;if(e.nodeType===s.ELEMENT_NODE&&t.nodeType===s.ELEMENT_NODE){const r=t.compareDocumentPosition(e);i=r&s.DOCUMENT_POSITION_PRECEDING||r&s.DOCUMENT_POSITION_CONTAINS}return!!i},Y=(e=[])=>{const t=[...e];return t.length>1&&t.sort((i,r)=>{let o;return C(r,i)?o=1:o=-1,o}),t},j=(e,t)=>{if(!e?.DOMException)throw new TypeError(`Unexpected global object ${p(e)}`);t?.nodeType!==s.DOCUMENT_NODE&&(t=e.document);const i=(0,h.default)({document:t,DOMException:e.DOMException});return i.configure({LOGERRORS:!1}),i},H=(e,t={})=>{if(!e||typeof e!="string")return!1;if(e.includes("[")){const i=e.lastIndexOf("[");if(e.substring(i).indexOf("]")<0)return!1}if(/[|\\]|::|[^\u0021-\u007F\s]|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]|:(?:is|where)\(\s*\)/.test(e))return!1;if(e.includes(":")){const{complex:i,descend:r}=t;return/:(?:is|not)\(/.test(e)?i?!M.test(e):!P.test(e):r?!1:!v.test(e)}return!0};0&&(module.exports={filterSelector,getDirectionality,getNamespaceURI,getSlottedTextContent,getType,initNwsapi,isContentEditable,isCustomElement,isFocusVisible,isFocusable,isInShadowTree,isNamespaceDeclared,isPreceding,isVisible,resolveContent,sortNodes,traverseNode});
//# sourceMappingURL=utility.js.map

@@ -63,3 +63,3 @@ {

},
"version": "5.2.2"
"version": "5.3.0"
}

@@ -14,5 +14,7 @@ /*!

import {
DOCUMENT_NODE, ELEMENT_NODE, REG_COMPLEX, REG_DESCEND, TARGET_ALL,
COMBO, COMPOUND_I, DESCEND, DOCUMENT_NODE, ELEMENT_NODE, TARGET_ALL,
TARGET_FIRST, TARGET_LINEAL, TARGET_SELF
} from './js/constant.js';
const REG_COMPLEX = new RegExp(`${COMBO}${COMPOUND_I}`, 'i');
const REG_DESCEND = new RegExp(`${DESCEND}${COMPOUND_I}`, 'i');

@@ -19,0 +21,0 @@ /* DOMSelector */

@@ -7,16 +7,15 @@ /**

export const AN_PLUS_B = 'AnPlusB';
export const ATTR_SELECTOR = 'AttributeSelector';
export const CLASS_SELECTOR = 'ClassSelector';
export const COMBINATOR = 'Combinator';
export const EMPTY = '__EMPTY__';
export const IDENTIFIER = 'Identifier';
export const IDENT = 'Identifier';
export const ID_SELECTOR = 'IdSelector';
export const NOT_SUPPORTED_ERR = 'NotSupportedError';
export const NTH = 'Nth';
export const PS_CLASS_SELECTOR = 'PseudoClassSelector';
export const PS_ELEMENT_SELECTOR = 'PseudoElementSelector';
export const RAW = 'Raw';
export const SELECTOR = 'Selector';
export const SELECTOR_ATTR = 'AttributeSelector';
export const SELECTOR_CLASS = 'ClassSelector';
export const SELECTOR_ID = 'IdSelector';
export const SELECTOR_LIST = 'SelectorList';
export const SELECTOR_PSEUDO_CLASS = 'PseudoClassSelector';
export const SELECTOR_PSEUDO_ELEMENT = 'PseudoElementSelector';
export const SELECTOR_TYPE = 'TypeSelector';
export const STRING = 'String';

@@ -28,2 +27,3 @@ export const SYNTAX_ERR = 'SyntaxError';

export const TARGET_SELF = 'self';
export const TYPE_SELECTOR = 'TypeSelector';
export const U_FFFD = '\uFFFD';

@@ -39,5 +39,5 @@

export const BIT_FFFF = 0xFFFF;
export const BIT_HYPHEN = 0x2D;
export const DUO = 2;
export const HEX = 16;
export const HYPHEN = 0x2D;
export const TYPE_FROM = 8;

@@ -67,3 +67,3 @@ export const TYPE_TO = -1;

export const LANG_PART = `(?:-${ALPHA_NUM})*`;
export const PSEUDO_CLASSES =
export const PSEUDO_CLASS =
`(?:any-)?link|${CHILD_IDX}|checked|empty|indeterminate|root|target|visited`;

@@ -102,33 +102,4 @@ export const ANB =

/* regexp */
export const REG_ANCHOR = /^a(?:rea)?$/;
export const REG_COMPLEX = new RegExp(`${COMBO}${COMPOUND_I}`, 'i');
export const REG_DESCEND = new RegExp(`${DESCEND}${COMPOUND_I}`, 'i');
export const REG_DIR = /^(?:ltr|rtl)$/;
export const REG_FILTER_COMPLEX =
new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPLEX})`);
export const REG_FILTER_COMPOUND =
new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH}|${LOGICAL_COMPOUND})`);
export const REG_FILTER_SIMPLE = new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH})`);
export const REG_FORM = /^(?:button|fieldset|form|input|select|textarea)$/;
export const REG_FORM_CTRL =
/^(?:button|fieldset|input|optgroup|option|select|textarea)$/;
export const REG_FORM_VALID = /^(?:button|form|input|select|textarea)$/;
export const REG_HEX = /^([\da-f]{1,6}\s?)/i;
export const REG_INTERACT = /^(?:details|dialog)$/;
export const REG_INVALID_SELECTOR = /^$|^\s*>|,\s*$/;
export const REG_LANG = new RegExp(`^(?:\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i');
export const REG_LANG_QUOTED = /(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/;
export const REG_LOGICAL_EMPTY = /(:(is|where)\(\s*\))/;
export const REG_LOGICAL_PSEUDO = /^(?:has|is|not|where)$/;
export const REG_SHADOW_HOST = /^host(?:-context)?$/;
export const REG_SHADOW_MODE = /^(?:close|open)$/;
export const REG_SHADOW_PSEUDO = /^part|slotted$/;
export const REG_TAG_NAME = /[A-Z][\\w-]*/i;
export const REG_TYPE_CHECK = /^(?:checkbox|radio)$/;
export const REG_TYPE_INPUT =
export const REG_LOGICAL = /^(?:has|is|not|where)$/;
export const REG_INPUT_TYPE =
/^(?:date(?:time-local)?|email|month|number|password|search|tel|text|time|url|week)$/;
export const REG_TYPE_RANGE =
/^(?:date(?:time-local)?|month|number|range|time|week)$/;
export const REG_TYPE_RESET = /^(?:button|reset)$/;
export const REG_TYPE_SUBMIT = /^(?:image|submit)$/;
export const REG_TYPE_TEXT = /^(?:email|number|password|search|tel|text|url)$/;

@@ -11,4 +11,4 @@ /**

import {
ALPHA_NUM, ELEMENT_NODE, EMPTY, LANG_PART, NOT_SUPPORTED_ERR, REG_LANG,
REG_TAG_NAME, SELECTOR_ATTR, SELECTOR_TYPE, SYNTAX_ERR
ALPHA_NUM, ATTR_SELECTOR, ELEMENT_NODE, EMPTY, LANG_PART, NOT_SUPPORTED_ERR,
SYNTAX_ERR, TYPE_SELECTOR
} from './constant.js';

@@ -298,3 +298,3 @@

if (node.ownerDocument.contentType === 'text/html' &&
REG_TAG_NAME.test(localName)) {
/[A-Z][\\w-]*/i.test(localName)) {
astPrefix = astPrefix.toLowerCase();

@@ -398,3 +398,4 @@ astLocalName = astLocalName.toLowerCase();

} else if (astName) {
if (REG_LANG.test(astName)) {
const reg = new RegExp(`^(?:\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i');
if (reg.test(astName)) {
let regExtendedLang;

@@ -468,7 +469,7 @@ if (astName.indexOf('-') > -1) {

switch (ast.type) {
case SELECTOR_ATTR: {
case ATTR_SELECTOR: {
matched = this._matchAttributeSelector(ast, node);
break;
}
case SELECTOR_TYPE: {
case TYPE_SELECTOR: {
matched = this._matchTypeSelector(ast, node, opt ?? {});

@@ -475,0 +476,0 @@ break;

@@ -11,8 +11,9 @@ /**

import {
BIT_01, BIT_02, BIT_04, BIT_08, BIT_16, BIT_32, BIT_FFFF, BIT_HYPHEN,
DUO, EMPTY, HEX, NTH, REG_HEX, REG_INVALID_SELECTOR, REG_LANG_QUOTED,
REG_LOGICAL_EMPTY, REG_LOGICAL_PSEUDO, REG_SHADOW_PSEUDO, SELECTOR,
SELECTOR_ATTR, SELECTOR_CLASS, SELECTOR_ID, SELECTOR_PSEUDO_CLASS,
SELECTOR_PSEUDO_ELEMENT, SELECTOR_TYPE, SYNTAX_ERR, U_FFFD
ATTR_SELECTOR, BIT_01, BIT_02, BIT_04, BIT_08, BIT_16, BIT_32, BIT_FFFF,
CLASS_SELECTOR, DUO, EMPTY, HEX, HYPHEN, ID_SELECTOR, NTH, PS_CLASS_SELECTOR,
PS_ELEMENT_SELECTOR, REG_LOGICAL, SELECTOR, SYNTAX_ERR, TYPE_SELECTOR, U_FFFD
} from './constant.js';
const REG_LANG_QUOTED = /(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/;
const REG_LOGICAL_EMPTY = /(:(is|where)\(\s*\))/;
const REG_SHADOW_PSEUDO = /^part|slotted$/;

@@ -33,3 +34,3 @@ /**

} else {
const hexExists = REG_HEX.exec(item);
const hexExists = /^([\da-f]{1,6}\s?)/i.exec(item);
if (hexExists) {

@@ -93,3 +94,3 @@ const [, hex] = hexExists;

const codePoint = postHash.codePointAt(0);
if (codePoint === BIT_HYPHEN) {
if (codePoint === HYPHEN) {
if (/^\d$/.test(postHash.substring(1, 2))) {

@@ -132,3 +133,3 @@ throw new DOMException(`Invalid selector ${selector}`, SYNTAX_ERR);

// invalid selectors
if (REG_INVALID_SELECTOR.test(selector)) {
if (/^$|^\s*>|,\s*$/.test(selector)) {
throw new DOMException(`Invalid selector ${selector}`, SYNTAX_ERR);

@@ -198,4 +199,4 @@ }

}
case SELECTOR_PSEUDO_CLASS: {
if (REG_LOGICAL_PSEUDO.test(node.name)) {
case PS_CLASS_SELECTOR: {
if (REG_LOGICAL.test(node.name)) {
info.set('hasNestedSelector', true);

@@ -209,3 +210,3 @@ info.set('hasLogicalPseudoFunc', true);

}
case SELECTOR_PSEUDO_ELEMENT: {
case PS_ELEMENT_SELECTOR: {
if (REG_SHADOW_PSEUDO.test(node.name)) {

@@ -230,8 +231,7 @@ info.set('hasNestedSelector', true);

if (list) {
if (node.type === SELECTOR_PSEUDO_CLASS &&
REG_LOGICAL_PSEUDO.test(node.name)) {
if (node.type === PS_CLASS_SELECTOR && REG_LOGICAL.test(node.name)) {
const itemList = list.filter(i => {
const { name, type } = i;
const res =
type === SELECTOR_PSEUDO_CLASS && REG_LOGICAL_PSEUDO.test(name);
type === PS_CLASS_SELECTOR && REG_LOGICAL.test(name);
return res;

@@ -250,3 +250,3 @@ });

}
} else if (node.type === SELECTOR_PSEUDO_ELEMENT &&
} else if (node.type === PS_ELEMENT_SELECTOR &&
REG_SHADOW_PSEUDO.test(node.name)) {

@@ -256,3 +256,3 @@ const itemList = list.filter(i => {

const res =
type === SELECTOR_PSEUDO_ELEMENT && REG_SHADOW_PSEUDO.test(name);
type === PS_ELEMENT_SELECTOR && REG_SHADOW_PSEUDO.test(name);
return res;

@@ -302,8 +302,8 @@ });

const order = new Map([
[SELECTOR_PSEUDO_ELEMENT, BIT_01],
[SELECTOR_ID, BIT_02],
[SELECTOR_CLASS, BIT_04],
[SELECTOR_TYPE, BIT_08],
[SELECTOR_ATTR, BIT_16],
[SELECTOR_PSEUDO_CLASS, BIT_32]
[PS_ELEMENT_SELECTOR, BIT_01],
[ID_SELECTOR, BIT_02],
[CLASS_SELECTOR, BIT_04],
[TYPE_SELECTOR, BIT_08],
[ATTR_SELECTOR, BIT_16],
[PS_CLASS_SELECTOR, BIT_32]
]);

@@ -310,0 +310,0 @@ arr.sort((a, b) => {

@@ -13,6 +13,11 @@ /**

DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINS,
DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, REG_DIR, REG_FILTER_COMPLEX,
REG_FILTER_COMPOUND, REG_FILTER_SIMPLE, REG_SHADOW_MODE, REG_TYPE_INPUT,
TEXT_NODE, TYPE_FROM, TYPE_TO, WALKER_FILTER
DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, N_TH, LOGICAL_COMPLEX,
LOGICAL_COMPOUND, PSEUDO_CLASS, REG_INPUT_TYPE, TEXT_NODE, TYPE_FROM,
TYPE_TO, WALKER_FILTER
} from './constant.js';
const REG_LOGICAL_COMPLEX =
new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH}|${LOGICAL_COMPLEX})`);
const REG_LOGICAL_COMPOUND =
new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH}|${LOGICAL_COMPOUND})`);
const REG_WO_LOGICAL = new RegExp(`:(?!${PSEUDO_CLASS}|${N_TH})`);

@@ -175,3 +180,3 @@ /**

if (host && mode && nodeType === DOCUMENT_FRAGMENT_NODE &&
REG_SHADOW_MODE.test(mode)) {
/^(?:close|open)$/.test(mode)) {
bool = true;

@@ -226,3 +231,3 @@ break;

const { getEmbeddingLevels } = bidiFactory();
if (REG_DIR.test(nodeDir)) {
if (/^(?:ltr|rtl)$/.test(nodeDir)) {
res = nodeDir;

@@ -259,3 +264,3 @@ } else if (nodeDir === 'auto') {

if (!/^(?:bdi|script|style|textarea)$/.test(itemLocalName) &&
(!itemDir || !REG_DIR.test(itemDir))) {
(!itemDir || !/^(?:ltr|rtl)$/.test(itemDir))) {
if (itemLocalName === 'slot') {

@@ -401,3 +406,3 @@ text = getSlottedTextContent(item);

case 'input': {
if (!type || REG_TYPE_INPUT.test(type)) {
if (!type || REG_INPUT_TYPE.test(type)) {
res = true;

@@ -604,20 +609,15 @@ }

const { complex, descend } = opt;
let reg;
if (/:(?:is|not)\(/.test(selector)) {
if (complex) {
reg = REG_FILTER_COMPLEX;
return !REG_LOGICAL_COMPLEX.test(selector);
} else {
reg = REG_FILTER_COMPOUND;
return !REG_LOGICAL_COMPOUND.test(selector);
}
} else if (descend) {
return false;
} else {
if (descend) {
return false;
}
reg = REG_FILTER_SIMPLE;
return !REG_WO_LOGICAL.test(selector);
}
if (reg.test(selector)) {
return false;
}
}
return true;
};
export const AN_PLUS_B: "AnPlusB";
export const ATTR_SELECTOR: "AttributeSelector";
export const CLASS_SELECTOR: "ClassSelector";
export const COMBINATOR: "Combinator";
export const EMPTY: "__EMPTY__";
export const IDENTIFIER: "Identifier";
export const IDENT: "Identifier";
export const ID_SELECTOR: "IdSelector";
export const NOT_SUPPORTED_ERR: "NotSupportedError";
export const NTH: "Nth";
export const PS_CLASS_SELECTOR: "PseudoClassSelector";
export const PS_ELEMENT_SELECTOR: "PseudoElementSelector";
export const RAW: "Raw";
export const SELECTOR: "Selector";
export const SELECTOR_ATTR: "AttributeSelector";
export const SELECTOR_CLASS: "ClassSelector";
export const SELECTOR_ID: "IdSelector";
export const SELECTOR_LIST: "SelectorList";
export const SELECTOR_PSEUDO_CLASS: "PseudoClassSelector";
export const SELECTOR_PSEUDO_ELEMENT: "PseudoElementSelector";
export const SELECTOR_TYPE: "TypeSelector";
export const STRING: "String";

@@ -22,2 +21,3 @@ export const SYNTAX_ERR: "SyntaxError";

export const TARGET_SELF: "self";
export const TYPE_SELECTOR: "TypeSelector";
export const U_FFFD: "�";

@@ -31,5 +31,5 @@ export const BIT_01: 1;

export const BIT_FFFF: 65535;
export const BIT_HYPHEN: 45;
export const DUO: 2;
export const HEX: 16;
export const HYPHEN: 45;
export const TYPE_FROM: 8;

@@ -53,3 +53,3 @@ export const TYPE_TO: -1;

export const LANG_PART: "(?:-[A-Z\\d]+)*";
export const PSEUDO_CLASSES: "(?:any-)?link|(?:first|last|only)-(?:child|of-type)|checked|empty|indeterminate|root|target|visited";
export const PSEUDO_CLASS: "(?:any-)?link|(?:first|last|only)-(?:child|of-type)|checked|empty|indeterminate|root|target|visited";
export const ANB: "[+-]?(?:(?:0|[1-9]\\d*)n?|n)|(?:[+-]?(?:0|[1-9]\\d*))?n\\s*[+-]\\s*(?:0|[1-9]\\d*)";

@@ -73,28 +73,3 @@ export const N_TH: "nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|[+-]?(?:(?:0|[1-9]\\d*)n?|n)|(?:[+-]?(?:0|[1-9]\\d*))?n\\s*[+-]\\s*(?:0|[1-9]\\d*))\\s*\\)";

export const LOGICAL_COMPOUND: "(?:is|not)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+))*\\s*\\)";
export const REG_ANCHOR: RegExp;
export const REG_COMPLEX: RegExp;
export const REG_DESCEND: RegExp;
export const REG_DIR: RegExp;
export const REG_FILTER_COMPLEX: RegExp;
export const REG_FILTER_COMPOUND: RegExp;
export const REG_FILTER_SIMPLE: RegExp;
export const REG_FORM: RegExp;
export const REG_FORM_CTRL: RegExp;
export const REG_FORM_VALID: RegExp;
export const REG_HEX: RegExp;
export const REG_INTERACT: RegExp;
export const REG_INVALID_SELECTOR: RegExp;
export const REG_LANG: RegExp;
export const REG_LANG_QUOTED: RegExp;
export const REG_LOGICAL_EMPTY: RegExp;
export const REG_LOGICAL_PSEUDO: RegExp;
export const REG_SHADOW_HOST: RegExp;
export const REG_SHADOW_MODE: RegExp;
export const REG_SHADOW_PSEUDO: RegExp;
export const REG_TAG_NAME: RegExp;
export const REG_TYPE_CHECK: RegExp;
export const REG_TYPE_INPUT: RegExp;
export const REG_TYPE_RANGE: RegExp;
export const REG_TYPE_RESET: RegExp;
export const REG_TYPE_SUBMIT: RegExp;
export const REG_TYPE_TEXT: RegExp;
export const REG_LOGICAL: RegExp;
export const REG_INPUT_TYPE: RegExp;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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