@asamuzakjp/dom-selector
Advanced tools
Comparing version 5.0.4 to 5.0.5
@@ -1,2 +0,2 @@ | ||
var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var Y=(o,t)=>{for(var r in t)O(o,r,{get:t[r],enumerable:!0})},H=(o,t,r,I)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of d(t))!U.call(o,s)&&s!==r&&O(o,s,{get:()=>t[s],enumerable:!(I=F(t,s))||I.enumerable});return o};var u=o=>H(O({},"__esModule",{value:!0}),o);var Jt={};Y(Jt,{ALPHA_NUM:()=>R,ANB:()=>D,AN_PLUS_B:()=>B,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>nt,BIT_08:()=>Et,BIT_16:()=>rt,BIT_32:()=>ct,BIT_FFFF:()=>xt,BIT_HYPHEN:()=>_t,CHILD_IDX:()=>N,COMBINATOR:()=>m,COMBO:()=>T,COMPLEX:()=>L,COMPLEX_L:()=>C,COMPOUND:()=>E,COMPOUND_A:()=>A,COMPOUND_B:()=>S,COMPOUND_I:()=>l,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>At,DOCUMENT_POSITION_CONTAINED_BY:()=>Nt,DOCUMENT_POSITION_CONTAINS:()=>It,DOCUMENT_POSITION_PRECEDING:()=>Ct,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>h,HEX:()=>Tt,IDENTIFIER:()=>w,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,LOGICAL_KEY:()=>p,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>i,NOT_SUPPORTED_ERR:()=>g,NTH:()=>f,N_TH:()=>_,PSEUDO_CLASSES:()=>x,RAW:()=>X,REG_ANCHOR:()=>at,REG_CHILD_INDEXED:()=>Mt,REG_COMPLEX:()=>Ft,REG_DIR:()=>dt,REG_FORM:()=>Ut,REG_FORM_CTRL:()=>Yt,REG_FORM_VALID:()=>Ht,REG_HEX:()=>ut,REG_INTERACT:()=>Bt,REG_INVALIDATE_PSEUDO:()=>mt,REG_INVALID_SELECTOR:()=>ht,REG_LANG:()=>wt,REG_LANG_QUOTED:()=>gt,REG_LOGICAL_COMPLEX:()=>ft,REG_LOGICAL_COMPOUND:()=>Xt,REG_LOGICAL_EMPTY:()=>bt,REG_LOGICAL_KEY:()=>Wt,REG_LOGICAL_PSEUDO:()=>yt,REG_SHADOW_HOST:()=>kt,REG_SHADOW_MODE:()=>Kt,REG_SHADOW_PSEUDO:()=>Zt,REG_TYPE_CHECK:()=>Vt,REG_TYPE_DATE:()=>vt,REG_TYPE_RANGE:()=>zt,REG_TYPE_RESET:()=>Qt,REG_TYPE_SUBMIT:()=>jt,REG_TYPE_TEXT:()=>qt,SELECTOR:()=>b,SELECTOR_ATTR:()=>W,SELECTOR_CLASS:()=>y,SELECTOR_ID:()=>k,SELECTOR_LIST:()=>K,SELECTOR_PSEUDO_CLASS:()=>Z,SELECTOR_PSEUDO_ELEMENT:()=>V,SELECTOR_TYPE:()=>v,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>it,STRING:()=>z,SUB_TYPE:()=>n,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>e,TAG_TYPE_I:()=>$,TARGET_ALL:()=>j,TARGET_FIRST:()=>q,TARGET_LINEAL:()=>J,TARGET_SELF:()=>tt,TEXT_NODE:()=>Lt,TYPE_FROM:()=>Ot,TYPE_TO:()=>Rt,U_FFFD:()=>ot,WALKER_FILTER:()=>lt});module.exports=u(Jt);const B="AnPlusB",m="Combinator",h="__EMPTY__",w="Identifier",g="NotSupportedError",f="Nth",X="Raw",b="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",K="SelectorList",Z="PseudoClassSelector",V="PseudoElementSelector",v="TypeSelector",z="String",Q="SyntaxError",j="all",q="first",J="lineal",tt="self",ot="\uFFFD",et=1,st=2,nt=4,Et=8,rt=16,ct=32,xt=65535,_t=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,Lt=3,At=9,St=11,Ct=2,It=8,Nt=16,Gt=4294967295,Dt=256,Pt=1024,it=1,lt=1281,R="[A-Z\\d]+",N="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",G=`(?:-${R})*`,x=`(?:any-)?link|${N}|checked|empty|indeterminate|root|target|visited`,D=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,_=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${D})\\s*\\)`,n="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",$="\\*|[A-Z][\\w-]*",p="(?:is|not)",E=`(?:${e}|(?:${e})?(?:${n})+)`,T="\\s?[\\s>~+]\\s?",L=`${E}(?:${T}${E})*`,P=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,i=`:is\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,A=`(?:${e}|(?:${e})?(?:${n}|${P})+)`,S=`(?:${e}|(?:${e})?(?:${n}|${i})+)`,l=`(?:${$}|(?:${$})?(?:${n})+)`,C=`${S}(?:${T}${S})*`,a=`${p}\\(\\s*${C}(?:\\s*,\\s*${C})*\\s*\\)`,M=`${p}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`:(?!${x}|${_})`),Ft=new RegExp(`${T}${l}`,"i"),dt=/^(?:ltr|rtl)$/,Ut=/^(?:button|fieldset|form|input|select|textarea)$/,Yt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ht=/^(?:button|form|input|select|textarea)$/,ut=/^([\da-f]{1,6}\s?)/i,Bt=/^(?:details|dialog)$/,mt=/^(?:(?:any-)?link|defined|dir|has|host(?:-context)?|not)$/,ht=/^$|^\s*>|,\s*$/,wt=new RegExp(`^(?:\\*-)?${R}${G}$`,"i"),gt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ft=new RegExp(`:(?!${x}|${_}|${a})`),Xt=new RegExp(`:(?!${x}|${_}|${M})`),bt=/(:(is|where)\(\s*\))/,Wt=new RegExp(`:${p}\\(`),yt=/^(?:has|is|not|where)$/,kt=/^host(?:-context)?$/,Kt=/^(?:close|open)$/,Zt=/^part|slotted$/,Vt=/^(?:checkbox|radio)$/,vt=/^(?:date(?:time-local)?|month|time|week)$/,zt=/(?:date(?:time-local)?|month|number|range|time|week)$/,Qt=/^(?:button|reset)$/,jt=/^(?:image|submit)$/,qt=/^(?: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,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,LOGICAL_COMPOUND,LOGICAL_KEY,NESTED_LOGICAL_A,NESTED_LOGICAL_B,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_VALID,REG_HEX,REG_INTERACT,REG_INVALIDATE_PSEUDO,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_COMPLEX,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,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER}); | ||
var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var Y=(o,t)=>{for(var n in t)O(o,n,{get:t[n],enumerable:!0})},H=(o,t,n,N)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of U(t))!d.call(o,s)&&s!==n&&O(o,s,{get:()=>t[s],enumerable:!(N=F(t,s))||N.enumerable});return o};var u=o=>H(O({},"__esModule",{value:!0}),o);var qt={};Y(qt,{ALPHA_NUM:()=>R,ANB:()=>D,AN_PLUS_B:()=>B,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>rt,BIT_08:()=>Et,BIT_16:()=>nt,BIT_32:()=>ct,BIT_FFFF:()=>xt,BIT_HYPHEN:()=>_t,CHILD_IDX:()=>I,COMBINATOR:()=>m,COMBO:()=>T,COMPLEX:()=>L,COMPLEX_L:()=>C,COMPOUND:()=>E,COMPOUND_A:()=>A,COMPOUND_B:()=>S,COMPOUND_I:()=>i,DIGIT:()=>c,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>At,DOCUMENT_POSITION_CONTAINED_BY:()=>It,DOCUMENT_POSITION_CONTAINS:()=>Nt,DOCUMENT_POSITION_PRECEDING:()=>Ct,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>w,HEX:()=>Tt,IDENTIFIER:()=>g,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,LOGICAL_KEY:()=>p,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>l,NOT_SUPPORTED_ERR:()=>h,NTH:()=>X,N_TH:()=>_,PSEUDO_CLASSES:()=>x,RAW:()=>f,REG_ANCHOR:()=>at,REG_CHILD_INDEXED:()=>Mt,REG_COMPLEX:()=>Ft,REG_DIR:()=>Ut,REG_FORM:()=>dt,REG_FORM_CTRL:()=>Yt,REG_FORM_VALID:()=>Ht,REG_HEX:()=>ut,REG_INTERACT:()=>Bt,REG_INVALID_SELECTOR:()=>mt,REG_LANG:()=>wt,REG_LANG_QUOTED:()=>gt,REG_LOGICAL_COMPLEX:()=>ht,REG_LOGICAL_COMPOUND:()=>Xt,REG_LOGICAL_EMPTY:()=>ft,REG_LOGICAL_KEY:()=>bt,REG_LOGICAL_PSEUDO:()=>Wt,REG_SHADOW_HOST:()=>yt,REG_SHADOW_MODE:()=>kt,REG_SHADOW_PSEUDO:()=>Kt,REG_TYPE_CHECK:()=>Zt,REG_TYPE_DATE:()=>vt,REG_TYPE_RANGE:()=>zt,REG_TYPE_RESET:()=>Vt,REG_TYPE_SUBMIT:()=>Qt,REG_TYPE_TEXT:()=>jt,SELECTOR:()=>b,SELECTOR_ATTR:()=>W,SELECTOR_CLASS:()=>y,SELECTOR_ID:()=>k,SELECTOR_LIST:()=>K,SELECTOR_PSEUDO_CLASS:()=>Z,SELECTOR_PSEUDO_ELEMENT:()=>v,SELECTOR_TYPE:()=>z,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>lt,STRING:()=>V,SUB_TYPE:()=>r,SYNTAX_ERR:()=>Q,TAG_TYPE:()=>e,TAG_TYPE_I:()=>$,TARGET_ALL:()=>j,TARGET_FIRST:()=>q,TARGET_LINEAL:()=>J,TARGET_SELF:()=>tt,TEXT_NODE:()=>Lt,TYPE_FROM:()=>Ot,TYPE_TO:()=>Rt,U_FFFD:()=>ot,WALKER_FILTER:()=>it});module.exports=u(qt);const B="AnPlusB",m="Combinator",w="__EMPTY__",g="Identifier",h="NotSupportedError",X="Nth",f="Raw",b="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",K="SelectorList",Z="PseudoClassSelector",v="PseudoElementSelector",z="TypeSelector",V="String",Q="SyntaxError",j="all",q="first",J="lineal",tt="self",ot="\uFFFD",et=1,st=2,rt=4,Et=8,nt=16,ct=32,xt=65535,_t=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,Lt=3,At=9,St=11,Ct=2,Nt=8,It=16,Gt=4294967295,Dt=256,Pt=1024,lt=1,it=1281,R="[A-Z\\d]+",I="(?:first|last|only)-(?:child|of-type)",c="(?:0|[1-9]\\d*)",G=`(?:-${R})*`,x=`(?:any-)?link|${I}|checked|empty|indeterminate|root|target|visited`,D=`[+-]?(?:${c}n?|n)|(?:[+-]?${c})?n\\s*[+-]\\s*${c}`,_=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${D})\\s*\\)`,r="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",$="\\*|[A-Z][\\w-]*",p="(?:is|not)",E=`(?:${e}|(?:${e})?(?:${r})+)`,T="\\s?[\\s>~+]\\s?",L=`${E}(?:${T}${E})*`,P=`:is\\(\\s*${E}(?:\\s*,\\s*${E})*\\s*\\)`,l=`:is\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,A=`(?:${e}|(?:${e})?(?:${r}|${P})+)`,S=`(?:${e}|(?:${e})?(?:${r}|${l})+)`,i=`(?:${$}|(?:${$})?(?:${r})+)`,C=`${S}(?:${T}${S})*`,a=`${p}\\(\\s*${C}(?:\\s*,\\s*${C})*\\s*\\)`,M=`${p}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`:(?!${x}|${_})`),Ft=new RegExp(`${T}${i}`,"i"),Ut=/^(?:ltr|rtl)$/,dt=/^(?:button|fieldset|form|input|select|textarea)$/,Yt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,Ht=/^(?:button|form|input|select|textarea)$/,ut=/^([\da-f]{1,6}\s?)/i,Bt=/^(?:details|dialog)$/,mt=/^$|^\s*>|,\s*$/,wt=new RegExp(`^(?:\\*-)?${R}${G}$`,"i"),gt=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ht=new RegExp(`:(?!${x}|${_}|${a})`),Xt=new RegExp(`:(?!${x}|${_}|${M})`),ft=/(:(is|where)\(\s*\))/,bt=new RegExp(`:${p}\\(`),Wt=/^(?:has|is|not|where)$/,yt=/^host(?:-context)?$/,kt=/^(?:close|open)$/,Kt=/^part|slotted$/,Zt=/^(?:checkbox|radio)$/,vt=/^(?:date(?:time-local)?|month|time|week)$/,zt=/(?:date(?:time-local)?|month|number|range|time|week)$/,Vt=/^(?: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,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,LOGICAL_COMPOUND,LOGICAL_KEY,NESTED_LOGICAL_A,NESTED_LOGICAL_B,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_VALID,REG_HEX,REG_INTERACT,REG_INVALID_SELECTOR,REG_LANG,REG_LANG_QUOTED,REG_LOGICAL_COMPLEX,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,TARGET_ALL,TARGET_FIRST,TARGET_LINEAL,TARGET_SELF,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER}); | ||
//# sourceMappingURL=constant.js.map |
@@ -1,2 +0,2 @@ | ||
var T=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var $=(x,o)=>{for(var e in o)T(x,e,{get:o[e],enumerable:!0})},F=(x,o,e,h)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of I(o))!U.call(x,n)&&n!==e&&T(x,n,{get:()=>o[n],enumerable:!(h=D(o,n))||h.enumerable});return x};var G=x=>F(T({},"__esModule",{value:!0}),x);var W={};$(W,{Finder:()=>H});module.exports=G(W);var k=require("./dom-util.js"),L=require("./matcher.js"),g=require("./parser.js"),a=require("./constant.js");const v="next",S="prev";class H{#a;#c;#m;#t;#n;#d;#o;#e;#f;#w;#b;#p;#s;#h;#r;#u;#i;#l;constructor(o){this.#l=o,this.#c=new WeakMap,this.#n=new WeakMap,this.#p=new WeakMap}_onError(o){if(!this.#w)if(o instanceof DOMException||o instanceof this.#l.DOMException)if(o.name===a.NOT_SUPPORTED_ERR)this.#i&&console.warn(o.message);else throw new this.#l.DOMException(o.message,o.name);else throw o}_setup(o,e,h={}){const{event:n,noexcept:r,warn:c}=h;return this.#w=!!r,this.#i=!!c,this.#d=this._setEvent(n),this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#h=(0,k.isInShadowTree)(e),[this.#a,this.#f]=this._correspond(o),this.#u=new WeakMap,this.#o=!1,e}_setEvent(o){return o instanceof this.#l.KeyboardEvent||o instanceof this.#l.MouseEvent?o:null}_correspond(o){const e=[];this.#m=!1;let h;if(this.#n.has(this.#t)){const n=this.#n.get(this.#t);if(n&&n.has(`${o}`)){const r=n.get(`${o}`);h=r.ast,this.#m=r.descendant,this.#o=r.invalidate}}if(h){const n=h.length;for(let r=0;r<n;r++)h[r].collected=!1,h[r].dir=null,h[r].filtered=!1,h[r].find=!1,e[r]=[]}else{let n;try{n=(0,g.parseSelector)(o)}catch(t){this._onError(t)}const{branches:r,info:{hasHasPseudo:c}}=(0,g.walkAST)(n),f=!!c;let b=!1,d=0;h=[];for(const[...t]of r){const s=[];let l=t.shift();if(l&&l.type!==a.COMBINATOR){const u=new Set;for(;l;){if(l.type===a.COMBINATOR){const[m]=t;if(m.type===a.COMBINATOR){const p=`Invalid selector ${o}`;throw new DOMException(p,a.SYNTAX_ERR)}const w=l.name;/^[\s>]$/.test(w)&&(b=!0),s.push({combo:l,leaves:(0,g.sortAST)(u)}),u.clear()}else if(l){let{name:m}=l;m&&typeof m=="string"&&(m=(0,g.unescapeSelector)(m),typeof m=="string"&&m!==l.name&&(l.name=m),/[|:]/.test(m)&&(l.namespace=!0)),u.add(l)}if(t.length)l=t.shift();else{s.push({combo:null,leaves:(0,g.sortAST)(u)}),u.clear();break}}}h.push({branch:s,collected:!1,dir:null,filtered:!1,find:!1}),e[d]=[],d++}let i;this.#n.has(this.#t)?i=this.#n.get(this.#t):i=new Map,i.set(`${o}`,{ast:h,descendant:b,invalidate:f}),this.#n.set(this.#t,i),this.#m=b,this.#o=f}return[h,e]}_createTreeWalker(o){let e;return this.#u.has(o)?e=this.#u.get(o):(e=this.#t.createTreeWalker(o,a.WALKER_FILTER),this.#u.set(o,e)),e}_prepareQuerySelectorWalker(){return this.#b=this._createTreeWalker(this.#e),this.#b}_collectNthChild(o,e,h){const{a:n,b:r,reverse:c,selector:f}=o,{parentNode:b}=e,d=new Set;let i;if(f)if(this.#c.has(f))i=this.#c.get(f);else{const{branches:t,info:s}=(0,g.walkAST)(f);i=t,this.#c.set(f,i),s.hasLogicalPseudoFunc&&(this.#o=!0)}if(b){const t=this.#r;let s=(0,k.traverseNode)(b,t);s=t.firstChild();let l=0;for(;s;)l++,s=t.nextSibling();const u=new Set;if(i)for(s=(0,k.traverseNode)(b,t),s=t.firstChild();s;){const{display:m,visibility:w}=this.#l.getComputedStyle(s);if(m!=="none"&&w!=="hidden"){let p;for(const N of i)if(p=this._matchLeaves(N,s,h),!p)break;p&&u.add(s)}s=t.nextSibling()}if(n===0){if(r>0&&r<=l){if(u.size){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(u.has(s)){if(m===r-1){d.add(s);break}m++}c?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(m===r-1){d.add(s);break}c?s=t.previousSibling():s=t.nextSibling(),m++}}}}else{let m=r-1;if(n>0)for(;m<0;)m+=n;if(m>=0&&m<l){s=(0,k.traverseNode)(b,t),c?s=t.lastChild():s=t.firstChild();let w=0,p=n>0?0:r-1;for(;s&&(s&&m>=0&&m<l);)u.size?u.has(s)&&(p===m&&(d.add(s),m+=n),n>0?p++:p--):w===m&&(f||d.add(s),m+=n),c?s=t.previousSibling():s=t.nextSibling(),w++}}if(c&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&n+r===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(o,e){const{a:h,b:n,reverse:r}=o,{localName:c,parentNode:f,prefix:b}=e,d=new Set;if(f){const i=this.#r;let t=(0,k.traverseNode)(f,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(h===0){if(n>0&&n<=s){t=(0,k.traverseNode)(f,i),r?t=i.lastChild():t=i.firstChild();let l=0;for(;t;){const{localName:u,prefix:m}=t;if(u===c&&m===b){if(l===n-1){d.add(t);break}l++}r?t=i.previousSibling():t=i.nextSibling()}}}else{let l=n-1;if(h>0)for(;l<0;)l+=h;if(l>=0&&l<s){t=(0,k.traverseNode)(f,i),r?t=i.lastChild():t=i.firstChild();let u=h>0?0:n-1;for(;t;){const{localName:m,prefix:w}=t;if(m===c&&w===b){if(u===l&&(d.add(t),l+=h),l<0||l>=s)break;h>0?u++:u--}r?t=i.previousSibling():t=i.nextSibling()}}}if(r&&d.size>1){const l=[...d];return new Set(l.reverse())}}else e===this.#s&&h+n===1&&d.add(e);return d}_matchAnPlusB(o,e,h,n){const{nth:{a:r,b:c,name:f},selector:b}=o,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 r=="string"&&/-?\d+/.test(r)?d.set("a",r*1):d.set("a",0),typeof c=="string"&&/-?\d+/.test(c)?d.set("b",c*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(o,e,h={}){let n;if(Array.isArray(o)&&o.length){const r=o.map(s=>s),[c]=r,{type:f}=c;let b;f===a.COMBINATOR?b=r.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;r.length;){const[s]=r,{type:l}=s;if(l===a.COMBINATOR)break;d.push(r.shift())}const i={combo:b,leaves:d};h.dir=v;const t=this._matchCombinator(i,e,h);if(t.size)if(r.length){for(const s of t)if(n=this._matchHasPseudoFunc(r,s,h),n)break}else n=!0}return!!n}_matchLogicalPseudoFunc(o,e,h={}){const{astName:n="",branches:r=[],selector:c="",twigBranches:f=[]}=o;let b;if(n==="has")if(c.includes(":has("))b=null;else{let d;for(const i of r)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 t;for(let s=0;s<i;s++){const l=f[s],u=l.length-1,{leaves:m}=l[u];if(t=this._matchLeaves(m,e,h),t&&u>0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=l[p],_=[];h.dir=S;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?t=!0:w=new Set(_);else{t=!1;break}}}if(t)break}n==="not"?t||(b=e):t&&(b=e)}return b??null}_matchPseudoClassSelector(o,e,h={}){const{children:n,name:r}=o,{localName:c,parentNode:f}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(r)){let t;if(this.#c.has(o))t=this.#c.get(o);else{const{branches:l}=(0,g.walkAST)(o),u=[],m=[];for(const[...w]of l){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)}t={astName:r,branches:l,twigBranches:m,selector:u.join(",")},this.#c.set(o,t)}const s=this._matchLogicalPseudoFunc(t,e,h);s&&i.add(s)}else if(Array.isArray(n))if(/^nth-(?:last-)?(?:child|of-type)$/.test(r)){const[t]=n;return this._matchAnPlusB(t,e,r,h)}else switch(r){case"dir":case"lang":{const t=L.matcher.matchSelector(o,e);t&&i.add(t);break}case"state":{if((0,k.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 :${r}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${r}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(!b){const t=`Unknown pseudo-class :${r}()`;throw new DOMException(t,a.SYNTAX_ERR)}}else switch(r){case"any-link":case"link":{a.REG_ANCHOR.test(c)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(a.REG_ANCHOR.test(c)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:l}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),t);u.origin===s&&u.pathname===l&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#d??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:l}=this.#d??{};(l==="mousedown"||l==="pointerdown")&&t&a.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#t.URL);e.id&&t===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#t.URL);if(t){const s=t.replace(/^#/,"");let l=this.#t.getElementById(s);for(;l;){if(l===e){i.add(e);break}l=l.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#h&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#d??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(r==="focus"||s==="keydown"&&e.contains(t))){let l=e,u=!0;for(;l;){if(l.disabled||l.hasAttribute("disabled")||l.hidden||l.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(l);if(u=!(m==="none"||w==="hidden"),!u)break}if(l.parentNode&&l.parentNode.nodeType===a.ELEMENT_NODE)l=l.parentNode;else break}u&&i.add(e)}break}case"focus-within":{let t,s=this.#t.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.parentNode}if(t){let l=e,u=!0;for(;l;){if(l.disabled||l.hasAttribute("disabled")||l.hidden||l.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(l);if(u=!(m==="none"||w==="hidden"),!u)break}if(l.parentNode&&l.parentNode.nodeType===a.ELEMENT_NODE)l=l.parentNode;else break}u&&i.add(e)}break}case"open":{a.REG_INTERACT.test(c)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{a.REG_INTERACT.test(c)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(a.REG_FORM_CTRL.test(c)||(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 t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const l=this.#r;let u=(0,k.traverseNode)(s,l);for(u=l.firstChild();u&&u.localName!=="legend";)u=l.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t&&i.add(e)}}break}case"enabled":{if((a.REG_FORM_CTRL.test(c)||(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 t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const l=this.#r;let u=(0,k.traverseNode)(s,l);for(u=l.firstChild();u&&u.localName!=="legend";)u=l.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t||i.add(e)}break}case"read-only":{switch(c){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.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(c){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.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 t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;c==="textarea"?s=e:c==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&c==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&c==="input"&&e.type==="checkbox"||c==="progress"&&!e.hasAttribute("value"))i.add(e);else if(c==="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.#t.documentElement);const l=s.getElementsByTagName("input"),u=l.length;let m;for(let w=0;w<u;w++){const p=l[w];if(p.getAttribute("type")==="radio"&&(t?p.getAttribute("name")===t&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(c==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#r;let l=(0,k.traverseNode)(t,s);for(l=s.firstChild();l&&t.contains(l);){const u=l.localName;let m;if(u==="button"?m=!(l.hasAttribute("type")&&a.REG_TYPE_RESET.test(l.getAttribute("type"))):u==="input"&&(m=l.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(l.getAttribute("type"))),m){l===e&&i.add(e);break}l=s.nextNode()}}}else(c==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||c==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(c))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(c==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let l;if(!s)l=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?l=s.maxLength>=s.value.length:l=!0:l=!1,!l));)s=t.nextNode();l&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(c))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(c==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let l;if(!s)l=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?l=s.maxLength>=s.value.length:l=!0:l=!1,!l));)s=t.nextNode();l||i.add(e)}break}case"in-range":{c==="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":{c==="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 t;if(/^(?:select|textarea)$/.test(c))t=e;else if(c==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.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(c))t=e;else if(c==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(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 t=this.#t.createTreeWalker(e,a.SHOW_ALL);let s=t.firstChild(),l;for(;s&&(l=s.nodeType!==a.ELEMENT_NODE&&s.nodeType!==a.TEXT_NODE,!!l);)s=t.nextSibling();l&&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[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(f){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.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||c.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":{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 ::${r}`;throw new DOMException(t,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){const t=`Unsupported pseudo-class :${r}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(r.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${r}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}}else if(!b){const t=`Unknown pseudo-class :${r}`;throw new DOMException(t,a.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(o,e){const{children:h,name:n}=o;let r;if(Array.isArray(h)){const{branches:c}=(0,g.walkAST)(h[0]),[f]=c,[...b]=f,{host:d}=e;if(n==="host"){let i;for(const t of b){const{type:s}=t;if(s===a.COMBINATOR){const u=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(u,a.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(r=e)}else if(n==="host-context"){let i=d,t;for(;i;){for(const s of b){const{type:l}=s;if(l===a.COMBINATOR){const m=`Invalid selector ${(0,g.generateCSS)(o)}`;throw new DOMException(m,a.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(r=e)}}else if(n==="host")r=e;else{const c=`Invalid selector :${n}`;throw new DOMException(c,a.SYNTAX_ERR)}return r??null}_matchSelector(o,e,h){const{type:n}=o,r=new Set;if(o.name===a.EMPTY)return r;const c=(0,g.unescapeSelector)(o.name);if(typeof c=="string"&&c!==o.name&&(o.name=c),e.nodeType===a.ELEMENT_NODE)switch(n){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(c,h);break}case a.SELECTOR_ID:{e.id===c&&r.add(e);break}case a.SELECTOR_CLASS:{e.classList.contains(c)&&r.add(e);break}case a.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(o,e,h);default:{const f=L.matcher.matchSelector(o,e,h);f&&r.add(f)}}else if(this.#h&&n===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(c!=="has"&&a.REG_LOGICAL_PSEUDO.test(c))return this._matchPseudoClassSelector(o,e,h);if(a.REG_SHADOW_HOST.test(c)){const f=this._matchShadowHostPseudoClass(o,e,h);f&&r.add(f)}}return r}_matchLeaves(o,e,h){let n,r=this.#p.get(o);if(r&&r.has(e)){const{matched:c}=r.get(e);n=c}if(typeof n!="boolean"){let c=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(c=!1);for(const f of o){switch(f.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{c=!1;break}case a.SELECTOR_PSEUDO_CLASS:{a.REG_INVALIDATE_PSEUDO.test(f.name)&&(c=!1);break}default:}if(n=this._matchSelector(f,e,h).has(e),!n)break}c&&!this.#o&&(r||(r=new WeakMap),r.set(e,{matched:n}),this.#p.set(o,r))}return!!n}_matchHTMLCollection(o,e={}){const{compound:h,filterLeaves:n}=e,r=new Set,c=o.length;if(c)if(h)for(let f=0;f<c;f++){const b=o[f];this._matchLeaves(n,b,e)&&r.add(b)}else{const f=[].slice.call(o);return new Set(f)}return r}_findDescendantNodes(o,e,h){const[n,...r]=o,c=r.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.#h)i=!0;else switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(b);t&&t!==e&&e.contains(t)&&(c?this._matchLeaves(r,t,h)&&d.add(t):d.add(t))}break}case a.SELECTOR_CLASS:{const t=e.getElementsByClassName(b);d=this._matchHTMLCollection(t,{compound:c,filterLeaves:r});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const t=e.getElementsByTagName(b);d=this._matchHTMLCollection(t,{compound:c,filterLeaves:r})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(o,e,h={}){const{combo:n,leaves:r}=o,{name:c}=n,{parentNode:f}=e,{dir:b}=h,d=new Set;if(b===v)switch(c){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(r,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(r,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,k.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(r,t,h)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(r,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let l=(0,k.traverseNode)(e,s);for(l=s.nextNode();l&&e.contains(l);)this._matchLeaves(r,l,h)&&d.add(l),l=s.nextNode()}}}else switch(c){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(r,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(f,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(r,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(r,f,h)&&d.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(r,t,h)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(o,e){const{node:h}=e,n=this.#b;let r=(0,k.traverseNode)(h,n),c;if(r)for((r.nodeType!==a.ELEMENT_NODE||r===h&&r!==this.#s)&&(r=n.nextNode());r;){if(this._matchLeaves(o,r,{warn:this.#i})){c=r;break}r=n.nextNode()}return c??null}_matchSelf(o){const e=[],h=this._matchLeaves(o,this.#e,{warn:this.#i});let n=!1;return h&&(e.push(this.#e),n=!0),[e,n]}_findLineal(o,e={}){const{complex:h}=e,n=[];let r=this._matchLeaves(o,this.#e,{warn:this.#i}),c=!1;if(r&&(n.push(this.#e),c=!0),!r||h){let f=this.#e.parentNode;for(;f&&(r=this._matchLeaves(o,f,{warn:this.#i}),r&&(n.push(f),c=!0),f.parentNode);)f=f.parentNode}return[n,c]}_findFirst(o){const e=[],h=this._findNode(o,{node:this.#e});let n=!1;return h&&(e.push(h),n=!0),[e,n]}_findFromHTMLCollection(o,e={}){const{complex:h,compound:n,filterLeaves:r,targetType:c}=e;let f=[],b=!1,d=!1;const i=o.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let t=0;t<i;t++){const s=o[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(n){if(this._matchLeaves(r,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else if(f.push(s),b=!0,c===a.TARGET_FIRST)break}}else if(h)if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(r,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;else if(n)for(let t=0;t<i;t++){const s=o[t];if(this._matchLeaves(r,s,{warn:this.#i})&&(f.push(s),b=!0,c===a.TARGET_FIRST))break}else f=[].slice.call(o),b=!0,d=!0;return[f,b,d]}_findEntryNodes(o,e,h){const{leaves:n}=o,[r,...c]=n,f=c.length>0,{name:b,type:d}=r;let i=[],t=!1,s=!1,l=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=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(c,u,{warn:this.#i})&&(i.push(u),s=!0):(i.push(u),s=!0))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):l=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(n,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const u=this.#s.getElementsByClassName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:c,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):l=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(n);else if(e===a.TARGET_LINEAL)[i,s]=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,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:c,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(n):l=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#h&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const u=this._matchShadowHostPseudoClass(r,this.#e);u&&(i.push(u),s=!0)}}else e===a.TARGET_SELF?[i,s]=this._matchSelf(n):e===a.TARGET_LINEAL?[i,s]=this._findLineal(n,{complex:h}):e===a.TARGET_FIRST?[i,s]=this._findFirst(n):l=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:l}}_collectNodes(o){const e=this.#a.values();if(o===a.TARGET_ALL||o===a.TARGET_FIRST){const h=new Set;let n=0;for(const{branch:r}of e){const c=r.length,f=c>1,b=r[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=r[c-1],{leaves:[{name:y,type:E}]}=_;if(E===a.SELECTOR_PSEUDO_ELEMENT||E===a.SELECTOR_ID)d=S,i=_;else if(N===a.SELECTOR_PSEUDO_ELEMENT||N===a.SELECTOR_ID)d=v,i=b;else if(o===a.TARGET_ALL)if(p==="*"&&N===a.SELECTOR_TYPE)d=S,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(c===2){const{name:A}=w;/^[+~]$/.test(A)?(d=S,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=S,i=_;else{let A;for(const{combo:C,leaves:[O]}of r){const{name:R,type:M}=O;if(M===a.SELECTOR_PSEUDO_CLASS&&R==="dir"){A=!1;break}if(!A&&C){const{name:P}=C;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=b):(d=S,i=_)}}else d=S,i=b;const{collected:t,compound:s,filtered:l,nodes:u,pending:m}=this._findEntryNodes(i,o,f);u.length?(this.#a[n].find=!0,this.#f[n]=u):m&&h.add(new Map([["index",n],["twig",i]])),this.#a[n].collected=t,this.#a[n].dir=d,this.#a[n].filtered=l||!s,n++}if(h.size){let r,c;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(r=this.#e,c=this.#b):(r=this.#s,c=this.#r);let f=(0,k.traverseNode)(r,c);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 s=d.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#f[s].push(f)}}f!==c.currentNode&&(f=(0,k.traverseNode)(f,c)),f=c.nextNode()}}}else{let h=0;for(const{branch:n}of e){const r=n[n.length-1],c=n.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(r,o,c);d.length&&(this.#a[h].find=!0,this.#f[h]=d),this.#a[h].dir=S,this.#a[h].filtered=b||!f,h++}}return[this.#a,this.#f]}_getCombinedNodes(o,e,h){const n=[];for(const r of e){const c=this._matchCombinator(o,r,{dir:h,warn:this.#i});c.size&&n.push(...c)}return n.length?new Set(n):new Set}_matchNodeNext(o,e,h){const{combo:n,index:r}=h,{combo:c,leaves:f}=o[r],b={combo:n,leaves:f},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(r===o.length-1){const[t]=(0,k.sortNodes)(d);i=t}else i=this._matchNodeNext(o,d,{combo:c,index:r+1});return i??null}_matchNodePrev(o,e,h){const{index:n}=h,r=o[n],c=new Set([e]),f=this._getCombinedNodes(r,c,S);let b;if(f.size){if(n===0)b=e;else for(const d of f)if(this._matchNodePrev(o,d,{index:n-1}))return e}return b??null}_find(o){(o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(o),n=e.length;let r,c=new Set;for(let f=0;f<n;f++){const{branch:b,collected:d,dir:i,find:t}=e[f],s=b.length;if(s&&t){const l=h[f],u=l.length,m=s-1;if(m===0)if((o===a.TARGET_ALL||o===a.TARGET_FIRST)&&this.#e.nodeType===a.ELEMENT_NODE)for(let w=0;w<u;w++){const p=l[w];if(p!==this.#e&&this.#e.contains(p)&&(c.add(p),o!==a.TARGET_ALL))break}else if(o===a.TARGET_ALL)if(c.size){const w=[...c];c=new Set([...w,...l]),r=!0}else c=new Set(l);else{const[w]=l;c.add(w)}else if(o===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of l){let N=new Set([p]);for(let _=1;_<s;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(c.size){const C=[...c];c=new Set([...C,...N]),r=!0}else c=N;else w=y;else break}}}else for(const w of l){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&&(c.add(w),s>1&&c.size>1&&(r=!0));else break}}else if(o===a.TARGET_FIRST&&i===v){const{combo:w}=b[0];let p;for(const N of l)if(p=this._matchNodeNext(b,new Set([N]),{combo:w,index:1}),p){c.add(p);break}if(!p&&!d){const{leaves:N}=b[0],[_]=l;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(b,new Set([y]),{combo:w,index:1}),p){c.add(p);break}y=this._findNode(N,{node:y})}}}else{let w;for(const p of l)if(w=this._matchNodePrev(b,p,{index:m-1}),w){c.add(p);break}if(!w&&!d&&o===a.TARGET_FIRST){const{leaves:p}=b[m],[N]=l;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(b,_,{index:m-1}),w){c.add(_);break}_=this._findNode(p,{node:_})}}}}}return o===a.TARGET_ALL&&r&&(c=new Set((0,k.sortNodes)(c))),c}}0&&(module.exports={Finder}); | ||
var T=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var U=(x,c)=>{for(var e in c)T(x,e,{get:c[e],enumerable:!0})},F=(x,c,e,h)=>{if(c&&typeof c=="object"||typeof c=="function")for(let o of I(c))!$.call(x,o)&&o!==e&&T(x,o,{get:()=>c[o],enumerable:!(h=D(c,o))||h.enumerable});return x};var G=x=>F(T({},"__esModule",{value:!0}),x);var H={};U(H,{Finder:()=>W});module.exports=G(H);var k=require("./dom-util.js"),L=require("./matcher.js"),g=require("./parser.js"),a=require("./constant.js");const v="next",S="prev";class W{#a;#n;#p;#t;#c;#d;#o;#b;#e;#f;#k;#u;#w;#s;#h;#r;#m;#i;#l;constructor(c){this.#l=c,this.#n=new WeakMap,this.#c=new WeakMap,this.#b=new WeakMap,this.#w=new WeakMap}_onError(c){if(!this.#k)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:o,noexcept:l,warn:n}=h;return this.#k=!!l,this.#i=!!n,this.#d=this._setEvent(o),this.#e=e,[this.#t,this.#s,this.#r]=(0,k.resolveContent)(e),this.#h=(0,k.isInShadowTree)(e),[this.#a,this.#f]=this._correspond(c),this.#b=new WeakMap,this.#m=new WeakMap,e}_setEvent(c){return c instanceof this.#l.KeyboardEvent||c instanceof this.#l.MouseEvent?c:null}_correspond(c){const e=[];this.#p=!1,this.#o=!1;let h;if(this.#c.has(this.#t)){const o=this.#c.get(this.#t);if(o&&o.has(`${c}`)){const l=o.get(`${c}`);h=l.ast,this.#p=l.descendant,this.#o=l.invalidate}}if(h){const o=h.length;for(let l=0;l<o;l++)h[l].collected=!1,h[l].dir=null,h[l].filtered=!1,h[l].find=!1,e[l]=[]}else{let o;try{o=(0,g.parseSelector)(c)}catch(t){this._onError(t)}const{branches:l,info:{hasHasPseudoFunc:n}}=(0,g.walkAST)(o),f=!!n;let b=!1,d=0;h=[];for(const[...t]of l){const s=[];let r=t.shift();if(r&&r.type!==a.COMBINATOR){const u=new Set;for(;r;){if(r.type===a.COMBINATOR){const[m]=t;if(m.type===a.COMBINATOR){const p=`Invalid selector ${c}`;throw new DOMException(p,a.SYNTAX_ERR)}const w=r.name;/^[\s>]$/.test(w)&&(b=!0),s.push({combo:r,leaves:(0,g.sortAST)(u)}),u.clear()}else if(r){let{name:m}=r;m&&typeof m=="string"&&(m=(0,g.unescapeSelector)(m),typeof m=="string"&&m!==r.name&&(r.name=m),/[|:]/.test(m)&&(r.namespace=!0)),u.add(r)}if(t.length)r=t.shift();else{s.push({combo:null,leaves:(0,g.sortAST)(u)}),u.clear();break}}}h.push({branch:s,collected:!1,dir:null,filtered:!1,find:!1}),e[d]=[],d++}let i;this.#c.has(this.#t)?i=this.#c.get(this.#t):i=new Map,i.set(`${c}`,{ast:h,descendant:b,invalidate:f}),this.#c.set(this.#t,i),this.#p=b,this.#o=f}return[h,e]}_createTreeWalker(c){let e;return this.#m.has(c)?e=this.#m.get(c):(e=this.#t.createTreeWalker(c,a.WALKER_FILTER),this.#m.set(c,e)),e}_prepareQuerySelectorWalker(){return this.#u=this._createTreeWalker(this.#e),this.#u}_collectNthChild(c,e,h){const{a:o,b:l,reverse:n,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:t,info:s}=(0,g.walkAST)(f);i=t,this.#n.set(f,i),s.hasLogicalPseudoFunc&&(this.#o=!0)}if(b){const t=this.#r;let s=(0,k.traverseNode)(b,t);s=t.firstChild();let r=0;for(;s;)r++,s=t.nextSibling();const u=new Set;if(i)for(s=(0,k.traverseNode)(b,t),s=t.firstChild();s;){const{display:m,visibility:w}=this.#l.getComputedStyle(s);if(m!=="none"&&w!=="hidden"){let p;for(const N of i)if(p=this._matchLeaves(N,s,h),!p)break;p&&u.add(s)}s=t.nextSibling()}if(o===0){if(l>0&&l<=r){if(u.size){s=(0,k.traverseNode)(b,t),n?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(u.has(s)){if(m===l-1){d.add(s);break}m++}n?s=t.previousSibling():s=t.nextSibling()}}else if(!f){s=(0,k.traverseNode)(b,t),n?s=t.lastChild():s=t.firstChild();let m=0;for(;s;){if(m===l-1){d.add(s);break}n?s=t.previousSibling():s=t.nextSibling(),m++}}}}else{let m=l-1;if(o>0)for(;m<0;)m+=o;if(m>=0&&m<r){s=(0,k.traverseNode)(b,t),n?s=t.lastChild():s=t.firstChild();let w=0,p=o>0?0:l-1;for(;s&&(s&&m>=0&&m<r);)u.size?u.has(s)&&(p===m&&(d.add(s),m+=o),o>0?p++:p--):w===m&&(f||d.add(s),m+=o),n?s=t.previousSibling():s=t.nextSibling(),w++}}if(n&&d.size>1){const m=[...d];return new Set(m.reverse())}}else if(e===this.#s&&o+l===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(c,e){const{a:h,b:o,reverse:l}=c,{localName:n,parentNode:f,prefix:b}=e,d=new Set;if(f){const i=this.#r;let t=(0,k.traverseNode)(f,i);t=i.firstChild();let s=0;for(;t;)s++,t=i.nextSibling();if(h===0){if(o>0&&o<=s){t=(0,k.traverseNode)(f,i),l?t=i.lastChild():t=i.firstChild();let r=0;for(;t;){const{localName:u,prefix:m}=t;if(u===n&&m===b){if(r===o-1){d.add(t);break}r++}l?t=i.previousSibling():t=i.nextSibling()}}}else{let r=o-1;if(h>0)for(;r<0;)r+=h;if(r>=0&&r<s){t=(0,k.traverseNode)(f,i),l?t=i.lastChild():t=i.firstChild();let u=h>0?0:o-1;for(;t;){const{localName:m,prefix:w}=t;if(m===n&&w===b){if(u===r&&(d.add(t),r+=h),r<0||r>=s)break;h>0?u++:u--}l?t=i.previousSibling():t=i.nextSibling()}}}if(l&&d.size>1){const r=[...d];return new Set(r.reverse())}}else e===this.#s&&h+o===1&&d.add(e);return d}_matchAnPlusB(c,e,h,o){const{nth:{a:l,b:n,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 n=="string"&&/-?\d+/.test(n)?d.set("b",n*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,o)}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 o;if(Array.isArray(c)&&c.length){const l=c.map(s=>s),[n]=l,{type:f}=n;let b;f===a.COMBINATOR?b=l.shift():b={name:" ",type:a.COMBINATOR};const d=[];for(;l.length;){const[s]=l,{type:r}=s;if(r===a.COMBINATOR)break;d.push(l.shift())}const i={combo:b,leaves:d};h.dir=v;const t=this._matchCombinator(i,e,h);if(t.size)if(l.length){for(const s of t)if(o=this._matchHasPseudoFunc(l,s,h),o)break}else o=!0}return!!o}_matchLogicalPseudoFunc(c,e,h={}){const{astName:o="",branches:l=[],selector:n="",twigBranches:f=[]}=c;let b;if(o==="has")if(n.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(o);h.forgive=d;const i=f.length;let t;for(let s=0;s<i;s++){const r=f[s],u=r.length-1,{leaves:m}=r[u];if(t=this._matchLeaves(m,e,h),t&&u>0){let w=new Set([e]);for(let p=u-1;p>=0;p--){const N=r[p],_=[];h.dir=S;for(const y of w){const E=this._matchCombinator(N,y,h);E.size&&_.push(...E)}if(_.length)p===0?t=!0:w=new Set(_);else{t=!1;break}}}if(t)break}o==="not"?t||(b=e):t&&(b=e)}return b??null}_matchPseudoClassSelector(c,e,h={}){const{children:o,name:l}=c,{localName:n,parentNode:f}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(l)){let t;if(this.#n.has(c))t=this.#n.get(c);else{const{branches:r}=(0,g.walkAST)(c),u=[],m=[];for(const[...w]of r){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)}t={astName:l,branches:r,twigBranches:m,selector:u.join(",")},this.#n.set(c,t)}const s=this._matchLogicalPseudoFunc(t,e,h);s&&i.add(s)}else if(Array.isArray(o))if(/^nth-(?:last-)?(?:child|of-type)$/.test(l)){const[t]=o;return this._matchAnPlusB(t,e,l,h)}else switch(l){case"dir":case"lang":{const t=L.matcher.matchSelector(c,e);t&&i.add(t);break}case"state":{if((0,k.isCustomElement)(e)){const[{value:t}]=o;t&&e[t]&&i.add(e)}break}case"current":case"nth-col":case"nth-last-col":{if(d){const t=`Unsupported pseudo-class :${l}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;case"contains":{if(d){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(!b){const t=`Unknown pseudo-class :${l}()`;throw new DOMException(t,a.SYNTAX_ERR)}}else switch(l){case"any-link":case"link":{a.REG_ANCHOR.test(n)&&e.hasAttribute("href")&&i.add(e);break}case"local-link":{if(a.REG_ANCHOR.test(n)&&e.hasAttribute("href")){const{href:t,origin:s,pathname:r}=new URL(this.#t.URL),u=new URL(e.getAttribute("href"),t);u.origin===s&&u.pathname===r&&i.add(e)}break}case"visited":break;case"hover":{const{target:t,type:s}=this.#d??{};(s==="mouseover"||s==="pointerover")&&e.contains(t)&&i.add(e);break}case"active":{const{buttons:t,target:s,type:r}=this.#d??{};(r==="mousedown"||r==="pointerdown")&&t&a.BIT_01&&e.contains(s)&&i.add(e);break}case"target":{const{hash:t}=new URL(this.#t.URL);e.id&&t===`#${e.id}`&&this.#t.contains(e)&&i.add(e);break}case"target-within":{const{hash:t}=new URL(this.#t.URL);if(t){const s=t.replace(/^#/,"");let r=this.#t.getElementById(s);for(;r;){if(r===e){i.add(e);break}r=r.parentNode}}break}case"scope":{this.#e.nodeType===a.ELEMENT_NODE?!this.#h&&e===this.#e&&i.add(e):e===this.#t.documentElement&&i.add(e);break}case"focus":case"focus-visible":{const{target:t,type:s}=this.#d??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(l==="focus"||s==="keydown"&&e.contains(t))){let r=e,u=!0;for(;r;){if(r.disabled||r.hasAttribute("disabled")||r.hidden||r.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(r);if(u=!(m==="none"||w==="hidden"),!u)break}if(r.parentNode&&r.parentNode.nodeType===a.ELEMENT_NODE)r=r.parentNode;else break}u&&i.add(e)}break}case"focus-within":{let t,s=this.#t.activeElement;if(s.tabIndex>=0)for(;s;){if(s===e){t=!0;break}s=s.parentNode}if(t){let r=e,u=!0;for(;r;){if(r.disabled||r.hasAttribute("disabled")||r.hidden||r.hasAttribute("hidden")){u=!1;break}else{const{display:m,visibility:w}=this.#l.getComputedStyle(r);if(u=!(m==="none"||w==="hidden"),!u)break}if(r.parentNode&&r.parentNode.nodeType===a.ELEMENT_NODE)r=r.parentNode;else break}u&&i.add(e)}break}case"open":{a.REG_INTERACT.test(n)&&e.hasAttribute("open")&&i.add(e);break}case"closed":{a.REG_INTERACT.test(n)&&!e.hasAttribute("open")&&i.add(e);break}case"disabled":{if(a.REG_FORM_CTRL.test(n)||(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 t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const r=this.#r;let u=(0,k.traverseNode)(s,r);for(u=r.firstChild();u&&u.localName!=="legend";)u=r.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t&&i.add(e)}}break}case"enabled":{if((a.REG_FORM_CTRL.test(n)||(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 t,s=f;for(;s;)if(s.localName==="fieldset"&&(s.disabled||s.hasAttribute("disabled"))){const r=this.#r;let u=(0,k.traverseNode)(s,r);for(u=r.firstChild();u&&u.localName!=="legend";)u=r.nextSibling();u&&u.contains(e)||(t=!0);break}else{if(s.localName==="form")break;if(s.parentNode?.nodeType===a.ELEMENT_NODE){if(s.parentNode.localName==="form")break;s=s.parentNode}else break}t||i.add(e)}break}case"read-only":{switch(n){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.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(n){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||i.add(e);break}case"input":{(!e.type||a.REG_TYPE_DATE.test(e.type)||a.REG_TYPE_TEXT.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 t;if(e.placeholder?t=e.placeholder:e.hasAttribute("placeholder")&&(t=e.getAttribute("placeholder")),typeof t=="string"&&!/[\r\n]/.test(t)){let s;n==="textarea"?s=e:n==="input"&&(e.hasAttribute("type")?a.REG_TYPE_TEXT.test(e.getAttribute("type"))&&(s=e):s=e),s&&e.value===""&&i.add(e)}break}case"checked":{(e.checked&&n==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))||e.selected&&n==="option")&&i.add(e);break}case"indeterminate":{if(e.indeterminate&&n==="input"&&e.type==="checkbox"||n==="progress"&&!e.hasAttribute("value"))i.add(e);else if(n==="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.#t.documentElement);const r=s.getElementsByTagName("input"),u=r.length;let m;for(let w=0;w<u;w++){const p=r[w];if(p.getAttribute("type")==="radio"&&(t?p.getAttribute("name")===t&&(m=!!p.checked):p.hasAttribute("name")||(m=!!p.checked),m))break}m||i.add(e)}break}case"default":{if(n==="button"&&!(e.hasAttribute("type")&&a.REG_TYPE_RESET.test(e.getAttribute("type")))||n==="input"&&e.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(e.getAttribute("type"))){let t=e.parentNode;for(;t&&t.localName!=="form";)t=t.parentNode;if(t){const s=this.#r;let r=(0,k.traverseNode)(t,s);for(r=s.firstChild();r&&t.contains(r);){const u=r.localName;let m;if(u==="button"?m=!(r.hasAttribute("type")&&a.REG_TYPE_RESET.test(r.getAttribute("type"))):u==="input"&&(m=r.hasAttribute("type")&&a.REG_TYPE_SUBMIT.test(r.getAttribute("type"))),m){r===e&&i.add(e);break}r=s.nextNode()}}}else(n==="input"&&e.hasAttribute("type")&&a.REG_TYPE_CHECK.test(e.getAttribute("type"))&&e.hasAttribute("checked")||n==="option"&&e.hasAttribute("selected"))&&i.add(e);break}case"valid":{if(a.REG_FORM_VALID.test(n))e.checkValidity()&&(e.maxLength>=0?e.maxLength>=e.value.length&&i.add(e):i.add(e));else if(n==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let r;if(!s)r=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?r=s.maxLength>=s.value.length:r=!0:r=!1,!r));)s=t.nextNode();r&&i.add(e)}break}case"invalid":{if(a.REG_FORM_VALID.test(n))e.checkValidity()?e.maxLength>=0&&e.maxLength<e.value.length&&i.add(e):i.add(e);else if(n==="fieldset"){const t=this.#r;let s=(0,k.traverseNode)(e,t);s=t.firstChild();let r;if(!s)r=!0;else for(;s&&e.contains(s)&&!(a.REG_FORM_VALID.test(s.localName)&&(s.checkValidity()?s.maxLength>=0?r=s.maxLength>=s.value.length:r=!0:r=!1,!r));)s=t.nextNode();r||i.add(e)}break}case"in-range":{n==="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":{n==="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 t;if(/^(?:select|textarea)$/.test(n))t=e;else if(n==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.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(n))t=e;else if(n==="input")if(e.hasAttribute("type")){const s=e.getAttribute("type");(s==="file"||a.REG_TYPE_CHECK.test(s)||a.REG_TYPE_DATE.test(s)||a.REG_TYPE_TEXT.test(s))&&(t=e)}else t=e;t&&!(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 t=this.#t.createTreeWalker(e,a.SHOW_ALL);let s=t.firstChild(),r;for(;s&&(r=s.nodeType!==a.ELEMENT_NODE&&s.nodeType!==a.TEXT_NODE,!!r);)s=t.nextSibling();r&&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[t]=this._collectNthOfType({a:0,b:1},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"last-of-type":{if(f){const[t]=this._collectNthOfType({a:0,b:1,reverse:!0},e);t&&i.add(t)}else e===this.#s&&i.add(e);break}case"only-of-type":{if(f){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.#s&&i.add(e);break}case"defined":{e.hasAttribute("is")||n.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":{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 ::${l}`;throw new DOMException(t,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){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}break}default:if(l.startsWith("-webkit-")){if(d){const t=`Unsupported pseudo-class :${l}`;throw new DOMException(t,a.NOT_SUPPORTED_ERR)}}else if(!b){const t=`Unknown pseudo-class :${l}`;throw new DOMException(t,a.SYNTAX_ERR)}}return i}_matchShadowHostPseudoClass(c,e){const{children:h,name:o}=c;let l;if(Array.isArray(h)){const{branches:n}=(0,g.walkAST)(h[0]),[f]=n,[...b]=f,{host:d}=e;if(o==="host"){let i;for(const t of b){const{type:s}=t;if(s===a.COMBINATOR){const u=`Invalid selector ${(0,g.generateCSS)(c)}`;throw new DOMException(u,a.SYNTAX_ERR)}if(i=this._matchSelector(t,d).has(d),!i)break}i&&(l=e)}else if(o==="host-context"){let i=d,t;for(;i;){for(const s of b){const{type:r}=s;if(r===a.COMBINATOR){const m=`Invalid selector ${(0,g.generateCSS)(c)}`;throw new DOMException(m,a.SYNTAX_ERR)}if(t=this._matchSelector(s,i).has(i),!t)break}if(t)break;i=i.parentNode}t&&(l=e)}}else if(o==="host")l=e;else{const n=`Invalid selector :${o}`;throw new DOMException(n,a.SYNTAX_ERR)}return l??null}_matchSelector(c,e,h){const{type:o}=c,l=new Set;if(c.name===a.EMPTY)return l;const n=(0,g.unescapeSelector)(c.name);if(typeof n=="string"&&n!==c.name&&(c.name=n),e.nodeType===a.ELEMENT_NODE)switch(o){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(n,h);break}case a.SELECTOR_ID:{e.id===n&&l.add(e);break}case a.SELECTOR_CLASS:{e.classList.contains(n)&&l.add(e);break}case a.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(c,e,h);default:{const f=L.matcher.matchSelector(c,e,h);f&&l.add(f)}}else if(this.#h&&o===a.SELECTOR_PSEUDO_CLASS&&e.nodeType===a.DOCUMENT_FRAGMENT_NODE){if(n!=="has"&&a.REG_LOGICAL_PSEUDO.test(n))return this._matchPseudoClassSelector(c,e,h);if(a.REG_SHADOW_HOST.test(n)){const f=this._matchShadowHostPseudoClass(c,e,h);f&&l.add(f)}}return l}_matchLeaves(c,e,h){let o,l;if(this.#o?l=this.#b.get(c):l=this.#w.get(c),l&&l.has(e)){const{matched:n}=l.get(e);o=n}if(typeof o!="boolean"){let n=!0;e.nodeType===a.ELEMENT_NODE&&a.REG_FORM.test(e.localName)&&(n=!1);for(const f of c){switch(f.type){case a.SELECTOR_ATTR:case a.SELECTOR_ID:{n=!1;break}case a.SELECTOR_PSEUDO_CLASS:{/^(?:(?:any-)?link|defined)$/.test(f.name)&&(n=!1);break}default:}if(o=this._matchSelector(f,e,h).has(e),!o)break}n&&(l||(l=new WeakMap),l.set(e,{matched:o}),this.#o?this.#b.set(c,l):this.#w.set(c,l))}return!!o}_matchHTMLCollection(c,e={}){const{compound:h,filterLeaves:o}=e,l=new Set,n=c.length;if(n)if(h)for(let f=0;f<n;f++){const b=c[f];this._matchLeaves(o,b,e)&&l.add(b)}else{const f=[].slice.call(c);return new Set(f)}return l}_findDescendantNodes(c,e,h){const[o,...l]=c,n=l.length>0,{type:f}=o,b=(0,g.unescapeSelector)(o.name);typeof b=="string"&&b!==o.name&&(o.name=b);let d=new Set,i=!1;if(this.#h)i=!0;else switch(f){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,h);break}case a.SELECTOR_ID:{if(this.#s.nodeType===a.ELEMENT_NODE)i=!0;else{const t=this.#s.getElementById(b);t&&t!==e&&e.contains(t)&&(n?this._matchLeaves(l,t,h)&&d.add(t):d.add(t))}break}case a.SELECTOR_CLASS:{const t=e.getElementsByClassName(b);d=this._matchHTMLCollection(t,{compound:n,filterLeaves:l});break}case a.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(b)){const t=e.getElementsByTagName(b);d=this._matchHTMLCollection(t,{compound:n,filterLeaves:l})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(c,e,h={}){const{combo:o,leaves:l}=c,{name:n}=o,{parentNode:f}=e,{dir:b}=h,d=new Set;if(b===v)switch(n){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(e,i);for(t=i.nextSibling();t;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{const i=this._createTreeWalker(e);let t=(0,k.traverseNode)(e,i);for(t=i.firstChild();t;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling();break}case" ":default:{const{nodes:i,pending:t}=this._findDescendantNodes(l,e);if(i.size)return i;if(t){const s=this._createTreeWalker(e);let r=(0,k.traverseNode)(e,s);for(r=s.nextNode();r&&e.contains(r);)this._matchLeaves(l,r,h)&&d.add(r),r=s.nextNode()}}}else switch(n){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(l,i,h)&&d.add(i);break}case"~":{if(f){const i=this._createTreeWalker(f);let t=(0,k.traverseNode)(f,i);for(t=i.firstChild();t&&t!==e;)this._matchLeaves(l,t,h)&&d.add(t),t=i.nextSibling()}break}case">":{f&&this._matchLeaves(l,f,h)&&d.add(f);break}case" ":default:{const i=[];let t=f;for(;t;)this._matchLeaves(l,t,h)&&i.push(t),t=t.parentNode;if(i.length)return new Set(i.reverse())}}return d}_findNode(c,e){const{node:h}=e,o=this.#u;let l=(0,k.traverseNode)(h,o),n;if(l)for((l.nodeType!==a.ELEMENT_NODE||l===h&&l!==this.#s)&&(l=o.nextNode());l;){if(this._matchLeaves(c,l,{warn:this.#i})){n=l;break}l=o.nextNode()}return n??null}_matchSelf(c){const e=[],h=this._matchLeaves(c,this.#e,{warn:this.#i});let o=!1;return h&&(e.push(this.#e),o=!0),[e,o]}_findLineal(c,e={}){const{complex:h}=e,o=[];let l=this._matchLeaves(c,this.#e,{warn:this.#i}),n=!1;if(l&&(o.push(this.#e),n=!0),!l||h){let f=this.#e.parentNode;for(;f&&(l=this._matchLeaves(c,f,{warn:this.#i}),l&&(o.push(f),n=!0),f.parentNode);)f=f.parentNode}return[o,n]}_findFirst(c){const e=[],h=this._findNode(c,{node:this.#e});let o=!1;return h&&(e.push(h),o=!0),[e,o]}_findFromHTMLCollection(c,e={}){const{complex:h,compound:o,filterLeaves:l,targetType:n}=e;let f=[],b=!1,d=!1;const i=c.length;if(i)if(this.#e.nodeType===a.ELEMENT_NODE)for(let t=0;t<i;t++){const s=c[t];if(s!==this.#e&&(this.#e.contains(s)||s.contains(this.#e))){if(o){if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,n===a.TARGET_FIRST))break}else if(f.push(s),b=!0,n===a.TARGET_FIRST)break}}else if(h)if(o)for(let t=0;t<i;t++){const s=c[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,n===a.TARGET_FIRST))break}else f=[].slice.call(c),b=!0,d=!0;else if(o)for(let t=0;t<i;t++){const s=c[t];if(this._matchLeaves(l,s,{warn:this.#i})&&(f.push(s),b=!0,n===a.TARGET_FIRST))break}else f=[].slice.call(c),b=!0,d=!0;return[f,b,d]}_findEntryNodes(c,e,h){const{leaves:o}=c,[l,...n]=o,f=n.length>0,{name:b,type:d}=l;let i=[],t=!1,s=!1,r=!1;switch(d){case a.SELECTOR_PSEUDO_ELEMENT:{L.matcher.matchPseudoElementSelector(b,{warn:this.#i});break}case a.SELECTOR_ID:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(o);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(o,{complex:h});else if(e===a.TARGET_FIRST&&this.#s.nodeType!==a.ELEMENT_NODE){const u=this.#s.getElementById(b);u&&(f?this._matchLeaves(n,u,{warn:this.#i})&&(i.push(u),s=!0):(i.push(u),s=!0))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(o):r=!0;break}case a.SELECTOR_CLASS:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(o);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(o,{complex:h});else if(this.#s.nodeType===a.DOCUMENT_NODE){const u=this.#s.getElementsByClassName(b);u.length&&([i,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:n,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(o):r=!0;break}case a.SELECTOR_TYPE:{if(e===a.TARGET_SELF)[i,s]=this._matchSelf(o);else if(e===a.TARGET_LINEAL)[i,s]=this._findLineal(o,{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,s,t]=this._findFromHTMLCollection(u,{complex:h,compound:f,filterLeaves:n,targetType:e}))}else e===a.TARGET_FIRST?[i,s]=this._findFirst(o):r=!0;break}default:if(e!==a.TARGET_LINEAL&&a.REG_SHADOW_HOST.test(b)){if(this.#h&&this.#e.nodeType===a.DOCUMENT_FRAGMENT_NODE){const u=this._matchShadowHostPseudoClass(l,this.#e);u&&(i.push(u),s=!0)}}else e===a.TARGET_SELF?[i,s]=this._matchSelf(o):e===a.TARGET_LINEAL?[i,s]=this._findLineal(o,{complex:h}):e===a.TARGET_FIRST?[i,s]=this._findFirst(o):r=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:r}}_collectNodes(c){const e=this.#a.values();if(c===a.TARGET_ALL||c===a.TARGET_FIRST){const h=new Set;let o=0;for(const{branch:l}of e){const n=l.length,f=n>1,b=l[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=l[n-1],{leaves:[{name:y,type:E}]}=_;if(E===a.SELECTOR_PSEUDO_ELEMENT||E===a.SELECTOR_ID)d=S,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=S,i=_;else if(y==="*"&&E===a.SELECTOR_TYPE)d=v,i=b;else if(n===2){const{name:A}=w;/^[+~]$/.test(A)?(d=S,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=S,i=_;else{let A;for(const{combo:C,leaves:[R]}of l){const{name:O,type:M}=R;if(M===a.SELECTOR_PSEUDO_CLASS&&O==="dir"){A=!1;break}if(!A&&C){const{name:P}=C;/^[+~]$/.test(P)&&(A=!0)}}A?(d=v,i=b):(d=S,i=_)}}else d=S,i=b;const{collected:t,compound:s,filtered:r,nodes:u,pending:m}=this._findEntryNodes(i,c,f);u.length?(this.#a[o].find=!0,this.#f[o]=u):m&&h.add(new Map([["index",o],["twig",i]])),this.#a[o].collected=t,this.#a[o].dir=d,this.#a[o].filtered=r||!s,o++}if(h.size){let l,n;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(l=this.#e,n=this.#u):(l=this.#s,n=this.#r);let f=(0,k.traverseNode)(l,n);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 s=d.get("index");this.#a[s].filtered=!0,this.#a[s].find=!0,this.#f[s].push(f)}}f!==n.currentNode&&(f=(0,k.traverseNode)(f,n)),f=n.nextNode()}}}else{let h=0;for(const{branch:o}of e){const l=o[o.length-1],n=o.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(l,c,n);d.length&&(this.#a[h].find=!0,this.#f[h]=d),this.#a[h].dir=S,this.#a[h].filtered=b||!f,h++}}return[this.#a,this.#f]}_getCombinedNodes(c,e,h){const o=[];for(const l of e){const n=this._matchCombinator(c,l,{dir:h,warn:this.#i});n.size&&o.push(...n)}return o.length?new Set(o):new Set}_matchNodeNext(c,e,h){const{combo:o,index:l}=h,{combo:n,leaves:f}=c[l],b={combo:o,leaves:f},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(l===c.length-1){const[t]=(0,k.sortNodes)(d);i=t}else i=this._matchNodeNext(c,d,{combo:n,index:l+1});return i??null}_matchNodePrev(c,e,h){const{index:o}=h,l=c[o],n=new Set([e]),f=this._getCombinedNodes(l,n,S);let b;if(f.size){if(o===0)b=e;else for(const d of f)if(this._matchNodePrev(c,d,{index:o-1}))return e}return b??null}_find(c){(c===a.TARGET_ALL||c===a.TARGET_FIRST)&&this._prepareQuerySelectorWalker();const[[...e],h]=this._collectNodes(c),o=e.length;let l,n=new Set;for(let f=0;f<o;f++){const{branch:b,collected:d,dir:i,find:t}=e[f],s=b.length;if(s&&t){const r=h[f],u=r.length,m=s-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=r[w];if(p!==this.#e&&this.#e.contains(p)&&(n.add(p),c!==a.TARGET_ALL))break}else if(c===a.TARGET_ALL)if(n.size){const w=[...n];n=new Set([...w,...r]),l=!0}else n=new Set(r);else{const[w]=r;n.add(w)}else if(c===a.TARGET_ALL)if(i===v){let{combo:w}=b[0];for(const p of r){let N=new Set([p]);for(let _=1;_<s;_++){const{combo:y,leaves:E}=b[_],A={combo:w,leaves:E};if(N=this._getCombinedNodes(A,N,i),N.size)if(_===m)if(n.size){const C=[...n];n=new Set([...C,...N]),l=!0}else n=N;else w=y;else break}}}else for(const w of r){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&&(n.add(w),s>1&&n.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 r)if(p=this._matchNodeNext(b,new Set([N]),{combo:w,index:1}),p){n.add(p);break}if(!p&&!d){const{leaves:N}=b[0],[_]=r;let y=this._findNode(N,{node:_});for(;y;){if(p=this._matchNodeNext(b,new Set([y]),{combo:w,index:1}),p){n.add(p);break}y=this._findNode(N,{node:y})}}}else{let w;for(const p of r)if(w=this._matchNodePrev(b,p,{index:m-1}),w){n.add(p);break}if(!w&&!d&&c===a.TARGET_FIRST){const{leaves:p}=b[m],[N]=r;let _=this._findNode(p,{node:N});for(;_;){if(w=this._matchNodePrev(b,_,{index:m-1}),w){n.add(_);break}_=this._findNode(p,{node:_})}}}}}return c===a.TARGET_ALL&&l&&(n=new Set((0,k.sortNodes)(n))),n}}0&&(module.exports={Finder}); | ||
//# sourceMappingURL=finder.js.map |
@@ -1,2 +0,2 @@ | ||
var p=Object.create;var r=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var c=(t,n)=>{for(var e in n)r(t,e,{get:n[e],enumerable:!0})},E=(t,n,e,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of l(n))!_.call(t,i)&&i!==e&&r(t,i,{get:()=>n[i],enumerable:!(f=o(n,i))||f.enumerable});return t};var u=(t,n,e)=>(e=t!=null?p(a(t)):{},E(n||!t||!t.__esModule?r(e,"default",{value:t,enumerable:!0}):e,t)),L=t=>E(r({},"__esModule",{value:!0}),t);var R={};c(R,{filterSelector:()=>x,initNwsapi:()=>G});module.exports=L(R);var O=u(require("@asamuzakjp/nwsapi"),1),s=require("./constant.js");const G=(t,n)=>{if(t?.document)n?.nodeType!==s.DOCUMENT_NODE&&(n=t.document);else{const i=`Unexpected global object ${Object.prototype.toString.call(t).slice(s.TYPE_FROM,s.TYPE_TO)}`;throw new TypeError(i)}const e=(0,O.default)({document:n,DOMException:t.DOMException});return e.configure({LOGERRORS:!1}),e},x=(t,n={})=>{if(!t||typeof t!="string")return!1;if(t.includes("[")){const e=t.lastIndexOf("[");if(t.substring(e).lastIndexOf("]")<0)return!1}if(/\||::|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]/.test(t))return!1;if(t.includes(":")){let e;if(s.REG_LOGICAL_KEY.test(t)){if(s.REG_LOGICAL_EMPTY.test(t))return!1;const{complex:f,descendant:i}=n;f&&i?e=s.REG_LOGICAL_COMPLEX:e=s.REG_LOGICAL_COMPOUND}else e=s.REG_CHILD_INDEXED;if(e.test(t))return!1}return!0};0&&(module.exports={filterSelector,initNwsapi}); | ||
var p=Object.create;var r=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var c=(t,n)=>{for(var e in n)r(t,e,{get:n[e],enumerable:!0})},E=(t,n,e,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of l(n))!_.call(t,i)&&i!==e&&r(t,i,{get:()=>n[i],enumerable:!(f=o(n,i))||f.enumerable});return t};var u=(t,n,e)=>(e=t!=null?p(a(t)):{},E(n||!t||!t.__esModule?r(e,"default",{value:t,enumerable:!0}):e,t)),L=t=>E(r({},"__esModule",{value:!0}),t);var D={};c(D,{filterSelector:()=>G,initNwsapi:()=>x});module.exports=L(D);var O=u(require("@asamuzakjp/nwsapi"),1),s=require("./constant.js");const x=(t,n)=>{if(!t||!t.DOMException){const i=`Unexpected global object ${Object.prototype.toString.call(t).slice(s.TYPE_FROM,s.TYPE_TO)}`;throw new TypeError(i)}n?.nodeType!==s.DOCUMENT_NODE&&(n=t.document);const e=(0,O.default)({document:n,DOMException:t.DOMException});return e.configure({LOGERRORS:!1}),e},G=(t,n={})=>{if(!t||typeof t!="string")return!1;if(t.includes("[")){const e=t.lastIndexOf("[");if(t.substring(e).lastIndexOf("]")<0)return!1}if(/\||::|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]/.test(t))return!1;if(t.includes(":")){let e;if(s.REG_LOGICAL_KEY.test(t)){if(s.REG_LOGICAL_EMPTY.test(t))return!1;const{complex:f,descendant:i}=n;f&&i?e=s.REG_LOGICAL_COMPLEX:e=s.REG_LOGICAL_COMPOUND}else e=s.REG_CHILD_INDEXED;if(e.test(t))return!1}return!0};0&&(module.exports={filterSelector,initNwsapi}); | ||
//# sourceMappingURL=nwsapi.js.map |
@@ -63,3 +63,3 @@ { | ||
}, | ||
"version": "5.0.4" | ||
"version": "5.0.5" | ||
} |
@@ -108,4 +108,2 @@ /** | ||
export const REG_INTERACT = /^(?:details|dialog)$/; | ||
export const REG_INVALIDATE_PSEUDO = | ||
/^(?:(?:any-)?link|defined|dir|has|host(?:-context)?|not)$/; | ||
export const REG_INVALID_SELECTOR = /^$|^\s*>|,\s*$/; | ||
@@ -112,0 +110,0 @@ export const REG_LANG = new RegExp(`^(?:\\*-)?${ALPHA_NUM}${LANG_PART}$`, 'i'); |
@@ -21,3 +21,3 @@ /** | ||
export const initNwsapi = (window, document) => { | ||
if (!window?.document) { | ||
if (!window || !window.DOMException) { | ||
const type = | ||
@@ -27,3 +27,4 @@ Object.prototype.toString.call(window).slice(TYPE_FROM, TYPE_TO); | ||
throw new TypeError(msg); | ||
} else if (document?.nodeType !== DOCUMENT_NODE) { | ||
} | ||
if (document?.nodeType !== DOCUMENT_NODE) { | ||
document = window.document; | ||
@@ -30,0 +31,0 @@ } |
@@ -78,3 +78,2 @@ export const AN_PLUS_B: "AnPlusB"; | ||
export const REG_INTERACT: RegExp; | ||
export const REG_INVALIDATE_PSEUDO: RegExp; | ||
export const REG_INVALID_SELECTOR: RegExp; | ||
@@ -81,0 +80,0 @@ export const REG_LANG: 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 too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
437394
4900