blob: 9a451f282b9b9394fc2e6c65f05dd1e92220e26b [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001/*!
Renovate botf591dcf2023-12-30 14:13:54 +00002 * Sizzle CSS Selector Engine v2.3.5
Copybara botbe50d492023-11-30 00:16:42 +01003 * https://sizzlejs.com/
4 *
5 * Copyright JS Foundation and other contributors
6 * Released under the MIT license
7 * https://js.foundation/
8 *
Renovate botf591dcf2023-12-30 14:13:54 +00009 * Date: 2020-03-14
Copybara botbe50d492023-11-30 00:16:42 +010010 */
Renovate botf591dcf2023-12-30 14:13:54 +000011( function( window ) {
Copybara botbe50d492023-11-30 00:16:42 +010012var i,
13 support,
14 Expr,
15 getText,
16 isXML,
17 tokenize,
18 compile,
19 select,
20 outermostContext,
21 sortInput,
22 hasDuplicate,
23
24 // Local document vars
25 setDocument,
26 document,
27 docElem,
28 documentIsHTML,
29 rbuggyQSA,
30 rbuggyMatches,
31 matches,
32 contains,
33
34 // Instance-specific data
35 expando = "sizzle" + 1 * new Date(),
36 preferredDoc = window.document,
37 dirruns = 0,
38 done = 0,
39 classCache = createCache(),
40 tokenCache = createCache(),
41 compilerCache = createCache(),
42 nonnativeSelectorCache = createCache(),
43 sortOrder = function( a, b ) {
44 if ( a === b ) {
45 hasDuplicate = true;
46 }
47 return 0;
48 },
49
50 // Instance methods
Renovate botf591dcf2023-12-30 14:13:54 +000051 hasOwn = ( {} ).hasOwnProperty,
Copybara botbe50d492023-11-30 00:16:42 +010052 arr = [],
53 pop = arr.pop,
Renovate botf591dcf2023-12-30 14:13:54 +000054 pushNative = arr.push,
Copybara botbe50d492023-11-30 00:16:42 +010055 push = arr.push,
56 slice = arr.slice,
Renovate botf591dcf2023-12-30 14:13:54 +000057
Copybara botbe50d492023-11-30 00:16:42 +010058 // Use a stripped-down indexOf as it's faster than native
59 // https://jsperf.com/thor-indexof-vs-for/5
60 indexOf = function( list, elem ) {
61 var i = 0,
62 len = list.length;
63 for ( ; i < len; i++ ) {
Renovate botf591dcf2023-12-30 14:13:54 +000064 if ( list[ i ] === elem ) {
Copybara botbe50d492023-11-30 00:16:42 +010065 return i;
66 }
67 }
68 return -1;
69 },
70
Renovate botf591dcf2023-12-30 14:13:54 +000071 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
72 "ismap|loop|multiple|open|readonly|required|scoped",
Copybara botbe50d492023-11-30 00:16:42 +010073
74 // Regular expressions
75
76 // http://www.w3.org/TR/css3-selectors/#whitespace
77 whitespace = "[\\x20\\t\\r\\n\\f]",
78
Renovate botf591dcf2023-12-30 14:13:54 +000079 // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
80 identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
81 "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
Copybara botbe50d492023-11-30 00:16:42 +010082
83 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
84 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
Renovate botf591dcf2023-12-30 14:13:54 +000085
Copybara botbe50d492023-11-30 00:16:42 +010086 // Operator (capture 2)
87 "*([*^$|!~]?=)" + whitespace +
Renovate botf591dcf2023-12-30 14:13:54 +000088
89 // "Attribute values must be CSS identifiers [capture 5]
90 // or strings [capture 3 or capture 4]"
91 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
92 whitespace + "*\\]",
Copybara botbe50d492023-11-30 00:16:42 +010093
94 pseudos = ":(" + identifier + ")(?:\\((" +
Renovate botf591dcf2023-12-30 14:13:54 +000095
Copybara botbe50d492023-11-30 00:16:42 +010096 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
97 // 1. quoted (capture 3; capture 4 or capture 5)
98 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
Renovate botf591dcf2023-12-30 14:13:54 +000099
Copybara botbe50d492023-11-30 00:16:42 +0100100 // 2. simple (capture 6)
101 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
Renovate botf591dcf2023-12-30 14:13:54 +0000102
Copybara botbe50d492023-11-30 00:16:42 +0100103 // 3. anything else (capture 2)
104 ".*" +
105 ")\\)|)",
106
107 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
108 rwhitespace = new RegExp( whitespace + "+", "g" ),
Renovate botf591dcf2023-12-30 14:13:54 +0000109 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
110 whitespace + "+$", "g" ),
Copybara botbe50d492023-11-30 00:16:42 +0100111
112 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
Renovate botf591dcf2023-12-30 14:13:54 +0000113 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
114 "*" ),
Copybara botbe50d492023-11-30 00:16:42 +0100115 rdescend = new RegExp( whitespace + "|>" ),
116
117 rpseudo = new RegExp( pseudos ),
118 ridentifier = new RegExp( "^" + identifier + "$" ),
119
120 matchExpr = {
121 "ID": new RegExp( "^#(" + identifier + ")" ),
122 "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
123 "TAG": new RegExp( "^(" + identifier + "|[*])" ),
124 "ATTR": new RegExp( "^" + attributes ),
125 "PSEUDO": new RegExp( "^" + pseudos ),
Renovate botf591dcf2023-12-30 14:13:54 +0000126 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
127 whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
128 whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
Copybara botbe50d492023-11-30 00:16:42 +0100129 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
Renovate botf591dcf2023-12-30 14:13:54 +0000130
Copybara botbe50d492023-11-30 00:16:42 +0100131 // For use in libraries implementing .is()
132 // We use this for POS matching in `select`
Renovate botf591dcf2023-12-30 14:13:54 +0000133 "needsContext": new RegExp( "^" + whitespace +
134 "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
135 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
Copybara botbe50d492023-11-30 00:16:42 +0100136 },
137
138 rhtml = /HTML$/i,
139 rinputs = /^(?:input|select|textarea|button)$/i,
140 rheader = /^h\d$/i,
141
142 rnative = /^[^{]+\{\s*\[native \w/,
143
144 // Easily-parseable/retrievable ID or TAG or CLASS selectors
145 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
146
147 rsibling = /[+~]/,
148
149 // CSS escapes
150 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
Renovate botf591dcf2023-12-30 14:13:54 +0000151 runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
152 funescape = function( escape, nonHex ) {
153 var high = "0x" + escape.slice( 1 ) - 0x10000;
154
155 return nonHex ?
156
157 // Strip the backslash prefix from a non-hex escape sequence
158 nonHex :
159
160 // Replace a hexadecimal escape sequence with the encoded Unicode code point
161 // Support: IE <=11+
162 // For values outside the Basic Multilingual Plane (BMP), manually construct a
163 // surrogate pair
Copybara botbe50d492023-11-30 00:16:42 +0100164 high < 0 ?
Copybara botbe50d492023-11-30 00:16:42 +0100165 String.fromCharCode( high + 0x10000 ) :
Copybara botbe50d492023-11-30 00:16:42 +0100166 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
167 },
168
169 // CSS string/identifier serialization
170 // https://drafts.csswg.org/cssom/#common-serializing-idioms
171 rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
172 fcssescape = function( ch, asCodePoint ) {
173 if ( asCodePoint ) {
174
175 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
176 if ( ch === "\0" ) {
177 return "\uFFFD";
178 }
179
180 // Control characters and (dependent upon position) numbers get escaped as code points
Renovate botf591dcf2023-12-30 14:13:54 +0000181 return ch.slice( 0, -1 ) + "\\" +
182 ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
Copybara botbe50d492023-11-30 00:16:42 +0100183 }
184
185 // Other potentially-special ASCII characters get backslash-escaped
186 return "\\" + ch;
187 },
188
189 // Used for iframes
190 // See setDocument()
191 // Removing the function wrapper causes a "Permission Denied"
192 // error in IE
193 unloadHandler = function() {
194 setDocument();
195 },
196
197 inDisabledFieldset = addCombinator(
198 function( elem ) {
199 return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
200 },
201 { dir: "parentNode", next: "legend" }
202 );
203
204// Optimize for push.apply( _, NodeList )
205try {
206 push.apply(
Renovate botf591dcf2023-12-30 14:13:54 +0000207 ( arr = slice.call( preferredDoc.childNodes ) ),
Copybara botbe50d492023-11-30 00:16:42 +0100208 preferredDoc.childNodes
209 );
Renovate botf591dcf2023-12-30 14:13:54 +0000210
Copybara botbe50d492023-11-30 00:16:42 +0100211 // Support: Android<4.0
212 // Detect silently failing push.apply
Renovate botf591dcf2023-12-30 14:13:54 +0000213 // eslint-disable-next-line no-unused-expressions
Copybara botbe50d492023-11-30 00:16:42 +0100214 arr[ preferredDoc.childNodes.length ].nodeType;
215} catch ( e ) {
216 push = { apply: arr.length ?
217
218 // Leverage slice if possible
219 function( target, els ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000220 pushNative.apply( target, slice.call( els ) );
Copybara botbe50d492023-11-30 00:16:42 +0100221 } :
222
223 // Support: IE<9
224 // Otherwise append directly
225 function( target, els ) {
226 var j = target.length,
227 i = 0;
Renovate botf591dcf2023-12-30 14:13:54 +0000228
Copybara botbe50d492023-11-30 00:16:42 +0100229 // Can't trust NodeList.length
Renovate botf591dcf2023-12-30 14:13:54 +0000230 while ( ( target[ j++ ] = els[ i++ ] ) ) {}
Copybara botbe50d492023-11-30 00:16:42 +0100231 target.length = j - 1;
232 }
233 };
234}
235
236function Sizzle( selector, context, results, seed ) {
237 var m, i, elem, nid, match, groups, newSelector,
238 newContext = context && context.ownerDocument,
239
240 // nodeType defaults to 9, since context defaults to document
241 nodeType = context ? context.nodeType : 9;
242
243 results = results || [];
244
245 // Return early from calls with invalid selector or context
246 if ( typeof selector !== "string" || !selector ||
247 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
248
249 return results;
250 }
251
252 // Try to shortcut find operations (as opposed to filters) in HTML documents
253 if ( !seed ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000254 setDocument( context );
Copybara botbe50d492023-11-30 00:16:42 +0100255 context = context || document;
256
257 if ( documentIsHTML ) {
258
259 // If the selector is sufficiently simple, try using a "get*By*" DOM method
260 // (excepting DocumentFragment context, where the methods don't exist)
Renovate botf591dcf2023-12-30 14:13:54 +0000261 if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100262
263 // ID selector
Renovate botf591dcf2023-12-30 14:13:54 +0000264 if ( ( m = match[ 1 ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100265
266 // Document context
267 if ( nodeType === 9 ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000268 if ( ( elem = context.getElementById( m ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100269
270 // Support: IE, Opera, Webkit
271 // TODO: identify versions
272 // getElementById can match elements by name instead of ID
273 if ( elem.id === m ) {
274 results.push( elem );
275 return results;
276 }
277 } else {
278 return results;
279 }
280
281 // Element context
282 } else {
283
284 // Support: IE, Opera, Webkit
285 // TODO: identify versions
286 // getElementById can match elements by name instead of ID
Renovate botf591dcf2023-12-30 14:13:54 +0000287 if ( newContext && ( elem = newContext.getElementById( m ) ) &&
Copybara botbe50d492023-11-30 00:16:42 +0100288 contains( context, elem ) &&
289 elem.id === m ) {
290
291 results.push( elem );
292 return results;
293 }
294 }
295
296 // Type selector
Renovate botf591dcf2023-12-30 14:13:54 +0000297 } else if ( match[ 2 ] ) {
Copybara botbe50d492023-11-30 00:16:42 +0100298 push.apply( results, context.getElementsByTagName( selector ) );
299 return results;
300
301 // Class selector
Renovate botf591dcf2023-12-30 14:13:54 +0000302 } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
Copybara botbe50d492023-11-30 00:16:42 +0100303 context.getElementsByClassName ) {
304
305 push.apply( results, context.getElementsByClassName( m ) );
306 return results;
307 }
308 }
309
310 // Take advantage of querySelectorAll
311 if ( support.qsa &&
312 !nonnativeSelectorCache[ selector + " " ] &&
Renovate botf591dcf2023-12-30 14:13:54 +0000313 ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
Copybara botbe50d492023-11-30 00:16:42 +0100314
315 // Support: IE 8 only
316 // Exclude object elements
Renovate botf591dcf2023-12-30 14:13:54 +0000317 ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100318
319 newSelector = selector;
320 newContext = context;
321
322 // qSA considers elements outside a scoping root when evaluating child or
323 // descendant combinators, which is not what we want.
324 // In such cases, we work around the behavior by prefixing every selector in the
325 // list with an ID selector referencing the scope context.
Renovate botf591dcf2023-12-30 14:13:54 +0000326 // The technique has to be used as well when a leading combinator is used
327 // as such selectors are not recognized by querySelectorAll.
Copybara botbe50d492023-11-30 00:16:42 +0100328 // Thanks to Andrew Dupont for this technique.
Renovate botf591dcf2023-12-30 14:13:54 +0000329 if ( nodeType === 1 &&
330 ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100331
Renovate botf591dcf2023-12-30 14:13:54 +0000332 // Expand context for sibling selectors
333 newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
334 context;
335
336 // We can use :scope instead of the ID hack if the browser
337 // supports it & if we're not changing the context.
338 if ( newContext !== context || !support.scope ) {
339
340 // Capture the context ID, setting it first if necessary
341 if ( ( nid = context.getAttribute( "id" ) ) ) {
342 nid = nid.replace( rcssescape, fcssescape );
343 } else {
344 context.setAttribute( "id", ( nid = expando ) );
345 }
Copybara botbe50d492023-11-30 00:16:42 +0100346 }
347
348 // Prefix every selector in the list
349 groups = tokenize( selector );
350 i = groups.length;
351 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000352 groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
353 toSelector( groups[ i ] );
Copybara botbe50d492023-11-30 00:16:42 +0100354 }
355 newSelector = groups.join( "," );
Copybara botbe50d492023-11-30 00:16:42 +0100356 }
357
358 try {
359 push.apply( results,
360 newContext.querySelectorAll( newSelector )
361 );
362 return results;
363 } catch ( qsaError ) {
364 nonnativeSelectorCache( selector, true );
365 } finally {
366 if ( nid === expando ) {
367 context.removeAttribute( "id" );
368 }
369 }
370 }
371 }
372 }
373
374 // All others
375 return select( selector.replace( rtrim, "$1" ), context, results, seed );
376}
377
378/**
379 * Create key-value caches of limited size
380 * @returns {function(string, object)} Returns the Object data after storing it on itself with
381 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
382 * deleting the oldest entry
383 */
384function createCache() {
385 var keys = [];
386
387 function cache( key, value ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000388
Copybara botbe50d492023-11-30 00:16:42 +0100389 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
390 if ( keys.push( key + " " ) > Expr.cacheLength ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000391
Copybara botbe50d492023-11-30 00:16:42 +0100392 // Only keep the most recent entries
393 delete cache[ keys.shift() ];
394 }
Renovate botf591dcf2023-12-30 14:13:54 +0000395 return ( cache[ key + " " ] = value );
Copybara botbe50d492023-11-30 00:16:42 +0100396 }
397 return cache;
398}
399
400/**
401 * Mark a function for special use by Sizzle
402 * @param {Function} fn The function to mark
403 */
404function markFunction( fn ) {
405 fn[ expando ] = true;
406 return fn;
407}
408
409/**
410 * Support testing using an element
411 * @param {Function} fn Passed the created element and returns a boolean result
412 */
413function assert( fn ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000414 var el = document.createElement( "fieldset" );
Copybara botbe50d492023-11-30 00:16:42 +0100415
416 try {
417 return !!fn( el );
Renovate botf591dcf2023-12-30 14:13:54 +0000418 } catch ( e ) {
Copybara botbe50d492023-11-30 00:16:42 +0100419 return false;
420 } finally {
Renovate botf591dcf2023-12-30 14:13:54 +0000421
Copybara botbe50d492023-11-30 00:16:42 +0100422 // Remove from its parent by default
423 if ( el.parentNode ) {
424 el.parentNode.removeChild( el );
425 }
Renovate botf591dcf2023-12-30 14:13:54 +0000426
Copybara botbe50d492023-11-30 00:16:42 +0100427 // release memory in IE
428 el = null;
429 }
430}
431
432/**
433 * Adds the same handler for all of the specified attrs
434 * @param {String} attrs Pipe-separated list of attributes
435 * @param {Function} handler The method that will be applied
436 */
437function addHandle( attrs, handler ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000438 var arr = attrs.split( "|" ),
Copybara botbe50d492023-11-30 00:16:42 +0100439 i = arr.length;
440
441 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000442 Expr.attrHandle[ arr[ i ] ] = handler;
Copybara botbe50d492023-11-30 00:16:42 +0100443 }
444}
445
446/**
447 * Checks document order of two siblings
448 * @param {Element} a
449 * @param {Element} b
450 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
451 */
452function siblingCheck( a, b ) {
453 var cur = b && a,
454 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
455 a.sourceIndex - b.sourceIndex;
456
457 // Use IE sourceIndex if available on both nodes
458 if ( diff ) {
459 return diff;
460 }
461
462 // Check if b follows a
463 if ( cur ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000464 while ( ( cur = cur.nextSibling ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100465 if ( cur === b ) {
466 return -1;
467 }
468 }
469 }
470
471 return a ? 1 : -1;
472}
473
474/**
475 * Returns a function to use in pseudos for input types
476 * @param {String} type
477 */
478function createInputPseudo( type ) {
479 return function( elem ) {
480 var name = elem.nodeName.toLowerCase();
481 return name === "input" && elem.type === type;
482 };
483}
484
485/**
486 * Returns a function to use in pseudos for buttons
487 * @param {String} type
488 */
489function createButtonPseudo( type ) {
490 return function( elem ) {
491 var name = elem.nodeName.toLowerCase();
Renovate botf591dcf2023-12-30 14:13:54 +0000492 return ( name === "input" || name === "button" ) && elem.type === type;
Copybara botbe50d492023-11-30 00:16:42 +0100493 };
494}
495
496/**
497 * Returns a function to use in pseudos for :enabled/:disabled
498 * @param {Boolean} disabled true for :disabled; false for :enabled
499 */
500function createDisabledPseudo( disabled ) {
501
502 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
503 return function( elem ) {
504
505 // Only certain elements can match :enabled or :disabled
506 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
507 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
508 if ( "form" in elem ) {
509
510 // Check for inherited disabledness on relevant non-disabled elements:
511 // * listed form-associated elements in a disabled fieldset
512 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
513 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
514 // * option elements in a disabled optgroup
515 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
516 // All such elements have a "form" property.
517 if ( elem.parentNode && elem.disabled === false ) {
518
519 // Option elements defer to a parent optgroup if present
520 if ( "label" in elem ) {
521 if ( "label" in elem.parentNode ) {
522 return elem.parentNode.disabled === disabled;
523 } else {
524 return elem.disabled === disabled;
525 }
526 }
527
528 // Support: IE 6 - 11
529 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
530 return elem.isDisabled === disabled ||
531
532 // Where there is no isDisabled, check manually
533 /* jshint -W018 */
534 elem.isDisabled !== !disabled &&
Renovate botf591dcf2023-12-30 14:13:54 +0000535 inDisabledFieldset( elem ) === disabled;
Copybara botbe50d492023-11-30 00:16:42 +0100536 }
537
538 return elem.disabled === disabled;
539
540 // Try to winnow out elements that can't be disabled before trusting the disabled property.
541 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
542 // even exist on them, let alone have a boolean value.
543 } else if ( "label" in elem ) {
544 return elem.disabled === disabled;
545 }
546
547 // Remaining elements are neither :enabled nor :disabled
548 return false;
549 };
550}
551
552/**
553 * Returns a function to use in pseudos for positionals
554 * @param {Function} fn
555 */
556function createPositionalPseudo( fn ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000557 return markFunction( function( argument ) {
Copybara botbe50d492023-11-30 00:16:42 +0100558 argument = +argument;
Renovate botf591dcf2023-12-30 14:13:54 +0000559 return markFunction( function( seed, matches ) {
Copybara botbe50d492023-11-30 00:16:42 +0100560 var j,
561 matchIndexes = fn( [], seed.length, argument ),
562 i = matchIndexes.length;
563
564 // Match elements found at the specified indexes
565 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000566 if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
567 seed[ j ] = !( matches[ j ] = seed[ j ] );
Copybara botbe50d492023-11-30 00:16:42 +0100568 }
569 }
Renovate botf591dcf2023-12-30 14:13:54 +0000570 } );
571 } );
Copybara botbe50d492023-11-30 00:16:42 +0100572}
573
574/**
575 * Checks a node for validity as a Sizzle context
576 * @param {Element|Object=} context
577 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
578 */
579function testContext( context ) {
580 return context && typeof context.getElementsByTagName !== "undefined" && context;
581}
582
583// Expose support vars for convenience
584support = Sizzle.support = {};
585
586/**
587 * Detects XML nodes
588 * @param {Element|Object} elem An element or a document
589 * @returns {Boolean} True iff elem is a non-HTML XML node
590 */
591isXML = Sizzle.isXML = function( elem ) {
592 var namespace = elem.namespaceURI,
Renovate botf591dcf2023-12-30 14:13:54 +0000593 docElem = ( elem.ownerDocument || elem ).documentElement;
Copybara botbe50d492023-11-30 00:16:42 +0100594
595 // Support: IE <=8
596 // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
597 // https://bugs.jquery.com/ticket/4833
598 return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
599};
600
601/**
602 * Sets document-related variables once based on the current document
603 * @param {Element|Object} [doc] An element or document object to use to set the document
604 * @returns {Object} Returns the current document
605 */
606setDocument = Sizzle.setDocument = function( node ) {
607 var hasCompare, subWindow,
608 doc = node ? node.ownerDocument || node : preferredDoc;
609
610 // Return early if doc is invalid or already selected
Renovate botf591dcf2023-12-30 14:13:54 +0000611 // Support: IE 11+, Edge 17 - 18+
612 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
613 // two documents; shallow comparisons work.
614 // eslint-disable-next-line eqeqeq
615 if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
Copybara botbe50d492023-11-30 00:16:42 +0100616 return document;
617 }
618
619 // Update global variables
620 document = doc;
621 docElem = document.documentElement;
622 documentIsHTML = !isXML( document );
623
Renovate botf591dcf2023-12-30 14:13:54 +0000624 // Support: IE 9 - 11+, Edge 12 - 18+
Copybara botbe50d492023-11-30 00:16:42 +0100625 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
Renovate botf591dcf2023-12-30 14:13:54 +0000626 // Support: IE 11+, Edge 17 - 18+
627 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
628 // two documents; shallow comparisons work.
629 // eslint-disable-next-line eqeqeq
630 if ( preferredDoc != document &&
631 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
Copybara botbe50d492023-11-30 00:16:42 +0100632
633 // Support: IE 11, Edge
634 if ( subWindow.addEventListener ) {
635 subWindow.addEventListener( "unload", unloadHandler, false );
636
637 // Support: IE 9 - 10 only
638 } else if ( subWindow.attachEvent ) {
639 subWindow.attachEvent( "onunload", unloadHandler );
640 }
641 }
642
Renovate botf591dcf2023-12-30 14:13:54 +0000643 // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
644 // Safari 4 - 5 only, Opera <=11.6 - 12.x only
645 // IE/Edge & older browsers don't support the :scope pseudo-class.
646 // Support: Safari 6.0 only
647 // Safari 6.0 supports :scope but it's an alias of :root there.
648 support.scope = assert( function( el ) {
649 docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
650 return typeof el.querySelectorAll !== "undefined" &&
651 !el.querySelectorAll( ":scope fieldset div" ).length;
652 } );
653
Copybara botbe50d492023-11-30 00:16:42 +0100654 /* Attributes
655 ---------------------------------------------------------------------- */
656
657 // Support: IE<8
658 // Verify that getAttribute really returns attributes and not properties
659 // (excepting IE8 booleans)
Renovate botf591dcf2023-12-30 14:13:54 +0000660 support.attributes = assert( function( el ) {
Copybara botbe50d492023-11-30 00:16:42 +0100661 el.className = "i";
Renovate botf591dcf2023-12-30 14:13:54 +0000662 return !el.getAttribute( "className" );
663 } );
Copybara botbe50d492023-11-30 00:16:42 +0100664
665 /* getElement(s)By*
666 ---------------------------------------------------------------------- */
667
668 // Check if getElementsByTagName("*") returns only elements
Renovate botf591dcf2023-12-30 14:13:54 +0000669 support.getElementsByTagName = assert( function( el ) {
670 el.appendChild( document.createComment( "" ) );
671 return !el.getElementsByTagName( "*" ).length;
672 } );
Copybara botbe50d492023-11-30 00:16:42 +0100673
674 // Support: IE<9
675 support.getElementsByClassName = rnative.test( document.getElementsByClassName );
676
677 // Support: IE<10
678 // Check if getElementById returns elements by name
679 // The broken getElementById methods don't pick up programmatically-set names,
680 // so use a roundabout getElementsByName test
Renovate botf591dcf2023-12-30 14:13:54 +0000681 support.getById = assert( function( el ) {
Copybara botbe50d492023-11-30 00:16:42 +0100682 docElem.appendChild( el ).id = expando;
683 return !document.getElementsByName || !document.getElementsByName( expando ).length;
Renovate botf591dcf2023-12-30 14:13:54 +0000684 } );
Copybara botbe50d492023-11-30 00:16:42 +0100685
686 // ID filter and find
687 if ( support.getById ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000688 Expr.filter[ "ID" ] = function( id ) {
Copybara botbe50d492023-11-30 00:16:42 +0100689 var attrId = id.replace( runescape, funescape );
690 return function( elem ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000691 return elem.getAttribute( "id" ) === attrId;
Copybara botbe50d492023-11-30 00:16:42 +0100692 };
693 };
Renovate botf591dcf2023-12-30 14:13:54 +0000694 Expr.find[ "ID" ] = function( id, context ) {
Copybara botbe50d492023-11-30 00:16:42 +0100695 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
696 var elem = context.getElementById( id );
697 return elem ? [ elem ] : [];
698 }
699 };
700 } else {
Renovate botf591dcf2023-12-30 14:13:54 +0000701 Expr.filter[ "ID" ] = function( id ) {
Copybara botbe50d492023-11-30 00:16:42 +0100702 var attrId = id.replace( runescape, funescape );
703 return function( elem ) {
704 var node = typeof elem.getAttributeNode !== "undefined" &&
Renovate botf591dcf2023-12-30 14:13:54 +0000705 elem.getAttributeNode( "id" );
Copybara botbe50d492023-11-30 00:16:42 +0100706 return node && node.value === attrId;
707 };
708 };
709
710 // Support: IE 6 - 7 only
711 // getElementById is not reliable as a find shortcut
Renovate botf591dcf2023-12-30 14:13:54 +0000712 Expr.find[ "ID" ] = function( id, context ) {
Copybara botbe50d492023-11-30 00:16:42 +0100713 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
714 var node, i, elems,
715 elem = context.getElementById( id );
716
717 if ( elem ) {
718
719 // Verify the id attribute
Renovate botf591dcf2023-12-30 14:13:54 +0000720 node = elem.getAttributeNode( "id" );
Copybara botbe50d492023-11-30 00:16:42 +0100721 if ( node && node.value === id ) {
722 return [ elem ];
723 }
724
725 // Fall back on getElementsByName
726 elems = context.getElementsByName( id );
727 i = 0;
Renovate botf591dcf2023-12-30 14:13:54 +0000728 while ( ( elem = elems[ i++ ] ) ) {
729 node = elem.getAttributeNode( "id" );
Copybara botbe50d492023-11-30 00:16:42 +0100730 if ( node && node.value === id ) {
731 return [ elem ];
732 }
733 }
734 }
735
736 return [];
737 }
738 };
739 }
740
741 // Tag
Renovate botf591dcf2023-12-30 14:13:54 +0000742 Expr.find[ "TAG" ] = support.getElementsByTagName ?
Copybara botbe50d492023-11-30 00:16:42 +0100743 function( tag, context ) {
744 if ( typeof context.getElementsByTagName !== "undefined" ) {
745 return context.getElementsByTagName( tag );
746
747 // DocumentFragment nodes don't have gEBTN
748 } else if ( support.qsa ) {
749 return context.querySelectorAll( tag );
750 }
751 } :
752
753 function( tag, context ) {
754 var elem,
755 tmp = [],
756 i = 0,
Renovate botf591dcf2023-12-30 14:13:54 +0000757
Copybara botbe50d492023-11-30 00:16:42 +0100758 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
759 results = context.getElementsByTagName( tag );
760
761 // Filter out possible comments
762 if ( tag === "*" ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000763 while ( ( elem = results[ i++ ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100764 if ( elem.nodeType === 1 ) {
765 tmp.push( elem );
766 }
767 }
768
769 return tmp;
770 }
771 return results;
772 };
773
774 // Class
Renovate botf591dcf2023-12-30 14:13:54 +0000775 Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
Copybara botbe50d492023-11-30 00:16:42 +0100776 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
777 return context.getElementsByClassName( className );
778 }
779 };
780
781 /* QSA/matchesSelector
782 ---------------------------------------------------------------------- */
783
784 // QSA and matchesSelector support
785
786 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
787 rbuggyMatches = [];
788
789 // qSa(:focus) reports false when true (Chrome 21)
790 // We allow this because of a bug in IE8/9 that throws an error
791 // whenever `document.activeElement` is accessed on an iframe
792 // So, we allow :focus to pass through QSA all the time to avoid the IE error
793 // See https://bugs.jquery.com/ticket/13378
794 rbuggyQSA = [];
795
Renovate botf591dcf2023-12-30 14:13:54 +0000796 if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
797
Copybara botbe50d492023-11-30 00:16:42 +0100798 // Build QSA regex
799 // Regex strategy adopted from Diego Perini
Renovate botf591dcf2023-12-30 14:13:54 +0000800 assert( function( el ) {
801
802 var input;
803
Copybara botbe50d492023-11-30 00:16:42 +0100804 // Select is set to empty string on purpose
805 // This is to test IE's treatment of not explicitly
806 // setting a boolean content attribute,
807 // since its presence should be enough
808 // https://bugs.jquery.com/ticket/12359
809 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
810 "<select id='" + expando + "-\r\\' msallowcapture=''>" +
811 "<option selected=''></option></select>";
812
813 // Support: IE8, Opera 11-12.16
814 // Nothing should be selected when empty strings follow ^= or $= or *=
815 // The test attribute must be unknown in Opera but "safe" for WinRT
816 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
Renovate botf591dcf2023-12-30 14:13:54 +0000817 if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
Copybara botbe50d492023-11-30 00:16:42 +0100818 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
819 }
820
821 // Support: IE8
822 // Boolean attributes and "value" are not treated correctly
Renovate botf591dcf2023-12-30 14:13:54 +0000823 if ( !el.querySelectorAll( "[selected]" ).length ) {
Copybara botbe50d492023-11-30 00:16:42 +0100824 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
825 }
826
827 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
828 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000829 rbuggyQSA.push( "~=" );
830 }
831
832 // Support: IE 11+, Edge 15 - 18+
833 // IE 11/Edge don't find elements on a `[name='']` query in some cases.
834 // Adding a temporary attribute to the document before the selection works
835 // around the issue.
836 // Interestingly, IE 10 & older don't seem to have the issue.
837 input = document.createElement( "input" );
838 input.setAttribute( "name", "" );
839 el.appendChild( input );
840 if ( !el.querySelectorAll( "[name='']" ).length ) {
841 rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
842 whitespace + "*(?:''|\"\")" );
Copybara botbe50d492023-11-30 00:16:42 +0100843 }
844
845 // Webkit/Opera - :checked should return selected option elements
846 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
847 // IE8 throws error here and will not see later tests
Renovate botf591dcf2023-12-30 14:13:54 +0000848 if ( !el.querySelectorAll( ":checked" ).length ) {
849 rbuggyQSA.push( ":checked" );
Copybara botbe50d492023-11-30 00:16:42 +0100850 }
851
852 // Support: Safari 8+, iOS 8+
853 // https://bugs.webkit.org/show_bug.cgi?id=136851
854 // In-page `selector#id sibling-combinator selector` fails
855 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000856 rbuggyQSA.push( ".#.+[+~]" );
Copybara botbe50d492023-11-30 00:16:42 +0100857 }
Copybara botbe50d492023-11-30 00:16:42 +0100858
Renovate botf591dcf2023-12-30 14:13:54 +0000859 // Support: Firefox <=3.6 - 5 only
860 // Old Firefox doesn't throw on a badly-escaped identifier.
861 el.querySelectorAll( "\\\f" );
862 rbuggyQSA.push( "[\\r\\n\\f]" );
863 } );
864
865 assert( function( el ) {
Copybara botbe50d492023-11-30 00:16:42 +0100866 el.innerHTML = "<a href='' disabled='disabled'></a>" +
867 "<select disabled='disabled'><option/></select>";
868
869 // Support: Windows 8 Native Apps
870 // The type and name attributes are restricted during .innerHTML assignment
Renovate botf591dcf2023-12-30 14:13:54 +0000871 var input = document.createElement( "input" );
Copybara botbe50d492023-11-30 00:16:42 +0100872 input.setAttribute( "type", "hidden" );
873 el.appendChild( input ).setAttribute( "name", "D" );
874
875 // Support: IE8
876 // Enforce case-sensitivity of name attribute
Renovate botf591dcf2023-12-30 14:13:54 +0000877 if ( el.querySelectorAll( "[name=d]" ).length ) {
Copybara botbe50d492023-11-30 00:16:42 +0100878 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
879 }
880
881 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
882 // IE8 throws error here and will not see later tests
Renovate botf591dcf2023-12-30 14:13:54 +0000883 if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
Copybara botbe50d492023-11-30 00:16:42 +0100884 rbuggyQSA.push( ":enabled", ":disabled" );
885 }
886
887 // Support: IE9-11+
888 // IE's :disabled selector does not pick up the children of disabled fieldsets
889 docElem.appendChild( el ).disabled = true;
Renovate botf591dcf2023-12-30 14:13:54 +0000890 if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
Copybara botbe50d492023-11-30 00:16:42 +0100891 rbuggyQSA.push( ":enabled", ":disabled" );
892 }
893
Renovate botf591dcf2023-12-30 14:13:54 +0000894 // Support: Opera 10 - 11 only
Copybara botbe50d492023-11-30 00:16:42 +0100895 // Opera 10-11 does not throw on post-comma invalid pseudos
Renovate botf591dcf2023-12-30 14:13:54 +0000896 el.querySelectorAll( "*,:x" );
897 rbuggyQSA.push( ",.*:" );
898 } );
Copybara botbe50d492023-11-30 00:16:42 +0100899 }
900
Renovate botf591dcf2023-12-30 14:13:54 +0000901 if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
Copybara botbe50d492023-11-30 00:16:42 +0100902 docElem.webkitMatchesSelector ||
903 docElem.mozMatchesSelector ||
904 docElem.oMatchesSelector ||
Renovate botf591dcf2023-12-30 14:13:54 +0000905 docElem.msMatchesSelector ) ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100906
Renovate botf591dcf2023-12-30 14:13:54 +0000907 assert( function( el ) {
908
Copybara botbe50d492023-11-30 00:16:42 +0100909 // Check to see if it's possible to do matchesSelector
910 // on a disconnected node (IE 9)
911 support.disconnectedMatch = matches.call( el, "*" );
912
913 // This should fail with an exception
914 // Gecko does not error, returns false instead
915 matches.call( el, "[s!='']:x" );
916 rbuggyMatches.push( "!=", pseudos );
Renovate botf591dcf2023-12-30 14:13:54 +0000917 } );
Copybara botbe50d492023-11-30 00:16:42 +0100918 }
919
Renovate botf591dcf2023-12-30 14:13:54 +0000920 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
921 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
Copybara botbe50d492023-11-30 00:16:42 +0100922
923 /* Contains
924 ---------------------------------------------------------------------- */
925 hasCompare = rnative.test( docElem.compareDocumentPosition );
926
927 // Element contains another
928 // Purposefully self-exclusive
929 // As in, an element does not contain itself
930 contains = hasCompare || rnative.test( docElem.contains ) ?
931 function( a, b ) {
932 var adown = a.nodeType === 9 ? a.documentElement : a,
933 bup = b && b.parentNode;
934 return a === bup || !!( bup && bup.nodeType === 1 && (
935 adown.contains ?
936 adown.contains( bup ) :
937 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
Renovate botf591dcf2023-12-30 14:13:54 +0000938 ) );
Copybara botbe50d492023-11-30 00:16:42 +0100939 } :
940 function( a, b ) {
941 if ( b ) {
Renovate botf591dcf2023-12-30 14:13:54 +0000942 while ( ( b = b.parentNode ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100943 if ( b === a ) {
944 return true;
945 }
946 }
947 }
948 return false;
949 };
950
951 /* Sorting
952 ---------------------------------------------------------------------- */
953
954 // Document order sorting
955 sortOrder = hasCompare ?
956 function( a, b ) {
957
958 // Flag for duplicate removal
959 if ( a === b ) {
960 hasDuplicate = true;
961 return 0;
962 }
963
964 // Sort on method existence if only one input has compareDocumentPosition
965 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
966 if ( compare ) {
967 return compare;
968 }
969
970 // Calculate position if both inputs belong to the same document
Renovate botf591dcf2023-12-30 14:13:54 +0000971 // Support: IE 11+, Edge 17 - 18+
972 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
973 // two documents; shallow comparisons work.
974 // eslint-disable-next-line eqeqeq
975 compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
Copybara botbe50d492023-11-30 00:16:42 +0100976 a.compareDocumentPosition( b ) :
977
978 // Otherwise we know they are disconnected
979 1;
980
981 // Disconnected nodes
982 if ( compare & 1 ||
Renovate botf591dcf2023-12-30 14:13:54 +0000983 ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100984
985 // Choose the first element that is related to our preferred document
Renovate botf591dcf2023-12-30 14:13:54 +0000986 // Support: IE 11+, Edge 17 - 18+
987 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
988 // two documents; shallow comparisons work.
989 // eslint-disable-next-line eqeqeq
990 if ( a == document || a.ownerDocument == preferredDoc &&
991 contains( preferredDoc, a ) ) {
Copybara botbe50d492023-11-30 00:16:42 +0100992 return -1;
993 }
Renovate botf591dcf2023-12-30 14:13:54 +0000994
995 // Support: IE 11+, Edge 17 - 18+
996 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
997 // two documents; shallow comparisons work.
998 // eslint-disable-next-line eqeqeq
999 if ( b == document || b.ownerDocument == preferredDoc &&
1000 contains( preferredDoc, b ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001001 return 1;
1002 }
1003
1004 // Maintain original order
1005 return sortInput ?
1006 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1007 0;
1008 }
1009
1010 return compare & 4 ? -1 : 1;
1011 } :
1012 function( a, b ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001013
Copybara botbe50d492023-11-30 00:16:42 +01001014 // Exit early if the nodes are identical
1015 if ( a === b ) {
1016 hasDuplicate = true;
1017 return 0;
1018 }
1019
1020 var cur,
1021 i = 0,
1022 aup = a.parentNode,
1023 bup = b.parentNode,
1024 ap = [ a ],
1025 bp = [ b ];
1026
1027 // Parentless nodes are either documents or disconnected
1028 if ( !aup || !bup ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001029
1030 // Support: IE 11+, Edge 17 - 18+
1031 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1032 // two documents; shallow comparisons work.
1033 /* eslint-disable eqeqeq */
1034 return a == document ? -1 :
1035 b == document ? 1 :
1036 /* eslint-enable eqeqeq */
Copybara botbe50d492023-11-30 00:16:42 +01001037 aup ? -1 :
1038 bup ? 1 :
1039 sortInput ?
1040 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1041 0;
1042
1043 // If the nodes are siblings, we can do a quick check
1044 } else if ( aup === bup ) {
1045 return siblingCheck( a, b );
1046 }
1047
1048 // Otherwise we need full lists of their ancestors for comparison
1049 cur = a;
Renovate botf591dcf2023-12-30 14:13:54 +00001050 while ( ( cur = cur.parentNode ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001051 ap.unshift( cur );
1052 }
1053 cur = b;
Renovate botf591dcf2023-12-30 14:13:54 +00001054 while ( ( cur = cur.parentNode ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001055 bp.unshift( cur );
1056 }
1057
1058 // Walk down the tree looking for a discrepancy
Renovate botf591dcf2023-12-30 14:13:54 +00001059 while ( ap[ i ] === bp[ i ] ) {
Copybara botbe50d492023-11-30 00:16:42 +01001060 i++;
1061 }
1062
1063 return i ?
Renovate botf591dcf2023-12-30 14:13:54 +00001064
Copybara botbe50d492023-11-30 00:16:42 +01001065 // Do a sibling check if the nodes have a common ancestor
Renovate botf591dcf2023-12-30 14:13:54 +00001066 siblingCheck( ap[ i ], bp[ i ] ) :
Copybara botbe50d492023-11-30 00:16:42 +01001067
1068 // Otherwise nodes in our document sort first
Renovate botf591dcf2023-12-30 14:13:54 +00001069 // Support: IE 11+, Edge 17 - 18+
1070 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1071 // two documents; shallow comparisons work.
1072 /* eslint-disable eqeqeq */
1073 ap[ i ] == preferredDoc ? -1 :
1074 bp[ i ] == preferredDoc ? 1 :
1075 /* eslint-enable eqeqeq */
Copybara botbe50d492023-11-30 00:16:42 +01001076 0;
1077 };
1078
1079 return document;
1080};
1081
1082Sizzle.matches = function( expr, elements ) {
1083 return Sizzle( expr, null, null, elements );
1084};
1085
1086Sizzle.matchesSelector = function( elem, expr ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001087 setDocument( elem );
Copybara botbe50d492023-11-30 00:16:42 +01001088
1089 if ( support.matchesSelector && documentIsHTML &&
1090 !nonnativeSelectorCache[ expr + " " ] &&
1091 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1092 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1093
1094 try {
1095 var ret = matches.call( elem, expr );
1096
1097 // IE 9's matchesSelector returns false on disconnected nodes
1098 if ( ret || support.disconnectedMatch ||
Renovate botf591dcf2023-12-30 14:13:54 +00001099
1100 // As well, disconnected nodes are said to be in a document
1101 // fragment in IE 9
1102 elem.document && elem.document.nodeType !== 11 ) {
Copybara botbe50d492023-11-30 00:16:42 +01001103 return ret;
1104 }
Renovate botf591dcf2023-12-30 14:13:54 +00001105 } catch ( e ) {
Copybara botbe50d492023-11-30 00:16:42 +01001106 nonnativeSelectorCache( expr, true );
1107 }
1108 }
1109
1110 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1111};
1112
1113Sizzle.contains = function( context, elem ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001114
Copybara botbe50d492023-11-30 00:16:42 +01001115 // Set document vars if needed
Renovate botf591dcf2023-12-30 14:13:54 +00001116 // Support: IE 11+, Edge 17 - 18+
1117 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1118 // two documents; shallow comparisons work.
1119 // eslint-disable-next-line eqeqeq
1120 if ( ( context.ownerDocument || context ) != document ) {
Copybara botbe50d492023-11-30 00:16:42 +01001121 setDocument( context );
1122 }
1123 return contains( context, elem );
1124};
1125
1126Sizzle.attr = function( elem, name ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001127
Copybara botbe50d492023-11-30 00:16:42 +01001128 // Set document vars if needed
Renovate botf591dcf2023-12-30 14:13:54 +00001129 // Support: IE 11+, Edge 17 - 18+
1130 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1131 // two documents; shallow comparisons work.
1132 // eslint-disable-next-line eqeqeq
1133 if ( ( elem.ownerDocument || elem ) != document ) {
Copybara botbe50d492023-11-30 00:16:42 +01001134 setDocument( elem );
1135 }
1136
1137 var fn = Expr.attrHandle[ name.toLowerCase() ],
Renovate botf591dcf2023-12-30 14:13:54 +00001138
Copybara botbe50d492023-11-30 00:16:42 +01001139 // Don't get fooled by Object.prototype properties (jQuery #13807)
1140 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1141 fn( elem, name, !documentIsHTML ) :
1142 undefined;
1143
1144 return val !== undefined ?
1145 val :
1146 support.attributes || !documentIsHTML ?
1147 elem.getAttribute( name ) :
Renovate botf591dcf2023-12-30 14:13:54 +00001148 ( val = elem.getAttributeNode( name ) ) && val.specified ?
Copybara botbe50d492023-11-30 00:16:42 +01001149 val.value :
1150 null;
1151};
1152
1153Sizzle.escape = function( sel ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001154 return ( sel + "" ).replace( rcssescape, fcssescape );
Copybara botbe50d492023-11-30 00:16:42 +01001155};
1156
1157Sizzle.error = function( msg ) {
1158 throw new Error( "Syntax error, unrecognized expression: " + msg );
1159};
1160
1161/**
1162 * Document sorting and removing duplicates
1163 * @param {ArrayLike} results
1164 */
1165Sizzle.uniqueSort = function( results ) {
1166 var elem,
1167 duplicates = [],
1168 j = 0,
1169 i = 0;
1170
1171 // Unless we *know* we can detect duplicates, assume their presence
1172 hasDuplicate = !support.detectDuplicates;
1173 sortInput = !support.sortStable && results.slice( 0 );
1174 results.sort( sortOrder );
1175
1176 if ( hasDuplicate ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001177 while ( ( elem = results[ i++ ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001178 if ( elem === results[ i ] ) {
1179 j = duplicates.push( i );
1180 }
1181 }
1182 while ( j-- ) {
1183 results.splice( duplicates[ j ], 1 );
1184 }
1185 }
1186
1187 // Clear input after sorting to release objects
1188 // See https://github.com/jquery/sizzle/pull/225
1189 sortInput = null;
1190
1191 return results;
1192};
1193
1194/**
1195 * Utility function for retrieving the text value of an array of DOM nodes
1196 * @param {Array|Element} elem
1197 */
1198getText = Sizzle.getText = function( elem ) {
1199 var node,
1200 ret = "",
1201 i = 0,
1202 nodeType = elem.nodeType;
1203
1204 if ( !nodeType ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001205
Copybara botbe50d492023-11-30 00:16:42 +01001206 // If no nodeType, this is expected to be an array
Renovate botf591dcf2023-12-30 14:13:54 +00001207 while ( ( node = elem[ i++ ] ) ) {
1208
Copybara botbe50d492023-11-30 00:16:42 +01001209 // Do not traverse comment nodes
1210 ret += getText( node );
1211 }
1212 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001213
Copybara botbe50d492023-11-30 00:16:42 +01001214 // Use textContent for elements
1215 // innerText usage removed for consistency of new lines (jQuery #11153)
1216 if ( typeof elem.textContent === "string" ) {
1217 return elem.textContent;
1218 } else {
Renovate botf591dcf2023-12-30 14:13:54 +00001219
Copybara botbe50d492023-11-30 00:16:42 +01001220 // Traverse its children
1221 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1222 ret += getText( elem );
1223 }
1224 }
1225 } else if ( nodeType === 3 || nodeType === 4 ) {
1226 return elem.nodeValue;
1227 }
Renovate botf591dcf2023-12-30 14:13:54 +00001228
Copybara botbe50d492023-11-30 00:16:42 +01001229 // Do not include comment or processing instruction nodes
1230
1231 return ret;
1232};
1233
1234Expr = Sizzle.selectors = {
1235
1236 // Can be adjusted by the user
1237 cacheLength: 50,
1238
1239 createPseudo: markFunction,
1240
1241 match: matchExpr,
1242
1243 attrHandle: {},
1244
1245 find: {},
1246
1247 relative: {
1248 ">": { dir: "parentNode", first: true },
1249 " ": { dir: "parentNode" },
1250 "+": { dir: "previousSibling", first: true },
1251 "~": { dir: "previousSibling" }
1252 },
1253
1254 preFilter: {
1255 "ATTR": function( match ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001256 match[ 1 ] = match[ 1 ].replace( runescape, funescape );
Copybara botbe50d492023-11-30 00:16:42 +01001257
1258 // Move the given value to match[3] whether quoted or unquoted
Renovate botf591dcf2023-12-30 14:13:54 +00001259 match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
1260 match[ 5 ] || "" ).replace( runescape, funescape );
Copybara botbe50d492023-11-30 00:16:42 +01001261
Renovate botf591dcf2023-12-30 14:13:54 +00001262 if ( match[ 2 ] === "~=" ) {
1263 match[ 3 ] = " " + match[ 3 ] + " ";
Copybara botbe50d492023-11-30 00:16:42 +01001264 }
1265
1266 return match.slice( 0, 4 );
1267 },
1268
1269 "CHILD": function( match ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001270
Copybara botbe50d492023-11-30 00:16:42 +01001271 /* matches from matchExpr["CHILD"]
1272 1 type (only|nth|...)
1273 2 what (child|of-type)
1274 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1275 4 xn-component of xn+y argument ([+-]?\d*n|)
1276 5 sign of xn-component
1277 6 x of xn-component
1278 7 sign of y-component
1279 8 y of y-component
1280 */
Renovate botf591dcf2023-12-30 14:13:54 +00001281 match[ 1 ] = match[ 1 ].toLowerCase();
Copybara botbe50d492023-11-30 00:16:42 +01001282
Renovate botf591dcf2023-12-30 14:13:54 +00001283 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
1284
Copybara botbe50d492023-11-30 00:16:42 +01001285 // nth-* requires argument
Renovate botf591dcf2023-12-30 14:13:54 +00001286 if ( !match[ 3 ] ) {
1287 Sizzle.error( match[ 0 ] );
Copybara botbe50d492023-11-30 00:16:42 +01001288 }
1289
1290 // numeric x and y parameters for Expr.filter.CHILD
1291 // remember that false/true cast respectively to 0/1
Renovate botf591dcf2023-12-30 14:13:54 +00001292 match[ 4 ] = +( match[ 4 ] ?
1293 match[ 5 ] + ( match[ 6 ] || 1 ) :
1294 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
1295 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
Copybara botbe50d492023-11-30 00:16:42 +01001296
Renovate botf591dcf2023-12-30 14:13:54 +00001297 // other types prohibit arguments
1298 } else if ( match[ 3 ] ) {
1299 Sizzle.error( match[ 0 ] );
Copybara botbe50d492023-11-30 00:16:42 +01001300 }
1301
1302 return match;
1303 },
1304
1305 "PSEUDO": function( match ) {
1306 var excess,
Renovate botf591dcf2023-12-30 14:13:54 +00001307 unquoted = !match[ 6 ] && match[ 2 ];
Copybara botbe50d492023-11-30 00:16:42 +01001308
Renovate botf591dcf2023-12-30 14:13:54 +00001309 if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001310 return null;
1311 }
1312
1313 // Accept quoted arguments as-is
Renovate botf591dcf2023-12-30 14:13:54 +00001314 if ( match[ 3 ] ) {
1315 match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
Copybara botbe50d492023-11-30 00:16:42 +01001316
1317 // Strip excess characters from unquoted arguments
1318 } else if ( unquoted && rpseudo.test( unquoted ) &&
Renovate botf591dcf2023-12-30 14:13:54 +00001319
Copybara botbe50d492023-11-30 00:16:42 +01001320 // Get excess from tokenize (recursively)
Renovate botf591dcf2023-12-30 14:13:54 +00001321 ( excess = tokenize( unquoted, true ) ) &&
1322
Copybara botbe50d492023-11-30 00:16:42 +01001323 // advance to the next closing parenthesis
Renovate botf591dcf2023-12-30 14:13:54 +00001324 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001325
1326 // excess is a negative index
Renovate botf591dcf2023-12-30 14:13:54 +00001327 match[ 0 ] = match[ 0 ].slice( 0, excess );
1328 match[ 2 ] = unquoted.slice( 0, excess );
Copybara botbe50d492023-11-30 00:16:42 +01001329 }
1330
1331 // Return only captures needed by the pseudo filter method (type and argument)
1332 return match.slice( 0, 3 );
1333 }
1334 },
1335
1336 filter: {
1337
1338 "TAG": function( nodeNameSelector ) {
1339 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1340 return nodeNameSelector === "*" ?
Renovate botf591dcf2023-12-30 14:13:54 +00001341 function() {
1342 return true;
1343 } :
Copybara botbe50d492023-11-30 00:16:42 +01001344 function( elem ) {
1345 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1346 };
1347 },
1348
1349 "CLASS": function( className ) {
1350 var pattern = classCache[ className + " " ];
1351
1352 return pattern ||
Renovate botf591dcf2023-12-30 14:13:54 +00001353 ( pattern = new RegExp( "(^|" + whitespace +
1354 ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
1355 className, function( elem ) {
1356 return pattern.test(
1357 typeof elem.className === "string" && elem.className ||
1358 typeof elem.getAttribute !== "undefined" &&
1359 elem.getAttribute( "class" ) ||
1360 ""
1361 );
1362 } );
Copybara botbe50d492023-11-30 00:16:42 +01001363 },
1364
1365 "ATTR": function( name, operator, check ) {
1366 return function( elem ) {
1367 var result = Sizzle.attr( elem, name );
1368
1369 if ( result == null ) {
1370 return operator === "!=";
1371 }
1372 if ( !operator ) {
1373 return true;
1374 }
1375
1376 result += "";
1377
Renovate botf591dcf2023-12-30 14:13:54 +00001378 /* eslint-disable max-len */
1379
Copybara botbe50d492023-11-30 00:16:42 +01001380 return operator === "=" ? result === check :
1381 operator === "!=" ? result !== check :
1382 operator === "^=" ? check && result.indexOf( check ) === 0 :
1383 operator === "*=" ? check && result.indexOf( check ) > -1 :
1384 operator === "$=" ? check && result.slice( -check.length ) === check :
1385 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1386 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1387 false;
Renovate botf591dcf2023-12-30 14:13:54 +00001388 /* eslint-enable max-len */
1389
Copybara botbe50d492023-11-30 00:16:42 +01001390 };
1391 },
1392
Renovate botf591dcf2023-12-30 14:13:54 +00001393 "CHILD": function( type, what, _argument, first, last ) {
Copybara botbe50d492023-11-30 00:16:42 +01001394 var simple = type.slice( 0, 3 ) !== "nth",
1395 forward = type.slice( -4 ) !== "last",
1396 ofType = what === "of-type";
1397
1398 return first === 1 && last === 0 ?
1399
1400 // Shortcut for :nth-*(n)
1401 function( elem ) {
1402 return !!elem.parentNode;
1403 } :
1404
Renovate botf591dcf2023-12-30 14:13:54 +00001405 function( elem, _context, xml ) {
Copybara botbe50d492023-11-30 00:16:42 +01001406 var cache, uniqueCache, outerCache, node, nodeIndex, start,
1407 dir = simple !== forward ? "nextSibling" : "previousSibling",
1408 parent = elem.parentNode,
1409 name = ofType && elem.nodeName.toLowerCase(),
1410 useCache = !xml && !ofType,
1411 diff = false;
1412
1413 if ( parent ) {
1414
1415 // :(first|last|only)-(child|of-type)
1416 if ( simple ) {
1417 while ( dir ) {
1418 node = elem;
Renovate botf591dcf2023-12-30 14:13:54 +00001419 while ( ( node = node[ dir ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001420 if ( ofType ?
1421 node.nodeName.toLowerCase() === name :
1422 node.nodeType === 1 ) {
1423
1424 return false;
1425 }
1426 }
Renovate botf591dcf2023-12-30 14:13:54 +00001427
Copybara botbe50d492023-11-30 00:16:42 +01001428 // Reverse direction for :only-* (if we haven't yet done so)
1429 start = dir = type === "only" && !start && "nextSibling";
1430 }
1431 return true;
1432 }
1433
1434 start = [ forward ? parent.firstChild : parent.lastChild ];
1435
1436 // non-xml :nth-child(...) stores cache data on `parent`
1437 if ( forward && useCache ) {
1438
1439 // Seek `elem` from a previously-cached index
1440
1441 // ...in a gzip-friendly way
1442 node = parent;
Renovate botf591dcf2023-12-30 14:13:54 +00001443 outerCache = node[ expando ] || ( node[ expando ] = {} );
Copybara botbe50d492023-11-30 00:16:42 +01001444
1445 // Support: IE <9 only
1446 // Defend against cloned attroperties (jQuery gh-1709)
1447 uniqueCache = outerCache[ node.uniqueID ] ||
Renovate botf591dcf2023-12-30 14:13:54 +00001448 ( outerCache[ node.uniqueID ] = {} );
Copybara botbe50d492023-11-30 00:16:42 +01001449
1450 cache = uniqueCache[ type ] || [];
1451 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1452 diff = nodeIndex && cache[ 2 ];
1453 node = nodeIndex && parent.childNodes[ nodeIndex ];
1454
Renovate botf591dcf2023-12-30 14:13:54 +00001455 while ( ( node = ++nodeIndex && node && node[ dir ] ||
Copybara botbe50d492023-11-30 00:16:42 +01001456
1457 // Fallback to seeking `elem` from the start
Renovate botf591dcf2023-12-30 14:13:54 +00001458 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001459
1460 // When found, cache indexes on `parent` and break
1461 if ( node.nodeType === 1 && ++diff && node === elem ) {
1462 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
1463 break;
1464 }
1465 }
1466
1467 } else {
Renovate botf591dcf2023-12-30 14:13:54 +00001468
Copybara botbe50d492023-11-30 00:16:42 +01001469 // Use previously-cached element index if available
1470 if ( useCache ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001471
Copybara botbe50d492023-11-30 00:16:42 +01001472 // ...in a gzip-friendly way
1473 node = elem;
Renovate botf591dcf2023-12-30 14:13:54 +00001474 outerCache = node[ expando ] || ( node[ expando ] = {} );
Copybara botbe50d492023-11-30 00:16:42 +01001475
1476 // Support: IE <9 only
1477 // Defend against cloned attroperties (jQuery gh-1709)
1478 uniqueCache = outerCache[ node.uniqueID ] ||
Renovate botf591dcf2023-12-30 14:13:54 +00001479 ( outerCache[ node.uniqueID ] = {} );
Copybara botbe50d492023-11-30 00:16:42 +01001480
1481 cache = uniqueCache[ type ] || [];
1482 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1483 diff = nodeIndex;
1484 }
1485
1486 // xml :nth-child(...)
1487 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1488 if ( diff === false ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001489
Copybara botbe50d492023-11-30 00:16:42 +01001490 // Use the same loop as above to seek `elem` from the start
Renovate botf591dcf2023-12-30 14:13:54 +00001491 while ( ( node = ++nodeIndex && node && node[ dir ] ||
1492 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001493
1494 if ( ( ofType ?
1495 node.nodeName.toLowerCase() === name :
1496 node.nodeType === 1 ) &&
1497 ++diff ) {
1498
1499 // Cache the index of each encountered element
1500 if ( useCache ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001501 outerCache = node[ expando ] ||
1502 ( node[ expando ] = {} );
Copybara botbe50d492023-11-30 00:16:42 +01001503
1504 // Support: IE <9 only
1505 // Defend against cloned attroperties (jQuery gh-1709)
1506 uniqueCache = outerCache[ node.uniqueID ] ||
Renovate botf591dcf2023-12-30 14:13:54 +00001507 ( outerCache[ node.uniqueID ] = {} );
Copybara botbe50d492023-11-30 00:16:42 +01001508
1509 uniqueCache[ type ] = [ dirruns, diff ];
1510 }
1511
1512 if ( node === elem ) {
1513 break;
1514 }
1515 }
1516 }
1517 }
1518 }
1519
1520 // Incorporate the offset, then check against cycle size
1521 diff -= last;
1522 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1523 }
1524 };
1525 },
1526
1527 "PSEUDO": function( pseudo, argument ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001528
Copybara botbe50d492023-11-30 00:16:42 +01001529 // pseudo-class names are case-insensitive
1530 // http://www.w3.org/TR/selectors/#pseudo-classes
1531 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1532 // Remember that setFilters inherits from pseudos
1533 var args,
1534 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1535 Sizzle.error( "unsupported pseudo: " + pseudo );
1536
1537 // The user may use createPseudo to indicate that
1538 // arguments are needed to create the filter function
1539 // just as Sizzle does
1540 if ( fn[ expando ] ) {
1541 return fn( argument );
1542 }
1543
1544 // But maintain support for old signatures
1545 if ( fn.length > 1 ) {
1546 args = [ pseudo, pseudo, "", argument ];
1547 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
Renovate botf591dcf2023-12-30 14:13:54 +00001548 markFunction( function( seed, matches ) {
Copybara botbe50d492023-11-30 00:16:42 +01001549 var idx,
1550 matched = fn( seed, argument ),
1551 i = matched.length;
1552 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001553 idx = indexOf( seed, matched[ i ] );
1554 seed[ idx ] = !( matches[ idx ] = matched[ i ] );
Copybara botbe50d492023-11-30 00:16:42 +01001555 }
Renovate botf591dcf2023-12-30 14:13:54 +00001556 } ) :
Copybara botbe50d492023-11-30 00:16:42 +01001557 function( elem ) {
1558 return fn( elem, 0, args );
1559 };
1560 }
1561
1562 return fn;
1563 }
1564 },
1565
1566 pseudos: {
Renovate botf591dcf2023-12-30 14:13:54 +00001567
Copybara botbe50d492023-11-30 00:16:42 +01001568 // Potentially complex pseudos
Renovate botf591dcf2023-12-30 14:13:54 +00001569 "not": markFunction( function( selector ) {
1570
Copybara botbe50d492023-11-30 00:16:42 +01001571 // Trim the selector passed to compile
1572 // to avoid treating leading and trailing
1573 // spaces as combinators
1574 var input = [],
1575 results = [],
1576 matcher = compile( selector.replace( rtrim, "$1" ) );
1577
1578 return matcher[ expando ] ?
Renovate botf591dcf2023-12-30 14:13:54 +00001579 markFunction( function( seed, matches, _context, xml ) {
Copybara botbe50d492023-11-30 00:16:42 +01001580 var elem,
1581 unmatched = matcher( seed, null, xml, [] ),
1582 i = seed.length;
1583
1584 // Match elements unmatched by `matcher`
1585 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001586 if ( ( elem = unmatched[ i ] ) ) {
1587 seed[ i ] = !( matches[ i ] = elem );
Copybara botbe50d492023-11-30 00:16:42 +01001588 }
1589 }
Renovate botf591dcf2023-12-30 14:13:54 +00001590 } ) :
1591 function( elem, _context, xml ) {
1592 input[ 0 ] = elem;
Copybara botbe50d492023-11-30 00:16:42 +01001593 matcher( input, null, xml, results );
Renovate botf591dcf2023-12-30 14:13:54 +00001594
Copybara botbe50d492023-11-30 00:16:42 +01001595 // Don't keep the element (issue #299)
Renovate botf591dcf2023-12-30 14:13:54 +00001596 input[ 0 ] = null;
Copybara botbe50d492023-11-30 00:16:42 +01001597 return !results.pop();
1598 };
Renovate botf591dcf2023-12-30 14:13:54 +00001599 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001600
Renovate botf591dcf2023-12-30 14:13:54 +00001601 "has": markFunction( function( selector ) {
Copybara botbe50d492023-11-30 00:16:42 +01001602 return function( elem ) {
1603 return Sizzle( selector, elem ).length > 0;
1604 };
Renovate botf591dcf2023-12-30 14:13:54 +00001605 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001606
Renovate botf591dcf2023-12-30 14:13:54 +00001607 "contains": markFunction( function( text ) {
Copybara botbe50d492023-11-30 00:16:42 +01001608 text = text.replace( runescape, funescape );
1609 return function( elem ) {
1610 return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
1611 };
Renovate botf591dcf2023-12-30 14:13:54 +00001612 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001613
1614 // "Whether an element is represented by a :lang() selector
1615 // is based solely on the element's language value
1616 // being equal to the identifier C,
1617 // or beginning with the identifier C immediately followed by "-".
1618 // The matching of C against the element's language value is performed case-insensitively.
1619 // The identifier C does not have to be a valid language name."
1620 // http://www.w3.org/TR/selectors/#lang-pseudo
1621 "lang": markFunction( function( lang ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001622
Copybara botbe50d492023-11-30 00:16:42 +01001623 // lang value must be a valid identifier
Renovate botf591dcf2023-12-30 14:13:54 +00001624 if ( !ridentifier.test( lang || "" ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001625 Sizzle.error( "unsupported lang: " + lang );
1626 }
1627 lang = lang.replace( runescape, funescape ).toLowerCase();
1628 return function( elem ) {
1629 var elemLang;
1630 do {
Renovate botf591dcf2023-12-30 14:13:54 +00001631 if ( ( elemLang = documentIsHTML ?
Copybara botbe50d492023-11-30 00:16:42 +01001632 elem.lang :
Renovate botf591dcf2023-12-30 14:13:54 +00001633 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001634
1635 elemLang = elemLang.toLowerCase();
1636 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1637 }
Renovate botf591dcf2023-12-30 14:13:54 +00001638 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
Copybara botbe50d492023-11-30 00:16:42 +01001639 return false;
1640 };
Renovate botf591dcf2023-12-30 14:13:54 +00001641 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001642
1643 // Miscellaneous
1644 "target": function( elem ) {
1645 var hash = window.location && window.location.hash;
1646 return hash && hash.slice( 1 ) === elem.id;
1647 },
1648
1649 "root": function( elem ) {
1650 return elem === docElem;
1651 },
1652
1653 "focus": function( elem ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001654 return elem === document.activeElement &&
1655 ( !document.hasFocus || document.hasFocus() ) &&
1656 !!( elem.type || elem.href || ~elem.tabIndex );
Copybara botbe50d492023-11-30 00:16:42 +01001657 },
1658
1659 // Boolean properties
1660 "enabled": createDisabledPseudo( false ),
1661 "disabled": createDisabledPseudo( true ),
1662
1663 "checked": function( elem ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001664
Copybara botbe50d492023-11-30 00:16:42 +01001665 // In CSS3, :checked should return both checked and selected elements
1666 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1667 var nodeName = elem.nodeName.toLowerCase();
Renovate botf591dcf2023-12-30 14:13:54 +00001668 return ( nodeName === "input" && !!elem.checked ) ||
1669 ( nodeName === "option" && !!elem.selected );
Copybara botbe50d492023-11-30 00:16:42 +01001670 },
1671
1672 "selected": function( elem ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001673
Copybara botbe50d492023-11-30 00:16:42 +01001674 // Accessing this property makes selected-by-default
1675 // options in Safari work properly
1676 if ( elem.parentNode ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001677 // eslint-disable-next-line no-unused-expressions
Copybara botbe50d492023-11-30 00:16:42 +01001678 elem.parentNode.selectedIndex;
1679 }
1680
1681 return elem.selected === true;
1682 },
1683
1684 // Contents
1685 "empty": function( elem ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001686
Copybara botbe50d492023-11-30 00:16:42 +01001687 // http://www.w3.org/TR/selectors/#empty-pseudo
1688 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1689 // but not by others (comment: 8; processing instruction: 7; etc.)
1690 // nodeType < 6 works because attributes (2) do not appear as children
1691 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1692 if ( elem.nodeType < 6 ) {
1693 return false;
1694 }
1695 }
1696 return true;
1697 },
1698
1699 "parent": function( elem ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001700 return !Expr.pseudos[ "empty" ]( elem );
Copybara botbe50d492023-11-30 00:16:42 +01001701 },
1702
1703 // Element/input types
1704 "header": function( elem ) {
1705 return rheader.test( elem.nodeName );
1706 },
1707
1708 "input": function( elem ) {
1709 return rinputs.test( elem.nodeName );
1710 },
1711
1712 "button": function( elem ) {
1713 var name = elem.nodeName.toLowerCase();
1714 return name === "input" && elem.type === "button" || name === "button";
1715 },
1716
1717 "text": function( elem ) {
1718 var attr;
1719 return elem.nodeName.toLowerCase() === "input" &&
1720 elem.type === "text" &&
1721
1722 // Support: IE<8
1723 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
Renovate botf591dcf2023-12-30 14:13:54 +00001724 ( ( attr = elem.getAttribute( "type" ) ) == null ||
1725 attr.toLowerCase() === "text" );
Copybara botbe50d492023-11-30 00:16:42 +01001726 },
1727
1728 // Position-in-collection
Renovate botf591dcf2023-12-30 14:13:54 +00001729 "first": createPositionalPseudo( function() {
Copybara botbe50d492023-11-30 00:16:42 +01001730 return [ 0 ];
Renovate botf591dcf2023-12-30 14:13:54 +00001731 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001732
Renovate botf591dcf2023-12-30 14:13:54 +00001733 "last": createPositionalPseudo( function( _matchIndexes, length ) {
Copybara botbe50d492023-11-30 00:16:42 +01001734 return [ length - 1 ];
Renovate botf591dcf2023-12-30 14:13:54 +00001735 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001736
Renovate botf591dcf2023-12-30 14:13:54 +00001737 "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
Copybara botbe50d492023-11-30 00:16:42 +01001738 return [ argument < 0 ? argument + length : argument ];
Renovate botf591dcf2023-12-30 14:13:54 +00001739 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001740
Renovate botf591dcf2023-12-30 14:13:54 +00001741 "even": createPositionalPseudo( function( matchIndexes, length ) {
Copybara botbe50d492023-11-30 00:16:42 +01001742 var i = 0;
1743 for ( ; i < length; i += 2 ) {
1744 matchIndexes.push( i );
1745 }
1746 return matchIndexes;
Renovate botf591dcf2023-12-30 14:13:54 +00001747 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001748
Renovate botf591dcf2023-12-30 14:13:54 +00001749 "odd": createPositionalPseudo( function( matchIndexes, length ) {
Copybara botbe50d492023-11-30 00:16:42 +01001750 var i = 1;
1751 for ( ; i < length; i += 2 ) {
1752 matchIndexes.push( i );
1753 }
1754 return matchIndexes;
Renovate botf591dcf2023-12-30 14:13:54 +00001755 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001756
Renovate botf591dcf2023-12-30 14:13:54 +00001757 "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
Copybara botbe50d492023-11-30 00:16:42 +01001758 var i = argument < 0 ?
1759 argument + length :
1760 argument > length ?
1761 length :
1762 argument;
1763 for ( ; --i >= 0; ) {
1764 matchIndexes.push( i );
1765 }
1766 return matchIndexes;
Renovate botf591dcf2023-12-30 14:13:54 +00001767 } ),
Copybara botbe50d492023-11-30 00:16:42 +01001768
Renovate botf591dcf2023-12-30 14:13:54 +00001769 "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
Copybara botbe50d492023-11-30 00:16:42 +01001770 var i = argument < 0 ? argument + length : argument;
1771 for ( ; ++i < length; ) {
1772 matchIndexes.push( i );
1773 }
1774 return matchIndexes;
Renovate botf591dcf2023-12-30 14:13:54 +00001775 } )
Copybara botbe50d492023-11-30 00:16:42 +01001776 }
1777};
1778
Renovate botf591dcf2023-12-30 14:13:54 +00001779Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
Copybara botbe50d492023-11-30 00:16:42 +01001780
1781// Add button/input type pseudos
1782for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
1783 Expr.pseudos[ i ] = createInputPseudo( i );
1784}
1785for ( i in { submit: true, reset: true } ) {
1786 Expr.pseudos[ i ] = createButtonPseudo( i );
1787}
1788
1789// Easy API for creating new setFilters
1790function setFilters() {}
1791setFilters.prototype = Expr.filters = Expr.pseudos;
1792Expr.setFilters = new setFilters();
1793
1794tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
1795 var matched, match, tokens, type,
1796 soFar, groups, preFilters,
1797 cached = tokenCache[ selector + " " ];
1798
1799 if ( cached ) {
1800 return parseOnly ? 0 : cached.slice( 0 );
1801 }
1802
1803 soFar = selector;
1804 groups = [];
1805 preFilters = Expr.preFilter;
1806
1807 while ( soFar ) {
1808
1809 // Comma and first run
Renovate botf591dcf2023-12-30 14:13:54 +00001810 if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001811 if ( match ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001812
Copybara botbe50d492023-11-30 00:16:42 +01001813 // Don't consume trailing commas as valid
Renovate botf591dcf2023-12-30 14:13:54 +00001814 soFar = soFar.slice( match[ 0 ].length ) || soFar;
Copybara botbe50d492023-11-30 00:16:42 +01001815 }
Renovate botf591dcf2023-12-30 14:13:54 +00001816 groups.push( ( tokens = [] ) );
Copybara botbe50d492023-11-30 00:16:42 +01001817 }
1818
1819 matched = false;
1820
1821 // Combinators
Renovate botf591dcf2023-12-30 14:13:54 +00001822 if ( ( match = rcombinators.exec( soFar ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001823 matched = match.shift();
Renovate botf591dcf2023-12-30 14:13:54 +00001824 tokens.push( {
Copybara botbe50d492023-11-30 00:16:42 +01001825 value: matched,
Renovate botf591dcf2023-12-30 14:13:54 +00001826
Copybara botbe50d492023-11-30 00:16:42 +01001827 // Cast descendant combinators to space
Renovate botf591dcf2023-12-30 14:13:54 +00001828 type: match[ 0 ].replace( rtrim, " " )
1829 } );
Copybara botbe50d492023-11-30 00:16:42 +01001830 soFar = soFar.slice( matched.length );
1831 }
1832
1833 // Filters
1834 for ( type in Expr.filter ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001835 if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
1836 ( match = preFilters[ type ]( match ) ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001837 matched = match.shift();
Renovate botf591dcf2023-12-30 14:13:54 +00001838 tokens.push( {
Copybara botbe50d492023-11-30 00:16:42 +01001839 value: matched,
1840 type: type,
1841 matches: match
Renovate botf591dcf2023-12-30 14:13:54 +00001842 } );
Copybara botbe50d492023-11-30 00:16:42 +01001843 soFar = soFar.slice( matched.length );
1844 }
1845 }
1846
1847 if ( !matched ) {
1848 break;
1849 }
1850 }
1851
1852 // Return the length of the invalid excess
1853 // if we're just parsing
1854 // Otherwise, throw an error or return tokens
1855 return parseOnly ?
1856 soFar.length :
1857 soFar ?
1858 Sizzle.error( selector ) :
Renovate botf591dcf2023-12-30 14:13:54 +00001859
Copybara botbe50d492023-11-30 00:16:42 +01001860 // Cache the tokens
1861 tokenCache( selector, groups ).slice( 0 );
1862};
1863
1864function toSelector( tokens ) {
1865 var i = 0,
1866 len = tokens.length,
1867 selector = "";
1868 for ( ; i < len; i++ ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001869 selector += tokens[ i ].value;
Copybara botbe50d492023-11-30 00:16:42 +01001870 }
1871 return selector;
1872}
1873
1874function addCombinator( matcher, combinator, base ) {
1875 var dir = combinator.dir,
1876 skip = combinator.next,
1877 key = skip || dir,
1878 checkNonElements = base && key === "parentNode",
1879 doneName = done++;
1880
1881 return combinator.first ?
Renovate botf591dcf2023-12-30 14:13:54 +00001882
Copybara botbe50d492023-11-30 00:16:42 +01001883 // Check against closest ancestor/preceding element
1884 function( elem, context, xml ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001885 while ( ( elem = elem[ dir ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001886 if ( elem.nodeType === 1 || checkNonElements ) {
1887 return matcher( elem, context, xml );
1888 }
1889 }
1890 return false;
1891 } :
1892
1893 // Check against all ancestor/preceding elements
1894 function( elem, context, xml ) {
1895 var oldCache, uniqueCache, outerCache,
1896 newCache = [ dirruns, doneName ];
1897
1898 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
1899 if ( xml ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001900 while ( ( elem = elem[ dir ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001901 if ( elem.nodeType === 1 || checkNonElements ) {
1902 if ( matcher( elem, context, xml ) ) {
1903 return true;
1904 }
1905 }
1906 }
1907 } else {
Renovate botf591dcf2023-12-30 14:13:54 +00001908 while ( ( elem = elem[ dir ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001909 if ( elem.nodeType === 1 || checkNonElements ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001910 outerCache = elem[ expando ] || ( elem[ expando ] = {} );
Copybara botbe50d492023-11-30 00:16:42 +01001911
1912 // Support: IE <9 only
1913 // Defend against cloned attroperties (jQuery gh-1709)
Renovate botf591dcf2023-12-30 14:13:54 +00001914 uniqueCache = outerCache[ elem.uniqueID ] ||
1915 ( outerCache[ elem.uniqueID ] = {} );
Copybara botbe50d492023-11-30 00:16:42 +01001916
1917 if ( skip && skip === elem.nodeName.toLowerCase() ) {
1918 elem = elem[ dir ] || elem;
Renovate botf591dcf2023-12-30 14:13:54 +00001919 } else if ( ( oldCache = uniqueCache[ key ] ) &&
Copybara botbe50d492023-11-30 00:16:42 +01001920 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
1921
1922 // Assign to newCache so results back-propagate to previous elements
Renovate botf591dcf2023-12-30 14:13:54 +00001923 return ( newCache[ 2 ] = oldCache[ 2 ] );
Copybara botbe50d492023-11-30 00:16:42 +01001924 } else {
Renovate botf591dcf2023-12-30 14:13:54 +00001925
Copybara botbe50d492023-11-30 00:16:42 +01001926 // Reuse newcache so results back-propagate to previous elements
1927 uniqueCache[ key ] = newCache;
1928
1929 // A match means we're done; a fail means we have to keep checking
Renovate botf591dcf2023-12-30 14:13:54 +00001930 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001931 return true;
1932 }
1933 }
1934 }
1935 }
1936 }
1937 return false;
1938 };
1939}
1940
1941function elementMatcher( matchers ) {
1942 return matchers.length > 1 ?
1943 function( elem, context, xml ) {
1944 var i = matchers.length;
1945 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001946 if ( !matchers[ i ]( elem, context, xml ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001947 return false;
1948 }
1949 }
1950 return true;
1951 } :
Renovate botf591dcf2023-12-30 14:13:54 +00001952 matchers[ 0 ];
Copybara botbe50d492023-11-30 00:16:42 +01001953}
1954
1955function multipleContexts( selector, contexts, results ) {
1956 var i = 0,
1957 len = contexts.length;
1958 for ( ; i < len; i++ ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001959 Sizzle( selector, contexts[ i ], results );
Copybara botbe50d492023-11-30 00:16:42 +01001960 }
1961 return results;
1962}
1963
1964function condense( unmatched, map, filter, context, xml ) {
1965 var elem,
1966 newUnmatched = [],
1967 i = 0,
1968 len = unmatched.length,
1969 mapped = map != null;
1970
1971 for ( ; i < len; i++ ) {
Renovate botf591dcf2023-12-30 14:13:54 +00001972 if ( ( elem = unmatched[ i ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01001973 if ( !filter || filter( elem, context, xml ) ) {
1974 newUnmatched.push( elem );
1975 if ( mapped ) {
1976 map.push( i );
1977 }
1978 }
1979 }
1980 }
1981
1982 return newUnmatched;
1983}
1984
1985function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
1986 if ( postFilter && !postFilter[ expando ] ) {
1987 postFilter = setMatcher( postFilter );
1988 }
1989 if ( postFinder && !postFinder[ expando ] ) {
1990 postFinder = setMatcher( postFinder, postSelector );
1991 }
Renovate botf591dcf2023-12-30 14:13:54 +00001992 return markFunction( function( seed, results, context, xml ) {
Copybara botbe50d492023-11-30 00:16:42 +01001993 var temp, i, elem,
1994 preMap = [],
1995 postMap = [],
1996 preexisting = results.length,
1997
1998 // Get initial elements from seed or context
Renovate botf591dcf2023-12-30 14:13:54 +00001999 elems = seed || multipleContexts(
2000 selector || "*",
2001 context.nodeType ? [ context ] : context,
2002 []
2003 ),
Copybara botbe50d492023-11-30 00:16:42 +01002004
2005 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2006 matcherIn = preFilter && ( seed || !selector ) ?
2007 condense( elems, preMap, preFilter, context, xml ) :
2008 elems,
2009
2010 matcherOut = matcher ?
Renovate botf591dcf2023-12-30 14:13:54 +00002011
Copybara botbe50d492023-11-30 00:16:42 +01002012 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2013 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2014
2015 // ...intermediate processing is necessary
2016 [] :
2017
2018 // ...otherwise use results directly
2019 results :
2020 matcherIn;
2021
2022 // Find primary matches
2023 if ( matcher ) {
2024 matcher( matcherIn, matcherOut, context, xml );
2025 }
2026
2027 // Apply postFilter
2028 if ( postFilter ) {
2029 temp = condense( matcherOut, postMap );
2030 postFilter( temp, [], context, xml );
2031
2032 // Un-match failing elements by moving them back to matcherIn
2033 i = temp.length;
2034 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002035 if ( ( elem = temp[ i ] ) ) {
2036 matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
Copybara botbe50d492023-11-30 00:16:42 +01002037 }
2038 }
2039 }
2040
2041 if ( seed ) {
2042 if ( postFinder || preFilter ) {
2043 if ( postFinder ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002044
Copybara botbe50d492023-11-30 00:16:42 +01002045 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2046 temp = [];
2047 i = matcherOut.length;
2048 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002049 if ( ( elem = matcherOut[ i ] ) ) {
2050
Copybara botbe50d492023-11-30 00:16:42 +01002051 // Restore matcherIn since elem is not yet a final match
Renovate botf591dcf2023-12-30 14:13:54 +00002052 temp.push( ( matcherIn[ i ] = elem ) );
Copybara botbe50d492023-11-30 00:16:42 +01002053 }
2054 }
Renovate botf591dcf2023-12-30 14:13:54 +00002055 postFinder( null, ( matcherOut = [] ), temp, xml );
Copybara botbe50d492023-11-30 00:16:42 +01002056 }
2057
2058 // Move matched elements from seed to results to keep them synchronized
2059 i = matcherOut.length;
2060 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002061 if ( ( elem = matcherOut[ i ] ) &&
2062 ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
Copybara botbe50d492023-11-30 00:16:42 +01002063
Renovate botf591dcf2023-12-30 14:13:54 +00002064 seed[ temp ] = !( results[ temp ] = elem );
Copybara botbe50d492023-11-30 00:16:42 +01002065 }
2066 }
2067 }
2068
2069 // Add elements to results, through postFinder if defined
2070 } else {
2071 matcherOut = condense(
2072 matcherOut === results ?
2073 matcherOut.splice( preexisting, matcherOut.length ) :
2074 matcherOut
2075 );
2076 if ( postFinder ) {
2077 postFinder( null, results, matcherOut, xml );
2078 } else {
2079 push.apply( results, matcherOut );
2080 }
2081 }
Renovate botf591dcf2023-12-30 14:13:54 +00002082 } );
Copybara botbe50d492023-11-30 00:16:42 +01002083}
2084
2085function matcherFromTokens( tokens ) {
2086 var checkContext, matcher, j,
2087 len = tokens.length,
Renovate botf591dcf2023-12-30 14:13:54 +00002088 leadingRelative = Expr.relative[ tokens[ 0 ].type ],
2089 implicitRelative = leadingRelative || Expr.relative[ " " ],
Copybara botbe50d492023-11-30 00:16:42 +01002090 i = leadingRelative ? 1 : 0,
2091
2092 // The foundational matcher ensures that elements are reachable from top-level context(s)
2093 matchContext = addCombinator( function( elem ) {
2094 return elem === checkContext;
2095 }, implicitRelative, true ),
2096 matchAnyContext = addCombinator( function( elem ) {
2097 return indexOf( checkContext, elem ) > -1;
2098 }, implicitRelative, true ),
2099 matchers = [ function( elem, context, xml ) {
2100 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
Renovate botf591dcf2023-12-30 14:13:54 +00002101 ( checkContext = context ).nodeType ?
Copybara botbe50d492023-11-30 00:16:42 +01002102 matchContext( elem, context, xml ) :
2103 matchAnyContext( elem, context, xml ) );
Renovate botf591dcf2023-12-30 14:13:54 +00002104
Copybara botbe50d492023-11-30 00:16:42 +01002105 // Avoid hanging onto element (issue #299)
2106 checkContext = null;
2107 return ret;
2108 } ];
2109
2110 for ( ; i < len; i++ ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002111 if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
2112 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
Copybara botbe50d492023-11-30 00:16:42 +01002113 } else {
Renovate botf591dcf2023-12-30 14:13:54 +00002114 matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
Copybara botbe50d492023-11-30 00:16:42 +01002115
2116 // Return special upon seeing a positional matcher
2117 if ( matcher[ expando ] ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002118
Copybara botbe50d492023-11-30 00:16:42 +01002119 // Find the next relative operator (if any) for proper handling
2120 j = ++i;
2121 for ( ; j < len; j++ ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002122 if ( Expr.relative[ tokens[ j ].type ] ) {
Copybara botbe50d492023-11-30 00:16:42 +01002123 break;
2124 }
2125 }
2126 return setMatcher(
2127 i > 1 && elementMatcher( matchers ),
2128 i > 1 && toSelector(
Renovate botf591dcf2023-12-30 14:13:54 +00002129
2130 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2131 tokens
2132 .slice( 0, i - 1 )
2133 .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
Copybara botbe50d492023-11-30 00:16:42 +01002134 ).replace( rtrim, "$1" ),
2135 matcher,
2136 i < j && matcherFromTokens( tokens.slice( i, j ) ),
Renovate botf591dcf2023-12-30 14:13:54 +00002137 j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
Copybara botbe50d492023-11-30 00:16:42 +01002138 j < len && toSelector( tokens )
2139 );
2140 }
2141 matchers.push( matcher );
2142 }
2143 }
2144
2145 return elementMatcher( matchers );
2146}
2147
2148function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2149 var bySet = setMatchers.length > 0,
2150 byElement = elementMatchers.length > 0,
2151 superMatcher = function( seed, context, xml, results, outermost ) {
2152 var elem, j, matcher,
2153 matchedCount = 0,
2154 i = "0",
2155 unmatched = seed && [],
2156 setMatched = [],
2157 contextBackup = outermostContext,
Renovate botf591dcf2023-12-30 14:13:54 +00002158
Copybara botbe50d492023-11-30 00:16:42 +01002159 // We must always have either seed elements or outermost context
Renovate botf591dcf2023-12-30 14:13:54 +00002160 elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
2161
Copybara botbe50d492023-11-30 00:16:42 +01002162 // Use integer dirruns iff this is the outermost matcher
Renovate botf591dcf2023-12-30 14:13:54 +00002163 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
Copybara botbe50d492023-11-30 00:16:42 +01002164 len = elems.length;
2165
2166 if ( outermost ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002167
2168 // Support: IE 11+, Edge 17 - 18+
2169 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2170 // two documents; shallow comparisons work.
2171 // eslint-disable-next-line eqeqeq
2172 outermostContext = context == document || context || outermost;
Copybara botbe50d492023-11-30 00:16:42 +01002173 }
2174
2175 // Add elements passing elementMatchers directly to results
2176 // Support: IE<9, Safari
2177 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
Renovate botf591dcf2023-12-30 14:13:54 +00002178 for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
Copybara botbe50d492023-11-30 00:16:42 +01002179 if ( byElement && elem ) {
2180 j = 0;
Renovate botf591dcf2023-12-30 14:13:54 +00002181
2182 // Support: IE 11+, Edge 17 - 18+
2183 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2184 // two documents; shallow comparisons work.
2185 // eslint-disable-next-line eqeqeq
2186 if ( !context && elem.ownerDocument != document ) {
Copybara botbe50d492023-11-30 00:16:42 +01002187 setDocument( elem );
2188 xml = !documentIsHTML;
2189 }
Renovate botf591dcf2023-12-30 14:13:54 +00002190 while ( ( matcher = elementMatchers[ j++ ] ) ) {
2191 if ( matcher( elem, context || document, xml ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01002192 results.push( elem );
2193 break;
2194 }
2195 }
2196 if ( outermost ) {
2197 dirruns = dirrunsUnique;
2198 }
2199 }
2200
2201 // Track unmatched elements for set filters
2202 if ( bySet ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002203
Copybara botbe50d492023-11-30 00:16:42 +01002204 // They will have gone through all possible matchers
Renovate botf591dcf2023-12-30 14:13:54 +00002205 if ( ( elem = !matcher && elem ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01002206 matchedCount--;
2207 }
2208
2209 // Lengthen the array for every element, matched or not
2210 if ( seed ) {
2211 unmatched.push( elem );
2212 }
2213 }
2214 }
2215
2216 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2217 // makes the latter nonnegative.
2218 matchedCount += i;
2219
2220 // Apply set filters to unmatched elements
2221 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2222 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2223 // no element matchers and no seed.
2224 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2225 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2226 // numerically zero.
2227 if ( bySet && i !== matchedCount ) {
2228 j = 0;
Renovate botf591dcf2023-12-30 14:13:54 +00002229 while ( ( matcher = setMatchers[ j++ ] ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01002230 matcher( unmatched, setMatched, context, xml );
2231 }
2232
2233 if ( seed ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002234
Copybara botbe50d492023-11-30 00:16:42 +01002235 // Reintegrate element matches to eliminate the need for sorting
2236 if ( matchedCount > 0 ) {
2237 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002238 if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
2239 setMatched[ i ] = pop.call( results );
Copybara botbe50d492023-11-30 00:16:42 +01002240 }
2241 }
2242 }
2243
2244 // Discard index placeholder values to get only actual matches
2245 setMatched = condense( setMatched );
2246 }
2247
2248 // Add matches to results
2249 push.apply( results, setMatched );
2250
2251 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2252 if ( outermost && !seed && setMatched.length > 0 &&
2253 ( matchedCount + setMatchers.length ) > 1 ) {
2254
2255 Sizzle.uniqueSort( results );
2256 }
2257 }
2258
2259 // Override manipulation of globals by nested matchers
2260 if ( outermost ) {
2261 dirruns = dirrunsUnique;
2262 outermostContext = contextBackup;
2263 }
2264
2265 return unmatched;
2266 };
2267
2268 return bySet ?
2269 markFunction( superMatcher ) :
2270 superMatcher;
2271}
2272
2273compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2274 var i,
2275 setMatchers = [],
2276 elementMatchers = [],
2277 cached = compilerCache[ selector + " " ];
2278
2279 if ( !cached ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002280
Copybara botbe50d492023-11-30 00:16:42 +01002281 // Generate a function of recursive functions that can be used to check each element
2282 if ( !match ) {
2283 match = tokenize( selector );
2284 }
2285 i = match.length;
2286 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002287 cached = matcherFromTokens( match[ i ] );
Copybara botbe50d492023-11-30 00:16:42 +01002288 if ( cached[ expando ] ) {
2289 setMatchers.push( cached );
2290 } else {
2291 elementMatchers.push( cached );
2292 }
2293 }
2294
2295 // Cache the compiled function
Renovate botf591dcf2023-12-30 14:13:54 +00002296 cached = compilerCache(
2297 selector,
2298 matcherFromGroupMatchers( elementMatchers, setMatchers )
2299 );
Copybara botbe50d492023-11-30 00:16:42 +01002300
2301 // Save selector and tokenization
2302 cached.selector = selector;
2303 }
2304 return cached;
2305};
2306
2307/**
2308 * A low-level selection function that works with Sizzle's compiled
2309 * selector functions
2310 * @param {String|Function} selector A selector or a pre-compiled
2311 * selector function built with Sizzle.compile
2312 * @param {Element} context
2313 * @param {Array} [results]
2314 * @param {Array} [seed] A set of elements to match against
2315 */
2316select = Sizzle.select = function( selector, context, results, seed ) {
2317 var i, tokens, token, type, find,
2318 compiled = typeof selector === "function" && selector,
Renovate botf591dcf2023-12-30 14:13:54 +00002319 match = !seed && tokenize( ( selector = compiled.selector || selector ) );
Copybara botbe50d492023-11-30 00:16:42 +01002320
2321 results = results || [];
2322
2323 // Try to minimize operations if there is only one selector in the list and no seed
2324 // (the latter of which guarantees us context)
2325 if ( match.length === 1 ) {
2326
2327 // Reduce context if the leading compound selector is an ID
Renovate botf591dcf2023-12-30 14:13:54 +00002328 tokens = match[ 0 ] = match[ 0 ].slice( 0 );
2329 if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
2330 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
Copybara botbe50d492023-11-30 00:16:42 +01002331
Renovate botf591dcf2023-12-30 14:13:54 +00002332 context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
2333 .replace( runescape, funescape ), context ) || [] )[ 0 ];
Copybara botbe50d492023-11-30 00:16:42 +01002334 if ( !context ) {
2335 return results;
2336
2337 // Precompiled matchers will still verify ancestry, so step up a level
2338 } else if ( compiled ) {
2339 context = context.parentNode;
2340 }
2341
2342 selector = selector.slice( tokens.shift().value.length );
2343 }
2344
2345 // Fetch a seed set for right-to-left matching
Renovate botf591dcf2023-12-30 14:13:54 +00002346 i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
Copybara botbe50d492023-11-30 00:16:42 +01002347 while ( i-- ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002348 token = tokens[ i ];
Copybara botbe50d492023-11-30 00:16:42 +01002349
2350 // Abort if we hit a combinator
Renovate botf591dcf2023-12-30 14:13:54 +00002351 if ( Expr.relative[ ( type = token.type ) ] ) {
Copybara botbe50d492023-11-30 00:16:42 +01002352 break;
2353 }
Renovate botf591dcf2023-12-30 14:13:54 +00002354 if ( ( find = Expr.find[ type ] ) ) {
2355
Copybara botbe50d492023-11-30 00:16:42 +01002356 // Search, expanding context for leading sibling combinators
Renovate botf591dcf2023-12-30 14:13:54 +00002357 if ( ( seed = find(
2358 token.matches[ 0 ].replace( runescape, funescape ),
2359 rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
2360 context
2361 ) ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01002362
2363 // If seed is empty or no tokens remain, we can return early
2364 tokens.splice( i, 1 );
2365 selector = seed.length && toSelector( tokens );
2366 if ( !selector ) {
2367 push.apply( results, seed );
2368 return results;
2369 }
2370
2371 break;
2372 }
2373 }
2374 }
2375 }
2376
2377 // Compile and execute a filtering function if one is not provided
2378 // Provide `match` to avoid retokenization if we modified the selector above
2379 ( compiled || compile( selector, match ) )(
2380 seed,
2381 context,
2382 !documentIsHTML,
2383 results,
2384 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2385 );
2386 return results;
2387};
2388
2389// One-time assignments
2390
2391// Sort stability
Renovate botf591dcf2023-12-30 14:13:54 +00002392support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
Copybara botbe50d492023-11-30 00:16:42 +01002393
2394// Support: Chrome 14-35+
2395// Always assume duplicates if they aren't passed to the comparison function
2396support.detectDuplicates = !!hasDuplicate;
2397
2398// Initialize against the default document
2399setDocument();
2400
2401// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2402// Detached nodes confoundingly follow *each other*
Renovate botf591dcf2023-12-30 14:13:54 +00002403support.sortDetached = assert( function( el ) {
2404
Copybara botbe50d492023-11-30 00:16:42 +01002405 // Should return 1, but returns 4 (following)
Renovate botf591dcf2023-12-30 14:13:54 +00002406 return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
2407} );
Copybara botbe50d492023-11-30 00:16:42 +01002408
2409// Support: IE<8
2410// Prevent attribute/property "interpolation"
2411// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
Renovate botf591dcf2023-12-30 14:13:54 +00002412if ( !assert( function( el ) {
Copybara botbe50d492023-11-30 00:16:42 +01002413 el.innerHTML = "<a href='#'></a>";
Renovate botf591dcf2023-12-30 14:13:54 +00002414 return el.firstChild.getAttribute( "href" ) === "#";
2415} ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01002416 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2417 if ( !isXML ) {
2418 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2419 }
Renovate botf591dcf2023-12-30 14:13:54 +00002420 } );
Copybara botbe50d492023-11-30 00:16:42 +01002421}
2422
2423// Support: IE<9
2424// Use defaultValue in place of getAttribute("value")
Renovate botf591dcf2023-12-30 14:13:54 +00002425if ( !support.attributes || !assert( function( el ) {
Copybara botbe50d492023-11-30 00:16:42 +01002426 el.innerHTML = "<input/>";
2427 el.firstChild.setAttribute( "value", "" );
2428 return el.firstChild.getAttribute( "value" ) === "";
Renovate botf591dcf2023-12-30 14:13:54 +00002429} ) ) {
2430 addHandle( "value", function( elem, _name, isXML ) {
Copybara botbe50d492023-11-30 00:16:42 +01002431 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2432 return elem.defaultValue;
2433 }
Renovate botf591dcf2023-12-30 14:13:54 +00002434 } );
Copybara botbe50d492023-11-30 00:16:42 +01002435}
2436
2437// Support: IE<9
2438// Use getAttributeNode to fetch booleans when getAttribute lies
Renovate botf591dcf2023-12-30 14:13:54 +00002439if ( !assert( function( el ) {
2440 return el.getAttribute( "disabled" ) == null;
2441} ) ) {
Copybara botbe50d492023-11-30 00:16:42 +01002442 addHandle( booleans, function( elem, name, isXML ) {
2443 var val;
2444 if ( !isXML ) {
2445 return elem[ name ] === true ? name.toLowerCase() :
Renovate botf591dcf2023-12-30 14:13:54 +00002446 ( val = elem.getAttributeNode( name ) ) && val.specified ?
Copybara botbe50d492023-11-30 00:16:42 +01002447 val.value :
Renovate botf591dcf2023-12-30 14:13:54 +00002448 null;
Copybara botbe50d492023-11-30 00:16:42 +01002449 }
Renovate botf591dcf2023-12-30 14:13:54 +00002450 } );
Copybara botbe50d492023-11-30 00:16:42 +01002451}
2452
2453// EXPOSE
2454var _sizzle = window.Sizzle;
2455
2456Sizzle.noConflict = function() {
2457 if ( window.Sizzle === Sizzle ) {
2458 window.Sizzle = _sizzle;
2459 }
2460
2461 return Sizzle;
2462};
2463
2464if ( typeof define === "function" && define.amd ) {
Renovate botf591dcf2023-12-30 14:13:54 +00002465 define( function() {
2466 return Sizzle;
2467 } );
2468
Copybara botbe50d492023-11-30 00:16:42 +01002469// Sizzle requires that there be a global window in Common-JS like environments
2470} else if ( typeof module !== "undefined" && module.exports ) {
2471 module.exports = Sizzle;
2472} else {
2473 window.Sizzle = Sizzle;
2474}
Renovate botf591dcf2023-12-30 14:13:54 +00002475
Copybara botbe50d492023-11-30 00:16:42 +01002476// EXPOSE
2477
Renovate botf591dcf2023-12-30 14:13:54 +00002478} )( window );