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

@asamuzakjp/dom-selector

Package Overview
Dependencies
Maintainers
0
Versions
194
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 4.6.0 to 4.6.1

2

dist/cjs/js/constant.js

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

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

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

var z=Object.create;var M=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var Y=(g,l)=>{for(var e in l)M(g,e,{get:l[e],enumerable:!0})},D=(g,l,e,h)=>{if(l&&typeof l=="object"||typeof l=="function")for(let n of W(l))!j.call(g,n)&&n!==e&&M(g,n,{get:()=>l[n],enumerable:!(h=H(l,n))||h.enumerable});return g};var q=(g,l,e)=>(e=g!=null?z(B(g)):{},D(l||!g||!g.__esModule?M(e,"default",{value:g,enumerable:!0}):e,g)),V=g=>D(M({},"__esModule",{value:!0}),g);var K={};Y(K,{Finder:()=>X});module.exports=V(K);var I=q(require("@asamuzakjp/nwsapi"),1),_=require("./dom-util.js"),O=require("./matcher.js"),y=require("./parser.js"),c=require("./constant.js");const x="next",S="prev",L="all",E="first",C="lineal",R="self";class X{#a;#c;#s;#h;#w;#r;#m;#e;#d;#k;#f;#o;#_;#t;#u;#b;#n;#p;#i;#l;constructor(l,e){this.#l=l,this.#r=e??l.document,this.#c=new WeakMap,this.#h=new WeakMap,this.#_=new WeakMap,this._initNwsapi()}_onError(l){if(!this.#k)if(l instanceof DOMException||l instanceof this.#l.DOMException)if(l.name===c.NOT_SUPPORTED_ERR)this.#i&&console.warn(l.message);else throw new this.#l.DOMException(l.message,l.name);else throw l}_setup(l,e,h={}){const{event:n,noexcept:a,warn:f}=h;return this.#k=!!a,this.#i=!!f,this.#m=this._setEvent(n),this.#e=e,[this.#s,this.#t,this.#n]=(0,_.resolveContent)(e),this.#u=(0,_.isInShadowTree)(e),[this.#a,this.#d]=this._correspond(l),this.#p=new WeakMap,e}_initNwsapi(){return this.#f=(0,I.default)({DOMException:this.#l.DOMException,document:this.#r}),this.#f.configure({LOGERRORS:!1}),this.#f}_setEvent(l){return l instanceof this.#l.KeyboardEvent||l instanceof this.#l.MouseEvent?l:null}_correspond(l){const e=[];this.#w=!1;let h;if(this.#h.has(this.#s)){const n=this.#h.get(this.#s);if(n&&n.has(`${l}`)){const a=n.get(`${l}`);this.#w=a.descendant,h=a.ast}}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,y.parseSelector)(l)}catch(t){this._onError(t)}const{branches:a,info:{hasHasPseudoFunc:f,hasHyphenSepAttr:r}}=(0,y.walkAST)(n);let u;f||r?u=!1:u=!0;let d=!1,i=0;h=[];for(const[...t]of a){const s=[];let o=t.shift();if(o&&o.type!==c.COMBINATOR){const m=new Set;for(;o;){if(o.type===c.COMBINATOR){const[b]=t;if(b.type===c.COMBINATOR){const w=`Invalid selector ${l}`;throw new DOMException(w,c.SYNTAX_ERR)}const p=o.name;/^[\s>]$/.test(p)&&(d=!0),s.push({combo:o,leaves:(0,y.sortAST)(m)}),m.clear()}else if(o){let{name:b}=o;b&&typeof b=="string"&&(b=(0,y.unescapeSelector)(b),typeof b=="string"&&b!==o.name&&(o.name=b),/[|:]/.test(b)&&(o.namespace=!0)),m.add(o)}if(t.length)o=t.shift();else{s.push({combo:null,leaves:(0,y.sortAST)(m)}),m.clear();break}}}h.push({branch:s,collected:!1,dir:null,filtered:!1,find:!1}),e[i]=[],i++}if(u){let t;this.#h.has(this.#s)?t=this.#h.get(this.#s):t=new Map,t.set(`${l}`,{ast:h,descendant:d}),this.#h.set(this.#s,t)}this.#w=d}return[h,e]}_createTreeWalker(l){let e;return this.#p.has(l)?e=this.#p.get(l):(e=this.#r.createTreeWalker(l,c.WALKER_FILTER),this.#p.set(l,e)),e}_prepareQuerySelectorWalker(){return this.#o=this._createTreeWalker(this.#e),this.#b=!1,this.#o}_collectNthChild(l,e,h){const{a:n,b:a,reverse:f,selector:r}=l,{parentNode:u}=e,d=new Set;let i;if(r)if(this.#c.has(r))i=this.#c.get(r);else{const{branches:t}=(0,y.walkAST)(r);i=t,this.#c.set(r,i)}if(u){const t=this.#n;let s=(0,_.traverseNode)(u,t);s=t.firstChild();let o=0;for(;s;)o++,s=t.nextSibling();s=(0,_.traverseNode)(u,t);const m=new Set;if(i)for(s=t.firstChild();s;){let b;for(const p of i)if(b=this._matchLeaves(p,s,h),!b)break;b&&m.add(s),s=t.nextSibling()}if(n===0){if(a>0&&a<=o){if(m.size){s=(0,_.traverseNode)(u,t),f?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(m.has(s)){if(b===a-1){d.add(s);break}b++}f?s=t.previousSibling():s=t.nextSibling()}}else if(!r){s=(0,_.traverseNode)(u,t),f?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(b===a-1){d.add(s);break}f?s=t.previousSibling():s=t.nextSibling(),b++}}}}else{let b=a-1;if(n>0)for(;b<0;)b+=n;if(b>=0&&b<o){s=(0,_.traverseNode)(u,t),f?s=t.lastChild():s=t.firstChild();let p=0,w=n>0?0:a-1;for(;s&&(s&&b>=0&&b<o);)m.size?m.has(s)&&(w===b&&(d.add(s),b+=n),n>0?w++:w--):p===b&&(r||d.add(s),b+=n),f?s=t.previousSibling():s=t.nextSibling(),p++}}if(f&&d.size>1){const b=[...d];return new Set(b.reverse())}}else if(e===this.#t&&n+a===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,h),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(l,e){const{a:h,b:n,reverse:a}=l,{localName:f,parentNode:r,prefix:u}=e,d=new Set;if(r){const i=this.#n;let t=(0,_.traverseNode)(r,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(h===0){if(n>0&&n<=s){t=(0,_.traverseNode)(r,i),a?t=i.lastChild():t=i.firstChild();let o=0;for(;t;){const{localName:m,prefix:b}=t;if(m===f&&b===u){if(o===n-1){d.add(t);break}o++}a?t=i.previousSibling():t=i.nextSibling()}}}else{let o=n-1;if(h>0)for(;o<0;)o+=h;if(o>=0&&o<s){t=(0,_.traverseNode)(r,i),a?t=i.lastChild():t=i.firstChild();let m=h>0?0:n-1;for(;t;){const{localName:b,prefix:p}=t;if(b===f&&p===u){if(m===o&&(d.add(t),o+=h),o<0||o>=s)break;h>0?m++:m--}a?t=i.previousSibling():t=i.nextSibling()}}}if(a&&d.size>1){const o=[...d];return new Set(o.reverse())}}else e===this.#t&&h+n===1&&d.add(e);return d}_matchAnPlusB(l,e,h,n){const{nth:{a,b:f,name:r},selector:u}=l,d=new Map;if(r?(r==="even"?(d.set("a",2),d.set("b",0)):r==="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 f=="string"&&/-?\d+/.test(f)?d.set("b",f*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(l,e,h={}){let n;if(Array.isArray(l)&&l.length){const a=l.map(s=>s),[f]=a,{type:r}=f;let u;r===c.COMBINATOR?u=a.shift():u={name:" ",type:c.COMBINATOR};const d=[];for(;a.length;){const[s]=a,{type:o}=s;if(o===c.COMBINATOR)break;d.push(a.shift())}const i={combo:u,leaves:d};h.dir=x;const t=this._matchCombinator(i,e,h);if(t.size)if(a.length){for(const s of t)if(n=this._matchHasPseudoFunc(a,s,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(l,e,h={}){const{astName:n="",branches:a=[],selector:f="",twigBranches:r=[]}=l;let u;if(n==="has")if(f.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=r.length;let t;for(let s=0;s<i;s++){const o=r[s],m=o.length-1,{leaves:b}=o[m];if(t=this._matchLeaves(b,e,h),t&&m>0){let p=new Set([e]);for(let w=m-1;w>=0;w--){const k=o[w],N=[];h.dir=S;for(const A of p){const v=this._matchCombinator(k,A,h);v.size&&N.push(...v)}if(N.length)w===0?t=!0:p=new Set(N);else{t=!1;break}}}if(t)break}n==="not"?t||(u=e):t&&(u=e)}return u??null}_matchPseudoClassSelector(l,e,h={}){const{children:n,name:a}=l,{localName:f,parentNode:r}=e,{forgive:u,warn:d=this.#i}=h,i=new Set;if(c.REG_LOGICAL_PSEUDO.test(a)){let t;if(this.#c.has(l))t=this.#c.get(l);else{const{branches:o}=(0,y.walkAST)(l),m=[],b=[];for(const[...p]of o){for(const A of p){const v=(0,y.generateCSS)(A);m.push(v)}const w=[],k=new Set;let N=p.shift();for(;N;)if(N.type===c.COMBINATOR?(w.push({combo:N,leaves:[...k]}),k.clear()):N&&k.add(N),p.length)N=p.shift();else{w.push({combo:null,leaves:[...k]}),k.clear();break}b.push(w)}t={astName:a,branches:o,twigBranches:b,selector:m.join(",")},this.#c.set(l,t)}const s=this._matchLogicalPseudoFunc(t,e,h);s&&i.add(s)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(a)){const[t]=n;return this._matchAnPlusB(t,e,a,h)}else switch(a){case"dir":case"lang":{const t=O.matcher.matchSelector(l,e);t&&i.add(t);break}case"state":{if((0,_.isCustomElement)(e)){const[{value:t}]=n;t&&e[t]&&i.add(e)}break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${a}()`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${a}()`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}default:if(!u){const t=`Unknown pseudo-class :${a}()`;throw new DOMException(t,c.SYNTAX_ERR)}}else switch(a){case"any-link":case"link":{c.REG_ANCHOR.test(f)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(c.REG_ANCHOR.test(f)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:o}=new URL(this.#s.URL),m=new URL(e.getAttribute("href"),t);m.origin===s&&m.pathname===o&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#m??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:o}=this.#m??{};(o==="mousedown"||o==="pointerdown")&&t&c.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#s.URL);e.id&&t===`#${e.id}`&&this.#s.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#s.URL);if(t){const s=t.replace(/^#/,"");let o=this.#s.getElementById(s);for(;o;){if(o===e){i.add(e);break}o=o.parentNode}}break}case"scope":{this.#e.nodeType===c.ELEMENT_NODE?!this.#u&&e===this.#e&&i.add(e):e===this.#s.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#m??{};if(e===this.#s.activeElement&&e.tabIndex>=0&&(a==="focus"||s==="keydown"&&e.contains(t))){let o=e,m=!0;for(;o;){if(o.disabled||o.hasAttribute("disabled")||o.hidden||o.hasAttribute("hidden")){m=!1;break}else{const{display:b,visibility:p}=this.#l.getComputedStyle(o);if(m=!(b==="none"||p==="hidden"),!m)break}if(o.parentNode&&o.parentNode.nodeType===c.ELEMENT_NODE)o=o.parentNode;else break}m&&i.add(e)}break}case"focus-within":{let t,s=this.#s.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.parentNode}if(t){let o=e,m=!0;for(;o;){if(o.disabled||o.hasAttribute("disabled")||o.hidden||o.hasAttribute("hidden")){m=!1;break}else{const{display:b,visibility:p}=this.#l.getComputedStyle(o);if(m=!(b==="none"||p==="hidden"),!m)break}if(o.parentNode&&o.parentNode.nodeType===c.ELEMENT_NODE)o=o.parentNode;else break}m&&i.add(e)}break}case"open":{c.REG_INTERACT.test(f)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{c.REG_INTERACT.test(f)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(c.REG_FORM_CTRL.test(f)||(0,_.isCustomElement)(e,{formAssociated:!0}))if(e.disabled||e.hasAttribute("disabled"))i.add(e);else{let t=r;for(;t;){if(c.REG_FORM_GROUP.test(t.localName))if(t.localName==="fieldset"){if(t.disabled&&t.hasAttribute("disabled"))break}else break;t=t.parentNode}t&&r.localName!=="legend"&&(t.disabled||t.hasAttribute("disabled"))&&i.add(e)}break}case"enabled":{(c.REG_FORM_CTRL.test(f)||(0,_.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled"))&&i.add(e);break}case"read-only":{switch(f){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||c.REG_TYPE_DATE.test(e.type)||c.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,_.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(f){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||c.REG_TYPE_DATE.test(e.type)||c.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,_.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;f==="textarea"?s=e:f==="input"&&(e.hasAttribute("type")?c.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&f==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&f==="input"&&e.type==="checkbox"||f==="progress"&&!e.hasAttribute("value"))i.add(e);else if(f==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;s||(s=this.#s.documentElement);const o=s.getElementsByTagName("input"),m=o.length;let b;for(let p=0;p<m;p++){const w=o[p];if(w.getAttribute("type")==="radio"&&(t?w.getAttribute("name")===t&&(b=!!w.checked):w.hasAttribute("name")||(b=!!w.checked),b))break}b||i.add(e)}break}case"default":{if(f==="button"&&!(e.hasAttribute("type")&&c.REG_TYPE_RESET.test(e.getAttribute("type")))||f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#n;let o=(0,_.traverseNode)(t,s);for(o=s.firstChild();o&&t.contains(o);){const m=o.localName;let b;if(m==="button"?b=!(o.hasAttribute("type")&&c.REG_TYPE_RESET.test(o.getAttribute("type"))):m==="input"&&(b=o.hasAttribute("type")&&c.REG_TYPE_SUBMIT.test(o.getAttribute("type"))),b){o===e&&i.add(e);break}o=s.nextNode()}}}else if(f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_CHECK.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))i.add(e);else if(f==="option"){let t=r,s=!1;for(;t&&t.localName!=="datalist";){if(t.localName==="select"){(t.multiple||t.hasAttribute("multiple"))&&(s=!0);break}t=t.parentNode}if(s)(e.selected||e.hasAttribute("selected"))&&i.add(e);else{const o=new Set,m=this.#n;let b=(0,_.traverseNode)(r,m);for(b=m.firstChild();b;){if(b.selected||b.hasAttribute("selected")){o.add(b);break}b=m.nextSibling()}o.size&&o.has(e)&&i.add(e)}}break}case"valid":{if(c.REG_FORM_VALID.test(f))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(f==="fieldset"){const t=this.#n;let s=(0,_.traverseNode)(e,t);s=t.firstChild();let o;if(!s)o=!0;else for(;s&&e.contains(s)&&!(c.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?o=s.maxLength>=s.value.length:o=!0:o=!1,!o));)s=t.nextNode();o&&i.add(e)}break}case"invalid":{if(c.REG_FORM_VALID.test(f))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(f==="fieldset"){const t=this.#n;let s=(0,_.traverseNode)(e,t);s=t.firstChild();let o;if(!s)o=!0;else for(;s&&e.contains(s)&&!(c.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?o=s.maxLength>=s.value.length:o=!0:o=!1,!o));)s=t.nextNode();o||i.add(e)}break}case"in-range":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&c.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":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&c.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||c.REG_TYPE_CHECK.test(s)||c.REG_TYPE_DATE.test(s)||c.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||c.REG_TYPE_CHECK.test(s)||c.REG_TYPE_DATE.test(s)||c.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#s.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#r.createTreeWalker(e,c.SHOW_ALL);let s=t.firstChild(),o;for(;s&&(o=s.nodeType!==c.ELEMENT_NODE&&s.nodeType!==c.TEXT_NODE,!!o);)s=t.nextSibling();o&&i.add(e)}else i.add(e);break}case"first-child":{(r&&e===r.firstElementChild||e===this.#t)&&i.add(e);break}case"last-child":{(r&&e===r.lastElementChild||e===this.#t)&&i.add(e);break}case"only-child":{(r&&e===r.firstElementChild&&e===r.lastElementChild||e===this.#t)&&i.add(e);break}case"first-of-type":{if(r){const[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#t&&i.add(e);break}case"last-of-type":{if(r){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#t&&i.add(e);break}case"only-of-type":{if(r){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s===e&&i.add(e)}}else e===this.#t&&i.add(e);break}case"defined":{e.hasAttribute("is")||f.includes("-")?(0,_.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#l.getComputedStyle(e);t!=="none"&&i.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d){const t=`Unsupported pseudo-element ::${a}`;throw new DOMException(t,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){const t=`Unsupported pseudo-class :${a}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}default:if(a.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${a}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}}else if(!u){const t=`Unknown pseudo-class :${a}`;throw new DOMException(t,c.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(l,e){const{children:h,name:n}=l;let a;if(Array.isArray(h)){const{branches:f}=(0,y.walkAST)(h[0]),[r]=f,[...u]=r,{host:d}=e;if(n==="host"){let i;for(const t of u){const{type:s}=t;if(s===c.COMBINATOR){const m=`Invalid selector ${(0,y.generateCSS)(l)}`;throw new DOMException(m,c.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(a=e)}else if(n==="host-context"){let i=d,t;for(;i;){for(const s of u){const{type:o}=s;if(o===c.COMBINATOR){const b=`Invalid selector ${(0,y.generateCSS)(l)}`;throw new DOMException(b,c.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(a=e)}}else if(n==="host")a=e;else{const f=`Invalid selector :${n}`;throw new DOMException(f,c.SYNTAX_ERR)}return a??null}_matchSelector(l,e,h){const{type:n}=l,a=new Set;if(l.name===c.EMPTY)return a;const f=(0,y.unescapeSelector)(l.name);if(typeof f=="string"&&f!==l.name&&(l.name=f),e.nodeType===c.ELEMENT_NODE)switch(n){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(f,h);break}case c.SELECTOR_ID:{e.id===f&&a.add(e);break}case c.SELECTOR_CLASS:{e.classList.contains(f)&&a.add(e);break}case c.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(l,e,h);default:{const r=O.matcher.matchSelector(l,e,h);r&&a.add(r)}}else if(this.#u&&n===c.SELECTOR_PSEUDO_CLASS&&e.nodeType===c.DOCUMENT_FRAGMENT_NODE){if(f!=="has"&&c.REG_LOGICAL_PSEUDO.test(f))return this._matchPseudoClassSelector(l,e,h);if(c.REG_SHADOW_HOST.test(f)){const r=this._matchShadowHostPseudoClass(l,e,h);r&&a.add(r)}}return a}_matchLeaves(l,e,h){const{attributes:n,localName:a,nodeType:f}=e;let r=this.#_.get(l),u;if(r&&r.has(e)){const{attr:d,matched:i}=r.get(e);n?.length===d&&(u=i)}if(typeof u!="boolean"){let d;f===c.ELEMENT_NODE&&c.REG_FORM.test(a)?d=!1:d=!0;for(const i of l){const{name:t,type:s}=i;if(s===c.SELECTOR_PSEUDO_CLASS&&t==="dir"&&(d=!1),u=this._matchSelector(i,e,h).has(e),!u)break}d&&(r||(r=new WeakMap),r.set(e,{attr:n?.length,matched:u}),this.#_.set(l,r))}return!!u}_matchHTMLCollection(l,e={}){const{compound:h,filterLeaves:n}=e,a=new Set,f=l.length;if(f)if(h)for(let r=0;r<f;r++){const u=l[r];this._matchLeaves(n,u,e)&&a.add(u)}else{const r=[].slice.call(l);return new Set(r)}return a}_findDescendantNodes(l,e,h){const[n,...a]=l,f=a.length>0,{type:r}=n,u=(0,y.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(r){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,h);break}case c.SELECTOR_ID:{if(this.#t.nodeType===c.ELEMENT_NODE)i=!0;else{const t=this.#t.getElementById(u);t&&t!==e&&e.contains(t)&&(f?this._matchLeaves(a,t,h)&&d.add(t):d.add(t))}break}case c.SELECTOR_CLASS:{const t=e.getElementsByClassName(u);d=this._matchHTMLCollection(t,{compound:f,filterLeaves:a});break}case c.SELECTOR_TYPE:{if(this.#s.contentType==="text/html"&&!/[*|]/.test(u)){const t=e.getElementsByTagName(u);d=this._matchHTMLCollection(t,{compound:f,filterLeaves:a})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(l,e,h={}){const{combo:n,leaves:a}=l,{name:f}=n,{parentNode:r}=e,{dir:u}=h,d=new Set;if(u===x)switch(f){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(a,i,h)&&d.add(i);break}case"~":{if(r){const i=this._createTreeWalker(r);let t=(0,_.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(a,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,_.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(a,t,h)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(a,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let o=(0,_.traverseNode)(e,s);for(o=s.nextNode();o&&e.contains(o);)this._matchLeaves(a,o,h)&&d.add(o),o=s.nextNode()}}}else switch(f){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(a,i,h)&&d.add(i);break}case"~":{if(r){const i=this._createTreeWalker(r);let t=(0,_.traverseNode)(r,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(a,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{r&&this._matchLeaves(a,r,h)&&d.add(r);break}case" ":default:{const i=[];let t=r;for(;t;)this._matchLeaves(a,t,h)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(l,e){const{node:h}=e;let n=(0,_.traverseNode)(h,this.#o),a;if(n)for(n.nodeType!==c.ELEMENT_NODE?n=this.#o.nextNode():n===h&&n!==this.#t&&(n=this.#o.nextNode());n;){if(this._matchLeaves(l,n,{warn:this.#i})){a=n;break}n=this.#o.nextNode()}return a??null}_matchSelf(l){const e=[],h=this._matchLeaves(l,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(l,e={}){const{complex:h}=e,n=[];let a=this._matchLeaves(l,this.#e,{warn:this.#i}),f=!1;if(a&&(n.push(this.#e),f=!0),!a||h){let r=this.#e.parentNode;for(;r&&(a=this._matchLeaves(l,r,{warn:this.#i}),a&&(n.push(r),f=!0),r.parentNode);)r=r.parentNode}return[n,f]}_findFirst(l){const e=[],h=this._findNode(l,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(l,e={}){const{complex:h,compound:n,filterLeaves:a,targetType:f}=e;let r=[],u=!1,d=!1;const i=l.length;if(i)if(this.#e.nodeType===c.ELEMENT_NODE)for(let t=0;t<i;t++){const s=l[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(n){if(this._matchLeaves(a,s,{warn:this.#i})&&(r.push(s),u=!0,f===E))break}else if(r.push(s),u=!0,f===E)break}}else if(h)if(n)for(let t=0;t<i;t++){const s=l[t];if(this._matchLeaves(a,s,{warn:this.#i})&&(r.push(s),u=!0,f===E))break}else r=[].slice.call(l),u=!0,d=!0;else if(n)for(let t=0;t<i;t++){const s=l[t];if(this._matchLeaves(a,s,{warn:this.#i})&&(r.push(s),u=!0,f===E))break}else r=[].slice.call(l),u=!0,d=!0;return[r,u,d]}_findEntryNodes(l,e,h){const{leaves:n}=l,[a,...f]=n,r=f.length>0,{name:u,type:d}=a;let i=[],t=!1,s=!1,o=!1;switch(d){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,{warn:this.#i});break}case c.SELECTOR_ID:{if(e===R)[i,s]=this._matchSelf(n);else if(e===C)[i,s]=this._findLineal(n,{complex:h});else if(e===E&&this.#t.nodeType!==c.ELEMENT_NODE){const m=this.#t.getElementById(u);m&&(r?this._matchLeaves(f,m,{warn:this.#i})&&(i.push(m),s=!0):(i.push(m),s=!0))}else e===E?[i,s]=this._findFirst(n):o=!0;break}case c.SELECTOR_CLASS:{if(e===R)[i,s]=this._matchSelf(n);else if(e===C)[i,s]=this._findLineal(n,{complex:h});else if(this.#t.nodeType===c.DOCUMENT_NODE){const m=this.#t.getElementsByClassName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:h,compound:r,filterLeaves:f,targetType:e}))}else e===E?[i,s]=this._findFirst(n):o=!0;break}case c.SELECTOR_TYPE:{if(e===R)[i,s]=this._matchSelf(n);else if(e===C)[i,s]=this._findLineal(n,{complex:h});else if(this.#s.contentType==="text/html"&&this.#t.nodeType===c.DOCUMENT_NODE&&!/[*|]/.test(u)){const m=this.#t.getElementsByTagName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:h,compound:r,filterLeaves:f,targetType:e}))}else e===E?[i,s]=this._findFirst(n):o=!0;break}default:if(e!==C&&c.REG_SHADOW_HOST.test(u)){if(this.#u&&this.#e.nodeType===c.DOCUMENT_FRAGMENT_NODE){const m=this._matchShadowHostPseudoClass(a,this.#e);m&&(i.push(m),s=!0)}}else e===R?[i,s]=this._matchSelf(n):e===C?[i,s]=this._findLineal(n,{complex:h}):e===E?[i,s]=this._findFirst(n):o=!0}return{collected:t,compound:r,filtered:s,nodes:i,pending:o}}_collectNodes(l){const e=this.#a.values();if(l===L||l===E){const h=new Set;let n=0;for(const{branch:a}of e){const f=a.length,r=f>1,u=a[0];let d,i;if(r){const{combo:p,leaves:[{name:w,type:k}]}=u,N=a[f-1],{leaves:[{name:A,type:v}]}=N;if(v===c.SELECTOR_PSEUDO_ELEMENT||v===c.SELECTOR_ID)d=S,i=N;else if(k===c.SELECTOR_PSEUDO_ELEMENT||k===c.SELECTOR_ID)d=x,i=u;else if(l===L)if(w==="*"&&k===c.SELECTOR_TYPE)d=S,i=N;else if(A==="*"&&v===c.SELECTOR_TYPE)d=x,i=u;else if(f===2){const{name:T}=p;/^[+~]$/.test(T)?(d=S,i=N):(d=x,i=u)}else d=x,i=u;else if(A==="*"&&v===c.SELECTOR_TYPE)d=x,i=u;else if(w==="*"&&k===c.SELECTOR_TYPE)d=S,i=N;else{let T;for(const{combo:P,leaves:[U]}of a){const{name:G,type:$}=U;if($===c.SELECTOR_PSEUDO_CLASS&&G==="dir"){T=!1;break}if(!T&&P){const{name:F}=P;/^[+~]$/.test(F)&&(T=!0)}}T?(d=x,i=u):(d=S,i=N)}}else d=S,i=u;const{collected:t,compound:s,filtered:o,nodes:m,pending:b}=this._findEntryNodes(i,l,r);m.length?(this.#a[n].find=!0,this.#d[n]=m):b&&h.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=t,this.#a[n].dir=d,this.#a[n].filtered=o||!s,n++}if(h.size){let a,f;this.#e!==this.#t&&this.#e.nodeType===c.ELEMENT_NODE?(a=this.#e,f=this.#o):(a=this.#t,f=this.#n);let r=(0,_.traverseNode)(a,f);for(;r;){let u=!1;if(this.#e.nodeType===c.ELEMENT_NODE?r===this.#e?u=!0:u=this.#e.contains(r):u=!0,u)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,r,{warn:this.#i})){const s=d.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#d[s].push(r)}}r!==f.currentNode&&(r=(0,_.traverseNode)(r,f)),r=f.nextNode()}}}else{let h=0;for(const{branch:n}of e){const a=n[n.length-1],f=n.length>1,{compound:r,filtered:u,nodes:d}=this._findEntryNodes(a,l,f);d.length&&(this.#a[h].find=!0,this.#d[h]=d),this.#a[h].dir=S,this.#a[h].filtered=u||!r,h++}}return[this.#a,this.#d]}_getCombinedNodes(l,e,h){const n=[];for(const a of e){const f=this._matchCombinator(l,a,{dir:h,warn:this.#i});f.size&&n.push(...f)}return n.length?new Set(n):new Set}_matchNodeNext(l,e,h){const{combo:n,index:a}=h,{combo:f,leaves:r}=l[a],u={combo:n,leaves:r},d=this._getCombinedNodes(u,e,x);let i;if(d.size)if(a===l.length-1){const[t]=(0,_.sortNodes)(d);i=t}else i=this._matchNodeNext(l,d,{combo:f,index:a+1});return i??null}_matchNodePrev(l,e,h){const{index:n}=h,a=l[n],f=new Set([e]),r=this._getCombinedNodes(a,f,S);let u;if(r.size){if(n===0)u=e;else for(const d of r)if(this._matchNodePrev(l,d,{index:n-1}))return e}return u??null}_find(l){(l===L||l===E)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(l),n=e.length;let a=new Set;for(let f=0;f<n;f++){const{branch:r,collected:u,dir:d,find:i}=e[f],t=r.length;if(t&&i){const s=h[f],o=s.length,m=t-1;if(m===0)if((l===L||l===E)&&this.#e.nodeType===c.ELEMENT_NODE)for(let b=0;b<o;b++){const p=s[b];if(p!==this.#e&&this.#e.contains(p)&&(a.add(p),l!==L))break}else if(l===L)if(a.size){const b=[...a];a=new Set([...b,...s]),this.#b=!0}else a=new Set(s);else{const[b]=s;a.add(b)}else if(l===L)if(d===x){let{combo:b}=r[0];for(const p of s){let w=new Set([p]);for(let k=1;k<t;k++){const{combo:N,leaves:A}=r[k],v={combo:b,leaves:A};if(w=this._getCombinedNodes(v,w,d),w.size)if(k===m)if(a.size){const T=[...a];a=new Set([...T,...w]),this.#b=!0}else a=w;else b=N;else break}}}else for(const b of s){let p=new Set([b]);for(let w=m-1;w>=0;w--){const k=r[w];if(p=this._getCombinedNodes(k,p,d),p.size)w===0&&(a.add(b),t>1&&a.size>1&&(this.#b=!0));else break}}else if(l===E&&d===x){const{combo:b}=r[0];let p;for(const w of s)if(p=this._matchNodeNext(r,new Set([w]),{combo:b,index:1}),p){a.add(p);break}if(!p&&!u){const{leaves:w}=r[0],[k]=s;let N=this._findNode(w,{node:k});for(;N;){if(p=this._matchNodeNext(r,new Set([N]),{combo:b,index:1}),p){a.add(p);break}N=this._findNode(w,{node:N})}}}else{let b;for(const p of s)if(b=this._matchNodePrev(r,p,{index:m-1}),b){a.add(p);break}if(!b&&!u&&l===E){const{leaves:p}=r[m],[w]=s;let k=this._findNode(p,{node:w});for(;k;){if(b=this._matchNodePrev(r,k,{index:m-1}),b){a.add(k);break}k=this._findNode(p,{node:k})}}}}}return a}matches(l,e,h){let n;try{if(e?.nodeType!==c.ELEMENT_NODE){const r=`Unexpected node ${e?.nodeName}`;throw new TypeError(r)}const a=e.ownerDocument;if(a===this.#r&&a.contentType==="text/html"){const r={complex:c.REG_COMPLEX_A.test(l),descendant:!0};if((0,y.filterSelector)(l,r))return this.#f.match(l,e)}this._setup(l,e,h),n=this._find(R).size}catch(a){this._onError(a)}return!!n}closest(l,e,h){let n;try{if(e?.nodeType!==c.ELEMENT_NODE){const r=`Unexpected node ${e?.nodeName}`;throw new TypeError(r)}const a=e.ownerDocument;if(a===this.#r&&a.contentType==="text/html"){const r={complex:c.REG_COMPLEX_A.test(l),descendant:!0};if((0,y.filterSelector)(l,r))return this.#f.closest(l,e)}this._setup(l,e,h);const f=this._find(C);if(f.size){let r=this.#e;for(;r;){if(f.has(r)){n=r;break}r=r.parentNode}}}catch(a){this._onError(a)}return n??null}querySelector(l,e,h){let n;try{(0,_.verifyNode)(e);let a;if(e.nodeType===c.DOCUMENT_NODE?a=e:a=e.ownerDocument,a===this.#r&&a.contentType==="text/html"){const r={complex:c.REG_COMPLEX_B.test(l),descendant:!1};if((0,y.filterSelector)(l,r))return this.#f.first(l,e)}this._setup(l,e,h);const f=this._find(E);f.delete(this.#e),f.size&&([n]=(0,_.sortNodes)(f))}catch(a){this._onError(a)}return n??null}querySelectorAll(l,e,h){let n;try{(0,_.verifyNode)(e);let a;if(e.nodeType===c.DOCUMENT_NODE?a=e:a=e.ownerDocument,a===this.#r&&a.contentType==="text/html"){const r={complex:c.REG_COMPLEX_B.test(l),descendant:!0};if((0,y.filterSelector)(l,r))return this.#f.select(l,e)}this._setup(l,e,h);const f=this._find(L);f.delete(this.#e),f.size&&(this.#b?n=(0,_.sortNodes)(f):n=[...f])}catch(a){this._onError(a)}return n??[]}}0&&(module.exports={Finder});
var z=Object.create;var M=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var Y=(g,l)=>{for(var e in l)M(g,e,{get:l[e],enumerable:!0})},P=(g,l,e,h)=>{if(l&&typeof l=="object"||typeof l=="function")for(let r of W(l))!j.call(g,r)&&r!==e&&M(g,r,{get:()=>l[r],enumerable:!(h=H(l,r))||h.enumerable});return g};var q=(g,l,e)=>(e=g!=null?z(B(g)):{},P(l||!g||!g.__esModule?M(e,"default",{value:g,enumerable:!0}):e,g)),V=g=>P(M({},"__esModule",{value:!0}),g);var K={};Y(K,{Finder:()=>X});module.exports=V(K);var I=q(require("@asamuzakjp/nwsapi"),1),_=require("./dom-util.js"),O=require("./matcher.js"),y=require("./parser.js"),c=require("./constant.js");const x="next",S="prev",L="all",E="first",C="lineal",R="self";class X{#a;#c;#s;#h;#w;#r;#m;#e;#d;#k;#f;#o;#_;#t;#u;#b;#n;#p;#i;#l;constructor(l,e){this.#l=l,this.#r=e??l.document,this.#c=new WeakMap,this.#h=new WeakMap,this.#_=new WeakMap,this._initNwsapi()}_onError(l){if(!this.#k)if(l instanceof DOMException||l instanceof this.#l.DOMException)if(l.name===c.NOT_SUPPORTED_ERR)this.#i&&console.warn(l.message);else throw new this.#l.DOMException(l.message,l.name);else throw l}_setup(l,e,h={}){const{event:r,noexcept:a,warn:f}=h;return this.#k=!!a,this.#i=!!f,this.#m=this._setEvent(r),this.#e=e,[this.#s,this.#t,this.#n]=(0,_.resolveContent)(e),this.#u=(0,_.isInShadowTree)(e),[this.#a,this.#d]=this._correspond(l),this.#p=new WeakMap,e}_initNwsapi(){return this.#f=(0,I.default)({DOMException:this.#l.DOMException,document:this.#r}),this.#f.configure({LOGERRORS:!1}),this.#f}_setEvent(l){return l instanceof this.#l.KeyboardEvent||l instanceof this.#l.MouseEvent?l:null}_correspond(l){const e=[];this.#w=!1;let h;if(this.#h.has(this.#s)){const r=this.#h.get(this.#s);if(r&&r.has(`${l}`)){const a=r.get(`${l}`);this.#w=a.descendant,h=a.ast}}if(h){const r=h.length;for(let a=0;a<r;a++)h[a].collected=!1,h[a].dir=null,h[a].filtered=!1,h[a].find=!1,e[a]=[]}else{let r;try{r=(0,y.parseSelector)(l)}catch(t){this._onError(t)}const{branches:a,info:{hasHasPseudoFunc:f,hasHyphenSepAttr:n}}=(0,y.walkAST)(r);let u;f||n?u=!1:u=!0;let d=!1,i=0;h=[];for(const[...t]of a){const s=[];let o=t.shift();if(o&&o.type!==c.COMBINATOR){const m=new Set;for(;o;){if(o.type===c.COMBINATOR){const[b]=t;if(b.type===c.COMBINATOR){const w=`Invalid selector ${l}`;throw new DOMException(w,c.SYNTAX_ERR)}const p=o.name;/^[\s>]$/.test(p)&&(d=!0),s.push({combo:o,leaves:(0,y.sortAST)(m)}),m.clear()}else if(o){let{name:b}=o;b&&typeof b=="string"&&(b=(0,y.unescapeSelector)(b),typeof b=="string"&&b!==o.name&&(o.name=b),/[|:]/.test(b)&&(o.namespace=!0)),m.add(o)}if(t.length)o=t.shift();else{s.push({combo:null,leaves:(0,y.sortAST)(m)}),m.clear();break}}}h.push({branch:s,collected:!1,dir:null,filtered:!1,find:!1}),e[i]=[],i++}if(u){let t;this.#h.has(this.#s)?t=this.#h.get(this.#s):t=new Map,t.set(`${l}`,{ast:h,descendant:d}),this.#h.set(this.#s,t)}this.#w=d}return[h,e]}_createTreeWalker(l){let e;return this.#p.has(l)?e=this.#p.get(l):(e=this.#r.createTreeWalker(l,c.WALKER_FILTER),this.#p.set(l,e)),e}_prepareQuerySelectorWalker(){return this.#o=this._createTreeWalker(this.#e),this.#b=!1,this.#o}_collectNthChild(l,e,h){const{a:r,b:a,reverse:f,selector:n}=l,{parentNode:u}=e,d=new Set;let i;if(n)if(this.#c.has(n))i=this.#c.get(n);else{const{branches:t}=(0,y.walkAST)(n);i=t,this.#c.set(n,i)}if(u){const t=this.#n;let s=(0,_.traverseNode)(u,t);s=t.firstChild();let o=0;for(;s;)o++,s=t.nextSibling();s=(0,_.traverseNode)(u,t);const m=new Set;if(i)for(s=t.firstChild();s;){let b;for(const p of i)if(b=this._matchLeaves(p,s,h),!b)break;b&&m.add(s),s=t.nextSibling()}if(r===0){if(a>0&&a<=o){if(m.size){s=(0,_.traverseNode)(u,t),f?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(m.has(s)){if(b===a-1){d.add(s);break}b++}f?s=t.previousSibling():s=t.nextSibling()}}else if(!n){s=(0,_.traverseNode)(u,t),f?s=t.lastChild():s=t.firstChild();let b=0;for(;s;){if(b===a-1){d.add(s);break}f?s=t.previousSibling():s=t.nextSibling(),b++}}}}else{let b=a-1;if(r>0)for(;b<0;)b+=r;if(b>=0&&b<o){s=(0,_.traverseNode)(u,t),f?s=t.lastChild():s=t.firstChild();let p=0,w=r>0?0:a-1;for(;s&&(s&&b>=0&&b<o);)m.size?m.has(s)&&(w===b&&(d.add(s),b+=r),r>0?w++:w--):p===b&&(n||d.add(s),b+=r),f?s=t.previousSibling():s=t.nextSibling(),p++}}if(f&&d.size>1){const b=[...d];return new Set(b.reverse())}}else if(e===this.#t&&r+a===1)if(i){let t;for(const s of i)if(t=this._matchLeaves(s,e,h),t)break;t&&d.add(e)}else d.add(e);return d}_collectNthOfType(l,e){const{a:h,b:r,reverse:a}=l,{localName:f,parentNode:n,prefix:u}=e,d=new Set;if(n){const i=this.#n;let t=(0,_.traverseNode)(n,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(h===0){if(r>0&&r<=s){t=(0,_.traverseNode)(n,i),a?t=i.lastChild():t=i.firstChild();let o=0;for(;t;){const{localName:m,prefix:b}=t;if(m===f&&b===u){if(o===r-1){d.add(t);break}o++}a?t=i.previousSibling():t=i.nextSibling()}}}else{let o=r-1;if(h>0)for(;o<0;)o+=h;if(o>=0&&o<s){t=(0,_.traverseNode)(n,i),a?t=i.lastChild():t=i.firstChild();let m=h>0?0:r-1;for(;t;){const{localName:b,prefix:p}=t;if(b===f&&p===u){if(m===o&&(d.add(t),o+=h),o<0||o>=s)break;h>0?m++:m--}a?t=i.previousSibling():t=i.nextSibling()}}}if(a&&d.size>1){const o=[...d];return new Set(o.reverse())}}else e===this.#t&&h+r===1&&d.add(e);return d}_matchAnPlusB(l,e,h,r){const{nth:{a,b:f,name:n},selector:u}=l,d=new Map;if(n?(n==="even"?(d.set("a",2),d.set("b",0)):n==="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 f=="string"&&/-?\d+/.test(f)?d.set("b",f*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,r)}else if(/^nth-(?:last-)?of-type$/.test(h)){const i=Object.fromEntries(d);return this._collectNthOfType(i,e)}return new Set}_matchHasPseudoFunc(l,e,h={}){let r;if(Array.isArray(l)&&l.length){const a=l.map(s=>s),[f]=a,{type:n}=f;let u;n===c.COMBINATOR?u=a.shift():u={name:" ",type:c.COMBINATOR};const d=[];for(;a.length;){const[s]=a,{type:o}=s;if(o===c.COMBINATOR)break;d.push(a.shift())}const i={combo:u,leaves:d};h.dir=x;const t=this._matchCombinator(i,e,h);if(t.size)if(a.length){for(const s of t)if(r=this._matchHasPseudoFunc(a,s,h),r)break}else r=!0}return!!r}_matchLogicalPseudoFunc(l,e,h={}){const{astName:r="",branches:a=[],selector:f="",twigBranches:n=[]}=l;let u;if(r==="has")if(f.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(r);h.forgive=d;const i=n.length;let t;for(let s=0;s<i;s++){const o=n[s],m=o.length-1,{leaves:b}=o[m];if(t=this._matchLeaves(b,e,h),t&&m>0){let p=new Set([e]);for(let w=m-1;w>=0;w--){const k=o[w],N=[];h.dir=S;for(const A of p){const v=this._matchCombinator(k,A,h);v.size&&N.push(...v)}if(N.length)w===0?t=!0:p=new Set(N);else{t=!1;break}}}if(t)break}r==="not"?t||(u=e):t&&(u=e)}return u??null}_matchPseudoClassSelector(l,e,h={}){const{children:r,name:a}=l,{localName:f,parentNode:n}=e,{forgive:u,warn:d=this.#i}=h,i=new Set;if(c.REG_LOGICAL_PSEUDO.test(a)){let t;if(this.#c.has(l))t=this.#c.get(l);else{const{branches:o}=(0,y.walkAST)(l),m=[],b=[];for(const[...p]of o){for(const A of p){const v=(0,y.generateCSS)(A);m.push(v)}const w=[],k=new Set;let N=p.shift();for(;N;)if(N.type===c.COMBINATOR?(w.push({combo:N,leaves:[...k]}),k.clear()):N&&k.add(N),p.length)N=p.shift();else{w.push({combo:null,leaves:[...k]}),k.clear();break}b.push(w)}t={astName:a,branches:o,twigBranches:b,selector:m.join(",")},this.#c.set(l,t)}const s=this._matchLogicalPseudoFunc(t,e,h);s&&i.add(s)}else if(Array.isArray(r))if(/^nth-(?:last-)?(?:child|of-type)$/.test(a)){const[t]=r;return this._matchAnPlusB(t,e,a,h)}else switch(a){case"dir":case"lang":{const t=O.matcher.matchSelector(l,e);t&&i.add(t);break}case"state":{if((0,_.isCustomElement)(e)){const[{value:t}]=r;t&&e[t]&&i.add(e)}break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${a}()`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${a}()`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}default:if(!u){const t=`Unknown pseudo-class :${a}()`;throw new DOMException(t,c.SYNTAX_ERR)}}else switch(a){case"any-link":case"link":{c.REG_ANCHOR.test(f)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(c.REG_ANCHOR.test(f)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:o}=new URL(this.#s.URL),m=new URL(e.getAttribute("href"),t);m.origin===s&&m.pathname===o&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#m??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:o}=this.#m??{};(o==="mousedown"||o==="pointerdown")&&t&c.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#s.URL);e.id&&t===`#${e.id}`&&this.#s.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#s.URL);if(t){const s=t.replace(/^#/,"");let o=this.#s.getElementById(s);for(;o;){if(o===e){i.add(e);break}o=o.parentNode}}break}case"scope":{this.#e.nodeType===c.ELEMENT_NODE?!this.#u&&e===this.#e&&i.add(e):e===this.#s.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#m??{};if(e===this.#s.activeElement&&e.tabIndex>=0&&(a==="focus"||s==="keydown"&&e.contains(t))){let o=e,m=!0;for(;o;){if(o.disabled||o.hasAttribute("disabled")||o.hidden||o.hasAttribute("hidden")){m=!1;break}else{const{display:b,visibility:p}=this.#l.getComputedStyle(o);if(m=!(b==="none"||p==="hidden"),!m)break}if(o.parentNode&&o.parentNode.nodeType===c.ELEMENT_NODE)o=o.parentNode;else break}m&&i.add(e)}break}case"focus-within":{let t,s=this.#s.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.parentNode}if(t){let o=e,m=!0;for(;o;){if(o.disabled||o.hasAttribute("disabled")||o.hidden||o.hasAttribute("hidden")){m=!1;break}else{const{display:b,visibility:p}=this.#l.getComputedStyle(o);if(m=!(b==="none"||p==="hidden"),!m)break}if(o.parentNode&&o.parentNode.nodeType===c.ELEMENT_NODE)o=o.parentNode;else break}m&&i.add(e)}break}case"open":{c.REG_INTERACT.test(f)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{c.REG_INTERACT.test(f)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(c.REG_FORM_CTRL.test(f)||(0,_.isCustomElement)(e,{formAssociated:!0}))if(e.disabled||e.hasAttribute("disabled"))i.add(e);else{let t=n;for(;t;){if(c.REG_FORM_GROUP.test(t.localName))if(t.localName==="fieldset"){if(t.disabled&&t.hasAttribute("disabled"))break}else break;t=t.parentNode}t&&n.localName!=="legend"&&(t.disabled||t.hasAttribute("disabled"))&&i.add(e)}break}case"enabled":{(c.REG_FORM_CTRL.test(f)||(0,_.isCustomElement)(e,{formAssociated:!0}))&&!(e.disabled&&e.hasAttribute("disabled"))&&i.add(e);break}case"read-only":{switch(f){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||c.REG_TYPE_DATE.test(e.type)||c.REG_TYPE_TEXT.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,_.isContentEditable)(e)||i.add(e)}break}case"read-write":{switch(f){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||c.REG_TYPE_DATE.test(e.type)||c.REG_TYPE_TEXT.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}default:(0,_.isContentEditable)(e)&&i.add(e)}break}case"placeholder-shown":{let t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;f==="textarea"?s=e:f==="input"&&(e.hasAttribute("type")?c.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&f==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&f==="input"&&e.type==="checkbox"||f==="progress"&&!e.hasAttribute("value"))i.add(e);else if(f==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const t=e.name;let s=e.parentNode;for(;s&&s.localName!=="form";)s=s.parentNode;s||(s=this.#s.documentElement);const o=s.getElementsByTagName("input"),m=o.length;let b;for(let p=0;p<m;p++){const w=o[p];if(w.getAttribute("type")==="radio"&&(t?w.getAttribute("name")===t&&(b=!!w.checked):w.hasAttribute("name")||(b=!!w.checked),b))break}b||i.add(e)}break}case"default":{if(f==="button"&&!(e.hasAttribute("type")&&c.REG_TYPE_RESET.test(e.getAttribute("type")))||f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#n;let o=(0,_.traverseNode)(t,s);for(o=s.firstChild();o&&t.contains(o);){const m=o.localName;let b;if(m==="button"?b=!(o.hasAttribute("type")&&c.REG_TYPE_RESET.test(o.getAttribute("type"))):m==="input"&&(b=o.hasAttribute("type")&&c.REG_TYPE_SUBMIT.test(o.getAttribute("type"))),b){o===e&&i.add(e);break}o=s.nextNode()}}}else if(f==="input"&&e.hasAttribute("type")&&c.REG_TYPE_CHECK.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))i.add(e);else if(f==="option"){let t=n,s=!1;for(;t&&t.localName!=="datalist";){if(t.localName==="select"){(t.multiple||t.hasAttribute("multiple"))&&(s=!0);break}t=t.parentNode}if(s)(e.selected||e.hasAttribute("selected"))&&i.add(e);else{const o=new Set,m=this.#n;let b=(0,_.traverseNode)(n,m);for(b=m.firstChild();b;){if(b.selected||b.hasAttribute("selected")){o.add(b);break}b=m.nextSibling()}o.size&&o.has(e)&&i.add(e)}}break}case"valid":{if(c.REG_FORM_VALID.test(f))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(f==="fieldset"){const t=this.#n;let s=(0,_.traverseNode)(e,t);s=t.firstChild();let o;if(!s)o=!0;else for(;s&&e.contains(s)&&!(c.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?o=s.maxLength>=s.value.length:o=!0:o=!1,!o));)s=t.nextNode();o&&i.add(e)}break}case"invalid":{if(c.REG_FORM_VALID.test(f))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(f==="fieldset"){const t=this.#n;let s=(0,_.traverseNode)(e,t);s=t.firstChild();let o;if(!s)o=!0;else for(;s&&e.contains(s)&&!(c.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?o=s.maxLength>=s.value.length:o=!0:o=!1,!o));)s=t.nextNode();o||i.add(e)}break}case"in-range":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&c.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":{f==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&c.REG_TYPE_RANGE.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&i.add(e);break}case"required":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||c.REG_TYPE_CHECK.test(s)||c.REG_TYPE_DATE.test(s)||c.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&(e.required||e.hasAttribute("required"))&&i.add(e);break}case"optional":{let t;if(/^(?:select|textarea)$/.test(f))t=e;else if(f==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||c.REG_TYPE_CHECK.test(s)||c.REG_TYPE_DATE.test(s)||c.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(e.required||e.hasAttribute("required"))&&i.add(e);break}case"root":{e===this.#s.documentElement&&i.add(e);break}case"empty":{if(e.hasChildNodes()){const t=this.#r.createTreeWalker(e,c.SHOW_ALL);let s=t.firstChild(),o;for(;s&&(o=s.nodeType!==c.ELEMENT_NODE&&s.nodeType!==c.TEXT_NODE,!!o);)s=t.nextSibling();o&&i.add(e)}else i.add(e);break}case"first-child":{(n&&e===n.firstElementChild||e===this.#t)&&i.add(e);break}case"last-child":{(n&&e===n.lastElementChild||e===this.#t)&&i.add(e);break}case"only-child":{(n&&e===n.firstElementChild&&e===n.lastElementChild||e===this.#t)&&i.add(e);break}case"first-of-type":{if(n){const[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#t&&i.add(e);break}case"last-of-type":{if(n){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#t&&i.add(e);break}case"only-of-type":{if(n){const[t]=this._collectNthOfType({a:0,b:1},e);if(t===e){const[s]=this._collectNthOfType({a:0,b:1,reverse:!0},e);s===e&&i.add(e)}}else e===this.#t&&i.add(e);break}case"defined":{e.hasAttribute("is")||f.includes("-")?(0,_.isCustomElement)(e)&&i.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&i.add(e);break}case"popover-open":{if(e.popover){const{display:t}=this.#l.getComputedStyle(e);t!=="none"&&i.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(d){const t=`Unsupported pseudo-element ::${a}`;throw new DOMException(t,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){const t=`Unsupported pseudo-class :${a}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}break}default:if(a.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${a}`;throw new DOMException(t,c.NOT_SUPPORTED_ERR)}}else if(!u){const t=`Unknown pseudo-class :${a}`;throw new DOMException(t,c.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(l,e){const{children:h,name:r}=l;let a;if(Array.isArray(h)){const{branches:f}=(0,y.walkAST)(h[0]),[n]=f,[...u]=n,{host:d}=e;if(r==="host"){let i;for(const t of u){const{type:s}=t;if(s===c.COMBINATOR){const m=`Invalid selector ${(0,y.generateCSS)(l)}`;throw new DOMException(m,c.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(a=e)}else if(r==="host-context"){let i=d,t;for(;i;){for(const s of u){const{type:o}=s;if(o===c.COMBINATOR){const b=`Invalid selector ${(0,y.generateCSS)(l)}`;throw new DOMException(b,c.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(a=e)}}else if(r==="host")a=e;else{const f=`Invalid selector :${r}`;throw new DOMException(f,c.SYNTAX_ERR)}return a??null}_matchSelector(l,e,h){const{type:r}=l,a=new Set;if(l.name===c.EMPTY)return a;const f=(0,y.unescapeSelector)(l.name);if(typeof f=="string"&&f!==l.name&&(l.name=f),e.nodeType===c.ELEMENT_NODE)switch(r){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(f,h);break}case c.SELECTOR_ID:{e.id===f&&a.add(e);break}case c.SELECTOR_CLASS:{e.classList.contains(f)&&a.add(e);break}case c.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(l,e,h);default:{const n=O.matcher.matchSelector(l,e,h);n&&a.add(n)}}else if(this.#u&&r===c.SELECTOR_PSEUDO_CLASS&&e.nodeType===c.DOCUMENT_FRAGMENT_NODE){if(f!=="has"&&c.REG_LOGICAL_PSEUDO.test(f))return this._matchPseudoClassSelector(l,e,h);if(c.REG_SHADOW_HOST.test(f)){const n=this._matchShadowHostPseudoClass(l,e,h);n&&a.add(n)}}return a}_matchLeaves(l,e,h){const{attributes:r,localName:a,nodeType:f}=e;let n=this.#_.get(l),u;if(n&&n.has(e)){const{attr:d,matched:i}=n.get(e);r?.length===d&&(u=i)}if(typeof u!="boolean"){let d;f===c.ELEMENT_NODE&&c.REG_FORM.test(a)?d=!1:d=!0;for(const i of l){const{name:t,type:s}=i;if(s===c.SELECTOR_PSEUDO_CLASS&&t==="dir"&&(d=!1),u=this._matchSelector(i,e,h).has(e),!u)break}d&&(n||(n=new WeakMap),n.set(e,{attr:r?.length,matched:u}),this.#_.set(l,n))}return!!u}_matchHTMLCollection(l,e={}){const{compound:h,filterLeaves:r}=e,a=new Set,f=l.length;if(f)if(h)for(let n=0;n<f;n++){const u=l[n];this._matchLeaves(r,u,e)&&a.add(u)}else{const n=[].slice.call(l);return new Set(n)}return a}_findDescendantNodes(l,e,h){const[r,...a]=l,f=a.length>0,{type:n}=r,u=(0,y.unescapeSelector)(r.name);typeof u=="string"&&u!==r.name&&(r.name=u);let d=new Set,i=!1;if(this.#u)i=!0;else switch(n){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,h);break}case c.SELECTOR_ID:{if(this.#t.nodeType===c.ELEMENT_NODE)i=!0;else{const t=this.#t.getElementById(u);t&&t!==e&&e.contains(t)&&(f?this._matchLeaves(a,t,h)&&d.add(t):d.add(t))}break}case c.SELECTOR_CLASS:{const t=e.getElementsByClassName(u);d=this._matchHTMLCollection(t,{compound:f,filterLeaves:a});break}case c.SELECTOR_TYPE:{if(this.#s.contentType==="text/html"&&!/[*|]/.test(u)){const t=e.getElementsByTagName(u);d=this._matchHTMLCollection(t,{compound:f,filterLeaves:a})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(l,e,h={}){const{combo:r,leaves:a}=l,{name:f}=r,{parentNode:n}=e,{dir:u}=h,d=new Set;if(u===x)switch(f){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(a,i,h)&&d.add(i);break}case"~":{if(n){const i=this._createTreeWalker(n);let t=(0,_.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(a,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,_.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(a,t,h)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(a,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let o=(0,_.traverseNode)(e,s);for(o=s.nextNode();o&&e.contains(o);)this._matchLeaves(a,o,h)&&d.add(o),o=s.nextNode()}}}else switch(f){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(a,i,h)&&d.add(i);break}case"~":{if(n){const i=this._createTreeWalker(n);let t=(0,_.traverseNode)(n,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(a,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{n&&this._matchLeaves(a,n,h)&&d.add(n);break}case" ":default:{const i=[];let t=n;for(;t;)this._matchLeaves(a,t,h)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(l,e){const{node:h}=e;let r=(0,_.traverseNode)(h,this.#o),a;if(r)for(r.nodeType!==c.ELEMENT_NODE?r=this.#o.nextNode():r===h&&r!==this.#t&&(r=this.#o.nextNode());r;){if(this._matchLeaves(l,r,{warn:this.#i})){a=r;break}r=this.#o.nextNode()}return a??null}_matchSelf(l){const e=[],h=this._matchLeaves(l,this.#e,{warn:this.#i});let r=!1;return h&&(e.push(this.#e),r=!0),[e,r]}_findLineal(l,e={}){const{complex:h}=e,r=[];let a=this._matchLeaves(l,this.#e,{warn:this.#i}),f=!1;if(a&&(r.push(this.#e),f=!0),!a||h){let n=this.#e.parentNode;for(;n&&(a=this._matchLeaves(l,n,{warn:this.#i}),a&&(r.push(n),f=!0),n.parentNode);)n=n.parentNode}return[r,f]}_findFirst(l){const e=[],h=this._findNode(l,{node:this.#e});let r=!1;return h&&(e.push(h),r=!0),[e,r]}_findFromHTMLCollection(l,e={}){const{complex:h,compound:r,filterLeaves:a,targetType:f}=e;let n=[],u=!1,d=!1;const i=l.length;if(i)if(this.#e.nodeType===c.ELEMENT_NODE)for(let t=0;t<i;t++){const s=l[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(r){if(this._matchLeaves(a,s,{warn:this.#i})&&(n.push(s),u=!0,f===E))break}else if(n.push(s),u=!0,f===E)break}}else if(h)if(r)for(let t=0;t<i;t++){const s=l[t];if(this._matchLeaves(a,s,{warn:this.#i})&&(n.push(s),u=!0,f===E))break}else n=[].slice.call(l),u=!0,d=!0;else if(r)for(let t=0;t<i;t++){const s=l[t];if(this._matchLeaves(a,s,{warn:this.#i})&&(n.push(s),u=!0,f===E))break}else n=[].slice.call(l),u=!0,d=!0;return[n,u,d]}_findEntryNodes(l,e,h){const{leaves:r}=l,[a,...f]=r,n=f.length>0,{name:u,type:d}=a;let i=[],t=!1,s=!1,o=!1;switch(d){case c.SELECTOR_PSEUDO_ELEMENT:{O.matcher.matchPseudoElementSelector(u,{warn:this.#i});break}case c.SELECTOR_ID:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:h});else if(e===E&&this.#t.nodeType!==c.ELEMENT_NODE){const m=this.#t.getElementById(u);m&&(n?this._matchLeaves(f,m,{warn:this.#i})&&(i.push(m),s=!0):(i.push(m),s=!0))}else e===E?[i,s]=this._findFirst(r):o=!0;break}case c.SELECTOR_CLASS:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:h});else if(this.#t.nodeType===c.DOCUMENT_NODE){const m=this.#t.getElementsByClassName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:h,compound:n,filterLeaves:f,targetType:e}))}else e===E?[i,s]=this._findFirst(r):o=!0;break}case c.SELECTOR_TYPE:{if(e===R)[i,s]=this._matchSelf(r);else if(e===C)[i,s]=this._findLineal(r,{complex:h});else if(this.#s.contentType==="text/html"&&this.#t.nodeType===c.DOCUMENT_NODE&&!/[*|]/.test(u)){const m=this.#t.getElementsByTagName(u);m.length&&([i,s,t]=this._findFromHTMLCollection(m,{complex:h,compound:n,filterLeaves:f,targetType:e}))}else e===E?[i,s]=this._findFirst(r):o=!0;break}default:if(e!==C&&c.REG_SHADOW_HOST.test(u)){if(this.#u&&this.#e.nodeType===c.DOCUMENT_FRAGMENT_NODE){const m=this._matchShadowHostPseudoClass(a,this.#e);m&&(i.push(m),s=!0)}}else e===R?[i,s]=this._matchSelf(r):e===C?[i,s]=this._findLineal(r,{complex:h}):e===E?[i,s]=this._findFirst(r):o=!0}return{collected:t,compound:n,filtered:s,nodes:i,pending:o}}_collectNodes(l){const e=this.#a.values();if(l===L||l===E){const h=new Set;let r=0;for(const{branch:a}of e){const f=a.length,n=f>1,u=a[0];let d,i;if(n){const{combo:p,leaves:[{name:w,type:k}]}=u,N=a[f-1],{leaves:[{name:A,type:v}]}=N;if(v===c.SELECTOR_PSEUDO_ELEMENT||v===c.SELECTOR_ID)d=S,i=N;else if(k===c.SELECTOR_PSEUDO_ELEMENT||k===c.SELECTOR_ID)d=x,i=u;else if(l===L)if(w==="*"&&k===c.SELECTOR_TYPE)d=S,i=N;else if(A==="*"&&v===c.SELECTOR_TYPE)d=x,i=u;else if(f===2){const{name:T}=p;/^[+~]$/.test(T)?(d=S,i=N):(d=x,i=u)}else d=x,i=u;else if(A==="*"&&v===c.SELECTOR_TYPE)d=x,i=u;else if(w==="*"&&k===c.SELECTOR_TYPE)d=S,i=N;else{let T;for(const{combo:D,leaves:[U]}of a){const{name:$,type:G}=U;if(G===c.SELECTOR_PSEUDO_CLASS&&$==="dir"){T=!1;break}if(!T&&D){const{name:F}=D;/^[+~]$/.test(F)&&(T=!0)}}T?(d=x,i=u):(d=S,i=N)}}else d=S,i=u;const{collected:t,compound:s,filtered:o,nodes:m,pending:b}=this._findEntryNodes(i,l,n);m.length?(this.#a[r].find=!0,this.#d[r]=m):b&&h.add(new Map([["index",r],["twig",i]])),this.#a[r].collected=t,this.#a[r].dir=d,this.#a[r].filtered=o||!s,r++}if(h.size){let a,f;this.#e!==this.#t&&this.#e.nodeType===c.ELEMENT_NODE?(a=this.#e,f=this.#o):(a=this.#t,f=this.#n);let n=(0,_.traverseNode)(a,f);for(;n;){let u=!1;if(this.#e.nodeType===c.ELEMENT_NODE?n===this.#e?u=!0:u=this.#e.contains(n):u=!0,u)for(const d of h){const{leaves:i}=d.get("twig");if(this._matchLeaves(i,n,{warn:this.#i})){const s=d.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#d[s].push(n)}}n!==f.currentNode&&(n=(0,_.traverseNode)(n,f)),n=f.nextNode()}}}else{let h=0;for(const{branch:r}of e){const a=r[r.length-1],f=r.length>1,{compound:n,filtered:u,nodes:d}=this._findEntryNodes(a,l,f);d.length&&(this.#a[h].find=!0,this.#d[h]=d),this.#a[h].dir=S,this.#a[h].filtered=u||!n,h++}}return[this.#a,this.#d]}_getCombinedNodes(l,e,h){const r=[];for(const a of e){const f=this._matchCombinator(l,a,{dir:h,warn:this.#i});f.size&&r.push(...f)}return r.length?new Set(r):new Set}_matchNodeNext(l,e,h){const{combo:r,index:a}=h,{combo:f,leaves:n}=l[a],u={combo:r,leaves:n},d=this._getCombinedNodes(u,e,x);let i;if(d.size)if(a===l.length-1){const[t]=(0,_.sortNodes)(d);i=t}else i=this._matchNodeNext(l,d,{combo:f,index:a+1});return i??null}_matchNodePrev(l,e,h){const{index:r}=h,a=l[r],f=new Set([e]),n=this._getCombinedNodes(a,f,S);let u;if(n.size){if(r===0)u=e;else for(const d of n)if(this._matchNodePrev(l,d,{index:r-1}))return e}return u??null}_find(l){(l===L||l===E)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(l),r=e.length;let a=new Set;for(let f=0;f<r;f++){const{branch:n,collected:u,dir:d,find:i}=e[f],t=n.length;if(t&&i){const s=h[f],o=s.length,m=t-1;if(m===0)if((l===L||l===E)&&this.#e.nodeType===c.ELEMENT_NODE)for(let b=0;b<o;b++){const p=s[b];if(p!==this.#e&&this.#e.contains(p)&&(a.add(p),l!==L))break}else if(l===L)if(a.size){const b=[...a];a=new Set([...b,...s]),this.#b=!0}else a=new Set(s);else{const[b]=s;a.add(b)}else if(l===L)if(d===x){let{combo:b}=n[0];for(const p of s){let w=new Set([p]);for(let k=1;k<t;k++){const{combo:N,leaves:A}=n[k],v={combo:b,leaves:A};if(w=this._getCombinedNodes(v,w,d),w.size)if(k===m)if(a.size){const T=[...a];a=new Set([...T,...w]),this.#b=!0}else a=w;else b=N;else break}}}else for(const b of s){let p=new Set([b]);for(let w=m-1;w>=0;w--){const k=n[w];if(p=this._getCombinedNodes(k,p,d),p.size)w===0&&(a.add(b),t>1&&a.size>1&&(this.#b=!0));else break}}else if(l===E&&d===x){const{combo:b}=n[0];let p;for(const w of s)if(p=this._matchNodeNext(n,new Set([w]),{combo:b,index:1}),p){a.add(p);break}if(!p&&!u){const{leaves:w}=n[0],[k]=s;let N=this._findNode(w,{node:k});for(;N;){if(p=this._matchNodeNext(n,new Set([N]),{combo:b,index:1}),p){a.add(p);break}N=this._findNode(w,{node:N})}}}else{let b;for(const p of s)if(b=this._matchNodePrev(n,p,{index:m-1}),b){a.add(p);break}if(!b&&!u&&l===E){const{leaves:p}=n[m],[w]=s;let k=this._findNode(p,{node:w});for(;k;){if(b=this._matchNodePrev(n,k,{index:m-1}),b){a.add(k);break}k=this._findNode(p,{node:k})}}}}}return a}matches(l,e,h){let r;try{if(e?.nodeType!==c.ELEMENT_NODE){const n=`Unexpected node ${e?.nodeName}`;throw new TypeError(n)}const a=e.ownerDocument;if(a===this.#r&&a.contentType==="text/html"){const n={complex:c.REG_COMPLEX.test(l),descendant:!0};if((0,y.filterSelector)(l,n))return this.#f.match(l,e)}this._setup(l,e,h),r=this._find(R).size}catch(a){this._onError(a)}return!!r}closest(l,e,h){let r;try{if(e?.nodeType!==c.ELEMENT_NODE){const n=`Unexpected node ${e?.nodeName}`;throw new TypeError(n)}const a=e.ownerDocument;if(a===this.#r&&a.contentType==="text/html"){const n={complex:c.REG_COMPLEX.test(l),descendant:!0};if((0,y.filterSelector)(l,n))return this.#f.closest(l,e)}this._setup(l,e,h);const f=this._find(C);if(f.size){let n=this.#e;for(;n;){if(f.has(n)){r=n;break}n=n.parentNode}}}catch(a){this._onError(a)}return r??null}querySelector(l,e,h){let r;try{(0,_.verifyNode)(e);let a;if(e.nodeType===c.DOCUMENT_NODE?a=e:a=e.ownerDocument,a===this.#r&&a.contentType==="text/html"&&(0,y.filterSelector)(l,{complex:!1,descendant:!1}))return this.#f.first(l,e);this._setup(l,e,h);const f=this._find(E);f.delete(this.#e),f.size&&([r]=(0,_.sortNodes)(f))}catch(a){this._onError(a)}return r??null}querySelectorAll(l,e,h){let r;try{(0,_.verifyNode)(e);let a;if(e.nodeType===c.DOCUMENT_NODE?a=e:a=e.ownerDocument,a===this.#r&&a.contentType==="text/html"&&(0,y.filterSelector)(l,{complex:!1,descendant:!0}))return this.#f.select(l,e);this._setup(l,e,h);const f=this._find(L);f.delete(this.#e),f.size&&(this.#b?r=(0,_.sortNodes)(f):r=[...f])}catch(a){this._onError(a)}return r??[]}}0&&(module.exports={Finder});
//# sourceMappingURL=finder.js.map

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

},
"version": "4.6.0"
"version": "4.6.1"
}

@@ -105,4 +105,3 @@ /**

export const REG_CHILD_INDEXED = new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH})`);
export const REG_COMPLEX_A = new RegExp(`${COMBO_A}${COMPOUND_I}`, 'i');
export const REG_COMPLEX_B = new RegExp(`${COMBO_B}${COMPOUND_I}`, 'i');
export const REG_COMPLEX = new RegExp(`${COMBO_A}${COMPOUND_I}`, 'i');
export const REG_DIR = /^(?:ltr|rtl)$/;

@@ -109,0 +108,0 @@ export const REG_FORM = /^(?:(?:fieldse|inpu|selec)t|button|form|textarea)$/;

@@ -73,4 +73,3 @@ export const AN_PLUS_B: "AnPlusB";

export const REG_CHILD_INDEXED: RegExp;
export const REG_COMPLEX_A: RegExp;
export const REG_COMPLEX_B: RegExp;
export const REG_COMPLEX: RegExp;
export const REG_DIR: RegExp;

@@ -77,0 +76,0 @@ export const REG_FORM: 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 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