@whenessel/seql-js 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/seql-js.d.ts +2 -0
- package/dist/seql-js.js +622 -525
- package/dist/seql-js.js.map +1 -1
- package/dist/seql-js.umd.cjs +3 -3
- package/dist/seql-js.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/seql-js.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Ae = "1.0", xe = 10, z = {
|
|
2
2
|
ANCHOR: 0.4,
|
|
3
3
|
PATH: 0.3,
|
|
4
4
|
TARGET: 0.2,
|
|
@@ -12,9 +12,9 @@ const fe = "1.0", ge = 10, U = {
|
|
|
12
12
|
DEPTH_PENALTY_THRESHOLD: 5,
|
|
13
13
|
DEPTH_PENALTY_FACTOR: 0.05,
|
|
14
14
|
DEGRADED_SCORE: 0.3
|
|
15
|
-
},
|
|
15
|
+
}, bt = {
|
|
16
16
|
MIN_CONFIDENCE_FOR_SKIP: 0.7
|
|
17
|
-
},
|
|
17
|
+
}, tt = [
|
|
18
18
|
"form",
|
|
19
19
|
"main",
|
|
20
20
|
"nav",
|
|
@@ -22,7 +22,7 @@ const fe = "1.0", ge = 10, U = {
|
|
|
22
22
|
"article",
|
|
23
23
|
"footer",
|
|
24
24
|
"header"
|
|
25
|
-
],
|
|
25
|
+
], et = [
|
|
26
26
|
"form",
|
|
27
27
|
"navigation",
|
|
28
28
|
"main",
|
|
@@ -31,7 +31,7 @@ const fe = "1.0", ge = 10, U = {
|
|
|
31
31
|
"complementary",
|
|
32
32
|
"banner",
|
|
33
33
|
"search"
|
|
34
|
-
],
|
|
34
|
+
], St = [
|
|
35
35
|
// HTML5 Semantic
|
|
36
36
|
"article",
|
|
37
37
|
"aside",
|
|
@@ -108,7 +108,7 @@ const fe = "1.0", ge = 10, U = {
|
|
|
108
108
|
"g",
|
|
109
109
|
"text",
|
|
110
110
|
"use"
|
|
111
|
-
],
|
|
111
|
+
], yt = [
|
|
112
112
|
"rect",
|
|
113
113
|
"path",
|
|
114
114
|
"circle",
|
|
@@ -122,7 +122,7 @@ const fe = "1.0", ge = 10, U = {
|
|
|
122
122
|
"defs",
|
|
123
123
|
"clipPath",
|
|
124
124
|
"mask"
|
|
125
|
-
],
|
|
125
|
+
], Ce = [
|
|
126
126
|
"aria-label",
|
|
127
127
|
"aria-labelledby",
|
|
128
128
|
"aria-describedby",
|
|
@@ -162,7 +162,7 @@ const fe = "1.0", ge = 10, U = {
|
|
|
162
162
|
"data-*": 30,
|
|
163
163
|
// Any aria-* attribute (if not above)
|
|
164
164
|
"aria-*": 25
|
|
165
|
-
},
|
|
165
|
+
}, Y = /* @__PURE__ */ new Set([
|
|
166
166
|
"id",
|
|
167
167
|
// handled separately
|
|
168
168
|
"class",
|
|
@@ -174,23 +174,30 @@ const fe = "1.0", ge = 10, U = {
|
|
|
174
174
|
"tabindex",
|
|
175
175
|
// can change
|
|
176
176
|
"contenteditable"
|
|
177
|
-
]),
|
|
177
|
+
]), At = {
|
|
178
178
|
maxPathDepth: 10,
|
|
179
179
|
enableSvgFingerprint: !0,
|
|
180
180
|
confidenceThreshold: 0,
|
|
181
181
|
fallbackToBody: !0,
|
|
182
182
|
includeUtilityClasses: !1,
|
|
183
183
|
source: "dom-dsl"
|
|
184
|
-
},
|
|
184
|
+
}, xt = {
|
|
185
185
|
strictMode: !1,
|
|
186
186
|
enableFallback: !0,
|
|
187
187
|
maxCandidates: 20,
|
|
188
188
|
matchUrlsByPathOnly: !0
|
|
189
189
|
};
|
|
190
|
-
function
|
|
191
|
-
|
|
190
|
+
function L(r) {
|
|
191
|
+
if (/^[a-z]+-\d+$/i.test(r) || /^[a-z]+(-[a-z]+)+-\d+$/i.test(r) || /^[a-z]+(_[a-z]+)*_\d+$/i.test(r) || /^\d+$/.test(r) || /^:[a-z0-9]+:$/i.test(r) || /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(r))
|
|
192
|
+
return !0;
|
|
193
|
+
if (/^[a-z]{1,3}[A-Za-z0-9]{8,}$/.test(r)) {
|
|
194
|
+
const t = /\d/.test(r), e = /[A-Z]/.test(r), s = r.length >= 20;
|
|
195
|
+
if (t && e || s)
|
|
196
|
+
return !0;
|
|
197
|
+
}
|
|
198
|
+
return !!(/^radix-/.test(r) || /^mui-\d+$/.test(r));
|
|
192
199
|
}
|
|
193
|
-
const
|
|
200
|
+
const Z = /* @__PURE__ */ new Set([
|
|
194
201
|
"aria-labelledby",
|
|
195
202
|
"aria-describedby",
|
|
196
203
|
"aria-controls",
|
|
@@ -204,10 +211,10 @@ const Q = /* @__PURE__ */ new Set([
|
|
|
204
211
|
"aria-errormessage",
|
|
205
212
|
"aria-flowto"
|
|
206
213
|
]);
|
|
207
|
-
function
|
|
208
|
-
return r.trim().split(/\s+/).some((e) =>
|
|
214
|
+
function K(r) {
|
|
215
|
+
return r.trim().split(/\s+/).some((e) => L(e));
|
|
209
216
|
}
|
|
210
|
-
class
|
|
217
|
+
class Ct {
|
|
211
218
|
constructor(t, e) {
|
|
212
219
|
this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
|
|
213
220
|
}
|
|
@@ -240,25 +247,25 @@ class St {
|
|
|
240
247
|
if (e === "head" || this.isInsideHead(t)) {
|
|
241
248
|
const c = s?.documentElement;
|
|
242
249
|
if (c) {
|
|
243
|
-
const
|
|
250
|
+
const l = {
|
|
244
251
|
element: c,
|
|
245
252
|
score: 1,
|
|
246
253
|
tier: "A",
|
|
247
254
|
depth: 0
|
|
248
255
|
};
|
|
249
|
-
return this.cacheResult(t,
|
|
256
|
+
return this.cacheResult(t, l), l;
|
|
250
257
|
}
|
|
251
258
|
}
|
|
252
259
|
if (e === "body") {
|
|
253
260
|
const c = s?.documentElement;
|
|
254
261
|
if (c) {
|
|
255
|
-
const
|
|
262
|
+
const l = {
|
|
256
263
|
element: c,
|
|
257
264
|
score: 1,
|
|
258
265
|
tier: "A",
|
|
259
266
|
depth: 0
|
|
260
267
|
};
|
|
261
|
-
return this.cacheResult(t,
|
|
268
|
+
return this.cacheResult(t, l), l;
|
|
262
269
|
}
|
|
263
270
|
}
|
|
264
271
|
let n = t.parentElement, a = 0, i = null;
|
|
@@ -272,10 +279,10 @@ class St {
|
|
|
272
279
|
};
|
|
273
280
|
const c = this.scoreAnchor(n);
|
|
274
281
|
if (c > 0) {
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
return
|
|
278
|
-
(!i ||
|
|
282
|
+
const l = this.applyDepthPenalty(c, a), f = this.getTier(n), h = { element: n, score: l, tier: f, depth: a };
|
|
283
|
+
if (f === "A")
|
|
284
|
+
return h;
|
|
285
|
+
(!i || l > i.score) && (i = h);
|
|
279
286
|
}
|
|
280
287
|
n = n.parentElement, a++;
|
|
281
288
|
}
|
|
@@ -290,11 +297,11 @@ class St {
|
|
|
290
297
|
scoreAnchor(t) {
|
|
291
298
|
let e = 0;
|
|
292
299
|
const s = t.tagName.toLowerCase();
|
|
293
|
-
|
|
300
|
+
tt.includes(s) && (e += I.SEMANTIC_TAG);
|
|
294
301
|
const n = t.getAttribute("role");
|
|
295
|
-
n &&
|
|
302
|
+
n && et.includes(n) && (e += I.ROLE), (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) && (e += I.ARIA_LABEL);
|
|
296
303
|
const a = t.id;
|
|
297
|
-
return a && !
|
|
304
|
+
return a && !L(a) && (e += I.STABLE_ID), (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test")) && (e += I.TEST_MARKER), Math.min(e, 1);
|
|
298
305
|
}
|
|
299
306
|
/**
|
|
300
307
|
* Applies depth penalty to score
|
|
@@ -311,10 +318,10 @@ class St {
|
|
|
311
318
|
*/
|
|
312
319
|
getTier(t) {
|
|
313
320
|
const e = t.tagName.toLowerCase();
|
|
314
|
-
if (
|
|
321
|
+
if (tt.includes(e))
|
|
315
322
|
return "A";
|
|
316
323
|
const s = t.getAttribute("role");
|
|
317
|
-
return s &&
|
|
324
|
+
return s && et.includes(s) ? "B" : "C";
|
|
318
325
|
}
|
|
319
326
|
/**
|
|
320
327
|
* Checks if element is inside <head> section.
|
|
@@ -347,7 +354,7 @@ class St {
|
|
|
347
354
|
this.cache && this.cache.setAnchor(t, e);
|
|
348
355
|
}
|
|
349
356
|
}
|
|
350
|
-
const
|
|
357
|
+
const Tt = [
|
|
351
358
|
// CSS-in-JS
|
|
352
359
|
/^css-[a-z0-9]+$/i,
|
|
353
360
|
/^sc-[a-z0-9]+-\d+$/i,
|
|
@@ -367,7 +374,7 @@ const At = [
|
|
|
367
374
|
/^_[a-z0-9]{5,}$/i,
|
|
368
375
|
/\d{5,}/
|
|
369
376
|
// 5+ digits in a row
|
|
370
|
-
],
|
|
377
|
+
], Et = [
|
|
371
378
|
// === FIX 4: Tailwind arbitrary values and variants (highest priority) ===
|
|
372
379
|
/^\[/,
|
|
373
380
|
// Any arbitrary value or variant starting with [ (e.g., [&_svg]:..., [mask-type:luminance])
|
|
@@ -385,6 +392,11 @@ const At = [
|
|
|
385
392
|
/^(rtl|ltr):/,
|
|
386
393
|
// === FIX 4: Group and peer variants ===
|
|
387
394
|
/^(group|peer)(-hover|-focus|-active)?:/,
|
|
395
|
+
// === Arbitrary pseudo-class/modifier variants (catch-all) ===
|
|
396
|
+
// Matches any lowercase/hyphenated prefix followed by colon
|
|
397
|
+
// e.g., file:bg-transparent, placeholder:text-gray, invalid:border-red, accept:text-primary
|
|
398
|
+
// Must come AFTER semantic pattern checks to avoid false positives
|
|
399
|
+
/^[a-z][a-z-]*:/,
|
|
388
400
|
// === FIX 4: Tailwind utilities with fraction values ===
|
|
389
401
|
/\/([\d.]+|full|auto|screen)$/,
|
|
390
402
|
// /50, /100, /full, /auto, /screen
|
|
@@ -473,7 +485,7 @@ const At = [
|
|
|
473
485
|
/^clearfix$/,
|
|
474
486
|
/^pull-(left|right)$/,
|
|
475
487
|
/^float-(left|right|none)$/
|
|
476
|
-
],
|
|
488
|
+
], wt = [
|
|
477
489
|
// === Navigation ===
|
|
478
490
|
/^(nav|menu|header|footer|sidebar|topbar|navbar|breadcrumb)/,
|
|
479
491
|
/(navigation|dropdown|megamenu)$/,
|
|
@@ -500,41 +512,91 @@ const At = [
|
|
|
500
512
|
// === Status ===
|
|
501
513
|
/^(loading|pending|complete|failed|draft|published)/
|
|
502
514
|
];
|
|
503
|
-
function
|
|
504
|
-
return
|
|
515
|
+
function q(r) {
|
|
516
|
+
return Tt.some((t) => t.test(r));
|
|
505
517
|
}
|
|
506
|
-
function
|
|
507
|
-
return r.length <= 2 || /^\d/.test(r) ? !0 :
|
|
518
|
+
function U(r) {
|
|
519
|
+
return r.length <= 2 || /^\d/.test(r) ? !0 : Et.some((t) => t.test(r));
|
|
508
520
|
}
|
|
509
|
-
function
|
|
510
|
-
return
|
|
521
|
+
function vt(r) {
|
|
522
|
+
return q(r) || U(r) ? !1 : wt.some((t) => t.test(r));
|
|
511
523
|
}
|
|
512
|
-
function
|
|
513
|
-
return !
|
|
524
|
+
function $t(r) {
|
|
525
|
+
return !q(r) && !U(r);
|
|
514
526
|
}
|
|
515
527
|
function M(r) {
|
|
516
|
-
return r.filter((t) =>
|
|
528
|
+
return r.filter((t) => $t(t));
|
|
517
529
|
}
|
|
518
|
-
function
|
|
519
|
-
if (
|
|
530
|
+
function Nt(r) {
|
|
531
|
+
if (q(r) || U(r))
|
|
520
532
|
return 0;
|
|
521
533
|
let t = 0.5;
|
|
522
|
-
return
|
|
534
|
+
return vt(r) && (t = 0.8), r.length < 3 ? t *= 0.3 : r.length < 5 && (t *= 0.6), /\d/.test(r) && (t *= 0.7), Math.min(t, 1);
|
|
523
535
|
}
|
|
524
|
-
function
|
|
536
|
+
function It(r) {
|
|
525
537
|
const t = [], e = [];
|
|
526
538
|
for (const s of r)
|
|
527
|
-
|
|
539
|
+
U(s) || q(s) ? e.push(s) : t.push(s);
|
|
528
540
|
return { semantic: t, utility: e };
|
|
529
541
|
}
|
|
530
|
-
function
|
|
531
|
-
return
|
|
542
|
+
function st(r) {
|
|
543
|
+
return U(r) || q(r);
|
|
532
544
|
}
|
|
533
|
-
function
|
|
534
|
-
return
|
|
545
|
+
function Te(r) {
|
|
546
|
+
return Nt(r);
|
|
535
547
|
}
|
|
536
|
-
const
|
|
537
|
-
|
|
548
|
+
const Rt = /* @__PURE__ */ new Set([
|
|
549
|
+
"tr",
|
|
550
|
+
"td",
|
|
551
|
+
"th",
|
|
552
|
+
"thead",
|
|
553
|
+
"tbody",
|
|
554
|
+
"tfoot"
|
|
555
|
+
]), Dt = /* @__PURE__ */ new Set([
|
|
556
|
+
"data-testid",
|
|
557
|
+
"data-qa",
|
|
558
|
+
"data-cy",
|
|
559
|
+
"data-test",
|
|
560
|
+
"aria-label",
|
|
561
|
+
"name",
|
|
562
|
+
"href"
|
|
563
|
+
]);
|
|
564
|
+
function Mt(r) {
|
|
565
|
+
if (r.id) return !0;
|
|
566
|
+
if (r.attributes) {
|
|
567
|
+
for (const t of Object.keys(r.attributes))
|
|
568
|
+
if (Dt.has(t)) return !0;
|
|
569
|
+
}
|
|
570
|
+
return !1;
|
|
571
|
+
}
|
|
572
|
+
function Lt(r, t, e) {
|
|
573
|
+
const s = r.parentElement;
|
|
574
|
+
if (!s) return !0;
|
|
575
|
+
for (const n of Array.from(s.children)) {
|
|
576
|
+
if (n === r || n.tagName.toLowerCase() !== t) continue;
|
|
577
|
+
if ((n.textContent?.trim() ?? "") === e) return !1;
|
|
578
|
+
}
|
|
579
|
+
return !0;
|
|
580
|
+
}
|
|
581
|
+
function _(r, t, e) {
|
|
582
|
+
if (Rt.has(r)) return !0;
|
|
583
|
+
if (Mt(t)) return !1;
|
|
584
|
+
if (e) {
|
|
585
|
+
const s = e.parentElement;
|
|
586
|
+
if (s) {
|
|
587
|
+
const n = t.text?.normalized;
|
|
588
|
+
if (n && Lt(e, r, n))
|
|
589
|
+
return !1;
|
|
590
|
+
if (Array.from(s.children).some(
|
|
591
|
+
(i) => i !== e && i.tagName.toLowerCase() === r
|
|
592
|
+
)) return !0;
|
|
593
|
+
}
|
|
594
|
+
return !1;
|
|
595
|
+
}
|
|
596
|
+
return !0;
|
|
597
|
+
}
|
|
598
|
+
const rt = (r) => r.replace(/([#:.[\]@])/g, "\\$1");
|
|
599
|
+
class Pt {
|
|
538
600
|
constructor(t, e) {
|
|
539
601
|
this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
|
|
540
602
|
}
|
|
@@ -569,19 +631,22 @@ class $t {
|
|
|
569
631
|
degraded: !0,
|
|
570
632
|
degradationReason: "target-not-descendant-of-anchor"
|
|
571
633
|
};
|
|
572
|
-
let
|
|
573
|
-
return
|
|
574
|
-
path:
|
|
575
|
-
const h =
|
|
634
|
+
let l = this.filterNoise(i);
|
|
635
|
+
return l = this.ensureUniqueness(i, l, t, e, s), {
|
|
636
|
+
path: l.map((h) => {
|
|
637
|
+
const d = h.tagName.toLowerCase(), u = s.extract(h);
|
|
576
638
|
let g;
|
|
577
|
-
if (h) {
|
|
578
|
-
const m =
|
|
579
|
-
|
|
639
|
+
if (_(d, u, h)) {
|
|
640
|
+
const m = h.parentElement;
|
|
641
|
+
if (m) {
|
|
642
|
+
const b = Array.from(m.children).indexOf(h);
|
|
643
|
+
b !== -1 && (g = b + 1);
|
|
644
|
+
}
|
|
580
645
|
}
|
|
581
646
|
return {
|
|
582
|
-
tag:
|
|
583
|
-
semantics:
|
|
584
|
-
score: s.scoreElement(
|
|
647
|
+
tag: d,
|
|
648
|
+
semantics: u,
|
|
649
|
+
score: s.scoreElement(h),
|
|
585
650
|
nthChild: g
|
|
586
651
|
};
|
|
587
652
|
}),
|
|
@@ -606,27 +671,27 @@ class $t {
|
|
|
606
671
|
if (!o) return e;
|
|
607
672
|
let c;
|
|
608
673
|
if (this.cache) {
|
|
609
|
-
const
|
|
610
|
-
|
|
674
|
+
const f = this.cache.getSelectorResults(i);
|
|
675
|
+
f !== void 0 ? c = f : (c = Array.from(o.querySelectorAll(i)), this.cache.setSelectorResults(i, c));
|
|
611
676
|
} else
|
|
612
677
|
c = o.querySelectorAll(i);
|
|
613
678
|
if (c.length <= 1)
|
|
614
679
|
return e;
|
|
615
|
-
const
|
|
616
|
-
for (const
|
|
617
|
-
if (a.scoreElement(
|
|
680
|
+
const l = t.filter((f) => !e.includes(f));
|
|
681
|
+
for (const f of l) {
|
|
682
|
+
if (a.scoreElement(f) < bt.MIN_CONFIDENCE_FOR_SKIP)
|
|
618
683
|
continue;
|
|
619
|
-
const
|
|
684
|
+
const d = this.insertNodeInOrder(e, f, t), u = this.buildTestSelector(s, d, n);
|
|
620
685
|
try {
|
|
621
|
-
let
|
|
686
|
+
let g;
|
|
622
687
|
if (this.cache) {
|
|
623
|
-
const m = this.cache.getSelectorResults(
|
|
624
|
-
m !== void 0 ?
|
|
688
|
+
const m = this.cache.getSelectorResults(u);
|
|
689
|
+
m !== void 0 ? g = m : (g = Array.from(o.querySelectorAll(u)), this.cache.setSelectorResults(u, g));
|
|
625
690
|
} else
|
|
626
|
-
|
|
627
|
-
if (
|
|
628
|
-
return
|
|
629
|
-
|
|
691
|
+
g = o.querySelectorAll(u);
|
|
692
|
+
if (g.length === 1)
|
|
693
|
+
return d;
|
|
694
|
+
g.length < c.length && (e = d);
|
|
630
695
|
} catch {
|
|
631
696
|
}
|
|
632
697
|
}
|
|
@@ -660,9 +725,9 @@ class $t {
|
|
|
660
725
|
*/
|
|
661
726
|
elementToSelector(t) {
|
|
662
727
|
let e = t.tagName.toLowerCase();
|
|
663
|
-
t.id && !
|
|
728
|
+
t.id && !L(t.id) && (e += `#${rt(t.id)}`);
|
|
664
729
|
for (const s of Array.from(t.classList))
|
|
665
|
-
|
|
730
|
+
st(s) || (e += `.${rt(s)}`);
|
|
666
731
|
return e;
|
|
667
732
|
}
|
|
668
733
|
/**
|
|
@@ -676,7 +741,7 @@ class $t {
|
|
|
676
741
|
*/
|
|
677
742
|
shouldInclude(t) {
|
|
678
743
|
const e = t.tagName.toLowerCase();
|
|
679
|
-
return
|
|
744
|
+
return St.includes(e) ? !0 : e === "div" || e === "span" ? this.hasSemanticFeatures(t) : !1;
|
|
680
745
|
}
|
|
681
746
|
/**
|
|
682
747
|
* Checks if element has meaningful semantic features
|
|
@@ -687,12 +752,12 @@ class $t {
|
|
|
687
752
|
if (s.name.startsWith("aria-")) return !0;
|
|
688
753
|
if (t.classList.length > 0) {
|
|
689
754
|
for (const s of Array.from(t.classList))
|
|
690
|
-
if (!
|
|
755
|
+
if (!st(s)) return !0;
|
|
691
756
|
}
|
|
692
757
|
if (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test"))
|
|
693
758
|
return !0;
|
|
694
759
|
const e = t.id;
|
|
695
|
-
return !!(e && !
|
|
760
|
+
return !!(e && !L(e));
|
|
696
761
|
}
|
|
697
762
|
/**
|
|
698
763
|
* Checks if element is inside <head> section.
|
|
@@ -739,31 +804,34 @@ class $t {
|
|
|
739
804
|
degradationReason: "head-not-found-in-path"
|
|
740
805
|
} : {
|
|
741
806
|
path: n.map((c) => {
|
|
742
|
-
const
|
|
743
|
-
let
|
|
744
|
-
if (
|
|
745
|
-
const
|
|
746
|
-
|
|
807
|
+
const l = c.tagName.toLowerCase(), f = s.extract(c);
|
|
808
|
+
let h;
|
|
809
|
+
if (_(l, f, c)) {
|
|
810
|
+
const d = c.parentElement;
|
|
811
|
+
if (d) {
|
|
812
|
+
const g = Array.from(d.children).indexOf(c);
|
|
813
|
+
g !== -1 && (h = g + 1);
|
|
814
|
+
}
|
|
747
815
|
}
|
|
748
816
|
return {
|
|
749
|
-
tag:
|
|
750
|
-
semantics:
|
|
817
|
+
tag: l,
|
|
818
|
+
semantics: f,
|
|
751
819
|
score: s.scoreElement(c),
|
|
752
|
-
nthChild:
|
|
820
|
+
nthChild: h
|
|
753
821
|
};
|
|
754
822
|
}),
|
|
755
823
|
degraded: !1
|
|
756
824
|
};
|
|
757
825
|
}
|
|
758
826
|
}
|
|
759
|
-
function
|
|
827
|
+
function j(r) {
|
|
760
828
|
return r ? r.trim().replace(/[\n\t\r]/g, " ").replace(/\s+/g, " ") : "";
|
|
761
829
|
}
|
|
762
|
-
const
|
|
830
|
+
const Ht = {
|
|
763
831
|
preserveQueryForAbsolute: !0,
|
|
764
832
|
removeDynamicHashes: !0
|
|
765
833
|
};
|
|
766
|
-
function
|
|
834
|
+
function kt(r) {
|
|
767
835
|
return r ? [
|
|
768
836
|
/\d{5,}/,
|
|
769
837
|
// 5+ digits
|
|
@@ -777,18 +845,18 @@ function It(r) {
|
|
|
777
845
|
// UUID-like
|
|
778
846
|
].some((e) => e.test(r)) : !1;
|
|
779
847
|
}
|
|
780
|
-
function
|
|
848
|
+
function _t(r, t) {
|
|
781
849
|
if (!r) return r;
|
|
782
850
|
const e = r.startsWith("http://") || r.startsWith("https://"), [s, n] = r.split("#"), [a, i] = s.split("?");
|
|
783
851
|
let o = a;
|
|
784
|
-
return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), n && (t.removeDynamicHashes &&
|
|
852
|
+
return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), n && (t.removeDynamicHashes && kt(n) || (o += `#${n}`)), o;
|
|
785
853
|
}
|
|
786
854
|
function D(r, t, e = {}) {
|
|
787
855
|
if (!t) return t;
|
|
788
|
-
const s = { ...
|
|
789
|
-
return r === "href" || r === "src" ?
|
|
856
|
+
const s = { ...Ht, ...e };
|
|
857
|
+
return r === "href" || r === "src" ? _t(t, s) : t;
|
|
790
858
|
}
|
|
791
|
-
const
|
|
859
|
+
const Ot = [
|
|
792
860
|
"role",
|
|
793
861
|
"aria-label",
|
|
794
862
|
"aria-labelledby",
|
|
@@ -799,7 +867,7 @@ const Dt = [
|
|
|
799
867
|
"aria-posinset",
|
|
800
868
|
"aria-setsize",
|
|
801
869
|
"aria-haspopup"
|
|
802
|
-
],
|
|
870
|
+
], qt = [
|
|
803
871
|
"aria-selected",
|
|
804
872
|
"aria-checked",
|
|
805
873
|
"aria-pressed",
|
|
@@ -812,7 +880,7 @@ const Dt = [
|
|
|
812
880
|
"aria-grabbed",
|
|
813
881
|
"aria-live",
|
|
814
882
|
"aria-atomic"
|
|
815
|
-
],
|
|
883
|
+
], Ut = [
|
|
816
884
|
"data-state",
|
|
817
885
|
"data-active",
|
|
818
886
|
"data-inactive",
|
|
@@ -831,7 +899,7 @@ const Dt = [
|
|
|
831
899
|
"data-hover",
|
|
832
900
|
"data-orientation",
|
|
833
901
|
"data-theme"
|
|
834
|
-
],
|
|
902
|
+
], zt = [
|
|
835
903
|
"data-radix-",
|
|
836
904
|
"data-headlessui-",
|
|
837
905
|
"data-reach-",
|
|
@@ -839,7 +907,7 @@ const Dt = [
|
|
|
839
907
|
"data-chakra-",
|
|
840
908
|
"data-mantine-",
|
|
841
909
|
"data-tw-"
|
|
842
|
-
],
|
|
910
|
+
], Ft = [
|
|
843
911
|
"data-testid",
|
|
844
912
|
"data-test-id",
|
|
845
913
|
"data-test",
|
|
@@ -851,7 +919,7 @@ const Dt = [
|
|
|
851
919
|
"data-entity-id",
|
|
852
920
|
"data-product-id",
|
|
853
921
|
"data-user-id"
|
|
854
|
-
],
|
|
922
|
+
], jt = [
|
|
855
923
|
// Google Analytics / GTM
|
|
856
924
|
"data-ga",
|
|
857
925
|
"data-gtm",
|
|
@@ -887,7 +955,7 @@ const Dt = [
|
|
|
887
955
|
"data-conversion",
|
|
888
956
|
"data-segment",
|
|
889
957
|
"data-analytics"
|
|
890
|
-
],
|
|
958
|
+
], Wt = [
|
|
891
959
|
"data-category",
|
|
892
960
|
// Google Analytics category
|
|
893
961
|
"data-action",
|
|
@@ -896,7 +964,7 @@ const Dt = [
|
|
|
896
964
|
// Google Analytics label
|
|
897
965
|
"data-value"
|
|
898
966
|
// Google Analytics value
|
|
899
|
-
],
|
|
967
|
+
], Bt = [
|
|
900
968
|
"id",
|
|
901
969
|
"name",
|
|
902
970
|
"type",
|
|
@@ -905,7 +973,7 @@ const Dt = [
|
|
|
905
973
|
"for",
|
|
906
974
|
"alt",
|
|
907
975
|
"href"
|
|
908
|
-
],
|
|
976
|
+
], Gt = [
|
|
909
977
|
"disabled",
|
|
910
978
|
"checked",
|
|
911
979
|
"selected",
|
|
@@ -913,17 +981,17 @@ const Dt = [
|
|
|
913
981
|
"readonly",
|
|
914
982
|
"required",
|
|
915
983
|
"value"
|
|
916
|
-
],
|
|
984
|
+
], Vt = [
|
|
917
985
|
/^radix-/,
|
|
918
986
|
/^headlessui-/,
|
|
919
987
|
/^mui-/,
|
|
920
988
|
/:\w+:/
|
|
921
989
|
// matches :ru:, :r1:, etc.
|
|
922
990
|
];
|
|
923
|
-
function
|
|
924
|
-
return
|
|
991
|
+
function Qt(r, t) {
|
|
992
|
+
return Ot.includes(r) ? !0 : qt.includes(r) || Ut.includes(r) || zt.some((e) => r.startsWith(e)) ? !1 : Ft.includes(r) ? !0 : jt.some((e) => r.startsWith(e)) || Wt.includes(r) ? !1 : r.startsWith("data-") && r.endsWith("-id") ? !0 : r === "id" ? !Vt.some((e) => e.test(t)) : Bt.includes(r) ? !0 : Gt.includes(r) ? !1 : !!r.startsWith("data-");
|
|
925
993
|
}
|
|
926
|
-
class
|
|
994
|
+
class nt {
|
|
927
995
|
constructor(t, e) {
|
|
928
996
|
this.includeUtilityClasses = t.includeUtilityClasses ?? !1, this.cache = e;
|
|
929
997
|
}
|
|
@@ -939,12 +1007,12 @@ class st {
|
|
|
939
1007
|
return i;
|
|
940
1008
|
}
|
|
941
1009
|
const e = {}, s = t.id;
|
|
942
|
-
if (s && !
|
|
1010
|
+
if (s && !L(s) && (e.id = s), t.classList.length > 0) {
|
|
943
1011
|
const i = Array.from(t.classList);
|
|
944
1012
|
if (this.includeUtilityClasses)
|
|
945
1013
|
e.classes = i;
|
|
946
1014
|
else {
|
|
947
|
-
const { semantic: o } =
|
|
1015
|
+
const { semantic: o } = It(i);
|
|
948
1016
|
o.length > 0 && (e.classes = o);
|
|
949
1017
|
}
|
|
950
1018
|
}
|
|
@@ -973,7 +1041,7 @@ class st {
|
|
|
973
1041
|
* @returns True if should be ignored
|
|
974
1042
|
*/
|
|
975
1043
|
shouldIgnoreAttribute(t) {
|
|
976
|
-
return !!(
|
|
1044
|
+
return !!(Y.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
|
|
977
1045
|
}
|
|
978
1046
|
/**
|
|
979
1047
|
* Gets attribute priority
|
|
@@ -1008,7 +1076,7 @@ class st {
|
|
|
1008
1076
|
const e = {};
|
|
1009
1077
|
for (const s of Array.from(t.attributes)) {
|
|
1010
1078
|
const n = s.name;
|
|
1011
|
-
if (this.shouldIgnoreAttribute(n) || !
|
|
1079
|
+
if (this.shouldIgnoreAttribute(n) || !Qt(n, s.value) || Z.has(n) && K(s.value) || this.getAttributePriority(n) === 0) continue;
|
|
1012
1080
|
const i = n === "href" || n === "src" ? D(n, s.value) : s.value;
|
|
1013
1081
|
!i || i.trim() === "" || this.isDynamicValue(i) || (e[n] = i);
|
|
1014
1082
|
}
|
|
@@ -1020,7 +1088,7 @@ class st {
|
|
|
1020
1088
|
extractText(t) {
|
|
1021
1089
|
const e = this.getDirectTextContent(t);
|
|
1022
1090
|
if (!e) return null;
|
|
1023
|
-
const s =
|
|
1091
|
+
const s = j(e);
|
|
1024
1092
|
if (!s) return null;
|
|
1025
1093
|
const n = 100, a = e.length > n ? e.slice(0, n) + "..." : e, i = s.length > n ? s.slice(0, n) + "..." : s;
|
|
1026
1094
|
return {
|
|
@@ -1068,7 +1136,7 @@ class st {
|
|
|
1068
1136
|
].includes(e);
|
|
1069
1137
|
}
|
|
1070
1138
|
}
|
|
1071
|
-
class
|
|
1139
|
+
class Yt {
|
|
1072
1140
|
/**
|
|
1073
1141
|
* Generates fingerprint for SVG element
|
|
1074
1142
|
* @param element - SVG element to fingerprint
|
|
@@ -1179,15 +1247,15 @@ class Ft {
|
|
|
1179
1247
|
return Math.abs(e).toString(16).padStart(8, "0");
|
|
1180
1248
|
}
|
|
1181
1249
|
}
|
|
1182
|
-
function
|
|
1183
|
-
const e = r.anchor.score, s = r.path.length > 0 ? r.path.reduce((o, c) => o + c.score, 0) / r.path.length : 0.5, n = r.target.score, a = e *
|
|
1250
|
+
function Zt(r, t = 0) {
|
|
1251
|
+
const e = r.anchor.score, s = r.path.length > 0 ? r.path.reduce((o, c) => o + c.score, 0) / r.path.length : 0.5, n = r.target.score, a = e * z.ANCHOR + s * z.PATH + n * z.TARGET + t * z.UNIQUENESS, i = r.anchor.degraded ? 0.2 : 0;
|
|
1184
1252
|
return Math.max(0, Math.min(1, a - i));
|
|
1185
1253
|
}
|
|
1186
|
-
function
|
|
1254
|
+
function Ee(r, t, e) {
|
|
1187
1255
|
let s = 0.5;
|
|
1188
1256
|
return t && (s += 0.2), e && (s += 0.15), s += Math.min(r * 0.05, 0.15), Math.min(s, 1);
|
|
1189
1257
|
}
|
|
1190
|
-
class
|
|
1258
|
+
class Kt {
|
|
1191
1259
|
constructor(t) {
|
|
1192
1260
|
this.cache = /* @__PURE__ */ new Map(), this.maxSize = t;
|
|
1193
1261
|
}
|
|
@@ -1218,9 +1286,9 @@ class Wt {
|
|
|
1218
1286
|
return this.cache.size;
|
|
1219
1287
|
}
|
|
1220
1288
|
}
|
|
1221
|
-
class
|
|
1289
|
+
class Xt {
|
|
1222
1290
|
constructor(t = {}) {
|
|
1223
|
-
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new
|
|
1291
|
+
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new Kt(
|
|
1224
1292
|
t.maxSelectorCacheSize ?? 1e3
|
|
1225
1293
|
), this.anchorCache = /* @__PURE__ */ new WeakMap(), this.semanticsCache = /* @__PURE__ */ new WeakMap(), this.stats = {
|
|
1226
1294
|
eidHits: 0,
|
|
@@ -1369,15 +1437,15 @@ class Bt {
|
|
|
1369
1437
|
return s > 0 ? t / s : 0;
|
|
1370
1438
|
}
|
|
1371
1439
|
}
|
|
1372
|
-
function
|
|
1373
|
-
return new
|
|
1440
|
+
function Jt(r) {
|
|
1441
|
+
return new Xt(r);
|
|
1374
1442
|
}
|
|
1375
|
-
let
|
|
1376
|
-
function
|
|
1377
|
-
return
|
|
1443
|
+
let F = null;
|
|
1444
|
+
function X() {
|
|
1445
|
+
return F || (F = Jt()), F;
|
|
1378
1446
|
}
|
|
1379
|
-
function
|
|
1380
|
-
|
|
1447
|
+
function we() {
|
|
1448
|
+
F = null;
|
|
1381
1449
|
}
|
|
1382
1450
|
function k(r) {
|
|
1383
1451
|
if (r.ownerDocument)
|
|
@@ -1395,7 +1463,7 @@ function k(r) {
|
|
|
1395
1463
|
3. You are working with a document node instead of an element`
|
|
1396
1464
|
);
|
|
1397
1465
|
}
|
|
1398
|
-
function
|
|
1466
|
+
function te(r, t) {
|
|
1399
1467
|
if (!t)
|
|
1400
1468
|
return;
|
|
1401
1469
|
const e = k(r), s = t instanceof Document ? t : k(t);
|
|
@@ -1410,63 +1478,64 @@ Common causes:
|
|
|
1410
1478
|
Solution: Ensure element and root parameter are from the same document context.`
|
|
1411
1479
|
);
|
|
1412
1480
|
}
|
|
1413
|
-
function
|
|
1481
|
+
function J(r, t = {}) {
|
|
1414
1482
|
if (!r || !r.ownerDocument || !r.isConnected)
|
|
1415
1483
|
return null;
|
|
1416
|
-
const e = { ...
|
|
1484
|
+
const e = { ...At, ...t };
|
|
1417
1485
|
if (e.root)
|
|
1418
1486
|
try {
|
|
1419
|
-
|
|
1487
|
+
te(r, e.root);
|
|
1420
1488
|
} catch (x) {
|
|
1421
1489
|
return console.error("Cross-document generation detected:", x), null;
|
|
1422
1490
|
}
|
|
1423
|
-
const s = e.cache ??
|
|
1491
|
+
const s = e.cache ?? X(), n = s.getEID(r);
|
|
1424
1492
|
if (n !== void 0)
|
|
1425
1493
|
return n;
|
|
1426
|
-
|
|
1427
|
-
|
|
1494
|
+
const a = r.tagName.toLowerCase();
|
|
1495
|
+
if (a === "html") {
|
|
1496
|
+
const x = new nt(e, s), y = re(r, e, x);
|
|
1428
1497
|
return s.setEID(r, y), y;
|
|
1429
1498
|
}
|
|
1430
|
-
const i = new
|
|
1431
|
-
if (!
|
|
1499
|
+
const i = new Ct(e, s), o = new Pt(e, s), c = new nt(e, s), l = new Yt(), f = i.findAnchor(r);
|
|
1500
|
+
if (!f && !e.fallbackToBody)
|
|
1432
1501
|
return null;
|
|
1433
|
-
const
|
|
1434
|
-
if (!
|
|
1435
|
-
const
|
|
1436
|
-
let
|
|
1437
|
-
if (
|
|
1438
|
-
const y = Array.from(
|
|
1439
|
-
y !== -1 && (
|
|
1440
|
-
}
|
|
1441
|
-
const
|
|
1442
|
-
tag:
|
|
1443
|
-
semantics:
|
|
1444
|
-
score:
|
|
1445
|
-
degraded:
|
|
1446
|
-
nthChild:
|
|
1447
|
-
}, S = o.buildPath(
|
|
1448
|
-
e.enableSvgFingerprint &&
|
|
1502
|
+
const h = f?.element ?? r.ownerDocument?.body ?? null;
|
|
1503
|
+
if (!h) return null;
|
|
1504
|
+
const d = !f || f.tier === "C", u = h.tagName.toLowerCase(), g = c.extract(h), m = h.parentElement;
|
|
1505
|
+
let p;
|
|
1506
|
+
if (m && u !== "body" && u !== "html" && _(u, g, h)) {
|
|
1507
|
+
const y = Array.from(m.children).indexOf(h);
|
|
1508
|
+
y !== -1 && (p = y + 1);
|
|
1509
|
+
}
|
|
1510
|
+
const b = {
|
|
1511
|
+
tag: h.tagName.toLowerCase(),
|
|
1512
|
+
semantics: g,
|
|
1513
|
+
score: f?.score ?? I.DEGRADED_SCORE,
|
|
1514
|
+
degraded: d,
|
|
1515
|
+
nthChild: p
|
|
1516
|
+
}, S = o.buildPath(h, r, c), T = c.extract(r);
|
|
1517
|
+
e.enableSvgFingerprint && ee(r) && (T.svg = l.fingerprint(r));
|
|
1449
1518
|
const C = r.parentElement;
|
|
1450
1519
|
let A;
|
|
1451
|
-
if (C) {
|
|
1520
|
+
if (C && _(a, T, r)) {
|
|
1452
1521
|
const y = Array.from(C.children).indexOf(r);
|
|
1453
1522
|
y !== -1 && (A = y + 1);
|
|
1454
1523
|
}
|
|
1455
1524
|
const v = {
|
|
1456
1525
|
tag: r.tagName.toLowerCase(),
|
|
1457
|
-
semantics:
|
|
1526
|
+
semantics: T,
|
|
1458
1527
|
score: c.scoreElement(r),
|
|
1459
1528
|
nthChild: A
|
|
1460
|
-
},
|
|
1529
|
+
}, P = [], $ = {
|
|
1461
1530
|
onMultiple: "best-score",
|
|
1462
1531
|
onMissing: "anchor-only",
|
|
1463
1532
|
maxDepth: 3
|
|
1464
|
-
},
|
|
1533
|
+
}, E = b.degraded || S.degraded, R = se(b.degraded, S), N = {
|
|
1465
1534
|
version: "1.0",
|
|
1466
1535
|
anchor: b,
|
|
1467
1536
|
path: S.path,
|
|
1468
1537
|
target: v,
|
|
1469
|
-
constraints:
|
|
1538
|
+
constraints: P,
|
|
1470
1539
|
fallback: $,
|
|
1471
1540
|
meta: {
|
|
1472
1541
|
confidence: 0,
|
|
@@ -1474,16 +1543,16 @@ function X(r, t = {}) {
|
|
|
1474
1543
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1475
1544
|
generator: "dom-eid@1.0",
|
|
1476
1545
|
source: e.source,
|
|
1477
|
-
degraded:
|
|
1546
|
+
degraded: E,
|
|
1478
1547
|
degradationReason: R
|
|
1479
1548
|
}
|
|
1480
1549
|
};
|
|
1481
|
-
return N.meta.confidence =
|
|
1550
|
+
return N.meta.confidence = Zt(N), N.meta.confidence < e.confidenceThreshold ? null : (s.setEID(r, N), N);
|
|
1482
1551
|
}
|
|
1483
|
-
function
|
|
1552
|
+
function ee(r) {
|
|
1484
1553
|
return r.namespaceURI === "http://www.w3.org/2000/svg" || r.tagName.toLowerCase() === "svg" || r instanceof SVGElement;
|
|
1485
1554
|
}
|
|
1486
|
-
function
|
|
1555
|
+
function se(r, t) {
|
|
1487
1556
|
if (r && t.degraded)
|
|
1488
1557
|
return "anchor-and-path-degraded";
|
|
1489
1558
|
if (r)
|
|
@@ -1491,7 +1560,7 @@ function Yt(r, t) {
|
|
|
1491
1560
|
if (t.degraded)
|
|
1492
1561
|
return t.degradationReason;
|
|
1493
1562
|
}
|
|
1494
|
-
function
|
|
1563
|
+
function re(r, t, e, s) {
|
|
1495
1564
|
const a = {
|
|
1496
1565
|
tag: "html",
|
|
1497
1566
|
semantics: e.extract(r),
|
|
@@ -1520,42 +1589,42 @@ function Zt(r, t, e, s) {
|
|
|
1520
1589
|
}
|
|
1521
1590
|
};
|
|
1522
1591
|
}
|
|
1523
|
-
class
|
|
1592
|
+
class lt {
|
|
1524
1593
|
buildSelector(t, e) {
|
|
1525
1594
|
if (t.target.tag === "html") {
|
|
1526
|
-
const
|
|
1595
|
+
const h = "html";
|
|
1527
1596
|
return e?.ensureUnique ? {
|
|
1528
|
-
selector:
|
|
1597
|
+
selector: h,
|
|
1529
1598
|
isUnique: !0,
|
|
1530
1599
|
usedNthOfType: !1,
|
|
1531
1600
|
extraClassesAdded: 0
|
|
1532
|
-
} :
|
|
1601
|
+
} : h;
|
|
1533
1602
|
}
|
|
1534
1603
|
if (t.anchor.tag === "html" && t.path.length === 0) {
|
|
1535
|
-
const
|
|
1604
|
+
const d = `html > ${this.buildNodeSelector(t.target.tag, t.target.semantics)}`;
|
|
1536
1605
|
return e?.ensureUnique ? {
|
|
1537
|
-
selector:
|
|
1538
|
-
isUnique: this.isUnique(
|
|
1606
|
+
selector: d,
|
|
1607
|
+
isUnique: this.isUnique(d, e.root ?? document),
|
|
1539
1608
|
usedNthOfType: !1,
|
|
1540
1609
|
extraClassesAdded: 0
|
|
1541
|
-
} :
|
|
1610
|
+
} : d;
|
|
1542
1611
|
}
|
|
1543
1612
|
if (t.anchor.tag === "html" && t.path.length > 0 && t.path[0].tag === "head")
|
|
1544
1613
|
return this.buildHeadSelector(t, e);
|
|
1545
1614
|
if (t.path.length === 0 && t.anchor.tag === t.target.tag && JSON.stringify(t.anchor.semantics) === JSON.stringify(t.target.semantics)) {
|
|
1546
|
-
const
|
|
1615
|
+
const h = this.buildNodeSelector(
|
|
1547
1616
|
t.target.tag,
|
|
1548
1617
|
t.target.semantics,
|
|
1549
1618
|
{ excludeClasses: !1 }
|
|
1550
1619
|
// Include classes for same-element case
|
|
1551
1620
|
);
|
|
1552
|
-
return e?.ensureUnique ? this.ensureUniqueSelector(
|
|
1621
|
+
return e?.ensureUnique ? this.ensureUniqueSelector(h, t, e) : h;
|
|
1553
1622
|
}
|
|
1554
1623
|
const n = [], a = e?.ensureUnique ? this.ensureUniqueAnchor(t, e.root) : this.buildNodeSelector(t.anchor.tag, t.anchor.semantics);
|
|
1555
1624
|
n.push(a);
|
|
1556
|
-
for (const
|
|
1557
|
-
let
|
|
1558
|
-
|
|
1625
|
+
for (const h of t.path) {
|
|
1626
|
+
let d = this.buildNodeSelector(h.tag, h.semantics);
|
|
1627
|
+
h.nthChild !== void 0 && _(h.tag, h.semantics) && (d += `:nth-child(${h.nthChild})`), n.push(d);
|
|
1559
1628
|
}
|
|
1560
1629
|
let i = this.buildNodeSelector(
|
|
1561
1630
|
t.target.tag,
|
|
@@ -1563,43 +1632,43 @@ class ot {
|
|
|
1563
1632
|
{ excludeClasses: e?.ensureUnique }
|
|
1564
1633
|
// Exclude classes initially if we need unique
|
|
1565
1634
|
);
|
|
1566
|
-
t.target.nthChild !== void 0 && (
|
|
1567
|
-
const o = this.isSvgChildElement(t.target.tag), c = t.path.some((
|
|
1568
|
-
let
|
|
1635
|
+
t.target.nthChild !== void 0 && _(t.target.tag, t.target.semantics) && (i += `:nth-child(${t.target.nthChild})`), n.push(i);
|
|
1636
|
+
const o = this.isSvgChildElement(t.target.tag), c = t.path.some((h) => h.tag === "svg");
|
|
1637
|
+
let l;
|
|
1569
1638
|
if (o && c) {
|
|
1570
|
-
const
|
|
1571
|
-
if (
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1639
|
+
const h = t.path.findIndex((d) => d.tag === "svg");
|
|
1640
|
+
if (h !== -1) {
|
|
1641
|
+
const d = h + 1, u = n.slice(0, d + 1), g = n.slice(d + 1, -1), m = n[n.length - 1];
|
|
1642
|
+
g.length > 0 ? l = u.join(" ") + " > " + g.join(" > ") + " > " + m : l = u.join(" ") + " > " + m;
|
|
1574
1643
|
} else
|
|
1575
|
-
|
|
1644
|
+
l = n.join(" ");
|
|
1576
1645
|
} else
|
|
1577
|
-
|
|
1646
|
+
l = n.join(" ");
|
|
1578
1647
|
if (!e?.ensureUnique)
|
|
1579
|
-
return
|
|
1580
|
-
const
|
|
1581
|
-
if (
|
|
1648
|
+
return l;
|
|
1649
|
+
const f = this.querySelectorSafe(l, e.root ?? document);
|
|
1650
|
+
if (f.length === 1)
|
|
1582
1651
|
return {
|
|
1583
|
-
selector:
|
|
1652
|
+
selector: l,
|
|
1584
1653
|
isUnique: !0,
|
|
1585
|
-
usedNthOfType:
|
|
1654
|
+
usedNthOfType: l.includes(":nth-"),
|
|
1586
1655
|
extraClassesAdded: 0
|
|
1587
1656
|
};
|
|
1588
|
-
if (
|
|
1589
|
-
const
|
|
1657
|
+
if (f.length === 0 || f.length > 1) {
|
|
1658
|
+
const h = this.buildFullDomPathSelector(
|
|
1590
1659
|
t,
|
|
1591
1660
|
t.target.semantics,
|
|
1592
1661
|
e.root ?? document
|
|
1593
1662
|
);
|
|
1594
|
-
if (
|
|
1663
|
+
if (h && this.isUnique(h, e.root ?? document))
|
|
1595
1664
|
return {
|
|
1596
|
-
selector:
|
|
1665
|
+
selector: h,
|
|
1597
1666
|
isUnique: !0,
|
|
1598
|
-
usedNthOfType:
|
|
1667
|
+
usedNthOfType: h.includes(":nth-"),
|
|
1599
1668
|
extraClassesAdded: 0
|
|
1600
1669
|
};
|
|
1601
1670
|
}
|
|
1602
|
-
return this.ensureUniqueSelector(
|
|
1671
|
+
return this.ensureUniqueSelector(l, t, e);
|
|
1603
1672
|
}
|
|
1604
1673
|
/**
|
|
1605
1674
|
* Builds selector for anchor only (used in fallback)
|
|
@@ -1614,10 +1683,10 @@ class ot {
|
|
|
1614
1683
|
*/
|
|
1615
1684
|
ensureUniqueSelector(t, e, s) {
|
|
1616
1685
|
const n = s.root ?? document, a = s.maxClasses ?? 4, i = e.target.tag, o = e.target.semantics;
|
|
1617
|
-
let c = t,
|
|
1686
|
+
let c = t, l = 0, f = !1;
|
|
1618
1687
|
if (this.querySelectorSafe(c, n).length === 0) {
|
|
1619
|
-
const
|
|
1620
|
-
if (
|
|
1688
|
+
const g = this.buildFullDomPathSelector(e, o, n);
|
|
1689
|
+
if (g && (c = g, this.isUnique(c, n)))
|
|
1621
1690
|
return {
|
|
1622
1691
|
selector: c,
|
|
1623
1692
|
isUnique: !0,
|
|
@@ -1632,33 +1701,33 @@ class ot {
|
|
|
1632
1701
|
usedNthOfType: !1,
|
|
1633
1702
|
extraClassesAdded: 0
|
|
1634
1703
|
};
|
|
1635
|
-
const
|
|
1636
|
-
for (let
|
|
1637
|
-
const m =
|
|
1638
|
-
if (c += `.${this.escapeCSS(m)}`,
|
|
1704
|
+
const d = M(o.classes ?? []);
|
|
1705
|
+
for (let g = 0; g < Math.min(d.length, a); g++) {
|
|
1706
|
+
const m = d[g];
|
|
1707
|
+
if (c += `.${this.escapeCSS(m)}`, l++, this.isUnique(c, n))
|
|
1639
1708
|
return {
|
|
1640
1709
|
selector: c,
|
|
1641
1710
|
isUnique: !0,
|
|
1642
1711
|
usedNthOfType: !1,
|
|
1643
|
-
extraClassesAdded:
|
|
1712
|
+
extraClassesAdded: l
|
|
1644
1713
|
};
|
|
1645
1714
|
}
|
|
1646
1715
|
if (!this.isUnique(c, n)) {
|
|
1647
|
-
const
|
|
1648
|
-
if (
|
|
1716
|
+
const g = this.buildFullDomPathSelector(e, o, n);
|
|
1717
|
+
if (g && this.isUnique(g, n))
|
|
1649
1718
|
return {
|
|
1650
|
-
selector:
|
|
1719
|
+
selector: g,
|
|
1651
1720
|
isUnique: !0,
|
|
1652
|
-
usedNthOfType:
|
|
1653
|
-
extraClassesAdded:
|
|
1721
|
+
usedNthOfType: g.includes(":nth-of-type("),
|
|
1722
|
+
extraClassesAdded: l
|
|
1654
1723
|
};
|
|
1655
1724
|
}
|
|
1656
|
-
const
|
|
1657
|
-
return
|
|
1725
|
+
const u = this.findNthElementByText(c, o, n);
|
|
1726
|
+
return u && (c += this.getNthSelector(u, i), f = !0), {
|
|
1658
1727
|
selector: c,
|
|
1659
1728
|
isUnique: this.isUnique(c, n),
|
|
1660
|
-
usedNthOfType:
|
|
1661
|
-
extraClassesAdded:
|
|
1729
|
+
usedNthOfType: f,
|
|
1730
|
+
extraClassesAdded: l
|
|
1662
1731
|
};
|
|
1663
1732
|
}
|
|
1664
1733
|
/**
|
|
@@ -1671,15 +1740,15 @@ class ot {
|
|
|
1671
1740
|
for (const i of a) {
|
|
1672
1741
|
const o = this.findTargetWithinAnchor(i, t.target.tag, e);
|
|
1673
1742
|
if (o.length === 0) continue;
|
|
1674
|
-
const c = o.map((
|
|
1675
|
-
const
|
|
1676
|
-
return { element:
|
|
1743
|
+
const c = o.map((l) => {
|
|
1744
|
+
const f = this.scorePathMatch(l, i, t.path);
|
|
1745
|
+
return { element: l, score: f };
|
|
1677
1746
|
});
|
|
1678
|
-
c.sort((
|
|
1679
|
-
for (const { element:
|
|
1680
|
-
const
|
|
1681
|
-
if (
|
|
1682
|
-
return
|
|
1747
|
+
c.sort((l, f) => f.score - l.score);
|
|
1748
|
+
for (const { element: l } of c) {
|
|
1749
|
+
const f = this.buildPathFromAnchorToTarget(i, l, t, s);
|
|
1750
|
+
if (f && this.isUnique(f, s))
|
|
1751
|
+
return f;
|
|
1683
1752
|
}
|
|
1684
1753
|
}
|
|
1685
1754
|
return null;
|
|
@@ -1699,26 +1768,26 @@ class ot {
|
|
|
1699
1768
|
n.unshift(a), a = a.parentElement;
|
|
1700
1769
|
let i = 0;
|
|
1701
1770
|
const o = Math.min(n.length, s.length);
|
|
1702
|
-
for (let
|
|
1703
|
-
const
|
|
1704
|
-
if (
|
|
1705
|
-
if (i += 10,
|
|
1706
|
-
const
|
|
1707
|
-
|
|
1771
|
+
for (let l = 0; l < o; l++) {
|
|
1772
|
+
const f = n[l], h = s[l];
|
|
1773
|
+
if (f.tagName.toLowerCase() === h.tag) {
|
|
1774
|
+
if (i += 10, h.nthChild !== void 0) {
|
|
1775
|
+
const d = f.parentElement;
|
|
1776
|
+
d && (Array.from(d.children).indexOf(f) + 1 === h.nthChild ? i += 20 : i -= 10);
|
|
1708
1777
|
}
|
|
1709
1778
|
} else
|
|
1710
1779
|
i -= 5;
|
|
1711
|
-
if (
|
|
1712
|
-
const
|
|
1713
|
-
(
|
|
1780
|
+
if (h.semantics.classes && h.semantics.classes.length > 0) {
|
|
1781
|
+
const d = h.semantics.classes.filter(
|
|
1782
|
+
(u) => f.classList.contains(u)
|
|
1714
1783
|
);
|
|
1715
|
-
i +=
|
|
1784
|
+
i += d.length * 2;
|
|
1716
1785
|
}
|
|
1717
|
-
if (
|
|
1718
|
-
const
|
|
1719
|
-
([
|
|
1786
|
+
if (h.semantics.attributes) {
|
|
1787
|
+
const d = Object.entries(h.semantics.attributes).filter(
|
|
1788
|
+
([u, g]) => f.getAttribute(u) === g
|
|
1720
1789
|
);
|
|
1721
|
-
i +=
|
|
1790
|
+
i += d.length * 3;
|
|
1722
1791
|
}
|
|
1723
1792
|
}
|
|
1724
1793
|
const c = Math.abs(n.length - s.length);
|
|
@@ -1735,8 +1804,8 @@ class ot {
|
|
|
1735
1804
|
return !1;
|
|
1736
1805
|
}
|
|
1737
1806
|
return !!(s.classes && s.classes.length > 0 && s.classes.every((o) => a.classList.contains(o)) || s.attributes && Object.entries(s.attributes).every(([o, c]) => {
|
|
1738
|
-
const
|
|
1739
|
-
return o === "href" || o === "src" ? D(o,
|
|
1807
|
+
const l = a.getAttribute(o);
|
|
1808
|
+
return o === "href" || o === "src" ? D(o, l || "") === D(o, c) : l === c;
|
|
1740
1809
|
}) || s.text);
|
|
1741
1810
|
});
|
|
1742
1811
|
}
|
|
@@ -1754,15 +1823,15 @@ class ot {
|
|
|
1754
1823
|
if (s?.semantics?.attributes) {
|
|
1755
1824
|
const o = this.buildNodeSelector(e, s.semantics, {
|
|
1756
1825
|
excludeClasses: !0
|
|
1757
|
-
}), c = [...n, e].join(" > "),
|
|
1758
|
-
if (
|
|
1826
|
+
}), c = [...n, e].join(" > "), l = this.querySelectorSafe(c, a), f = [...n, o].join(" > "), h = this.querySelectorSafe(f, a);
|
|
1827
|
+
if (h.length > 0 && h.length < l.length)
|
|
1759
1828
|
return o;
|
|
1760
1829
|
}
|
|
1761
1830
|
if (s?.semantics?.classes) {
|
|
1762
1831
|
const o = M(s.semantics.classes);
|
|
1763
1832
|
if (o.length > 0) {
|
|
1764
|
-
const c = `${e}.${this.escapeCSS(o[0])}`,
|
|
1765
|
-
if (
|
|
1833
|
+
const c = `${e}.${this.escapeCSS(o[0])}`, l = [...n, e].join(" > "), f = this.querySelectorSafe(l, a), h = [...n, c].join(" > "), d = this.querySelectorSafe(h, a);
|
|
1834
|
+
if (d.length > 0 && d.length < f.length)
|
|
1766
1835
|
return c;
|
|
1767
1836
|
}
|
|
1768
1837
|
}
|
|
@@ -1785,19 +1854,19 @@ class ot {
|
|
|
1785
1854
|
// Most flexible - no classes on target, only semantic attributes
|
|
1786
1855
|
// ============================================================
|
|
1787
1856
|
() => {
|
|
1788
|
-
const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics),
|
|
1857
|
+
const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), l = s.target.tag, f = s.target.semantics, h = [];
|
|
1789
1858
|
for (const p of s.path)
|
|
1790
|
-
|
|
1791
|
-
const
|
|
1792
|
-
if (this.isUnique(
|
|
1793
|
-
return
|
|
1794
|
-
const
|
|
1859
|
+
h.push(p.tag);
|
|
1860
|
+
const u = [c, ...h, l].filter(Boolean).join(" ");
|
|
1861
|
+
if (this.isUnique(u, n))
|
|
1862
|
+
return u;
|
|
1863
|
+
const g = this.buildNodeSelector(l, f, {
|
|
1795
1864
|
excludeClasses: !0
|
|
1796
1865
|
// KEY: no classes on target in Strategy 0
|
|
1797
1866
|
}), m = [
|
|
1798
1867
|
c,
|
|
1799
|
-
...
|
|
1800
|
-
|
|
1868
|
+
...h.slice(0, -1),
|
|
1869
|
+
g
|
|
1801
1870
|
].join(" ");
|
|
1802
1871
|
return this.isUnique(m, n) ? m : null;
|
|
1803
1872
|
},
|
|
@@ -1808,16 +1877,16 @@ class ot {
|
|
|
1808
1877
|
// Target: ONLY attributes, NO classes
|
|
1809
1878
|
// ============================================================
|
|
1810
1879
|
() => {
|
|
1811
|
-
const c = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)],
|
|
1812
|
-
let
|
|
1813
|
-
for (let
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1880
|
+
const c = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)], l = /* @__PURE__ */ new Map();
|
|
1881
|
+
let f = 0;
|
|
1882
|
+
for (let d = 0; d < a.length - 1; d++) {
|
|
1883
|
+
const u = a[d], g = u.tagName.toLowerCase();
|
|
1884
|
+
f < s.path.length && s.path[f].tag === g ? (l.set(u, s.path[f]), f++) : l.set(u, null);
|
|
1816
1885
|
}
|
|
1817
|
-
for (let
|
|
1818
|
-
const
|
|
1819
|
-
if (
|
|
1820
|
-
const b =
|
|
1886
|
+
for (let d = 0; d < a.length; d++) {
|
|
1887
|
+
const u = a[d], g = u.tagName.toLowerCase();
|
|
1888
|
+
if (d < a.length - 1) {
|
|
1889
|
+
const b = l.get(u) || null, S = this.disambiguateParent(u, g, b, c, n);
|
|
1821
1890
|
c.push(S);
|
|
1822
1891
|
continue;
|
|
1823
1892
|
}
|
|
@@ -1826,13 +1895,13 @@ class ot {
|
|
|
1826
1895
|
s.target.semantics,
|
|
1827
1896
|
{ excludeClasses: !0 }
|
|
1828
1897
|
// KEY: no classes on target
|
|
1829
|
-
), p =
|
|
1830
|
-
p && ["td", "th", "tr", "thead", "tbody", "tfoot"].includes(
|
|
1831
|
-
(S) => S.tagName.toLowerCase() ===
|
|
1832
|
-
).length > 1 ? c.push(`${m}${this.getNthSelector(
|
|
1898
|
+
), p = u.parentElement;
|
|
1899
|
+
p && ["td", "th", "tr", "thead", "tbody", "tfoot"].includes(g) && Array.from(p.children).filter(
|
|
1900
|
+
(S) => S.tagName.toLowerCase() === g
|
|
1901
|
+
).length > 1 ? c.push(`${m}${this.getNthSelector(u, g)}`) : c.push(m);
|
|
1833
1902
|
}
|
|
1834
|
-
const
|
|
1835
|
-
return this.isUnique(
|
|
1903
|
+
const h = c.join(" > ");
|
|
1904
|
+
return this.isUnique(h, n) ? h : null;
|
|
1836
1905
|
},
|
|
1837
1906
|
// ============================================================
|
|
1838
1907
|
// Strategy 2: anchor parent[attrs|class|nth] target[attrs_only]
|
|
@@ -1841,48 +1910,48 @@ class ot {
|
|
|
1841
1910
|
// Target: ONLY attributes, NO classes
|
|
1842
1911
|
// ============================================================
|
|
1843
1912
|
() => {
|
|
1844
|
-
const
|
|
1845
|
-
for (let
|
|
1846
|
-
const
|
|
1913
|
+
const l = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)];
|
|
1914
|
+
for (let d = 0; d < a.length - 1; d++) {
|
|
1915
|
+
const g = a[d].tagName.toLowerCase(), m = s.path[d] || null, p = l.join(" ") + " " + g;
|
|
1847
1916
|
if (this.querySelectorSafe(p, n).length > 1) {
|
|
1848
1917
|
if (m?.semantics?.attributes) {
|
|
1849
|
-
const C = this.buildNodeSelector(
|
|
1918
|
+
const C = this.buildNodeSelector(g, m.semantics, {
|
|
1850
1919
|
excludeClasses: !0
|
|
1851
|
-
}), A =
|
|
1920
|
+
}), A = l.join(" ") + " " + C;
|
|
1852
1921
|
if (this.querySelectorSafe(A, n).length === 1 || this.querySelectorSafe(A + " " + s.target.tag, n).length === 1) {
|
|
1853
|
-
|
|
1922
|
+
l.push(C);
|
|
1854
1923
|
continue;
|
|
1855
1924
|
}
|
|
1856
1925
|
}
|
|
1857
1926
|
if (m?.semantics?.classes) {
|
|
1858
1927
|
const C = M(m.semantics.classes);
|
|
1859
1928
|
if (C.length > 0) {
|
|
1860
|
-
const A = `${
|
|
1929
|
+
const A = `${g}.${this.escapeCSS(C[0])}`, v = l.join(" ") + " " + A;
|
|
1861
1930
|
if (this.querySelectorSafe(v, n).length === 1 || this.querySelectorSafe(v + " " + s.target.tag, n).length === 1) {
|
|
1862
|
-
|
|
1931
|
+
l.push(A);
|
|
1863
1932
|
continue;
|
|
1864
1933
|
}
|
|
1865
1934
|
}
|
|
1866
1935
|
}
|
|
1867
|
-
const S = a[
|
|
1868
|
-
if (
|
|
1869
|
-
(A) => A.tagName.toLowerCase() ===
|
|
1936
|
+
const S = a[d], T = S.parentElement;
|
|
1937
|
+
if (T && Array.from(T.children).filter(
|
|
1938
|
+
(A) => A.tagName.toLowerCase() === g
|
|
1870
1939
|
).length > 1) {
|
|
1871
|
-
|
|
1940
|
+
l.push(`${g}${this.getNthSelector(S, g)}`);
|
|
1872
1941
|
continue;
|
|
1873
1942
|
}
|
|
1874
1943
|
}
|
|
1875
|
-
|
|
1944
|
+
l.push(g);
|
|
1876
1945
|
}
|
|
1877
|
-
const
|
|
1946
|
+
const f = this.buildNodeSelector(
|
|
1878
1947
|
s.target.tag,
|
|
1879
1948
|
s.target.semantics,
|
|
1880
1949
|
{ excludeClasses: !0 }
|
|
1881
1950
|
// KEY: no classes on target
|
|
1882
1951
|
);
|
|
1883
|
-
|
|
1884
|
-
const
|
|
1885
|
-
return this.isUnique(
|
|
1952
|
+
l.push(f);
|
|
1953
|
+
const h = l.join(" ");
|
|
1954
|
+
return this.isUnique(h, n) ? h : null;
|
|
1886
1955
|
},
|
|
1887
1956
|
// ============================================================
|
|
1888
1957
|
// Strategy 3: anchor path target[attrs + 1_stable_class]
|
|
@@ -1890,18 +1959,18 @@ class ot {
|
|
|
1890
1959
|
// Only use this if attrs alone are not sufficient
|
|
1891
1960
|
// ============================================================
|
|
1892
1961
|
() => {
|
|
1893
|
-
const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics),
|
|
1894
|
-
for (const
|
|
1895
|
-
|
|
1962
|
+
const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), l = [];
|
|
1963
|
+
for (const u of s.path)
|
|
1964
|
+
l.push(u.tag);
|
|
1896
1965
|
if (M(s.target.semantics.classes ?? []).length === 0)
|
|
1897
1966
|
return null;
|
|
1898
|
-
const
|
|
1967
|
+
const h = this.buildNodeSelector(
|
|
1899
1968
|
s.target.tag,
|
|
1900
1969
|
s.target.semantics,
|
|
1901
1970
|
{ maxClasses: 1 }
|
|
1902
1971
|
// KEY: ONE stable class only
|
|
1903
|
-
),
|
|
1904
|
-
return this.isUnique(
|
|
1972
|
+
), d = [c, ...l.slice(0, -1), h].join(" ");
|
|
1973
|
+
return this.isUnique(d, n) ? d : null;
|
|
1905
1974
|
},
|
|
1906
1975
|
// ============================================================
|
|
1907
1976
|
// Strategy 4: anchor path target[attrs]:nth-of-type(N)
|
|
@@ -1909,25 +1978,25 @@ class ot {
|
|
|
1909
1978
|
// Only use when all other strategies fail
|
|
1910
1979
|
// ============================================================
|
|
1911
1980
|
() => {
|
|
1912
|
-
const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics),
|
|
1981
|
+
const c = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), l = [];
|
|
1913
1982
|
for (const m of s.path)
|
|
1914
|
-
|
|
1915
|
-
const
|
|
1916
|
-
if (!
|
|
1983
|
+
l.push(m.tag);
|
|
1984
|
+
const f = a[a.length - 1], h = f.parentElement;
|
|
1985
|
+
if (!h || Array.from(h.children).filter(
|
|
1917
1986
|
(m) => m.tagName.toLowerCase() === s.target.tag
|
|
1918
1987
|
).length <= 1) return null;
|
|
1919
|
-
const
|
|
1988
|
+
const u = this.buildNodeSelector(
|
|
1920
1989
|
s.target.tag,
|
|
1921
1990
|
s.target.semantics,
|
|
1922
1991
|
{ excludeClasses: !0 }
|
|
1923
1992
|
// No classes, just attrs + nth
|
|
1924
|
-
) + this.getNthSelector(
|
|
1925
|
-
return this.isUnique(
|
|
1993
|
+
) + this.getNthSelector(f, s.target.tag), g = [c, ...l.slice(0, -1), u].join(" ");
|
|
1994
|
+
return this.isUnique(g, n) ? g : null;
|
|
1926
1995
|
}
|
|
1927
1996
|
];
|
|
1928
1997
|
for (const c of o) {
|
|
1929
|
-
const
|
|
1930
|
-
if (
|
|
1998
|
+
const l = c();
|
|
1999
|
+
if (l) return l;
|
|
1931
2000
|
}
|
|
1932
2001
|
return null;
|
|
1933
2002
|
}
|
|
@@ -1939,7 +2008,7 @@ class ot {
|
|
|
1939
2008
|
buildElementSelector(t) {
|
|
1940
2009
|
const e = t.tagName.toLowerCase();
|
|
1941
2010
|
let s = e;
|
|
1942
|
-
if (t.id && !
|
|
2011
|
+
if (t.id && !L(t.id))
|
|
1943
2012
|
return `${e}#${this.escapeCSS(t.id)}`;
|
|
1944
2013
|
const n = Array.from(t.classList), a = M(n);
|
|
1945
2014
|
a.length > 0 && (s += a.slice(0, 2).map((o) => `.${this.escapeCSS(o)}`).join(""));
|
|
@@ -2014,11 +2083,11 @@ class ot {
|
|
|
2014
2083
|
if (n.attributes) {
|
|
2015
2084
|
const i = this.getSortedAttributes(n.attributes);
|
|
2016
2085
|
for (const { name: o, value: c } of i) {
|
|
2017
|
-
const
|
|
2018
|
-
if (
|
|
2019
|
-
const
|
|
2020
|
-
if (this.isUnique(
|
|
2021
|
-
return
|
|
2086
|
+
const l = o === "href" || o === "src" ? D(o, c) : c;
|
|
2087
|
+
if (l) {
|
|
2088
|
+
const f = `${s}[${o}="${this.escapeAttr(l)}"]`;
|
|
2089
|
+
if (this.isUnique(f, e))
|
|
2090
|
+
return f;
|
|
2022
2091
|
}
|
|
2023
2092
|
}
|
|
2024
2093
|
}
|
|
@@ -2086,7 +2155,7 @@ class ot {
|
|
|
2086
2155
|
* @returns True if should be ignored
|
|
2087
2156
|
*/
|
|
2088
2157
|
shouldIgnoreAttribute(t) {
|
|
2089
|
-
return !!(
|
|
2158
|
+
return !!(Y.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
|
|
2090
2159
|
}
|
|
2091
2160
|
/**
|
|
2092
2161
|
* Gets attributes sorted by priority
|
|
@@ -2095,7 +2164,7 @@ class ot {
|
|
|
2095
2164
|
*/
|
|
2096
2165
|
getSortedAttributes(t) {
|
|
2097
2166
|
return Object.entries(t).filter(([e]) => !this.shouldIgnoreAttribute(e)).filter(
|
|
2098
|
-
([e, s]) => !
|
|
2167
|
+
([e, s]) => !Z.has(e) || !K(s)
|
|
2099
2168
|
).map(([e, s]) => ({
|
|
2100
2169
|
name: e,
|
|
2101
2170
|
value: s,
|
|
@@ -2140,7 +2209,7 @@ class ot {
|
|
|
2140
2209
|
* @returns True if element is an SVG child
|
|
2141
2210
|
*/
|
|
2142
2211
|
isSvgChildElement(t) {
|
|
2143
|
-
return
|
|
2212
|
+
return yt.includes(t);
|
|
2144
2213
|
}
|
|
2145
2214
|
/**
|
|
2146
2215
|
* Builds CSS selector for elements inside <head>.
|
|
@@ -2175,11 +2244,11 @@ class ot {
|
|
|
2175
2244
|
};
|
|
2176
2245
|
}
|
|
2177
2246
|
}
|
|
2178
|
-
function
|
|
2247
|
+
function at(r, t) {
|
|
2179
2248
|
if (!r) return r;
|
|
2180
|
-
const e =
|
|
2249
|
+
const e = ie(t);
|
|
2181
2250
|
try {
|
|
2182
|
-
if (
|
|
2251
|
+
if (ne(r) || r.startsWith("//") || ae(r))
|
|
2183
2252
|
return r;
|
|
2184
2253
|
const s = new URL(r, e);
|
|
2185
2254
|
if (!e)
|
|
@@ -2194,19 +2263,19 @@ function rt(r, t) {
|
|
|
2194
2263
|
return r;
|
|
2195
2264
|
}
|
|
2196
2265
|
}
|
|
2197
|
-
function
|
|
2266
|
+
function ne(r) {
|
|
2198
2267
|
return !r.startsWith("http://") && !r.startsWith("https://") && !r.startsWith("//");
|
|
2199
2268
|
}
|
|
2200
|
-
function
|
|
2269
|
+
function ae(r) {
|
|
2201
2270
|
return ["javascript:", "mailto:", "tel:", "data:", "blob:", "file:"].some((e) => r.startsWith(e));
|
|
2202
2271
|
}
|
|
2203
|
-
function
|
|
2272
|
+
function ie(r) {
|
|
2204
2273
|
if (r)
|
|
2205
2274
|
return r;
|
|
2206
2275
|
if (typeof window < "u" && window.location && window.location.href)
|
|
2207
2276
|
return window.location.href;
|
|
2208
2277
|
}
|
|
2209
|
-
function
|
|
2278
|
+
function it(r) {
|
|
2210
2279
|
if (!r || typeof r != "string")
|
|
2211
2280
|
return "";
|
|
2212
2281
|
if (r.startsWith("javascript:") || r.startsWith("mailto:") || r.startsWith("tel:") || r.startsWith("data:") || r.startsWith("blob:") || r.startsWith("/") || r.startsWith("./") || r.startsWith("../"))
|
|
@@ -2218,7 +2287,7 @@ function nt(r) {
|
|
|
2218
2287
|
return r;
|
|
2219
2288
|
}
|
|
2220
2289
|
}
|
|
2221
|
-
class
|
|
2290
|
+
class oe {
|
|
2222
2291
|
/**
|
|
2223
2292
|
* Filters elements that match the semantics
|
|
2224
2293
|
* @param elements - Candidate elements
|
|
@@ -2249,7 +2318,7 @@ class te {
|
|
|
2249
2318
|
(o) => o.nodeType === Node.TEXT_NODE
|
|
2250
2319
|
).map((o) => o.textContent?.trim() ?? "").join(" ") || (t.textContent?.trim() ?? "");
|
|
2251
2320
|
if (!a) return !1;
|
|
2252
|
-
const i =
|
|
2321
|
+
const i = j(a);
|
|
2253
2322
|
return e.matchMode === "partial" ? i.includes(e.normalized) : i === e.normalized;
|
|
2254
2323
|
}
|
|
2255
2324
|
/**
|
|
@@ -2261,7 +2330,7 @@ class te {
|
|
|
2261
2330
|
(o) => o.nodeType === Node.TEXT_NODE
|
|
2262
2331
|
).map((o) => o.textContent?.trim() ?? "").join(" ") || (t.textContent?.trim() ?? "");
|
|
2263
2332
|
if (!a) return !1;
|
|
2264
|
-
const i =
|
|
2333
|
+
const i = j(a);
|
|
2265
2334
|
return i.includes(e.normalized) || e.normalized.includes(i);
|
|
2266
2335
|
}
|
|
2267
2336
|
/**
|
|
@@ -2294,20 +2363,20 @@ class te {
|
|
|
2294
2363
|
if (n) {
|
|
2295
2364
|
const c = D(a, i, {
|
|
2296
2365
|
preserveQueryForAbsolute: !1
|
|
2297
|
-
}),
|
|
2366
|
+
}), l = D(a, o || "", {
|
|
2298
2367
|
preserveQueryForAbsolute: !1
|
|
2299
|
-
}),
|
|
2300
|
-
if (
|
|
2368
|
+
}), f = it(c), h = it(l);
|
|
2369
|
+
if (f !== h)
|
|
2301
2370
|
return !1;
|
|
2302
2371
|
} else {
|
|
2303
|
-
const c =
|
|
2372
|
+
const c = at(
|
|
2304
2373
|
D(a, i, { preserveQueryForAbsolute: !1 }),
|
|
2305
2374
|
s
|
|
2306
|
-
),
|
|
2375
|
+
), l = at(
|
|
2307
2376
|
D(a, o || "", { preserveQueryForAbsolute: !1 }),
|
|
2308
2377
|
s
|
|
2309
2378
|
);
|
|
2310
|
-
if (c !==
|
|
2379
|
+
if (c !== l)
|
|
2311
2380
|
return !1;
|
|
2312
2381
|
}
|
|
2313
2382
|
else if (o !== i)
|
|
@@ -2374,7 +2443,7 @@ class te {
|
|
|
2374
2443
|
return Math.abs(e).toString(16).padStart(8, "0");
|
|
2375
2444
|
}
|
|
2376
2445
|
}
|
|
2377
|
-
class
|
|
2446
|
+
class ce {
|
|
2378
2447
|
/**
|
|
2379
2448
|
* Applies a single constraint to candidates
|
|
2380
2449
|
* @param candidates - Current candidate elements
|
|
@@ -2464,9 +2533,9 @@ class ee {
|
|
|
2464
2533
|
return s[e.length];
|
|
2465
2534
|
}
|
|
2466
2535
|
}
|
|
2467
|
-
class
|
|
2536
|
+
class le {
|
|
2468
2537
|
constructor() {
|
|
2469
|
-
this.cssGenerator = new
|
|
2538
|
+
this.cssGenerator = new lt();
|
|
2470
2539
|
}
|
|
2471
2540
|
/**
|
|
2472
2541
|
* Handles fallback when resolution fails
|
|
@@ -2603,14 +2672,14 @@ class se {
|
|
|
2603
2672
|
}
|
|
2604
2673
|
if (e.role && (n += 0.15, t.getAttribute("role") === e.role && (s += 0.15)), e.text) {
|
|
2605
2674
|
n += 0.1;
|
|
2606
|
-
const a =
|
|
2675
|
+
const a = j(t.textContent);
|
|
2607
2676
|
a === e.text.normalized ? s += 0.1 : a.includes(e.text.normalized) && (s += 0.05);
|
|
2608
2677
|
}
|
|
2609
2678
|
return n > 0 ? s / n : 0;
|
|
2610
2679
|
}
|
|
2611
2680
|
}
|
|
2612
|
-
function
|
|
2613
|
-
const s = { ...
|
|
2681
|
+
function he(r, t, e = {}) {
|
|
2682
|
+
const s = { ...xt, ...e };
|
|
2614
2683
|
let n;
|
|
2615
2684
|
try {
|
|
2616
2685
|
t instanceof Document ? n = t : n = k(t);
|
|
@@ -2630,34 +2699,34 @@ function re(r, t, e = {}) {
|
|
|
2630
2699
|
"options.root does not match dom parameter document. Using document from dom parameter. This may indicate a cross-document operation issue."
|
|
2631
2700
|
);
|
|
2632
2701
|
}
|
|
2633
|
-
const a = s.documentUrl ?? n.defaultView?.location?.href, i = s.matchUrlsByPathOnly ?? !0, o = new
|
|
2702
|
+
const a = s.documentUrl ?? n.defaultView?.location?.href, i = s.matchUrlsByPathOnly ?? !0, o = new lt(), c = new oe(), l = new ce(), f = new le(), h = o.buildSelector(r, {
|
|
2634
2703
|
ensureUnique: !1,
|
|
2635
2704
|
root: n
|
|
2636
2705
|
});
|
|
2637
|
-
let
|
|
2706
|
+
let d;
|
|
2638
2707
|
try {
|
|
2639
|
-
|
|
2708
|
+
d = Array.from(n.querySelectorAll(h));
|
|
2640
2709
|
} catch (p) {
|
|
2641
2710
|
const b = p instanceof Error ? p.message : "Unknown selector error";
|
|
2642
2711
|
return {
|
|
2643
2712
|
status: "error",
|
|
2644
2713
|
elements: [],
|
|
2645
|
-
warnings: [`Invalid CSS selector: ${
|
|
2714
|
+
warnings: [`Invalid CSS selector: ${h}`, `Error: ${b}`],
|
|
2646
2715
|
confidence: 0,
|
|
2647
2716
|
meta: { degraded: !0, degradationReason: "invalid-selector" }
|
|
2648
2717
|
};
|
|
2649
2718
|
}
|
|
2650
|
-
const
|
|
2651
|
-
|
|
2652
|
-
const
|
|
2653
|
-
|
|
2719
|
+
const u = d.length;
|
|
2720
|
+
d.length > s.maxCandidates && (d = d.slice(0, s.maxCandidates));
|
|
2721
|
+
const g = c.match(
|
|
2722
|
+
d,
|
|
2654
2723
|
r.target.semantics,
|
|
2655
2724
|
a,
|
|
2656
2725
|
i
|
|
2657
2726
|
);
|
|
2658
|
-
if (
|
|
2727
|
+
if (g.length === 0 && u > 0 && r.target.semantics.text !== void 0) {
|
|
2659
2728
|
const p = c.matchLenient(
|
|
2660
|
-
|
|
2729
|
+
d,
|
|
2661
2730
|
r.target.semantics,
|
|
2662
2731
|
a,
|
|
2663
2732
|
i
|
|
@@ -2672,11 +2741,11 @@ function re(r, t, e = {}) {
|
|
|
2672
2741
|
// Slight confidence penalty
|
|
2673
2742
|
meta: { degraded: !0, degradationReason: "relaxed-text-matching" }
|
|
2674
2743
|
};
|
|
2675
|
-
const b =
|
|
2744
|
+
const b = ot(
|
|
2676
2745
|
p,
|
|
2677
2746
|
r,
|
|
2678
|
-
|
|
2679
|
-
|
|
2747
|
+
l,
|
|
2748
|
+
f,
|
|
2680
2749
|
n,
|
|
2681
2750
|
s,
|
|
2682
2751
|
1
|
|
@@ -2691,18 +2760,18 @@ function re(r, t, e = {}) {
|
|
|
2691
2760
|
};
|
|
2692
2761
|
}
|
|
2693
2762
|
}
|
|
2694
|
-
if (
|
|
2763
|
+
if (g.length === 1)
|
|
2695
2764
|
return {
|
|
2696
2765
|
status: "success",
|
|
2697
|
-
elements:
|
|
2766
|
+
elements: g,
|
|
2698
2767
|
warnings: [],
|
|
2699
2768
|
confidence: r.meta.confidence,
|
|
2700
2769
|
meta: { degraded: !1 }
|
|
2701
2770
|
};
|
|
2702
|
-
if (
|
|
2703
|
-
const p =
|
|
2771
|
+
if (g.length === 0) {
|
|
2772
|
+
const p = u > 0 ? `CSS selector found ${u} candidates but semantic filtering rejected all. This may indicate text content mismatch.` : "CSS selector found no candidates";
|
|
2704
2773
|
if (s.enableFallback) {
|
|
2705
|
-
const b =
|
|
2774
|
+
const b = f.handleFallback(r, n);
|
|
2706
2775
|
return {
|
|
2707
2776
|
...b,
|
|
2708
2777
|
warnings: [...b.warnings, p]
|
|
@@ -2716,25 +2785,25 @@ function re(r, t, e = {}) {
|
|
|
2716
2785
|
meta: { degraded: !0, degradationReason: "not-found" }
|
|
2717
2786
|
};
|
|
2718
2787
|
}
|
|
2719
|
-
return
|
|
2720
|
-
|
|
2788
|
+
return ot(
|
|
2789
|
+
g,
|
|
2721
2790
|
r,
|
|
2722
|
-
|
|
2723
|
-
|
|
2791
|
+
l,
|
|
2792
|
+
f,
|
|
2724
2793
|
n,
|
|
2725
2794
|
s,
|
|
2726
2795
|
1
|
|
2727
2796
|
// no confidence penalty for exact match path
|
|
2728
2797
|
);
|
|
2729
2798
|
}
|
|
2730
|
-
function
|
|
2799
|
+
function ue(r) {
|
|
2731
2800
|
return [...r].sort((t, e) => e.priority - t.priority);
|
|
2732
2801
|
}
|
|
2733
|
-
function
|
|
2802
|
+
function ot(r, t, e, s, n, a, i) {
|
|
2734
2803
|
let o = r;
|
|
2735
|
-
const c =
|
|
2736
|
-
for (const
|
|
2737
|
-
if (o = e.applyConstraint(o,
|
|
2804
|
+
const c = ue(t.constraints);
|
|
2805
|
+
for (const f of c) {
|
|
2806
|
+
if (o = e.applyConstraint(o, f), o.length === 1)
|
|
2738
2807
|
return {
|
|
2739
2808
|
status: "success",
|
|
2740
2809
|
elements: o,
|
|
@@ -2759,13 +2828,13 @@ function at(r, t, e, s, n, a, i) {
|
|
|
2759
2828
|
confidence: t.meta.confidence * 0.7 * i,
|
|
2760
2829
|
meta: { degraded: !0, degradationReason: "ambiguous" }
|
|
2761
2830
|
};
|
|
2762
|
-
const
|
|
2831
|
+
const l = s.handleAmbiguous(o, t);
|
|
2763
2832
|
return {
|
|
2764
|
-
...
|
|
2765
|
-
confidence:
|
|
2833
|
+
...l,
|
|
2834
|
+
confidence: l.confidence * i
|
|
2766
2835
|
};
|
|
2767
2836
|
}
|
|
2768
|
-
function
|
|
2837
|
+
function ve(r) {
|
|
2769
2838
|
const t = [], e = [];
|
|
2770
2839
|
if (r.version ? r.version !== "1.0" && e.push(`Unknown version: ${r.version}`) : t.push("Missing version field"), r.anchor ? (r.anchor.tag || t.push("Anchor missing tag"), typeof r.anchor.score != "number" && t.push("Anchor missing score"), r.anchor.semantics || t.push("Anchor missing semantics")) : t.push("Missing anchor field"), r.target ? (r.target.tag || t.push("Target missing tag"), typeof r.target.score != "number" && t.push("Target missing score"), r.target.semantics || t.push("Target missing semantics")) : t.push("Missing target field"), !Array.isArray(r.path))
|
|
2771
2840
|
t.push("Path must be an array");
|
|
@@ -2780,33 +2849,55 @@ function Se(r) {
|
|
|
2780
2849
|
warnings: e
|
|
2781
2850
|
};
|
|
2782
2851
|
}
|
|
2783
|
-
function
|
|
2852
|
+
function $e(r) {
|
|
2784
2853
|
if (!r || typeof r != "object") return !1;
|
|
2785
2854
|
const t = r;
|
|
2786
2855
|
return typeof t.version == "string" && typeof t.anchor == "object" && Array.isArray(t.path) && typeof t.target == "object";
|
|
2787
2856
|
}
|
|
2788
|
-
const
|
|
2857
|
+
const ht = {
|
|
2858
|
+
id: "i",
|
|
2859
|
+
"data-testid": "tid",
|
|
2860
|
+
"data-qa": "qa",
|
|
2861
|
+
"data-cy": "cy",
|
|
2862
|
+
"data-test": "dt",
|
|
2863
|
+
"aria-label": "al",
|
|
2864
|
+
"aria-labelledby": "alb",
|
|
2865
|
+
"aria-describedby": "adb",
|
|
2866
|
+
name: "n",
|
|
2867
|
+
href: "h",
|
|
2868
|
+
src: "s",
|
|
2869
|
+
type: "t",
|
|
2870
|
+
role: "r",
|
|
2871
|
+
alt: "at",
|
|
2872
|
+
title: "tt",
|
|
2873
|
+
for: "f",
|
|
2874
|
+
placeholder: "ph",
|
|
2875
|
+
text: "x"
|
|
2876
|
+
}, G = Object.fromEntries(
|
|
2877
|
+
Object.entries(ht).map(([r, t]) => [t, r])
|
|
2878
|
+
), ut = {
|
|
2789
2879
|
maxClasses: 2,
|
|
2790
2880
|
maxAttributes: 5,
|
|
2791
2881
|
includeText: !0,
|
|
2792
2882
|
maxTextLength: 50,
|
|
2793
2883
|
simplifyTarget: !0,
|
|
2794
|
-
includeConstraints: !0
|
|
2884
|
+
includeConstraints: !0,
|
|
2885
|
+
format: "compact"
|
|
2795
2886
|
};
|
|
2796
|
-
function
|
|
2887
|
+
function ct(r) {
|
|
2797
2888
|
return r === "id" ? 101 : w[r] !== void 0 ? w[r] : r.startsWith("data-") ? w["data-*"] : r.startsWith("aria-") ? w["aria-*"] : 0;
|
|
2798
2889
|
}
|
|
2799
|
-
function
|
|
2890
|
+
function de(r) {
|
|
2800
2891
|
return ["id", "data-testid", "data-qa", "data-cy", "href", "text", "role"].includes(r);
|
|
2801
2892
|
}
|
|
2802
|
-
function
|
|
2893
|
+
function fe(r) {
|
|
2803
2894
|
return !!(/@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/.test(r) || /(\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/.test(r) || /\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}/.test(r));
|
|
2804
2895
|
}
|
|
2805
|
-
function
|
|
2806
|
-
const e = { ...
|
|
2807
|
-
return `${
|
|
2896
|
+
function ge(r, t) {
|
|
2897
|
+
const e = { ...ut, ...t }, s = e.format === "compact", n = s ? "v1" : `v${r.version}`, a = s ? ":" : ": ", i = s ? "::" : " :: ", o = s ? ">" : " > ", c = e.includeText && r.target.semantics.text ? r.target.semantics.text.normalized : void 0, l = W(r.anchor, !1, e), f = r.path.length > 0 ? r.path.map((u) => W(u, !1, e, c)).join(o) + o : "", h = W(r.target, !0, e), d = e.includeConstraints ? pe(r, e) : "";
|
|
2898
|
+
return `${n}${a}${l}${i}${f}${h}${d}`;
|
|
2808
2899
|
}
|
|
2809
|
-
function
|
|
2900
|
+
function me(r) {
|
|
2810
2901
|
r = r.trim();
|
|
2811
2902
|
const t = r.match(/^v(\d+(?:\.\d+)?)\s*:\s*/);
|
|
2812
2903
|
if (!t)
|
|
@@ -2826,13 +2917,13 @@ function ce(r) {
|
|
|
2826
2917
|
const c = s.split(/\s*>\s*/).map((p) => p.trim()).filter((p) => p);
|
|
2827
2918
|
if (c.length === 0)
|
|
2828
2919
|
throw new Error("Invalid SEQL Selector: missing target node");
|
|
2829
|
-
const
|
|
2920
|
+
const l = c[c.length - 1], f = c.slice(0, -1), h = B(a, !0), d = f.map((p) => B(p, !1)), u = B(l, !1), g = be(o);
|
|
2830
2921
|
return {
|
|
2831
2922
|
version: "1.0",
|
|
2832
|
-
anchor:
|
|
2833
|
-
path:
|
|
2834
|
-
target:
|
|
2835
|
-
constraints:
|
|
2923
|
+
anchor: h,
|
|
2924
|
+
path: d,
|
|
2925
|
+
target: u,
|
|
2926
|
+
constraints: g,
|
|
2836
2927
|
fallback: {
|
|
2837
2928
|
onMultiple: "best-score",
|
|
2838
2929
|
onMissing: "anchor-only",
|
|
@@ -2847,65 +2938,71 @@ function ce(r) {
|
|
|
2847
2938
|
}
|
|
2848
2939
|
};
|
|
2849
2940
|
}
|
|
2850
|
-
function
|
|
2851
|
-
const { tag:
|
|
2852
|
-
let
|
|
2853
|
-
const
|
|
2854
|
-
|
|
2855
|
-
const
|
|
2856
|
-
const
|
|
2857
|
-
return { name:
|
|
2858
|
-
}).filter((
|
|
2859
|
-
|
|
2860
|
-
const
|
|
2861
|
-
|
|
2862
|
-
for (const { name:
|
|
2863
|
-
i
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
}
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
);
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2941
|
+
function W(r, t = !1, e = ut, s) {
|
|
2942
|
+
const { tag: n, semantics: a } = r, i = e.format === "compact";
|
|
2943
|
+
let o = n;
|
|
2944
|
+
const c = [], l = { ...a.attributes };
|
|
2945
|
+
a.id && (l.id = a.id), a.role && !l.role && (l.role = a.role);
|
|
2946
|
+
const f = Object.entries(l).map(([u, g]) => {
|
|
2947
|
+
const m = ct(u), p = u === "href" || u === "src" ? D(u, g) : g;
|
|
2948
|
+
return { name: u, value: p, priority: m };
|
|
2949
|
+
}).filter((u) => u.name !== "id" && u.name !== "class" && Y.has(u.name) || Z.has(u.name) && K(u.value) ? !1 : u.priority > 0 || u.name === "role" || u.name === "id");
|
|
2950
|
+
f.sort((u, g) => g.priority - u.priority);
|
|
2951
|
+
const h = f.slice(0, e.maxAttributes);
|
|
2952
|
+
h.sort((u, g) => u.name.localeCompare(g.name));
|
|
2953
|
+
for (const { name: u, value: g } of h) {
|
|
2954
|
+
const m = i ? ht[u] ?? u : u;
|
|
2955
|
+
c.push(`${m}="${V(g)}"`);
|
|
2956
|
+
}
|
|
2957
|
+
if (e.includeText && a.text && !fe(a.text.normalized)) {
|
|
2958
|
+
const u = a.text.normalized;
|
|
2959
|
+
if (u.length > 0 && u.length <= e.maxTextLength && !(!t && s !== void 0 && u === s)) {
|
|
2960
|
+
const m = i ? "x" : "text";
|
|
2961
|
+
c.push(`${m}="${V(u)}"`);
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
let d = c;
|
|
2965
|
+
if (c.length > 0 && t && e.simplifyTarget && a.id && (d = c.filter((u) => {
|
|
2966
|
+
const g = u.split("=")[0], m = G[g] ?? g;
|
|
2967
|
+
return ct(m) >= 60 || m === "text" || m === "id" || m === "role";
|
|
2968
|
+
})), a.classes && a.classes.length > 0) {
|
|
2969
|
+
const u = M(a.classes), g = !!a.id || c.some((p) => {
|
|
2970
|
+
const b = p.split("=")[0], S = G[b] ?? b;
|
|
2971
|
+
return S === "href" || S === "data-testid" || S === "text" || S === "role";
|
|
2972
|
+
});
|
|
2973
|
+
if (!(t && e.simplifyTarget && g) && u.length > 0) {
|
|
2974
|
+
const p = u.sort().slice(0, e.maxClasses);
|
|
2975
|
+
o += p.map((b) => `.${b}`).join("");
|
|
2879
2976
|
}
|
|
2880
2977
|
}
|
|
2881
|
-
if (d.length > 0 && (
|
|
2882
|
-
const
|
|
2883
|
-
t && e.simplifyTarget &&
|
|
2978
|
+
if (d.length > 0 && (o += `[${d.join(",")}]`), "nthChild" in r && r.nthChild) {
|
|
2979
|
+
const u = !!a.id || a.attributes && Object.keys(a.attributes).some(de);
|
|
2980
|
+
t && e.simplifyTarget && u || (o += `#${r.nthChild}`);
|
|
2884
2981
|
}
|
|
2885
|
-
return
|
|
2982
|
+
return o;
|
|
2886
2983
|
}
|
|
2887
|
-
function
|
|
2984
|
+
function pe(r, t) {
|
|
2888
2985
|
if (!r.constraints || r.constraints.length === 0)
|
|
2889
2986
|
return "";
|
|
2890
|
-
const
|
|
2891
|
-
for (const
|
|
2892
|
-
switch (
|
|
2987
|
+
const e = [];
|
|
2988
|
+
for (const n of r.constraints)
|
|
2989
|
+
switch (n.type) {
|
|
2893
2990
|
case "uniqueness":
|
|
2894
|
-
|
|
2991
|
+
e.push("unique=true");
|
|
2895
2992
|
break;
|
|
2896
2993
|
case "position":
|
|
2897
|
-
|
|
2994
|
+
n.params && n.params.strategy && e.push(`pos=${n.params.strategy}`);
|
|
2898
2995
|
break;
|
|
2899
2996
|
case "text-proximity":
|
|
2900
|
-
if (
|
|
2901
|
-
const
|
|
2902
|
-
|
|
2997
|
+
if (n.params && n.params.reference) {
|
|
2998
|
+
const a = V(String(n.params.reference));
|
|
2999
|
+
e.push(`text="${a}"`);
|
|
2903
3000
|
}
|
|
2904
3001
|
break;
|
|
2905
3002
|
}
|
|
2906
|
-
return
|
|
3003
|
+
return e.length === 0 ? "" : `${t.format === "verbose" ? " " : ""}{${e.join(",")}}`;
|
|
2907
3004
|
}
|
|
2908
|
-
function
|
|
3005
|
+
function B(r, t) {
|
|
2909
3006
|
let e = r;
|
|
2910
3007
|
const s = {}, n = e.match(/^([a-z][a-z0-9-]*)/);
|
|
2911
3008
|
if (!n)
|
|
@@ -2919,22 +3016,22 @@ function W(r, t) {
|
|
|
2919
3016
|
i.length > 0 && (s.classes = i);
|
|
2920
3017
|
const c = e.match(/^\[([^\]]+)\]/);
|
|
2921
3018
|
if (c) {
|
|
2922
|
-
const
|
|
2923
|
-
for (const
|
|
2924
|
-
const m =
|
|
3019
|
+
const h = c[1], d = {}, u = Se(h);
|
|
3020
|
+
for (const g of u) {
|
|
3021
|
+
const m = g.match(/^([a-z][a-z0-9-]*)(?:=|~=)"((?:[^"\\]|\\.)*)"/);
|
|
2925
3022
|
if (m) {
|
|
2926
|
-
const [, p, b] = m;
|
|
2927
|
-
|
|
3023
|
+
const [, p, b] = m, S = G[p] ?? p;
|
|
3024
|
+
d[S] = dt(b);
|
|
2928
3025
|
}
|
|
2929
3026
|
}
|
|
2930
|
-
Object.keys(
|
|
2931
|
-
raw:
|
|
2932
|
-
normalized:
|
|
2933
|
-
}, delete
|
|
3027
|
+
Object.keys(d).length > 0 && (d.text && (s.text = {
|
|
3028
|
+
raw: d.text,
|
|
3029
|
+
normalized: d.text
|
|
3030
|
+
}, delete d.text), d.id && (s.id = d.id, delete d.id), d.role && (s.role = d.role, delete d.role), Object.keys(d).length > 0 && (s.attributes = d)), e = e.slice(c[0].length);
|
|
2934
3031
|
}
|
|
2935
|
-
let
|
|
2936
|
-
const
|
|
2937
|
-
if (
|
|
3032
|
+
let l;
|
|
3033
|
+
const f = e.match(/^#(\d+)/);
|
|
3034
|
+
if (f && (l = parseInt(f[1], 10), e = e.slice(f[0].length)), e.trim())
|
|
2938
3035
|
throw new Error(`Invalid node: unexpected content "${e}" in "${r}"`);
|
|
2939
3036
|
return t ? {
|
|
2940
3037
|
tag: a,
|
|
@@ -2945,10 +3042,10 @@ function W(r, t) {
|
|
|
2945
3042
|
tag: a,
|
|
2946
3043
|
semantics: s,
|
|
2947
3044
|
score: 0.7,
|
|
2948
|
-
nthChild:
|
|
3045
|
+
nthChild: l
|
|
2949
3046
|
};
|
|
2950
3047
|
}
|
|
2951
|
-
function
|
|
3048
|
+
function be(r) {
|
|
2952
3049
|
if (!r.trim())
|
|
2953
3050
|
return [];
|
|
2954
3051
|
const t = [], e = r.split(",").map((s) => s.trim());
|
|
@@ -2978,7 +3075,7 @@ function he(r) {
|
|
|
2978
3075
|
t.push({
|
|
2979
3076
|
type: "text-proximity",
|
|
2980
3077
|
params: {
|
|
2981
|
-
reference:
|
|
3078
|
+
reference: dt(i),
|
|
2982
3079
|
maxDistance: 5
|
|
2983
3080
|
},
|
|
2984
3081
|
priority: 60
|
|
@@ -2989,7 +3086,7 @@ function he(r) {
|
|
|
2989
3086
|
}
|
|
2990
3087
|
return t;
|
|
2991
3088
|
}
|
|
2992
|
-
function
|
|
3089
|
+
function Se(r) {
|
|
2993
3090
|
const t = [];
|
|
2994
3091
|
let e = "", s = !1;
|
|
2995
3092
|
for (let n = 0; n < r.length; n++) {
|
|
@@ -2998,34 +3095,34 @@ function ue(r) {
|
|
|
2998
3095
|
}
|
|
2999
3096
|
return e.trim() && t.push(e.trim()), t;
|
|
3000
3097
|
}
|
|
3001
|
-
function
|
|
3098
|
+
function V(r) {
|
|
3002
3099
|
return r.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/>/g, "\\>").replace(/:/g, "\\:");
|
|
3003
3100
|
}
|
|
3004
|
-
function
|
|
3101
|
+
function dt(r) {
|
|
3005
3102
|
return r.replace(/\\\\/g, "\0").replace(/\\"/g, '"').replace(/\\>/g, ">").replace(/\\:/g, ":").replace(/\x00/g, "\\");
|
|
3006
3103
|
}
|
|
3007
|
-
function
|
|
3008
|
-
const s =
|
|
3009
|
-
return s ?
|
|
3104
|
+
function Ne(r, t, e) {
|
|
3105
|
+
const s = J(r, t);
|
|
3106
|
+
return s ? ge(s, e) : null;
|
|
3010
3107
|
}
|
|
3011
|
-
function
|
|
3108
|
+
function Ie(r, t, e) {
|
|
3012
3109
|
try {
|
|
3013
|
-
const s =
|
|
3110
|
+
const s = me(r), n = {
|
|
3014
3111
|
...e,
|
|
3015
3112
|
root: e?.root || t
|
|
3016
3113
|
};
|
|
3017
|
-
return
|
|
3114
|
+
return he(s, t, n).elements || [];
|
|
3018
3115
|
} catch (s) {
|
|
3019
3116
|
return console.error("Failed to resolve SEQL Selector:", s), [];
|
|
3020
3117
|
}
|
|
3021
3118
|
}
|
|
3022
|
-
const
|
|
3023
|
-
function
|
|
3024
|
-
return r.id && !
|
|
3119
|
+
const ye = /* @__PURE__ */ new Set(["script", "style", "noscript", "meta", "link", "head", "title"]);
|
|
3120
|
+
function Q(r) {
|
|
3121
|
+
return r.id && !L(r.id) ? 3 : r.hasAttribute("role") || r.hasAttribute("aria-label") || r.hasAttribute("aria-labelledby") || r.hasAttribute("data-testid") || r.hasAttribute("data-qa") || r.hasAttribute("data-test") ? 2 : 1;
|
|
3025
3122
|
}
|
|
3026
|
-
function
|
|
3123
|
+
function ft(r, t) {
|
|
3027
3124
|
const e = r.tagName.toLowerCase();
|
|
3028
|
-
return !!(
|
|
3125
|
+
return !!(ye.has(e) || t && Q(r) === 1 && ![
|
|
3029
3126
|
"form",
|
|
3030
3127
|
"main",
|
|
3031
3128
|
"nav",
|
|
@@ -3041,13 +3138,13 @@ function ht(r, t) {
|
|
|
3041
3138
|
"textarea"
|
|
3042
3139
|
].includes(e));
|
|
3043
3140
|
}
|
|
3044
|
-
function
|
|
3141
|
+
function gt(r) {
|
|
3045
3142
|
return [...r].sort((t, e) => {
|
|
3046
|
-
const s =
|
|
3047
|
-
return
|
|
3143
|
+
const s = Q(t);
|
|
3144
|
+
return Q(e) - s;
|
|
3048
3145
|
});
|
|
3049
3146
|
}
|
|
3050
|
-
function
|
|
3147
|
+
function Re(r = {}) {
|
|
3051
3148
|
const t = performance.now();
|
|
3052
3149
|
let {
|
|
3053
3150
|
root: e,
|
|
@@ -3057,16 +3154,16 @@ function Te(r = {}) {
|
|
|
3057
3154
|
progressInterval: i = 100,
|
|
3058
3155
|
skipNonSemantic: o = !0,
|
|
3059
3156
|
generatorOptions: c = {},
|
|
3060
|
-
cache:
|
|
3061
|
-
signal:
|
|
3157
|
+
cache: l,
|
|
3158
|
+
signal: f
|
|
3062
3159
|
} = r;
|
|
3063
|
-
const
|
|
3064
|
-
let
|
|
3160
|
+
const h = l ?? X(), d = { ...c, cache: h };
|
|
3161
|
+
let u;
|
|
3065
3162
|
try {
|
|
3066
3163
|
if (e)
|
|
3067
|
-
e instanceof Document,
|
|
3164
|
+
e instanceof Document, u = Array.from(e.querySelectorAll(s));
|
|
3068
3165
|
else if (typeof document < "u")
|
|
3069
|
-
|
|
3166
|
+
u = Array.from(document.querySelectorAll(s));
|
|
3070
3167
|
else
|
|
3071
3168
|
throw new Error("Root element or document is required when document is not available");
|
|
3072
3169
|
} catch {
|
|
@@ -3085,66 +3182,66 @@ function Te(r = {}) {
|
|
|
3085
3182
|
};
|
|
3086
3183
|
}
|
|
3087
3184
|
if (!e) {
|
|
3088
|
-
if (
|
|
3185
|
+
if (u.length === 0)
|
|
3089
3186
|
throw new Error("Root element or document is required when no elements are found");
|
|
3090
|
-
const x = k(
|
|
3187
|
+
const x = k(u[0]);
|
|
3091
3188
|
e = x.body || x.documentElement;
|
|
3092
3189
|
}
|
|
3093
|
-
const
|
|
3094
|
-
|
|
3095
|
-
if (k(x) !==
|
|
3190
|
+
const g = e instanceof Document ? e : k(e);
|
|
3191
|
+
u.forEach((x, y) => {
|
|
3192
|
+
if (k(x) !== g)
|
|
3096
3193
|
throw new Error(
|
|
3097
3194
|
`Batch generation requires all elements from the same document. Element at index ${y} is from a different document. If working with iframes, ensure all elements are from the same iframe's contentDocument.`
|
|
3098
3195
|
);
|
|
3099
3196
|
});
|
|
3100
|
-
const m =
|
|
3197
|
+
const m = u.filter((x) => !ft(x, o)), b = gt(m).slice(0, n), S = [], T = [];
|
|
3101
3198
|
let C = 0;
|
|
3102
3199
|
const A = b.length;
|
|
3103
3200
|
let v = 0;
|
|
3104
|
-
for (let x = 0; x < b.length && !
|
|
3105
|
-
const y = b[x],
|
|
3106
|
-
if (
|
|
3201
|
+
for (let x = 0; x < b.length && !f?.aborted; x++) {
|
|
3202
|
+
const y = b[x], O = h.getEID(y);
|
|
3203
|
+
if (O)
|
|
3107
3204
|
S.push({
|
|
3108
3205
|
element: y,
|
|
3109
|
-
eid:
|
|
3206
|
+
eid: O,
|
|
3110
3207
|
generationTimeMs: 0
|
|
3111
3208
|
// Cached, no generation time
|
|
3112
3209
|
});
|
|
3113
3210
|
else {
|
|
3114
|
-
const
|
|
3211
|
+
const mt = performance.now();
|
|
3115
3212
|
try {
|
|
3116
|
-
const
|
|
3117
|
-
|
|
3213
|
+
const H = J(y, d), pt = performance.now() - mt;
|
|
3214
|
+
H ? S.push({
|
|
3118
3215
|
element: y,
|
|
3119
|
-
eid:
|
|
3120
|
-
generationTimeMs:
|
|
3216
|
+
eid: H,
|
|
3217
|
+
generationTimeMs: pt
|
|
3121
3218
|
}) : C++;
|
|
3122
|
-
} catch (
|
|
3123
|
-
|
|
3219
|
+
} catch (H) {
|
|
3220
|
+
T.push({
|
|
3124
3221
|
element: y,
|
|
3125
|
-
error:
|
|
3222
|
+
error: H instanceof Error ? H.message : String(H)
|
|
3126
3223
|
});
|
|
3127
3224
|
}
|
|
3128
3225
|
}
|
|
3129
3226
|
a && x - v >= i && (a(x + 1, A), v = x);
|
|
3130
3227
|
}
|
|
3131
3228
|
a && a(A, A);
|
|
3132
|
-
const
|
|
3229
|
+
const P = performance.now() - t, $ = h.getStats(), E = $.eidHits + $.eidMisses + $.selectorHits + $.selectorMisses, R = $.eidHits + $.selectorHits, N = E > 0 ? R / E : 0;
|
|
3133
3230
|
return {
|
|
3134
3231
|
results: S,
|
|
3135
|
-
failed:
|
|
3232
|
+
failed: T,
|
|
3136
3233
|
stats: {
|
|
3137
3234
|
totalElements: A,
|
|
3138
3235
|
successful: S.length,
|
|
3139
|
-
failed:
|
|
3236
|
+
failed: T.length,
|
|
3140
3237
|
skipped: C,
|
|
3141
|
-
totalTimeMs:
|
|
3142
|
-
avgTimePerElementMs: S.length > 0 ?
|
|
3238
|
+
totalTimeMs: P,
|
|
3239
|
+
avgTimePerElementMs: S.length > 0 ? P / S.length : 0,
|
|
3143
3240
|
cacheHitRate: N
|
|
3144
3241
|
}
|
|
3145
3242
|
};
|
|
3146
3243
|
}
|
|
3147
|
-
function
|
|
3244
|
+
function De(r, t = {}) {
|
|
3148
3245
|
const e = performance.now(), {
|
|
3149
3246
|
limit: s = 1 / 0,
|
|
3150
3247
|
onProgress: n,
|
|
@@ -3152,13 +3249,13 @@ function Ee(r, t = {}) {
|
|
|
3152
3249
|
skipNonSemantic: i = !0,
|
|
3153
3250
|
generatorOptions: o = {},
|
|
3154
3251
|
cache: c,
|
|
3155
|
-
signal:
|
|
3156
|
-
} = t,
|
|
3252
|
+
signal: l
|
|
3253
|
+
} = t, f = c ?? X(), h = { ...o, cache: f }, d = r.filter((E) => !ft(E, i)), g = gt(d).slice(0, s), m = [], p = [];
|
|
3157
3254
|
let b = 0;
|
|
3158
|
-
const S =
|
|
3159
|
-
let
|
|
3160
|
-
for (let
|
|
3161
|
-
const R =
|
|
3255
|
+
const S = g.length;
|
|
3256
|
+
let T = 0;
|
|
3257
|
+
for (let E = 0; E < g.length && !l?.aborted; E++) {
|
|
3258
|
+
const R = g[E], N = f.getEID(R);
|
|
3162
3259
|
if (N)
|
|
3163
3260
|
m.push({
|
|
3164
3261
|
element: R,
|
|
@@ -3168,11 +3265,11 @@ function Ee(r, t = {}) {
|
|
|
3168
3265
|
else {
|
|
3169
3266
|
const x = performance.now();
|
|
3170
3267
|
try {
|
|
3171
|
-
const y =
|
|
3268
|
+
const y = J(R, h), O = performance.now() - x;
|
|
3172
3269
|
y ? m.push({
|
|
3173
3270
|
element: R,
|
|
3174
3271
|
eid: y,
|
|
3175
|
-
generationTimeMs:
|
|
3272
|
+
generationTimeMs: O
|
|
3176
3273
|
}) : b++;
|
|
3177
3274
|
} catch (y) {
|
|
3178
3275
|
p.push({
|
|
@@ -3181,10 +3278,10 @@ function Ee(r, t = {}) {
|
|
|
3181
3278
|
});
|
|
3182
3279
|
}
|
|
3183
3280
|
}
|
|
3184
|
-
n &&
|
|
3281
|
+
n && E - T >= a && (n(E + 1, S), T = E);
|
|
3185
3282
|
}
|
|
3186
3283
|
n && n(S, S);
|
|
3187
|
-
const C = performance.now() - e, A =
|
|
3284
|
+
const C = performance.now() - e, A = f.getStats(), v = A.eidHits + A.eidMisses + A.selectorHits + A.selectorMisses, P = A.eidHits + A.selectorHits, $ = v > 0 ? P / v : 0;
|
|
3188
3285
|
return {
|
|
3189
3286
|
results: m,
|
|
3190
3287
|
failed: p,
|
|
@@ -3200,41 +3297,41 @@ function Ee(r, t = {}) {
|
|
|
3200
3297
|
};
|
|
3201
3298
|
}
|
|
3202
3299
|
export {
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3300
|
+
Ct as AnchorFinder,
|
|
3301
|
+
ce as ConstraintsEvaluator,
|
|
3302
|
+
lt as CssGenerator,
|
|
3303
|
+
At as DEFAULT_GENERATOR_OPTIONS,
|
|
3304
|
+
xt as DEFAULT_RESOLVER_OPTIONS,
|
|
3305
|
+
Xt as EIDCache,
|
|
3306
|
+
Ae as EID_VERSION,
|
|
3307
|
+
le as FallbackHandler,
|
|
3308
|
+
xe as MAX_PATH_DEPTH,
|
|
3309
|
+
Pt as PathBuilder,
|
|
3310
|
+
et as ROLE_ANCHOR_VALUES,
|
|
3311
|
+
tt as SEMANTIC_ANCHOR_TAGS,
|
|
3312
|
+
Ce as SEMANTIC_ATTRIBUTES,
|
|
3313
|
+
St as SEMANTIC_TAGS,
|
|
3314
|
+
nt as SemanticExtractor,
|
|
3315
|
+
oe as SemanticsMatcher,
|
|
3316
|
+
Yt as SvgFingerprinter,
|
|
3317
|
+
Zt as calculateConfidence,
|
|
3318
|
+
Ee as calculateElementScore,
|
|
3319
|
+
Jt as createEIDCache,
|
|
3320
|
+
It as filterClasses,
|
|
3321
|
+
J as generateEID,
|
|
3322
|
+
Re as generateEIDBatch,
|
|
3323
|
+
De as generateEIDForElements,
|
|
3324
|
+
Ne as generateSEQL,
|
|
3325
|
+
Te as getClassScore,
|
|
3326
|
+
X as getGlobalCache,
|
|
3327
|
+
$e as isEID,
|
|
3328
|
+
st as isUtilityClass,
|
|
3329
|
+
j as normalizeText,
|
|
3330
|
+
me as parseSEQL,
|
|
3331
|
+
we as resetGlobalCache,
|
|
3332
|
+
he as resolve,
|
|
3333
|
+
Ie as resolveSEQL,
|
|
3334
|
+
ge as stringifySEQL,
|
|
3335
|
+
ve as validateEID
|
|
3239
3336
|
};
|
|
3240
3337
|
//# sourceMappingURL=seql-js.js.map
|