@whenessel/seql-js 1.0.2 → 1.1.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.js CHANGED
@@ -1,9 +1,9 @@
1
- const Gt = "1.0", Vt = 10, L = {
1
+ const ee = "1.0", se = 10, L = {
2
2
  ANCHOR: 0.4,
3
3
  PATH: 0.3,
4
4
  TARGET: 0.2,
5
5
  UNIQUENESS: 0.1
6
- }, $ = {
6
+ }, I = {
7
7
  SEMANTIC_TAG: 0.5,
8
8
  ROLE: 0.3,
9
9
  ARIA_LABEL: 0.1,
@@ -22,7 +22,7 @@ const Gt = "1.0", Vt = 10, L = {
22
22
  "article",
23
23
  "footer",
24
24
  "header"
25
- ], K = [
25
+ ], X = [
26
26
  "form",
27
27
  "navigation",
28
28
  "main",
@@ -122,7 +122,7 @@ const Gt = "1.0", Vt = 10, L = {
122
122
  "defs",
123
123
  "clipPath",
124
124
  "mask"
125
- ], Qt = [
125
+ ], re = [
126
126
  "aria-label",
127
127
  "aria-labelledby",
128
128
  "aria-describedby",
@@ -135,7 +135,7 @@ const Gt = "1.0", Vt = 10, L = {
135
135
  "title",
136
136
  "placeholder",
137
137
  "alt"
138
- ], T = {
138
+ ], w = {
139
139
  // Test attributes (highest priority)
140
140
  "data-testid": 100,
141
141
  "data-qa": 99,
@@ -181,7 +181,7 @@ const Gt = "1.0", Vt = 10, L = {
181
181
  fallbackToBody: !0,
182
182
  includeUtilityClasses: !1,
183
183
  source: "dom-dsl"
184
- }, ft = {
184
+ }, dt = {
185
185
  strictMode: !1,
186
186
  enableFallback: !0,
187
187
  maxCandidates: 20
@@ -206,7 +206,7 @@ const B = /* @__PURE__ */ new Set([
206
206
  function G(n) {
207
207
  return n.trim().split(/\s+/).some((e) => D(e));
208
208
  }
209
- class dt {
209
+ class ft {
210
210
  constructor(t, e) {
211
211
  this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
212
212
  }
@@ -217,30 +217,30 @@ class dt {
217
217
  */
218
218
  findAnchor(t) {
219
219
  if (this.cache) {
220
- const a = this.cache.getAnchor(t);
221
- if (a !== void 0)
222
- return a;
220
+ const i = this.cache.getAnchor(t);
221
+ if (i !== void 0)
222
+ return i;
223
223
  }
224
224
  let e = t.parentElement, s = 0, r = null;
225
225
  for (; e && s < this.maxDepth; ) {
226
226
  if (e.tagName.toLowerCase() === "body")
227
227
  return r || {
228
228
  element: e,
229
- score: $.DEGRADED_SCORE,
229
+ score: I.DEGRADED_SCORE,
230
230
  tier: "C",
231
231
  depth: s
232
232
  };
233
- const a = this.scoreAnchor(e);
234
- if (a > 0) {
235
- const o = this.applyDepthPenalty(a, s), l = this.getTier(e), h = { element: e, score: o, tier: l, depth: s };
233
+ const i = this.scoreAnchor(e);
234
+ if (i > 0) {
235
+ const o = this.applyDepthPenalty(i, s), l = this.getTier(e), u = { element: e, score: o, tier: l, depth: s };
236
236
  if (l === "A")
237
- return h;
238
- (!r || o > r.score) && (r = h);
237
+ return u;
238
+ (!r || o > r.score) && (r = u);
239
239
  }
240
240
  e = e.parentElement, s++;
241
241
  }
242
- const i = r;
243
- return this.cache && this.cache.setAnchor(t, i), i;
242
+ const a = r;
243
+ return this.cache && this.cache.setAnchor(t, a), a;
244
244
  }
245
245
  /**
246
246
  * Scores an element as anchor candidate (without depth penalty)
@@ -250,20 +250,20 @@ class dt {
250
250
  scoreAnchor(t) {
251
251
  let e = 0;
252
252
  const s = t.tagName.toLowerCase();
253
- Y.includes(s) && (e += $.SEMANTIC_TAG);
253
+ Y.includes(s) && (e += I.SEMANTIC_TAG);
254
254
  const r = t.getAttribute("role");
255
- r && K.includes(r) && (e += $.ROLE), (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) && (e += $.ARIA_LABEL);
256
- const i = t.id;
257
- return i && !D(i) && (e += $.STABLE_ID), (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test")) && (e += $.TEST_MARKER), Math.min(e, 1);
255
+ r && X.includes(r) && (e += I.ROLE), (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) && (e += I.ARIA_LABEL);
256
+ const a = t.id;
257
+ return a && !D(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);
258
258
  }
259
259
  /**
260
260
  * Applies depth penalty to score
261
261
  * Following SPECIFICATION.md §7: depthPenalty = (depth - threshold) * factor
262
262
  */
263
263
  applyDepthPenalty(t, e) {
264
- if (e <= $.DEPTH_PENALTY_THRESHOLD)
264
+ if (e <= I.DEPTH_PENALTY_THRESHOLD)
265
265
  return t;
266
- const s = (e - $.DEPTH_PENALTY_THRESHOLD) * $.DEPTH_PENALTY_FACTOR;
266
+ const s = (e - I.DEPTH_PENALTY_THRESHOLD) * I.DEPTH_PENALTY_FACTOR;
267
267
  return Math.max(0, t - s);
268
268
  }
269
269
  /**
@@ -274,7 +274,7 @@ class dt {
274
274
  if (Y.includes(e))
275
275
  return "A";
276
276
  const s = t.getAttribute("role");
277
- return s && K.includes(s) ? "B" : "C";
277
+ return s && X.includes(s) ? "B" : "C";
278
278
  }
279
279
  }
280
280
  const gt = [
@@ -297,7 +297,7 @@ const gt = [
297
297
  /^_[a-z0-9]{5,}$/i,
298
298
  /\d{5,}/
299
299
  // 5+ digits in a row
300
- ], mt = [
300
+ ], pt = [
301
301
  // === FIX 4: Tailwind arbitrary values and variants (highest priority) ===
302
302
  /^\[/,
303
303
  // Any arbitrary value or variant starting with [ (e.g., [&_svg]:..., [mask-type:luminance])
@@ -331,6 +331,23 @@ const gt = [
331
331
  // === Spacing (Tailwind) ===
332
332
  /^(gap|space)-/,
333
333
  /^[mp][trblxy]?-(\d+|auto|px)$/,
334
+ // === Negative Tailwind utilities (margins, positioning, transforms) ===
335
+ /^-[mp][trblxy]?-\d+$/,
336
+ // -m-4, -mt-2, -mx-4, -px-4, -py-2
337
+ /^-(top|right|bottom|left|inset)-\d+$/,
338
+ // -top-4, -bottom-6, -left-6, -inset-0
339
+ /^-z-\d+$/,
340
+ // -z-10, -z-20
341
+ /^-space-[xy]-\d+$/,
342
+ // -space-x-2, -space-y-4
343
+ /^-translate-[xy]-\d+$/,
344
+ // -translate-x-4, -translate-y-2
345
+ /^-rotate-\d+$/,
346
+ // -rotate-45, -rotate-90
347
+ /^-scale-\d+$/,
348
+ // -scale-50, -scale-75
349
+ /^-skew-[xy]-\d+$/,
350
+ // -skew-x-12, -skew-y-6
334
351
  // === Sizing ===
335
352
  /^(w|h|min-w|min-h|max-w|max-h|size)-/,
336
353
  // === Colors & Styling ===
@@ -355,6 +372,7 @@ const gt = [
355
372
  // animations
356
373
  // === Overflow & Scrolling ===
357
374
  /^(overflow|overscroll|scroll)-/,
375
+ /^object-(contain|cover|fill|none|scale-down)$/,
358
376
  // === Interactivity ===
359
377
  /^(cursor|pointer-events|select|resize)-/,
360
378
  // === Visibility & Opacity ===
@@ -385,7 +403,7 @@ const gt = [
385
403
  /^clearfix$/,
386
404
  /^pull-(left|right)$/,
387
405
  /^float-(left|right|none)$/
388
- ], pt = [
406
+ ], mt = [
389
407
  // === Navigation ===
390
408
  /^(nav|menu|header|footer|sidebar|topbar|navbar|breadcrumb)/,
391
409
  /(navigation|dropdown|megamenu)$/,
@@ -412,23 +430,23 @@ const gt = [
412
430
  // === Status ===
413
431
  /^(loading|pending|complete|failed|draft|published)/
414
432
  ];
415
- function q(n) {
433
+ function k(n) {
416
434
  return gt.some((t) => t.test(n));
417
435
  }
418
- function O(n) {
419
- return n.length <= 2 || /^\d/.test(n) ? !0 : mt.some((t) => t.test(n));
436
+ function q(n) {
437
+ return n.length <= 2 || /^\d/.test(n) ? !0 : pt.some((t) => t.test(n));
420
438
  }
421
439
  function bt(n) {
422
- return q(n) || O(n) ? !1 : pt.some((t) => t.test(n));
440
+ return k(n) || q(n) ? !1 : mt.some((t) => t.test(n));
423
441
  }
424
442
  function St(n) {
425
- return !q(n) && !O(n);
443
+ return !k(n) && !q(n);
426
444
  }
427
- function I(n) {
445
+ function N(n) {
428
446
  return n.filter((t) => St(t));
429
447
  }
430
448
  function yt(n) {
431
- if (q(n) || O(n))
449
+ if (k(n) || q(n))
432
450
  return 0;
433
451
  let t = 0.5;
434
452
  return bt(n) && (t = 0.8), n.length < 3 ? t *= 0.3 : n.length < 5 && (t *= 0.6), /\d/.test(n) && (t *= 0.7), Math.min(t, 1);
@@ -436,13 +454,13 @@ function yt(n) {
436
454
  function At(n) {
437
455
  const t = [], e = [];
438
456
  for (const s of n)
439
- O(s) || q(s) ? e.push(s) : t.push(s);
457
+ q(s) || k(s) ? e.push(s) : t.push(s);
440
458
  return { semantic: t, utility: e };
441
459
  }
442
- function X(n) {
443
- return O(n) || q(n);
460
+ function K(n) {
461
+ return q(n) || k(n);
444
462
  }
445
- function Zt(n) {
463
+ function ne(n) {
446
464
  return yt(n);
447
465
  }
448
466
  const J = (n) => n.replace(/([#:.[\]@])/g, "\\$1");
@@ -459,10 +477,10 @@ class xt {
459
477
  */
460
478
  buildPath(t, e, s) {
461
479
  const r = [];
462
- let i = e.parentElement;
463
- for (; i && i !== t && r.length < this.maxDepth; )
464
- r.unshift(i), i = i.parentElement;
465
- const a = r.length >= this.maxDepth && i !== t;
480
+ let a = e.parentElement;
481
+ for (; a && a !== t && r.length < this.maxDepth; )
482
+ r.unshift(a), a = a.parentElement;
483
+ const i = r.length >= this.maxDepth && a !== t;
466
484
  let o = this.filterNoise(r);
467
485
  return o = this.ensureUniqueness(
468
486
  r,
@@ -471,22 +489,22 @@ class xt {
471
489
  e,
472
490
  s
473
491
  ), {
474
- path: o.map((h) => {
475
- const c = h.parentElement;
476
- let u;
477
- if (c) {
478
- const g = Array.from(c.children).indexOf(h);
479
- g !== -1 && (u = g + 1);
492
+ path: o.map((u) => {
493
+ const d = u.parentElement;
494
+ let c;
495
+ if (d) {
496
+ const g = Array.from(d.children).indexOf(u);
497
+ g !== -1 && (c = g + 1);
480
498
  }
481
499
  return {
482
- tag: h.tagName.toLowerCase(),
483
- semantics: s.extract(h),
484
- score: s.scoreElement(h),
485
- nthChild: u
500
+ tag: u.tagName.toLowerCase(),
501
+ semantics: s.extract(u),
502
+ score: s.scoreElement(u),
503
+ nthChild: c
486
504
  };
487
505
  }),
488
- degraded: a,
489
- degradationReason: a ? "path-depth-overflow" : void 0
506
+ degraded: i,
507
+ degradationReason: i ? "path-depth-overflow" : void 0
490
508
  };
491
509
  }
492
510
  /**
@@ -499,34 +517,34 @@ class xt {
499
517
  * Ensures path uniqueness by adding nodes if needed
500
518
  * Following SPECIFICATION.md §8 Disambiguation Algorithm
501
519
  */
502
- ensureUniqueness(t, e, s, r, i) {
503
- const a = this.buildTestSelector(s, e, r);
520
+ ensureUniqueness(t, e, s, r, a) {
521
+ const i = this.buildTestSelector(s, e, r);
504
522
  try {
505
523
  const o = r.ownerDocument;
506
524
  if (!o) return e;
507
525
  let l;
508
526
  if (this.cache) {
509
- const c = this.cache.getSelectorResults(a);
510
- c !== void 0 ? l = c : (l = Array.from(o.querySelectorAll(a)), this.cache.setSelectorResults(a, l));
527
+ const d = this.cache.getSelectorResults(i);
528
+ d !== void 0 ? l = d : (l = Array.from(o.querySelectorAll(i)), this.cache.setSelectorResults(i, l));
511
529
  } else
512
- l = o.querySelectorAll(a);
530
+ l = o.querySelectorAll(i);
513
531
  if (l.length <= 1)
514
532
  return e;
515
- const h = t.filter((c) => !e.includes(c));
516
- for (const c of h) {
517
- if (i.scoreElement(c) < ct.MIN_CONFIDENCE_FOR_SKIP)
533
+ const u = t.filter((d) => !e.includes(d));
534
+ for (const d of u) {
535
+ if (a.scoreElement(d) < ct.MIN_CONFIDENCE_FOR_SKIP)
518
536
  continue;
519
- const f = this.insertNodeInOrder(e, c, t), g = this.buildTestSelector(s, f, r);
537
+ const h = this.insertNodeInOrder(e, d, t), g = this.buildTestSelector(s, h, r);
520
538
  try {
521
- let d;
539
+ let f;
522
540
  if (this.cache) {
523
- const m = this.cache.getSelectorResults(g);
524
- m !== void 0 ? d = m : (d = Array.from(o.querySelectorAll(g)), this.cache.setSelectorResults(g, d));
541
+ const p = this.cache.getSelectorResults(g);
542
+ p !== void 0 ? f = p : (f = Array.from(o.querySelectorAll(g)), this.cache.setSelectorResults(g, f));
525
543
  } else
526
- d = o.querySelectorAll(g);
527
- if (d.length === 1)
528
- return f;
529
- d.length < l.length && (e = f);
544
+ f = o.querySelectorAll(g);
545
+ if (f.length === 1)
546
+ return h;
547
+ f.length < l.length && (e = h);
530
548
  } catch {
531
549
  }
532
550
  }
@@ -539,11 +557,11 @@ class xt {
539
557
  * Inserts node into path maintaining original order
540
558
  */
541
559
  insertNodeInOrder(t, e, s) {
542
- const r = s.indexOf(e), i = [...t];
543
- let a = 0;
544
- for (let o = 0; o < i.length && !(s.indexOf(i[o]) > r); o++)
545
- a = o + 1;
546
- return i.splice(a, 0, e), i;
560
+ const r = s.indexOf(e), a = [...t];
561
+ let i = 0;
562
+ for (let o = 0; o < a.length && !(s.indexOf(a[o]) > r); o++)
563
+ i = o + 1;
564
+ return a.splice(i, 0, e), a;
547
565
  }
548
566
  /**
549
567
  * Builds a test CSS selector from path
@@ -551,8 +569,8 @@ class xt {
551
569
  buildTestSelector(t, e, s) {
552
570
  const r = [];
553
571
  r.push(this.elementToSelector(t));
554
- for (const i of e)
555
- r.push(this.elementToSelector(i));
572
+ for (const a of e)
573
+ r.push(this.elementToSelector(a));
556
574
  return r.push(this.elementToSelector(s)), r.join(" ");
557
575
  }
558
576
  /**
@@ -562,7 +580,7 @@ class xt {
562
580
  let e = t.tagName.toLowerCase();
563
581
  t.id && !D(t.id) && (e += `#${J(t.id)}`);
564
582
  for (const s of Array.from(t.classList))
565
- X(s) || (e += `.${J(s)}`);
583
+ K(s) || (e += `.${J(s)}`);
566
584
  return e;
567
585
  }
568
586
  /**
@@ -587,7 +605,7 @@ class xt {
587
605
  if (s.name.startsWith("aria-")) return !0;
588
606
  if (t.classList.length > 0) {
589
607
  for (const s of Array.from(t.classList))
590
- if (!X(s)) return !0;
608
+ if (!K(s)) return !0;
591
609
  }
592
610
  if (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test"))
593
611
  return !0;
@@ -602,7 +620,7 @@ const Ct = {
602
620
  preserveQueryForAbsolute: !0,
603
621
  removeDynamicHashes: !0
604
622
  };
605
- function Et(n) {
623
+ function Tt(n) {
606
624
  return n ? [
607
625
  /\d{5,}/,
608
626
  // 5+ digits
@@ -616,20 +634,110 @@ function Et(n) {
616
634
  // UUID-like
617
635
  ].some((e) => e.test(n)) : !1;
618
636
  }
619
- function Tt(n, t) {
637
+ function Et(n, t) {
620
638
  if (!n) return n;
621
639
  const e = n.startsWith("http://") || n.startsWith("https://");
622
640
  let [s, r] = n.split("#");
623
- const [i, a] = s.split("?");
624
- let o = i;
625
- return e && t.preserveQueryForAbsolute && a && (o += `?${a}`), r && (t.removeDynamicHashes && Et(r) || (o += `#${r}`)), o;
641
+ const [a, i] = s.split("?");
642
+ let o = a;
643
+ return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), r && (t.removeDynamicHashes && Tt(r) || (o += `#${r}`)), o;
626
644
  }
627
- function P(n, t, e = {}) {
645
+ function _(n, t, e = {}) {
628
646
  if (!t) return t;
629
647
  const s = { ...Ct, ...e };
630
- return n === "href" || n === "src" ? Tt(t, s) : t;
648
+ return n === "href" || n === "src" ? Et(t, s) : t;
649
+ }
650
+ const wt = [
651
+ "role",
652
+ "aria-label",
653
+ "aria-labelledby",
654
+ "aria-describedby",
655
+ "aria-controls",
656
+ "aria-owns",
657
+ "aria-level",
658
+ "aria-posinset",
659
+ "aria-setsize",
660
+ "aria-haspopup"
661
+ ], vt = [
662
+ "aria-selected",
663
+ "aria-checked",
664
+ "aria-pressed",
665
+ "aria-expanded",
666
+ "aria-hidden",
667
+ "aria-disabled",
668
+ "aria-current",
669
+ "aria-busy",
670
+ "aria-invalid",
671
+ "aria-grabbed",
672
+ "aria-live",
673
+ "aria-atomic"
674
+ ], $t = [
675
+ "data-state",
676
+ "data-active",
677
+ "data-inactive",
678
+ "data-selected",
679
+ "data-open",
680
+ "data-closed",
681
+ "data-visible",
682
+ "data-hidden",
683
+ "data-disabled",
684
+ "data-enabled",
685
+ "data-loading",
686
+ "data-error",
687
+ "data-success",
688
+ "data-highlighted",
689
+ "data-focused",
690
+ "data-hover",
691
+ "data-orientation",
692
+ "data-theme"
693
+ ], Mt = [
694
+ "data-radix-",
695
+ "data-headlessui-",
696
+ "data-reach-",
697
+ "data-mui-",
698
+ "data-chakra-",
699
+ "data-mantine-",
700
+ "data-tw-"
701
+ ], It = [
702
+ "data-testid",
703
+ "data-test-id",
704
+ "data-test",
705
+ "data-cy",
706
+ "data-qa",
707
+ "data-automation-id",
708
+ "data-id",
709
+ "data-component",
710
+ "data-entity-id",
711
+ "data-product-id",
712
+ "data-user-id"
713
+ ], Rt = [
714
+ "id",
715
+ "name",
716
+ "type",
717
+ "placeholder",
718
+ "title",
719
+ "for",
720
+ "alt",
721
+ "href"
722
+ ], Nt = [
723
+ "disabled",
724
+ "checked",
725
+ "selected",
726
+ "hidden",
727
+ "readonly",
728
+ "required",
729
+ "value"
730
+ ], Dt = [
731
+ /^radix-/,
732
+ /^headlessui-/,
733
+ /^mui-/,
734
+ /:\w+:/
735
+ // matches :ru:, :r1:, etc.
736
+ ];
737
+ function Ht(n, t) {
738
+ return wt.includes(n) ? !0 : vt.includes(n) || $t.includes(n) || Mt.some((e) => n.startsWith(e)) ? !1 : It.includes(n) || n.startsWith("data-") && n.endsWith("-id") ? !0 : n === "id" ? !Dt.some((e) => e.test(t)) : Rt.includes(n) ? !0 : Nt.includes(n) ? !1 : !!n.startsWith("data-");
631
739
  }
632
- class wt {
740
+ class Pt {
633
741
  constructor(t, e) {
634
742
  this.includeUtilityClasses = t.includeUtilityClasses ?? !1, this.cache = e;
635
743
  }
@@ -640,26 +748,26 @@ class wt {
640
748
  */
641
749
  extract(t) {
642
750
  if (this.cache) {
643
- const a = this.cache.getSemantics(t);
644
- if (a !== void 0)
645
- return a;
751
+ const i = this.cache.getSemantics(t);
752
+ if (i !== void 0)
753
+ return i;
646
754
  }
647
755
  const e = {}, s = t.id;
648
756
  if (s && !D(s) && (e.id = s), t.classList.length > 0) {
649
- const a = Array.from(t.classList);
757
+ const i = Array.from(t.classList);
650
758
  if (this.includeUtilityClasses)
651
- e.classes = a;
759
+ e.classes = i;
652
760
  else {
653
- const { semantic: o } = At(a);
761
+ const { semantic: o } = At(i);
654
762
  o.length > 0 && (e.classes = o);
655
763
  }
656
764
  }
657
765
  const r = this.extractAttributes(t);
658
766
  Object.keys(r).length > 0 && (e.attributes = r);
659
- const i = t.getAttribute("role");
660
- if (i && (e.role = i), this.shouldExtractText(t)) {
661
- const a = this.extractText(t);
662
- a && (e.text = a);
767
+ const a = t.getAttribute("role");
768
+ if (a && (e.role = a), this.shouldExtractText(t)) {
769
+ const i = this.extractText(t);
770
+ i && (e.text = i);
663
771
  }
664
772
  return this.cache && this.cache.setSemantics(t, e), e;
665
773
  }
@@ -687,7 +795,7 @@ class wt {
687
795
  * @returns Priority number (higher = more priority)
688
796
  */
689
797
  getAttributePriority(t) {
690
- return T[t] !== void 0 ? T[t] : t.startsWith("data-") ? T["data-*"] : t.startsWith("aria-") ? T["aria-*"] : 0;
798
+ return w[t] !== void 0 ? w[t] : t.startsWith("data-") ? w["data-*"] : t.startsWith("aria-") ? w["aria-*"] : 0;
691
799
  }
692
800
  /**
693
801
  * Checks if attribute value is dynamic (should be ignored)
@@ -714,9 +822,9 @@ class wt {
714
822
  const e = {};
715
823
  for (const s of Array.from(t.attributes)) {
716
824
  const r = s.name;
717
- if (this.shouldIgnoreAttribute(r) || B.has(r) && G(s.value) || this.getAttributePriority(r) === 0) continue;
718
- const a = r === "href" || r === "src" ? P(r, s.value) : s.value;
719
- !a || a.trim() === "" || this.isDynamicValue(a) || (e[r] = a);
825
+ if (this.shouldIgnoreAttribute(r) || !Ht(r, s.value) || B.has(r) && G(s.value) || this.getAttributePriority(r) === 0) continue;
826
+ const i = r === "href" || r === "src" ? _(r, s.value) : s.value;
827
+ !i || i.trim() === "" || this.isDynamicValue(i) || (e[r] = i);
720
828
  }
721
829
  return e;
722
830
  }
@@ -728,10 +836,10 @@ class wt {
728
836
  if (!e) return null;
729
837
  const s = V(e);
730
838
  if (!s) return null;
731
- const r = 100, i = e.length > r ? e.slice(0, r) + "..." : e, a = s.length > r ? s.slice(0, r) + "..." : s;
839
+ const r = 100, a = e.length > r ? e.slice(0, r) + "..." : e, i = s.length > r ? s.slice(0, r) + "..." : s;
732
840
  return {
733
- raw: i,
734
- normalized: a
841
+ raw: a,
842
+ normalized: i
735
843
  };
736
844
  }
737
845
  /**
@@ -774,7 +882,7 @@ class wt {
774
882
  ].includes(e);
775
883
  }
776
884
  }
777
- class vt {
885
+ class _t {
778
886
  /**
779
887
  * Generates fingerprint for SVG element
780
888
  * @param element - SVG element to fingerprint
@@ -789,10 +897,10 @@ class vt {
789
897
  const o = t.getAttribute("d");
790
898
  o && (r.dHash = this.computePathHash(o));
791
899
  } else ["circle", "rect", "ellipse", "line"].includes(s) && (r.geomHash = this.computeGeomHash(t, s));
792
- const i = t.getAttribute("role");
793
- i && (r.role = i);
794
- const a = t.querySelector("title");
795
- return a?.textContent && (r.titleText = a.textContent.trim()), r;
900
+ const a = t.getAttribute("role");
901
+ a && (r.role = a);
902
+ const i = t.querySelector("title");
903
+ return i?.textContent && (r.titleText = i.textContent.trim()), r;
796
904
  }
797
905
  /**
798
906
  * Computes hash from path data (first N commands)
@@ -825,7 +933,7 @@ class vt {
825
933
  * Normalizes path data for consistent hashing
826
934
  */
827
935
  normalizePathData(t) {
828
- return (t.match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/gi) ?? []).slice(0, 5).map((r) => r.trim().replace(/(-?\d+\.?\d*)/g, (i) => parseFloat(i).toFixed(1))).join(" ");
936
+ return (t.match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/gi) ?? []).slice(0, 5).map((r) => r.trim().replace(/(-?\d+\.?\d*)/g, (a) => parseFloat(a).toFixed(1))).join(" ");
829
937
  }
830
938
  /**
831
939
  * Computes geometry hash for non-path shapes
@@ -838,19 +946,19 @@ class vt {
838
946
  break;
839
947
  case "rect":
840
948
  {
841
- const r = parseFloat(t.getAttribute("width") ?? "0"), i = parseFloat(t.getAttribute("height") ?? "0");
842
- r > 0 && i > 0 && s.push(`ratio=${(r / i).toFixed(2)}`);
949
+ const r = parseFloat(t.getAttribute("width") ?? "0"), a = parseFloat(t.getAttribute("height") ?? "0");
950
+ r > 0 && a > 0 && s.push(`ratio=${(r / a).toFixed(2)}`);
843
951
  }
844
952
  break;
845
953
  case "ellipse":
846
954
  {
847
- const r = parseFloat(t.getAttribute("rx") ?? "0"), i = parseFloat(t.getAttribute("ry") ?? "0");
848
- r > 0 && i > 0 && s.push(`ratio=${(r / i).toFixed(2)}`);
955
+ const r = parseFloat(t.getAttribute("rx") ?? "0"), a = parseFloat(t.getAttribute("ry") ?? "0");
956
+ r > 0 && a > 0 && s.push(`ratio=${(r / a).toFixed(2)}`);
849
957
  }
850
958
  break;
851
959
  case "line":
852
960
  {
853
- const r = parseFloat(t.getAttribute("x1") ?? "0"), i = parseFloat(t.getAttribute("y1") ?? "0"), a = parseFloat(t.getAttribute("x2") ?? "0"), o = parseFloat(t.getAttribute("y2") ?? "0"), l = Math.atan2(o - i, a - r);
961
+ const r = parseFloat(t.getAttribute("x1") ?? "0"), a = parseFloat(t.getAttribute("y1") ?? "0"), i = parseFloat(t.getAttribute("x2") ?? "0"), o = parseFloat(t.getAttribute("y2") ?? "0"), l = Math.atan2(o - a, i - r);
854
962
  s.push(`angle=${l.toFixed(2)}`);
855
963
  }
856
964
  break;
@@ -885,15 +993,15 @@ class vt {
885
993
  return Math.abs(e).toString(16).padStart(8, "0");
886
994
  }
887
995
  }
888
- function $t(n, t = 0) {
889
- const e = n.anchor.score, s = n.path.length > 0 ? n.path.reduce((o, l) => o + l.score, 0) / n.path.length : 0.5, r = n.target.score, i = e * L.ANCHOR + s * L.PATH + r * L.TARGET + t * L.UNIQUENESS, a = n.anchor.degraded ? 0.2 : 0;
890
- return Math.max(0, Math.min(1, i - a));
996
+ function kt(n, t = 0) {
997
+ const e = n.anchor.score, s = n.path.length > 0 ? n.path.reduce((o, l) => o + l.score, 0) / n.path.length : 0.5, r = n.target.score, a = e * L.ANCHOR + s * L.PATH + r * L.TARGET + t * L.UNIQUENESS, i = n.anchor.degraded ? 0.2 : 0;
998
+ return Math.max(0, Math.min(1, a - i));
891
999
  }
892
- function Yt(n, t, e) {
1000
+ function ae(n, t, e) {
893
1001
  let s = 0.5;
894
1002
  return t && (s += 0.2), e && (s += 0.15), s += Math.min(n * 0.05, 0.15), Math.min(s, 1);
895
1003
  }
896
- class Mt {
1004
+ class qt {
897
1005
  constructor(t) {
898
1006
  this.cache = /* @__PURE__ */ new Map(), this.maxSize = t;
899
1007
  }
@@ -924,9 +1032,9 @@ class Mt {
924
1032
  return this.cache.size;
925
1033
  }
926
1034
  }
927
- class It {
1035
+ class Lt {
928
1036
  constructor(t = {}) {
929
- this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new Mt(
1037
+ this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new qt(
930
1038
  t.maxSelectorCacheSize ?? 1e3
931
1039
  ), this.anchorCache = /* @__PURE__ */ new WeakMap(), this.semanticsCache = /* @__PURE__ */ new WeakMap(), this.stats = {
932
1040
  eidHits: 0,
@@ -1075,15 +1183,15 @@ class It {
1075
1183
  return s > 0 ? t / s : 0;
1076
1184
  }
1077
1185
  }
1078
- function Nt(n) {
1079
- return new It(n);
1186
+ function Ot(n) {
1187
+ return new Lt(n);
1080
1188
  }
1081
- let _ = null;
1189
+ let O = null;
1082
1190
  function Q() {
1083
- return _ || (_ = Nt()), _;
1191
+ return O || (O = Ot()), O;
1084
1192
  }
1085
- function Kt() {
1086
- _ = null;
1193
+ function ie() {
1194
+ O = null;
1087
1195
  }
1088
1196
  function Z(n, t = {}) {
1089
1197
  if (!n || !n.ownerDocument || !n.isConnected)
@@ -1091,60 +1199,67 @@ function Z(n, t = {}) {
1091
1199
  const e = { ...ut, ...t }, s = e.cache ?? Q(), r = s.getEID(n);
1092
1200
  if (r !== void 0)
1093
1201
  return r;
1094
- const i = new dt(e, s), a = new xt(e, s), o = new wt(e, s), l = new vt(), h = i.findAnchor(n);
1095
- if (!h && !e.fallbackToBody)
1202
+ const a = new ft(e, s), i = new xt(e, s), o = new Pt(e, s), l = new _t(), u = a.findAnchor(n);
1203
+ if (!u && !e.fallbackToBody)
1096
1204
  return null;
1097
- const c = h?.element ?? n.ownerDocument?.body ?? null;
1098
- if (!c) return null;
1099
- const u = !h || h.tier === "C", f = o.extract(c), g = {
1100
- tag: c.tagName.toLowerCase(),
1101
- semantics: f,
1102
- score: h?.score ?? $.DEGRADED_SCORE,
1103
- degraded: u
1104
- }, d = a.buildPath(
1105
- c,
1205
+ const d = u?.element ?? n.ownerDocument?.body ?? null;
1206
+ if (!d) return null;
1207
+ const c = !u || u.tier === "C", h = d.tagName.toLowerCase(), g = d.parentElement;
1208
+ let f;
1209
+ if (g && h !== "body" && h !== "html") {
1210
+ const T = Array.from(g.children).indexOf(d);
1211
+ T !== -1 && (f = T + 1);
1212
+ }
1213
+ const p = o.extract(d), m = {
1214
+ tag: d.tagName.toLowerCase(),
1215
+ semantics: p,
1216
+ score: u?.score ?? I.DEGRADED_SCORE,
1217
+ degraded: c,
1218
+ nthChild: f
1219
+ }, b = i.buildPath(
1220
+ d,
1106
1221
  n,
1107
1222
  o
1108
- ), m = o.extract(n);
1109
- e.enableSvgFingerprint && Rt(n) && (m.svg = l.fingerprint(n));
1110
- const p = n.parentElement;
1111
- let S;
1112
- if (p) {
1113
- const C = Array.from(p.children).indexOf(n);
1114
- C !== -1 && (S = C + 1);
1115
- }
1116
- const y = {
1223
+ ), y = o.extract(n);
1224
+ e.enableSvgFingerprint && zt(n) && (y.svg = l.fingerprint(n));
1225
+ const v = n.parentElement;
1226
+ let A;
1227
+ if (v) {
1228
+ const T = Array.from(v.children).indexOf(n);
1229
+ T !== -1 && (A = T + 1);
1230
+ }
1231
+ const S = {
1117
1232
  tag: n.tagName.toLowerCase(),
1118
- semantics: m,
1233
+ semantics: y,
1119
1234
  score: o.scoreElement(n),
1120
- nthChild: S
1121
- }, w = [], A = {
1235
+ nthChild: A
1236
+ }, $ = [], M = {
1122
1237
  onMultiple: "best-score",
1123
1238
  onMissing: "anchor-only",
1124
1239
  maxDepth: 3
1125
- }, b = g.degraded || d.degraded, v = Dt(g.degraded, d), x = {
1240
+ }, H = m.degraded || b.degraded, E = Ut(m.degraded, b), C = {
1126
1241
  version: "1.0",
1127
- anchor: g,
1128
- path: d.path,
1129
- target: y,
1130
- constraints: w,
1131
- fallback: A,
1242
+ anchor: m,
1243
+ path: b.path,
1244
+ target: S,
1245
+ constraints: $,
1246
+ fallback: M,
1132
1247
  meta: {
1133
1248
  confidence: 0,
1134
1249
  // Calculated below
1135
1250
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1136
1251
  generator: "dom-eid@1.0",
1137
1252
  source: e.source,
1138
- degraded: b,
1139
- degradationReason: v
1253
+ degraded: H,
1254
+ degradationReason: E
1140
1255
  }
1141
1256
  };
1142
- return x.meta.confidence = $t(x), x.meta.confidence < e.confidenceThreshold ? null : (s.setEID(n, x), x);
1257
+ return C.meta.confidence = kt(C), C.meta.confidence < e.confidenceThreshold ? null : (s.setEID(n, C), C);
1143
1258
  }
1144
- function Rt(n) {
1259
+ function zt(n) {
1145
1260
  return n.namespaceURI === "http://www.w3.org/2000/svg" || n.tagName.toLowerCase() === "svg" || n instanceof SVGElement;
1146
1261
  }
1147
- function Dt(n, t) {
1262
+ function Ut(n, t) {
1148
1263
  if (n && t.degraded)
1149
1264
  return "anchor-and-path-degraded";
1150
1265
  if (n)
@@ -1155,64 +1270,64 @@ function Dt(n, t) {
1155
1270
  class st {
1156
1271
  buildSelector(t, e) {
1157
1272
  if (t.path.length === 0 && t.anchor.tag === t.target.tag && JSON.stringify(t.anchor.semantics) === JSON.stringify(t.target.semantics)) {
1158
- const u = this.buildNodeSelector(
1273
+ const c = this.buildNodeSelector(
1159
1274
  t.target.tag,
1160
1275
  t.target.semantics,
1161
1276
  { excludeClasses: !1 }
1162
1277
  // Include classes for same-element case
1163
1278
  );
1164
- return e?.ensureUnique ? this.ensureUniqueSelector(u, t, e) : u;
1279
+ return e?.ensureUnique ? this.ensureUniqueSelector(c, t, e) : c;
1165
1280
  }
1166
- const r = [], i = e?.ensureUnique ? this.ensureUniqueAnchor(t, e.root ?? document) : this.buildNodeSelector(t.anchor.tag, t.anchor.semantics);
1167
- r.push(i);
1168
- for (const u of t.path) {
1169
- let f = this.buildNodeSelector(u.tag, u.semantics);
1170
- u.nthChild !== void 0 && (["tr", "td", "th", "thead", "tbody", "tfoot"].includes(u.tag) ? f += `:nth-child(${u.nthChild})` : f += `:nth-child(${u.nthChild})`), r.push(f);
1281
+ const r = [], a = e?.ensureUnique ? this.ensureUniqueAnchor(t, e.root ?? document) : this.buildNodeSelector(t.anchor.tag, t.anchor.semantics);
1282
+ r.push(a);
1283
+ for (const c of t.path) {
1284
+ let h = this.buildNodeSelector(c.tag, c.semantics);
1285
+ c.nthChild !== void 0 && (["tr", "td", "th", "thead", "tbody", "tfoot"].includes(c.tag) ? h += `:nth-child(${c.nthChild})` : h += `:nth-child(${c.nthChild})`), r.push(h);
1171
1286
  }
1172
- let a = this.buildNodeSelector(
1287
+ let i = this.buildNodeSelector(
1173
1288
  t.target.tag,
1174
1289
  t.target.semantics,
1175
1290
  { excludeClasses: e?.ensureUnique }
1176
1291
  // Exclude classes initially if we need unique
1177
1292
  );
1178
- t.target.nthChild !== void 0 && (["tr", "td", "th", "thead", "tbody", "tfoot"].includes(t.target.tag) ? a += `:nth-child(${t.target.nthChild})` : a += `:nth-child(${t.target.nthChild})`), r.push(a);
1179
- const o = this.isSvgChildElement(t.target.tag), l = t.path.some((u) => u.tag === "svg");
1180
- let h;
1293
+ t.target.nthChild !== void 0 && (["tr", "td", "th", "thead", "tbody", "tfoot"].includes(t.target.tag) ? i += `:nth-child(${t.target.nthChild})` : i += `:nth-child(${t.target.nthChild})`), r.push(i);
1294
+ const o = this.isSvgChildElement(t.target.tag), l = t.path.some((c) => c.tag === "svg");
1295
+ let u;
1181
1296
  if (o && l) {
1182
- const u = t.path.findIndex((f) => f.tag === "svg");
1183
- if (u !== -1) {
1184
- const f = u + 1, g = r.slice(0, f + 1), d = r.slice(f + 1, -1), m = r[r.length - 1];
1185
- d.length > 0 ? h = g.join(" ") + " > " + d.join(" > ") + " > " + m : h = g.join(" ") + " > " + m;
1297
+ const c = t.path.findIndex((h) => h.tag === "svg");
1298
+ if (c !== -1) {
1299
+ const h = c + 1, g = r.slice(0, h + 1), f = r.slice(h + 1, -1), p = r[r.length - 1];
1300
+ f.length > 0 ? u = g.join(" ") + " > " + f.join(" > ") + " > " + p : u = g.join(" ") + " > " + p;
1186
1301
  } else
1187
- h = r.join(" ");
1302
+ u = r.join(" ");
1188
1303
  } else
1189
- h = r.join(" ");
1304
+ u = r.join(" ");
1190
1305
  if (!e?.ensureUnique)
1191
- return h;
1192
- const c = this.querySelectorSafe(h, e.root ?? document);
1193
- if (c.length === 1)
1306
+ return u;
1307
+ const d = this.querySelectorSafe(u, e.root ?? document);
1308
+ if (d.length === 1)
1194
1309
  return {
1195
- selector: h,
1310
+ selector: u,
1196
1311
  isUnique: !0,
1197
- usedNthOfType: h.includes(":nth-"),
1312
+ usedNthOfType: u.includes(":nth-"),
1198
1313
  extraClassesAdded: 0
1199
1314
  };
1200
- if (c.length === 0 || c.length > 1) {
1201
- const u = this.buildFullDomPathSelector(
1315
+ if (d.length === 0 || d.length > 1) {
1316
+ const c = this.buildFullDomPathSelector(
1202
1317
  t,
1203
1318
  t.target.semantics,
1204
1319
  e.root ?? document
1205
1320
  );
1206
- if (u && this.isUnique(u, e.root ?? document))
1321
+ if (c && this.isUnique(c, e.root ?? document))
1207
1322
  return {
1208
- selector: u,
1323
+ selector: c,
1209
1324
  isUnique: !0,
1210
- usedNthOfType: u.includes(":nth-"),
1325
+ usedNthOfType: c.includes(":nth-"),
1211
1326
  extraClassesAdded: 0
1212
1327
  };
1213
1328
  }
1214
1329
  return this.ensureUniqueSelector(
1215
- h,
1330
+ u,
1216
1331
  t,
1217
1332
  e
1218
1333
  );
@@ -1229,11 +1344,11 @@ class st {
1229
1344
  * Ensures selector uniqueness by progressively adding classes and nth-of-type
1230
1345
  */
1231
1346
  ensureUniqueSelector(t, e, s) {
1232
- const r = s.root ?? document, i = s.maxClasses ?? 4, a = e.target.tag, o = e.target.semantics;
1233
- let l = t, h = 0, c = !1;
1347
+ const r = s.root ?? document, a = s.maxClasses ?? 4, i = e.target.tag, o = e.target.semantics;
1348
+ let l = t, u = 0, d = !1;
1234
1349
  if (this.querySelectorSafe(l, r).length === 0) {
1235
- const d = this.buildFullDomPathSelector(e, o, r);
1236
- if (d && (l = d, this.isUnique(l, r)))
1350
+ const f = this.buildFullDomPathSelector(e, o, r);
1351
+ if (f && (l = f, this.isUnique(l, r)))
1237
1352
  return {
1238
1353
  selector: l,
1239
1354
  isUnique: !0,
@@ -1248,33 +1363,33 @@ class st {
1248
1363
  usedNthOfType: !1,
1249
1364
  extraClassesAdded: 0
1250
1365
  };
1251
- const f = I(o.classes ?? []);
1252
- for (let d = 0; d < Math.min(f.length, i); d++) {
1253
- const m = f[d];
1254
- if (l += `.${this.escapeCSS(m)}`, h++, this.isUnique(l, r))
1366
+ const h = N(o.classes ?? []);
1367
+ for (let f = 0; f < Math.min(h.length, a); f++) {
1368
+ const p = h[f];
1369
+ if (l += `.${this.escapeCSS(p)}`, u++, this.isUnique(l, r))
1255
1370
  return {
1256
1371
  selector: l,
1257
1372
  isUnique: !0,
1258
1373
  usedNthOfType: !1,
1259
- extraClassesAdded: h
1374
+ extraClassesAdded: u
1260
1375
  };
1261
1376
  }
1262
1377
  if (!this.isUnique(l, r)) {
1263
- const d = this.buildFullDomPathSelector(e, o, r);
1264
- if (d && this.isUnique(d, r))
1378
+ const f = this.buildFullDomPathSelector(e, o, r);
1379
+ if (f && this.isUnique(f, r))
1265
1380
  return {
1266
- selector: d,
1381
+ selector: f,
1267
1382
  isUnique: !0,
1268
- usedNthOfType: d.includes(":nth-of-type("),
1269
- extraClassesAdded: h
1383
+ usedNthOfType: f.includes(":nth-of-type("),
1384
+ extraClassesAdded: u
1270
1385
  };
1271
1386
  }
1272
1387
  const g = this.findNthElementByText(l, o, r);
1273
- return g && (l += this.getNthSelector(g, a), c = !0), {
1388
+ return g && (l += this.getNthSelector(g, i), d = !0), {
1274
1389
  selector: l,
1275
1390
  isUnique: this.isUnique(l, r),
1276
- usedNthOfType: c,
1277
- extraClassesAdded: h
1391
+ usedNthOfType: d,
1392
+ extraClassesAdded: u
1278
1393
  };
1279
1394
  }
1280
1395
  /**
@@ -1282,29 +1397,29 @@ class st {
1282
1397
  * This handles cases where intermediate div/span elements were filtered out
1283
1398
  */
1284
1399
  buildFullDomPathSelector(t, e, s) {
1285
- const r = this.buildNodeSelector(t.anchor.tag, t.anchor.semantics), i = this.querySelectorSafe(r, s);
1286
- if (i.length === 0) return null;
1287
- for (const a of i) {
1400
+ const r = this.buildNodeSelector(t.anchor.tag, t.anchor.semantics), a = this.querySelectorSafe(r, s);
1401
+ if (a.length === 0) return null;
1402
+ for (const i of a) {
1288
1403
  const o = this.findTargetWithinAnchor(
1289
- a,
1404
+ i,
1290
1405
  t.target.tag,
1291
1406
  e
1292
1407
  );
1293
1408
  if (o.length === 0) continue;
1294
- const l = o.map((h) => {
1295
- const c = this.scorePathMatch(h, a, t.path);
1296
- return { element: h, score: c };
1409
+ const l = o.map((u) => {
1410
+ const d = this.scorePathMatch(u, i, t.path);
1411
+ return { element: u, score: d };
1297
1412
  });
1298
- l.sort((h, c) => c.score - h.score);
1299
- for (const { element: h } of l) {
1300
- const c = this.buildPathFromAnchorToTarget(
1301
- a,
1302
- h,
1413
+ l.sort((u, d) => d.score - u.score);
1414
+ for (const { element: u } of l) {
1415
+ const d = this.buildPathFromAnchorToTarget(
1416
+ i,
1417
+ u,
1303
1418
  t,
1304
1419
  s
1305
1420
  );
1306
- if (c && this.isUnique(c, s))
1307
- return c;
1421
+ if (d && this.isUnique(d, s))
1422
+ return d;
1308
1423
  }
1309
1424
  }
1310
1425
  return null;
@@ -1319,52 +1434,52 @@ class st {
1319
1434
  */
1320
1435
  scorePathMatch(t, e, s) {
1321
1436
  const r = [];
1322
- let i = t.parentElement;
1323
- for (; i && i !== e; )
1324
- r.unshift(i), i = i.parentElement;
1325
- let a = 0;
1437
+ let a = t.parentElement;
1438
+ for (; a && a !== e; )
1439
+ r.unshift(a), a = a.parentElement;
1440
+ let i = 0;
1326
1441
  const o = Math.min(r.length, s.length);
1327
- for (let h = 0; h < o; h++) {
1328
- const c = r[h], u = s[h];
1329
- if (c.tagName.toLowerCase() === u.tag) {
1330
- if (a += 10, u.nthChild !== void 0) {
1331
- const f = c.parentElement;
1332
- f && (Array.from(f.children).indexOf(c) + 1 === u.nthChild ? a += 20 : a -= 10);
1442
+ for (let u = 0; u < o; u++) {
1443
+ const d = r[u], c = s[u];
1444
+ if (d.tagName.toLowerCase() === c.tag) {
1445
+ if (i += 10, c.nthChild !== void 0) {
1446
+ const h = d.parentElement;
1447
+ h && (Array.from(h.children).indexOf(d) + 1 === c.nthChild ? i += 20 : i -= 10);
1333
1448
  }
1334
1449
  } else
1335
- a -= 5;
1336
- if (u.semantics.classes && u.semantics.classes.length > 0) {
1337
- const f = u.semantics.classes.filter(
1338
- (g) => c.classList.contains(g)
1450
+ i -= 5;
1451
+ if (c.semantics.classes && c.semantics.classes.length > 0) {
1452
+ const h = c.semantics.classes.filter(
1453
+ (g) => d.classList.contains(g)
1339
1454
  );
1340
- a += f.length * 2;
1455
+ i += h.length * 2;
1341
1456
  }
1342
- if (u.semantics.attributes) {
1343
- const f = Object.entries(u.semantics.attributes).filter(
1344
- ([g, d]) => c.getAttribute(g) === d
1457
+ if (c.semantics.attributes) {
1458
+ const h = Object.entries(c.semantics.attributes).filter(
1459
+ ([g, f]) => d.getAttribute(g) === f
1345
1460
  );
1346
- a += f.length * 3;
1461
+ i += h.length * 3;
1347
1462
  }
1348
1463
  }
1349
1464
  const l = Math.abs(r.length - s.length);
1350
- return a -= l * 2, a;
1465
+ return i -= l * 2, i;
1351
1466
  }
1352
1467
  /**
1353
1468
  * Finds target elements within an anchor by matching semantics
1354
1469
  */
1355
1470
  findTargetWithinAnchor(t, e, s) {
1356
- return Array.from(t.querySelectorAll(e)).filter((i) => {
1471
+ return Array.from(t.querySelectorAll(e)).filter((a) => {
1357
1472
  if (s.text) {
1358
- const a = i.textContent?.trim() || "", o = s.text.normalized;
1359
- if (!a.includes(o) && !o.includes(a))
1473
+ const i = a.textContent?.trim() || "", o = s.text.normalized;
1474
+ if (!i.includes(o) && !o.includes(i))
1360
1475
  return !1;
1361
1476
  }
1362
1477
  return !!(s.classes && s.classes.length > 0 && s.classes.every(
1363
- (o) => i.classList.contains(o)
1478
+ (o) => a.classList.contains(o)
1364
1479
  ) || s.attributes && Object.entries(s.attributes).every(
1365
1480
  ([o, l]) => {
1366
- const h = i.getAttribute(o);
1367
- return o === "href" || o === "src" ? P(o, h || "") === P(o, l) : h === l;
1481
+ const u = a.getAttribute(o);
1482
+ return o === "href" || o === "src" ? _(o, u || "") === _(o, l) : u === l;
1368
1483
  }
1369
1484
  ) || s.text);
1370
1485
  });
@@ -1379,24 +1494,24 @@ class st {
1379
1494
  * @param root Root element for queries
1380
1495
  * @returns Disambiguated selector part (e.g., "div[role='main']" or "div.sidebar" or "div:nth-of-type(3)")
1381
1496
  */
1382
- disambiguateParent(t, e, s, r, i) {
1497
+ disambiguateParent(t, e, s, r, a) {
1383
1498
  if (s?.semantics?.attributes) {
1384
1499
  const o = this.buildNodeSelector(e, s.semantics, {
1385
1500
  excludeClasses: !0
1386
- }), l = [...r, e].join(" > "), h = this.querySelectorSafe(l, i), c = [...r, o].join(" > "), u = this.querySelectorSafe(c, i);
1387
- if (u.length > 0 && u.length < h.length)
1501
+ }), l = [...r, e].join(" > "), u = this.querySelectorSafe(l, a), d = [...r, o].join(" > "), c = this.querySelectorSafe(d, a);
1502
+ if (c.length > 0 && c.length < u.length)
1388
1503
  return o;
1389
1504
  }
1390
1505
  if (s?.semantics?.classes) {
1391
- const o = I(s.semantics.classes);
1506
+ const o = N(s.semantics.classes);
1392
1507
  if (o.length > 0) {
1393
- const l = `${e}.${this.escapeCSS(o[0])}`, h = [...r, e].join(" > "), c = this.querySelectorSafe(h, i), u = [...r, l].join(" > "), f = this.querySelectorSafe(u, i);
1394
- if (f.length > 0 && f.length < c.length)
1508
+ const l = `${e}.${this.escapeCSS(o[0])}`, u = [...r, e].join(" > "), d = this.querySelectorSafe(u, a), c = [...r, l].join(" > "), h = this.querySelectorSafe(c, a);
1509
+ if (h.length > 0 && h.length < d.length)
1395
1510
  return l;
1396
1511
  }
1397
1512
  }
1398
- const a = t.parentElement;
1399
- return a && Array.from(a.children).filter(
1513
+ const i = t.parentElement;
1514
+ return i && Array.from(i.children).filter(
1400
1515
  (l) => l.tagName.toLowerCase() === e
1401
1516
  ).length > 1 ? `${e}${this.getNthSelector(t, e)}` : e;
1402
1517
  }
@@ -1404,11 +1519,11 @@ class st {
1404
1519
  * Builds CSS selector path from anchor to target by traversing actual DOM
1405
1520
  */
1406
1521
  buildPathFromAnchorToTarget(t, e, s, r) {
1407
- const i = [];
1408
- let a = e;
1409
- for (; a && a !== t; )
1410
- i.unshift(a), a = a.parentElement;
1411
- if (a !== t)
1522
+ const a = [];
1523
+ let i = e;
1524
+ for (; i && i !== t; )
1525
+ a.unshift(i), i = i.parentElement;
1526
+ if (i !== t)
1412
1527
  return null;
1413
1528
  const o = [
1414
1529
  // ============================================================
@@ -1416,17 +1531,17 @@ class st {
1416
1531
  // Most flexible - no classes on target, only semantic attributes
1417
1532
  // ============================================================
1418
1533
  () => {
1419
- const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), h = s.target.tag, c = s.target.semantics, u = [];
1420
- for (const p of s.path)
1421
- u.push(p.tag);
1422
- const g = [l, ...u, h].filter(Boolean).join(" ");
1534
+ const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = s.target.tag, d = s.target.semantics, c = [];
1535
+ for (const m of s.path)
1536
+ c.push(m.tag);
1537
+ const g = [l, ...c, u].filter(Boolean).join(" ");
1423
1538
  if (this.isUnique(g, r))
1424
1539
  return g;
1425
- const d = this.buildNodeSelector(h, c, {
1540
+ const f = this.buildNodeSelector(u, d, {
1426
1541
  excludeClasses: !0
1427
1542
  // KEY: no classes on target in Strategy 0
1428
- }), m = [l, ...u.slice(0, -1), d].join(" ");
1429
- return this.isUnique(m, r) ? m : null;
1543
+ }), p = [l, ...c.slice(0, -1), f].join(" ");
1544
+ return this.isUnique(p, r) ? p : null;
1430
1545
  },
1431
1546
  // ============================================================
1432
1547
  // Strategy 1: anchor > parent[attrs|class|nth] > target[attrs_only]
@@ -1435,31 +1550,31 @@ class st {
1435
1550
  // Target: ONLY attributes, NO classes
1436
1551
  // ============================================================
1437
1552
  () => {
1438
- const l = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)], h = /* @__PURE__ */ new Map();
1439
- let c = 0;
1440
- for (let f = 0; f < i.length - 1; f++) {
1441
- const g = i[f], d = g.tagName.toLowerCase();
1442
- c < s.path.length && s.path[c].tag === d ? (h.set(g, s.path[c]), c++) : h.set(g, null);
1553
+ const l = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)], u = /* @__PURE__ */ new Map();
1554
+ let d = 0;
1555
+ for (let h = 0; h < a.length - 1; h++) {
1556
+ const g = a[h], f = g.tagName.toLowerCase();
1557
+ d < s.path.length && s.path[d].tag === f ? (u.set(g, s.path[d]), d++) : u.set(g, null);
1443
1558
  }
1444
- for (let f = 0; f < i.length; f++) {
1445
- const g = i[f], d = g.tagName.toLowerCase();
1446
- if (f < i.length - 1) {
1447
- const S = h.get(g) || null, y = this.disambiguateParent(g, d, S, l, r);
1559
+ for (let h = 0; h < a.length; h++) {
1560
+ const g = a[h], f = g.tagName.toLowerCase();
1561
+ if (h < a.length - 1) {
1562
+ const b = u.get(g) || null, y = this.disambiguateParent(g, f, b, l, r);
1448
1563
  l.push(y);
1449
1564
  continue;
1450
1565
  }
1451
- const m = this.buildNodeSelector(
1566
+ const p = this.buildNodeSelector(
1452
1567
  s.target.tag,
1453
1568
  s.target.semantics,
1454
1569
  { excludeClasses: !0 }
1455
1570
  // KEY: no classes on target
1456
- ), p = g.parentElement;
1457
- p && ["td", "th", "tr", "thead", "tbody", "tfoot"].includes(d) && Array.from(p.children).filter(
1458
- (y) => y.tagName.toLowerCase() === d
1459
- ).length > 1 ? l.push(`${m}${this.getNthSelector(g, d)}`) : l.push(m);
1571
+ ), m = g.parentElement;
1572
+ m && ["td", "th", "tr", "thead", "tbody", "tfoot"].includes(f) && Array.from(m.children).filter(
1573
+ (y) => y.tagName.toLowerCase() === f
1574
+ ).length > 1 ? l.push(`${p}${this.getNthSelector(g, f)}`) : l.push(p);
1460
1575
  }
1461
- const u = l.join(" > ");
1462
- return this.isUnique(u, r) ? u : null;
1576
+ const c = l.join(" > ");
1577
+ return this.isUnique(c, r) ? c : null;
1463
1578
  },
1464
1579
  // ============================================================
1465
1580
  // Strategy 2: anchor parent[attrs|class|nth] target[attrs_only]
@@ -1468,48 +1583,48 @@ class st {
1468
1583
  // Target: ONLY attributes, NO classes
1469
1584
  // ============================================================
1470
1585
  () => {
1471
- const h = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)];
1472
- for (let f = 0; f < i.length - 1; f++) {
1473
- const d = i[f].tagName.toLowerCase(), m = s.path[f] || null, p = h.join(" ") + " " + d;
1474
- if (this.querySelectorSafe(p, r).length > 1) {
1475
- if (m?.semantics?.attributes) {
1476
- const A = this.buildNodeSelector(d, m.semantics, {
1586
+ const u = [this.buildNodeSelector(s.anchor.tag, s.anchor.semantics)];
1587
+ for (let h = 0; h < a.length - 1; h++) {
1588
+ const f = a[h].tagName.toLowerCase(), p = s.path[h] || null, m = u.join(" ") + " " + f;
1589
+ if (this.querySelectorSafe(m, r).length > 1) {
1590
+ if (p?.semantics?.attributes) {
1591
+ const A = this.buildNodeSelector(f, p.semantics, {
1477
1592
  excludeClasses: !0
1478
- }), b = h.join(" ") + " " + A;
1479
- if (this.querySelectorSafe(b, r).length === 1 || this.querySelectorSafe(b + " " + s.target.tag, r).length === 1) {
1480
- h.push(A);
1593
+ }), S = u.join(" ") + " " + A;
1594
+ if (this.querySelectorSafe(S, r).length === 1 || this.querySelectorSafe(S + " " + s.target.tag, r).length === 1) {
1595
+ u.push(A);
1481
1596
  continue;
1482
1597
  }
1483
1598
  }
1484
- if (m?.semantics?.classes) {
1485
- const A = I(m.semantics.classes);
1599
+ if (p?.semantics?.classes) {
1600
+ const A = N(p.semantics.classes);
1486
1601
  if (A.length > 0) {
1487
- const b = `${d}.${this.escapeCSS(A[0])}`, v = h.join(" ") + " " + b;
1488
- if (this.querySelectorSafe(v, r).length === 1 || this.querySelectorSafe(v + " " + s.target.tag, r).length === 1) {
1489
- h.push(b);
1602
+ const S = `${f}.${this.escapeCSS(A[0])}`, $ = u.join(" ") + " " + S;
1603
+ if (this.querySelectorSafe($, r).length === 1 || this.querySelectorSafe($ + " " + s.target.tag, r).length === 1) {
1604
+ u.push(S);
1490
1605
  continue;
1491
1606
  }
1492
1607
  }
1493
1608
  }
1494
- const y = i[f], w = y.parentElement;
1495
- if (w && Array.from(w.children).filter(
1496
- (b) => b.tagName.toLowerCase() === d
1609
+ const y = a[h], v = y.parentElement;
1610
+ if (v && Array.from(v.children).filter(
1611
+ (S) => S.tagName.toLowerCase() === f
1497
1612
  ).length > 1) {
1498
- h.push(`${d}${this.getNthSelector(y, d)}`);
1613
+ u.push(`${f}${this.getNthSelector(y, f)}`);
1499
1614
  continue;
1500
1615
  }
1501
1616
  }
1502
- h.push(d);
1617
+ u.push(f);
1503
1618
  }
1504
- const c = this.buildNodeSelector(
1619
+ const d = this.buildNodeSelector(
1505
1620
  s.target.tag,
1506
1621
  s.target.semantics,
1507
1622
  { excludeClasses: !0 }
1508
1623
  // KEY: no classes on target
1509
1624
  );
1510
- h.push(c);
1511
- const u = h.join(" ");
1512
- return this.isUnique(u, r) ? u : null;
1625
+ u.push(d);
1626
+ const c = u.join(" ");
1627
+ return this.isUnique(c, r) ? c : null;
1513
1628
  },
1514
1629
  // ============================================================
1515
1630
  // Strategy 3: anchor path target[attrs + 1_stable_class]
@@ -1517,18 +1632,18 @@ class st {
1517
1632
  // Only use this if attrs alone are not sufficient
1518
1633
  // ============================================================
1519
1634
  () => {
1520
- const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), h = [];
1635
+ const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = [];
1521
1636
  for (const g of s.path)
1522
- h.push(g.tag);
1523
- if (I(s.target.semantics.classes ?? []).length === 0)
1637
+ u.push(g.tag);
1638
+ if (N(s.target.semantics.classes ?? []).length === 0)
1524
1639
  return null;
1525
- const u = this.buildNodeSelector(
1640
+ const c = this.buildNodeSelector(
1526
1641
  s.target.tag,
1527
1642
  s.target.semantics,
1528
1643
  { maxClasses: 1 }
1529
1644
  // KEY: ONE stable class only
1530
- ), f = [l, ...h.slice(0, -1), u].join(" ");
1531
- return this.isUnique(f, r) ? f : null;
1645
+ ), h = [l, ...u.slice(0, -1), c].join(" ");
1646
+ return this.isUnique(h, r) ? h : null;
1532
1647
  },
1533
1648
  // ============================================================
1534
1649
  // Strategy 4: anchor path target[attrs]:nth-of-type(N)
@@ -1536,25 +1651,25 @@ class st {
1536
1651
  // Only use when all other strategies fail
1537
1652
  // ============================================================
1538
1653
  () => {
1539
- const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), h = [];
1540
- for (const m of s.path)
1541
- h.push(m.tag);
1542
- const c = i[i.length - 1], u = c.parentElement;
1543
- if (!u || Array.from(u.children).filter(
1544
- (m) => m.tagName.toLowerCase() === s.target.tag
1654
+ const l = this.buildNodeSelector(s.anchor.tag, s.anchor.semantics), u = [];
1655
+ for (const p of s.path)
1656
+ u.push(p.tag);
1657
+ const d = a[a.length - 1], c = d.parentElement;
1658
+ if (!c || Array.from(c.children).filter(
1659
+ (p) => p.tagName.toLowerCase() === s.target.tag
1545
1660
  ).length <= 1) return null;
1546
1661
  const g = this.buildNodeSelector(
1547
1662
  s.target.tag,
1548
1663
  s.target.semantics,
1549
1664
  { excludeClasses: !0 }
1550
1665
  // No classes, just attrs + nth
1551
- ) + this.getNthSelector(c, s.target.tag), d = [l, ...h.slice(0, -1), g].join(" ");
1552
- return this.isUnique(d, r) ? d : null;
1666
+ ) + this.getNthSelector(d, s.target.tag), f = [l, ...u.slice(0, -1), g].join(" ");
1667
+ return this.isUnique(f, r) ? f : null;
1553
1668
  }
1554
1669
  ];
1555
1670
  for (const l of o) {
1556
- const h = l();
1557
- if (h) return h;
1671
+ const u = l();
1672
+ if (u) return u;
1558
1673
  }
1559
1674
  return null;
1560
1675
  }
@@ -1569,10 +1684,10 @@ class st {
1569
1684
  let s = e;
1570
1685
  if (t.id && !D(t.id))
1571
1686
  return `${e}#${this.escapeCSS(t.id)}`;
1572
- const r = Array.from(t.classList), i = I(r);
1573
- i.length > 0 && (s += i.slice(0, 2).map((o) => `.${this.escapeCSS(o)}`).join(""));
1574
- const a = t.getAttribute("role");
1575
- return a && (s += `[role="${this.escapeAttr(a)}"]`), s;
1687
+ const r = Array.from(t.classList), a = N(r);
1688
+ a.length > 0 && (s += a.slice(0, 2).map((o) => `.${this.escapeCSS(o)}`).join(""));
1689
+ const i = t.getAttribute("role");
1690
+ return i && (s += `[role="${this.escapeAttr(i)}"]`), s;
1576
1691
  }
1577
1692
  /**
1578
1693
  * Safe querySelectorAll that doesn't throw
@@ -1592,11 +1707,11 @@ class st {
1592
1707
  const r = this.querySelectorSafe(t, s);
1593
1708
  if (r.length <= 1) return null;
1594
1709
  if (e.text) {
1595
- const i = e.text.normalized;
1596
- for (const a of r) {
1597
- const o = a.textContent?.trim() || "";
1598
- if (o === i || o.includes(i) || i.includes(o))
1599
- return a;
1710
+ const a = e.text.normalized;
1711
+ for (const i of r) {
1712
+ const o = i.textContent?.trim() || "";
1713
+ if (o === a || o.includes(a) || a.includes(o))
1714
+ return i;
1600
1715
  }
1601
1716
  }
1602
1717
  return null;
@@ -1617,10 +1732,10 @@ class st {
1617
1732
  getNthOfTypeIndex(t, e) {
1618
1733
  const s = t.parentElement;
1619
1734
  if (!s) return null;
1620
- const i = Array.from(s.children).filter(
1621
- (a) => a.tagName.toLowerCase() === e
1735
+ const a = Array.from(s.children).filter(
1736
+ (i) => i.tagName.toLowerCase() === e
1622
1737
  ).indexOf(t);
1623
- return i !== -1 ? i + 1 : null;
1738
+ return a !== -1 ? a + 1 : null;
1624
1739
  }
1625
1740
  /**
1626
1741
  * FIX 2: Ensures anchor selector is unique in the document
@@ -1634,29 +1749,34 @@ class st {
1634
1749
  if (this.isUnique(s, e))
1635
1750
  return s;
1636
1751
  if (r.classes && r.classes.length > 0) {
1637
- const a = I(r.classes);
1638
- if (a.length > 0) {
1639
- const o = `${s}.${this.escapeCSS(a[0])}`;
1752
+ const i = N(r.classes);
1753
+ if (i.length > 0) {
1754
+ const o = `${s}.${this.escapeCSS(i[0])}`;
1640
1755
  if (this.isUnique(o, e))
1641
1756
  return o;
1642
1757
  }
1643
1758
  }
1644
1759
  if (r.attributes) {
1645
- const a = this.getSortedAttributes(r.attributes);
1646
- for (const { name: o, value: l } of a) {
1647
- const h = o === "href" || o === "src" ? P(o, l) : l;
1648
- if (h) {
1649
- const c = `${s}[${o}="${this.escapeAttr(h)}"]`;
1650
- if (this.isUnique(c, e))
1651
- return c;
1760
+ const i = this.getSortedAttributes(r.attributes);
1761
+ for (const { name: o, value: l } of i) {
1762
+ const u = o === "href" || o === "src" ? _(o, l) : l;
1763
+ if (u) {
1764
+ const d = `${s}[${o}="${this.escapeAttr(u)}"]`;
1765
+ if (this.isUnique(d, e))
1766
+ return d;
1652
1767
  }
1653
1768
  }
1654
1769
  }
1655
- const i = Array.from(e.querySelectorAll(s));
1656
- if (i.length > 1) {
1657
- const a = this.findElementBySemantics(i, r);
1658
- if (a) {
1659
- const o = this.getNthOfTypeIndex(a, s);
1770
+ if (t.anchor.nthChild !== void 0) {
1771
+ const i = `${s}:nth-child(${t.anchor.nthChild})`;
1772
+ if (this.isUnique(i, e))
1773
+ return i;
1774
+ }
1775
+ const a = Array.from(e.querySelectorAll(s));
1776
+ if (a.length > 1) {
1777
+ const i = this.findElementBySemantics(a, r);
1778
+ if (i) {
1779
+ const o = this.getNthOfTypeIndex(i, s);
1660
1780
  if (o)
1661
1781
  return `${s}:nth-of-type(${o})`;
1662
1782
  }
@@ -1672,14 +1792,14 @@ class st {
1672
1792
  findElementBySemantics(t, e) {
1673
1793
  return e.classes && e.classes.length > 0 || e.attributes && Object.keys(e.attributes).length > 0 || e.text ? t.find((r) => {
1674
1794
  if (e.classes && e.classes.length > 0 && e.classes.every(
1675
- (a) => r.classList.contains(a)
1795
+ (i) => r.classList.contains(i)
1676
1796
  ) || e.attributes && Object.entries(e.attributes).every(
1677
- ([a, o]) => r.getAttribute(a) === o
1797
+ ([i, o]) => r.getAttribute(i) === o
1678
1798
  ))
1679
1799
  return !0;
1680
1800
  if (e.text) {
1681
- const i = r.textContent?.trim() || "", a = e.text.normalized;
1682
- if (i.includes(a) || a.includes(i))
1801
+ const a = r.textContent?.trim() || "", i = e.text.normalized;
1802
+ if (a.includes(i) || i.includes(a))
1683
1803
  return !0;
1684
1804
  }
1685
1805
  return !1;
@@ -1696,8 +1816,8 @@ class st {
1696
1816
  getNthSelector(t, e) {
1697
1817
  const s = t.parentElement;
1698
1818
  if (!s) return "";
1699
- const r = Array.from(s.children), i = r.indexOf(t) + 1;
1700
- return ["tr", "td", "th", "thead", "tbody", "tfoot"].includes(e) ? `:nth-child(${i})` : `:nth-of-type(${r.filter((l) => l.tagName.toLowerCase() === e).indexOf(t) + 1})`;
1819
+ const r = Array.from(s.children), a = r.indexOf(t) + 1;
1820
+ return ["tr", "td", "th", "thead", "tbody", "tfoot"].includes(e) ? `:nth-child(${a})` : `:nth-of-type(${r.filter((l) => l.tagName.toLowerCase() === e).indexOf(t) + 1})`;
1701
1821
  }
1702
1822
  /**
1703
1823
  * Gets attribute priority for sorting
@@ -1705,7 +1825,7 @@ class st {
1705
1825
  * @returns Priority number (higher = more priority)
1706
1826
  */
1707
1827
  getAttributePriority(t) {
1708
- return T[t] !== void 0 ? T[t] : t.startsWith("data-") ? T["data-*"] : t.startsWith("aria-") ? T["aria-*"] : 0;
1828
+ return w[t] !== void 0 ? w[t] : t.startsWith("data-") ? w["data-*"] : t.startsWith("aria-") ? w["aria-*"] : 0;
1709
1829
  }
1710
1830
  /**
1711
1831
  * Checks if attribute should be ignored
@@ -1736,15 +1856,15 @@ class st {
1736
1856
  if (e.id)
1737
1857
  return r += `#${this.escapeCSS(e.id)}`, r;
1738
1858
  if (e.attributes) {
1739
- const i = this.getSortedAttributes(e.attributes);
1740
- for (const { name: a, value: o } of i) {
1741
- const l = a === "href" || a === "src" ? P(a, o) : o;
1742
- l && (r += `[${a}="${this.escapeAttr(l)}"]`);
1859
+ const a = this.getSortedAttributes(e.attributes);
1860
+ for (const { name: i, value: o } of a) {
1861
+ const l = i === "href" || i === "src" ? _(i, o) : o;
1862
+ l && (r += `[${i}="${this.escapeAttr(l)}"]`);
1743
1863
  }
1744
1864
  }
1745
1865
  if (e.role && !e.attributes?.role && (r += `[role="${this.escapeAttr(e.role)}"]`), !s?.excludeClasses && e.classes && e.classes.length > 0) {
1746
- const i = I(e.classes), a = s?.maxClasses !== void 0 ? i.slice(0, s.maxClasses) : i;
1747
- r += a.map((o) => `.${this.escapeCSS(o)}`).join("");
1866
+ const a = N(e.classes), i = s?.maxClasses !== void 0 ? a.slice(0, s.maxClasses) : a;
1867
+ r += i.map((o) => `.${this.escapeCSS(o)}`).join("");
1748
1868
  }
1749
1869
  return r;
1750
1870
  }
@@ -1752,7 +1872,8 @@ class st {
1752
1872
  * Escapes special characters for CSS selector
1753
1873
  */
1754
1874
  escapeCSS(t) {
1755
- return t.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1");
1875
+ let e = t;
1876
+ return e.startsWith("-") && (e = "\\-" + e.slice(1)), e = e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, "\\$1"), e;
1756
1877
  }
1757
1878
  /**
1758
1879
  * Escapes quotes for attribute values
@@ -1769,7 +1890,7 @@ class st {
1769
1890
  return ht.includes(t);
1770
1891
  }
1771
1892
  }
1772
- class Ht {
1893
+ class Ft {
1773
1894
  /**
1774
1895
  * Filters elements that match the semantics
1775
1896
  * @param elements - Candidate elements
@@ -1790,10 +1911,10 @@ class Ht {
1790
1911
  * Prioritizes direct text nodes, but falls back to full textContent if no direct text
1791
1912
  */
1792
1913
  matchText(t, e) {
1793
- const i = Array.from(t.childNodes).filter((o) => o.nodeType === Node.TEXT_NODE).map((o) => o.textContent?.trim() ?? "").join(" ") || (t.textContent?.trim() ?? "");
1794
- if (!i) return !1;
1795
- const a = V(i);
1796
- return e.matchMode === "partial" ? a.includes(e.normalized) : a === e.normalized;
1914
+ const a = Array.from(t.childNodes).filter((o) => o.nodeType === Node.TEXT_NODE).map((o) => o.textContent?.trim() ?? "").join(" ") || (t.textContent?.trim() ?? "");
1915
+ if (!a) return !1;
1916
+ const i = V(a);
1917
+ return e.matchMode === "partial" ? i.includes(e.normalized) : i === e.normalized;
1797
1918
  }
1798
1919
  /**
1799
1920
  * Matches attributes
@@ -1821,7 +1942,7 @@ class Ht {
1821
1942
  * Computes simple path hash (matching SvgFingerprinter)
1822
1943
  */
1823
1944
  computePathHash(t) {
1824
- const r = (t.match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/gi) ?? []).slice(0, 5).map((i) => i.trim().replace(/(-?\d+\.?\d*)/g, (a) => parseFloat(a).toFixed(1))).join(" ");
1945
+ const r = (t.match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/gi) ?? []).slice(0, 5).map((a) => a.trim().replace(/(-?\d+\.?\d*)/g, (i) => parseFloat(i).toFixed(1))).join(" ");
1825
1946
  return this.simpleHash(r);
1826
1947
  }
1827
1948
  /**
@@ -1834,17 +1955,17 @@ class Ht {
1834
1955
  s.push(`r=${t.getAttribute("r") ?? "0"}`);
1835
1956
  break;
1836
1957
  case "rect": {
1837
- const r = parseFloat(t.getAttribute("width") ?? "0"), i = parseFloat(t.getAttribute("height") ?? "0");
1838
- r > 0 && i > 0 && s.push(`ratio=${(r / i).toFixed(2)}`);
1958
+ const r = parseFloat(t.getAttribute("width") ?? "0"), a = parseFloat(t.getAttribute("height") ?? "0");
1959
+ r > 0 && a > 0 && s.push(`ratio=${(r / a).toFixed(2)}`);
1839
1960
  break;
1840
1961
  }
1841
1962
  case "ellipse": {
1842
- const r = parseFloat(t.getAttribute("rx") ?? "0"), i = parseFloat(t.getAttribute("ry") ?? "0");
1843
- r > 0 && i > 0 && s.push(`ratio=${(r / i).toFixed(2)}`);
1963
+ const r = parseFloat(t.getAttribute("rx") ?? "0"), a = parseFloat(t.getAttribute("ry") ?? "0");
1964
+ r > 0 && a > 0 && s.push(`ratio=${(r / a).toFixed(2)}`);
1844
1965
  break;
1845
1966
  }
1846
1967
  case "line": {
1847
- const r = parseFloat(t.getAttribute("x1") ?? "0"), i = parseFloat(t.getAttribute("y1") ?? "0"), a = parseFloat(t.getAttribute("x2") ?? "0"), o = parseFloat(t.getAttribute("y2") ?? "0"), l = Math.atan2(o - i, a - r);
1968
+ const r = parseFloat(t.getAttribute("x1") ?? "0"), a = parseFloat(t.getAttribute("y1") ?? "0"), i = parseFloat(t.getAttribute("x2") ?? "0"), o = parseFloat(t.getAttribute("y2") ?? "0"), l = Math.atan2(o - a, i - r);
1848
1969
  s.push(`angle=${l.toFixed(2)}`);
1849
1970
  break;
1850
1971
  }
@@ -1863,7 +1984,7 @@ class Ht {
1863
1984
  return Math.abs(e).toString(16).padStart(8, "0");
1864
1985
  }
1865
1986
  }
1866
- class Pt {
1987
+ class jt {
1867
1988
  /**
1868
1989
  * Applies a single constraint to candidates
1869
1990
  * @param candidates - Current candidate elements
@@ -1944,19 +2065,19 @@ class Pt {
1944
2065
  if (t === e) return 0;
1945
2066
  if (t.length === 0) return e.length;
1946
2067
  if (e.length === 0) return t.length;
1947
- const s = Array.from({ length: e.length + 1 }, (r, i) => i);
2068
+ const s = Array.from({ length: e.length + 1 }, (r, a) => a);
1948
2069
  for (let r = 1; r <= t.length; r++) {
1949
- let i = r;
1950
- for (let a = 1; a <= e.length; a++) {
1951
- const o = t[r - 1] === e[a - 1] ? s[a - 1] : Math.min(s[a - 1], i, s[a]) + 1;
1952
- s[a - 1] = i, i = o;
2070
+ let a = r;
2071
+ for (let i = 1; i <= e.length; i++) {
2072
+ const o = t[r - 1] === e[i - 1] ? s[i - 1] : Math.min(s[i - 1], a, s[i]) + 1;
2073
+ s[i - 1] = a, a = o;
1953
2074
  }
1954
- s[e.length] = i;
2075
+ s[e.length] = a;
1955
2076
  }
1956
2077
  return s[e.length];
1957
2078
  }
1958
2079
  }
1959
- class kt {
2080
+ class Wt {
1960
2081
  constructor() {
1961
2082
  this.cssGenerator = new st();
1962
2083
  }
@@ -1995,21 +2116,21 @@ class kt {
1995
2116
  fallbackToAnchor(t, e) {
1996
2117
  const s = this.cssGenerator.buildAnchorSelector(t), r = e instanceof Document ? e : e.ownerDocument ?? e;
1997
2118
  try {
1998
- const i = r.querySelector(s);
1999
- if (i)
2119
+ const a = r.querySelector(s);
2120
+ if (a)
2000
2121
  return {
2001
2122
  status: "degraded-fallback",
2002
- elements: [i],
2123
+ elements: [a],
2003
2124
  warnings: ["Target not found, returning anchor"],
2004
2125
  confidence: t.meta.confidence * 0.3,
2005
2126
  meta: { degraded: !0, degradationReason: "anchor-fallback" }
2006
2127
  };
2007
- } catch (i) {
2008
- const a = i instanceof Error ? i.message : "Unknown selector error";
2128
+ } catch (a) {
2129
+ const i = a instanceof Error ? a.message : "Unknown selector error";
2009
2130
  return {
2010
2131
  status: "error",
2011
2132
  elements: [],
2012
- warnings: [`Invalid anchor selector: ${a}`],
2133
+ warnings: [`Invalid anchor selector: ${i}`],
2013
2134
  confidence: 0,
2014
2135
  meta: { degraded: !0, degradationReason: "invalid-anchor-selector" }
2015
2136
  };
@@ -2057,10 +2178,10 @@ class kt {
2057
2178
  */
2058
2179
  selectBestScoring(t, e) {
2059
2180
  const s = e.target.semantics;
2060
- let r = t[0], i = -1;
2061
- for (const a of t) {
2062
- const o = this.scoreElementMatch(a, s);
2063
- o > i && (i = o, r = a);
2181
+ let r = t[0], a = -1;
2182
+ for (const i of t) {
2183
+ const o = this.scoreElementMatch(i, s);
2184
+ o > a && (a = o, r = i);
2064
2185
  }
2065
2186
  return {
2066
2187
  status: "success",
@@ -2068,7 +2189,7 @@ class kt {
2068
2189
  warnings: [
2069
2190
  `Multiple matches (${t.length}), selected best-scoring element`
2070
2191
  ],
2071
- confidence: e.meta.confidence * (0.7 + i * 0.2),
2192
+ confidence: e.meta.confidence * (0.7 + a * 0.2),
2072
2193
  meta: { degraded: !0, degradationReason: "best-of-multiple" }
2073
2194
  };
2074
2195
  }
@@ -2080,61 +2201,61 @@ class kt {
2080
2201
  let s = 0, r = 0;
2081
2202
  if (e.id && (r += 0.3, t.id === e.id && (s += 0.3)), e.classes && e.classes.length > 0) {
2082
2203
  r += 0.25;
2083
- const i = Array.from(t.classList), a = e.classes.filter(
2084
- (o) => i.includes(o)
2204
+ const a = Array.from(t.classList), i = e.classes.filter(
2205
+ (o) => a.includes(o)
2085
2206
  ).length;
2086
- s += a / e.classes.length * 0.25;
2207
+ s += i / e.classes.length * 0.25;
2087
2208
  }
2088
2209
  if (e.attributes) {
2089
- const i = Object.entries(e.attributes);
2090
- if (i.length > 0) {
2210
+ const a = Object.entries(e.attributes);
2211
+ if (a.length > 0) {
2091
2212
  r += 0.2;
2092
- let a = 0;
2093
- for (const [o, l] of i)
2094
- t.getAttribute(o) === l && a++;
2095
- s += a / i.length * 0.2;
2213
+ let i = 0;
2214
+ for (const [o, l] of a)
2215
+ t.getAttribute(o) === l && i++;
2216
+ s += i / a.length * 0.2;
2096
2217
  }
2097
2218
  }
2098
2219
  if (e.role && (r += 0.15, t.getAttribute("role") === e.role && (s += 0.15)), e.text) {
2099
2220
  r += 0.1;
2100
- const i = V(t.textContent);
2101
- i === e.text.normalized ? s += 0.1 : i.includes(e.text.normalized) && (s += 0.05);
2221
+ const a = V(t.textContent);
2222
+ a === e.text.normalized ? s += 0.1 : a.includes(e.text.normalized) && (s += 0.05);
2102
2223
  }
2103
2224
  return r > 0 ? s / r : 0;
2104
2225
  }
2105
2226
  }
2106
- function qt(n, t, e = {}) {
2107
- const s = { ...ft, ...e }, r = new st(), i = new Ht(), a = new Pt(), o = new kt(), l = t instanceof Document ? t : t.ownerDocument ?? t, h = r.buildSelector(n, {
2227
+ function Bt(n, t, e = {}) {
2228
+ const s = { ...dt, ...e }, r = new st(), a = new Ft(), i = new jt(), o = new Wt(), l = t instanceof Document ? t : t.ownerDocument ?? t, u = r.buildSelector(n, {
2108
2229
  ensureUnique: !1,
2109
2230
  root: l
2110
2231
  });
2111
- let c;
2232
+ let d;
2112
2233
  try {
2113
- c = Array.from(l.querySelectorAll(h));
2114
- } catch (d) {
2115
- const m = d instanceof Error ? d.message : "Unknown selector error";
2234
+ d = Array.from(l.querySelectorAll(u));
2235
+ } catch (f) {
2236
+ const p = f instanceof Error ? f.message : "Unknown selector error";
2116
2237
  return {
2117
2238
  status: "error",
2118
2239
  elements: [],
2119
2240
  warnings: [
2120
- `Invalid CSS selector: ${h}`,
2121
- `Error: ${m}`
2241
+ `Invalid CSS selector: ${u}`,
2242
+ `Error: ${p}`
2122
2243
  ],
2123
2244
  confidence: 0,
2124
2245
  meta: { degraded: !0, degradationReason: "invalid-selector" }
2125
2246
  };
2126
2247
  }
2127
- c.length > s.maxCandidates && (c = c.slice(0, s.maxCandidates));
2128
- const u = i.match(c, n.target.semantics);
2129
- if (u.length === 1)
2248
+ d.length > s.maxCandidates && (d = d.slice(0, s.maxCandidates));
2249
+ const c = a.match(d, n.target.semantics);
2250
+ if (c.length === 1)
2130
2251
  return {
2131
2252
  status: "success",
2132
- elements: u,
2253
+ elements: c,
2133
2254
  warnings: [],
2134
2255
  confidence: n.meta.confidence,
2135
2256
  meta: { degraded: !1 }
2136
2257
  };
2137
- if (u.length === 0)
2258
+ if (c.length === 0)
2138
2259
  return s.enableFallback ? o.handleFallback(n, l) : {
2139
2260
  status: "error",
2140
2261
  elements: [],
@@ -2142,18 +2263,18 @@ function qt(n, t, e = {}) {
2142
2263
  confidence: 0,
2143
2264
  meta: { degraded: !0, degradationReason: "not-found" }
2144
2265
  };
2145
- let f = u;
2146
- const g = Ot(n.constraints);
2147
- for (const d of g) {
2148
- if (f = a.applyConstraint(f, d), f.length === 1)
2266
+ let h = c;
2267
+ const g = Gt(n.constraints);
2268
+ for (const f of g) {
2269
+ if (h = i.applyConstraint(h, f), h.length === 1)
2149
2270
  return {
2150
2271
  status: "success",
2151
- elements: f,
2272
+ elements: h,
2152
2273
  warnings: [],
2153
2274
  confidence: n.meta.confidence * 0.9,
2154
2275
  meta: { degraded: !1 }
2155
2276
  };
2156
- if (f.length === 0)
2277
+ if (h.length === 0)
2157
2278
  return s.enableFallback ? o.handleFallback(n, l) : {
2158
2279
  status: "error",
2159
2280
  elements: [],
@@ -2164,16 +2285,16 @@ function qt(n, t, e = {}) {
2164
2285
  }
2165
2286
  return s.strictMode ? {
2166
2287
  status: "ambiguous",
2167
- elements: f,
2168
- warnings: [`Non-unique resolution: ${f.length} matches`],
2288
+ elements: h,
2289
+ warnings: [`Non-unique resolution: ${h.length} matches`],
2169
2290
  confidence: n.meta.confidence * 0.7,
2170
2291
  meta: { degraded: !0, degradationReason: "ambiguous" }
2171
- } : o.handleAmbiguous(f, n);
2292
+ } : o.handleAmbiguous(h, n);
2172
2293
  }
2173
- function Ot(n) {
2294
+ function Gt(n) {
2174
2295
  return [...n].sort((t, e) => e.priority - t.priority);
2175
2296
  }
2176
- function Xt(n) {
2297
+ function oe(n) {
2177
2298
  const t = [], e = [];
2178
2299
  if (n.version ? n.version !== "1.0" && e.push(`Unknown version: ${n.version}`) : t.push("Missing version field"), n.anchor ? (n.anchor.tag || t.push("Anchor missing tag"), typeof n.anchor.score != "number" && t.push("Anchor missing score"), n.anchor.semantics || t.push("Anchor missing semantics")) : t.push("Missing anchor field"), n.target ? (n.target.tag || t.push("Target missing tag"), typeof n.target.score != "number" && t.push("Target missing score"), n.target.semantics || t.push("Target missing semantics")) : t.push("Missing target field"), !Array.isArray(n.path))
2179
2300
  t.push("Path must be an array");
@@ -2188,7 +2309,7 @@ function Xt(n) {
2188
2309
  warnings: e
2189
2310
  };
2190
2311
  }
2191
- function Jt(n) {
2312
+ function ce(n) {
2192
2313
  if (!n || typeof n != "object") return !1;
2193
2314
  const t = n;
2194
2315
  return typeof t.version == "string" && typeof t.anchor == "object" && Array.isArray(t.path) && typeof t.target == "object";
@@ -2202,19 +2323,19 @@ const rt = {
2202
2323
  includeConstraints: !0
2203
2324
  };
2204
2325
  function tt(n) {
2205
- return n === "id" ? 101 : T[n] !== void 0 ? T[n] : n.startsWith("data-") ? T["data-*"] : n.startsWith("aria-") ? T["aria-*"] : 0;
2326
+ return n === "id" ? 101 : w[n] !== void 0 ? w[n] : n.startsWith("data-") ? w["data-*"] : n.startsWith("aria-") ? w["aria-*"] : 0;
2206
2327
  }
2207
- function Lt(n) {
2328
+ function Vt(n) {
2208
2329
  return ["id", "data-testid", "data-qa", "data-cy", "href", "text", "role"].includes(n);
2209
2330
  }
2210
- function _t(n) {
2331
+ function Qt(n) {
2211
2332
  return !!(/@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/.test(n) || /(\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/.test(n) || /\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}/.test(n));
2212
2333
  }
2213
- function zt(n, t) {
2214
- const e = { ...rt, ...t }, s = `v${n.version}`, r = F(n.anchor, !1, e), i = n.path.length > 0 ? n.path.map((l) => F(l, !1, e)).join(" > ") + " > " : "", a = F(n.target, !0, e), o = e.includeConstraints ? Ut(n) : "";
2215
- return `${s}: ${r} :: ${i}${a}${o}`;
2334
+ function Zt(n, t) {
2335
+ const e = { ...rt, ...t }, s = `v${n.version}`, r = U(n.anchor, !1, e), a = n.path.length > 0 ? n.path.map((l) => U(l, !1, e)).join(" > ") + " > " : "", i = U(n.target, !0, e), o = e.includeConstraints ? Xt(n) : "";
2336
+ return `${s}: ${r} :: ${a}${i}${o}`;
2216
2337
  }
2217
- function Ft(n) {
2338
+ function Yt(n) {
2218
2339
  n = n.trim();
2219
2340
  const t = n.match(/^v(\d+(?:\.\d+)?)\s*:\s*/);
2220
2341
  if (!t)
@@ -2226,21 +2347,21 @@ function Ft(n) {
2226
2347
  const r = s.match(/^(.+?)\s*::\s*/);
2227
2348
  if (!r)
2228
2349
  throw new Error('Invalid SEQL Selector: missing anchor separator "::"');
2229
- const i = r[1].trim();
2350
+ const a = r[1].trim();
2230
2351
  s = s.slice(r[0].length);
2231
- const a = s.match(/\s*\{([^}]+)\}\s*$/);
2352
+ const i = s.match(/\s*\{([^}]+)\}\s*$/);
2232
2353
  let o = "";
2233
- a && (o = a[1], s = s.slice(0, a.index));
2234
- const l = s.split(/\s*>\s*/).map((p) => p.trim()).filter((p) => p);
2354
+ i && (o = i[1], s = s.slice(0, i.index));
2355
+ const l = s.split(/\s*>\s*/).map((m) => m.trim()).filter((m) => m);
2235
2356
  if (l.length === 0)
2236
2357
  throw new Error("Invalid SEQL Selector: missing target node");
2237
- const h = l[l.length - 1], c = l.slice(0, -1), u = U(i, !0), f = c.map((p) => U(p, !1)), g = U(h, !1), d = jt(o);
2358
+ const u = l[l.length - 1], d = l.slice(0, -1), c = F(a, !0), h = d.map((m) => F(m, !1)), g = F(u, !1), f = Kt(o);
2238
2359
  return {
2239
2360
  version: "1.0",
2240
- anchor: u,
2241
- path: f,
2361
+ anchor: c,
2362
+ path: h,
2242
2363
  target: g,
2243
- constraints: d,
2364
+ constraints: f,
2244
2365
  fallback: {
2245
2366
  onMultiple: "best-score",
2246
2367
  onMissing: "anchor-only",
@@ -2255,45 +2376,42 @@ function Ft(n) {
2255
2376
  }
2256
2377
  };
2257
2378
  }
2258
- function F(n, t = !1, e = rt) {
2379
+ function U(n, t = !1, e = rt) {
2259
2380
  const { tag: s, semantics: r } = n;
2260
- let i = s;
2261
- const a = [], o = { ...r.attributes };
2381
+ let a = s;
2382
+ const i = [], o = { ...r.attributes };
2262
2383
  r.id && (o.id = r.id), r.role && !o.role && (o.role = r.role);
2263
- const l = Object.entries(o).map(([c, u]) => {
2264
- const f = tt(c), g = c === "href" || c === "src" ? P(c, u) : u;
2265
- return { name: c, value: g, priority: f };
2384
+ const l = Object.entries(o).map(([c, h]) => {
2385
+ const g = tt(c), f = c === "href" || c === "src" ? _(c, h) : h;
2386
+ return { name: c, value: f, priority: g };
2266
2387
  }).filter((c) => ["style", "xmlns", "tabindex", "contenteditable"].includes(c.name) || B.has(c.name) && G(c.value) ? !1 : c.priority > 0 || c.name === "role" || c.name === "id");
2267
- l.sort((c, u) => u.priority - c.priority);
2268
- const h = l.slice(0, e.maxAttributes);
2269
- h.sort((c, u) => c.name.localeCompare(u.name));
2270
- for (const { name: c, value: u } of h)
2271
- a.push(`${c}="${j(u)}"`);
2272
- if (e.includeText && r.text && !_t(r.text.normalized)) {
2388
+ l.sort((c, h) => h.priority - c.priority);
2389
+ const u = l.slice(0, e.maxAttributes);
2390
+ u.sort((c, h) => c.name.localeCompare(h.name));
2391
+ for (const { name: c, value: h } of u)
2392
+ i.push(`${c}="${j(h)}"`);
2393
+ if (e.includeText && r.text && !Qt(r.text.normalized)) {
2273
2394
  const c = r.text.normalized;
2274
- c.length > 0 && c.length <= e.maxTextLength && a.push(`text="${j(c)}"`);
2275
- }
2276
- if (a.length > 0) {
2277
- let c = a;
2278
- t && e.simplifyTarget && r.id && (c = a.filter((u) => {
2279
- const f = u.split("=")[0];
2280
- return tt(f) >= 60 || f === "text" || f === "id" || f === "role";
2281
- })), c.length > 0 && (c.sort((u, f) => u.localeCompare(f)), i += `[${c.join(",")}]`);
2282
- }
2283
- if (r.classes && r.classes.length > 0) {
2284
- const c = I(r.classes), u = !!r.id || a.some((g) => g.startsWith("href=") || g.startsWith("data-testid=") || g.startsWith("text=") || g.startsWith("role="));
2285
- if (!(t && e.simplifyTarget && u) && c.length > 0) {
2286
- const g = c.sort().slice(0, e.maxClasses);
2287
- i += g.map((d) => `.${d}`).join("");
2395
+ c.length > 0 && c.length <= e.maxTextLength && i.push(`text="${j(c)}"`);
2396
+ }
2397
+ let d = i;
2398
+ if (i.length > 0 && (t && e.simplifyTarget && r.id && (d = i.filter((c) => {
2399
+ const h = c.split("=")[0];
2400
+ return tt(h) >= 60 || h === "text" || h === "id" || h === "role";
2401
+ })), d.length > 0 && d.sort((c, h) => c.localeCompare(h))), r.classes && r.classes.length > 0) {
2402
+ const c = N(r.classes), h = !!r.id || i.some((f) => f.startsWith("href=") || f.startsWith("data-testid=") || f.startsWith("text=") || f.startsWith("role="));
2403
+ if (!(t && e.simplifyTarget && h) && c.length > 0) {
2404
+ const f = c.sort().slice(0, e.maxClasses);
2405
+ a += f.map((p) => `.${p}`).join("");
2288
2406
  }
2289
2407
  }
2290
- if ("nthChild" in n && n.nthChild) {
2291
- const c = !!r.id || r.attributes && Object.keys(r.attributes).some(Lt);
2292
- t && e.simplifyTarget && c || (i += `#${n.nthChild}`);
2408
+ if (d.length > 0 && (a += `[${d.join(",")}]`), "nthChild" in n && n.nthChild) {
2409
+ const c = !!r.id || r.attributes && Object.keys(r.attributes).some(Vt);
2410
+ t && e.simplifyTarget && c || (a += `#${n.nthChild}`);
2293
2411
  }
2294
- return i;
2412
+ return a;
2295
2413
  }
2296
- function Ut(n) {
2414
+ function Xt(n) {
2297
2415
  if (!n.constraints || n.constraints.length === 0)
2298
2416
  return "";
2299
2417
  const t = [];
@@ -2314,58 +2432,58 @@ function Ut(n) {
2314
2432
  }
2315
2433
  return t.length === 0 ? "" : ` {${t.join(",")}}`;
2316
2434
  }
2317
- function U(n, t) {
2435
+ function F(n, t) {
2318
2436
  let e = n;
2319
2437
  const s = {}, r = e.match(/^([a-z][a-z0-9-]*)/);
2320
2438
  if (!r)
2321
2439
  throw new Error(`Invalid node: missing tag name in "${n}"`);
2322
- const i = r[1];
2323
- e = e.slice(i.length);
2324
- const a = [];
2440
+ const a = r[1];
2441
+ e = e.slice(a.length);
2442
+ const i = [];
2325
2443
  let o;
2326
2444
  for (; o = e.match(/^\.([a-zA-Z][a-zA-Z0-9-_]*)/); )
2327
- a.push(o[1]), e = e.slice(o[0].length);
2328
- a.length > 0 && (s.classes = a);
2445
+ i.push(o[1]), e = e.slice(o[0].length);
2446
+ i.length > 0 && (s.classes = i);
2329
2447
  const l = e.match(/^\[([^\]]+)\]/);
2330
2448
  if (l) {
2331
- const u = l[1], f = {}, g = Wt(u);
2332
- for (const d of g) {
2333
- const m = d.match(/^([a-z][a-z0-9-]*)(?:=|~=)"((?:[^"\\]|\\.)*)"/);
2334
- if (m) {
2335
- const [, p, S] = m;
2336
- f[p] = nt(S);
2449
+ const c = l[1], h = {}, g = Jt(c);
2450
+ for (const f of g) {
2451
+ const p = f.match(/^([a-z][a-z0-9-]*)(?:=|~=)"((?:[^"\\]|\\.)*)"/);
2452
+ if (p) {
2453
+ const [, m, b] = p;
2454
+ h[m] = nt(b);
2337
2455
  }
2338
2456
  }
2339
- Object.keys(f).length > 0 && (f.text && (s.text = {
2340
- raw: f.text,
2341
- normalized: f.text
2342
- }, delete f.text), f.id && (s.id = f.id, delete f.id), f.role && (s.role = f.role, delete f.role), Object.keys(f).length > 0 && (s.attributes = f)), e = e.slice(l[0].length);
2343
- }
2344
- let h;
2345
- const c = e.match(/^#(\d+)/);
2346
- if (c && (h = parseInt(c[1], 10), e = e.slice(c[0].length)), e.trim())
2457
+ Object.keys(h).length > 0 && (h.text && (s.text = {
2458
+ raw: h.text,
2459
+ normalized: h.text
2460
+ }, delete h.text), h.id && (s.id = h.id, delete h.id), h.role && (s.role = h.role, delete h.role), Object.keys(h).length > 0 && (s.attributes = h)), e = e.slice(l[0].length);
2461
+ }
2462
+ let u;
2463
+ const d = e.match(/^#(\d+)/);
2464
+ if (d && (u = parseInt(d[1], 10), e = e.slice(d[0].length)), e.trim())
2347
2465
  throw new Error(`Invalid node: unexpected content "${e}" in "${n}"`);
2348
2466
  return t ? {
2349
- tag: i,
2467
+ tag: a,
2350
2468
  semantics: s,
2351
2469
  score: 0.7,
2352
2470
  degraded: !1
2353
2471
  } : {
2354
- tag: i,
2472
+ tag: a,
2355
2473
  semantics: s,
2356
2474
  score: 0.7,
2357
- nthChild: h
2475
+ nthChild: u
2358
2476
  };
2359
2477
  }
2360
- function jt(n) {
2478
+ function Kt(n) {
2361
2479
  if (!n.trim())
2362
2480
  return [];
2363
2481
  const t = [], e = n.split(",").map((s) => s.trim());
2364
2482
  for (const s of e) {
2365
- const [r, i] = s.split("=").map((a) => a.trim());
2483
+ const [r, a] = s.split("=").map((i) => i.trim());
2366
2484
  switch (r) {
2367
2485
  case "unique":
2368
- i === "true" && t.push({
2486
+ a === "true" && t.push({
2369
2487
  type: "uniqueness",
2370
2488
  params: {
2371
2489
  mode: "strict"
@@ -2377,17 +2495,17 @@ function jt(n) {
2377
2495
  t.push({
2378
2496
  type: "position",
2379
2497
  params: {
2380
- strategy: i
2498
+ strategy: a
2381
2499
  },
2382
2500
  priority: 70
2383
2501
  });
2384
2502
  break;
2385
2503
  case "text":
2386
- const a = i.replace(/^"(.*)"$/, "$1");
2504
+ const i = a.replace(/^"(.*)"$/, "$1");
2387
2505
  t.push({
2388
2506
  type: "text-proximity",
2389
2507
  params: {
2390
- reference: nt(a),
2508
+ reference: nt(i),
2391
2509
  maxDistance: 5
2392
2510
  },
2393
2511
  priority: 60
@@ -2397,12 +2515,12 @@ function jt(n) {
2397
2515
  }
2398
2516
  return t;
2399
2517
  }
2400
- function Wt(n) {
2518
+ function Jt(n) {
2401
2519
  const t = [];
2402
2520
  let e = "", s = !1;
2403
2521
  for (let r = 0; r < n.length; r++) {
2404
- const i = n[r];
2405
- i === '"' && (r === 0 || n[r - 1] !== "\\") ? (s = !s, e += i) : i === "," && !s ? (e.trim() && t.push(e.trim()), e = "") : e += i;
2522
+ const a = n[r];
2523
+ a === '"' && (r === 0 || n[r - 1] !== "\\") ? (s = !s, e += a) : a === "," && !s ? (e.trim() && t.push(e.trim()), e = "") : e += a;
2406
2524
  }
2407
2525
  return e.trim() && t.push(e.trim()), t;
2408
2526
  }
@@ -2412,19 +2530,19 @@ function j(n) {
2412
2530
  function nt(n) {
2413
2531
  return n.replace(/\\\\/g, "\0").replace(/\\"/g, '"').replace(/\\>/g, ">").replace(/\\:/g, ":").replace(/\x00/g, "\\");
2414
2532
  }
2415
- function te(n, t, e) {
2533
+ function le(n, t, e) {
2416
2534
  const s = Z(n, t);
2417
- return s ? zt(s, e) : null;
2535
+ return s ? Zt(s, e) : null;
2418
2536
  }
2419
- function ee(n, t, e) {
2537
+ function he(n, t, e) {
2420
2538
  try {
2421
- const s = Ft(n);
2422
- return qt(s, t, e).elements || [];
2539
+ const s = Yt(n);
2540
+ return Bt(s, t, e).elements || [];
2423
2541
  } catch (s) {
2424
2542
  return console.error("Failed to resolve SEQL Selector:", s), [];
2425
2543
  }
2426
2544
  }
2427
- const Bt = /* @__PURE__ */ new Set([
2545
+ const te = /* @__PURE__ */ new Set([
2428
2546
  "script",
2429
2547
  "style",
2430
2548
  "noscript",
@@ -2436,9 +2554,9 @@ const Bt = /* @__PURE__ */ new Set([
2436
2554
  function W(n) {
2437
2555
  return n.id && !D(n.id) ? 3 : n.hasAttribute("role") || n.hasAttribute("aria-label") || n.hasAttribute("aria-labelledby") || n.hasAttribute("data-testid") || n.hasAttribute("data-qa") || n.hasAttribute("data-test") ? 2 : 1;
2438
2556
  }
2439
- function it(n, t) {
2557
+ function at(n, t) {
2440
2558
  const e = n.tagName.toLowerCase();
2441
- return !!(Bt.has(e) || t && W(n) === 1 && ![
2559
+ return !!(te.has(e) || t && W(n) === 1 && ![
2442
2560
  "form",
2443
2561
  "main",
2444
2562
  "nav",
@@ -2454,27 +2572,27 @@ function it(n, t) {
2454
2572
  "textarea"
2455
2573
  ].includes(e));
2456
2574
  }
2457
- function at(n) {
2575
+ function it(n) {
2458
2576
  return [...n].sort((t, e) => {
2459
2577
  const s = W(t);
2460
2578
  return W(e) - s;
2461
2579
  });
2462
2580
  }
2463
- function se(n = {}) {
2581
+ function ue(n = {}) {
2464
2582
  const t = performance.now(), {
2465
2583
  root: e = typeof document < "u" ? document.body : void 0,
2466
2584
  filter: s = "*",
2467
2585
  limit: r = 1 / 0,
2468
- onProgress: i,
2469
- progressInterval: a = 100,
2586
+ onProgress: a,
2587
+ progressInterval: i = 100,
2470
2588
  skipNonSemantic: o = !0,
2471
2589
  generatorOptions: l = {},
2472
- cache: h,
2473
- signal: c
2590
+ cache: u,
2591
+ signal: d
2474
2592
  } = n;
2475
2593
  if (!e)
2476
2594
  throw new Error("Root element or document is required");
2477
- const u = h ?? Q(), f = { ...l, cache: u };
2595
+ const c = u ?? Q(), h = { ...l, cache: c };
2478
2596
  let g;
2479
2597
  try {
2480
2598
  e instanceof Document, g = Array.from(e.querySelectorAll(s));
@@ -2493,148 +2611,148 @@ function se(n = {}) {
2493
2611
  }
2494
2612
  };
2495
2613
  }
2496
- const d = g.filter(
2497
- (E) => !it(E, o)
2498
- ), p = at(d).slice(0, r), S = [], y = [];
2499
- let w = 0;
2500
- const A = p.length;
2501
- let b = 0;
2502
- for (let E = 0; E < p.length && !c?.aborted; E++) {
2503
- const R = p[E], M = u.getEID(R);
2504
- if (M)
2505
- S.push({
2506
- element: R,
2507
- eid: M,
2614
+ const f = g.filter(
2615
+ (x) => !at(x, o)
2616
+ ), m = it(f).slice(0, r), b = [], y = [];
2617
+ let v = 0;
2618
+ const A = m.length;
2619
+ let S = 0;
2620
+ for (let x = 0; x < m.length && !d?.aborted; x++) {
2621
+ const T = m[x], R = c.getEID(T);
2622
+ if (R)
2623
+ b.push({
2624
+ element: T,
2625
+ eid: R,
2508
2626
  generationTimeMs: 0
2509
2627
  // Cached, no generation time
2510
2628
  });
2511
2629
  else {
2512
2630
  const z = performance.now();
2513
2631
  try {
2514
- const H = Z(R, f), ot = performance.now() - z;
2515
- H ? S.push({
2516
- element: R,
2517
- eid: H,
2632
+ const P = Z(T, h), ot = performance.now() - z;
2633
+ P ? b.push({
2634
+ element: T,
2635
+ eid: P,
2518
2636
  generationTimeMs: ot
2519
- }) : w++;
2520
- } catch (H) {
2637
+ }) : v++;
2638
+ } catch (P) {
2521
2639
  y.push({
2522
- element: R,
2523
- error: H instanceof Error ? H.message : String(H)
2640
+ element: T,
2641
+ error: P instanceof Error ? P.message : String(P)
2524
2642
  });
2525
2643
  }
2526
2644
  }
2527
- i && E - b >= a && (i(E + 1, A), b = E);
2645
+ a && x - S >= i && (a(x + 1, A), S = x);
2528
2646
  }
2529
- i && i(A, A);
2530
- const v = performance.now() - t, x = u.getStats(), k = x.eidHits + x.eidMisses + x.selectorHits + x.selectorMisses, C = x.eidHits + x.selectorHits, N = k > 0 ? C / k : 0;
2647
+ a && a(A, A);
2648
+ const $ = performance.now() - t, M = c.getStats(), H = M.eidHits + M.eidMisses + M.selectorHits + M.selectorMisses, E = M.eidHits + M.selectorHits, C = H > 0 ? E / H : 0;
2531
2649
  return {
2532
- results: S,
2650
+ results: b,
2533
2651
  failed: y,
2534
2652
  stats: {
2535
2653
  totalElements: A,
2536
- successful: S.length,
2654
+ successful: b.length,
2537
2655
  failed: y.length,
2538
- skipped: w,
2539
- totalTimeMs: v,
2540
- avgTimePerElementMs: S.length > 0 ? v / S.length : 0,
2541
- cacheHitRate: N
2656
+ skipped: v,
2657
+ totalTimeMs: $,
2658
+ avgTimePerElementMs: b.length > 0 ? $ / b.length : 0,
2659
+ cacheHitRate: C
2542
2660
  }
2543
2661
  };
2544
2662
  }
2545
- function re(n, t = {}) {
2663
+ function de(n, t = {}) {
2546
2664
  const e = performance.now(), {
2547
2665
  limit: s = 1 / 0,
2548
2666
  onProgress: r,
2549
- progressInterval: i = 100,
2550
- skipNonSemantic: a = !0,
2667
+ progressInterval: a = 100,
2668
+ skipNonSemantic: i = !0,
2551
2669
  generatorOptions: o = {},
2552
2670
  cache: l,
2553
- signal: h
2554
- } = t, c = l ?? Q(), u = { ...o, cache: c }, f = n.filter(
2555
- (C) => !it(C, a)
2556
- ), d = at(f).slice(0, s), m = [], p = [];
2557
- let S = 0;
2558
- const y = d.length;
2559
- let w = 0;
2560
- for (let C = 0; C < d.length && !h?.aborted; C++) {
2561
- const N = d[C], E = c.getEID(N);
2562
- if (E)
2563
- m.push({
2564
- element: N,
2565
- eid: E,
2671
+ signal: u
2672
+ } = t, d = l ?? Q(), c = { ...o, cache: d }, h = n.filter(
2673
+ (E) => !at(E, i)
2674
+ ), f = it(h).slice(0, s), p = [], m = [];
2675
+ let b = 0;
2676
+ const y = f.length;
2677
+ let v = 0;
2678
+ for (let E = 0; E < f.length && !u?.aborted; E++) {
2679
+ const C = f[E], x = d.getEID(C);
2680
+ if (x)
2681
+ p.push({
2682
+ element: C,
2683
+ eid: x,
2566
2684
  generationTimeMs: 0
2567
2685
  });
2568
2686
  else {
2569
- const R = performance.now();
2687
+ const T = performance.now();
2570
2688
  try {
2571
- const M = Z(N, u), z = performance.now() - R;
2572
- M ? m.push({
2573
- element: N,
2574
- eid: M,
2689
+ const R = Z(C, c), z = performance.now() - T;
2690
+ R ? p.push({
2691
+ element: C,
2692
+ eid: R,
2575
2693
  generationTimeMs: z
2576
- }) : S++;
2577
- } catch (M) {
2578
- p.push({
2579
- element: N,
2580
- error: M instanceof Error ? M.message : String(M)
2694
+ }) : b++;
2695
+ } catch (R) {
2696
+ m.push({
2697
+ element: C,
2698
+ error: R instanceof Error ? R.message : String(R)
2581
2699
  });
2582
2700
  }
2583
2701
  }
2584
- r && C - w >= i && (r(C + 1, y), w = C);
2702
+ r && E - v >= a && (r(E + 1, y), v = E);
2585
2703
  }
2586
2704
  r && r(y, y);
2587
- const A = performance.now() - e, b = c.getStats(), v = b.eidHits + b.eidMisses + b.selectorHits + b.selectorMisses, x = b.eidHits + b.selectorHits, k = v > 0 ? x / v : 0;
2705
+ const A = performance.now() - e, S = d.getStats(), $ = S.eidHits + S.eidMisses + S.selectorHits + S.selectorMisses, M = S.eidHits + S.selectorHits, H = $ > 0 ? M / $ : 0;
2588
2706
  return {
2589
- results: m,
2590
- failed: p,
2707
+ results: p,
2708
+ failed: m,
2591
2709
  stats: {
2592
2710
  totalElements: y,
2593
- successful: m.length,
2594
- failed: p.length,
2595
- skipped: S,
2711
+ successful: p.length,
2712
+ failed: m.length,
2713
+ skipped: b,
2596
2714
  totalTimeMs: A,
2597
- avgTimePerElementMs: m.length > 0 ? A / m.length : 0,
2598
- cacheHitRate: k
2715
+ avgTimePerElementMs: p.length > 0 ? A / p.length : 0,
2716
+ cacheHitRate: H
2599
2717
  }
2600
2718
  };
2601
2719
  }
2602
2720
  export {
2603
- dt as AnchorFinder,
2604
- Pt as ConstraintsEvaluator,
2721
+ ft as AnchorFinder,
2722
+ jt as ConstraintsEvaluator,
2605
2723
  st as CssGenerator,
2606
2724
  ut as DEFAULT_GENERATOR_OPTIONS,
2607
- ft as DEFAULT_RESOLVER_OPTIONS,
2608
- It as EIDCache,
2609
- Gt as EID_VERSION,
2610
- kt as FallbackHandler,
2611
- Vt as MAX_PATH_DEPTH,
2725
+ dt as DEFAULT_RESOLVER_OPTIONS,
2726
+ Lt as EIDCache,
2727
+ ee as EID_VERSION,
2728
+ Wt as FallbackHandler,
2729
+ se as MAX_PATH_DEPTH,
2612
2730
  xt as PathBuilder,
2613
- K as ROLE_ANCHOR_VALUES,
2731
+ X as ROLE_ANCHOR_VALUES,
2614
2732
  Y as SEMANTIC_ANCHOR_TAGS,
2615
- Qt as SEMANTIC_ATTRIBUTES,
2733
+ re as SEMANTIC_ATTRIBUTES,
2616
2734
  lt as SEMANTIC_TAGS,
2617
- wt as SemanticExtractor,
2618
- Ht as SemanticsMatcher,
2619
- vt as SvgFingerprinter,
2620
- $t as calculateConfidence,
2621
- Yt as calculateElementScore,
2622
- Nt as createEIDCache,
2735
+ Pt as SemanticExtractor,
2736
+ Ft as SemanticsMatcher,
2737
+ _t as SvgFingerprinter,
2738
+ kt as calculateConfidence,
2739
+ ae as calculateElementScore,
2740
+ Ot as createEIDCache,
2623
2741
  At as filterClasses,
2624
2742
  Z as generateEID,
2625
- se as generateEIDBatch,
2626
- re as generateEIDForElements,
2627
- te as generateSEQL,
2628
- Zt as getClassScore,
2743
+ ue as generateEIDBatch,
2744
+ de as generateEIDForElements,
2745
+ le as generateSEQL,
2746
+ ne as getClassScore,
2629
2747
  Q as getGlobalCache,
2630
- Jt as isEID,
2631
- X as isUtilityClass,
2748
+ ce as isEID,
2749
+ K as isUtilityClass,
2632
2750
  V as normalizeText,
2633
- Ft as parseSEQL,
2634
- Kt as resetGlobalCache,
2635
- qt as resolve,
2636
- ee as resolveSEQL,
2637
- zt as stringifySEQL,
2638
- Xt as validateEID
2751
+ Yt as parseSEQL,
2752
+ ie as resetGlobalCache,
2753
+ Bt as resolve,
2754
+ he as resolveSEQL,
2755
+ Zt as stringifySEQL,
2756
+ oe as validateEID
2639
2757
  };
2640
2758
  //# sourceMappingURL=seql-js.js.map