@asamuzakjp/dom-selector
Advanced tools
Comparing version 5.0.7 to 5.0.8
@@ -1,2 +0,2 @@ | ||
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}); | ||
var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var H=(o,t)=>{for(var n in t)O(o,n,{get:t[n],enumerable:!0})},Y=(o,t,n,C)=>{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:!(C=F(t,s))||C.enumerable});return o};var u=o=>Y(O({},"__esModule",{value:!0}),o);var to={};H(to,{ALPHA_NUM:()=>R,ANB:()=>D,AN_PLUS_B:()=>B,BIT_01:()=>et,BIT_02:()=>st,BIT_04:()=>Et,BIT_08:()=>rt,BIT_16:()=>nt,BIT_32:()=>_t,BIT_FFFF:()=>ct,BIT_HYPHEN:()=>xt,CHILD_IDX:()=>I,COMBINATOR:()=>m,COMBO:()=>p,COMPLEX:()=>L,COMPLEX_L:()=>N,COMPOUND:()=>r,COMPOUND_A:()=>A,COMPOUND_B:()=>S,COMPOUND_I:()=>i,DIGIT:()=>_,DOCUMENT_FRAGMENT_NODE:()=>St,DOCUMENT_NODE:()=>At,DOCUMENT_POSITION_CONTAINED_BY:()=>It,DOCUMENT_POSITION_CONTAINS:()=>Ct,DOCUMENT_POSITION_PRECEDING:()=>Nt,DUO:()=>pt,ELEMENT_NODE:()=>$t,EMPTY:()=>w,HEX:()=>Tt,IDENTIFIER:()=>g,KEY_IS_NOT:()=>T,LANG_PART:()=>G,LOGICAL_COMPLEX:()=>a,LOGICAL_COMPOUND:()=>M,NESTED_LOGICAL_A:()=>P,NESTED_LOGICAL_B:()=>l,NOT_SUPPORTED_ERR:()=>h,NTH:()=>f,N_TH:()=>x,PSEUDO_CLASSES:()=>c,RAW:()=>X,REG_ANCHOR:()=>at,REG_COMPLEX:()=>Mt,REG_DIR:()=>Ft,REG_FILTER_CHAR:()=>Ut,REG_FILTER_PSEUDO:()=>dt,REG_FORM:()=>Ht,REG_FORM_CTRL:()=>Yt,REG_FORM_VALID:()=>ut,REG_HEX:()=>Bt,REG_INTERACT:()=>mt,REG_INVALID_SELECTOR:()=>wt,REG_LANG:()=>gt,REG_LANG_QUOTED:()=>ht,REG_LOGICAL_COMPLEX:()=>ft,REG_LOGICAL_COMPOUND:()=>Xt,REG_LOGICAL_EMPTY:()=>bt,REG_LOGICAL_IS_NOT:()=>Wt,REG_LOGICAL_PSEUDO:()=>yt,REG_SHADOW_HOST:()=>kt,REG_SHADOW_MODE:()=>Zt,REG_SHADOW_PSEUDO:()=>Kt,REG_TAG_NAME:()=>vt,REG_TYPE_CHECK:()=>zt,REG_TYPE_DATE:()=>Vt,REG_TYPE_RANGE:()=>Qt,REG_TYPE_RESET:()=>jt,REG_TYPE_SUBMIT:()=>qt,REG_TYPE_TEXT:()=>Jt,SELECTOR:()=>b,SELECTOR_ATTR:()=>W,SELECTOR_CLASS:()=>y,SELECTOR_ID:()=>k,SELECTOR_LIST:()=>Z,SELECTOR_PSEUDO_CLASS:()=>K,SELECTOR_PSEUDO_ELEMENT:()=>v,SELECTOR_TYPE:()=>z,SHOW_ALL:()=>Gt,SHOW_DOCUMENT:()=>Dt,SHOW_DOCUMENT_FRAGMENT:()=>Pt,SHOW_ELEMENT:()=>lt,STRING:()=>V,SUB_TYPE:()=>E,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(to);const B="AnPlusB",m="Combinator",w="__EMPTY__",g="Identifier",h="NotSupportedError",f="Nth",X="Raw",b="Selector",W="AttributeSelector",y="ClassSelector",k="IdSelector",Z="SelectorList",K="PseudoClassSelector",v="PseudoElementSelector",z="TypeSelector",V="String",Q="SyntaxError",j="all",q="first",J="lineal",tt="self",ot="\uFFFD",et=1,st=2,Et=4,rt=8,nt=16,_t=32,ct=65535,xt=45,pt=2,Tt=16,Ot=8,Rt=-1,$t=1,Lt=3,At=9,St=11,Nt=2,Ct=8,It=16,Gt=4294967295,Dt=256,Pt=1024,lt=1,it=1281,R="[A-Z\\d]+",I="(?:first|last|only)-(?:child|of-type)",_="(?:0|[1-9]\\d*)",G=`(?:-${R})*`,c=`(?:any-)?link|${I}|checked|empty|indeterminate|root|target|visited`,D=`[+-]?(?:${_}n?|n)|(?:[+-]?${_})?n\\s*[+-]\\s*${_}`,x=`nth-(?:last-)?(?:child|of-type)\\(\\s*(?:even|odd|${D})\\s*\\)`,E="\\[[^|\\]]+\\]|[#.:][\\w-]+",e="\\*|[A-Za-z][\\w-]*",$="\\*|[A-Z][\\w-]*",r=`(?:${e}|(?:${e})?(?:${E})+)`,p="\\s?[\\s>~+]\\s?",L=`${r}(?:${p}${r})*`,P=`:is\\(\\s*${r}(?:\\s*,\\s*${r})*\\s*\\)`,l=`:is\\(\\s*${L}(?:\\s*,\\s*${L})*\\s*\\)`,A=`(?:${e}|(?:${e})?(?:${E}|${P})+)`,S=`(?:${e}|(?:${e})?(?:${E}|${l})+)`,i=`(?:${$}|(?:${$})?(?:${E})+)`,N=`${S}(?:${p}${S})*`,T="(?:is|not)",a=`${T}\\(\\s*${N}(?:\\s*,\\s*${N})*\\s*\\)`,M=`${T}\\(\\s*${A}(?:\\s*,\\s*${A})*\\s*\\)`,at=/^a(?:rea)?$/,Mt=new RegExp(`${p}${i}`,"i"),Ft=/^(?:ltr|rtl)$/,Ut=/[\w\s\-#$%&()*+,./:;<>=?@[\]^"'`]/,dt=new RegExp(`:(?!${c}|${x})`),Ht=/^(?:button|fieldset|form|input|select|textarea)$/,Yt=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,ut=/^(?:button|form|input|select|textarea)$/,Bt=/^([\da-f]{1,6}\s?)/i,mt=/^(?:details|dialog)$/,wt=/^$|^\s*>|,\s*$/,gt=new RegExp(`^(?:\\*-)?${R}${G}$`,"i"),ht=/(:lang\(\s*("[A-Za-z\d\-*]*")\s*\))/,ft=new RegExp(`:(?!${c}|${x}|${a})`),Xt=new RegExp(`:(?!${c}|${x}|${M})`),bt=/(:(is|where)\(\s*\))/,Wt=new RegExp(`:${T}\\(`),yt=/^(?:has|is|not|where)$/,kt=/^host(?:-context)?$/,Zt=/^(?:close|open)$/,Kt=/^part|slotted$/,vt=/[A-Z][\\w-]*/i,zt=/^(?:checkbox|radio)$/,Vt=/^(?:date(?:time-local)?|month|time|week)$/,Qt=/(?:date(?:time-local)?|month|number|range|time|week)$/,jt=/^(?:button|reset)$/,qt=/^(?:image|submit)$/,Jt=/^(?:email|number|password|search|tel|text|url)$/;0&&(module.exports={ALPHA_NUM,ANB,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,CHILD_IDX,COMBINATOR,COMBO,COMPLEX,COMPLEX_L,COMPOUND,COMPOUND_A,COMPOUND_B,COMPOUND_I,DIGIT,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,KEY_IS_NOT,LANG_PART,LOGICAL_COMPLEX,LOGICAL_COMPOUND,NESTED_LOGICAL_A,NESTED_LOGICAL_B,NOT_SUPPORTED_ERR,NTH,N_TH,PSEUDO_CLASSES,RAW,REG_ANCHOR,REG_COMPLEX,REG_DIR,REG_FILTER_CHAR,REG_FILTER_PSEUDO,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_IS_NOT,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,REG_TAG_NAME,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 $=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|dir)$/.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}); | ||
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:r,warn:n}=h;return this.#k=!!r,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 r=o.get(`${c}`);h=r.ast,this.#p=r.descendant,this.#o=r.invalidate}}if(h){const o=h.length;for(let r=0;r<o;r++)h[r].collected=!1,h[r].dir=null,h[r].filtered=!1,h[r].find=!1,e[r]=[]}else{let o;try{o=(0,g.parseSelector)(c)}catch(t){this._onError(t)}const{branches:r,info:{hasHasPseudoFunc:n}}=(0,g.walkAST)(o),f=!!n;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 ${c}`;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.#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:r,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 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(o===0){if(r>0&&r<=l){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===r-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===r-1){d.add(s);break}n?s=t.previousSibling():s=t.nextSibling(),m++}}}}else{let m=r-1;if(o>0)for(;m<0;)m+=o;if(m>=0&&m<l){s=(0,k.traverseNode)(b,t),n?s=t.lastChild():s=t.firstChild();let w=0,p=o>0?0:r-1;for(;s&&(s&&m>=0&&m<l);)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+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(c,e){const{a:h,b:o,reverse:r}=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),r?t=i.lastChild():t=i.firstChild();let l=0;for(;t;){const{localName:u,prefix:m}=t;if(u===n&&m===b){if(l===o-1){d.add(t);break}l++}r?t=i.previousSibling():t=i.nextSibling()}}}else{let l=o-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:o-1;for(;t;){const{localName:m,prefix:w}=t;if(m===n&&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+o===1&&d.add(e);return d}_matchAnPlusB(c,e,h,o){const{nth:{a:r,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 r=="string"&&/-?\d+/.test(r)?d.set("a",r*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 r=c.map(s=>s),[n]=r,{type:f}=n;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(o=this._matchHasPseudoFunc(r,s,h),o)break}else o=!0}return!!o}_matchLogicalPseudoFunc(c,e,h={}){const{astName:o="",branches:r=[],selector:n="",twigBranches:f=[]}=c;let b;if(o==="has")if(n.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(o);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}o==="not"?t||(b=e):t&&(b=e)}return b??null}_matchPseudoClassSelector(c,e,h={}){const{children:o,name:r}=c,{localName:n,parentNode:f}=e,{forgive:b,warn:d=this.#i}=h,i=new Set;if(a.REG_LOGICAL_PSEUDO.test(r)){let t;if(this.#n.has(c))t=this.#n.get(c);else{const{branches:l}=(0,g.walkAST)(c),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.#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(r)){const[t]=o;return this._matchAnPlusB(t,e,r,h)}else switch(r){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;if(t)if(e[t])i.add(e);else for(const s in e){const l=e[s];if(l instanceof this.#l.ElementInternals){l?.states?.has(t)&&i.add(e);break}}}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(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: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(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 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(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 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(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 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(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 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(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 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(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 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":{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(),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")||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 ::${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(c,e){const{children:h,name:o}=c;let r;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&&(r=e)}else if(o==="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)(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&&(r=e)}}else if(o==="host")r=e;else{const n=`Invalid selector :${o}`;throw new DOMException(n,a.SYNTAX_ERR)}return r??null}_matchSelector(c,e,h){const{type:o}=c,r=new Set;if(c.name===a.EMPTY)return r;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&&r.add(e);break}case a.SELECTOR_CLASS:{e.classList.contains(n)&&r.add(e);break}case a.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(c,e,h);default:{const f=L.matcher.matchSelector(c,e,h);f&&r.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&&r.add(f)}}return r}_matchLeaves(c,e,h){let o,r;if(this.#o?r=this.#b.get(c):r=this.#w.get(c),r&&r.has(e)){const{matched:n}=r.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|dir)$/.test(f.name)&&(n=!1);break}default:}if(o=this._matchSelector(f,e,h).has(e),!o)break}n&&(r||(r=new WeakMap),r.set(e,{matched:o}),this.#o?this.#b.set(c,r):this.#w.set(c,r))}return!!o}_matchHTMLCollection(c,e={}){const{compound:h,filterLeaves:o}=e,r=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)&&r.add(b)}else{const f=[].slice.call(c);return new Set(f)}return r}_findDescendantNodes(c,e,h){const[o,...r]=c,n=r.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(r,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:r});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:r})}else i=!0;break}default:i=!0}return{nodes:d,pending:i}}_matchCombinator(c,e,h={}){const{combo:o,leaves:r}=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(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(n){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(c,e){const{node:h}=e,o=this.#u;let r=(0,k.traverseNode)(h,o),n;if(r)for((r.nodeType!==a.ELEMENT_NODE||r===h&&r!==this.#s)&&(r=o.nextNode());r;){if(this._matchLeaves(c,r,{warn:this.#i})){n=r;break}r=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 r=this._matchLeaves(c,this.#e,{warn:this.#i}),n=!1;if(r&&(o.push(this.#e),n=!0),!r||h){let f=this.#e.parentNode;for(;f&&(r=this._matchLeaves(c,f,{warn:this.#i}),r&&(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:r,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(r,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(r,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(r,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,[r,...n]=o,f=n.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(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):l=!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):l=!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):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(o):e===a.TARGET_LINEAL?[i,s]=this._findLineal(o,{complex:h}):e===a.TARGET_FIRST?[i,s]=this._findFirst(o):l=!0}return{collected:t,compound:f,filtered:s,nodes:i,pending:l}}_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:r}of e){const n=r.length,f=n>1,b=r[0];let d,i;if(f){const{combo:w,leaves:[{name:p,type:N}]}=b,_=r[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 r){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:l,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=l||!s,o++}if(h.size){let r,n;this.#e!==this.#s&&this.#e.nodeType===a.ELEMENT_NODE?(r=this.#e,n=this.#u):(r=this.#s,n=this.#r);let f=(0,k.traverseNode)(r,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 r=o[o.length-1],n=o.length>1,{compound:f,filtered:b,nodes:d}=this._findEntryNodes(r,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 r of e){const n=this._matchCombinator(c,r,{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:r}=h,{combo:n,leaves:f}=c[r],b={combo:o,leaves:f},d=this._getCombinedNodes(b,e,v);let i;if(d.size)if(r===c.length-1){const[t]=(0,k.sortNodes)(d);i=t}else i=this._matchNodeNext(c,d,{combo:n,index:r+1});return i??null}_matchNodePrev(c,e,h){const{index:o}=h,r=c[o],n=new Set([e]),f=this._getCombinedNodes(r,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 r,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 l=h[f],u=l.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=l[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,...l]),r=!0}else n=new Set(l);else{const[w]=l;n.add(w)}else if(c===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(n.size){const C=[...n];n=new Set([...C,...N]),r=!0}else n=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&&(n.add(w),s>1&&n.size>1&&(r=!0));else break}}else if(c===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){n.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){n.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){n.add(p);break}if(!w&&!d&&c===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){n.add(_);break}_=this._findNode(p,{node:_})}}}}}return c===a.TARGET_ALL&&r&&(n=new Set((0,k.sortNodes)(n))),n}}0&&(module.exports={Finder}); | ||
//# sourceMappingURL=finder.js.map |
@@ -1,2 +0,2 @@ | ||
var $=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var A=(x,t)=>{for(var e in t)$(x,e,{get:t[e],enumerable:!0})},_=(x,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of S(t))!O.call(x,r)&&r!==e&&$(x,r,{get:()=>t[r],enumerable:!(n=L(t,r))||n.enumerable});return x};var P=x=>_($({},"__esModule",{value:!0}),x);var C={};A(C,{Matcher:()=>k,default:()=>R,matcher:()=>N});module.exports=P(C);var y=require("./dom-util.js"),b=require("./parser.js"),s=require("./constant.js");class k{matchPseudoElementSelector(t,e={}){if(!t||typeof t!="string"){const o=`Unexpected type ${Object.prototype.toString.call(t).slice(s.TYPE_FROM,s.TYPE_TO)}`;throw new TypeError(o)}const{forgive:n,warn:r}=e;switch(t){case"after":case"backdrop":case"before":case"cue":case"cue-region":case"first-letter":case"first-line":case"file-selector-button":case"marker":case"placeholder":case"selection":case"target-text":{if(r){const a=`Unsupported pseudo-element ::${t}`;throw new DOMException(a,s.NOT_SUPPORTED_ERR)}break}case"part":case"slotted":{if(r){const a=`Unsupported pseudo-element ::${t}()`;throw new DOMException(a,s.NOT_SUPPORTED_ERR)}break}default:if(t.startsWith("-webkit-")){if(r){const a=`Unsupported pseudo-element ::${t}`;throw new DOMException(a,s.NOT_SUPPORTED_ERR)}}else if(!n){const a=`Unknown pseudo-element ::${t}`;throw new DOMException(a,s.SYNTAX_ERR)}}}_matchAttributeSelector(t,e){const{flags:n,matcher:r,name:a,value:o}=t;if(typeof n=="string"&&!/^[is]$/i.test(n)){const c=`Invalid selector ${(0,b.generateCSS)(t)}`;throw new DOMException(c,s.SYNTAX_ERR)}const{attributes:w}=e;let h;if(w&&w.length){const d=e.ownerDocument.contentType;let c;d==="text/html"?typeof n=="string"&&/^s$/i.test(n)?c=!1:c=!0:typeof n=="string"&&/^i$/i.test(n)?c=!0:c=!1;let g=(0,b.unescapeSelector)(a.name);c&&(g=g.toLowerCase());const f=new Set;if(g.indexOf("|")>-1){const{prefix:p,localName:u}=(0,b.parseAstName)(g);for(const i of w){let{name:l,value:m}=i;switch(c&&(l=l.toLowerCase(),m=m.toLowerCase()),p){case"":{u===l&&f.add(m);break}case"*":{l.indexOf(":")>-1?l.endsWith(`:${u}`)&&f.add(m):u===l&&f.add(m);break}default:if(l.indexOf(":")>-1){const[T,E]=l.split(":");if(T==="xml"&&E==="lang")continue;p===T&&u===E&&(0,y.isNamespaceDeclared)(p,e)&&f.add(m)}}}}else for(let{name:p,value:u}of w)if(c&&(p=p.toLowerCase(),u=u.toLowerCase()),p.indexOf(":")>-1){const[i,l]=p.split(":");if(i==="xml"&&l==="lang")continue;g===l&&f.add(u)}else g===p&&f.add(u);if(f.size){const{name:p,value:u}=o??{};let i;switch(p?c?i=p.toLowerCase():i=p:u?c?i=u.toLowerCase():i=u:u===""&&(i=u),r){case"=":{typeof i=="string"&&f.has(i)&&(h=e);break}case"~=":{if(i&&typeof i=="string"){for(const l of f)if(new Set(l.split(/\s+/)).has(i)){h=e;break}}break}case"|=":{if(i&&typeof i=="string"){let l;for(const m of f)if(m===i||m.startsWith(`${i}-`)){l=m;break}l&&(h=e)}break}case"^=":{if(i&&typeof i=="string"){let l;for(const m of f)if(m.startsWith(`${i}`)){l=m;break}l&&(h=e)}break}case"$=":{if(i&&typeof i=="string"){let l;for(const m of f)if(m.endsWith(`${i}`)){l=m;break}l&&(h=e)}break}case"*=":{if(i&&typeof i=="string"){let l;for(const m of f)if(m.includes(`${i}`)){l=m;break}l&&(h=e)}break}case null:default:h=e}}}return h??null}_matchTypeSelector(t,e,n={}){const r=(0,b.unescapeSelector)(t.name),{localName:a,namespaceURI:o,prefix:w}=e,{forgive:h}=n;let{prefix:d,localName:c}=(0,b.parseAstName)(r,e);e.ownerDocument.contentType==="text/html"&&(d=d.toLowerCase(),c=c.toLowerCase());let g,f;a.indexOf(":")>-1?[g,f]=a.split(":"):(g=w||"",f=a);let p;switch(d){case"":{!g&&!o&&(c==="*"||c===f)&&(p=e);break}case"*":{(c==="*"||c===f)&&(p=e);break}default:{const u=e.lookupNamespaceURI(d),i=e.lookupNamespaceURI(g);if(u===i&&d===g)(c==="*"||c===f)&&(p=e);else if(!h&&!u){const l=`Undeclared namespace ${d}`;throw new DOMException(l,s.SYNTAX_ERR)}}}return p??null}_matchDirectionPseudoClass(t,e){const n=(0,y.getDirectionality)(e);let r;return t.name===n&&(r=e),r??null}_matchLanguagePseudoClass(t,e){if(t.name===s.EMPTY)return null;const n=(0,b.unescapeSelector)(t.name);typeof n=="string"&&n!==t.name&&(t.name=n);let r;if(n==="*")if(e.hasAttribute("lang"))e.getAttribute("lang")&&(r=e);else{let a=e.parentNode;for(;a&&a.nodeType===s.ELEMENT_NODE;){if(a.hasAttribute("lang")){a.getAttribute("lang")&&(r=e);break}a=a.parentNode}}else if(n&&s.REG_LANG.test(n)){let a;if(n.indexOf("-")>-1){const[o,w,...h]=n.split("-");let d;o==="*"?d=`${s.ALPHA_NUM}${s.LANG_PART}`:d=`${o}${s.LANG_PART}`;const c=`-${w}${s.LANG_PART}`,g=h.length;let f="";if(g)for(let p=0;p<g;p++)f+=`-${h[p]}${s.LANG_PART}`;a=new RegExp(`^${d}${c}${f}$`,"i")}else a=new RegExp(`^${n}${s.LANG_PART}$`,"i");if(e.hasAttribute("lang"))a.test(e.getAttribute("lang"))&&(r=e);else{let o=e.parentNode;for(;o&&o.nodeType===s.ELEMENT_NODE;){if(o.hasAttribute("lang")){const w=o.getAttribute("lang");a.test(w)&&(r=e);break}o=o.parentNode}}}return r??null}matchSelector(t,e,n){if(!t||!t.type){const o=`Unexpected node ${Object.prototype.toString.call(t).slice(s.TYPE_FROM,s.TYPE_TO)}`;throw new TypeError(o)}else if(!e||!e.nodeType){const o=`Unexpected node ${Object.prototype.toString.call(e).slice(s.TYPE_FROM,s.TYPE_TO)}`;throw new TypeError(o)}else if(e.nodeType!==s.ELEMENT_NODE){const a=`Unexpected node ${e.nodeName}`;throw new TypeError(a)}let r;switch(t.type){case s.SELECTOR_ATTR:{r=this._matchAttributeSelector(t,e);break}case s.SELECTOR_TYPE:{r=this._matchTypeSelector(t,e,n);break}default:{const{children:[a],name:o}=t;o==="dir"?r=this._matchDirectionPseudoClass(a,e):o==="lang"&&(r=this._matchLanguagePseudoClass(a,e))}}return r}}const N=new k;var R=N;0&&(module.exports={Matcher,matcher}); | ||
var T=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var A=(x,t)=>{for(var e in t)T(x,e,{get:t[e],enumerable:!0})},_=(x,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of S(t))!O.call(x,r)&&r!==e&&T(x,r,{get:()=>t[r],enumerable:!(n=L(t,r))||n.enumerable});return x};var R=x=>_(T({},"__esModule",{value:!0}),x);var C={};A(C,{Matcher:()=>k,default:()=>P,matcher:()=>N});module.exports=R(C);var y=require("./dom-util.js"),b=require("./parser.js"),s=require("./constant.js");class k{matchPseudoElementSelector(t,e={}){if(!t||typeof t!="string"){const o=`Unexpected type ${Object.prototype.toString.call(t).slice(s.TYPE_FROM,s.TYPE_TO)}`;throw new TypeError(o)}const{forgive:n,warn:r}=e;switch(t){case"after":case"backdrop":case"before":case"cue":case"cue-region":case"first-letter":case"first-line":case"file-selector-button":case"marker":case"placeholder":case"selection":case"target-text":{if(r){const a=`Unsupported pseudo-element ::${t}`;throw new DOMException(a,s.NOT_SUPPORTED_ERR)}break}case"part":case"slotted":{if(r){const a=`Unsupported pseudo-element ::${t}()`;throw new DOMException(a,s.NOT_SUPPORTED_ERR)}break}default:if(t.startsWith("-webkit-")){if(r){const a=`Unsupported pseudo-element ::${t}`;throw new DOMException(a,s.NOT_SUPPORTED_ERR)}}else if(!n){const a=`Unknown pseudo-element ::${t}`;throw new DOMException(a,s.SYNTAX_ERR)}}}_matchAttributeSelector(t,e){const{flags:n,matcher:r,name:a,value:o}=t;if(typeof n=="string"&&!/^[is]$/i.test(n)){const c=`Invalid selector ${(0,b.generateCSS)(t)}`;throw new DOMException(c,s.SYNTAX_ERR)}const{attributes:w}=e;let h;if(w&&w.length){const d=e.ownerDocument.contentType;let c;d==="text/html"?typeof n=="string"&&/^s$/i.test(n)?c=!1:c=!0:typeof n=="string"&&/^i$/i.test(n)?c=!0:c=!1;let g=(0,b.unescapeSelector)(a.name);c&&(g=g.toLowerCase());const f=new Set;if(g.indexOf("|")>-1){const{prefix:p,localName:u}=(0,b.parseAstName)(g);for(const i of w){let{name:l,value:m}=i;switch(c&&(l=l.toLowerCase(),m=m.toLowerCase()),p){case"":{u===l&&f.add(m);break}case"*":{l.indexOf(":")>-1?l.endsWith(`:${u}`)&&f.add(m):u===l&&f.add(m);break}default:if(l.indexOf(":")>-1){const[$,E]=l.split(":");if($==="xml"&&E==="lang")continue;p===$&&u===E&&(0,y.isNamespaceDeclared)(p,e)&&f.add(m)}}}}else for(let{name:p,value:u}of w)if(c&&(p=p.toLowerCase(),u=u.toLowerCase()),p.indexOf(":")>-1){const[i,l]=p.split(":");if(i==="xml"&&l==="lang")continue;g===l&&f.add(u)}else g===p&&f.add(u);if(f.size){const{name:p,value:u}=o??{};let i;switch(p?c?i=p.toLowerCase():i=p:u?c?i=u.toLowerCase():i=u:u===""&&(i=u),r){case"=":{typeof i=="string"&&f.has(i)&&(h=e);break}case"~=":{if(i&&typeof i=="string"){for(const l of f)if(new Set(l.split(/\s+/)).has(i)){h=e;break}}break}case"|=":{if(i&&typeof i=="string"){let l;for(const m of f)if(m===i||m.startsWith(`${i}-`)){l=m;break}l&&(h=e)}break}case"^=":{if(i&&typeof i=="string"){let l;for(const m of f)if(m.startsWith(`${i}`)){l=m;break}l&&(h=e)}break}case"$=":{if(i&&typeof i=="string"){let l;for(const m of f)if(m.endsWith(`${i}`)){l=m;break}l&&(h=e)}break}case"*=":{if(i&&typeof i=="string"){let l;for(const m of f)if(m.includes(`${i}`)){l=m;break}l&&(h=e)}break}case null:default:h=e}}}return h??null}_matchTypeSelector(t,e,n={}){const r=(0,b.unescapeSelector)(t.name),{localName:a,namespaceURI:o,prefix:w}=e,{forgive:h}=n;let{prefix:d,localName:c}=(0,b.parseAstName)(r,e);e.ownerDocument.contentType==="text/html"&&s.REG_TAG_NAME.test(a)&&(d=d.toLowerCase(),c=c.toLowerCase());let g,f;a.indexOf(":")>-1?[g,f]=a.split(":"):(g=w||"",f=a);let p;switch(d){case"":{!g&&!o&&(c==="*"||c===f)&&(p=e);break}case"*":{(c==="*"||c===f)&&(p=e);break}default:{const u=e.lookupNamespaceURI(d),i=e.lookupNamespaceURI(g);if(u===i&&d===g)(c==="*"||c===f)&&(p=e);else if(!h&&!u){const l=`Undeclared namespace ${d}`;throw new DOMException(l,s.SYNTAX_ERR)}}}return p??null}_matchDirectionPseudoClass(t,e){const n=(0,y.getDirectionality)(e);let r;return t.name===n&&(r=e),r??null}_matchLanguagePseudoClass(t,e){if(t.name===s.EMPTY)return null;const n=(0,b.unescapeSelector)(t.name);typeof n=="string"&&n!==t.name&&(t.name=n);let r;if(n==="*")if(e.hasAttribute("lang"))e.getAttribute("lang")&&(r=e);else{let a=e.parentNode;for(;a&&a.nodeType===s.ELEMENT_NODE;){if(a.hasAttribute("lang")){a.getAttribute("lang")&&(r=e);break}a=a.parentNode}}else if(n&&s.REG_LANG.test(n)){let a;if(n.indexOf("-")>-1){const[o,w,...h]=n.split("-");let d;o==="*"?d=`${s.ALPHA_NUM}${s.LANG_PART}`:d=`${o}${s.LANG_PART}`;const c=`-${w}${s.LANG_PART}`,g=h.length;let f="";if(g)for(let p=0;p<g;p++)f+=`-${h[p]}${s.LANG_PART}`;a=new RegExp(`^${d}${c}${f}$`,"i")}else a=new RegExp(`^${n}${s.LANG_PART}$`,"i");if(e.hasAttribute("lang"))a.test(e.getAttribute("lang"))&&(r=e);else{let o=e.parentNode;for(;o&&o.nodeType===s.ELEMENT_NODE;){if(o.hasAttribute("lang")){const w=o.getAttribute("lang");a.test(w)&&(r=e);break}o=o.parentNode}}}return r??null}matchSelector(t,e,n){if(!t||!t.type){const o=`Unexpected node ${Object.prototype.toString.call(t).slice(s.TYPE_FROM,s.TYPE_TO)}`;throw new TypeError(o)}else if(!e||!e.nodeType){const o=`Unexpected node ${Object.prototype.toString.call(e).slice(s.TYPE_FROM,s.TYPE_TO)}`;throw new TypeError(o)}else if(e.nodeType!==s.ELEMENT_NODE){const a=`Unexpected node ${e.nodeName}`;throw new TypeError(a)}let r;switch(t.type){case s.SELECTOR_ATTR:{r=this._matchAttributeSelector(t,e);break}case s.SELECTOR_TYPE:{r=this._matchTypeSelector(t,e,n);break}default:{const{children:[a],name:o}=t;o==="dir"?r=this._matchDirectionPseudoClass(a,e):o==="lang"&&(r=this._matchLanguagePseudoClass(a,e))}}return r}}const N=new k;var P=N;0&&(module.exports={Matcher,matcher}); | ||
//# sourceMappingURL=matcher.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 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}); | ||
var p=Object.create;var r=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty;var R=(t,s)=>{for(var e in s)r(t,e,{get:s[e],enumerable:!0})},O=(t,s,e,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of a(s))!o.call(t,f)&&f!==e&&r(t,f,{get:()=>s[f],enumerable:!(i=_(s,f))||i.enumerable});return t};var u=(t,s,e)=>(e=t!=null?p(l(t)):{},O(s||!t||!t.__esModule?r(e,"default",{value:t,enumerable:!0}):e,t)),L=t=>O(r({},"__esModule",{value:!0}),t);var x={};R(x,{filterSelector:()=>G,initNwsapi:()=>c});module.exports=L(x);var E=u(require("@asamuzakjp/nwsapi"),1),n=require("./constant.js");const c=(t,s)=>{if(!t||!t.DOMException){const f=`Unexpected global object ${Object.prototype.toString.call(t).slice(n.TYPE_FROM,n.TYPE_TO)}`;throw new TypeError(f)}s?.nodeType!==n.DOCUMENT_NODE&&(s=t.document);const e=(0,E.default)({document:s,DOMException:t.DOMException});return e.configure({LOGERRORS:!1}),e},G=(t,s={})=>{if(!t||typeof t!="string"||!n.REG_FILTER_CHAR.test(t))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(n.REG_LOGICAL_IS_NOT.test(t)){if(n.REG_LOGICAL_EMPTY.test(t))return!1;const{complex:i,descendant:f}=s;i&&f?e=n.REG_LOGICAL_COMPLEX:e=n.REG_LOGICAL_COMPOUND}else e=n.REG_FILTER_PSEUDO;if(e.test(t))return!1}return!0};0&&(module.exports={filterSelector,initNwsapi}); | ||
//# sourceMappingURL=nwsapi.js.map |
@@ -63,3 +63,3 @@ { | ||
}, | ||
"version": "5.0.7" | ||
"version": "5.0.8" | ||
} |
@@ -76,4 +76,2 @@ /** | ||
export const TAG_TYPE_I = '\\*|[A-Z][\\w-]*'; | ||
// LOGICAL_KEY: :has() and :where() are excluded | ||
export const LOGICAL_KEY = '(?:is|not)'; | ||
export const COMPOUND = `(?:${TAG_TYPE}|(?:${TAG_TYPE})?(?:${SUB_TYPE})+)`; | ||
@@ -93,12 +91,14 @@ export const COMBO = '\\s?[\\s>~+]\\s?'; | ||
export const COMPLEX_L = `${COMPOUND_B}(?:${COMBO}${COMPOUND_B})*`; | ||
export const KEY_IS_NOT = '(?:is|not)'; | ||
export const LOGICAL_COMPLEX = | ||
`${LOGICAL_KEY}\\(\\s*${COMPLEX_L}(?:\\s*,\\s*${COMPLEX_L})*\\s*\\)`; | ||
`${KEY_IS_NOT}\\(\\s*${COMPLEX_L}(?:\\s*,\\s*${COMPLEX_L})*\\s*\\)`; | ||
export const LOGICAL_COMPOUND = | ||
`${LOGICAL_KEY}\\(\\s*${COMPOUND_A}(?:\\s*,\\s*${COMPOUND_A})*\\s*\\)`; | ||
`${KEY_IS_NOT}\\(\\s*${COMPOUND_A}(?:\\s*,\\s*${COMPOUND_A})*\\s*\\)`; | ||
/* regexp */ | ||
export const REG_ANCHOR = /^a(?:rea)?$/; | ||
export const REG_CHILD_INDEXED = new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH})`); | ||
export const REG_COMPLEX = new RegExp(`${COMBO}${COMPOUND_I}`, 'i'); | ||
export const REG_DIR = /^(?:ltr|rtl)$/; | ||
export const REG_FILTER_CHAR = /[\w\s\-#$%&()*+,./:;<>=?@[\]^"'`]/; | ||
export const REG_FILTER_PSEUDO = new RegExp(`:(?!${PSEUDO_CLASSES}|${N_TH})`); | ||
export const REG_FORM = /^(?:button|fieldset|form|input|select|textarea)$/; | ||
@@ -118,3 +118,3 @@ export const REG_FORM_CTRL = | ||
export const REG_LOGICAL_EMPTY = /(:(is|where)\(\s*\))/; | ||
export const REG_LOGICAL_KEY = new RegExp(`:${LOGICAL_KEY}\\(`); | ||
export const REG_LOGICAL_IS_NOT = new RegExp(`:${KEY_IS_NOT}\\(`); | ||
export const REG_LOGICAL_PSEUDO = /^(?:has|is|not|where)$/; | ||
@@ -124,2 +124,3 @@ export const REG_SHADOW_HOST = /^host(?:-context)?$/; | ||
export const REG_SHADOW_PSEUDO = /^part|slotted$/; | ||
export const REG_TAG_NAME = /[A-Z][\\w-]*/i; | ||
export const REG_TYPE_CHECK = /^(?:checkbox|radio)$/; | ||
@@ -126,0 +127,0 @@ export const REG_TYPE_DATE = /^(?:date(?:time-local)?|month|time|week)$/; |
@@ -12,3 +12,3 @@ /** | ||
ALPHA_NUM, ELEMENT_NODE, EMPTY, LANG_PART, NOT_SUPPORTED_ERR, REG_LANG, | ||
SELECTOR_ATTR, SELECTOR_TYPE, SYNTAX_ERR, TYPE_FROM, TYPE_TO | ||
REG_TAG_NAME, SELECTOR_ATTR, SELECTOR_TYPE, SYNTAX_ERR, TYPE_FROM, TYPE_TO | ||
} from './constant.js'; | ||
@@ -301,3 +301,4 @@ | ||
} = parseAstName(astName, node); | ||
if (node.ownerDocument.contentType === 'text/html') { | ||
if (node.ownerDocument.contentType === 'text/html' && | ||
REG_TAG_NAME.test(localName)) { | ||
astPrefix = astPrefix.toLowerCase(); | ||
@@ -304,0 +305,0 @@ astLocalName = astLocalName.toLowerCase(); |
@@ -10,4 +10,4 @@ /** | ||
import { | ||
DOCUMENT_NODE, REG_CHILD_INDEXED, REG_LOGICAL_COMPLEX, REG_LOGICAL_COMPOUND, | ||
REG_LOGICAL_EMPTY, REG_LOGICAL_KEY, TYPE_FROM, TYPE_TO | ||
DOCUMENT_NODE, REG_LOGICAL_COMPLEX, REG_LOGICAL_COMPOUND, REG_FILTER_CHAR, | ||
REG_LOGICAL_EMPTY, REG_LOGICAL_IS_NOT, REG_FILTER_PSEUDO, TYPE_FROM, TYPE_TO | ||
} from './constant.js'; | ||
@@ -51,2 +51,6 @@ | ||
} | ||
// filter char | ||
if (!REG_FILTER_CHAR.test(selector)) { | ||
return false; | ||
} | ||
// filter missing close square bracket | ||
@@ -70,4 +74,4 @@ if (selector.includes('[')) { | ||
let reg; | ||
if (REG_LOGICAL_KEY.test(selector)) { | ||
// filter empty :is() and :where() | ||
if (REG_LOGICAL_IS_NOT.test(selector)) { | ||
// filter empty :is() | ||
if (REG_LOGICAL_EMPTY.test(selector)) { | ||
@@ -83,3 +87,3 @@ return false; | ||
} else { | ||
reg = REG_CHILD_INDEXED; | ||
reg = REG_FILTER_PSEUDO; | ||
} | ||
@@ -86,0 +90,0 @@ if (reg.test(selector)) { |
@@ -57,3 +57,2 @@ export const AN_PLUS_B: "AnPlusB"; | ||
export const TAG_TYPE_I: "\\*|[A-Z][\\w-]*"; | ||
export const LOGICAL_KEY: "(?:is|not)"; | ||
export const COMPOUND: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)"; | ||
@@ -68,8 +67,10 @@ export const COMBO: "\\s?[\\s>~+]\\s?"; | ||
export const COMPLEX_L: "(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\))+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\))+))*"; | ||
export const KEY_IS_NOT: "(?:is|not)"; | ||
export const LOGICAL_COMPLEX: "(?:is|not)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\))+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\))+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\))+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s?[\\s>~+]\\s?(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*)*\\s*\\))+))*)*\\s*\\)"; | ||
export const LOGICAL_COMPOUND: "(?:is|not)\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+|:is\\(\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+)(?:\\s*,\\s*(?:\\*|[A-Za-z][\\w-]*|(?:\\*|[A-Za-z][\\w-]*)?(?:\\[[^|\\]]+\\]|[#.:][\\w-]+)+))*\\s*\\))+))*\\s*\\)"; | ||
export const REG_ANCHOR: RegExp; | ||
export const REG_CHILD_INDEXED: RegExp; | ||
export const REG_COMPLEX: RegExp; | ||
export const REG_DIR: RegExp; | ||
export const REG_FILTER_CHAR: RegExp; | ||
export const REG_FILTER_PSEUDO: RegExp; | ||
export const REG_FORM: RegExp; | ||
@@ -86,3 +87,3 @@ export const REG_FORM_CTRL: RegExp; | ||
export const REG_LOGICAL_EMPTY: RegExp; | ||
export const REG_LOGICAL_KEY: RegExp; | ||
export const REG_LOGICAL_IS_NOT: RegExp; | ||
export const REG_LOGICAL_PSEUDO: RegExp; | ||
@@ -92,2 +93,3 @@ export const REG_SHADOW_HOST: RegExp; | ||
export const REG_SHADOW_PSEUDO: RegExp; | ||
export const REG_TAG_NAME: RegExp; | ||
export const REG_TYPE_CHECK: RegExp; | ||
@@ -94,0 +96,0 @@ export const REG_TYPE_DATE: RegExp; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is 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
439376
4922