@asamuzakjp/dom-selector 1.1.2 → 1.1.4

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
@@ -234,7 +234,7 @@ const dom = new JSDOM('', {
234
234
 
235
235
  ### Performance
236
236
 
237
- |Method / Selector|Jsdom|Patched-jsdom|Result|
237
+ |Method / Selector|Jsdom v22.1.0 (nwsapi)|Patched-jsdom|Result|
238
238
  |:----------------|:----------------|:----------------|:----------------|
239
239
  |matches('.container.box')|2,103,531 ops/sec ±16.53%|113,370 ops/sec ±9.63%|jsdom is 18.6 times faster. patched-jsdom took 0.009msec.|
240
240
  |matches('.container:not(.box)')|1,103,421 ops/sec ±0.13%|75,746 ops/sec ±0.14%|jsdom is 14.6 times faster. patched-jsdom took 0.013msec.|
@@ -255,7 +255,7 @@ const dom = new JSDOM('', {
255
255
  |querySelector('.container.box')|80,132 ops/sec ±1.31%|23,699 ops/sec ±1.43%|jsdom is 3.4 times faster. patched-jsdom took 0.042msec.|
256
256
  |querySelector('.container:not(.box)')|69,928 ops/sec ±1.42%|17,739 ops/sec ±1.21%|jsdom is 3.9 times faster. patched-jsdom took 0.056msec.|
257
257
  |querySelector('.box + .box')|65,958 ops/sec ±1.35%|18,716 ops/sec ±1.41%|jsdom is 3.5 times faster. patched-jsdom took 0.053msec.|
258
- |jsdom querySelector('.box ~ .box')|67,535 ops/sec ±1.53%|8,419 ops/sec ±1.24%|jsdom is 8.0 times faster. patched-jsdom took 0.119msec.|
258
+ |querySelector('.box ~ .box')|67,535 ops/sec ±1.53%|8,419 ops/sec ±1.24%|jsdom is 8.0 times faster. patched-jsdom took 0.119msec.|
259
259
  |querySelector('.box > .block')|1,039 ops/sec ±1.61%|2,782 ops/sec ±0.84%|patched-jsdom is 2.7 times faster. patched-jsdom took 0.359msec.|
260
260
  |querySelector('.box .content')|492 ops/sec ±1.52%|259 ops/sec ±1.19%|jsdom is 1.9 times faster. patched-jsdom took 3.867msec.|
261
261
  |querySelector('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner > .content')|202 ops/sec ±1.21%|430 ops/sec ±0.86%|patched-jsdom is 2.1 times faster. patched-jsdom took 2.323msec.|
@@ -264,7 +264,7 @@ const dom = new JSDOM('', {
264
264
  |querySelectorAll('.container:not(.box)')|81,439 ops/sec ±1.22%|16,083 ops/sec ±1.86%|jsdom is 5.1 times faster. patched-jsdom took 0.062msec.|
265
265
  |querySelectorAll('.box + .box')|80,091 ops/sec ±1.29%|18,897 ops/sec ±0.09%|jsdom is 4.2 times faster. patched-jsdom took 0.053msec.|
266
266
  |querySelectorAll('.box ~ .box')|80,555 ops/sec ±0.11%|8,200 ops/sec ±1.90%|jsdom is 9.8 times faster. patched-jsdom took 0.122msec.|
267
- |jsdom querySelectorAll('.box > .block')|937 ops/sec ±1.40%|2,378 ops/sec ±0.97%|patched-jsdom is 2.5 times faster. patched-jsdom took 0.421msec.|
267
+ |querySelectorAll('.box > .block')|937 ops/sec ±1.40%|2,378 ops/sec ±0.97%|patched-jsdom is 2.5 times faster. patched-jsdom took 0.421msec.|
268
268
  |querySelectorAll('.box .content')|480 ops/sec ±1.08%|240 ops/sec ±1.03%|jsdom is 2.0 times faster. patched-jsdom took 4.160msec.|
269
269
  |querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner > .content')|202 ops/sec ±1.25%|427 ops/sec ±0.86%|patched-jsdom is 2.1 times faster. patched-jsdom took 2.342msec.|
270
270
  |querySelectorAll('.box:first-child ~ .box:nth-of-type(4n+1) + .box .block.inner:has(> .content)')|N/A|365 ops/sec ±0.81%|jsdom throws. patched-jsdom took 2.737msec.|
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var T=(o,t)=>{for(var r in t)E(o,r,{get:t[r],enumerable:!0})},_=(o,t,r,x)=>{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:!(x=s(t,e))||x.enumerable});return o};var p=o=>_(E({},"__esModule",{value:!0}),o);var V={};T(V,{ALPHA_NUM:()=>O,AN_PLUS_B:()=>S,BIT_01:()=>d,BIT_02:()=>i,BIT_04:()=>u,BIT_08:()=>W,BIT_16:()=>Y,BIT_32:()=>h,COMBINATOR:()=>N,DOCUMENT_FRAGMENT_NODE:()=>Z,DOCUMENT_NODE:()=>g,DOCUMENT_POSITION_CONTAINED_BY:()=>q,DOCUMENT_POSITION_CONTAINS:()=>k,DOCUMENT_POSITION_PRECEDING:()=>j,DUO:()=>X,ELEMENT_NODE:()=>y,HEX:()=>$,IDENTIFIER:()=>I,MAX_BIT_16:()=>b,NOT_SUPPORTED_ERR:()=>R,NTH:()=>D,RAW:()=>C,REG_LOGICAL_PSEUDO:()=>z,REG_SHADOW_HOST:()=>J,REG_SHADOW_MODE:()=>K,REG_SHADOW_PSEUDO:()=>Q,SELECTOR:()=>A,SELECTOR_ATTR:()=>L,SELECTOR_CLASS:()=>P,SELECTOR_ID:()=>l,SELECTOR_LIST:()=>M,SELECTOR_PSEUDO_CLASS:()=>U,SELECTOR_PSEUDO_ELEMENT:()=>F,SELECTOR_TYPE:()=>B,SHOW_ELEMENT:()=>v,STRING:()=>G,SYNTAX_ERR:()=>H,TEXT_NODE:()=>f,TYPE_FROM:()=>m,TYPE_TO:()=>w,U_FFFD:()=>a});module.exports=p(V);const O="[A-Z\\d]+",S="AnPlusB",N="Combinator",I="Identifier",R="NotSupportedError",D="Nth",C="Raw",A="Selector",L="AttributeSelector",P="ClassSelector",l="IdSelector",M="SelectorList",U="PseudoClassSelector",F="PseudoElementSelector",B="TypeSelector",G="String",H="SyntaxError",a="\uFFFD",d=1,i=2,u=4,W=8,Y=16,h=32,X=2,$=16,b=65535,m=8,w=-1,y=1,f=3,g=9,Z=11,j=2,k=8,q=16,v=1,z=/^(?:(?:ha|i)s|not|where)$/,J=/^host(?:-context)?$/,K=/^(?:close|open)$/,Q=/^part|slotted$/;0&&(module.exports={ALPHA_NUM,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,COMBINATOR,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,HEX,IDENTIFIER,MAX_BIT_16,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_ELEMENT,STRING,SYNTAX_ERR,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD});
1
+ var E=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var T=(o,t)=>{for(var r in t)E(o,r,{get:t[r],enumerable:!0})},_=(o,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of n(t))!x.call(o,e)&&e!==r&&E(o,e,{get:()=>t[e],enumerable:!(s=c(t,e))||s.enumerable});return o};var p=o=>_(E({},"__esModule",{value:!0}),o);var tt={};T(tt,{ALPHA_NUM:()=>O,AN_PLUS_B:()=>S,BIT_01:()=>d,BIT_02:()=>i,BIT_04:()=>u,BIT_08:()=>Y,BIT_16:()=>W,BIT_32:()=>h,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:()=>$,ELEMENT_NODE:()=>f,HEX:()=>b,IDENTIFIER:()=>I,MAX_BIT_16:()=>m,NOT_SUPPORTED_ERR:()=>D,NTH:()=>R,RAW:()=>C,REG_LOGICAL_PSEUDO:()=>J,REG_SHADOW_HOST:()=>K,REG_SHADOW_MODE:()=>Q,REG_SHADOW_PSEUDO:()=>V,SELECTOR:()=>A,SELECTOR_ATTR:()=>L,SELECTOR_CLASS:()=>P,SELECTOR_ID:()=>l,SELECTOR_LIST:()=>M,SELECTOR_PSEUDO_CLASS:()=>U,SELECTOR_PSEUDO_ELEMENT:()=>F,SELECTOR_TYPE:()=>B,SHOW_ELEMENT:()=>z,STRING:()=>H,SYNTAX_ERR:()=>G,TEXT_NODE:()=>g,TYPE_FROM:()=>w,TYPE_TO:()=>y,U_FFFD:()=>a});module.exports=p(tt);const O="[A-Z\\d]+",S="AnPlusB",N="Combinator",I="Identifier",D="NotSupportedError",R="Nth",C="Raw",A="Selector",L="AttributeSelector",P="ClassSelector",l="IdSelector",M="SelectorList",U="PseudoClassSelector",F="PseudoElementSelector",B="TypeSelector",H="String",G="SyntaxError",a="\uFFFD",d=1,i=2,u=4,Y=8,W=16,h=32,X=45,$=2,b=16,m=65535,w=8,y=-1,f=1,g=3,Z=9,j=11,k=2,q=8,v=16,z=1,J=/^(?:(?:ha|i)s|not|where)$/,K=/^host(?:-context)?$/,Q=/^(?:close|open)$/,V=/^part|slotted$/;0&&(module.exports={ALPHA_NUM,AN_PLUS_B,BIT_01,BIT_02,BIT_04,BIT_08,BIT_16,BIT_32,BIT_HYPHEN,COMBINATOR,DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_PRECEDING,DUO,ELEMENT_NODE,HEX,IDENTIFIER,MAX_BIT_16,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_ELEMENT,STRING,SYNTAX_ERR,TEXT_NODE,TYPE_FROM,TYPE_TO,U_FFFD});
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 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 = 0x1;\nexport const BIT_02 = 0x2;\nexport const BIT_04 = 0x4;\nexport const BIT_08 = 0x8;\nexport const BIT_16 = 0x10;\nexport const BIT_32 = 0x20;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const MAX_BIT_16 = 0xFFFF;\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 = 0x2;\nexport const DOCUMENT_POSITION_CONTAINS = 0x8;\nexport const DOCUMENT_POSITION_CONTAINED_BY = 0x10;\n\n/* NodeFilter */\nexport const SHOW_ELEMENT = 0x1;\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,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,cAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,WAAAC,EAAA,eAAAC,EAAA,2BAAAC,EAAA,kBAAAC,EAAA,mCAAAC,EAAA,+BAAAC,EAAA,gCAAAC,EAAA,QAAAC,EAAA,iBAAAC,EAAA,QAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,sBAAAC,EAAA,QAAAC,EAAA,QAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,sBAAAC,EAAA,aAAAC,EAAA,kBAAAC,EAAA,mBAAAC,EAAA,gBAAAC,EAAA,kBAAAC,EAAA,0BAAAC,EAAA,4BAAAC,EAAA,kBAAAC,EAAA,iBAAAC,EAAA,WAAAC,EAAA,eAAAC,EAAA,cAAAC,EAAA,cAAAC,EAAA,YAAAC,EAAA,WAAAC,IAAA,eAAAC,EAAA3C,GAKO,MAAME,EAAY,YACZC,EAAY,UACZO,EAAa,aACbS,EAAa,aACbE,EAAoB,oBACpBC,EAAM,MACNC,EAAM,MACNK,EAAW,WACXC,EAAgB,oBAChBC,EAAiB,gBACjBC,EAAc,aACdC,EAAgB,eAChBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAgB,eAChBE,EAAS,SACTC,EAAa,cACbI,EAAS,SAGTtC,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAS,GACTC,EAAS,GACTO,EAAM,EACNE,EAAM,GACNE,EAAa,MACboB,EAAY,EACZC,EAAU,GAGVxB,EAAe,EACfsB,EAAY,EACZ3B,EAAgB,EAChBD,EAAyB,GACzBI,EAA8B,EAC9BD,EAA6B,EAC7BD,EAAiC,GAGjCuB,EAAe,EAGfZ,EAAqB,4BACrBC,EAAkB,sBAClBC,EAAkB,mBAClBC,EAAoB",
6
- "names": ["constant_exports", "__export", "ALPHA_NUM", "AN_PLUS_B", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "COMBINATOR", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "HEX", "IDENTIFIER", "MAX_BIT_16", "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_ELEMENT", "STRING", "SYNTAX_ERR", "TEXT_NODE", "TYPE_FROM", "TYPE_TO", "U_FFFD", "__toCommonJS"]
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 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_HYPHEN = 0x2D;\nexport const DUO = 2;\nexport const HEX = 16;\nexport const MAX_BIT_16 = 0xFFFF;\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_ELEMENT = 1;\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,eAAAC,EAAA,eAAAC,EAAA,2BAAAC,EAAA,kBAAAC,EAAA,mCAAAC,EAAA,+BAAAC,EAAA,gCAAAC,EAAA,QAAAC,EAAA,iBAAAC,EAAA,QAAAC,EAAA,eAAAC,EAAA,eAAAC,EAAA,sBAAAC,EAAA,QAAAC,EAAA,QAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,oBAAAC,EAAA,sBAAAC,EAAA,aAAAC,EAAA,kBAAAC,EAAA,mBAAAC,EAAA,gBAAAC,EAAA,kBAAAC,EAAA,0BAAAC,EAAA,4BAAAC,EAAA,kBAAAC,EAAA,iBAAAC,EAAA,WAAAC,EAAA,eAAAC,EAAA,cAAAC,EAAA,cAAAC,EAAA,YAAAC,EAAA,WAAAC,IAAA,eAAAC,EAAA5C,IAKO,MAAME,EAAY,YACZC,EAAY,UACZQ,EAAa,aACbS,EAAa,aACbE,EAAoB,oBACpBC,EAAM,MACNC,EAAM,MACNK,EAAW,WACXC,EAAgB,oBAChBC,EAAiB,gBACjBC,EAAc,aACdC,EAAgB,eAChBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAgB,eAChBE,EAAS,SACTC,EAAa,cACbI,EAAS,SAGTvC,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAS,EACTC,EAAS,GACTC,EAAS,GACTC,EAAa,GACbO,EAAM,EACNE,EAAM,GACNE,EAAa,MACboB,EAAY,EACZC,EAAU,GAGVxB,EAAe,EACfsB,EAAY,EACZ3B,EAAgB,EAChBD,EAAyB,GACzBI,EAA8B,EAC9BD,EAA6B,EAC7BD,EAAiC,GAGjCuB,EAAe,EAGfZ,EAAqB,4BACrBC,EAAkB,sBAClBC,EAAkB,mBAClBC,EAAoB",
6
+ "names": ["constant_exports", "__export", "ALPHA_NUM", "AN_PLUS_B", "BIT_01", "BIT_02", "BIT_04", "BIT_08", "BIT_16", "BIT_32", "BIT_HYPHEN", "COMBINATOR", "DOCUMENT_FRAGMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_POSITION_CONTAINED_BY", "DOCUMENT_POSITION_CONTAINS", "DOCUMENT_POSITION_PRECEDING", "DUO", "ELEMENT_NODE", "HEX", "IDENTIFIER", "MAX_BIT_16", "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_ELEMENT", "STRING", "SYNTAX_ERR", "TEXT_NODE", "TYPE_FROM", "TYPE_TO", "U_FFFD", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var y=Object.create;var p=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var i in t)p(e,i,{get:t[i],enumerable:!0})},N=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!g.call(e,n)&&n!==i&&p(e,n,{get:()=>t[n],enumerable:!(r=E(t,n))||r.enumerable});return e};var O=(e,t,i)=>(i=e!=null?y(D(e)):{},N(t||!e||!e.__esModule?p(i,"default",{value:e,enumerable:!0}):i,e)),C=e=>N(p({},"__esModule",{value:!0}),e);var A={};h(A,{getDirectionality:()=>m,getSlottedTextContent:()=>u,isContentEditable:()=>T,isInShadowTree:()=>d,isNamespaceDeclared:()=>w,isSameOrDescendant:()=>_,selectorToNodeProps:()=>v});module.exports=C(A);var b=O(require("bidi-js"),1),s=require("./constant.js");const c=(0,b.default)(),d=(e={})=>{let t;if(e.nodeType===s.ELEMENT_NODE||e.nodeType===s.DOCUMENT_FRAGMENT_NODE){let i=e;for(;i;){const{host:r,mode:n,nodeType:l,parentNode:f}=i;if(r&&n&&l===s.DOCUMENT_FRAGMENT_NODE&&s.REG_SHADOW_MODE.test(n)){t=!0;break}i=f}}return!!t},u=(e={})=>{let t;if(e.localName==="slot"&&d(e)){const i=e.assignedNodes();if(i.length){for(const r of i)if(t=r.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},m=(e={})=>{let t;if(e.nodeType===s.ELEMENT_NODE){const{dir:i,localName:r,parentNode:n}=e,l="ltr",f="rtl";if(/^(?:ltr|rtl)$/.test(i))t=i;else if(i==="auto"){let o;if(r==="textarea"||r==="input"&&(!e.type||/^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/.test(e.type))?o=e.value:r==="slot"?o=u(e):o=e.textContent.trim(),o){const{paragraphs:[{level:a}]}=c.getEmbeddingLevels(o);a%2===1?t=f:t=l}if(!t)if(n){const{nodeType:a}=n;a===s.ELEMENT_NODE?t=m(n):(a===s.DOCUMENT_NODE||a===s.DOCUMENT_FRAGMENT_NODE)&&(t=l)}else t=l}else if(r==="bdi"){const o=e.textContent.trim();if(o){const{paragraphs:[{level:a}]}=c.getEmbeddingLevels(o);a%2===1?t=f:t=l}t||n||(t=l)}else if(r==="input"&&e.type==="tel")t=l;else if(n){if(r==="slot"){const o=u(e);if(o){const{paragraphs:[{level:a}]}=c.getEmbeddingLevels(o);a%2===1?t=f:t=l}}if(!t){const{nodeType:o}=n;o===s.ELEMENT_NODE?t=m(n):(o===s.DOCUMENT_NODE||o===s.DOCUMENT_FRAGMENT_NODE)&&(t=l)}}else t=l}return t??null},T=(e={})=>{let t;if(e.nodeType===s.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const i=e.getAttribute("contenteditable");if(i===""||/^(?:plaintext-only|true)$/.test(i))t=!0;else if(i==="inherit"){let r=e.parentNode;for(;r;){if(T(r)){t=!0;break}r=r.parentNode}}}}return!!t},w=(e="",t={})=>{let i;if(e&&typeof e=="string"&&t.nodeType===s.ELEMENT_NODE){const r=`xmlns:${e}`,n=t.ownerDocument.documentElement;let l=t;for(;l;){if(typeof l.hasAttribute=="function"&&l.hasAttribute(r)){i=!0;break}else if(l===n)break;l=l.parentNode}}return!!i},_=(e={},t={})=>{let i;return e.ownerDocument&&e.nodeType===s.ELEMENT_NODE&&((!t||t.nodeType!==s.ELEMENT_NODE)&&(t=e.ownerDocument),e===t?i=!0:t&&(i=t.compareDocumentPosition(e)&s.DOCUMENT_POSITION_CONTAINED_BY)),!!i},v=(e,t)=>{let i,r;if(e&&typeof e=="string")/\|/.test(e)?[i,r]=e.split("|"):(i="*",r=e);else throw new DOMException(`invalid selector ${e}`,s.SYNTAX_ERR);return{prefix:i,tagName:r}};0&&(module.exports={getDirectionality,getSlottedTextContent,isContentEditable,isInShadowTree,isNamespaceDeclared,isSameOrDescendant,selectorToNodeProps});
1
+ var b=Object.create;var a=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var i in t)a(e,i,{get:t[i],enumerable:!0})},u=(e,t,i,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!E.call(e,n)&&n!==i&&a(e,n,{get:()=>t[n],enumerable:!(l=T(t,n))||l.enumerable});return e};var g=(e,t,i)=>(i=e!=null?b(y(e)):{},u(t||!e||!e.__esModule?a(i,"default",{value:e,enumerable:!0}):i,e)),h=e=>u(a({},"__esModule",{value:!0}),e);var _={};D(_,{getDirectionality:()=>c,getSlottedTextContent:()=>p,isContentEditable:()=>d,isInShadowTree:()=>N,isNamespaceDeclared:()=>O,isSameOrDescendant:()=>C,selectorToNodeProps:()=>w});module.exports=h(_);var m=g(require("bidi-js"),1),s=require("./constant.js");const f=(0,m.default)(),N=(e={})=>{let t;if(e.nodeType===s.ELEMENT_NODE||e.nodeType===s.DOCUMENT_FRAGMENT_NODE){let i=e;for(;i;){const{host:l,mode:n,nodeType:r,parentNode:o}=i;if(l&&n&&r===s.DOCUMENT_FRAGMENT_NODE&&s.REG_SHADOW_MODE.test(n)){t=!0;break}i=o}}return!!t},p=(e={})=>{let t;if(e.localName==="slot"&&N(e)){const i=e.assignedNodes();if(i.length){for(const l of i)if(t=l.textContent.trim(),t)break}else t=e.textContent.trim()}return t??null},c=(e={})=>{let t;if(e.nodeType===s.ELEMENT_NODE){const{dir:i,localName:l,parentNode:n}=e;if(/^(?:ltr|rtl)$/.test(i))t=i;else if(i==="auto"){let r;if(l==="textarea"||l==="input"&&(!e.type||/^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/.test(e.type))?r=e.value:l==="slot"?r=p(e):r=e.textContent.trim(),r){const{paragraphs:[{level:o}]}=f.getEmbeddingLevels(r);o%2===1?t="rtl":t="ltr"}if(!t)if(n){const{nodeType:o}=n;o===s.ELEMENT_NODE?t=c(n):(o===s.DOCUMENT_NODE||o===s.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}else t="ltr"}else if(l==="bdi"){const r=e.textContent.trim();if(r){const{paragraphs:[{level:o}]}=f.getEmbeddingLevels(r);o%2===1?t="rtl":t="ltr"}t||n||(t="ltr")}else if(l==="input"&&e.type==="tel")t="ltr";else if(n){if(l==="slot"){const r=p(e);if(r){const{paragraphs:[{level:o}]}=f.getEmbeddingLevels(r);o%2===1?t="rtl":t="ltr"}}if(!t){const{nodeType:r}=n;r===s.ELEMENT_NODE?t=c(n):(r===s.DOCUMENT_NODE||r===s.DOCUMENT_FRAGMENT_NODE)&&(t="ltr")}}else t="ltr"}return t??null},d=(e={})=>{let t;if(e.nodeType===s.ELEMENT_NODE){if(typeof e.isContentEditable=="boolean")t=e.isContentEditable;else if(e.ownerDocument.designMode==="on")t=!0;else if(e.hasAttribute("contenteditable")){const i=e.getAttribute("contenteditable");if(i===""||/^(?:plaintext-only|true)$/.test(i))t=!0;else if(i==="inherit"){let l=e.parentNode;for(;l;){if(d(l)){t=!0;break}l=l.parentNode}}}}return!!t},O=(e="",t={})=>{let i;if(e&&typeof e=="string"&&t.nodeType===s.ELEMENT_NODE){const l=`xmlns:${e}`,n=t.ownerDocument.documentElement;let r=t;for(;r;){if(typeof r.hasAttribute=="function"&&r.hasAttribute(l)){i=!0;break}else if(r===n)break;r=r.parentNode}}return!!i},C=(e={},t={})=>{let i;return e.ownerDocument&&e.nodeType===s.ELEMENT_NODE&&((!t||t.nodeType!==s.ELEMENT_NODE)&&(t=e.ownerDocument),e===t?i=!0:t&&(i=t.compareDocumentPosition(e)&s.DOCUMENT_POSITION_CONTAINED_BY)),!!i},w=(e,t)=>{let i,l;if(e&&typeof e=="string")e.indexOf("|")>-1?[i,l]=e.split("|"):(i="*",l=e);else throw new DOMException(`invalid selector ${e}`,s.SYNTAX_ERR);return{prefix:i,tagName:l}};0&&(module.exports={getDirectionality,getSlottedTextContent,isContentEditable,isInShadowTree,isNamespaceDeclared,isSameOrDescendant,selectorToNodeProps});
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_CONTAINED_BY,\n ELEMENT_NODE, REG_SHADOW_MODE, SYNTAX_ERR\n} from './constant.js';\n\n/* bidi */\nconst bidi = bidiFactory();\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 ltr = 'ltr';\n const rtl = 'rtl';\n if (/^(?:ltr|rtl)$/.test(nodeDir)) {\n res = nodeDir;\n } else if (nodeDir === 'auto') {\n let text;\n if (localName === 'textarea') {\n text = node.value;\n } else if (localName === 'input' &&\n (!node.type ||\n /^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/.test(node.type))) {\n text = node.value;\n } else if (localName === 'slot') {\n text = getSlottedTextContent(node);\n } else {\n text = node.textContent.trim();\n }\n if (text) {\n const { paragraphs: [{ level }] } = bidi.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 }] } = bidi.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 }] } = bidi.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 * 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 const attr = `xmlns:${ns}`;\n const root = node.ownerDocument.documentElement;\n let parent = node;\n while (parent) {\n if (typeof parent.hasAttribute === 'function' &&\n parent.hasAttribute(attr)) {\n res = true;\n break;\n } else if (parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n }\n return !!res;\n};\n\n/**\n * is node same or descendant of the root node\n * @param {object} node - Element node\n * @param {object} root - Document, DocumentFragment, Element node\n * @returns {boolean} - result\n */\nexport const isSameOrDescendant = (node = {}, root = {}) => {\n let res;\n if (node.ownerDocument && node.nodeType === ELEMENT_NODE) {\n if (!root || root.nodeType !== ELEMENT_NODE) {\n root = node.ownerDocument;\n }\n if (node === root) {\n res = true;\n } else if (root) {\n res = root.compareDocumentPosition(node) & DOCUMENT_POSITION_CONTAINED_BY;\n }\n }\n return !!res;\n};\n\n/**\n * selector to node properties - e.g. ns|E -> { prefix: ns, tagName: E }\n * @param {string} selector - type selector\n * @param {object} [node] - Element node\n * @returns {object} - node properties\n */\nexport const selectorToNodeProps = (selector, node) => {\n let prefix;\n let tagName;\n if (selector && typeof selector === 'string') {\n if (/\\|/.test(selector)) {\n [prefix, tagName] = selector.split('|');\n } else {\n prefix = '*';\n tagName = selector;\n }\n } else {\n throw new DOMException(`invalid selector ${selector}`, SYNTAX_ERR);\n }\n return {\n prefix,\n tagName\n };\n};\n"],
5
- "mappings": "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",
6
- "names": ["dom_util_exports", "__export", "getDirectionality", "getSlottedTextContent", "isContentEditable", "isInShadowTree", "isNamespaceDeclared", "isSameOrDescendant", "selectorToNodeProps", "__toCommonJS", "import_bidi_js", "import_constant", "bidi", "bidiFactory", "node", "bool", "refNode", "host", "mode", "nodeType", "parentNode", "res", "nodes", "item", "nodeDir", "localName", "ltr", "rtl", "text", "level", "parentNodeType", "attr", "parent", "ns", "root", "selector", "prefix", "tagName"]
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_CONTAINED_BY,\n ELEMENT_NODE, REG_SHADOW_MODE, SYNTAX_ERR\n} from './constant.js';\n\n/* bidi */\nconst bidi = bidiFactory();\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 if (/^(?:ltr|rtl)$/.test(nodeDir)) {\n res = nodeDir;\n } else if (nodeDir === 'auto') {\n let text;\n if (localName === 'textarea') {\n text = node.value;\n } else if (localName === 'input' &&\n (!node.type ||\n /^(?:(?:butto|hidde)n|(?:emai|te|ur)l|(?:rese|submi|tex)t|password|search)$/.test(node.type))) {\n text = node.value;\n } else if (localName === 'slot') {\n text = getSlottedTextContent(node);\n } else {\n text = node.textContent.trim();\n }\n if (text) {\n const { paragraphs: [{ level }] } = bidi.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 }] } = bidi.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 }] } = bidi.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 * 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 const attr = `xmlns:${ns}`;\n const root = node.ownerDocument.documentElement;\n let parent = node;\n while (parent) {\n if (typeof parent.hasAttribute === 'function' &&\n parent.hasAttribute(attr)) {\n res = true;\n break;\n } else if (parent === root) {\n break;\n }\n parent = parent.parentNode;\n }\n }\n return !!res;\n};\n\n/**\n * is node same or descendant of the root node\n * @param {object} node - Element node\n * @param {object} root - Document, DocumentFragment, Element node\n * @returns {boolean} - result\n */\nexport const isSameOrDescendant = (node = {}, root = {}) => {\n let res;\n if (node.ownerDocument && node.nodeType === ELEMENT_NODE) {\n if (!root || root.nodeType !== ELEMENT_NODE) {\n root = node.ownerDocument;\n }\n if (node === root) {\n res = true;\n } else if (root) {\n res = root.compareDocumentPosition(node) & DOCUMENT_POSITION_CONTAINED_BY;\n }\n }\n return !!res;\n};\n\n/**\n * selector to node properties - e.g. ns|E -> { prefix: ns, tagName: E }\n * @param {string} selector - type selector\n * @param {object} [node] - Element node\n * @returns {object} - node properties\n */\nexport const selectorToNodeProps = (selector, node) => {\n let prefix;\n let tagName;\n if (selector && typeof selector === 'string') {\n if (selector.indexOf('|') > -1) {\n [prefix, tagName] = selector.split('|');\n } else {\n prefix = '*';\n tagName = selector;\n }\n } else {\n throw new DOMException(`invalid selector ${selector}`, SYNTAX_ERR);\n }\n return {\n prefix,\n tagName\n };\n};\n"],
5
+ "mappings": "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",
6
+ "names": ["dom_util_exports", "__export", "getDirectionality", "getSlottedTextContent", "isContentEditable", "isInShadowTree", "isNamespaceDeclared", "isSameOrDescendant", "selectorToNodeProps", "__toCommonJS", "import_bidi_js", "import_constant", "bidi", "bidiFactory", "node", "bool", "refNode", "host", "mode", "nodeType", "parentNode", "res", "nodes", "item", "nodeDir", "localName", "text", "level", "parentNodeType", "attr", "parent", "ns", "root", "selector", "prefix", "tagName"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var B=Object.create;var P=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var H=(x,s)=>{for(var e in s)P(x,e,{get:s[e],enumerable:!0})},U=(x,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let h of F(s))!j.call(x,h)&&h!==e&&P(x,h,{get:()=>s[h],enumerable:!(c=z(s,h))||c.enumerable});return x};var G=(x,s,e)=>(e=x!=null?B(V(x)):{},U(s||!x||!x.__esModule?P(e,"default",{value:x,enumerable:!0}):e,x)),W=x=>U(P({},"__esModule",{value:!0}),x);var X={};H(X,{Matcher:()=>q});module.exports=W(X);var M=G(require("is-potential-custom-element-name"),1),E=require("./dom-util.js"),y=require("./parser.js"),o=require("./constant.js");const R="all",O="first",D="lineal",I="self";class q{#i;#l;#a;#e;#r;#t;#o;#c;#s;constructor(s,e,c={}){const{sort:h,warn:a}=c;this.#l=new Map([[o.SELECTOR_PSEUDO_ELEMENT,o.BIT_01],[o.SELECTOR_ID,o.BIT_02],[o.SELECTOR_CLASS,o.BIT_04],[o.SELECTOR_TYPE,o.BIT_08],[o.SELECTOR_ATTR,o.BIT_16],[o.SELECTOR_PSEUDO_CLASS,o.BIT_32]]),this.#a=new WeakMap,this.#o=s,this.#e=e,this.#c=!!h,this.#s=!!a,[this.#i,this.#r]=this._prepare(s),this.#t=this._getRoot(e)}_onError(s){if(s instanceof DOMException&&s.name===o.NOT_SUPPORTED_ERR)this.#s&&console.warn(s.message);else throw s}_getRoot(s=this.#e){let e,c;switch(s.nodeType){case o.DOCUMENT_NODE:{e=s,c=s;break}case o.DOCUMENT_FRAGMENT_NODE:{e=s.ownerDocument,c=s;break}case o.ELEMENT_NODE:{if((0,E.isSameOrDescendant)(s))e=s.ownerDocument,c=s.ownerDocument;else{let a=s;for(;a&&a.parentNode;)a=a.parentNode;e=a.ownerDocument,c=a}break}default:throw new TypeError(`Unexpected node ${s.nodeName}`)}const h=(0,E.isInShadowTree)(s);return{document:e,root:c,shadow:h}}_sortLeaves(s){const e=[...s];return e.length>1&&e.sort((c,h)=>{const{type:a}=c,{type:b}=h,p=this.#l.get(a),r=this.#l.get(b);let t;return p===r?t=0:p>r?t=1:t=-1,t}),e}_prepare(s=this.#o){const e=(0,y.parseSelector)(s),c=(0,y.walkAST)(e),h=[],a=[];let b=0;for(const[...p]of c){const r=[];let t=p.shift();if(t&&t.type!==o.COMBINATOR){const i=new Set;for(;t;){if(t.type===o.COMBINATOR){const[l]=p;if(l.type===o.COMBINATOR){const d=`Invalid combinator ${t.name}${l.name}`;throw new DOMException(d,o.SYNTAX_ERR)}r.push({combo:t,leaves:this._sortLeaves(i)}),i.clear()}else t&&i.add(t);if(p.length)t=p.shift();else{r.push({combo:null,leaves:this._sortLeaves(i)}),i.clear();break}}}h.push({branch:r,find:null,skip:!1}),a[b]=new Set,b++}return[h,a]}_collectNthChild(s,e){const{a:c,b:h,reverse:a,selector:b}=s,{parentNode:p}=e,r=new Set;let t;if(b&&(this.#a.has(b)?t=this.#a.get(b):(t=(0,y.walkAST)(b),this.#a.set(b,t))),p){const i=[...p.children],l=i.length;if(l){const d=new Set;if(t){const n=t.length;for(const f of i){let u;for(let m=0;m<n;m++){const N=t[m];if(u=this._matchLeaves(N,f),!u)break}u&&d.add(f)}}if(a&&i.reverse(),c===0){if(h>0&&h<=l){if(d.size)for(let n=0;n<l;n++){const f=i[n];if(d.has(f)){r.add(f);break}}else if(!b){const n=i[h-1];r.add(n)}}}else{let n=h-1;if(c>0)for(;n<0;)n+=c;if(n>=0&&n<l){let f=c>0?0:h-1;for(let u=0;u<l&&n>=0&&n<l;u++){const m=i[u];d.size?d.has(m)&&(f===n&&(r.add(m),n+=c),c>0?f++:f--):u===n&&(b||r.add(m),n+=c)}}}}}else{const{root:i}=this.#t;if(e===i&&i.nodeType===o.ELEMENT_NODE&&c+h===1)if(t){const l=t.length;let d;for(let n=0;n<l;n++){const f=t[n];if(d=this._matchLeaves(f,e),d)break}d&&r.add(e)}else r.add(e)}return r}_collectNthOfType(s,e){const{a:c,b:h,reverse:a}=s,{localName:b,parentNode:p,prefix:r}=e,t=new Set;if(p){const i=[...p.children],l=i.length;if(l)if(a&&i.reverse(),c===0){if(h>0&&h<=l){let d=0;for(let n=0;n<l;n++){const f=i[n],{localName:u,prefix:m}=f;if(u===b&&m===r){if(d===h-1){t.add(f);break}d++}}}}else{let d=h-1;if(c>0)for(;d<0;)d+=c;if(d>=0&&d<l){let n=c>0?0:h-1;for(let f=0;f<l;f++){const u=i[f],{localName:m,prefix:N}=u;if(m===b&&N===r){if(n===d&&(t.add(u),d+=c),d<0||d>=l)break;c>0?n++:n--}}}}}else{const{root:i}=this.#t;e===i&&i.nodeType===o.ELEMENT_NODE&&c+h===1&&t.add(e)}return t}_matchAnPlusB(s,e,c){const{nth:{a:h,b:a,name:b},selector:p}=s,r=(0,y.unescapeSelector)(b),t=new Map;r?(r==="even"?(t.set("a",2),t.set("b",0)):r==="odd"&&(t.set("a",2),t.set("b",1)),/last/.test(c)&&t.set("reverse",!0)):(typeof h=="string"&&/-?\d+/.test(h)?t.set("a",h*1):t.set("a",0),typeof a=="string"&&/-?\d+/.test(a)?t.set("b",a*1):t.set("b",0),/last/.test(c)&&t.set("reverse",!0));let i=new Set;if(t.has("a")&&t.has("b")){if(/^nth-(?:last-)?child$/.test(c)){p&&t.set("selector",p);const l=Object.fromEntries(t),d=this._collectNthChild(l,e);d.size&&(i=d)}else if(/^nth-(?:last-)?of-type$/.test(c)){const l=Object.fromEntries(t),d=this._collectNthOfType(l,e);d.size&&(i=d)}}return i}_matchPseudoElementSelector(s,e={}){const{forgive:c}=e;switch(s){case"after":case"backdrop":case"before":case"cue":case"cue-region":case"first-letter":case"first-line":case"file-selector-button":case"marker":case"placeholder":case"selection":case"target-text":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${s}`,o.NOT_SUPPORTED_ERR);break}case"part":case"slotted":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${s}()`,o.NOT_SUPPORTED_ERR);break}default:if(s.startsWith("-webkit-")){if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${s}`,o.NOT_SUPPORTED_ERR)}else if(!c)throw new DOMException(`Unknown pseudo-element ::${s}`,o.SYNTAX_ERR)}}_matchDirectionPseudoClass(s,e){const c=(0,y.unescapeSelector)(s.name),h=(0,E.getDirectionality)(e);let a;return c===h&&(a=e),a??null}_matchLanguagePseudoClass(s,e){const c=(0,y.unescapeSelector)(s.name);let h;if(c)if(c==="*")if(e.hasAttribute("lang"))e.getAttribute("lang")&&(h=e);else{let a=e.parentNode;for(;a;){if(a.hasAttribute("lang")){a.getAttribute("lang")&&(h=e);break}a=a.parentNode}}else{const a=`(?:-${o.ALPHA_NUM})*`;if(new RegExp(`^(?:\\*-)?${o.ALPHA_NUM}${a}$`,"i").test(c)){let p;if(/-/.test(c)){const[r,t,...i]=c.split("-");let l;r==="*"?l=`${o.ALPHA_NUM}${a}`:l=`${r}${a}`;const d=`-${t}${a}`,n=i.length;let f="";if(n)for(let u=0;u<n;u++)f+=`-${i[u]}${a}`;p=new RegExp(`^${l}${d}${f}$`,"i")}else p=new RegExp(`^${c}${a}$`,"i");if(e.hasAttribute("lang"))p.test(e.getAttribute("lang"))&&(h=e);else{let r=e.parentNode;for(;r;){if(r.hasAttribute("lang")){const t=r.getAttribute("lang");p.test(t)&&(h=e);break}r=r.parentNode}}}}return h??null}_matchHasPseudoFunc(s,e){let c;if(Array.isArray(s)&&s.length){const[h]=s,{type:a}=h;let b;a===o.COMBINATOR?b=s.shift():b={name:" ",type:o.COMBINATOR};const p=[];for(;s.length;){const[i]=s,{type:l}=i;if(l===o.COMBINATOR)break;p.push(s.shift())}const r={combo:b,leaves:p},t=this._matchCombinator(r,e,{find:"next"});if(t.size)if(s.length){for(const i of t)if(c=this._matchHasPseudoFunc(Object.assign([],s),i),c)break}else c=!0}return!!c}_matchLogicalPseudoFunc(s,e){const{astName:c="",branches:h=[],selector:a="",twigBranches:b=[]}=s;let p;if(c==="has")if(a.includes(":has("))p=null;else{const r=h.length;let t;for(let i=0;i<r;i++){const l=h[i];if(t=this._matchHasPseudoFunc(Object.assign([],l),e),t)break}t&&(p=e)}else{const r=/^(?:is|where)$/.test(c),t=b.length;let i;for(let l=0;l<t;l++){const d=b[l],n=d.length-1,{leaves:f}=d[n];if(i=this._matchLeaves(f,e,{forgive:r}),i&&n>0){let u=new Set([e]);for(let m=n-1;m>=0;m--){const N=d[m],k=[];for(const A of u){const L=this._matchCombinator(N,A,{forgive:r,find:"prev"});L.size&&k.push(...L)}if(k.length)if(m===0){i=!0;break}else u=new Set(k);else{i=!1;break}}}if(i)break}c==="not"?i||(p=e):i&&(p=e)}return p??null}_matchPseudoClassSelector(s,e,c={}){const{children:h}=s,{localName:a,parentNode:b}=e,{forgive:p}=c,r=(0,y.unescapeSelector)(s.name);let t=new Set;if(o.REG_LOGICAL_PSEUDO.test(r)){let i;if(this.#a.has(s))i=this.#a.get(s);else{const d=(0,y.walkAST)(s),n=[],f=[];for(const[...u]of d){for(const A of u){const L=(0,y.generateCSS)(A);n.push(L)}const m=[],N=new Set;let k=u.shift();for(;k;)if(k.type===o.COMBINATOR?(m.push({combo:k,leaves:[...N]}),N.clear()):k&&N.add(k),u.length)k=u.shift();else{m.push({combo:null,leaves:[...N]}),N.clear();break}f.push(m)}i={astName:r,branches:d,twigBranches:f,selector:n.join(",")},this.#a.set(s,i)}const l=this._matchLogicalPseudoFunc(i,e);l&&t.add(l)}else if(Array.isArray(h)){const[i]=h;if(/^nth-(?:last-)?(?:child|of-type)$/.test(r)){const l=this._matchAnPlusB(i,e,r);l.size&&(t=l)}else if(r==="dir"){const l=this._matchDirectionPseudoClass(i,e);l&&t.add(l)}else if(r==="lang"){const l=this._matchLanguagePseudoClass(i,e);l&&t.add(l)}else switch(r){case"current":case"nth-col":case"nth-last-col":{if(this.#s)throw new DOMException(`Unsupported pseudo-class :${r}()`,o.NOT_SUPPORTED_ERR);break}default:if(!p)throw new DOMException(`Unknown pseudo-class :${r}()`,o.SYNTAX_ERR)}}else{const{document:i,root:l}=this.#t,{documentElement:d}=i,n=new URL(i.URL),f=/^a(?:rea)?$/,u=/^(?:(?:fieldse|inpu|selec)t|button|opt(?:group|ion)|textarea)$/,m=/^(?:(?:(?:in|out)pu|selec)t|button|form|textarea)$/,N=/^d(?:etails|ialog)$/,k=/^(?:checkbox|radio)$/,A=/^(?:date(?:time-local)?|month|time|week)$/,L=/(?:(?:rang|tim)e|date(?:time-local)?|month|number|week)$/,$=/^(?:(?:emai|te|ur)l|number|password|search|text)$/;switch(r){case"any-link":case"link":{f.test(a)&&e.hasAttribute("href")&&t.add(e);break}case"local-link":{if(f.test(a)&&e.hasAttribute("href")){const g=new URL(e.getAttribute("href"),n.href);g.origin===n.origin&&g.pathname===n.pathname&&t.add(e)}break}case"visited":break;case"target":{e.id&&n.hash&&n.hash===`#${e.id}`&&(0,E.isSameOrDescendant)(e)&&t.add(e);break}case"target-within":{if(n.hash){const g=n.hash.replace(/^#/,"");let w=i.getElementById(g);for(;w;){if(w===e){t.add(e);break}w=w.parentNode}}break}case"scope":{this.#e.nodeType===o.ELEMENT_NODE?e===this.#e&&t.add(e):e===d&&t.add(e);break}case"focus":{e===i.activeElement&&t.add(e);break}case"focus-within":{let g=i.activeElement;for(;g;){if(g===e){t.add(e);break}g=g.parentNode}break}case"open":{N.test(a)&&e.hasAttribute("open")&&t.add(e);break}case"closed":{N.test(a)&&!e.hasAttribute("open")&&t.add(e);break}case"disabled":{if(u.test(a)||(0,M.default)(a))if(e.disabled||e.hasAttribute("disabled"))t.add(e);else{let g=b;for(;g&&g.localName!=="fieldset";)g=g.parentNode;g&&b.localName!=="legend"&&g.hasAttribute("disabled")&&t.add(e)}break}case"enabled":{(u.test(a)||(0,M.default)(a))&&!(e.disabled&&e.hasAttribute("disabled"))&&t.add(e);break}case"read-only":{switch(a){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}case"input":{(!e.type||A.test(e.type)||$.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,E.isContentEditable)(e)||t.add(e)}break}case"read-write":{switch(a){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||t.add(e);break}case"input":{(!e.type||A.test(e.type)||$.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,E.isContentEditable)(e)&&t.add(e)}break}case"placeholder-shown":{let g;a==="textarea"?g=e:a==="input"&&(e.hasAttribute("type")?$.test(e.getAttribute("type"))&&(g=e):g=e),g&&e.value===""&&e.hasAttribute("placeholder")&&e.getAttribute("placeholder").trim().length&&t.add(e);break}case"checked":{(e.checked&&a==="input"&&e.hasAttribute("type")&&k.test(e.getAttribute("type"))||e.selected&&a==="option")&&t.add(e);break}case"indeterminate":{if(e.indeterminate&&a==="input"&&e.type==="checkbox"||a==="progress"&&!e.hasAttribute("value"))t.add(e);else if(a==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const g=e.name;let w=e.parentNode;for(;w&&w.localName!=="form";)w=w.parentNode;w||(w=d);const _=[...w.getElementsByTagName("input")];let S;for(const v of _)if(v.getAttribute("type")==="radio"&&(g?v.getAttribute("name")===g&&(S=!!v.checked):v.hasAttribute("name")||(S=!!v.checked),S))break;S||t.add(e)}break}case"default":{const g=/^(?:button|reset)$/,w=/^(?:image|submit)$/;if(a==="button"&&!(e.hasAttribute("type")&&g.test(e.getAttribute("type")))||a==="input"&&e.hasAttribute("type")&&w.test(e.getAttribute("type"))){let _=e.parentNode;for(;_&&_.localName!=="form";)_=_.parentNode;if(_){const S=i.createNodeIterator(_,o.SHOW_ELEMENT);let v=S.nextNode();for(;v;){const C=v.localName;let T;if(C==="button"?T=!(v.hasAttribute("type")&&g.test(v.getAttribute("type"))):C==="input"&&(T=v.hasAttribute("type")&&w.test(v.getAttribute("type"))),T){v===e&&t.add(e);break}v=S.nextNode()}}}else if(a==="input"&&e.hasAttribute("type")&&k.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))t.add(e);else if(a==="option"){let _=!1,S=b;for(;S&&S.localName!=="datalist";){if(S.localName==="select"){(S.multiple||S.hasAttribute("multiple"))&&(_=!0);break}S=S.parentNode}if(_)(e.selected||e.hasAttribute("selected"))&&t.add(e);else{const v=b.firstElementChild,C=new Set;let T=v;for(;T;){if(T.selected||T.hasAttribute("selected")){C.add(T);break}T=T.nextElementSibling}C.size||C.add(v),C.has(e)&&t.add(e)}}break}case"valid":{if(m.test(a))e.checkValidity()&&t.add(e);else if(/^fieldset$/.test(a)){const g=i.createNodeIterator(e,o.SHOW_ELEMENT);let w=g.nextNode();w===e&&(w=g.nextNode());let _;for(;w&&!(m.test(w.localName)&&(_=w.checkValidity(),!_));)w=g.nextNode();_&&t.add(e)}break}case"invalid":{if(m.test(a))e.checkValidity()||t.add(e);else if(/^fieldset$/.test(a)){const g=i.createNodeIterator(e,o.SHOW_ELEMENT);let w=g.nextNode();w===e&&(w=g.nextNode());let _;for(;w&&!(m.test(w.localName)&&(_=w.checkValidity(),!_));)w=g.nextNode();_||t.add(e)}break}case"in-range":{a==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&L.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":{a==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&L.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&t.add(e);break}case"required":{let g;if(/^(?:select|textarea)$/.test(a))g=e;else if(a==="input")if(e.hasAttribute("type")){const w=e.getAttribute("type");(w==="file"||k.test(w)||A.test(w)||$.test(w))&&(g=e)}else g=e;g&&(e.required||e.hasAttribute("required"))&&t.add(e);break}case"optional":{let g;if(/^(?:select|textarea)$/.test(a))g=e;else if(a==="input")if(e.hasAttribute("type")){const w=e.getAttribute("type");(w==="file"||k.test(w)||A.test(w)||$.test(w))&&(g=e)}else g=e;g&&!(e.required||e.hasAttribute("required"))&&t.add(e);break}case"root":{e===d&&t.add(e);break}case"empty":{if(e.hasChildNodes()){const g=e.childNodes.values();let w;for(const _ of g)if(w=_.nodeType!==o.ELEMENT_NODE&&_.nodeType!==o.TEXT_NODE,!w)break;w&&t.add(e)}else t.add(e);break}case"first-child":{(b&&e===b.firstElementChild||e===l&&l.nodeType===o.ELEMENT_NODE)&&t.add(e);break}case"last-child":{(b&&e===b.lastElementChild||e===l&&l.nodeType===o.ELEMENT_NODE)&&t.add(e);break}case"only-child":{(b&&e===b.firstElementChild&&e===b.lastElementChild||e===l&&l.nodeType===o.ELEMENT_NODE)&&t.add(e);break}case"first-of-type":{if(b){const[g]=this._collectNthOfType({a:0,b:1},e);g&&t.add(g)}else e===l&&l.nodeType===o.ELEMENT_NODE&&t.add(e);break}case"last-of-type":{if(b){const[g]=this._collectNthOfType({a:0,b:1,reverse:!0},e);g&&t.add(g)}else e===l&&l.nodeType===o.ELEMENT_NODE&&t.add(e);break}case"only-of-type":{if(b){const[g]=this._collectNthOfType({a:0,b:1},e);if(g===e){const[w]=this._collectNthOfType({a:0,b:1,reverse:!0},e);w===e&&t.add(e)}}else e===l&&l.nodeType===o.ELEMENT_NODE&&t.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${r}`,o.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(this.#s)throw new DOMException(`Unsupported pseudo-class :${r}`,o.NOT_SUPPORTED_ERR);break}default:if(r.startsWith("-webkit-")){if(this.#s)throw new DOMException(`Unsupported pseudo-class :${r}`,o.NOT_SUPPORTED_ERR)}else if(!p)throw new DOMException(`Unknown pseudo-class :${r}`,o.SYNTAX_ERR)}}return t}_matchAttributeSelector(s,e){const{flags:c,matcher:h,name:a,value:b}=s;if(typeof c=="string"&&!/^[is]$/i.test(c)){const t=(0,y.generateCSS)(s);throw new DOMException(`Invalid selector ${t}`,o.SYNTAX_ERR)}const{attributes:p}=e;let r;if(p&&p.length){const{document:t}=this.#t;let i;t.contentType==="text/html"?typeof c=="string"&&/^s$/i.test(c)?i=!1:i=!0:typeof c=="string"&&/^i$/i.test(c)?i=!0:i=!1;let{name:l}=a;l=(0,y.unescapeSelector)(l),i&&(l=l.toLowerCase());const d=new Set;if(/\|/.test(l)){const{prefix:n,tagName:f}=(0,E.selectorToNodeProps)(l);for(let{name:u,value:m}of p)switch(i&&(u=u.toLowerCase(),m=m.toLowerCase()),n){case"":{f===u&&d.add(m);break}case"*":{/:/.test(u)?u.endsWith(`:${f}`)&&d.add(m):f===u&&d.add(m);break}default:if(/:/.test(u)){const[N,k]=u.split(":");n===N&&f===k&&(0,E.isNamespaceDeclared)(n,e)&&d.add(m)}}}else for(let{name:n,value:f}of p)if(i&&(n=n.toLowerCase(),f=f.toLowerCase()),/:/.test(n)){const[u,m]=n.split(":");if(u==="xml"&&m==="lang")continue;l===m&&d.add(f)}else l===n&&d.add(f);if(d.size){const{name:n,value:f}=b||{};let u;switch(n?i?u=n.toLowerCase():u=n:f?i?u=f.toLowerCase():u=f:f===""&&(u=f),h){case"=":{typeof u=="string"&&d.has(u)&&(r=e);break}case"~=":{if(u&&typeof u=="string"){for(const m of d)if(new Set(m.split(/\s+/)).has(u)){r=e;break}}break}case"|=":{if(u&&typeof u=="string"){let m;for(const N of d)if(N===u||N.startsWith(`${u}-`)){m=N;break}m&&(r=e)}break}case"^=":{if(u&&typeof u=="string"){let m;for(const N of d)if(N.startsWith(`${u}`)){m=N;break}m&&(r=e)}break}case"$=":{if(u&&typeof u=="string"){let m;for(const N of d)if(N.endsWith(`${u}`)){m=N;break}m&&(r=e)}break}case"*=":{if(u&&typeof u=="string"){let m;for(const N of d)if(N.includes(`${u}`)){m=N;break}m&&(r=e)}break}case null:default:r=e}}}return r??null}_matchClassSelector(s,e){const c=(0,y.unescapeSelector)(s.name);let h;return e.classList.contains(c)&&(h=e),h??null}_matchIDSelector(s,e){const c=(0,y.unescapeSelector)(s.name),{id:h}=e;let a;return c===h&&(a=e),a??null}_matchTypeSelector(s,e){const c=(0,y.unescapeSelector)(s.name),{localName:h,prefix:a}=e,{document:b}=this.#t;let{prefix:p,tagName:r}=(0,E.selectorToNodeProps)(c,e);b.contentType==="text/html"&&(p=p.toLowerCase(),r=r.toLowerCase());let t,i;/:/.test(h)?[t,i]=h.split(":"):(t=a||"",i=h);let l;return p===""&&t===""?e.namespaceURI===null&&(r==="*"||r===i)&&(l=e):p==="*"?(r==="*"||r===i)&&(l=e):p===t&&(0,E.isNamespaceDeclared)(p,e)&&(r==="*"||r===i)&&(l=e),l??null}_matchShadowHostPseudoClass(s,e){const{children:c}=s,h=(0,y.unescapeSelector)(s.name);let a;if(Array.isArray(c)){const[b]=(0,y.walkAST)(c[0]),[...p]=b,{host:r}=e;if(h==="host"){let t;for(const i of p){const{type:l}=i;if(l===o.COMBINATOR){const d=(0,y.generateCSS)(s);throw new DOMException(`Invalid selector ${d}`,o.SYNTAX_ERR)}if(t=this._matchSelector(i,r).has(r),!t)break}t&&(a=e)}else if(h==="host-context"){let t=r,i;for(;t;){for(const l of p){const{type:d}=l;if(d===o.COMBINATOR){const n=(0,y.generateCSS)(s);throw new DOMException(`Invalid selector ${n}`,o.SYNTAX_ERR)}if(i=this._matchSelector(l,t).has(t),!i)break}if(i)break;t=t.parentNode}i&&(a=e)}}else h==="host"&&(a=e);return a??null}_matchSelector(s,e,c){const{type:h}=s,a=(0,y.unescapeSelector)(s.name),{shadow:b}=this.#t;let p=new Set;if(e.nodeType===o.ELEMENT_NODE)switch(h){case o.SELECTOR_ATTR:{const r=this._matchAttributeSelector(s,e);r&&p.add(r);break}case o.SELECTOR_CLASS:{const r=this._matchClassSelector(s,e);r&&p.add(r);break}case o.SELECTOR_ID:{const r=this._matchIDSelector(s,e);r&&p.add(r);break}case o.SELECTOR_PSEUDO_CLASS:{const r=this._matchPseudoClassSelector(s,e,c);r.size&&(p=r);break}case o.SELECTOR_PSEUDO_ELEMENT:{this._matchPseudoElementSelector(a,c);break}case o.SELECTOR_TYPE:default:{const r=this._matchTypeSelector(s,e);r&&p.add(r)}}else if(b&&h===o.SELECTOR_PSEUDO_CLASS&&e.nodeType===o.DOCUMENT_FRAGMENT_NODE){if(a!=="has"&&o.REG_LOGICAL_PSEUDO.test(a)){const r=this._matchPseudoClassSelector(s,e,c);r.size&&(p=r)}else if(o.REG_SHADOW_HOST.test(a)){const r=this._matchShadowHostPseudoClass(s,e);r&&p.add(r)}}return p}_matchLeaves(s,e,c){let h;for(const a of s)if(h=this._matchSelector(a,e,c).has(e),!h)break;return!!h}_findDescendantNodes(s,e){const[c,...h]=s,{type:a}=c,b=(0,y.unescapeSelector)(c.name),p=h.length>0,r=new Set;let t=!1;switch(a){case o.SELECTOR_ID:{const{root:i}=this.#t;if(i.nodeType===o.ELEMENT_NODE)t=!0;else{const l=i.getElementById(b);if(l&&l!==e){const d=(0,E.isSameOrDescendant)(l,e);let n;d&&(n=l),n&&(p?this._matchLeaves(h,n)&&r.add(n):r.add(n))}}break}case o.SELECTOR_PSEUDO_ELEMENT:{this._matchPseudoElementSelector(b);break}default:t=!0}return{nodes:r,pending:t}}_matchCombinator(s,e,c={}){const{combo:h,leaves:a}=s,{name:b}=h,{find:p,forgive:r}=c;let t=new Set;if(p==="next")switch(b){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(a,i,{forgive:r})&&t.add(i);break}case"~":{let i=e.nextElementSibling;for(;i;)this._matchLeaves(a,i,{forgive:r})&&t.add(i),i=i.nextElementSibling;break}case">":{const i=[...e.children];for(const l of i)this._matchLeaves(a,l,{forgive:r})&&t.add(l);break}case" ":default:{const{nodes:i,pending:l}=this._findDescendantNodes(a,e);if(i.size)t=i;else if(l){const{document:d}=this.#t,n=d.createNodeIterator(e,o.SHOW_ELEMENT);let f=n.nextNode();for(f===e&&(f=n.nextNode());f;)this._matchLeaves(a,f,{forgive:r})&&t.add(f),f=n.nextNode()}}}else switch(b){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(a,i,{forgive:r})&&t.add(i);break}case"~":{const i=[];let l=e.previousElementSibling;for(;l;)this._matchLeaves(a,l,{forgive:r})&&i.push(l),l=l.previousElementSibling;i.length&&(t=new Set(i.reverse()));break}case">":{const i=e.parentNode;i&&this._matchLeaves(a,i,{forgive:r})&&t.add(i);break}case" ":default:{const i=[];let l=e.parentNode;for(;l;)this._matchLeaves(a,l,{forgive:r})&&i.push(l),l=l.parentNode;i.length&&(t=new Set(i.reverse()))}}return t}_findNodes(s,e){const{leaves:[c,...h]}=s,{type:a}=c,b=(0,y.unescapeSelector)(c.name),p=h.length>0,{document:r,root:t,shadow:i}=this.#t;let l=new Set,d=!1;switch(a){case o.SELECTOR_ID:{let n;if(e===I)this._matchLeaves([c],this.#e)&&(n=this.#e);else if(e===D){let f=this.#e;for(;f;){if(this._matchLeaves([c],f)){n=f;break}f=f.parentNode}}else t.nodeType===o.ELEMENT_NODE?d=!0:n=t.getElementById(b);n&&(p?this._matchLeaves(h,n)&&l.add(n):l.add(n));break}case o.SELECTOR_CLASS:{const n=[];if(e===I)this.#e.nodeType===o.ELEMENT_NODE&&this.#e.classList.contains(b)&&n.push(this.#e);else if(e===D){let f=this.#e;for(;f&&f.nodeType===o.ELEMENT_NODE;)f.classList.contains(b)&&n.push(f),f=f.parentNode}else if(t.nodeType===o.DOCUMENT_FRAGMENT_NODE){const f=[...t.children];for(const u of f){u.classList.contains(b)&&n.push(u);const m=[...u.getElementsByClassName(b)];n.push(...m)}}else{const f=[...t.getElementsByClassName(b)];n.push(...f)}if(n.length)if(p)for(const f of n)this._matchLeaves(h,f)&&l.add(f);else l=new Set(n);break}case o.SELECTOR_TYPE:{const n=[];if(e===I)this.#e.nodeType===o.ELEMENT_NODE&&this._matchLeaves([c],this.#e)&&n.push(this.#e);else if(e===D){let f=this.#e;for(;f&&f.nodeType===o.ELEMENT_NODE;)this._matchLeaves([c],f)&&n.push(f),f=f.parentNode}else if(r.contentType!=="text/html"||/[*|]/.test(b))d=!0;else if(t.nodeType===o.DOCUMENT_FRAGMENT_NODE){const f=b.toLowerCase(),u=[...t.children];for(const m of u){m.localName===f&&n.push(m);const N=[...m.getElementsByTagName(b)];n.push(...N)}}else{const f=[...t.getElementsByTagName(b)];n.push(...f)}if(n.length)if(p)for(const f of n)this._matchLeaves(h,f)&&l.add(f);else l=new Set(n);break}case o.SELECTOR_PSEUDO_ELEMENT:{this._matchPseudoElementSelector(b);break}default:{const n=[];if(e!==D&&o.REG_SHADOW_HOST.test(b)){if(i&&this.#e.nodeType===o.DOCUMENT_FRAGMENT_NODE){const f=this._matchShadowHostPseudoClass(c,this.#e);f&&n.push(f)}}else if(e===I)this._matchLeaves([c],this.#e)&&n.push(this.#e);else if(e===D){let f=this.#e;for(;f;)this._matchLeaves([c],f)&&n.push(f),f=f.parentNode}else d=!0;if(n.length)if(p)for(const f of n)this._matchLeaves(h,f)&&l.add(f);else l=new Set(n)}}return{nodes:l,pending:d}}_getFirstTwig(s){const e=s.length-1,c=s[0];let h,a;if(e){const b=s[e],{leaves:[{type:p}]}=b;p===o.SELECTOR_PSEUDO_ELEMENT||p===o.SELECTOR_ID?(h="prev",a=b):(h="next",a=c)}else h="prev",a=c;return{find:h,twig:a}}_collectNodes(s){const e=this.#i.values();if(s===R||s===O){const c=new Set;let h=0;for(const{branch:a}of e){const{find:b,twig:p}=this._getFirstTwig(a),{nodes:r,pending:t}=this._findNodes(p,s);r.size?this.#r[h]=r:t?c.add(new Map([["index",h],["twig",p]])):this.#i[h].skip=!0,this.#i[h].find=b,h++}if(c.size){const{document:a,root:b}=this.#t,p=a.createNodeIterator(b,o.SHOW_ELEMENT);let r=p.nextNode();for(;r;){let t=!1;if(this.#e.nodeType===o.ELEMENT_NODE?t=(0,E.isSameOrDescendant)(r,this.#e):t=!0,t)for(const i of c){const{leaves:l}=i.get("twig");if(this._matchLeaves(l,r)){const n=i.get("index");this.#r[n].add(r)}}r=p.nextNode()}}}else{let c=0;for(const{branch:h}of e){const a=h[h.length-1],{nodes:b}=this._findNodes(a,s);b.size?this.#r[c]=b:this.#i[c].skip=!0,this.#i[c].find="prev",c++}}return[this.#i,this.#r]}_sortNodes(s){const e=[...s];return e.length>1&&e.sort((c,h)=>{const a=c.compareDocumentPosition(h);let b;return a&o.DOCUMENT_POSITION_PRECEDING||a&o.DOCUMENT_POSITION_CONTAINS?b=1:b=-1,b}),e}_matchNodes(s){const[...e]=this.#i,c=e.length;let h=new Set;for(let a=0;a<c;a++){const{branch:b,find:p,skip:r}=e[a],t=b.length;if(!r&&t){const i=this.#r[a],l=t-1;if(l===0)if((s===R||s===O)&&this.#e.nodeType===o.ELEMENT_NODE){for(const d of i)if(d!==this.#e&&(0,E.isSameOrDescendant)(d,this.#e)&&(h.add(d),s===O))break}else if(s===O){const[d]=this._sortNodes(i);h.add(d)}else{const d=[...h],n=[...i];h=new Set([...d,...n])}else if(p==="next"){let{combo:d}=b[0];for(const n of i){let f=new Set([n]);for(let u=1;u<t;u++){const{combo:m,leaves:N}=b[u],k=[];for(const A of f){const L={combo:d,leaves:N},$=this._matchCombinator(L,A,{find:p});$.size&&k.push(...$)}if(k.length)if(u===l){if(s===O){const[A]=this._sortNodes(k);h.add(A)}else{const A=[...h];h=new Set([...A,...k])}break}else d=m,f=new Set(k);else break}}}else for(const d of i){let n=new Set([d]),f;for(let u=l-1;u>=0;u--){const m=b[u],N=[];for(const k of n){const A=this._matchCombinator(m,k,{find:p});A.size&&N.push(...A)}if(N.length)if(f=!0,u===0){h.add(d);break}else n=new Set(N);else{f=!1;break}}if(f&&s!==R)break}}}return h}_find(s){return this._collectNodes(s),this._matchNodes(s)}matches(){if(this.#e.nodeType!==o.ELEMENT_NODE)throw new TypeError(`Unexpected node ${this.#e.nodeName}`);let s;try{s=this._find(I).has(this.#e)}catch(e){this._onError(e)}return!!s}closest(){if(this.#e.nodeType!==o.ELEMENT_NODE)throw new TypeError(`Unexpected node ${this.#e.nodeName}`);let s;try{const e=this._find(D);let c=this.#e;for(;c;){if(e.has(c)){s=c;break}c=c.parentNode}}catch(e){this._onError(e)}return s??null}querySelector(){let s;try{const e=this._find(O);e.delete(this.#e),e.size>1?[s]=this._sortNodes(e):e.size&&([s]=[...e])}catch(e){this._onError(e)}return s??null}querySelectorAll(){const s=[];try{const e=this._find(R);e.delete(this.#e),e.size>1&&this.#c?s.push(...this._sortNodes(e)):e.size&&s.push(...e)}catch(e){this._onError(e)}return s}}0&&(module.exports={Matcher});
1
+ var F=Object.create;var P=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var W=(S,s)=>{for(var e in s)P(S,e,{get:s[e],enumerable:!0})},z=(S,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let h of j(s))!G.call(S,h)&&h!==e&&P(S,h,{get:()=>s[h],enumerable:!(c=V(s,h))||c.enumerable});return S};var q=(S,s,e)=>(e=S!=null?F(H(S)):{},z(s||!S||!S.__esModule?P(e,"default",{value:S,enumerable:!0}):e,S)),X=S=>z(P({},"__esModule",{value:!0}),S);var J={};W(J,{Matcher:()=>Y});module.exports=X(J);var B=q(require("is-potential-custom-element-name"),1),E=require("./dom-util.js"),y=require("./parser.js"),l=require("./constant.js");const R="next",M="prev",U="all",C="first",D="lineal",I="self";class Y{#i;#l;#a;#e;#r;#t;#o;#c;#s;constructor(s,e,c={}){const{sort:h,warn:a}=c;this.#l=new Map([[l.SELECTOR_PSEUDO_ELEMENT,l.BIT_01],[l.SELECTOR_ID,l.BIT_02],[l.SELECTOR_CLASS,l.BIT_04],[l.SELECTOR_TYPE,l.BIT_08],[l.SELECTOR_ATTR,l.BIT_16],[l.SELECTOR_PSEUDO_CLASS,l.BIT_32]]),this.#a=new WeakMap,this.#o=s,this.#e=e,this.#c=!!h,this.#s=!!a,[this.#i,this.#r]=this._prepare(s),this.#t=this._getRoot(e)}_onError(s){if(s instanceof DOMException&&s.name===l.NOT_SUPPORTED_ERR)this.#s&&console.warn(s.message);else throw s}_getRoot(s=this.#e){let e,c;switch(s.nodeType){case l.DOCUMENT_NODE:{e=s,c=s;break}case l.DOCUMENT_FRAGMENT_NODE:{e=s.ownerDocument,c=s;break}case l.ELEMENT_NODE:{if((0,E.isSameOrDescendant)(s))e=s.ownerDocument,c=s.ownerDocument;else{let a=s;for(;a&&a.parentNode;)a=a.parentNode;e=a.ownerDocument,c=a}break}default:throw new TypeError(`Unexpected node ${s.nodeName}`)}const h=(0,E.isInShadowTree)(s);return{document:e,root:c,shadow:h}}_sortLeaves(s){const e=[...s];return e.length>1&&e.sort((c,h)=>{const{type:a}=c,{type:b}=h,p=this.#l.get(a),r=this.#l.get(b);let t;return p===r?t=0:p>r?t=1:t=-1,t}),e}_prepare(s=this.#o){const e=(0,y.parseSelector)(s),c=(0,y.walkAST)(e),h=[],a=[];let b=0;for(const[...p]of c){const r=[];let t=p.shift();if(t&&t.type!==l.COMBINATOR){const i=new Set;for(;t;){if(t.type===l.COMBINATOR){const[o]=p;if(o.type===l.COMBINATOR){const d=`Invalid combinator ${t.name}${o.name}`;throw new DOMException(d,l.SYNTAX_ERR)}r.push({combo:t,leaves:this._sortLeaves(i)}),i.clear()}else t&&i.add(t);if(p.length)t=p.shift();else{r.push({combo:null,leaves:this._sortLeaves(i)}),i.clear();break}}}h.push({branch:r,find:null,skip:!1}),a[b]=new Set,b++}return[h,a]}_collectNthChild(s,e){const{a:c,b:h,reverse:a,selector:b}=s,{parentNode:p}=e,r=new Set;let t;if(b&&(this.#a.has(b)?t=this.#a.get(b):(t=(0,y.walkAST)(b),this.#a.set(b,t))),p){const i=[...p.children],o=i.length;if(o){const d=new Set;if(t){const n=t.length;for(const f of i){let u;for(let m=0;m<n;m++){const w=t[m];if(u=this._matchLeaves(w,f),!u)break}u&&d.add(f)}}if(a&&i.reverse(),c===0){if(h>0&&h<=o){if(d.size)for(let n=0;n<o;n++){const f=i[n];if(d.has(f)){r.add(f);break}}else if(!b){const n=i[h-1];r.add(n)}}}else{let n=h-1;if(c>0)for(;n<0;)n+=c;if(n>=0&&n<o){let f=c>0?0:h-1;for(let u=0;u<o&&n>=0&&n<o;u++){const m=i[u];d.size?d.has(m)&&(f===n&&(r.add(m),n+=c),c>0?f++:f--):u===n&&(b||r.add(m),n+=c)}}}}}else{const{root:i}=this.#t;if(e===i&&i.nodeType===l.ELEMENT_NODE&&c+h===1)if(t){const o=t.length;let d;for(let n=0;n<o;n++){const f=t[n];if(d=this._matchLeaves(f,e),d)break}d&&r.add(e)}else r.add(e)}return r}_collectNthOfType(s,e){const{a:c,b:h,reverse:a}=s,{localName:b,parentNode:p,prefix:r}=e,t=new Set;if(p){const i=[...p.children],o=i.length;if(o)if(a&&i.reverse(),c===0){if(h>0&&h<=o){let d=0;for(let n=0;n<o;n++){const f=i[n],{localName:u,prefix:m}=f;if(u===b&&m===r){if(d===h-1){t.add(f);break}d++}}}}else{let d=h-1;if(c>0)for(;d<0;)d+=c;if(d>=0&&d<o){let n=c>0?0:h-1;for(let f=0;f<o;f++){const u=i[f],{localName:m,prefix:w}=u;if(m===b&&w===r){if(n===d&&(t.add(u),d+=c),d<0||d>=o)break;c>0?n++:n--}}}}}else{const{root:i}=this.#t;e===i&&i.nodeType===l.ELEMENT_NODE&&c+h===1&&t.add(e)}return t}_matchAnPlusB(s,e,c){const{nth:{a:h,b:a,name:b},selector:p}=s,r=(0,y.unescapeSelector)(b),t=new Map;r?(r==="even"?(t.set("a",2),t.set("b",0)):r==="odd"&&(t.set("a",2),t.set("b",1)),c.indexOf("last")>-1&&t.set("reverse",!0)):(typeof h=="string"&&/-?\d+/.test(h)?t.set("a",h*1):t.set("a",0),typeof a=="string"&&/-?\d+/.test(a)?t.set("b",a*1):t.set("b",0),c.indexOf("last")>-1&&t.set("reverse",!0));let i=new Set;if(t.has("a")&&t.has("b")){if(/^nth-(?:last-)?child$/.test(c)){p&&t.set("selector",p);const o=Object.fromEntries(t),d=this._collectNthChild(o,e);d.size&&(i=d)}else if(/^nth-(?:last-)?of-type$/.test(c)){const o=Object.fromEntries(t),d=this._collectNthOfType(o,e);d.size&&(i=d)}}return i}_matchPseudoElementSelector(s,e={}){const{forgive:c}=e;switch(s){case"after":case"backdrop":case"before":case"cue":case"cue-region":case"first-letter":case"first-line":case"file-selector-button":case"marker":case"placeholder":case"selection":case"target-text":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${s}`,l.NOT_SUPPORTED_ERR);break}case"part":case"slotted":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${s}()`,l.NOT_SUPPORTED_ERR);break}default:if(s.startsWith("-webkit-")){if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${s}`,l.NOT_SUPPORTED_ERR)}else if(!c)throw new DOMException(`Unknown pseudo-element ::${s}`,l.SYNTAX_ERR)}}_matchDirectionPseudoClass(s,e){const c=(0,y.unescapeSelector)(s.name),h=(0,E.getDirectionality)(e);let a;return c===h&&(a=e),a??null}_matchLanguagePseudoClass(s,e){const c=(0,y.unescapeSelector)(s.name);let h;if(c)if(c==="*")if(e.hasAttribute("lang"))e.getAttribute("lang")&&(h=e);else{let a=e.parentNode;for(;a;){if(a.hasAttribute("lang")){a.getAttribute("lang")&&(h=e);break}a=a.parentNode}}else{const a=`(?:-${l.ALPHA_NUM})*`;if(new RegExp(`^(?:\\*-)?${l.ALPHA_NUM}${a}$`,"i").test(c)){let p;if(c.indexOf("-")>-1){const[r,t,...i]=c.split("-");let o;r==="*"?o=`${l.ALPHA_NUM}${a}`:o=`${r}${a}`;const d=`-${t}${a}`,n=i.length;let f="";if(n)for(let u=0;u<n;u++)f+=`-${i[u]}${a}`;p=new RegExp(`^${o}${d}${f}$`,"i")}else p=new RegExp(`^${c}${a}$`,"i");if(e.hasAttribute("lang"))p.test(e.getAttribute("lang"))&&(h=e);else{let r=e.parentNode;for(;r;){if(r.hasAttribute("lang")){const t=r.getAttribute("lang");p.test(t)&&(h=e);break}r=r.parentNode}}}}return h??null}_matchHasPseudoFunc(s,e){let c;if(Array.isArray(s)&&s.length){const[h]=s,{type:a}=h;let b;a===l.COMBINATOR?b=s.shift():b={name:" ",type:l.COMBINATOR};const p=[];for(;s.length;){const[i]=s,{type:o}=i;if(o===l.COMBINATOR)break;p.push(s.shift())}const r={combo:b,leaves:p},t=this._matchCombinator(r,e,{find:R});if(t.size)if(s.length){for(const i of t)if(c=this._matchHasPseudoFunc(Object.assign([],s),i),c)break}else c=!0}return!!c}_matchLogicalPseudoFunc(s,e){const{astName:c="",branches:h=[],selector:a="",twigBranches:b=[]}=s;let p;if(c==="has")if(a.includes(":has("))p=null;else{const r=h.length;let t;for(let i=0;i<r;i++){const o=h[i];if(t=this._matchHasPseudoFunc(Object.assign([],o),e),t)break}t&&(p=e)}else{const r=/^(?:is|where)$/.test(c),t=b.length;let i;for(let o=0;o<t;o++){const d=b[o],n=d.length-1,{leaves:f}=d[n];if(i=this._matchLeaves(f,e,{forgive:r}),i&&n>0){let u=new Set([e]);for(let m=n-1;m>=0;m--){const w=d[m],k=[];for(const A of u){const L=this._matchCombinator(w,A,{forgive:r,find:M});L.size&&k.push(...L)}if(k.length)if(m===0){i=!0;break}else u=new Set(k);else{i=!1;break}}}if(i)break}c==="not"?i||(p=e):i&&(p=e)}return p??null}_matchPseudoClassSelector(s,e,c={}){const{children:h}=s,{localName:a,parentNode:b}=e,{forgive:p}=c,r=(0,y.unescapeSelector)(s.name);let t=new Set;if(l.REG_LOGICAL_PSEUDO.test(r)){let i;if(this.#a.has(s))i=this.#a.get(s);else{const d=(0,y.walkAST)(s),n=[],f=[];for(const[...u]of d){for(const A of u){const L=(0,y.generateCSS)(A);n.push(L)}const m=[],w=new Set;let k=u.shift();for(;k;)if(k.type===l.COMBINATOR?(m.push({combo:k,leaves:[...w]}),w.clear()):k&&w.add(k),u.length)k=u.shift();else{m.push({combo:null,leaves:[...w]}),w.clear();break}f.push(m)}i={astName:r,branches:d,twigBranches:f,selector:n.join(",")},this.#a.set(s,i)}const o=this._matchLogicalPseudoFunc(i,e);o&&t.add(o)}else if(Array.isArray(h)){const[i]=h;if(/^nth-(?:last-)?(?:child|of-type)$/.test(r)){const o=this._matchAnPlusB(i,e,r);o.size&&(t=o)}else if(r==="dir"){const o=this._matchDirectionPseudoClass(i,e);o&&t.add(o)}else if(r==="lang"){const o=this._matchLanguagePseudoClass(i,e);o&&t.add(o)}else switch(r){case"current":case"nth-col":case"nth-last-col":{if(this.#s)throw new DOMException(`Unsupported pseudo-class :${r}()`,l.NOT_SUPPORTED_ERR);break}default:if(!p)throw new DOMException(`Unknown pseudo-class :${r}()`,l.SYNTAX_ERR)}}else{const{document:i,root:o}=this.#t,{documentElement:d}=i,n=new URL(i.URL),f=/^a(?:rea)?$/,u=/^(?:(?:fieldse|inpu|selec)t|button|opt(?:group|ion)|textarea)$/,m=/^(?:(?:(?:in|out)pu|selec)t|button|form|textarea)$/,w=/^d(?:etails|ialog)$/,k=/^(?:checkbox|radio)$/,A=/^(?:date(?:time-local)?|month|time|week)$/,L=/(?:(?:rang|tim)e|date(?:time-local)?|month|number|week)$/,O=/^(?:(?:emai|te|ur)l|number|password|search|text)$/;switch(r){case"any-link":case"link":{f.test(a)&&e.hasAttribute("href")&&t.add(e);break}case"local-link":{if(f.test(a)&&e.hasAttribute("href")){const N=new URL(e.getAttribute("href"),n.href);N.origin===n.origin&&N.pathname===n.pathname&&t.add(e)}break}case"visited":break;case"target":{e.id&&n.hash&&n.hash===`#${e.id}`&&(0,E.isSameOrDescendant)(e)&&t.add(e);break}case"target-within":{if(n.hash){const N=n.hash.replace(/^#/,"");let g=i.getElementById(N);for(;g;){if(g===e){t.add(e);break}g=g.parentNode}}break}case"scope":{this.#e.nodeType===l.ELEMENT_NODE?e===this.#e&&t.add(e):e===d&&t.add(e);break}case"focus":{e===i.activeElement&&t.add(e);break}case"focus-within":{let N=i.activeElement;for(;N;){if(N===e){t.add(e);break}N=N.parentNode}break}case"open":{w.test(a)&&e.hasAttribute("open")&&t.add(e);break}case"closed":{w.test(a)&&!e.hasAttribute("open")&&t.add(e);break}case"disabled":{if(u.test(a)||(0,B.default)(a))if(e.disabled||e.hasAttribute("disabled"))t.add(e);else{let N=b;for(;N&&N.localName!=="fieldset";)N=N.parentNode;N&&b.localName!=="legend"&&N.hasAttribute("disabled")&&t.add(e)}break}case"enabled":{(u.test(a)||(0,B.default)(a))&&!(e.disabled&&e.hasAttribute("disabled"))&&t.add(e);break}case"read-only":{switch(a){case"textarea":{(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}case"input":{(!e.type||A.test(e.type)||O.test(e.type))&&(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,E.isContentEditable)(e)||t.add(e)}break}case"read-write":{switch(a){case"textarea":{e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled")||t.add(e);break}case"input":{(!e.type||A.test(e.type)||O.test(e.type))&&!(e.readonly||e.hasAttribute("readonly")||e.disabled||e.hasAttribute("disabled"))&&t.add(e);break}default:(0,E.isContentEditable)(e)&&t.add(e)}break}case"placeholder-shown":{let N;a==="textarea"?N=e:a==="input"&&(e.hasAttribute("type")?O.test(e.getAttribute("type"))&&(N=e):N=e),N&&e.value===""&&e.hasAttribute("placeholder")&&e.getAttribute("placeholder").trim().length&&t.add(e);break}case"checked":{(e.checked&&a==="input"&&e.hasAttribute("type")&&k.test(e.getAttribute("type"))||e.selected&&a==="option")&&t.add(e);break}case"indeterminate":{if(e.indeterminate&&a==="input"&&e.type==="checkbox"||a==="progress"&&!e.hasAttribute("value"))t.add(e);else if(a==="input"&&e.type==="radio"&&!e.hasAttribute("checked")){const N=e.name;let g=e.parentNode;for(;g&&g.localName!=="form";)g=g.parentNode;g||(g=d);const _=[...g.getElementsByTagName("input")];let T;for(const x of _)if(x.getAttribute("type")==="radio"&&(N?x.getAttribute("name")===N&&(T=!!x.checked):x.hasAttribute("name")||(T=!!x.checked),T))break;T||t.add(e)}break}case"default":{const N=/^(?:button|reset)$/,g=/^(?:image|submit)$/;if(a==="button"&&!(e.hasAttribute("type")&&N.test(e.getAttribute("type")))||a==="input"&&e.hasAttribute("type")&&g.test(e.getAttribute("type"))){let _=e.parentNode;for(;_&&_.localName!=="form";)_=_.parentNode;if(_){const T=i.createNodeIterator(_,l.SHOW_ELEMENT);let x=T.nextNode();for(;x;){const $=x.localName;let v;if($==="button"?v=!(x.hasAttribute("type")&&N.test(x.getAttribute("type"))):$==="input"&&(v=x.hasAttribute("type")&&g.test(x.getAttribute("type"))),v){x===e&&t.add(e);break}x=T.nextNode()}}}else if(a==="input"&&e.hasAttribute("type")&&k.test(e.getAttribute("type"))&&(e.checked||e.hasAttribute("checked")))t.add(e);else if(a==="option"){let _=!1,T=b;for(;T&&T.localName!=="datalist";){if(T.localName==="select"){(T.multiple||T.hasAttribute("multiple"))&&(_=!0);break}T=T.parentNode}if(_)(e.selected||e.hasAttribute("selected"))&&t.add(e);else{const x=b.firstElementChild,$=new Set;let v=x;for(;v;){if(v.selected||v.hasAttribute("selected")){$.add(v);break}v=v.nextElementSibling}$.size||$.add(x),$.has(e)&&t.add(e)}}break}case"valid":{if(m.test(a))e.checkValidity()&&t.add(e);else if(a==="fieldset"){const N=i.createNodeIterator(e,l.SHOW_ELEMENT);let g=N.nextNode();g===e&&(g=N.nextNode());let _;for(;g&&!(m.test(g.localName)&&(_=g.checkValidity(),!_));)g=N.nextNode();_&&t.add(e)}break}case"invalid":{if(m.test(a))e.checkValidity()||t.add(e);else if(a==="fieldset"){const N=i.createNodeIterator(e,l.SHOW_ELEMENT);let g=N.nextNode();g===e&&(g=N.nextNode());let _;for(;g&&!(m.test(g.localName)&&(_=g.checkValidity(),!_));)g=N.nextNode();_||t.add(e)}break}case"in-range":{a==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&L.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":{a==="input"&&!(e.readonly||e.hasAttribute("readonly"))&&!(e.disabled||e.hasAttribute("disabled"))&&e.hasAttribute("type")&&L.test(e.getAttribute("type"))&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&t.add(e);break}case"required":{let N;if(/^(?:select|textarea)$/.test(a))N=e;else if(a==="input")if(e.hasAttribute("type")){const g=e.getAttribute("type");(g==="file"||k.test(g)||A.test(g)||O.test(g))&&(N=e)}else N=e;N&&(e.required||e.hasAttribute("required"))&&t.add(e);break}case"optional":{let N;if(/^(?:select|textarea)$/.test(a))N=e;else if(a==="input")if(e.hasAttribute("type")){const g=e.getAttribute("type");(g==="file"||k.test(g)||A.test(g)||O.test(g))&&(N=e)}else N=e;N&&!(e.required||e.hasAttribute("required"))&&t.add(e);break}case"root":{e===d&&t.add(e);break}case"empty":{if(e.hasChildNodes()){const N=e.childNodes.values();let g;for(const _ of N)if(g=_.nodeType!==l.ELEMENT_NODE&&_.nodeType!==l.TEXT_NODE,!g)break;g&&t.add(e)}else t.add(e);break}case"first-child":{(b&&e===b.firstElementChild||e===o&&o.nodeType===l.ELEMENT_NODE)&&t.add(e);break}case"last-child":{(b&&e===b.lastElementChild||e===o&&o.nodeType===l.ELEMENT_NODE)&&t.add(e);break}case"only-child":{(b&&e===b.firstElementChild&&e===b.lastElementChild||e===o&&o.nodeType===l.ELEMENT_NODE)&&t.add(e);break}case"first-of-type":{if(b){const[N]=this._collectNthOfType({a:0,b:1},e);N&&t.add(N)}else e===o&&o.nodeType===l.ELEMENT_NODE&&t.add(e);break}case"last-of-type":{if(b){const[N]=this._collectNthOfType({a:0,b:1,reverse:!0},e);N&&t.add(N)}else e===o&&o.nodeType===l.ELEMENT_NODE&&t.add(e);break}case"only-of-type":{if(b){const[N]=this._collectNthOfType({a:0,b:1},e);if(N===e){const[g]=this._collectNthOfType({a:0,b:1,reverse:!0},e);g===e&&t.add(e)}}else e===o&&o.nodeType===l.ELEMENT_NODE&&t.add(e);break}case"host":case"host-context":break;case"after":case"before":case"first-letter":case"first-line":{if(this.#s)throw new DOMException(`Unsupported pseudo-element ::${r}`,l.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(this.#s)throw new DOMException(`Unsupported pseudo-class :${r}`,l.NOT_SUPPORTED_ERR);break}default:if(r.startsWith("-webkit-")){if(this.#s)throw new DOMException(`Unsupported pseudo-class :${r}`,l.NOT_SUPPORTED_ERR)}else if(!p)throw new DOMException(`Unknown pseudo-class :${r}`,l.SYNTAX_ERR)}}return t}_matchAttributeSelector(s,e){const{flags:c,matcher:h,name:a,value:b}=s;if(typeof c=="string"&&!/^[is]$/i.test(c)){const t=(0,y.generateCSS)(s);throw new DOMException(`Invalid selector ${t}`,l.SYNTAX_ERR)}const{attributes:p}=e;let r;if(p&&p.length){const{document:t}=this.#t;let i;t.contentType==="text/html"?typeof c=="string"&&/^s$/i.test(c)?i=!1:i=!0:typeof c=="string"&&/^i$/i.test(c)?i=!0:i=!1;let o=(0,y.unescapeSelector)(a.name);i&&(o=o.toLowerCase());const d=new Set;if(o.indexOf("|")>-1){const{prefix:n,tagName:f}=(0,E.selectorToNodeProps)(o);for(let{name:u,value:m}of p)switch(i&&(u=u.toLowerCase(),m=m.toLowerCase()),n){case"":{f===u&&d.add(m);break}case"*":{u.indexOf(":")>-1?u.endsWith(`:${f}`)&&d.add(m):f===u&&d.add(m);break}default:if(u.indexOf(":")>-1){const[w,k]=u.split(":");n===w&&f===k&&(0,E.isNamespaceDeclared)(n,e)&&d.add(m)}}}else for(let{name:n,value:f}of p)if(i&&(n=n.toLowerCase(),f=f.toLowerCase()),n.indexOf(":")>-1){const[u,m]=n.split(":");if(u==="xml"&&m==="lang")continue;o===m&&d.add(f)}else o===n&&d.add(f);if(d.size){const{name:n,value:f}=b||{};let u;switch(n?i?u=n.toLowerCase():u=n:f?i?u=f.toLowerCase():u=f:f===""&&(u=f),h){case"=":{typeof u=="string"&&d.has(u)&&(r=e);break}case"~=":{if(u&&typeof u=="string"){for(const m of d)if(new Set(m.split(/\s+/)).has(u)){r=e;break}}break}case"|=":{if(u&&typeof u=="string"){let m;for(const w of d)if(w===u||w.startsWith(`${u}-`)){m=w;break}m&&(r=e)}break}case"^=":{if(u&&typeof u=="string"){let m;for(const w of d)if(w.startsWith(`${u}`)){m=w;break}m&&(r=e)}break}case"$=":{if(u&&typeof u=="string"){let m;for(const w of d)if(w.endsWith(`${u}`)){m=w;break}m&&(r=e)}break}case"*=":{if(u&&typeof u=="string"){let m;for(const w of d)if(w.includes(`${u}`)){m=w;break}m&&(r=e)}break}case null:default:r=e}}}return r??null}_matchClassSelector(s,e){const c=(0,y.unescapeSelector)(s.name);let h;return e.classList.contains(c)&&(h=e),h??null}_matchIDSelector(s,e){const c=(0,y.unescapeSelector)(s.name),{id:h}=e;let a;return c===h&&(a=e),a??null}_matchTypeSelector(s,e){const c=(0,y.unescapeSelector)(s.name),{localName:h,prefix:a}=e,{document:b}=this.#t;let{prefix:p,tagName:r}=(0,E.selectorToNodeProps)(c,e);b.contentType==="text/html"&&(p=p.toLowerCase(),r=r.toLowerCase());let t,i;h.indexOf(":")>-1?[t,i]=h.split(":"):(t=a||"",i=h);let o;return p===""&&t===""?e.namespaceURI===null&&(r==="*"||r===i)&&(o=e):p==="*"?(r==="*"||r===i)&&(o=e):p===t&&(0,E.isNamespaceDeclared)(p,e)&&(r==="*"||r===i)&&(o=e),o??null}_matchShadowHostPseudoClass(s,e){const{children:c}=s,h=(0,y.unescapeSelector)(s.name);let a;if(Array.isArray(c)){const[b]=(0,y.walkAST)(c[0]),[...p]=b,{host:r}=e;if(h==="host"){let t;for(const i of p){const{type:o}=i;if(o===l.COMBINATOR){const d=(0,y.generateCSS)(s);throw new DOMException(`Invalid selector ${d}`,l.SYNTAX_ERR)}if(t=this._matchSelector(i,r).has(r),!t)break}t&&(a=e)}else if(h==="host-context"){let t=r,i;for(;t;){for(const o of p){const{type:d}=o;if(d===l.COMBINATOR){const n=(0,y.generateCSS)(s);throw new DOMException(`Invalid selector ${n}`,l.SYNTAX_ERR)}if(i=this._matchSelector(o,t).has(t),!i)break}if(i)break;t=t.parentNode}i&&(a=e)}}else h==="host"&&(a=e);return a??null}_matchSelector(s,e,c){const{type:h}=s,a=(0,y.unescapeSelector)(s.name),{shadow:b}=this.#t;let p=new Set;if(e.nodeType===l.ELEMENT_NODE)switch(h){case l.SELECTOR_ATTR:{const r=this._matchAttributeSelector(s,e);r&&p.add(r);break}case l.SELECTOR_CLASS:{const r=this._matchClassSelector(s,e);r&&p.add(r);break}case l.SELECTOR_ID:{const r=this._matchIDSelector(s,e);r&&p.add(r);break}case l.SELECTOR_PSEUDO_CLASS:{const r=this._matchPseudoClassSelector(s,e,c);r.size&&(p=r);break}case l.SELECTOR_PSEUDO_ELEMENT:{this._matchPseudoElementSelector(a,c);break}case l.SELECTOR_TYPE:default:{const r=this._matchTypeSelector(s,e);r&&p.add(r)}}else if(b&&h===l.SELECTOR_PSEUDO_CLASS&&e.nodeType===l.DOCUMENT_FRAGMENT_NODE){if(a!=="has"&&l.REG_LOGICAL_PSEUDO.test(a)){const r=this._matchPseudoClassSelector(s,e,c);r.size&&(p=r)}else if(l.REG_SHADOW_HOST.test(a)){const r=this._matchShadowHostPseudoClass(s,e);r&&p.add(r)}}return p}_matchLeaves(s,e,c){let h;for(const a of s)if(h=this._matchSelector(a,e,c).has(e),!h)break;return!!h}_findDescendantNodes(s,e){const[c,...h]=s,{type:a}=c,b=(0,y.unescapeSelector)(c.name),p=h.length>0,r=new Set;let t=!1;switch(a){case l.SELECTOR_ID:{const{root:i}=this.#t;if(i.nodeType===l.ELEMENT_NODE)t=!0;else{const o=i.getElementById(b);if(o&&o!==e){const d=(0,E.isSameOrDescendant)(o,e);let n;d&&(n=o),n&&(p?this._matchLeaves(h,n)&&r.add(n):r.add(n))}}break}case l.SELECTOR_PSEUDO_ELEMENT:{this._matchPseudoElementSelector(b);break}default:t=!0}return{nodes:r,pending:t}}_matchCombinator(s,e,c={}){const{combo:h,leaves:a}=s,{name:b}=h,{find:p,forgive:r}=c;let t=new Set;if(p===R)switch(b){case"+":{const i=e.nextElementSibling;i&&this._matchLeaves(a,i,{forgive:r})&&t.add(i);break}case"~":{let i=e.nextElementSibling;for(;i;)this._matchLeaves(a,i,{forgive:r})&&t.add(i),i=i.nextElementSibling;break}case">":{const i=[...e.children];for(const o of i)this._matchLeaves(a,o,{forgive:r})&&t.add(o);break}case" ":default:{const{nodes:i,pending:o}=this._findDescendantNodes(a,e);if(i.size)t=i;else if(o){const{document:d}=this.#t,n=d.createNodeIterator(e,l.SHOW_ELEMENT);let f=n.nextNode();for(f===e&&(f=n.nextNode());f;)this._matchLeaves(a,f,{forgive:r})&&t.add(f),f=n.nextNode()}}}else switch(b){case"+":{const i=e.previousElementSibling;i&&this._matchLeaves(a,i,{forgive:r})&&t.add(i);break}case"~":{const i=[];let o=e.previousElementSibling;for(;o;)this._matchLeaves(a,o,{forgive:r})&&i.push(o),o=o.previousElementSibling;i.length&&(t=new Set(i.reverse()));break}case">":{const i=e.parentNode;i&&this._matchLeaves(a,i,{forgive:r})&&t.add(i);break}case" ":default:{const i=[];let o=e.parentNode;for(;o;)this._matchLeaves(a,o,{forgive:r})&&i.push(o),o=o.parentNode;i.length&&(t=new Set(i.reverse()))}}return t}_findNodes(s,e){const{leaves:[c,...h]}=s,{type:a}=c,b=(0,y.unescapeSelector)(c.name),p=h.length>0,{document:r,root:t,shadow:i}=this.#t;let o=new Set,d=!1;switch(a){case l.SELECTOR_ID:{let n;if(e===I)this._matchLeaves([c],this.#e)&&(n=this.#e);else if(e===D){let f=this.#e;for(;f;){if(this._matchLeaves([c],f)){n=f;break}f=f.parentNode}}else t.nodeType===l.ELEMENT_NODE?d=!0:n=t.getElementById(b);n&&(p?this._matchLeaves(h,n)&&o.add(n):o.add(n));break}case l.SELECTOR_CLASS:{const n=[];if(e===I)this.#e.nodeType===l.ELEMENT_NODE&&this.#e.classList.contains(b)&&n.push(this.#e);else if(e===D){let f=this.#e;for(;f&&f.nodeType===l.ELEMENT_NODE;)f.classList.contains(b)&&n.push(f),f=f.parentNode}else if(t.nodeType===l.DOCUMENT_FRAGMENT_NODE){const f=[...t.children];for(const u of f){u.classList.contains(b)&&n.push(u);const m=[...u.getElementsByClassName(b)];n.push(...m)}}else{const f=[...t.getElementsByClassName(b)];n.push(...f)}if(n.length)if(p)for(const f of n)this._matchLeaves(h,f)&&o.add(f);else o=new Set(n);break}case l.SELECTOR_TYPE:{const n=[];if(e===I)this.#e.nodeType===l.ELEMENT_NODE&&this._matchLeaves([c],this.#e)&&n.push(this.#e);else if(e===D){let f=this.#e;for(;f&&f.nodeType===l.ELEMENT_NODE;)this._matchLeaves([c],f)&&n.push(f),f=f.parentNode}else if(r.contentType!=="text/html"||/[*|]/.test(b))d=!0;else if(t.nodeType===l.DOCUMENT_FRAGMENT_NODE){const f=b.toLowerCase(),u=[...t.children];for(const m of u){m.localName===f&&n.push(m);const w=[...m.getElementsByTagName(b)];n.push(...w)}}else{const f=[...t.getElementsByTagName(b)];n.push(...f)}if(n.length)if(p)for(const f of n)this._matchLeaves(h,f)&&o.add(f);else o=new Set(n);break}case l.SELECTOR_PSEUDO_ELEMENT:{this._matchPseudoElementSelector(b);break}default:{const n=[];if(e!==D&&l.REG_SHADOW_HOST.test(b)){if(i&&this.#e.nodeType===l.DOCUMENT_FRAGMENT_NODE){const f=this._matchShadowHostPseudoClass(c,this.#e);f&&n.push(f)}}else if(e===I)this._matchLeaves([c],this.#e)&&n.push(this.#e);else if(e===D){let f=this.#e;for(;f;)this._matchLeaves([c],f)&&n.push(f),f=f.parentNode}else d=!0;if(n.length)if(p)for(const f of n)this._matchLeaves(h,f)&&o.add(f);else o=new Set(n)}}return{nodes:o,pending:d}}_getFirstTwig(s){const e=s.length-1,c=s[0];let h,a;if(e){const b=s[e],{leaves:[{type:p}]}=b;p===l.SELECTOR_PSEUDO_ELEMENT||p===l.SELECTOR_ID?(h=M,a=b):(h=R,a=c)}else h=M,a=c;return{find:h,twig:a}}_collectNodes(s){const e=this.#i.values();if(s===U||s===C){const c=new Set;let h=0;for(const{branch:a}of e){const{find:b,twig:p}=this._getFirstTwig(a),{nodes:r,pending:t}=this._findNodes(p,s);r.size?this.#r[h]=r:t?c.add(new Map([["index",h],["twig",p]])):this.#i[h].skip=!0,this.#i[h].find=b,h++}if(c.size){const{document:a,root:b}=this.#t,p=a.createNodeIterator(b,l.SHOW_ELEMENT);let r=p.nextNode();for(;r;){let t=!1;if(this.#e.nodeType===l.ELEMENT_NODE?t=(0,E.isSameOrDescendant)(r,this.#e):t=!0,t)for(const i of c){const{leaves:o}=i.get("twig");if(this._matchLeaves(o,r)){const n=i.get("index");this.#r[n].add(r)}}r=p.nextNode()}}}else{let c=0;for(const{branch:h}of e){const a=h[h.length-1],{nodes:b}=this._findNodes(a,s);b.size?this.#r[c]=b:this.#i[c].skip=!0,this.#i[c].find=M,c++}}return[this.#i,this.#r]}_sortNodes(s){const e=[...s];return e.length>1&&e.sort((c,h)=>{const a=c.compareDocumentPosition(h);let b;return a&l.DOCUMENT_POSITION_PRECEDING||a&l.DOCUMENT_POSITION_CONTAINS?b=1:b=-1,b}),e}_matchNodes(s){const[...e]=this.#i,c=e.length;let h=new Set;for(let a=0;a<c;a++){const{branch:b,find:p,skip:r}=e[a],t=b.length;if(!r&&t){const i=this.#r[a],o=t-1;if(o===0)if((s===U||s===C)&&this.#e.nodeType===l.ELEMENT_NODE){for(const d of i)if(d!==this.#e&&(0,E.isSameOrDescendant)(d,this.#e)&&(h.add(d),s===C))break}else if(s===C){const[d]=this._sortNodes(i);h.add(d)}else{const d=[...h],n=[...i];h=new Set([...d,...n])}else if(p===R){let{combo:d}=b[0];for(const n of i){let f=new Set([n]);for(let u=1;u<t;u++){const{combo:m,leaves:w}=b[u],k=[];for(const A of f){const L={combo:d,leaves:w},O=this._matchCombinator(L,A,{find:p});O.size&&k.push(...O)}if(k.length)if(u===o){if(s===C){const[A]=this._sortNodes(k);h.add(A)}else{const A=[...h];h=new Set([...A,...k])}break}else d=m,f=new Set(k);else break}}}else for(const d of i){let n=new Set([d]),f;for(let u=o-1;u>=0;u--){const m=b[u],w=[];for(const k of n){const A=this._matchCombinator(m,k,{find:p});A.size&&w.push(...A)}if(w.length)if(f=!0,u===0){h.add(d);break}else n=new Set(w);else{f=!1;break}}if(f&&s!==U)break}}}return h}_find(s){return this._collectNodes(s),this._matchNodes(s)}matches(){if(this.#e.nodeType!==l.ELEMENT_NODE)throw new TypeError(`Unexpected node ${this.#e.nodeName}`);let s;try{s=this._find(I).has(this.#e)}catch(e){this._onError(e)}return!!s}closest(){if(this.#e.nodeType!==l.ELEMENT_NODE)throw new TypeError(`Unexpected node ${this.#e.nodeName}`);let s;try{const e=this._find(D);let c=this.#e;for(;c;){if(e.has(c)){s=c;break}c=c.parentNode}}catch(e){this._onError(e)}return s??null}querySelector(){let s;try{const e=this._find(C);e.delete(this.#e),e.size>1?[s]=this._sortNodes(e):e.size&&([s]=[...e])}catch(e){this._onError(e)}return s??null}querySelectorAll(){const s=[];try{const e=this._find(U);e.delete(this.#e),e.size>1&&this.#c?s.push(...this._sortNodes(e)):e.size&&s.push(...e)}catch(e){this._onError(e)}return s}}0&&(module.exports={Matcher});
2
2
  //# sourceMappingURL=matcher.js.map