@asamuzakjp/dom-selector 4.2.2 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -35,6 +35,7 @@ matches - same functionality as [Element.matches()][64]
35
35
  - `selector` **[string][59]** CSS selector
36
36
  - `node` **[object][60]** Element node
37
37
  - `opt` **[object][60]?** options
38
+ - `opt.event` **[object][60]?** instance of MouseEvent, KeyboardEvent
38
39
  - `opt.noexcept` **[boolean][61]?** no exception
39
40
  - `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class
40
41
 
@@ -50,6 +51,7 @@ closest - same functionality as [Element.closest()][65]
50
51
  - `selector` **[string][59]** CSS selector
51
52
  - `node` **[object][60]** Element node
52
53
  - `opt` **[object][60]?** options
54
+ - `opt.event` **[object][60]?** instance of MouseEvent, KeyboardEvent
53
55
  - `opt.noexcept` **[boolean][61]?** no exception
54
56
  - `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class
55
57
 
@@ -65,6 +67,7 @@ querySelector - same functionality as [Document.querySelector()][66], [DocumentF
65
67
  - `selector` **[string][59]** CSS selector
66
68
  - `node` **[object][60]** Document, DocumentFragment or Element node
67
69
  - `opt` **[object][60]?** options
70
+ - `opt.event` **[object][60]?** instance of MouseEvent, KeyboardEvent
68
71
  - `opt.noexcept` **[boolean][61]?** no exception
69
72
  - `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class
70
73
 
@@ -81,6 +84,7 @@ querySelectorAll - same functionality as [Document.querySelectorAll()][69], [Doc
81
84
  - `selector` **[string][59]** CSS selector
82
85
  - `node` **[object][60]** Document, DocumentFragment or Element node
83
86
  - `opt` **[object][60]?** options
87
+ - `opt.event` **[object][60]?** instance of MouseEvent, KeyboardEvent
84
88
  - `opt.noexcept` **[boolean][61]?** no exception
85
89
  - `opt.warn` **[boolean][61]?** console warn e.g. unsupported pseudo-class
86
90
 
@@ -125,11 +129,11 @@ Returns **[Array][62]<([object][60] \| [undefined][63])>** array of matched n
125
129
  |E:current(s)|Unsupported| |
126
130
  |E:past|Unsupported| |
127
131
  |E:future|Unsupported| |
128
- |E:active|Unsupported| |
129
- |E:hover|Unsupported| |
132
+ |E:active|✓|Enabled if a `mousedown` / `pointerdown` event is passed as an option.|
133
+ |E:hover|✓|Enabled if a `mouseover` / `pointerover` event is passed as an option.|
130
134
  |E:focus|✓| |
131
135
  |E:focus‑within|✓| |
132
- |E:focus‑visible|Unsupported| |
136
+ |E:focus‑visible|✓|Enabled if a `keydown` event is passed as an option.|
133
137
  |E:open<br>E:closed|Partially supported|Matching with &lt;select&gt;, e.g. `select:open`, is not supported.|
134
138
  |E:enabled<br>E:disabled|✓| |
135
139
  |E:read&#8209;write<br>E:read&#8209;only|✓| |
@@ -160,6 +164,7 @@ Returns **[Array][62]&lt;([object][60] \| [undefined][63])>** array of matched n
160
164
  |F \|\| E|Unsupported| |
161
165
  |E:nth&#8209;col(n)|Unsupported| |
162
166
  |E:nth&#8209;last&#8209;col(n)|Unsupported| |
167
+ |E:popover-open|✓| |
163
168
  |E:host|✓| |
164
169
  |E:host(s)|✓| |
165
170
  |E:host&#8209;context(s)|✓| |
@@ -252,45 +257,45 @@ See [benchmark](https://github.com/asamuzaK/domSelector/actions/workflows/benchm
252
257
 
253
258
  ### matches()
254
259
 
255
- |Selector|jsdom v24.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
260
+ |Selector|jsdom v24.1.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
256
261
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
257
- |simple selector:<br>`matches('.content')`|993,434 ops/sec ±0.92%|7,738 ops/sec ±0.82%|9,388 ops/sec ±0.63%|934,402 ops/sec ±1.24%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
258
- |compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|593,746 ops/sec ±0.24%|7,510 ops/sec ±0.73%|9,048 ops/sec ±1.11%|510,470 ops/sec ±0.17%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
259
- |compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|7,532 ops/sec ±0.64%|F|148,751 ops/sec ±1.43%|patched-jsdom is the fastest.|
260
- |compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|478,481 ops/sec ±0.32%|7,437 ops/sec ±0.57%|8,922 ops/sec ±0.47%|406,300 ops/sec ±0.32%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
261
- |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|151,608 ops/sec ±0.24%|F|5,749 ops/sec ±0.57%|136,036 ops/sec ±0.46%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
262
- |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|F|F|5,654 ops/sec ±0.57%|40,774 ops/sec ±0.59%|patched-jsdom is the fastest.|
263
- |complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|F|F|6,243 ops/sec ±0.45%|146,879 ops/sec ±1.92%|patched-jsdom is the fastest.|
262
+ |simple selector:<br>`matches('.content')`|989,361 ops/sec ±0.27%|7,447 ops/sec ±1.10%|9,037 ops/sec ±1.74%|947,094 ops/sec ±0.24%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
263
+ |compound selector:<br>`matches('p.content[id]:is(:last-child, :only-child)')`|581,187 ops/sec ±0.21%|7,137 ops/sec ±0.82%|8,808 ops/sec ±1.24%|492,756 ops/sec ±0.25%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
264
+ |compound selector:<br>`matches('p.content[id]:is(:invalid-nth-child, :only-child)')`|F|7,144 ops/sec ±0.51%|F|145,203 ops/sec ±0.94%|patched-jsdom is the fastest.|
265
+ |compound selector:<br>`matches('p.content[id]:not(:is(.foo, .bar))')`|472,261 ops/sec ±1.64%|7,199 ops/sec ±0.58%|8,612 ops/sec ±0.51%|403,920 ops/sec ±0.29%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
266
+ |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|152,011 ops/sec ±0.66%|F|5,737 ops/sec ±0.43%|135,540 ops/sec ±0.41%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
267
+ |complex selector:<br>`matches('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|F|F|5,767 ops/sec ±0.47%|39,996 ops/sec ±0.79%|patched-jsdom is the fastest.|
268
+ |complex selector within logical pseudo-class:<br>`matches(':is(.box > .content, .block > .content)')`|416,215 ops/sec ±0.49%|F|6,105 ops/sec ±0.29%|358,945 ops/sec ±0.29%|jsdom is the fastest and 1.2 times faster than patched-jsdom.|
264
269
 
265
270
  ### closest()
266
271
 
267
- |Selector|jsdom v24.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
272
+ |Selector|jsdom v24.1.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
268
273
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
269
- |simple selector:<br>`closest('.container')`|362,505 ops/sec ±0.41%|7,607 ops/sec ±0.62%|9,365 ops/sec ±0.59%|362,275 ops/sec ±0.39%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
270
- |compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|137,678 ops/sec ±0.32%|F|8,749 ops/sec ±0.67%|129,174 ops/sec ±0.30%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
271
- |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|139,504 ops/sec ±0.43%|F|5,774 ops/sec ±0.51%|126,287 ops/sec ±0.32%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
272
- |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|F|F|5,710 ops/sec ±0.36%|29,552 ops/sec ±0.90%|patched-jsdom is the fastest.|
273
- |complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|F|4,754 ops/sec ±0.73%|5,935 ops/sec ±0.32%|64,421 ops/sec ±0.98%|patched-jsdom is the fastest.|
274
+ |simple selector:<br>`closest('.container')`|367,877 ops/sec ±1.14%|7,218 ops/sec ±0.76%|9,181 ops/sec ±0.64%|356,762 ops/sec ±1.02%|jsdom is the fastest and 1.0 times faster than patched-jsdom.|
275
+ |compound selector:<br>`closest('div.container[id]:not(.foo, .box)')`|134,650 ops/sec ±0.32%|F|8,549 ops/sec ±0.62%|125,888 ops/sec ±3.16%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
276
+ |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|134,654 ops/sec ±2.02%|F|5,751 ops/sec ±1.01%|119,709 ops/sec ±2.00%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
277
+ |complex selector:<br>`closest('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|F|F|5,596 ops/sec ±0.81%|28,732 ops/sec ±1.13%|patched-jsdom is the fastest.|
278
+ |complex selector within logical pseudo-class:<br>`closest(':is(.container > .content, .container > .box)')`|192,885 ops/sec ±1.15%|4,685 ops/sec ±1.30%|5,927 ops/sec ±0.64%|181,927 ops/sec ±1.39%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
274
279
 
275
280
  ### querySelector()
276
281
 
277
- |Selector|jsdom v24.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
282
+ |Selector|jsdom v24.1.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
278
283
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
279
- |simple selector:<br>`querySelector('.content')`|28,406 ops/sec ±0.62%|9,286 ops/sec ±0.63%|10,750 ops/sec ±0.59%|25,303 ops/sec ±1.00%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
280
- |compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|9,564 ops/sec ±0.33%|8,884 ops/sec ±0.59%|10,834 ops/sec ±0.60%|8,809 ops/sec ±0.53%|linkedom is the fastest and 1.2 times faster than patched-jsdom. jsdom is 1.1 times faster than patched-jsdom.|
281
- |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|228 ops/sec ±0.41%|F|1,390 ops/sec ±0.61%|713 ops/sec ±2.32%|linkedom is the fastest and 1.9 times faster than patched-jsdom. patched-jsdom is 3.1 times faster than jsdom.|
282
- |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|F|F|1,523 ops/sec ±1.72%|494 ops/sec ±1.97%|linkedom is the fastest and 3.1 times faster than patched-jsdom.|
283
- |complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|F|F|9,987 ops/sec ±0.59%|101,461 ops/sec ±1.56%|patched-jsdom is the fastest.|
284
+ |simple selector:<br>`querySelector('.content')`|27,400 ops/sec ±0.96%|9,042 ops/sec ±1.19%|10,550 ops/sec ±0.69%|25,885 ops/sec ±1.48%|jsdom is the fastest and 1.1 times faster than patched-jsdom.|
285
+ |compound selector:<br>`querySelector('p.content[id]:is(:last-child, :only-child)')`|8,685 ops/sec ±1.47%|8,723 ops/sec ±1.20%|9,836 ops/sec ±0.69%|8,418 ops/sec ±1.41%|linkedom is the fastest and 1.2 times faster than patched-jsdom. jsdom is 1.0 times faster than patched-jsdom.|
286
+ |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|206 ops/sec ±1.48%|F|1,289 ops/sec ±0.42%|709 ops/sec ±1.75%|linkedom is the fastest and 1.8 times faster than patched-jsdom. patched-jsdom is 3.4 times faster than jsdom.|
287
+ |complex selector:<br>`querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|F|F|1,598 ops/sec ±0.35%|476 ops/sec ±1.94%|linkedom is the fastest and 3.4 times faster than patched-jsdom.|
288
+ |complex selector within logical pseudo-class:<br>`querySelector(':is(.box > .content, .block > .content)')`|2,921 ops/sec ±1.78%|F|9,782 ops/sec ±0.52%|97,513 ops/sec ±1.46%|patched-jsdom is the fastest. patched-jsdom is 33.4 times faster than jsdom.|
284
289
 
285
290
  ### querySelectorAll()
286
291
 
287
- |Selector|jsdom v24.0.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
292
+ |Selector|jsdom v24.1.0 (nwsapi)|happy-dom|linkeDom|patched-jsdom (dom-selector)|Result|
288
293
  |:-----------|:-----------|:-----------|:-----------|:-----------|:-----------|
289
- |simple selector:<br>`querySelectorAll('.content')`|2,713 ops/sec ±1.04%|729 ops/sec ±0.29%|1,187 ops/sec ±0.40%|2,988 ops/sec ±0.19%|patched-jsdom is the fastest. patched-jsdom is 1.1 times faster than jsdom.|
290
- |compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|946 ops/sec ±0.26%|724 ops/sec ±0.35%|1,194 ops/sec ±0.25%|971 ops/sec ±0.25%|linkedom is the fastest and 1.2 times faster than patched-jsdom. patched-jsdom is 1.0 times faster than jsdom.|
291
- |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|225 ops/sec ±1.41%|F|416 ops/sec ±1.46%|818 ops/sec ±1.67%|patched-jsdom is the fastest. patched-jsdom is 3.6 times faster than jsdom.|
292
- |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|F|F|443 ops/sec ±1.47%|530 ops/sec ±1.87%|patched-jsdom is the fastest.|
293
- |complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|F|F|525 ops/sec ±0.27%|255 ops/sec ±1.13%|linkedom is the fastest and 2.1 times faster than patched-jsdom.|
294
+ |simple selector:<br>`querySelectorAll('.content')`|2,549 ops/sec ±0.55%|729 ops/sec ±0.48%|1,188 ops/sec ±1.57%|3,153 ops/sec ±0.95%|patched-jsdom is the fastest. patched-jsdom is 1.2 times faster than jsdom.|
295
+ |compound selector:<br>`querySelectorAll('p.content[id]:is(:last-child, :only-child)')`|880 ops/sec ±1.32%|706 ops/sec ±1.55%|1,156 ops/sec ±0.93%|938 ops/sec ±1.27%|linkedom is the fastest and 1.2 times faster than patched-jsdom. patched-jsdom is 1.1 times faster than jsdom.|
296
+ |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box[id] .block.inner > .content')`|196 ops/sec ±0.73%|F|414 ops/sec ±0.24%|797 ops/sec ±1.66%|patched-jsdom is the fastest. patched-jsdom is 4.1 times faster than jsdom.|
297
+ |complex selector:<br>`querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')`|F|F|451 ops/sec ±0.36%|504 ops/sec ±1.88%|patched-jsdom is the fastest.|
298
+ |complex selector within logical pseudo-class:<br>`querySelectorAll(':is(.box > .content, .block > .content)')`|273 ops/sec ±0.89%|F|498 ops/sec ±1.38%|236 ops/sec ±2.36%|linkedom is the fastest and 2.1 times faster than patched-jsdom. jsdom is 1.2 times faster than patched-jsdom.|
294
299
 
295
300
 
296
301
  ## Acknowledgments
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var _=(o,t)=>{for(var r in t)E(o,r,{get:t[r],enumerable:!0})},T=(o,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of c(t))!n.call(o,e)&&e!==r&&E(o,e,{get:()=>t[e],enumerable:!(s=x(t,e))||s.enumerable});return o};var p=o=>T(E({},"__esModule",{value:!0}),o);var st={};_(st,{ALPHA_NUM:()=>O,AN_PLUS_B:()=>S,BIT_01:()=>Y,BIT_02:()=>a,BIT_04:()=>d,BIT_08:()=>i,BIT_16:()=>u,BIT_32:()=>h,BIT_FFFF:()=>$,BIT_HYPHEN:()=>X,COMBINATOR:()=>N,DOCUMENT_FRAGMENT_NODE:()=>j,DOCUMENT_NODE:()=>Z,DOCUMENT_POSITION_CONTAINED_BY:()=>v,DOCUMENT_POSITION_CONTAINS:()=>q,DOCUMENT_POSITION_PRECEDING:()=>k,DUO:()=>b,ELEMENT_NODE:()=>g,EMPTY:()=>R,HEX:()=>m,IDENTIFIER:()=>D,NOT_SUPPORTED_ERR:()=>I,NTH:()=>C,RAW:()=>L,REG_LOGICAL_PSEUDO:()=>ot,REG_SHADOW_HOST:()=>et,REG_SHADOW_MODE:()=>rt,REG_SHADOW_PSEUDO:()=>Et,SELECTOR:()=>A,SELECTOR_ATTR:()=>P,SELECTOR_CLASS:()=>F,SELECTOR_ID:()=>M,SELECTOR_LIST:()=>U,SELECTOR_PSEUDO_CLASS:()=>l,SELECTOR_PSEUDO_ELEMENT:()=>H,SELECTOR_TYPE:()=>B,SHOW_ALL:()=>z,SHOW_DOCUMENT:()=>J,SHOW_DOCUMENT_FRAGMENT:()=>Q,SHOW_ELEMENT:()=>V,STRING:()=>f,SYNTAX_ERR:()=>G,TEXT_NODE:()=>K,TYPE_FROM:()=>w,TYPE_TO:()=>y,U_FFFD:()=>W,WALKER_FILTER:()=>tt});module.exports=p(st);const O="[A-Z\\d]+",S="AnPlusB",N="Combinator",R="__EMPTY__",D="Identifier",I="NotSupportedError",C="Nth",L="Raw",A="Selector",P="AttributeSelector",F="ClassSelector",M="IdSelector",U="SelectorList",l="PseudoClassSelector",H="PseudoElementSelector",B="TypeSelector",f="String",G="SyntaxError",W="\uFFFD",Y=1,a=2,d=4,i=8,u=16,h=32,$=65535,X=45,b=2,m=16,w=8,y=-1,g=1,K=3,Z=9,j=11,k=2,q=8,v=16,z=4294967295,J=256,Q=1024,V=1,tt=1281,ot=/^(?:(?:ha|i)s|not|where)$/,et=/^host(?:-context)?$/,rt=/^(?:close|open)$/,Et=/^part|slotted$/;0&&(module.exports={ALPHA_NUM,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,COMBINATOR,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,NOT_SUPPORTED_ERR,NTH,RAW,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,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,SYNTAX_ERR,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER});
1
+ var E=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var _=(o,t)=>{for(var r in t)E(o,r,{get:t[r],enumerable:!0})},T=(o,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of c(t))!n.call(o,e)&&e!==r&&E(o,e,{get:()=>t[e],enumerable:!(s=x(t,e))||s.enumerable});return o};var p=o=>T(E({},"__esModule",{value:!0}),o);var st={};_(st,{ALPHA_NUM:()=>O,AN_PLUS_B:()=>S,BIT_01:()=>Y,BIT_02:()=>a,BIT_04:()=>d,BIT_08:()=>i,BIT_16:()=>u,BIT_32:()=>h,BIT_FFFF:()=>$,BIT_HYPHEN:()=>X,COMBINATOR:()=>N,DOCUMENT_FRAGMENT_NODE:()=>j,DOCUMENT_NODE:()=>Z,DOCUMENT_POSITION_CONTAINED_BY:()=>v,DOCUMENT_POSITION_CONTAINS:()=>q,DOCUMENT_POSITION_PRECEDING:()=>k,DUO:()=>b,ELEMENT_NODE:()=>g,EMPTY:()=>R,HEX:()=>m,IDENTIFIER:()=>D,NOT_SUPPORTED_ERR:()=>I,NTH:()=>C,RAW:()=>L,REG_LOGICAL_PSEUDO:()=>ot,REG_SHADOW_HOST:()=>et,REG_SHADOW_MODE:()=>rt,REG_SHADOW_PSEUDO:()=>Et,SELECTOR:()=>A,SELECTOR_ATTR:()=>P,SELECTOR_CLASS:()=>F,SELECTOR_ID:()=>M,SELECTOR_LIST:()=>U,SELECTOR_PSEUDO_CLASS:()=>l,SELECTOR_PSEUDO_ELEMENT:()=>H,SELECTOR_TYPE:()=>B,SHOW_ALL:()=>z,SHOW_DOCUMENT:()=>J,SHOW_DOCUMENT_FRAGMENT:()=>Q,SHOW_ELEMENT:()=>V,STRING:()=>f,SYNTAX_ERR:()=>G,TEXT_NODE:()=>K,TYPE_FROM:()=>w,TYPE_TO:()=>y,U_FFFD:()=>W,WALKER_FILTER:()=>tt});module.exports=p(st);const O="[A-Z\\d]+",S="AnPlusB",N="Combinator",R="__EMPTY__",D="Identifier",I="NotSupportedError",C="Nth",L="Raw",A="Selector",P="AttributeSelector",F="ClassSelector",M="IdSelector",U="SelectorList",l="PseudoClassSelector",H="PseudoElementSelector",B="TypeSelector",f="String",G="SyntaxError",W="\uFFFD",Y=1,a=2,d=4,i=8,u=16,h=32,$=65535,X=45,b=2,m=16,w=8,y=-1,g=1,K=3,Z=9,j=11,k=2,q=8,v=16,z=4294967295,J=256,Q=1024,V=1,tt=1281,ot=/^(?:has|is|not|where)$/,et=/^host(?:-context)?$/,rt=/^(?:close|open)$/,Et=/^part|slotted$/;0&&(module.exports={ALPHA_NUM,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_FFFF,BIT_HYPHEN,COMBINATOR,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,EMPTY,HEX,IDENTIFIER,NOT_SUPPORTED_ERR,NTH,RAW,REG_LOGICAL_PSEUDO,REG_SHADOW_HOST,REG_SHADOW_MODE,REG_SHADOW_PSEUDO,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,SYNTAX_ERR,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD,WALKER_FILTER});
2
2
  //# sourceMappingURL=constant.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/js/constant.js"],
4
- "sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const ALPHA_NUM = '[A-Z\\\\d]+';\nexport const AN_PLUS_B = 'AnPlusB';\nexport const COMBINATOR = 'Combinator';\nexport const EMPTY = '__EMPTY__';\nexport const IDENTIFIER = 'Identifier';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const RAW = 'Raw';\nexport const SELECTOR = 'Selector';\nexport const SELECTOR_ATTR = 'AttributeSelector';\nexport const SELECTOR_CLASS = 'ClassSelector';\nexport const SELECTOR_ID = 'IdSelector';\nexport const SELECTOR_LIST = 'SelectorList';\nexport const SELECTOR_PSEUDO_CLASS = 'PseudoClassSelector';\nexport const SELECTOR_PSEUDO_ELEMENT = 'PseudoElementSelector';\nexport const SELECTOR_TYPE = 'TypeSelector';\nexport const STRING = 'String';\nexport const SYNTAX_ERR = 'SyntaxError';\nexport const U_FFFD = '\\uFFFD';\n\n/* numeric */\nexport const BIT_01 = 1;\nexport const BIT_02 = 2;\nexport const BIT_04 = 4;\nexport const BIT_08 = 8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const BIT_FFFF = 0xFFFF;\nexport const BIT_HYPHEN = 0x2D;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const TYPE_FROM = 8;\nexport const TYPE_TO = -1;\n\n/* Node */\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\nexport const DOCUMENT_POSITION_PRECEDING = 2;\nexport const DOCUMENT_POSITION_CONTAINS = 8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ALL = 0xffffffff;\nexport const SHOW_DOCUMENT = 0x100;\nexport const SHOW_DOCUMENT_FRAGMENT = 0x400;\nexport const SHOW_ELEMENT = 1;\nexport const WALKER_FILTER = 0x501;\n\n/* regexp */\nexport const REG_LOGICAL_PSEUDO = /^(?:(?:ha|i)s|not|where)$/;\nexport const REG_SHADOW_HOST = /^host(?:-context)?$/;\nexport const REG_SHADOW_MODE = /^(?:close|open)$/;\nexport const REG_SHADOW_PSEUDO = /^part|slotted$/;\n"],
5
- "mappings": "4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,cAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,aAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,2BAAAC,EAAA,kBAAAC,EAAA,mCAAAC,EAAA,+BAAAC,EAAA,gCAAAC,EAAA,QAAAC,EAAA,iBAAAC,EAAA,UAAAC,EAAA,QAAAC,EAAA,eAAAC,EAAA,sBAAAC,EAAA,QAAAC,EAAA,QAAAC,EAAA,uBAAAC,GAAA,oBAAAC,GAAA,oBAAAC,GAAA,sBAAAC,GAAA,aAAAC,EAAA,kBAAAC,EAAA,mBAAAC,EAAA,gBAAAC,EAAA,kBAAAC,EAAA,0BAAAC,EAAA,4BAAAC,EAAA,kBAAAC,EAAA,aAAAC,EAAA,kBAAAC,EAAA,2BAAAC,EAAA,iBAAAC,EAAA,WAAAC,EAAA,eAAAC,EAAA,cAAAC,EAAA,cAAAC,EAAA,YAAAC,EAAA,WAAAC,EAAA,kBAAAC,KAAA,eAAAC,EAAAjD,IAKO,MAAME,EAAY,YACZC,EAAY,UACZS,EAAa,aACbQ,EAAQ,YACRE,EAAa,aACbC,EAAoB,oBACpBC,EAAM,MACNC,EAAM,MACNK,EAAW,WACXC,EAAgB,oBAChBC,EAAiB,gBACjBC,EAAc,aACdC,EAAgB,eAChBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAgB,eAChBK,EAAS,SACTC,EAAa,cACbI,EAAS,SAGT3C,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAS,GACTC,EAAS,GACTC,EAAW,MACXC,EAAa,GACbO,EAAM,EACNG,EAAM,GACNwB,EAAY,EACZC,EAAU,GAGV3B,EAAe,EACfyB,EAAY,EACZ9B,EAAgB,EAChBD,EAAyB,GACzBI,EAA8B,EAC9BD,EAA6B,EAC7BD,EAAiC,GAGjCuB,EAAW,WACXC,EAAgB,IAChBC,EAAyB,KACzBC,EAAe,EACfO,GAAgB,KAGhBtB,GAAqB,4BACrBC,GAAkB,sBAClBC,GAAkB,mBAClBC,GAAoB",
4
+ "sourcesContent": ["/**\n * constant.js\n */\n\n/* string */\nexport const ALPHA_NUM = '[A-Z\\\\d]+';\nexport const AN_PLUS_B = 'AnPlusB';\nexport const COMBINATOR = 'Combinator';\nexport const EMPTY = '__EMPTY__';\nexport const IDENTIFIER = 'Identifier';\nexport const NOT_SUPPORTED_ERR = 'NotSupportedError';\nexport const NTH = 'Nth';\nexport const RAW = 'Raw';\nexport const SELECTOR = 'Selector';\nexport const SELECTOR_ATTR = 'AttributeSelector';\nexport const SELECTOR_CLASS = 'ClassSelector';\nexport const SELECTOR_ID = 'IdSelector';\nexport const SELECTOR_LIST = 'SelectorList';\nexport const SELECTOR_PSEUDO_CLASS = 'PseudoClassSelector';\nexport const SELECTOR_PSEUDO_ELEMENT = 'PseudoElementSelector';\nexport const SELECTOR_TYPE = 'TypeSelector';\nexport const STRING = 'String';\nexport const SYNTAX_ERR = 'SyntaxError';\nexport const U_FFFD = '\\uFFFD';\n\n/* numeric */\nexport const BIT_01 = 1;\nexport const BIT_02 = 2;\nexport const BIT_04 = 4;\nexport const BIT_08 = 8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const BIT_FFFF = 0xFFFF;\nexport const BIT_HYPHEN = 0x2D;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const TYPE_FROM = 8;\nexport const TYPE_TO = -1;\n\n/* Node */\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 3;\nexport const DOCUMENT_NODE = 9;\nexport const DOCUMENT_FRAGMENT_NODE = 11;\nexport const DOCUMENT_POSITION_PRECEDING = 2;\nexport const DOCUMENT_POSITION_CONTAINS = 8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ALL = 0xffffffff;\nexport const SHOW_DOCUMENT = 0x100;\nexport const SHOW_DOCUMENT_FRAGMENT = 0x400;\nexport const SHOW_ELEMENT = 1;\nexport const WALKER_FILTER = 0x501;\n\n/* regexp */\nexport const REG_LOGICAL_PSEUDO = /^(?:has|is|not|where)$/;\nexport const REG_SHADOW_HOST = /^host(?:-context)?$/;\nexport const REG_SHADOW_MODE = /^(?:close|open)$/;\nexport const REG_SHADOW_PSEUDO = /^part|slotted$/;\n"],
5
+ "mappings": "4ZAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,eAAAE,EAAA,cAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,aAAAC,EAAA,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N_PLUS_B", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_FFFF", "BIT_HYPHEN", "COMBINATOR", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "EMPTY", "HEX", "IDENTIFIER", "NOT_SUPPORTED_ERR", "NTH", "RAW", "REG_LOGICAL_PSEUDO", "REG_SHADOW_HOST", "REG_SHADOW_MODE", "REG_SHADOW_PSEUDO", "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", "SYNTAX_ERR", "TEXT_NODE", "TYPE_FROM", "TYPE_TO", "U_FFFD", "WALKER_FILTER", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var k=Object.create;var p=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},x=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of C(t))!I.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(s=w(t,o))||s.enumerable});return e};var M=(e,t,r)=>(r=e!=null?k(_(e)):{},x(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>x(p({},"__esModule",{value:!0}),e);var S={};v(S,{getDirectionality:()=>m,getNamespaceURI:()=>D,getSlottedTextContent:()=>f,isContentEditable:()=>h,isInShadowTree:()=>g,isNamespaceDeclared:()=>$,isPreceding:()=>O,resolveContent:()=>U,sortNodes:()=>P,verifyNode:()=>d});module.exports=R(S);var E=M(require("bidi-js"),1),i=require("./constant.js");const d=e=>{if(!e||!e.nodeType||!e.nodeName){const r=`Unexpected type ${Object.prototype.toString.call(e).slice(i.TYPE_FROM,i.TYPE_TO)}`;throw new TypeError(r)}else if(!(e.nodeType===i.DOCUMENT_NODE||e.nodeType===i.DOCUMENT_FRAGMENT_NODE||e.nodeType===i.ELEMENT_NODE)){const t=`Unexpected node ${e.nodeName}`;throw new TypeError(t)}return e},U=e=>{e=d(e);let t,r;switch(e.nodeType){case i.DOCUMENT_NODE:{t=e,r=e;break}case i.DOCUMENT_FRAGMENT_NODE:{t=e.ownerDocument,r=e;break}case i.ELEMENT_NODE:default:{t=e.ownerDocument;let o=e;for(;o&&o.parentNode;)o=o.parentNode;r=o;break}}const s=t.createTreeWalker(r,i.WALKER_FILTER);return[t,r,s]},g=(e={})=>{let t;if(e.nodeType===i.ELEMENT_NODE||e.nodeType===i.DOCUMENT_FRAGMENT_NODE){let r=e;for(;r;){const{host:s,mode:o,nodeType:a,parentNode:c}=r;if(s&&o&&a===i.DOCUMENT_FRAGMENT_NODE&&i.REG_SHADOW_MODE.test(o)){t=!0;break}r=c}}return!!t},f=(e={})=>{let t;if(e.localName==="slot"&&g(e)){const r=e.assignedNodes();if(r.length){for(const s of r)if(t=s.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},m=(e={})=>{let t;if(e.nodeType===i.ELEMENT_NODE){const{dir:r,localName:s,parentNode:o}=e,{getEmbeddingLevels:a}=(0,E.default)(),c=/^(?:ltr|rtl)$/;if(c.test(r))t=r;else if(r==="auto"){let l;switch(s){case"input":{!e.type||/^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/.test(e.type)?l=e.value:/^(?:(?:ima|ran)ge|(?:dat|tim)e|c(?:olor|heckbox)|number|radio)$/.test(e.type)&&(t="ltr");break}case"slot":{l=f(e);break}case"textarea":{l=e.value;break}default:{const n=[].slice.call(e.childNodes);for(const u of n){const{dir:T,localName:N,nodeType:y,textContent:b}=u;if(y===i.TEXT_NODE?l=b.trim():y===i.ELEMENT_NODE&&!/^(?:bdi|s(?:cript|tyle)|textarea)$/.test(N)&&(!T||!c.test(T))&&(N==="slot"?l=f(u):l=b.trim()),l)break}}}if(l){const{paragraphs:[{level:n}]}=a(l);n%2===1?t="rtl":t="ltr"}if(!t)if(o){const{nodeType:n}=o;n===i.ELEMENT_NODE?t=m(o):(n===i.DOCUMENT_NODE||n===i.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}else t="ltr"}else if(s==="bdi"){const l=e.textContent.trim();if(l){const{paragraphs:[{level:n}]}=a(l);n%2===1?t="rtl":t="ltr"}t||o||(t="ltr")}else if(s==="input"&&e.type==="tel")t="ltr";else if(o){if(s==="slot"){const l=f(e);if(l){const{paragraphs:[{level:n}]}=a(l);n%2===1?t="rtl":t="ltr"}}if(!t){const{nodeType:l}=o;l===i.ELEMENT_NODE?t=m(o):(l===i.DOCUMENT_NODE||l===i.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}}else t="ltr"}return t??null},h=(e={})=>{let t;if(e.nodeType===i.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const r=e.getAttribute("contenteditable");if(r===""||/^(?:plaintext-only|true)$/.test(r))t=!0;else if(r==="inherit"){let s=e.parentNode;for(;s;){if(h(s)){t=!0;break}s=s.parentNode}}}}return!!t},D=(e,t)=>{let r;if(e&&typeof e=="string"&&t?.nodeType===i.ELEMENT_NODE){const{attributes:s}=t;for(const o of s){const{name:a,namespaceURI:c,prefix:l,value:n}=o;if(a===`xmlns:${e}`){r=n;break}else if(l===e){r=c;break}}}return r??null},$=(e="",t={})=>{let r;if(e&&typeof e=="string"&&t.nodeType===i.ELEMENT_NODE&&(r=t.lookupNamespaceURI(e),!r)){const s=t.ownerDocument.documentElement;let o=t;for(;o&&(r=D(e,o),!(r||o===s));)o=o.parentNode}return!!r},O=(e={},t={})=>{let r;if(e.nodeType===i.ELEMENT_NODE&&t.nodeType===i.ELEMENT_NODE){const s=t.compareDocumentPosition(e);r=s&i.DOCUMENT_POSITION_PRECEDING||s&i.DOCUMENT_POSITION_CONTAINS}return!!r},P=(e=[])=>{const t=[...e];return t.length>1&&t.sort((r,s)=>{let o;return O(s,r)?o=1:o=-1,o}),t};0&&(module.exports={getDirectionality,getNamespaceURI,getSlottedTextContent,isContentEditable,isInShadowTree,isNamespaceDeclared,isPreceding,resolveContent,sortNodes,verifyNode});
1
+ var k=Object.create;var p=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},x=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of C(t))!I.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(s=w(t,o))||s.enumerable});return e};var M=(e,t,r)=>(r=e!=null?k(_(e)):{},x(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>x(p({},"__esModule",{value:!0}),e);var S={};v(S,{getDirectionality:()=>m,getNamespaceURI:()=>D,getSlottedTextContent:()=>f,isContentEditable:()=>h,isInShadowTree:()=>g,isNamespaceDeclared:()=>$,isPreceding:()=>O,resolveContent:()=>U,sortNodes:()=>P,verifyNode:()=>d});module.exports=R(S);var E=M(require("bidi-js"),1),i=require("./constant.js");const d=e=>{if(!e||!e.nodeType||!e.nodeName){const r=`Unexpected type ${Object.prototype.toString.call(e).slice(i.TYPE_FROM,i.TYPE_TO)}`;throw new TypeError(r)}else if(!(e.nodeType===i.DOCUMENT_NODE||e.nodeType===i.DOCUMENT_FRAGMENT_NODE||e.nodeType===i.ELEMENT_NODE)){const t=`Unexpected node ${e.nodeName}`;throw new TypeError(t)}return e},U=e=>{e=d(e);let t,r;switch(e.nodeType){case i.DOCUMENT_NODE:{t=e,r=e;break}case i.DOCUMENT_FRAGMENT_NODE:{t=e.ownerDocument,r=e;break}case i.ELEMENT_NODE:default:{t=e.ownerDocument;let o=e;for(;o&&o.parentNode;)o=o.parentNode;r=o;break}}const s=t.createTreeWalker(r,i.WALKER_FILTER);return[t,r,s]},g=(e={})=>{let t;if(e.nodeType===i.ELEMENT_NODE||e.nodeType===i.DOCUMENT_FRAGMENT_NODE){let r=e;for(;r;){const{host:s,mode:o,nodeType:a,parentNode:c}=r;if(s&&o&&a===i.DOCUMENT_FRAGMENT_NODE&&i.REG_SHADOW_MODE.test(o)){t=!0;break}r=c}}return!!t},f=(e={})=>{let t;if(e.localName==="slot"&&g(e)){const r=e.assignedNodes();if(r.length){for(const s of r)if(t=s.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},m=(e={})=>{let t;if(e.nodeType===i.ELEMENT_NODE){const{dir:r,localName:s,parentNode:o}=e,{getEmbeddingLevels:a}=(0,E.default)(),c=/^(?:ltr|rtl)$/;if(c.test(r))t=r;else if(r==="auto"){let l;switch(s){case"input":{!e.type||/^(?:button|email|hidden|password|reset|search|submit|tel|text|url)$/.test(e.type)?l=e.value:/^(?:checkbox|color|date|image|number|radio|range|time)$/.test(e.type)&&(t="ltr");break}case"slot":{l=f(e);break}case"textarea":{l=e.value;break}default:{const n=[].slice.call(e.childNodes);for(const u of n){const{dir:T,localName:N,nodeType:y,textContent:b}=u;if(y===i.TEXT_NODE?l=b.trim():y===i.ELEMENT_NODE&&!/^(?:bdi|script|style|textarea)$/.test(N)&&(!T||!c.test(T))&&(N==="slot"?l=f(u):l=b.trim()),l)break}}}if(l){const{paragraphs:[{level:n}]}=a(l);n%2===1?t="rtl":t="ltr"}if(!t)if(o){const{nodeType:n}=o;n===i.ELEMENT_NODE?t=m(o):(n===i.DOCUMENT_NODE||n===i.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}else t="ltr"}else if(s==="bdi"){const l=e.textContent.trim();if(l){const{paragraphs:[{level:n}]}=a(l);n%2===1?t="rtl":t="ltr"}t||o||(t="ltr")}else if(s==="input"&&e.type==="tel")t="ltr";else if(o){if(s==="slot"){const l=f(e);if(l){const{paragraphs:[{level:n}]}=a(l);n%2===1?t="rtl":t="ltr"}}if(!t){const{nodeType:l}=o;l===i.ELEMENT_NODE?t=m(o):(l===i.DOCUMENT_NODE||l===i.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}}else t="ltr"}return t??null},h=(e={})=>{let t;if(e.nodeType===i.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const r=e.getAttribute("contenteditable");if(r===""||/^(?:plaintext-only|true)$/.test(r))t=!0;else if(r==="inherit"){let s=e.parentNode;for(;s;){if(h(s)){t=!0;break}s=s.parentNode}}}}return!!t},D=(e,t)=>{let r;if(e&&typeof e=="string"&&t?.nodeType===i.ELEMENT_NODE){const{attributes:s}=t;for(const o of s){const{name:a,namespaceURI:c,prefix:l,value:n}=o;if(a===`xmlns:${e}`){r=n;break}else if(l===e){r=c;break}}}return r??null},$=(e="",t={})=>{let r;if(e&&typeof e=="string"&&t.nodeType===i.ELEMENT_NODE&&(r=t.lookupNamespaceURI(e),!r)){const s=t.ownerDocument.documentElement;let o=t;for(;o&&(r=D(e,o),!(r||o===s));)o=o.parentNode}return!!r},O=(e={},t={})=>{let r;if(e.nodeType===i.ELEMENT_NODE&&t.nodeType===i.ELEMENT_NODE){const s=t.compareDocumentPosition(e);r=s&i.DOCUMENT_POSITION_PRECEDING||s&i.DOCUMENT_POSITION_CONTAINS}return!!r},P=(e=[])=>{const t=[...e];return t.length>1&&t.sort((r,s)=>{let o;return O(s,r)?o=1:o=-1,o}),t};0&&(module.exports={getDirectionality,getNamespaceURI,getSlottedTextContent,isContentEditable,isInShadowTree,isNamespaceDeclared,isPreceding,resolveContent,sortNodes,verifyNode});
2
2
  //# sourceMappingURL=dom-util.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/js/dom-util.js"],
4
- "sourcesContent": ["/**\n * dom-util.js\n */\n\n/* import */\nimport bidiFactory from 'bidi-js';\n\n/* constants */\nimport {\n DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINS,\n DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, REG_SHADOW_MODE, TEXT_NODE,\n TYPE_FROM, TYPE_TO, WALKER_FILTER\n} from './constant.js';\n\n/**\n * verify node\n * @param {*} node - node\n * @throws\n * @returns {object} - Document, DocumentFragment, Element node\n */\nexport const verifyNode = node => {\n if (!node || !node.nodeType || !node.nodeName) {\n const type = Object.prototype.toString.call(node).slice(TYPE_FROM, TYPE_TO);\n const msg = `Unexpected type ${type}`;\n throw new TypeError(msg);\n } else if (!(node.nodeType === DOCUMENT_NODE ||\n node.nodeType === DOCUMENT_FRAGMENT_NODE ||\n node.nodeType === ELEMENT_NODE)) {\n const msg = `Unexpected node ${node.nodeName}`;\n throw new TypeError(msg);\n }\n return node;\n};\n\n/**\n * resolve content document, root node and tree walker\n * @param {object} node - Document, DocumentFragment, Element node\n * @returns {Array.<object>} - array of document, root node, tree walker\n */\nexport const resolveContent = node => {\n node = verifyNode(node);\n let document;\n let root;\n switch (node.nodeType) {\n case DOCUMENT_NODE: {\n document = node;\n root = node;\n break;\n }\n case DOCUMENT_FRAGMENT_NODE: {\n document = node.ownerDocument;\n root = node;\n break;\n }\n case ELEMENT_NODE:\n default: {\n document = node.ownerDocument;\n let parent = node;\n while (parent) {\n if (parent.parentNode) {\n parent = parent.parentNode;\n } else {\n break;\n }\n }\n root = parent;\n break;\n }\n }\n const tree = document.createTreeWalker(root, WALKER_FILTER);\n return [\n document,\n root,\n tree\n ];\n};\n\n/**\n * is in shadow tree\n * @param {object} node - node\n * @returns {boolean} - result;\n */\nexport const isInShadowTree = (node = {}) => {\n let bool;\n if (node.nodeType === ELEMENT_NODE ||\n node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n let refNode = node;\n while (refNode) {\n const { host, mode, nodeType, parentNode } = refNode;\n if (host && mode && nodeType === DOCUMENT_FRAGMENT_NODE &&\n REG_SHADOW_MODE.test(mode)) {\n bool = true;\n break;\n }\n refNode = parentNode;\n }\n }\n return !!bool;\n};\n\n/**\n * get slotted text content\n * @param {object} node - Element node\n * @returns {?string} - text content\n */\nexport const getSlottedTextContent = (node = {}) => {\n let res;\n if (node.localName === 'slot' && isInShadowTree(node)) {\n const nodes = node.assignedNodes();\n if (nodes.length) {\n for (const item of nodes) {\n res = item.textContent.trim();\n if (res) {\n break;\n }\n }\n } else {\n res = node.textContent.trim();\n }\n }\n return res ?? null;\n};\n\n/**\n * get directionality of node\n * @see https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute\n * @param {object} node - Element node\n * @returns {?string} - 'ltr' / 'rtl'\n */\nexport const getDirectionality = (node = {}) => {\n let res;\n if (node.nodeType === ELEMENT_NODE) {\n const { dir: nodeDir, localName, parentNode } = node;\n const { getEmbeddingLevels } = bidiFactory();\n const regDir = /^(?:ltr|rtl)$/;\n if (regDir.test(nodeDir)) {\n res = nodeDir;\n } else if (nodeDir === 'auto') {\n let text;\n switch (localName) {\n case 'input': {\n if (!node.type || /^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/.test(node.type)) {\n text = node.value;\n } else if (/^(?:(?:ima|ran)ge|(?:dat|tim)e|c(?:olor|heckbox)|number|radio)$/.test(node.type)) {\n res = 'ltr';\n }\n break;\n }\n case 'slot': {\n text = getSlottedTextContent(node);\n break;\n }\n case 'textarea': {\n text = node.value;\n break;\n }\n default: {\n const items = [].slice.call(node.childNodes);\n for (const item of items) {\n const {\n dir: itemDir, localName: itemLocalName, nodeType: itemNodeType,\n textContent: itemTextContent\n } = item;\n if (itemNodeType === TEXT_NODE) {\n text = itemTextContent.trim();\n } else if (itemNodeType === ELEMENT_NODE) {\n if (!/^(?:bdi|s(?:cript|tyle)|textarea)$/.test(itemLocalName) &&\n (!itemDir || !regDir.test(itemDir))) {\n if (itemLocalName === 'slot') {\n text = getSlottedTextContent(item);\n } else {\n text = itemTextContent.trim();\n }\n }\n }\n if (text) {\n break;\n }\n }\n }\n }\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n if (!res) {\n if (parentNode) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n res = getDirectionality(parentNode);\n } else if (parentNodeType === DOCUMENT_NODE ||\n parentNodeType === DOCUMENT_FRAGMENT_NODE) {\n res = 'ltr';\n }\n } else {\n res = 'ltr';\n }\n }\n } else if (localName === 'bdi') {\n const text = node.textContent.trim();\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n if (!(res || parentNode)) {\n res = 'ltr';\n }\n } else if (localName === 'input' && node.type === 'tel') {\n res = 'ltr';\n } else if (parentNode) {\n if (localName === 'slot') {\n const text = getSlottedTextContent(node);\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n }\n if (!res) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n res = getDirectionality(parentNode);\n } else if (parentNodeType === DOCUMENT_NODE ||\n parentNodeType === DOCUMENT_FRAGMENT_NODE) {\n res = 'ltr';\n }\n }\n } else {\n res = 'ltr';\n }\n }\n return res ?? null;\n};\n\n/**\n * is content editable\n * NOTE: not implemented in jsdom https://github.com/jsdom/jsdom/issues/1670\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isContentEditable = (node = {}) => {\n let res;\n if (node.nodeType === ELEMENT_NODE) {\n if (typeof node.isContentEditable === 'boolean') {\n res = node.isContentEditable;\n } else if (node.ownerDocument.designMode === 'on') {\n res = true;\n } else if (node.hasAttribute('contenteditable')) {\n const attr = node.getAttribute('contenteditable');\n if (attr === '' || /^(?:plaintext-only|true)$/.test(attr)) {\n res = true;\n } else if (attr === 'inherit') {\n let parent = node.parentNode;\n while (parent) {\n if (isContentEditable(parent)) {\n res = true;\n break;\n }\n parent = parent.parentNode;\n }\n }\n }\n }\n return !!res;\n};\n\n/**\n * get namespace URI\n * @param {string} ns - namespace prefix\n * @param {Array} node - Element node\n * @returns {?string} - namespace URI\n */\nexport const getNamespaceURI = (ns, node) => {\n let res;\n if (ns && typeof ns === 'string' && node?.nodeType === ELEMENT_NODE) {\n const { attributes } = node;\n for (const attr of attributes) {\n const { name, namespaceURI, prefix, value } = attr;\n if (name === `xmlns:${ns}`) {\n res = value;\n break;\n } else if (prefix === ns) {\n res = namespaceURI;\n break;\n }\n }\n }\n return res ?? null;\n};\n\n/**\n * is namespace declared\n * @param {string} ns - namespace\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isNamespaceDeclared = (ns = '', node = {}) => {\n let res;\n if (ns && typeof ns === 'string' && node.nodeType === ELEMENT_NODE) {\n res = node.lookupNamespaceURI(ns);\n if (!res) {\n const root = node.ownerDocument.documentElement;\n let parent = node;\n while (parent) {\n res = getNamespaceURI(ns, parent);\n if (res || parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n }\n }\n return !!res;\n};\n\n/**\n * is preceding - nodeA precedes and/or contains nodeB\n * @param {object} nodeA - Element node\n * @param {object} nodeB - Element node\n * @returns {boolean} - result\n */\nexport const isPreceding = (nodeA = {}, nodeB = {}) => {\n let res;\n if (nodeA.nodeType === ELEMENT_NODE && nodeB.nodeType === ELEMENT_NODE) {\n const posBit = nodeB.compareDocumentPosition(nodeA);\n res = posBit & DOCUMENT_POSITION_PRECEDING ||\n posBit & DOCUMENT_POSITION_CONTAINS;\n }\n return !!res;\n};\n\n/**\n * sort nodes\n * @param {Array.<object>|Set.<object>} nodes - collection of nodes\n * @returns {Array.<object|undefined>} - collection of sorted nodes\n */\nexport const sortNodes = (nodes = []) => {\n const arr = [...nodes];\n if (arr.length > 1) {\n arr.sort((a, b) => {\n let res;\n if (isPreceding(b, a)) {\n res = 1;\n } else {\n res = -1;\n }\n return res;\n });\n }\n return arr;\n};\n"],
5
- "mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,oBAAAC,EAAA,0BAAAC,EAAA,sBAAAC,EAAA,mBAAAC,EAAA,wBAAAC,EAAA,gBAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAZ,GAKA,IAAAa,EAAwB,wBAGxBC,EAIO,yBAQA,MAAMH,EAAaI,GAAQ,CAChC,GAAI,CAACA,GAAQ,CAACA,EAAK,UAAY,CAACA,EAAK,SAAU,CAE7C,MAAMC,EAAM,mBADC,OAAO,UAAU,SAAS,KAAKD,CAAI,EAAE,MAAM,YAAW,SAAO,CACvC,GACnC,MAAM,IAAI,UAAUC,CAAG,CACzB,SAAW,EAAED,EAAK,WAAa,iBAClBA,EAAK,WAAa,0BAClBA,EAAK,WAAa,gBAAe,CAC5C,MAAMC,EAAM,mBAAmBD,EAAK,QAAQ,GAC5C,MAAM,IAAI,UAAUC,CAAG,CACzB,CACA,OAAOD,CACT,EAOaN,EAAiBM,GAAQ,CACpCA,EAAOJ,EAAWI,CAAI,EACtB,IAAIE,EACAC,EACJ,OAAQH,EAAK,SAAU,CACrB,KAAK,gBAAe,CAClBE,EAAWF,EACXG,EAAOH,EACP,KACF,CACA,KAAK,yBAAwB,CAC3BE,EAAWF,EAAK,cAChBG,EAAOH,EACP,KACF,CACA,KAAK,eACL,QAAS,CACPE,EAAWF,EAAK,cAChB,IAAII,EAASJ,EACb,KAAOI,GACDA,EAAO,YACTA,EAASA,EAAO,WAKpBD,EAAOC,EACP,KACF,CAC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B,EACN,KACF,CACF,CACF,CACA,OAAOpB,GAAO,IAChB,EAQapB,EAAsB,CAACqC,EAAK,GAAI7B,EAAO,CAAC,IAAM,CACzD,IAAIY,EACJ,GAAIiB,GAAM,OAAOA,GAAO,UAAY7B,EAAK,WAAa,iBACpDY,EAAMZ,EAAK,mBAAmB6B,CAAE,EAC5B,CAACjB,GAAK,CACR,MAAMT,EAAOH,EAAK,cAAc,gBAChC,IAAII,EAASJ,EACb,KAAOI,IACLQ,EAAMxB,EAAgByC,EAAIzB,CAAM,EAC5B,EAAAQ,GAAOR,IAAWD,KAGtBC,EAASA,EAAO,UAEpB,CAEF,MAAO,CAAC,CAACQ,CACX,EAQanB,EAAc,CAAC0C,EAAQ,CAAC,EAAGC,EAAQ,CAAC,IAAM,CACrD,IAAIxB,EACJ,GAAIuB,EAAM,WAAa,gBAAgBC,EAAM,WAAa,eAAc,CACtE,MAAMC,EAASD,EAAM,wBAAwBD,CAAK,EAClDvB,EAAMyB,EAAS,+BACTA,EAAS,4BACjB,CACA,MAAO,CAAC,CAACzB,CACX,EAOajB,EAAY,CAACkB,EAAQ,CAAC,IAAM,CACvC,MAAMyB,EAAM,CAAC,GAAGzB,CAAK,EACrB,OAAIyB,EAAI,OAAS,GACfA,EAAI,KAAK,CAACC,EAAGC,IAAM,CACjB,IAAI5B,EACJ,OAAInB,EAAY+C,EAAGD,CAAC,EAClB3B,EAAM,EAENA,EAAM,GAEDA,CACT,CAAC,EAEI0B,CACT",
4
+ "sourcesContent": ["/**\n * dom-util.js\n */\n\n/* import */\nimport bidiFactory from 'bidi-js';\n\n/* constants */\nimport {\n DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINS,\n DOCUMENT_POSITION_PRECEDING, ELEMENT_NODE, REG_SHADOW_MODE, TEXT_NODE,\n TYPE_FROM, TYPE_TO, WALKER_FILTER\n} from './constant.js';\n\n/**\n * verify node\n * @param {*} node - node\n * @throws\n * @returns {object} - Document, DocumentFragment, Element node\n */\nexport const verifyNode = node => {\n if (!node || !node.nodeType || !node.nodeName) {\n const type = Object.prototype.toString.call(node).slice(TYPE_FROM, TYPE_TO);\n const msg = `Unexpected type ${type}`;\n throw new TypeError(msg);\n } else if (!(node.nodeType === DOCUMENT_NODE ||\n node.nodeType === DOCUMENT_FRAGMENT_NODE ||\n node.nodeType === ELEMENT_NODE)) {\n const msg = `Unexpected node ${node.nodeName}`;\n throw new TypeError(msg);\n }\n return node;\n};\n\n/**\n * resolve content document, root node and tree walker\n * @param {object} node - Document, DocumentFragment, Element node\n * @returns {Array.<object>} - array of document, root node, tree walker\n */\nexport const resolveContent = node => {\n node = verifyNode(node);\n let document;\n let root;\n switch (node.nodeType) {\n case DOCUMENT_NODE: {\n document = node;\n root = node;\n break;\n }\n case DOCUMENT_FRAGMENT_NODE: {\n document = node.ownerDocument;\n root = node;\n break;\n }\n case ELEMENT_NODE:\n default: {\n document = node.ownerDocument;\n let parent = node;\n while (parent) {\n if (parent.parentNode) {\n parent = parent.parentNode;\n } else {\n break;\n }\n }\n root = parent;\n break;\n }\n }\n const tree = document.createTreeWalker(root, WALKER_FILTER);\n return [\n document,\n root,\n tree\n ];\n};\n\n/**\n * is in shadow tree\n * @param {object} node - node\n * @returns {boolean} - result;\n */\nexport const isInShadowTree = (node = {}) => {\n let bool;\n if (node.nodeType === ELEMENT_NODE ||\n node.nodeType === DOCUMENT_FRAGMENT_NODE) {\n let refNode = node;\n while (refNode) {\n const { host, mode, nodeType, parentNode } = refNode;\n if (host && mode && nodeType === DOCUMENT_FRAGMENT_NODE &&\n REG_SHADOW_MODE.test(mode)) {\n bool = true;\n break;\n }\n refNode = parentNode;\n }\n }\n return !!bool;\n};\n\n/**\n * get slotted text content\n * @param {object} node - Element node\n * @returns {?string} - text content\n */\nexport const getSlottedTextContent = (node = {}) => {\n let res;\n if (node.localName === 'slot' && isInShadowTree(node)) {\n const nodes = node.assignedNodes();\n if (nodes.length) {\n for (const item of nodes) {\n res = item.textContent.trim();\n if (res) {\n break;\n }\n }\n } else {\n res = node.textContent.trim();\n }\n }\n return res ?? null;\n};\n\n/**\n * get directionality of node\n * @see https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute\n * @param {object} node - Element node\n * @returns {?string} - 'ltr' / 'rtl'\n */\nexport const getDirectionality = (node = {}) => {\n let res;\n if (node.nodeType === ELEMENT_NODE) {\n const { dir: nodeDir, localName, parentNode } = node;\n const { getEmbeddingLevels } = bidiFactory();\n const regDir = /^(?:ltr|rtl)$/;\n if (regDir.test(nodeDir)) {\n res = nodeDir;\n } else if (nodeDir === 'auto') {\n let text;\n switch (localName) {\n case 'input': {\n if (!node.type || /^(?:button|email|hidden|password|reset|search|submit|tel|text|url)$/.test(node.type)) {\n text = node.value;\n } else if (/^(?:checkbox|color|date|image|number|radio|range|time)$/.test(node.type)) {\n res = 'ltr';\n }\n break;\n }\n case 'slot': {\n text = getSlottedTextContent(node);\n break;\n }\n case 'textarea': {\n text = node.value;\n break;\n }\n default: {\n const items = [].slice.call(node.childNodes);\n for (const item of items) {\n const {\n dir: itemDir, localName: itemLocalName, nodeType: itemNodeType,\n textContent: itemTextContent\n } = item;\n if (itemNodeType === TEXT_NODE) {\n text = itemTextContent.trim();\n } else if (itemNodeType === ELEMENT_NODE) {\n if (!/^(?:bdi|script|style|textarea)$/.test(itemLocalName) &&\n (!itemDir || !regDir.test(itemDir))) {\n if (itemLocalName === 'slot') {\n text = getSlottedTextContent(item);\n } else {\n text = itemTextContent.trim();\n }\n }\n }\n if (text) {\n break;\n }\n }\n }\n }\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n if (!res) {\n if (parentNode) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n res = getDirectionality(parentNode);\n } else if (parentNodeType === DOCUMENT_NODE ||\n parentNodeType === DOCUMENT_FRAGMENT_NODE) {\n res = 'ltr';\n }\n } else {\n res = 'ltr';\n }\n }\n } else if (localName === 'bdi') {\n const text = node.textContent.trim();\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n if (!(res || parentNode)) {\n res = 'ltr';\n }\n } else if (localName === 'input' && node.type === 'tel') {\n res = 'ltr';\n } else if (parentNode) {\n if (localName === 'slot') {\n const text = getSlottedTextContent(node);\n if (text) {\n const { paragraphs: [{ level }] } = getEmbeddingLevels(text);\n if (level % 2 === 1) {\n res = 'rtl';\n } else {\n res = 'ltr';\n }\n }\n }\n if (!res) {\n const { nodeType: parentNodeType } = parentNode;\n if (parentNodeType === ELEMENT_NODE) {\n res = getDirectionality(parentNode);\n } else if (parentNodeType === DOCUMENT_NODE ||\n parentNodeType === DOCUMENT_FRAGMENT_NODE) {\n res = 'ltr';\n }\n }\n } else {\n res = 'ltr';\n }\n }\n return res ?? null;\n};\n\n/**\n * is content editable\n * NOTE: not implemented in jsdom https://github.com/jsdom/jsdom/issues/1670\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isContentEditable = (node = {}) => {\n let res;\n if (node.nodeType === ELEMENT_NODE) {\n if (typeof node.isContentEditable === 'boolean') {\n res = node.isContentEditable;\n } else if (node.ownerDocument.designMode === 'on') {\n res = true;\n } else if (node.hasAttribute('contenteditable')) {\n const attr = node.getAttribute('contenteditable');\n if (attr === '' || /^(?:plaintext-only|true)$/.test(attr)) {\n res = true;\n } else if (attr === 'inherit') {\n let parent = node.parentNode;\n while (parent) {\n if (isContentEditable(parent)) {\n res = true;\n break;\n }\n parent = parent.parentNode;\n }\n }\n }\n }\n return !!res;\n};\n\n/**\n * get namespace URI\n * @param {string} ns - namespace prefix\n * @param {Array} node - Element node\n * @returns {?string} - namespace URI\n */\nexport const getNamespaceURI = (ns, node) => {\n let res;\n if (ns && typeof ns === 'string' && node?.nodeType === ELEMENT_NODE) {\n const { attributes } = node;\n for (const attr of attributes) {\n const { name, namespaceURI, prefix, value } = attr;\n if (name === `xmlns:${ns}`) {\n res = value;\n break;\n } else if (prefix === ns) {\n res = namespaceURI;\n break;\n }\n }\n }\n return res ?? null;\n};\n\n/**\n * is namespace declared\n * @param {string} ns - namespace\n * @param {object} node - Element node\n * @returns {boolean} - result\n */\nexport const isNamespaceDeclared = (ns = '', node = {}) => {\n let res;\n if (ns && typeof ns === 'string' && node.nodeType === ELEMENT_NODE) {\n res = node.lookupNamespaceURI(ns);\n if (!res) {\n const root = node.ownerDocument.documentElement;\n let parent = node;\n while (parent) {\n res = getNamespaceURI(ns, parent);\n if (res || parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n }\n }\n return !!res;\n};\n\n/**\n * is preceding - nodeA precedes and/or contains nodeB\n * @param {object} nodeA - Element node\n * @param {object} nodeB - Element node\n * @returns {boolean} - result\n */\nexport const isPreceding = (nodeA = {}, nodeB = {}) => {\n let res;\n if (nodeA.nodeType === ELEMENT_NODE && nodeB.nodeType === ELEMENT_NODE) {\n const posBit = nodeB.compareDocumentPosition(nodeA);\n res = posBit & DOCUMENT_POSITION_PRECEDING ||\n posBit & DOCUMENT_POSITION_CONTAINS;\n }\n return !!res;\n};\n\n/**\n * sort nodes\n * @param {Array.<object>|Set.<object>} nodes - collection of nodes\n * @returns {Array.<object|undefined>} - collection of sorted nodes\n */\nexport const sortNodes = (nodes = []) => {\n const arr = [...nodes];\n if (arr.length > 1) {\n arr.sort((a, b) => {\n let res;\n if (isPreceding(b, a)) {\n res = 1;\n } else {\n res = -1;\n }\n return res;\n });\n }\n return arr;\n};\n"],
5
+ "mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,oBAAAC,EAAA,0BAAAC,EAAA,sBAAAC,EAAA,mBAAAC,EAAA,wBAAAC,EAAA,gBAAAC,EAAA,mBAAAC,EAAA,cAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAZ,GAKA,IAAAa,EA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,CACrD,IAAIxB,EACJ,GAAIuB,EAAM,WAAa,gBAAgBC,EAAM,WAAa,eAAc,CACtE,MAAMC,EAASD,EAAM,wBAAwBD,CAAK,EAClDvB,EAAMyB,EAAS,+BACTA,EAAS,4BACjB,CACA,MAAO,CAAC,CAACzB,CACX,EAOajB,EAAY,CAACkB,EAAQ,CAAC,IAAM,CACvC,MAAMyB,EAAM,CAAC,GAAGzB,CAAK,EACrB,OAAIyB,EAAI,OAAS,GACfA,EAAI,KAAK,CAACC,EAAGC,IAAM,CACjB,IAAI5B,EACJ,OAAInB,EAAY+C,EAAGD,CAAC,EAClB3B,EAAM,EAENA,EAAM,GAEDA,CACT,CAAC,EAEI0B,CACT",
6
6
  "names": ["dom_util_exports", "__export", "getDirectionality", "getNamespaceURI", "getSlottedTextContent", "isContentEditable", "isInShadowTree", "isNamespaceDeclared", "isPreceding", "resolveContent", "sortNodes", "verifyNode", "__toCommonJS", "import_bidi_js", "import_constant", "node", "msg", "document", "root", "parent", "tree", "bool", "refNode", "host", "mode", "nodeType", "parentNode", "res", "nodes", "item", "nodeDir", "localName", "getEmbeddingLevels", "bidiFactory", "regDir", "text", "items", "itemDir", "itemLocalName", "itemNodeType", "itemTextContent", "level", "parentNodeType", "attr", "ns", "attributes", "name", "namespaceURI", "prefix", "value", "nodeA", "nodeB", "posBit", "arr", "a", "b"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var B=Object.create;var I=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var X=(E,a)=>{for(var e in a)I(E,e,{get:a[e],enumerable:!0})},U=(E,a,e,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of G(a))!V.call(E,l)&&l!==e&&I(E,l,{get:()=>a[l],enumerable:!(r=j(a,l))||r.enumerable});return E};var z=(E,a,e)=>(e=E!=null?B(q(E)):{},U(a||!E||!E.__esModule?I(e,"default",{value:E,enumerable:!0}):e,E)),Y=E=>U(I({},"__esModule",{value:!0}),E);var K={};X(K,{Finder:()=>Q});module.exports=Y(K);var P=z(require("is-potential-custom-element-name"),1),F=z(require("nwsapi"),1),C=require("./dom-util.js"),$=require("./matcher.js"),S=require("./parser.js"),b=require("./constant.js");const T="next",O="prev",M="all",A="first",R="lineal",D="self";class Q{#a;#l;#t;#f;#h;#e;#d;#w;#o;#c;#p;#s;#b;#u;#r;#m;#i;#n;constructor(a){this.#n=a,this.#h=a.document,this.#l=new WeakMap,this.#p=new WeakMap,this.#o=(0,F.default)({document:a.document,DOMException:a.DOMException}),this.#o.configure({LOGERRORS:!1})}_onError(a){if(!this.#w)if(a instanceof DOMException||a instanceof this.#n.DOMException)if(a.name===b.NOT_SUPPORTED_ERR)this.#i&&console.warn(a.message);else throw new this.#n.DOMException(a.message,a.name);else throw a}_setup(a,e,r={}){const{noexcept:l,warn:s}=r;return this.#w=!!l,this.#i=!!s,this.#e=e,[this.#t,this.#s,this.#r]=(0,C.resolveContent)(e),this.#b=(0,C.isInShadowTree)(e),[this.#a,this.#d]=this._correspond(a),this.#m=new WeakMap,e}_correspond(a){const e=[];this.#f=!1;let r;if(this.#t){const l=this.#l.get(this.#t);if(l&&l.has(`${a}`)){const s=l.get(`${a}`);this.#f=s.descendant,r=s.ast}}if(r){const l=r.length;for(let s=0;s<l;s++)r[s].collected=!1,r[s].dir=null,r[s].filtered=!1,r[s].find=!1,e[s]=[]}else{let l;try{l=(0,S.parseSelector)(a)}catch(d){this._onError(d)}const s=(0,S.walkAST)(l);let o=!1,n=0;r=[];for(const[...d]of s){const f=[];let t=d.shift();if(t&&t.type!==b.COMBINATOR){const i=new Set;for(;t;){if(t.type===b.COMBINATOR){const[c]=d;if(c.type===b.COMBINATOR){const _=`Invalid selector ${a}`;throw new DOMException(_,b.SYNTAX_ERR)}const w=t.name;/^[\s>]$/.test(w)&&(o=!0),f.push({combo:t,leaves:(0,S.sortAST)(i)}),i.clear()}else if(t){let{name:c}=t;c&&typeof c=="string"&&(c=(0,S.unescapeSelector)(c),typeof c=="string"&&c!==t.name&&(t.name=c),/[|:]/.test(c)&&(t.namespace=!0)),i.add(t)}if(d.length)t=d.shift();else{f.push({combo:null,leaves:(0,S.sortAST)(i)}),i.clear();break}}}r.push({branch:f,collected:!1,dir:null,filtered:!1,find:!1}),e[n]=[],n++}if(this.#t){let d;this.#l.has(this.#t)?d=this.#l.get(this.#t):d=new Map,d.set(`${a}`,{ast:r,descendant:o}),this.#l.set(this.#t,d)}this.#f=o}return[r,e]}_createTreeWalker(a){let e;return this.#m.has(a)?e=this.#m.get(a):(e=this.#h.createTreeWalker(a,b.WALKER_FILTER),this.#m.set(a,e)),e}_prepareQuerySelectorWalker(){return this.#c=this._createTreeWalker(this.#e),this.#u=!1,this.#c}_traverse(a,e=this.#r){let r=e.currentNode,l;if(r===a)l=r;else if(r.contains(a))for(r=e.nextNode();r;){if(r===a){l=r;break}r=e.nextNode()}else{if(r!==e.root)for(;r&&!(r===e.root||r===a);)r=e.parentNode();if(a?.nodeType===b.ELEMENT_NODE)for(;r;){if(r===a){l=r;break}r=e.nextNode()}else l=r}return l??null}_collectNthChild(a,e,r){const{a:l,b:s,reverse:o,selector:n}=a,{parentNode:d}=e,f=new Set;let t;if(n&&(this.#l.has(n)?t=this.#l.get(n):(t=(0,S.walkAST)(n),this.#l.set(n,t))),d){const i=this.#r;let c=this._traverse(d,i);c=i.firstChild();let w=0;for(;c;)w++,c=i.nextSibling();c=this._traverse(d,i);const _=new Set;if(t)for(c=i.firstChild();c;){let m;for(const N of t)if(m=this._matchLeaves(N,c,r),!m)break;m&&_.add(c),c=i.nextSibling()}if(l===0){if(s>0&&s<=w){if(_.size){c=this._traverse(d,i),o?c=i.lastChild():c=i.firstChild();let m=0;for(;c;){if(_.has(c)){if(m===s-1){f.add(c);break}m++}o?c=i.previousSibling():c=i.nextSibling()}}else if(!n){c=this._traverse(d,i),o?c=i.lastChild():c=i.firstChild();let m=0;for(;c;){if(m===s-1){f.add(c);break}o?c=i.previousSibling():c=i.nextSibling(),m++}}}}else{let m=s-1;if(l>0)for(;m<0;)m+=l;if(m>=0&&m<w){c=this._traverse(d,i),o?c=i.lastChild():c=i.firstChild();let N=0,k=l>0?0:s-1;for(;c&&(c&&m>=0&&m<w);)_.size?_.has(c)&&(k===m&&(f.add(c),m+=l),l>0?k++:k--):N===m&&(n||f.add(c),m+=l),o?c=i.previousSibling():c=i.nextSibling(),N++}}if(o&&f.size>1){const m=[...f];return new Set(m.reverse())}}else if(e===this.#s&&l+s===1)if(t){let i;for(const c of t)if(i=this._matchLeaves(c,e,r),i)break;i&&f.add(e)}else f.add(e);return f}_collectNthOfType(a,e){const{a:r,b:l,reverse:s}=a,{localName:o,parentNode:n,prefix:d}=e,f=new Set;if(n){const t=this.#r;let i=this._traverse(n,t);i=t.firstChild();let c=0;for(;i;)c++,i=t.nextSibling();if(r===0){if(l>0&&l<=c){i=this._traverse(n,t),s?i=t.lastChild():i=t.firstChild();let w=0;for(;i;){const{localName:_,prefix:m}=i;if(_===o&&m===d){if(w===l-1){f.add(i);break}w++}s?i=t.previousSibling():i=t.nextSibling()}}}else{let w=l-1;if(r>0)for(;w<0;)w+=r;if(w>=0&&w<c){i=this._traverse(n,t),s?i=t.lastChild():i=t.firstChild();let _=r>0?0:l-1;for(;i;){const{localName:m,prefix:N}=i;if(m===o&&N===d){if(_===w&&(f.add(i),w+=r),w<0||w>=c)break;r>0?_++:_--}s?i=t.previousSibling():i=t.nextSibling()}}}if(s&&f.size>1){const w=[...f];return new Set(w.reverse())}}else e===this.#s&&r+l===1&&f.add(e);return f}_matchAnPlusB(a,e,r,l){const{nth:{a:s,b:o,name:n},selector:d}=a,f=new Map;if(n?(n==="even"?(f.set("a",2),f.set("b",0)):n==="odd"&&(f.set("a",2),f.set("b",1)),r.indexOf("last")>-1&&f.set("reverse",!0)):(typeof s=="string"&&/-?\d+/.test(s)?f.set("a",s*1):f.set("a",0),typeof o=="string"&&/-?\d+/.test(o)?f.set("b",o*1):f.set("b",0),r.indexOf("last")>-1&&f.set("reverse",!0)),/^nth-(?:last-)?child$/.test(r)){d&&f.set("selector",d);const t=Object.fromEntries(f);return this._collectNthChild(t,e,l)}else if(/^nth-(?:last-)?of-type$/.test(r)){const t=Object.fromEntries(f);return this._collectNthOfType(t,e)}return new Set}_matchHasPseudoFunc(a,e,r={}){let l;if(Array.isArray(a)&&a.length){const[s]=a,{type:o}=s;let n;o===b.COMBINATOR?n=a.shift():n={name:" ",type:b.COMBINATOR};const d=[];for(;a.length;){const[i]=a,{type:c}=i;if(c===b.COMBINATOR)break;d.push(a.shift())}const f={combo:n,leaves:d};r.dir=T;const t=this._matchCombinator(f,e,r);if(t.size)if(a.length){for(const i of t)if(l=this._matchHasPseudoFunc(Object.assign([],a),i,r),l)break}else l=!0}return!!l}_matchLogicalPseudoFunc(a,e,r={}){const{astName:l="",branches:s=[],selector:o="",twigBranches:n=[]}=a;let d;if(l==="has")if(o.includes(":has("))d=null;else{let f;for(const t of s)if(f=this._matchHasPseudoFunc(Object.assign([],t),e,r),f)break;f&&(d=e)}else{const f=/^(?:is|where)$/.test(l);r.forgive=f;const t=n.length;let i;for(let c=0;c<t;c++){const w=n[c],_=w.length-1,{leaves:m}=w[_];if(i=this._matchLeaves(m,e,r),i&&_>0){let N=new Set([e]);for(let k=_-1;k>=0;k--){const g=w[k],h=[];r.dir=O;for(const u of N){const p=this._matchCombinator(g,u,r);p.size&&h.push(...p)}if(h.length)k===0?i=!0:N=new Set(h);else{i=!1;break}}}if(i)break}l==="not"?i||(d=e):i&&(d=e)}return d??null}_matchPseudoClassSelector(a,e,r={}){const{children:l,name:s}=a,{localName:o,parentNode:n}=e,{forgive:d,warn:f=this.#i}=r,t=new Set;if(b.REG_LOGICAL_PSEUDO.test(s)){let i;if(this.#l.has(a))i=this.#l.get(a);else{const w=(0,S.walkAST)(a),_=[],m=[];for(const[...N]of w){for(const u of N){const p=(0,S.generateCSS)(u);_.push(p)}const k=[],g=new Set;let h=N.shift();for(;h;)if(h.type===b.COMBINATOR?(k.push({combo:h,leaves:[...g]}),g.clear()):h&&g.add(h),N.length)h=N.shift();else{k.push({combo:null,leaves:[...g]}),g.clear();break}m.push(k)}i={astName:s,branches:w,twigBranches:m,selector:_.join(",")},this.#l.set(a,i)}const c=this._matchLogicalPseudoFunc(i,e,r);c&&t.add(c)}else if(Array.isArray(l))if(/^nth-(?:last-)?(?:child|of-type)$/.test(s)){const[i]=l;return this._matchAnPlusB(i,e,s,r)}else switch(s){case"dir":case"lang":{const i=$.matcher.matchSelector(a,e);i&&t.add(i);break}case"current":case"nth-col":case"nth-last-col":{if(f){const i=`Unsupported pseudo-class :${s}()`;throw new DOMException(i,b.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;default:if(!d){const i=`Unknown pseudo-class :${s}()`;throw new DOMException(i,b.SYNTAX_ERR)}}else{const i=/^a(?:rea)?$/,c=/^(?:(?:fieldse|inpu|selec)t|button|opt(?:group|ion)|textarea)$/,w=/^(?:(?:inpu|selec)t|button|form|textarea)$/,_=/^d(?:etails|ialog)$/,m=/^(?:checkbox|radio)$/,N=/^(?:date(?:time-local)?|month|time|week)$/,k=/(?:(?:rang|tim)e|date(?:time-local)?|month|number|week)$/,g=/^(?:(?:emai|te|ur)l|number|password|search|text)$/;switch(s){case"any-link":case"link":{i.test(o)&&e.hasAttribute("href")&&t.add(e);break}case"local-link":{if(i.test(o)&&e.hasAttribute("href")){const{href:h,origin:u,pathname:p}=new URL(this.#t.URL),y=new URL(e.getAttribute("href"),h);y.origin===u&&y.pathname===p&&t.add(e)}break}case"visited":break;case"target":{const{hash:h}=new URL(this.#t.URL);e.id&&h===`#${e.id}`&&this.#t.contains(e)&&t.add(e);break}case"target-within":{const{hash:h}=new URL(this.#t.URL);if(h){const u=h.replace(/^#/,"");let p=this.#t.getElementById(u);for(;p;){if(p===e){t.add(e);break}p=p.parentNode}}break}case"scope":{this.#e.nodeType===b.ELEMENT_NODE?!this.#b&&e===this.#e&&t.add(e):e===this.#t.documentElement&&t.add(e);break}case"focus":{if(e===this.#t.activeElement&&e.tabIndex>=0){let h=e,u=!0;for(;h;){if(h.disabled||h.hasAttribute("disabled")||h.hidden||h.hasAttribute("hidden")){u=!1;break}else{const{display:p,visibility:y}=this.#n.getComputedStyle(h);if(u=!(p==="none"||y==="hidden"),!u)break}if(h.parentNode&&h.parentNode.nodeType===b.ELEMENT_NODE)h=h.parentNode;else break}u&&t.add(e)}break}case"focus-within":{let h,u=this.#t.activeElement;if(u.tabIndex>=0)for(;u;){if(u===e){h=!0;break}u=u.parentNode}if(h){let p=e,y=!0;for(;p;){if(p.disabled||p.hasAttribute("disabled")||p.hidden||p.hasAttribute("hidden")){y=!1;break}else{const{display:v,visibility:L}=this.#n.getComputedStyle(p);if(y=!(v==="none"||L==="hidden"),!y)break}if(p.parentNode&&p.parentNode.nodeType===b.ELEMENT_NODE)p=p.parentNode;else break}y&&t.add(e)}break}case"open":{_.test(o)&&e.hasAttribute("open")&&t.add(e);break}case"closed":{_.test(o)&&!e.hasAttribute("open")&&t.add(e);break}case"disabled":{if(c.test(o)||(0,P.default)(o))if(e.disabled||e.hasAttribute("disabled"))t.add(e);else{let h=n;for(;h&&h.localName!=="fieldset";)h=h.parentNode;h&&n.localName!=="legend"&&h.hasAttribute("disabled")&&t.add(e)}break}case"enabled":{(c.test(o)||(0,P.default)(o))&&!(e.disabled&&e.hasAttribute("disabled"))&&t.add(e);break}case"read-only":{switch(o){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}case"input":{(!e.type||N.test(e.type)||g.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,C.isContentEditable)(e)||t.add(e)}break}case"read-write":{switch(o){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||t.add(e);break}case"input":{(!e.type||N.test(e.type)||g.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,C.isContentEditable)(e)&&t.add(e)}break}case"placeholder-shown":{let h;o==="textarea"?h=e:o==="input"&&(e.hasAttribute("type")?g.test(e.getAttribute("type"))&&(h=e):h=e),h&&e.value===""&&e.hasAttribute("placeholder")&&e.getAttribute("placeholder").trim().length&&t.add(e);break}case"checked":{(e.checked&&o==="input"&&e.hasAttribute("type")&&m.test(e.getAttribute("type"))||e.selected&&o==="option")&&t.add(e);break}case"indeterminate":{if(e.indeterminate&&o==="input"&&e.type==="checkbox"||o==="progress"&&!e.hasAttribute("value"))t.add(e);else if(o==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const h=e.name;let u=e.parentNode;for(;u&&u.localName!=="form";)u=u.parentNode;u||(u=this.#t.documentElement);const p=u.getElementsByTagName("input"),y=p.length;let v;for(let L=0;L<y;L++){const x=p[L];if(x.getAttribute("type")==="radio"&&(h?x.getAttribute("name")===h&&(v=!!x.checked):x.hasAttribute("name")||(v=!!x.checked),v))break}v||t.add(e)}break}case"default":{const h=/^(?:button|reset)$/,u=/^(?:image|submit)$/;if(o==="button"&&!(e.hasAttribute("type")&&h.test(e.getAttribute("type")))||o==="input"&&e.hasAttribute("type")&&u.test(e.getAttribute("type"))){let p=e.parentNode;for(;p&&p.localName!=="form";)p=p.parentNode;if(p){const y=this.#r;let v=this._traverse(p,y);for(v=y.firstChild();v&&p.contains(v);){const L=v.localName;let x;if(L==="button"?x=!(v.hasAttribute("type")&&h.test(v.getAttribute("type"))):L==="input"&&(x=v.hasAttribute("type")&&u.test(v.getAttribute("type"))),x){v===e&&t.add(e);break}v=y.nextNode()}}}else if(o==="input"&&e.hasAttribute("type")&&m.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))t.add(e);else if(o==="option"){let p=n,y=!1;for(;p&&p.localName!=="datalist";){if(p.localName==="select"){(p.multiple||p.hasAttribute("multiple"))&&(y=!0);break}p=p.parentNode}if(y)(e.selected||e.hasAttribute("selected"))&&t.add(e);else{const v=new Set,L=this.#r;let x=this._traverse(n,L);for(x=L.firstChild();x;){if(x.selected||x.hasAttribute("selected")){v.add(x);break}x=L.nextSibling()}v.size&&v.has(e)&&t.add(e)}}break}case"valid":{if(w.test(o))e.checkValidity()&&t.add(e);else if(o==="fieldset"){const h=this.#r;let u=this._traverse(e,h);u=h.firstChild();let p;for(;u&&e.contains(u)&&!(w.test(u.localName)&&(p=u.checkValidity(),!p));)u=h.nextNode();p&&t.add(e)}break}case"invalid":{if(w.test(o))e.checkValidity()||t.add(e);else if(o==="fieldset"){const h=this.#r;let u=this._traverse(e,h);u=h.firstChild();let p;for(;u&&e.contains(u)&&!(w.test(u.localName)&&(p=u.checkValidity(),!p));)u=h.nextNode();p||t.add(e)}break}case"in-range":{o==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&k.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&t.add(e);break}case"out-of-range":{o==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&k.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&t.add(e);break}case"required":{let h;if(/^(?:select|textarea)$/.test(o))h=e;else if(o==="input")if(e.hasAttribute("type")){const u=e.getAttribute("type");(u==="file"||m.test(u)||N.test(u)||g.test(u))&&(h=e)}else h=e;h&&(e.required||e.hasAttribute("required"))&&t.add(e);break}case"optional":{let h;if(/^(?:select|textarea)$/.test(o))h=e;else if(o==="input")if(e.hasAttribute("type")){const u=e.getAttribute("type");(u==="file"||m.test(u)||N.test(u)||g.test(u))&&(h=e)}else h=e;h&&!(e.required||e.hasAttribute("required"))&&t.add(e);break}case"root":{e===this.#t.documentElement&&t.add(e);break}case"empty":{if(e.hasChildNodes()){const h=this.#h.createTreeWalker(e,b.SHOW_ALL);let u=h.firstChild(),p;for(;u&&(p=u.nodeType!==b.ELEMENT_NODE&&u.nodeType!==b.TEXT_NODE,!!p);)u=h.nextSibling();p&&t.add(e)}else t.add(e);break}case"first-child":{(n&&e===n.firstElementChild||e===this.#s)&&t.add(e);break}case"last-child":{(n&&e===n.lastElementChild||e===this.#s)&&t.add(e);break}case"only-child":{(n&&e===n.firstElementChild&&e===n.lastElementChild||e===this.#s)&&t.add(e);break}case"first-of-type":{if(n){const[h]=this._collectNthOfType({a:0,b:1},e);h&&t.add(h)}else e===this.#s&&t.add(e);break}case"last-of-type":{if(n){const[h]=this._collectNthOfType({a:0,b:1,reverse:!0},e);h&&t.add(h)}else e===this.#s&&t.add(e);break}case"only-of-type":{if(n){const[h]=this._collectNthOfType({a:0,b:1},e);if(h===e){const[u]=this._collectNthOfType({a:0,b:1,reverse:!0},e);u===e&&t.add(e)}}else e===this.#s&&t.add(e);break}case"defined":{const h=e.getAttribute("is");h?(0,P.default)(h)&&this.#n.customElements.get(h)&&t.add(e):(0,P.default)(o)?this.#n.customElements.get(o)&&t.add(e):(e instanceof this.#n.HTMLElement||e instanceof this.#n.SVGElement)&&t.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(f){const h=`Unsupported pseudo-element ::${s}`;throw new DOMException(h,b.NOT_SUPPORTED_ERR)}break}case"active":case"autofill":case"blank":case"buffering":case"current":case"focus-visible":case"fullscreen":case"future":case"hover":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(f){const h=`Unsupported pseudo-class :${s}`;throw new DOMException(h,b.NOT_SUPPORTED_ERR)}break}default:if(s.startsWith("-webkit-")){if(f){const h=`Unsupported pseudo-class :${s}`;throw new DOMException(h,b.NOT_SUPPORTED_ERR)}}else if(!d){const h=`Unknown pseudo-class :${s}`;throw new DOMException(h,b.SYNTAX_ERR)}}}return t}_matchShadowHostPseudoClass(a,e){const{children:r,name:l}=a;let s;if(Array.isArray(r)){const[o]=(0,S.walkAST)(r[0]),[...n]=o,{host:d}=e;if(l==="host"){let f;for(const t of n){const{type:i}=t;if(i===b.COMBINATOR){const w=`Invalid selector ${(0,S.generateCSS)(a)}`;throw new DOMException(w,b.SYNTAX_ERR)}if(f=this._matchSelector(t,d).has(d),!f)break}f&&(s=e)}else if(l==="host-context"){let f=d,t;for(;f;){for(const i of n){const{type:c}=i;if(c===b.COMBINATOR){const _=`Invalid selector ${(0,S.generateCSS)(a)}`;throw new DOMException(_,b.SYNTAX_ERR)}if(t=this._matchSelector(i,f).has(f),!t)break}if(t)break;f=f.parentNode}t&&(s=e)}}else if(l==="host")s=e;else{const o=`Invalid selector :${l}`;throw new DOMException(o,b.SYNTAX_ERR)}return s??null}_matchSelector(a,e,r){const{type:l}=a,s=new Set;if(a.name===b.EMPTY)return s;const o=(0,S.unescapeSelector)(a.name);if(typeof o=="string"&&o!==a.name&&(a.name=o),e.nodeType===b.ELEMENT_NODE)switch(l){case b.SELECTOR_PSEUDO_ELEMENT:{$.matcher.matchPseudoElementSelector(o,r);break}case b.SELECTOR_ID:{e.id===o&&s.add(e);break}case b.SELECTOR_CLASS:{e.classList.contains(o)&&s.add(e);break}case b.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(a,e,r);default:{const n=$.matcher.matchSelector(a,e,r);n&&s.add(n)}}else if(this.#b&&l===b.SELECTOR_PSEUDO_CLASS&&e.nodeType===b.DOCUMENT_FRAGMENT_NODE){if(o!=="has"&&b.REG_LOGICAL_PSEUDO.test(o))return this._matchPseudoClassSelector(a,e,r);if(b.REG_SHADOW_HOST.test(o)){const n=this._matchShadowHostPseudoClass(a,e,r);n&&s.add(n)}}return s}_matchLeaves(a,e,r){const{attributes:l,localName:s,nodeType:o}=e;let n=this.#p.get(a),d;if(n&&n.has(e)){const{attr:f,matched:t}=n.get(e);l?.length===f&&(d=t)}if(typeof d!="boolean"){const f=/^(?:(?:fieldse|inpu|selec)t|button|form|textarea)$/;let t;o===b.ELEMENT_NODE&&f.test(s)?t=!1:t=!0;for(const i of a){const{name:c,type:w}=i;if(w===b.SELECTOR_PSEUDO_CLASS&&c==="dir"&&(t=!1),d=this._matchSelector(i,e,r).has(e),!d)break}t&&(n||(n=new WeakMap),n.set(e,{attr:l?.length,matched:d}),this.#p.set(a,n))}return!!d}_matchHTMLCollection(a,e={}){const{compound:r,filterLeaves:l}=e,s=new Set,o=a.length;if(o)if(r)for(let n=0;n<o;n++){const d=a[n];this._matchLeaves(l,d,e)&&s.add(d)}else{const n=[].slice.call(a);return new Set(n)}return s}_findDescendantNodes(a,e,r){const[l,...s]=a,o=s.length>0,{type:n}=l,d=(0,S.unescapeSelector)(l.name);typeof d=="string"&&d!==l.name&&(l.name=d);let f=new Set,t=!1;if(this.#b)t=!0;else switch(n){case b.SELECTOR_PSEUDO_ELEMENT:{$.matcher.matchPseudoElementSelector(d,r);break}case b.SELECTOR_ID:{if(this.#s.nodeType===b.ELEMENT_NODE)t=!0;else{const i=this.#s.getElementById(d);i&&i!==e&&e.contains(i)&&(o?this._matchLeaves(s,i,r)&&f.add(i):f.add(i))}break}case b.SELECTOR_CLASS:{const i=e.getElementsByClassName(d);f=this._matchHTMLCollection(i,{compound:o,filterLeaves:s});break}case b.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(d)){const i=e.getElementsByTagName(d);f=this._matchHTMLCollection(i,{compound:o,filterLeaves:s})}else t=!0;break}default:t=!0}return{nodes:f,pending:t}}_matchCombinator(a,e,r={}){const{combo:l,leaves:s}=a,{name:o}=l,{parentNode:n}=e,{dir:d}=r,f=new Set;if(d===T)switch(o){case"+":{const t=e.nextElementSibling;t&&this._matchLeaves(s,t,r)&&f.add(t);break}case"~":{if(n){const t=this._createTreeWalker(n);let i=this._traverse(e,t);for(i=t.nextSibling();i;)this._matchLeaves(s,i,r)&&f.add(i),i=t.nextSibling()}break}case">":{const t=this._createTreeWalker(e);let i=this._traverse(e,t);for(i=t.firstChild();i;)this._matchLeaves(s,i,r)&&f.add(i),i=t.nextSibling();break}case" ":default:{const{nodes:t,pending:i}=this._findDescendantNodes(s,e);if(t.size)return t;if(i){const c=this._createTreeWalker(e);let w=this._traverse(e,c);for(w=c.nextNode();w&&e.contains(w);)this._matchLeaves(s,w,r)&&f.add(w),w=c.nextNode()}}}else switch(o){case"+":{const t=e.previousElementSibling;t&&this._matchLeaves(s,t,r)&&f.add(t);break}case"~":{if(n){const t=this._createTreeWalker(n);let i=this._traverse(n,t);for(i=t.firstChild();i&&i!==e;)this._matchLeaves(s,i,r)&&f.add(i),i=t.nextSibling()}break}case">":{n&&this._matchLeaves(s,n,r)&&f.add(n);break}case" ":default:{const t=[];let i=n;for(;i;)this._matchLeaves(s,i,r)&&t.push(i),i=i.parentNode;if(t.length)return new Set(t.reverse())}}return f}_findNode(a,e){const{node:r}=e;let l=this._traverse(r,this.#c),s;if(l)for(l.nodeType!==b.ELEMENT_NODE?l=this.#c.nextNode():l===r&&l!==this.#s&&(l=this.#c.nextNode());l;){if(this._matchLeaves(a,l,{warn:this.#i})){s=l;break}l=this.#c.nextNode()}return s??null}_matchSelf(a){const e=[],r=this._matchLeaves(a,this.#e,{warn:this.#i});let l=!1;return r&&(e.push(this.#e),l=!0),[e,l]}_findLineal(a,e={}){const{complex:r}=e,l=[];let s=this._matchLeaves(a,this.#e,{warn:this.#i}),o=!1;if(s&&(l.push(this.#e),o=!0),!s||r){let n=this.#e.parentNode;for(;n&&(s=this._matchLeaves(a,n,{warn:this.#i}),s&&(l.push(n),o=!0),n.parentNode);)n=n.parentNode}return[l,o]}_findFirst(a){const e=[],r=this._findNode(a,{node:this.#e});let l=!1;return r&&(e.push(r),l=!0),[e,l]}_findFromHTMLCollection(a,e={}){const{complex:r,compound:l,filterLeaves:s,targetType:o}=e;let n=[],d=!1,f=!1;const t=a.length;if(t)if(this.#e.nodeType===b.ELEMENT_NODE)for(let i=0;i<t;i++){const c=a[i];if(c!==this.#e&&(this.#e.contains(c)||c.contains(this.#e))){if(l){if(this._matchLeaves(s,c,{warn:this.#i})&&(n.push(c),d=!0,o===A))break}else if(n.push(c),d=!0,o===A)break}}else if(r)if(l)for(let i=0;i<t;i++){const c=a[i];if(this._matchLeaves(s,c,{warn:this.#i})&&(n.push(c),d=!0,o===A))break}else n=[].slice.call(a),d=!0,f=!0;else if(l)for(let i=0;i<t;i++){const c=a[i];if(this._matchLeaves(s,c,{warn:this.#i})&&(n.push(c),d=!0,o===A))break}else n=[].slice.call(a),d=!0,f=!0;return[n,d,f]}_findEntryNodes(a,e,r){const{leaves:l}=a,[s,...o]=l,n=o.length>0,{name:d,type:f}=s;let t=[],i=!1,c=!1,w=!1;switch(f){case b.SELECTOR_PSEUDO_ELEMENT:{$.matcher.matchPseudoElementSelector(d,{warn:this.#i});break}case b.SELECTOR_ID:{if(e===D)[t,c]=this._matchSelf(l);else if(e===R)[t,c]=this._findLineal(l,{complex:r});else if(e===A&&this.#s.nodeType!==b.ELEMENT_NODE){const _=this.#s.getElementById(d);_&&(n?this._matchLeaves(o,_,{warn:this.#i})&&(t.push(_),c=!0):(t.push(_),c=!0))}else e===A?[t,c]=this._findFirst(l):w=!0;break}case b.SELECTOR_CLASS:{if(e===D)[t,c]=this._matchSelf(l);else if(e===R)[t,c]=this._findLineal(l,{complex:r});else if(this.#s.nodeType===b.DOCUMENT_NODE){const _=this.#s.getElementsByClassName(d);_.length&&([t,c,i]=this._findFromHTMLCollection(_,{complex:r,compound:n,filterLeaves:o,targetType:e}))}else e===A?[t,c]=this._findFirst(l):w=!0;break}case b.SELECTOR_TYPE:{if(e===D)[t,c]=this._matchSelf(l);else if(e===R)[t,c]=this._findLineal(l,{complex:r});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===b.DOCUMENT_NODE&&!/[*|]/.test(d)){const _=this.#s.getElementsByTagName(d);_.length&&([t,c,i]=this._findFromHTMLCollection(_,{complex:r,compound:n,filterLeaves:o,targetType:e}))}else e===A?[t,c]=this._findFirst(l):w=!0;break}default:if(e!==R&&b.REG_SHADOW_HOST.test(d)){if(this.#b&&this.#e.nodeType===b.DOCUMENT_FRAGMENT_NODE){const _=this._matchShadowHostPseudoClass(s,this.#e);_&&(t.push(_),c=!0)}}else e===D?[t,c]=this._matchSelf(l):e===R?[t,c]=this._findLineal(l,{complex:r}):e===A?[t,c]=this._findFirst(l):w=!0}return{collected:i,compound:n,filtered:c,nodes:t,pending:w}}_collectNodes(a){const e=this.#a.values();if(a===M||a===A){const r=new Set;let l=0;for(const{branch:s}of e){const o=s.length,n=o>1,d=s[0];let f,t;if(n){const{combo:N,leaves:[{name:k,type:g}]}=d,h=s[o-1],{leaves:[{name:u,type:p}]}=h;if(p===b.SELECTOR_PSEUDO_ELEMENT||p===b.SELECTOR_ID)f=O,t=h;else if(g===b.SELECTOR_PSEUDO_ELEMENT||g===b.SELECTOR_ID)f=T,t=d;else if(a===M)if(k==="*"&&g===b.SELECTOR_TYPE)f=O,t=h;else if(u==="*"&&p===b.SELECTOR_TYPE)f=T,t=d;else if(o===2){const{name:y}=N;/^[+~]$/.test(y)?(f=O,t=h):(f=T,t=d)}else f=T,t=d;else if(u==="*"&&p===b.SELECTOR_TYPE)f=T,t=d;else if(k==="*"&&g===b.SELECTOR_TYPE)f=O,t=h;else{let y;for(const{combo:v,leaves:[L]}of s){const{name:x,type:W}=L;if(W===b.SELECTOR_PSEUDO_CLASS&&x==="dir"){y=!1;break}if(!y&&v){const{name:H}=v;/^[+~]$/.test(H)&&(y=!0)}}y?(f=T,t=d):(f=O,t=h)}}else f=O,t=d;const{collected:i,compound:c,filtered:w,nodes:_,pending:m}=this._findEntryNodes(t,a,n);_.length?(this.#a[l].find=!0,this.#d[l]=_):m&&r.add(new Map([["index",l],["twig",t]])),this.#a[l].collected=i,this.#a[l].dir=f,this.#a[l].filtered=w||!c,l++}if(r.size){let s,o;this.#e!==this.#s&&this.#e.nodeType===b.ELEMENT_NODE?(s=this.#e,o=this.#c):(s=this.#s,o=this.#r);let n=this._traverse(s,o);for(;n;){let d=!1;if(this.#e.nodeType===b.ELEMENT_NODE?n===this.#e?d=!0:d=this.#e.contains(n):d=!0,d)for(const f of r){const{leaves:t}=f.get("twig");if(this._matchLeaves(t,n,{warn:this.#i})){const c=f.get("index");this.#a[c].filtered=!0,this.#a[c].find=!0,this.#d[c].push(n)}}n!==o.currentNode&&(n=this._traverse(n,o)),n=o.nextNode()}}}else{let r=0;for(const{branch:l}of e){const s=l[l.length-1],o=l.length>1,{compound:n,filtered:d,nodes:f}=this._findEntryNodes(s,a,o);f.length&&(this.#a[r].find=!0,this.#d[r]=f),this.#a[r].dir=O,this.#a[r].filtered=d||!n,r++}}return[this.#a,this.#d]}_getCombinedNodes(a,e,r){const l=[];for(const s of e){const o=this._matchCombinator(a,s,{dir:r,warn:this.#i});o.size&&l.push(...o)}return l.length?new Set(l):new Set}_matchNodeNext(a,e,r){const{combo:l,index:s}=r,{combo:o,leaves:n}=a[s],d={combo:l,leaves:n},f=this._getCombinedNodes(d,e,T);let t;if(f.size)if(s===a.length-1){const[i]=(0,C.sortNodes)(f);t=i}else t=this._matchNodeNext(a,f,{combo:o,index:s+1});return t??null}_matchNodePrev(a,e,r){const{index:l}=r,s=a[l],o=new Set([e]),n=this._getCombinedNodes(s,o,O);let d;if(n.size){if(l===0)d=e;else for(const f of n)if(this._matchNodePrev(a,f,{index:l-1}))return e}return d??null}_find(a){(a===M||a===A)&&this._prepareQuerySelectorWalker();const[[...e],r]=this._collectNodes(a),l=e.length;let s=new Set;for(let o=0;o<l;o++){const{branch:n,collected:d,dir:f,find:t}=e[o],i=n.length;if(i&&t){const c=r[o],w=c.length,_=i-1;if(_===0)if((a===M||a===A)&&this.#e.nodeType===b.ELEMENT_NODE)for(let m=0;m<w;m++){const N=c[m];if(N!==this.#e&&this.#e.contains(N)&&(s.add(N),a!==M))break}else if(a===M)if(s.size){const m=[...s];s=new Set([...m,...c]),this.#u=!0}else s=new Set(c);else{const[m]=c;s.add(m)}else if(a===M)if(f===T){let{combo:m}=n[0];for(const N of c){let k=new Set([N]);for(let g=1;g<i;g++){const{combo:h,leaves:u}=n[g],p={combo:m,leaves:u};if(k=this._getCombinedNodes(p,k,f),k.size)if(g===_)if(s.size){const y=[...s];s=new Set([...y,...k]),this.#u=!0}else s=k;else m=h;else break}}}else for(const m of c){let N=new Set([m]);for(let k=_-1;k>=0;k--){const g=n[k];if(N=this._getCombinedNodes(g,N,f),N.size)k===0&&(s.add(m),i>1&&s.size>1&&(this.#u=!0));else break}}else if(a===A&&f===T){const{combo:m}=n[0];let N;for(const k of c)if(N=this._matchNodeNext(n,new Set([k]),{combo:m,index:1}),N){s.add(N);break}if(!N&&!d){const{leaves:k}=n[0],[g]=c;let h=this._findNode(k,{node:g});for(;h;){if(N=this._matchNodeNext(n,new Set([h]),{combo:m,index:1}),N){s.add(N);break}h=this._findNode(k,{node:h})}}}else{let m;for(const N of c)if(m=this._matchNodePrev(n,N,{index:_-1}),m){s.add(N);break}if(!m&&!d&&a===A){const{leaves:N}=n[_],[k]=c;let g=this._findNode(N,{node:k});for(;g;){if(m=this._matchNodePrev(n,g,{index:_-1}),m){s.add(g);break}g=this._findNode(N,{node:g})}}}}}return s}matches(a,e,r){let l;try{if(e?.nodeType!==b.ELEMENT_NODE){const s=`Unexpected node ${e?.nodeName}`;throw new TypeError(s)}(0,S.filterSelector)(a)?l=this.#o.match(a,e):(this._setup(a,e,r),l=this._find(D).size)}catch(s){this._onError(s)}return!!l}closest(a,e,r){let l;try{if(e?.nodeType!==b.ELEMENT_NODE){const s=`Unexpected node ${e?.nodeName}`;throw new TypeError(s)}if((0,S.filterSelector)(a))l=this.#o.closest(a,e);else{this._setup(a,e,r);const s=this._find(R);if(s.size){let o=this.#e;for(;o;){if(s.has(o)){l=o;break}o=o.parentNode}}}}catch(s){this._onError(s)}return l??null}querySelector(a,e,r){let l;try{if(this._setup(a,e,r),this.#h===this.#t&&!this.#f&&(0,S.filterSelector)(a))l=this.#o.first(a,e);else{const s=this._find(A);s.delete(this.#e),s.size&&([l]=(0,C.sortNodes)(s))}}catch(s){this._onError(s)}return l??null}querySelectorAll(a,e,r){let l;try{if(this._setup(a,e,r),this.#h===this.#t&&!this.#f&&(0,S.filterSelector)(a))l=this.#o.select(a,e);else{const s=this._find(M);s.delete(this.#e),s.size&&(this.#u?l=(0,C.sortNodes)(s):l=[...s])}}catch(s){this._onError(s)}return l??[]}}0&&(module.exports={Finder});
1
+ var B=Object.create;var I=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var X=(A,a)=>{for(var e in a)I(A,e,{get:a[e],enumerable:!0})},U=(A,a,e,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of G(a))!V.call(A,l)&&l!==e&&I(A,l,{get:()=>a[l],enumerable:!(r=j(a,l))||r.enumerable});return A};var z=(A,a,e)=>(e=A!=null?B(q(A)):{},U(a||!A||!A.__esModule?I(e,"default",{value:A,enumerable:!0}):e,A)),Y=A=>U(I({},"__esModule",{value:!0}),A);var Q={};X(Q,{Finder:()=>K});module.exports=Y(Q);var P=z(require("is-potential-custom-element-name"),1),F=z(require("@asamuzakjp/nwsapi"),1),C=require("./dom-util.js"),$=require("./matcher.js"),x=require("./parser.js"),b=require("./constant.js");const T="next",O="prev",M="all",L="first",R="lineal",D="self";class K{#a;#r;#c;#t;#h;#d;#p;#e;#b;#k;#f;#o;#_;#s;#u;#m;#n;#w;#i;#l;constructor(a){this.#l=a,this.#d=a.document,this.#r=new WeakMap,this.#_=new WeakMap,this.#f=(0,F.default)({document:a.document,DOMException:a.DOMException}),this.#f.configure({LOGERRORS:!1})}_onError(a){if(!this.#k)if(a instanceof DOMException||a instanceof this.#l.DOMException)if(a.name===b.NOT_SUPPORTED_ERR)this.#i&&console.warn(a.message);else throw new this.#l.DOMException(a.message,a.name);else throw a}_setup(a,e,r={}){const{event:l,noexcept:i,warn:c}=r;return this.#k=!!i,this.#i=!!c,this.#p=this._setEvent(l),this.#e=e,[this.#t,this.#s,this.#n]=(0,C.resolveContent)(e),this.#u=(0,C.isInShadowTree)(e),[this.#a,this.#b]=this._correspond(a),this.#w=new WeakMap,e}_setEvent(a){return a instanceof this.#l.MouseEvent||a instanceof this.#l.KeyboardEvent?a:null}_correspond(a){const e=[];this.#c=!1,this.#h=!1;let r;if(this.#t){const l=this.#r.get(this.#t);if(l&&l.has(`${a}`)){const i=l.get(`${a}`);this.#c=i.complex,this.#h=i.descendant,r=i.ast}}if(r){const l=r.length;for(let i=0;i<l;i++)r[i].collected=!1,r[i].dir=null,r[i].filtered=!1,r[i].find=!1,e[i]=[]}else{let l;try{l=(0,x.parseSelector)(a)}catch(f){this._onError(f)}const{branches:i,complex:c}=(0,x.walkAST)(l);let n=!1,d=0;r=[];for(const[...f]of i){const t=[];let s=f.shift();if(s&&s.type!==b.COMBINATOR){const o=new Set;for(;s;){if(s.type===b.COMBINATOR){const[p]=f;if(p.type===b.COMBINATOR){const w=`Invalid selector ${a}`;throw new DOMException(w,b.SYNTAX_ERR)}const _=s.name;/^[\s>]$/.test(_)&&(n=!0),t.push({combo:s,leaves:(0,x.sortAST)(o)}),o.clear()}else if(s){let{name:p}=s;p&&typeof p=="string"&&(p=(0,x.unescapeSelector)(p),typeof p=="string"&&p!==s.name&&(s.name=p),/[|:]/.test(p)&&(s.namespace=!0)),o.add(s)}if(f.length)s=f.shift();else{t.push({combo:null,leaves:(0,x.sortAST)(o)}),o.clear();break}}}r.push({branch:t,collected:!1,dir:null,filtered:!1,find:!1}),e[d]=[],d++}if(this.#t){let f;this.#r.has(this.#t)?f=this.#r.get(this.#t):f=new Map,f.set(`${a}`,{ast:r,complex:c,descendant:n}),this.#r.set(this.#t,f)}this.#c=c,this.#h=n}return[r,e]}_createTreeWalker(a){let e;return this.#w.has(a)?e=this.#w.get(a):(e=this.#d.createTreeWalker(a,b.WALKER_FILTER),this.#w.set(a,e)),e}_prepareQuerySelectorWalker(){return this.#o=this._createTreeWalker(this.#e),this.#m=!1,this.#o}_traverse(a,e=this.#n){let r=e.currentNode,l;if(r===a)l=r;else if(r.contains(a))for(r=e.nextNode();r;){if(r===a){l=r;break}r=e.nextNode()}else{if(r!==e.root)for(;r&&!(r===e.root||r===a);)r=e.parentNode();if(a?.nodeType===b.ELEMENT_NODE)for(;r;){if(r===a){l=r;break}r=e.nextNode()}else l=r}return l??null}_collectNthChild(a,e,r){const{a:l,b:i,reverse:c,selector:n}=a,{parentNode:d}=e,f=new Set;let t;if(n)if(this.#r.has(n))t=this.#r.get(n);else{const{branches:s}=(0,x.walkAST)(n);t=s,this.#r.set(n,t)}if(d){const s=this.#n;let o=this._traverse(d,s);o=s.firstChild();let p=0;for(;o;)p++,o=s.nextSibling();o=this._traverse(d,s);const _=new Set;if(t)for(o=s.firstChild();o;){let w;for(const k of t)if(w=this._matchLeaves(k,o,r),!w)break;w&&_.add(o),o=s.nextSibling()}if(l===0){if(i>0&&i<=p){if(_.size){o=this._traverse(d,s),c?o=s.lastChild():o=s.firstChild();let w=0;for(;o;){if(_.has(o)){if(w===i-1){f.add(o);break}w++}c?o=s.previousSibling():o=s.nextSibling()}}else if(!n){o=this._traverse(d,s),c?o=s.lastChild():o=s.firstChild();let w=0;for(;o;){if(w===i-1){f.add(o);break}c?o=s.previousSibling():o=s.nextSibling(),w++}}}}else{let w=i-1;if(l>0)for(;w<0;)w+=l;if(w>=0&&w<p){o=this._traverse(d,s),c?o=s.lastChild():o=s.firstChild();let k=0,N=l>0?0:i-1;for(;o&&(o&&w>=0&&w<p);)_.size?_.has(o)&&(N===w&&(f.add(o),w+=l),l>0?N++:N--):k===w&&(n||f.add(o),w+=l),c?o=s.previousSibling():o=s.nextSibling(),k++}}if(c&&f.size>1){const w=[...f];return new Set(w.reverse())}}else if(e===this.#s&&l+i===1)if(t){let s;for(const o of t)if(s=this._matchLeaves(o,e,r),s)break;s&&f.add(e)}else f.add(e);return f}_collectNthOfType(a,e){const{a:r,b:l,reverse:i}=a,{localName:c,parentNode:n,prefix:d}=e,f=new Set;if(n){const t=this.#n;let s=this._traverse(n,t);s=t.firstChild();let o=0;for(;s;)o++,s=t.nextSibling();if(r===0){if(l>0&&l<=o){s=this._traverse(n,t),i?s=t.lastChild():s=t.firstChild();let p=0;for(;s;){const{localName:_,prefix:w}=s;if(_===c&&w===d){if(p===l-1){f.add(s);break}p++}i?s=t.previousSibling():s=t.nextSibling()}}}else{let p=l-1;if(r>0)for(;p<0;)p+=r;if(p>=0&&p<o){s=this._traverse(n,t),i?s=t.lastChild():s=t.firstChild();let _=r>0?0:l-1;for(;s;){const{localName:w,prefix:k}=s;if(w===c&&k===d){if(_===p&&(f.add(s),p+=r),p<0||p>=o)break;r>0?_++:_--}i?s=t.previousSibling():s=t.nextSibling()}}}if(i&&f.size>1){const p=[...f];return new Set(p.reverse())}}else e===this.#s&&r+l===1&&f.add(e);return f}_matchAnPlusB(a,e,r,l){const{nth:{a:i,b:c,name:n},selector:d}=a,f=new Map;if(n?(n==="even"?(f.set("a",2),f.set("b",0)):n==="odd"&&(f.set("a",2),f.set("b",1)),r.indexOf("last")>-1&&f.set("reverse",!0)):(typeof i=="string"&&/-?\d+/.test(i)?f.set("a",i*1):f.set("a",0),typeof c=="string"&&/-?\d+/.test(c)?f.set("b",c*1):f.set("b",0),r.indexOf("last")>-1&&f.set("reverse",!0)),/^nth-(?:last-)?child$/.test(r)){d&&f.set("selector",d);const t=Object.fromEntries(f);return this._collectNthChild(t,e,l)}else if(/^nth-(?:last-)?of-type$/.test(r)){const t=Object.fromEntries(f);return this._collectNthOfType(t,e)}return new Set}_matchHasPseudoFunc(a,e,r={}){let l;if(Array.isArray(a)&&a.length){const[i]=a,{type:c}=i;let n;c===b.COMBINATOR?n=a.shift():n={name:" ",type:b.COMBINATOR};const d=[];for(;a.length;){const[s]=a,{type:o}=s;if(o===b.COMBINATOR)break;d.push(a.shift())}const f={combo:n,leaves:d};r.dir=T;const t=this._matchCombinator(f,e,r);if(t.size)if(a.length){for(const s of t)if(l=this._matchHasPseudoFunc(Object.assign([],a),s,r),l)break}else l=!0}return!!l}_matchLogicalPseudoFunc(a,e,r={}){const{astName:l="",branches:i=[],selector:c="",twigBranches:n=[]}=a;let d;if(l==="has")if(c.includes(":has("))d=null;else{let f;for(const t of i)if(f=this._matchHasPseudoFunc(Object.assign([],t),e,r),f)break;f&&(d=e)}else{const f=/^(?:is|where)$/.test(l);r.forgive=f;const t=n.length;let s;for(let o=0;o<t;o++){const p=n[o],_=p.length-1,{leaves:w}=p[_];if(s=this._matchLeaves(w,e,r),s&&_>0){let k=new Set([e]);for(let N=_-1;N>=0;N--){const g=p[N],h=[];r.dir=O;for(const m of k){const u=this._matchCombinator(g,m,r);u.size&&h.push(...u)}if(h.length)N===0?s=!0:k=new Set(h);else{s=!1;break}}}if(s)break}l==="not"?s||(d=e):s&&(d=e)}return d??null}_matchPseudoClassSelector(a,e,r={}){const{children:l,name:i}=a,{localName:c,parentNode:n}=e,{forgive:d,warn:f=this.#i}=r,t=new Set;if(b.REG_LOGICAL_PSEUDO.test(i)){let s;if(this.#r.has(a))s=this.#r.get(a);else{const{branches:p}=(0,x.walkAST)(a),_=[],w=[];for(const[...k]of p){for(const m of k){const u=(0,x.generateCSS)(m);_.push(u)}const N=[],g=new Set;let h=k.shift();for(;h;)if(h.type===b.COMBINATOR?(N.push({combo:h,leaves:[...g]}),g.clear()):h&&g.add(h),k.length)h=k.shift();else{N.push({combo:null,leaves:[...g]}),g.clear();break}w.push(N)}s={astName:i,branches:p,twigBranches:w,selector:_.join(",")},this.#r.set(a,s)}const o=this._matchLogicalPseudoFunc(s,e,r);o&&t.add(o)}else if(Array.isArray(l))if(/^nth-(?:last-)?(?:child|of-type)$/.test(i)){const[s]=l;return this._matchAnPlusB(s,e,i,r)}else switch(i){case"dir":case"lang":{const s=$.matcher.matchSelector(a,e);s&&t.add(s);break}case"current":case"nth-col":case"nth-last-col":{if(f){const s=`Unsupported pseudo-class :${i}()`;throw new DOMException(s,b.NOT_SUPPORTED_ERR)}break}case"host":case"host-context":break;default:if(!d){const s=`Unknown pseudo-class :${i}()`;throw new DOMException(s,b.SYNTAX_ERR)}}else{const s=/^a(?:rea)?$/,o=/^(?:button|fieldset|input|optgroup|option|select|textarea)$/,p=/^(?:button|form|input|select|textarea)$/,_=/^(?:details|dialog)$/,w=/^(?:checkbox|radio)$/,k=/^(?:date(?:time-local)?|month|time|week)$/,N=/(?:date(?:time-local)?|month|number|range|time|week)$/,g=/^(?:email|number|password|search|tel|text|url)$/;switch(i){case"any-link":case"link":{s.test(c)&&e.hasAttribute("href")&&t.add(e);break}case"local-link":{if(s.test(c)&&e.hasAttribute("href")){const{href:h,origin:m,pathname:u}=new URL(this.#t.URL),y=new URL(e.getAttribute("href"),h);y.origin===m&&y.pathname===u&&t.add(e)}break}case"visited":break;case"hover":{const{target:h,type:m}=this.#p??{};(m==="mouseover"||m==="pointerover")&&e.contains(h)&&t.add(e);break}case"active":{const{buttons:h,target:m,type:u}=this.#p??{};(u==="mousedown"||u==="pointerdown")&&h&b.BIT_01&&e.contains(m)&&t.add(e);break}case"target":{const{hash:h}=new URL(this.#t.URL);e.id&&h===`#${e.id}`&&this.#t.contains(e)&&t.add(e);break}case"target-within":{const{hash:h}=new URL(this.#t.URL);if(h){const m=h.replace(/^#/,"");let u=this.#t.getElementById(m);for(;u;){if(u===e){t.add(e);break}u=u.parentNode}}break}case"scope":{this.#e.nodeType===b.ELEMENT_NODE?!this.#u&&e===this.#e&&t.add(e):e===this.#t.documentElement&&t.add(e);break}case"focus":case"focus-visible":{const{target:h,type:m}=this.#p??{};if(e===this.#t.activeElement&&e.tabIndex>=0&&(i==="focus"||m==="keydown"&&e.contains(h))){let u=e,y=!0;for(;u;){if(u.disabled||u.hasAttribute("disabled")||u.hidden||u.hasAttribute("hidden")){y=!1;break}else{const{display:v,visibility:E}=this.#l.getComputedStyle(u);if(y=!(v==="none"||E==="hidden"),!y)break}if(u.parentNode&&u.parentNode.nodeType===b.ELEMENT_NODE)u=u.parentNode;else break}y&&t.add(e)}break}case"focus-within":{let h,m=this.#t.activeElement;if(m.tabIndex>=0)for(;m;){if(m===e){h=!0;break}m=m.parentNode}if(h){let u=e,y=!0;for(;u;){if(u.disabled||u.hasAttribute("disabled")||u.hidden||u.hasAttribute("hidden")){y=!1;break}else{const{display:v,visibility:E}=this.#l.getComputedStyle(u);if(y=!(v==="none"||E==="hidden"),!y)break}if(u.parentNode&&u.parentNode.nodeType===b.ELEMENT_NODE)u=u.parentNode;else break}y&&t.add(e)}break}case"open":{_.test(c)&&e.hasAttribute("open")&&t.add(e);break}case"closed":{_.test(c)&&!e.hasAttribute("open")&&t.add(e);break}case"disabled":{if(o.test(c)||(0,P.default)(c))if(e.disabled||e.hasAttribute("disabled"))t.add(e);else{let h=n;for(;h&&h.localName!=="fieldset";)h=h.parentNode;h&&n.localName!=="legend"&&h.hasAttribute("disabled")&&t.add(e)}break}case"enabled":{(o.test(c)||(0,P.default)(c))&&!(e.disabled&&e.hasAttribute("disabled"))&&t.add(e);break}case"read-only":{switch(c){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}case"input":{(!e.type||k.test(e.type)||g.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,C.isContentEditable)(e)||t.add(e)}break}case"read-write":{switch(c){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||t.add(e);break}case"input":{(!e.type||k.test(e.type)||g.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,C.isContentEditable)(e)&&t.add(e)}break}case"placeholder-shown":{let h;c==="textarea"?h=e:c==="input"&&(e.hasAttribute("type")?g.test(e.getAttribute("type"))&&(h=e):h=e),h&&e.value===""&&e.hasAttribute("placeholder")&&e.getAttribute("placeholder").trim().length&&t.add(e);break}case"checked":{(e.checked&&c==="input"&&e.hasAttribute("type")&&w.test(e.getAttribute("type"))||e.selected&&c==="option")&&t.add(e);break}case"indeterminate":{if(e.indeterminate&&c==="input"&&e.type==="checkbox"||c==="progress"&&!e.hasAttribute("value"))t.add(e);else if(c==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const h=e.name;let m=e.parentNode;for(;m&&m.localName!=="form";)m=m.parentNode;m||(m=this.#t.documentElement);const u=m.getElementsByTagName("input"),y=u.length;let v;for(let E=0;E<y;E++){const S=u[E];if(S.getAttribute("type")==="radio"&&(h?S.getAttribute("name")===h&&(v=!!S.checked):S.hasAttribute("name")||(v=!!S.checked),v))break}v||t.add(e)}break}case"default":{const h=/^(?:button|reset)$/,m=/^(?:image|submit)$/;if(c==="button"&&!(e.hasAttribute("type")&&h.test(e.getAttribute("type")))||c==="input"&&e.hasAttribute("type")&&m.test(e.getAttribute("type"))){let u=e.parentNode;for(;u&&u.localName!=="form";)u=u.parentNode;if(u){const y=this.#n;let v=this._traverse(u,y);for(v=y.firstChild();v&&u.contains(v);){const E=v.localName;let S;if(E==="button"?S=!(v.hasAttribute("type")&&h.test(v.getAttribute("type"))):E==="input"&&(S=v.hasAttribute("type")&&m.test(v.getAttribute("type"))),S){v===e&&t.add(e);break}v=y.nextNode()}}}else if(c==="input"&&e.hasAttribute("type")&&w.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))t.add(e);else if(c==="option"){let u=n,y=!1;for(;u&&u.localName!=="datalist";){if(u.localName==="select"){(u.multiple||u.hasAttribute("multiple"))&&(y=!0);break}u=u.parentNode}if(y)(e.selected||e.hasAttribute("selected"))&&t.add(e);else{const v=new Set,E=this.#n;let S=this._traverse(n,E);for(S=E.firstChild();S;){if(S.selected||S.hasAttribute("selected")){v.add(S);break}S=E.nextSibling()}v.size&&v.has(e)&&t.add(e)}}break}case"valid":{if(p.test(c))e.checkValidity()&&t.add(e);else if(c==="fieldset"){const h=this.#n;let m=this._traverse(e,h);m=h.firstChild();let u;for(;m&&e.contains(m)&&!(p.test(m.localName)&&(u=m.checkValidity(),!u));)m=h.nextNode();u&&t.add(e)}break}case"invalid":{if(p.test(c))e.checkValidity()||t.add(e);else if(c==="fieldset"){const h=this.#n;let m=this._traverse(e,h);m=h.firstChild();let u;for(;m&&e.contains(m)&&!(p.test(m.localName)&&(u=m.checkValidity(),!u));)m=h.nextNode();u||t.add(e)}break}case"in-range":{c==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&N.test(e.getAttribute("type"))&&!(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(e.hasAttribute("min")||e.hasAttribute("max")||e.getAttribute("type")==="range")&&t.add(e);break}case"out-of-range":{c==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&N.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&t.add(e);break}case"required":{let h;if(/^(?:select|textarea)$/.test(c))h=e;else if(c==="input")if(e.hasAttribute("type")){const m=e.getAttribute("type");(m==="file"||w.test(m)||k.test(m)||g.test(m))&&(h=e)}else h=e;h&&(e.required||e.hasAttribute("required"))&&t.add(e);break}case"optional":{let h;if(/^(?:select|textarea)$/.test(c))h=e;else if(c==="input")if(e.hasAttribute("type")){const m=e.getAttribute("type");(m==="file"||w.test(m)||k.test(m)||g.test(m))&&(h=e)}else h=e;h&&!(e.required||e.hasAttribute("required"))&&t.add(e);break}case"root":{e===this.#t.documentElement&&t.add(e);break}case"empty":{if(e.hasChildNodes()){const h=this.#d.createTreeWalker(e,b.SHOW_ALL);let m=h.firstChild(),u;for(;m&&(u=m.nodeType!==b.ELEMENT_NODE&&m.nodeType!==b.TEXT_NODE,!!u);)m=h.nextSibling();u&&t.add(e)}else t.add(e);break}case"first-child":{(n&&e===n.firstElementChild||e===this.#s)&&t.add(e);break}case"last-child":{(n&&e===n.lastElementChild||e===this.#s)&&t.add(e);break}case"only-child":{(n&&e===n.firstElementChild&&e===n.lastElementChild||e===this.#s)&&t.add(e);break}case"first-of-type":{if(n){const[h]=this._collectNthOfType({a:0,b:1},e);h&&t.add(h)}else e===this.#s&&t.add(e);break}case"last-of-type":{if(n){const[h]=this._collectNthOfType({a:0,b:1,reverse:!0},e);h&&t.add(h)}else e===this.#s&&t.add(e);break}case"only-of-type":{if(n){const[h]=this._collectNthOfType({a:0,b:1},e);if(h===e){const[m]=this._collectNthOfType({a:0,b:1,reverse:!0},e);m===e&&t.add(e)}}else e===this.#s&&t.add(e);break}case"defined":{const h=e.getAttribute("is");h?(0,P.default)(h)&&this.#l.customElements.get(h)&&t.add(e):(0,P.default)(c)?this.#l.customElements.get(c)&&t.add(e):(e instanceof this.#l.HTMLElement||e instanceof this.#l.SVGElement)&&t.add(e);break}case"popover-open":{if(e.popover){const{display:h}=this.#l.getComputedStyle(e);h!=="none"&&t.add(e)}break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(f){const h=`Unsupported pseudo-element ::${i}`;throw new DOMException(h,b.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(f){const h=`Unsupported pseudo-class :${i}`;throw new DOMException(h,b.NOT_SUPPORTED_ERR)}break}default:if(i.startsWith("-webkit-")){if(f){const h=`Unsupported pseudo-class :${i}`;throw new DOMException(h,b.NOT_SUPPORTED_ERR)}}else if(!d){const h=`Unknown pseudo-class :${i}`;throw new DOMException(h,b.SYNTAX_ERR)}}}return t}_matchShadowHostPseudoClass(a,e){const{children:r,name:l}=a;let i;if(Array.isArray(r)){const{branches:c}=(0,x.walkAST)(r[0]),[n]=c,[...d]=n,{host:f}=e;if(l==="host"){let t;for(const s of d){const{type:o}=s;if(o===b.COMBINATOR){const _=`Invalid selector ${(0,x.generateCSS)(a)}`;throw new DOMException(_,b.SYNTAX_ERR)}if(t=this._matchSelector(s,f).has(f),!t)break}t&&(i=e)}else if(l==="host-context"){let t=f,s;for(;t;){for(const o of d){const{type:p}=o;if(p===b.COMBINATOR){const w=`Invalid selector ${(0,x.generateCSS)(a)}`;throw new DOMException(w,b.SYNTAX_ERR)}if(s=this._matchSelector(o,t).has(t),!s)break}if(s)break;t=t.parentNode}s&&(i=e)}}else if(l==="host")i=e;else{const c=`Invalid selector :${l}`;throw new DOMException(c,b.SYNTAX_ERR)}return i??null}_matchSelector(a,e,r){const{type:l}=a,i=new Set;if(a.name===b.EMPTY)return i;const c=(0,x.unescapeSelector)(a.name);if(typeof c=="string"&&c!==a.name&&(a.name=c),e.nodeType===b.ELEMENT_NODE)switch(l){case b.SELECTOR_PSEUDO_ELEMENT:{$.matcher.matchPseudoElementSelector(c,r);break}case b.SELECTOR_ID:{e.id===c&&i.add(e);break}case b.SELECTOR_CLASS:{e.classList.contains(c)&&i.add(e);break}case b.SELECTOR_PSEUDO_CLASS:return this._matchPseudoClassSelector(a,e,r);default:{const n=$.matcher.matchSelector(a,e,r);n&&i.add(n)}}else if(this.#u&&l===b.SELECTOR_PSEUDO_CLASS&&e.nodeType===b.DOCUMENT_FRAGMENT_NODE){if(c!=="has"&&b.REG_LOGICAL_PSEUDO.test(c))return this._matchPseudoClassSelector(a,e,r);if(b.REG_SHADOW_HOST.test(c)){const n=this._matchShadowHostPseudoClass(a,e,r);n&&i.add(n)}}return i}_matchLeaves(a,e,r){const{attributes:l,localName:i,nodeType:c}=e;let n=this.#_.get(a),d;if(n&&n.has(e)){const{attr:f,matched:t}=n.get(e);l?.length===f&&(d=t)}if(typeof d!="boolean"){const f=/^(?:(?:fieldse|inpu|selec)t|button|form|textarea)$/;let t;c===b.ELEMENT_NODE&&f.test(i)?t=!1:t=!0;for(const s of a){const{name:o,type:p}=s;if(p===b.SELECTOR_PSEUDO_CLASS&&o==="dir"&&(t=!1),d=this._matchSelector(s,e,r).has(e),!d)break}t&&(n||(n=new WeakMap),n.set(e,{attr:l?.length,matched:d}),this.#_.set(a,n))}return!!d}_matchHTMLCollection(a,e={}){const{compound:r,filterLeaves:l}=e,i=new Set,c=a.length;if(c)if(r)for(let n=0;n<c;n++){const d=a[n];this._matchLeaves(l,d,e)&&i.add(d)}else{const n=[].slice.call(a);return new Set(n)}return i}_findDescendantNodes(a,e,r){const[l,...i]=a,c=i.length>0,{type:n}=l,d=(0,x.unescapeSelector)(l.name);typeof d=="string"&&d!==l.name&&(l.name=d);let f=new Set,t=!1;if(this.#u)t=!0;else switch(n){case b.SELECTOR_PSEUDO_ELEMENT:{$.matcher.matchPseudoElementSelector(d,r);break}case b.SELECTOR_ID:{if(this.#s.nodeType===b.ELEMENT_NODE)t=!0;else{const s=this.#s.getElementById(d);s&&s!==e&&e.contains(s)&&(c?this._matchLeaves(i,s,r)&&f.add(s):f.add(s))}break}case b.SELECTOR_CLASS:{const s=e.getElementsByClassName(d);f=this._matchHTMLCollection(s,{compound:c,filterLeaves:i});break}case b.SELECTOR_TYPE:{if(this.#t.contentType==="text/html"&&!/[*|]/.test(d)){const s=e.getElementsByTagName(d);f=this._matchHTMLCollection(s,{compound:c,filterLeaves:i})}else t=!0;break}default:t=!0}return{nodes:f,pending:t}}_matchCombinator(a,e,r={}){const{combo:l,leaves:i}=a,{name:c}=l,{parentNode:n}=e,{dir:d}=r,f=new Set;if(d===T)switch(c){case"+":{const t=e.nextElementSibling;t&&this._matchLeaves(i,t,r)&&f.add(t);break}case"~":{if(n){const t=this._createTreeWalker(n);let s=this._traverse(e,t);for(s=t.nextSibling();s;)this._matchLeaves(i,s,r)&&f.add(s),s=t.nextSibling()}break}case">":{const t=this._createTreeWalker(e);let s=this._traverse(e,t);for(s=t.firstChild();s;)this._matchLeaves(i,s,r)&&f.add(s),s=t.nextSibling();break}case" ":default:{const{nodes:t,pending:s}=this._findDescendantNodes(i,e);if(t.size)return t;if(s){const o=this._createTreeWalker(e);let p=this._traverse(e,o);for(p=o.nextNode();p&&e.contains(p);)this._matchLeaves(i,p,r)&&f.add(p),p=o.nextNode()}}}else switch(c){case"+":{const t=e.previousElementSibling;t&&this._matchLeaves(i,t,r)&&f.add(t);break}case"~":{if(n){const t=this._createTreeWalker(n);let s=this._traverse(n,t);for(s=t.firstChild();s&&s!==e;)this._matchLeaves(i,s,r)&&f.add(s),s=t.nextSibling()}break}case">":{n&&this._matchLeaves(i,n,r)&&f.add(n);break}case" ":default:{const t=[];let s=n;for(;s;)this._matchLeaves(i,s,r)&&t.push(s),s=s.parentNode;if(t.length)return new Set(t.reverse())}}return f}_findNode(a,e){const{node:r}=e;let l=this._traverse(r,this.#o),i;if(l)for(l.nodeType!==b.ELEMENT_NODE?l=this.#o.nextNode():l===r&&l!==this.#s&&(l=this.#o.nextNode());l;){if(this._matchLeaves(a,l,{warn:this.#i})){i=l;break}l=this.#o.nextNode()}return i??null}_matchSelf(a){const e=[],r=this._matchLeaves(a,this.#e,{warn:this.#i});let l=!1;return r&&(e.push(this.#e),l=!0),[e,l]}_findLineal(a,e={}){const{complex:r}=e,l=[];let i=this._matchLeaves(a,this.#e,{warn:this.#i}),c=!1;if(i&&(l.push(this.#e),c=!0),!i||r){let n=this.#e.parentNode;for(;n&&(i=this._matchLeaves(a,n,{warn:this.#i}),i&&(l.push(n),c=!0),n.parentNode);)n=n.parentNode}return[l,c]}_findFirst(a){const e=[],r=this._findNode(a,{node:this.#e});let l=!1;return r&&(e.push(r),l=!0),[e,l]}_findFromHTMLCollection(a,e={}){const{complex:r,compound:l,filterLeaves:i,targetType:c}=e;let n=[],d=!1,f=!1;const t=a.length;if(t)if(this.#e.nodeType===b.ELEMENT_NODE)for(let s=0;s<t;s++){const o=a[s];if(o!==this.#e&&(this.#e.contains(o)||o.contains(this.#e))){if(l){if(this._matchLeaves(i,o,{warn:this.#i})&&(n.push(o),d=!0,c===L))break}else if(n.push(o),d=!0,c===L)break}}else if(r)if(l)for(let s=0;s<t;s++){const o=a[s];if(this._matchLeaves(i,o,{warn:this.#i})&&(n.push(o),d=!0,c===L))break}else n=[].slice.call(a),d=!0,f=!0;else if(l)for(let s=0;s<t;s++){const o=a[s];if(this._matchLeaves(i,o,{warn:this.#i})&&(n.push(o),d=!0,c===L))break}else n=[].slice.call(a),d=!0,f=!0;return[n,d,f]}_findEntryNodes(a,e,r){const{leaves:l}=a,[i,...c]=l,n=c.length>0,{name:d,type:f}=i;let t=[],s=!1,o=!1,p=!1;switch(f){case b.SELECTOR_PSEUDO_ELEMENT:{$.matcher.matchPseudoElementSelector(d,{warn:this.#i});break}case b.SELECTOR_ID:{if(e===D)[t,o]=this._matchSelf(l);else if(e===R)[t,o]=this._findLineal(l,{complex:r});else if(e===L&&this.#s.nodeType!==b.ELEMENT_NODE){const _=this.#s.getElementById(d);_&&(n?this._matchLeaves(c,_,{warn:this.#i})&&(t.push(_),o=!0):(t.push(_),o=!0))}else e===L?[t,o]=this._findFirst(l):p=!0;break}case b.SELECTOR_CLASS:{if(e===D)[t,o]=this._matchSelf(l);else if(e===R)[t,o]=this._findLineal(l,{complex:r});else if(this.#s.nodeType===b.DOCUMENT_NODE){const _=this.#s.getElementsByClassName(d);_.length&&([t,o,s]=this._findFromHTMLCollection(_,{complex:r,compound:n,filterLeaves:c,targetType:e}))}else e===L?[t,o]=this._findFirst(l):p=!0;break}case b.SELECTOR_TYPE:{if(e===D)[t,o]=this._matchSelf(l);else if(e===R)[t,o]=this._findLineal(l,{complex:r});else if(this.#t.contentType==="text/html"&&this.#s.nodeType===b.DOCUMENT_NODE&&!/[*|]/.test(d)){const _=this.#s.getElementsByTagName(d);_.length&&([t,o,s]=this._findFromHTMLCollection(_,{complex:r,compound:n,filterLeaves:c,targetType:e}))}else e===L?[t,o]=this._findFirst(l):p=!0;break}default:if(e!==R&&b.REG_SHADOW_HOST.test(d)){if(this.#u&&this.#e.nodeType===b.DOCUMENT_FRAGMENT_NODE){const _=this._matchShadowHostPseudoClass(i,this.#e);_&&(t.push(_),o=!0)}}else e===D?[t,o]=this._matchSelf(l):e===R?[t,o]=this._findLineal(l,{complex:r}):e===L?[t,o]=this._findFirst(l):p=!0}return{collected:s,compound:n,filtered:o,nodes:t,pending:p}}_collectNodes(a){const e=this.#a.values();if(a===M||a===L){const r=new Set;let l=0;for(const{branch:i}of e){const c=i.length,n=c>1,d=i[0];let f,t;if(n){const{combo:k,leaves:[{name:N,type:g}]}=d,h=i[c-1],{leaves:[{name:m,type:u}]}=h;if(u===b.SELECTOR_PSEUDO_ELEMENT||u===b.SELECTOR_ID)f=O,t=h;else if(g===b.SELECTOR_PSEUDO_ELEMENT||g===b.SELECTOR_ID)f=T,t=d;else if(a===M)if(N==="*"&&g===b.SELECTOR_TYPE)f=O,t=h;else if(m==="*"&&u===b.SELECTOR_TYPE)f=T,t=d;else if(c===2){const{name:y}=k;/^[+~]$/.test(y)?(f=O,t=h):(f=T,t=d)}else f=T,t=d;else if(m==="*"&&u===b.SELECTOR_TYPE)f=T,t=d;else if(N==="*"&&g===b.SELECTOR_TYPE)f=O,t=h;else{let y;for(const{combo:v,leaves:[E]}of i){const{name:S,type:W}=E;if(W===b.SELECTOR_PSEUDO_CLASS&&S==="dir"){y=!1;break}if(!y&&v){const{name:H}=v;/^[+~]$/.test(H)&&(y=!0)}}y?(f=T,t=d):(f=O,t=h)}}else f=O,t=d;const{collected:s,compound:o,filtered:p,nodes:_,pending:w}=this._findEntryNodes(t,a,n);_.length?(this.#a[l].find=!0,this.#b[l]=_):w&&r.add(new Map([["index",l],["twig",t]])),this.#a[l].collected=s,this.#a[l].dir=f,this.#a[l].filtered=p||!o,l++}if(r.size){let i,c;this.#e!==this.#s&&this.#e.nodeType===b.ELEMENT_NODE?(i=this.#e,c=this.#o):(i=this.#s,c=this.#n);let n=this._traverse(i,c);for(;n;){let d=!1;if(this.#e.nodeType===b.ELEMENT_NODE?n===this.#e?d=!0:d=this.#e.contains(n):d=!0,d)for(const f of r){const{leaves:t}=f.get("twig");if(this._matchLeaves(t,n,{warn:this.#i})){const o=f.get("index");this.#a[o].filtered=!0,this.#a[o].find=!0,this.#b[o].push(n)}}n!==c.currentNode&&(n=this._traverse(n,c)),n=c.nextNode()}}}else{let r=0;for(const{branch:l}of e){const i=l[l.length-1],c=l.length>1,{compound:n,filtered:d,nodes:f}=this._findEntryNodes(i,a,c);f.length&&(this.#a[r].find=!0,this.#b[r]=f),this.#a[r].dir=O,this.#a[r].filtered=d||!n,r++}}return[this.#a,this.#b]}_getCombinedNodes(a,e,r){const l=[];for(const i of e){const c=this._matchCombinator(a,i,{dir:r,warn:this.#i});c.size&&l.push(...c)}return l.length?new Set(l):new Set}_matchNodeNext(a,e,r){const{combo:l,index:i}=r,{combo:c,leaves:n}=a[i],d={combo:l,leaves:n},f=this._getCombinedNodes(d,e,T);let t;if(f.size)if(i===a.length-1){const[s]=(0,C.sortNodes)(f);t=s}else t=this._matchNodeNext(a,f,{combo:c,index:i+1});return t??null}_matchNodePrev(a,e,r){const{index:l}=r,i=a[l],c=new Set([e]),n=this._getCombinedNodes(i,c,O);let d;if(n.size){if(l===0)d=e;else for(const f of n)if(this._matchNodePrev(a,f,{index:l-1}))return e}return d??null}_find(a){(a===M||a===L)&&this._prepareQuerySelectorWalker();const[[...e],r]=this._collectNodes(a),l=e.length;let i=new Set;for(let c=0;c<l;c++){const{branch:n,collected:d,dir:f,find:t}=e[c],s=n.length;if(s&&t){const o=r[c],p=o.length,_=s-1;if(_===0)if((a===M||a===L)&&this.#e.nodeType===b.ELEMENT_NODE)for(let w=0;w<p;w++){const k=o[w];if(k!==this.#e&&this.#e.contains(k)&&(i.add(k),a!==M))break}else if(a===M)if(i.size){const w=[...i];i=new Set([...w,...o]),this.#m=!0}else i=new Set(o);else{const[w]=o;i.add(w)}else if(a===M)if(f===T){let{combo:w}=n[0];for(const k of o){let N=new Set([k]);for(let g=1;g<s;g++){const{combo:h,leaves:m}=n[g],u={combo:w,leaves:m};if(N=this._getCombinedNodes(u,N,f),N.size)if(g===_)if(i.size){const y=[...i];i=new Set([...y,...N]),this.#m=!0}else i=N;else w=h;else break}}}else for(const w of o){let k=new Set([w]);for(let N=_-1;N>=0;N--){const g=n[N];if(k=this._getCombinedNodes(g,k,f),k.size)N===0&&(i.add(w),s>1&&i.size>1&&(this.#m=!0));else break}}else if(a===L&&f===T){const{combo:w}=n[0];let k;for(const N of o)if(k=this._matchNodeNext(n,new Set([N]),{combo:w,index:1}),k){i.add(k);break}if(!k&&!d){const{leaves:N}=n[0],[g]=o;let h=this._findNode(N,{node:g});for(;h;){if(k=this._matchNodeNext(n,new Set([h]),{combo:w,index:1}),k){i.add(k);break}h=this._findNode(N,{node:h})}}}else{let w;for(const k of o)if(w=this._matchNodePrev(n,k,{index:_-1}),w){i.add(k);break}if(!w&&!d&&a===L){const{leaves:k}=n[_],[N]=o;let g=this._findNode(k,{node:N});for(;g;){if(w=this._matchNodePrev(n,g,{index:_-1}),w){i.add(g);break}g=this._findNode(k,{node:g})}}}}}return i}matches(a,e,r){let l;try{if(e?.nodeType!==b.ELEMENT_NODE){const i=`Unexpected node ${e?.nodeName}`;throw new TypeError(i)}(0,x.filterSelector)(a,{complex:this.#c,descendant:!0})?l=this.#f.match(a,e):(this._setup(a,e,r),l=this._find(D).size)}catch(i){this._onError(i)}return!!l}closest(a,e,r){let l;try{if(e?.nodeType!==b.ELEMENT_NODE){const i=`Unexpected node ${e?.nodeName}`;throw new TypeError(i)}if((0,x.filterSelector)(a,{complex:this.#c,descendant:!0}))l=this.#f.closest(a,e);else{this._setup(a,e,r);const i=this._find(R);if(i.size){let c=this.#e;for(;c;){if(i.has(c)){l=c;break}c=c.parentNode}}}}catch(i){this._onError(i)}return l??null}querySelector(a,e,r){let l;try{if(this._setup(a,e,r),this.#d===this.#t&&!this.#h&&(0,x.filterSelector)(a,{complex:this.#c,descendant:!1}))l=this.#f.first(a,e);else{const i=this._find(L);i.delete(this.#e),i.size&&([l]=(0,C.sortNodes)(i))}}catch(i){this._onError(i)}return l??null}querySelectorAll(a,e,r){let l;try{if(this._setup(a,e,r),this.#d===this.#t&&!this.#h&&(0,x.filterSelector)(a,{complex:this.#c,descendant:!1}))l=this.#f.select(a,e);else{const i=this._find(M);i.delete(this.#e),i.size&&(this.#m?l=(0,C.sortNodes)(i):l=[...i])}}catch(i){this._onError(i)}return l??[]}}0&&(module.exports={Finder});
2
2
  //# sourceMappingURL=finder.js.map