@afterpack/protection-map 0.1.0 → 0.2.0-rc.20260930T1421

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/template.html CHANGED
@@ -32,25 +32,20 @@
32
32
 
33
33
  --wash: #f3f3f3;
34
34
 
35
- --heat-0: #fff3c2;
36
- --heat-1: #ffde85;
37
- --heat-2: #ffc247;
38
- --heat-3: #fa940f;
39
- --heat-4: #e6650f;
40
- --heat-5: #d1381a;
41
- --heat-6: #b62020;
42
-
43
- --cost-0: #f8e3d5;
44
- --cost-1: #eec9ae;
45
- --cost-2: #dda780;
46
- --cost-3: #c48350;
47
- --cost-4: #a45f24;
48
- --cost-5: #7f4406;
49
- --cost-6: #5a2d00;
50
-
51
- --band-safety: #d4d4d4;
52
- --band-reflection: #bdbdbd;
53
- --band-skip: #969696;
35
+ --cx-readable: rgba(82, 82, 82, 0.09);
36
+ --cx-names: rgba(47, 158, 68, 0.13);
37
+ --cx-low: rgba(47, 158, 68, 0.28);
38
+ --cx-mid: rgba(234, 179, 8, 0.38);
39
+ --cx-high: rgba(239, 68, 68, 0.34);
40
+ --cx-max: rgba(153, 27, 27, 0.46);
41
+ --cx-protected: rgba(99, 102, 241, 0.15);
42
+ --cx-readable-solid: #a3a3a3;
43
+ --cx-names-solid: #8fd19e;
44
+ --cx-low-solid: #2f9e44;
45
+ --cx-mid-solid: #e0a800;
46
+ --cx-high-solid: #e03131;
47
+ --cx-max-solid: #8f1d1d;
48
+ --cx-protected-solid: #6366f1;
54
49
 
55
50
  --status-leak: #dc2626;
56
51
  --status-leak-soft: #fee2e2;
@@ -59,17 +54,6 @@
59
54
  --status-weak: #a16207;
60
55
  --status-weak-soft: #fef9c3;
61
56
 
62
- --class-preserved: #525252;
63
- --class-preserved-soft: #e5e5e5;
64
- --class-preserved-wash: rgba(82, 82, 82, 0.09);
65
- --class-renamed: #0d7d88;
66
- --class-renamed-soft: #d6eef0;
67
- --class-flattened: #1d6fa5;
68
- --class-flattened-soft: #dbeafe;
69
- --class-destroyed: #7141b8;
70
- --class-destroyed-soft: #efe3fb;
71
- --class-destroyed-edge: #b57317;
72
-
73
57
  --tok-hover-bg: rgba(181, 115, 23, 0.36);
74
58
  --tok-hover-ring: rgba(160, 106, 18, 0.85);
75
59
  --resizer-hover: rgba(160, 106, 18, 0.55);
@@ -106,24 +90,18 @@
106
90
 
107
91
  --wash: #252526;
108
92
 
109
- --heat-0: #543912; --heat-1: #714514; --heat-2: #8e4e15; --heat-3: #b15416;
110
- --heat-4: #d14b1a; --heat-5: #df3c2a; --heat-6: #df4949;
111
-
112
- --cost-0: #2a1c11; --cost-1: #482b14; --cost-2: #6d411c; --cost-3: #955823;
113
- --cost-4: #bf6f29; --cost-5: #e78b3c; --cost-6: #fca765;
114
-
115
- --band-safety: #2a2a2a; --band-reflection: #333333; --band-skip: #474747;
93
+ --cx-readable: rgba(179, 179, 179, 0.07); --cx-names: rgba(81, 207, 102, 0.11);
94
+ --cx-low: rgba(81, 207, 102, 0.24); --cx-mid: rgba(250, 204, 21, 0.26);
95
+ --cx-high: rgba(248, 81, 73, 0.32); --cx-max: rgba(220, 38, 38, 0.58);
96
+ --cx-protected: rgba(129, 140, 248, 0.22);
97
+ --cx-readable-solid: #6b6b6b; --cx-names-solid: #3f8f50; --cx-low-solid: #51cf66;
98
+ --cx-mid-solid: #fcc419; --cx-high-solid: #ff6b6b; --cx-max-solid: #c92a2a;
99
+ --cx-protected-solid: #818cf8;
116
100
 
117
101
  --status-leak: #f87171; --status-leak-soft: rgba(248, 113, 113, 0.16);
118
102
  --status-property: #fbbf24; --status-property-soft: rgba(251, 191, 36, 0.16);
119
103
  --status-weak: #d0bb5a; --status-weak-soft: rgba(208, 187, 90, 0.15);
120
104
 
121
- --class-preserved: #b3b3b3; --class-preserved-soft: rgba(179, 179, 179, 0.20);
122
- --class-preserved-wash: rgba(179, 179, 179, 0.06);
123
- --class-renamed: #5ed0d0; --class-renamed-soft: rgba(94, 208, 208, 0.20);
124
- --class-flattened: #6db8ea; --class-flattened-soft: rgba(109, 184, 234, 0.20);
125
- --class-destroyed: #c9a3ff; --class-destroyed-soft: rgba(201, 163, 255, 0.20); --class-destroyed-edge: #eaae3d;
126
-
127
105
  --tok-hover-bg: rgba(234, 174, 61, 0.26);
128
106
  --tok-hover-ring: rgba(234, 174, 61, 0.95);
129
107
  --resizer-hover: rgba(234, 174, 61, 0.65);
@@ -143,18 +121,16 @@
143
121
  --surface-hover: #e8e8e8; --scrollbar: #c9c9c9; --border: #e5e5e5; --border-strong: #cecece;
144
122
  --text-primary: #262626; --text-secondary: #616161; --text-muted: #767676;
145
123
  --brand: #a06a12; --brand-hover: #b57317; --brand-ink: #ffffff; --focus-ring: #a06a12; --wash: #f3f3f3;
146
- --heat-0: #fff3c2; --heat-1: #ffde85; --heat-2: #ffc247; --heat-3: #fa940f;
147
- --heat-4: #e6650f; --heat-5: #d1381a; --heat-6: #b62020;
148
- --cost-0: #f8e3d5; --cost-1: #eec9ae; --cost-2: #dda780; --cost-3: #c48350;
149
- --cost-4: #a45f24; --cost-5: #7f4406; --cost-6: #5a2d00;
150
- --band-safety: #d4d4d4; --band-reflection: #bdbdbd; --band-skip: #969696;
124
+ --cx-readable: rgba(82, 82, 82, 0.09); --cx-names: rgba(47, 158, 68, 0.13);
125
+ --cx-low: rgba(47, 158, 68, 0.28); --cx-mid: rgba(234, 179, 8, 0.38);
126
+ --cx-high: rgba(239, 68, 68, 0.34); --cx-max: rgba(153, 27, 27, 0.46);
127
+ --cx-protected: rgba(99, 102, 241, 0.15);
128
+ --cx-readable-solid: #a3a3a3; --cx-names-solid: #8fd19e; --cx-low-solid: #2f9e44;
129
+ --cx-mid-solid: #e0a800; --cx-high-solid: #e03131; --cx-max-solid: #8f1d1d;
130
+ --cx-protected-solid: #6366f1;
151
131
  --status-leak: #dc2626; --status-leak-soft: #fee2e2;
152
132
  --status-property: #b45309; --status-property-soft: #fef3c7;
153
133
  --status-weak: #a16207; --status-weak-soft: #fef9c3;
154
- --class-preserved: #525252; --class-preserved-soft: #e5e5e5; --class-preserved-wash: rgba(82, 82, 82, 0.09);
155
- --class-renamed: #0d7d88; --class-renamed-soft: #d6eef0;
156
- --class-flattened: #1d6fa5; --class-flattened-soft: #dbeafe;
157
- --class-destroyed: #7141b8; --class-destroyed-soft: #efe3fb; --class-destroyed-edge: #b57317;
158
134
  --tok-hover-bg: rgba(181, 115, 23, 0.36); --tok-hover-ring: rgba(160, 106, 18, 0.85);
159
135
  --resizer-hover: rgba(160, 106, 18, 0.55);
160
136
  --logo-plate: #141414; --syn-comment: #008000; --syn-key: #0000ff; --syn-str: #a31515; --syn-num: #046043;
@@ -166,18 +142,16 @@
166
142
  --surface-hover: #2a2d2e; --scrollbar: #4f4f4f; --border: #2b2b2b; --border-strong: #3c3c3c;
167
143
  --text-primary: #cccccc; --text-secondary: #9d9d9d; --text-muted: #8c8c8c;
168
144
  --brand: #eaae3d; --brand-hover: #fcea85; --brand-ink: #0a0a0a; --focus-ring: #eaae3d; --wash: #252526;
169
- --heat-0: #543912; --heat-1: #714514; --heat-2: #8e4e15; --heat-3: #b15416;
170
- --heat-4: #d14b1a; --heat-5: #df3c2a; --heat-6: #df4949;
171
- --cost-0: #2a1c11; --cost-1: #482b14; --cost-2: #6d411c; --cost-3: #955823;
172
- --cost-4: #bf6f29; --cost-5: #e78b3c; --cost-6: #fca765;
173
- --band-safety: #2a2a2a; --band-reflection: #333333; --band-skip: #474747;
145
+ --cx-readable: rgba(179, 179, 179, 0.07); --cx-names: rgba(81, 207, 102, 0.11);
146
+ --cx-low: rgba(81, 207, 102, 0.24); --cx-mid: rgba(250, 204, 21, 0.26);
147
+ --cx-high: rgba(248, 81, 73, 0.32); --cx-max: rgba(220, 38, 38, 0.58);
148
+ --cx-protected: rgba(129, 140, 248, 0.22);
149
+ --cx-readable-solid: #6b6b6b; --cx-names-solid: #3f8f50; --cx-low-solid: #51cf66;
150
+ --cx-mid-solid: #fcc419; --cx-high-solid: #ff6b6b; --cx-max-solid: #c92a2a;
151
+ --cx-protected-solid: #818cf8;
174
152
  --status-leak: #f87171; --status-leak-soft: rgba(248, 113, 113, 0.16);
175
153
  --status-property: #fbbf24; --status-property-soft: rgba(251, 191, 36, 0.16);
176
154
  --status-weak: #d0bb5a; --status-weak-soft: rgba(208, 187, 90, 0.15);
177
- --class-preserved: #b3b3b3; --class-preserved-soft: rgba(179, 179, 179, 0.20); --class-preserved-wash: rgba(179, 179, 179, 0.06);
178
- --class-renamed: #5ed0d0; --class-renamed-soft: rgba(94, 208, 208, 0.20);
179
- --class-flattened: #6db8ea; --class-flattened-soft: rgba(109, 184, 234, 0.20);
180
- --class-destroyed: #c9a3ff; --class-destroyed-soft: rgba(201, 163, 255, 0.20); --class-destroyed-edge: #eaae3d;
181
155
  --tok-hover-bg: rgba(234, 174, 61, 0.26); --tok-hover-ring: rgba(234, 174, 61, 0.95);
182
156
  --resizer-hover: rgba(234, 174, 61, 0.65);
183
157
  --logo-plate: rgba(255, 255, 255, 0.04); --syn-comment: #6a9955; --syn-key: #8fc8ff; --syn-str: #e8b598; --syn-num: #c3dbb4;
@@ -323,7 +297,7 @@ body.is-resizing .pane-resizer::before { transition: none; }
323
297
  @media (max-width: 480px) {
324
298
  .topbar { padding: 8px 10px; }
325
299
  .rail-left, .rail-right { padding: 10px 8px 18px; }
326
- .code-toolbar { padding: 6px 10px; }
300
+ .file-head-row { padding: 8px 10px; }
327
301
  }
328
302
 
329
303
  .topbar {
@@ -347,13 +321,14 @@ body.is-resizing .pane-resizer::before { transition: none; }
347
321
  overflow: hidden;
348
322
  text-overflow: ellipsis;
349
323
  }
350
- .topbar h1 .dot { color: var(--brand); }
351
- .tag-size {
324
+ .tag {
325
+ display: inline-flex;
326
+ align-items: center;
327
+ gap: 5px;
352
328
  font-family: var(--font-mono);
353
- font-size: 10px;
329
+ font-size: 10.5px;
354
330
  font-weight: 700;
355
- letter-spacing: 0.06em;
356
- text-transform: uppercase;
331
+ letter-spacing: 0.03em;
357
332
  color: var(--text-secondary);
358
333
  background: var(--surface-3);
359
334
  border: 1px solid var(--border-strong);
@@ -364,7 +339,16 @@ body.is-resizing .pane-resizer::before { transition: none; }
364
339
  cursor: help;
365
340
  transition: color 0.3s ease, border-color 0.3s ease;
366
341
  }
367
- .tag-size:hover, .tag-size:focus-visible { color: var(--brand); border-color: var(--brand); }
342
+ .tag:hover, .tag:focus-visible { color: var(--brand); border-color: var(--brand); }
343
+ .tag svg { display: block; }
344
+ .tag .tag-em { color: var(--text-primary); }
345
+ .cx-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--cx-protected-solid); }
346
+ .cx-dot[data-band="readable"], .cx-dot[data-band="none"] { background: var(--cx-readable-solid); }
347
+ .cx-dot[data-band="names"] { background: var(--cx-names-solid); }
348
+ .cx-dot[data-band="low"] { background: var(--cx-low-solid); }
349
+ .cx-dot[data-band="mid"] { background: var(--cx-mid-solid); }
350
+ .cx-dot[data-band="high"] { background: var(--cx-high-solid); }
351
+ .cx-dot[data-band="max"] { background: var(--cx-max-solid); }
368
352
  .topbar .spacer { flex: 1 1 auto; min-width: 8px; }
369
353
 
370
354
  .brand-logo {
@@ -606,31 +590,21 @@ body.is-resizing .pane-resizer::before { transition: none; }
606
590
  .badge-weak.has-leak { background: var(--status-leak); }
607
591
  .tree-row-folder .badge-weak { opacity: 0.78; }
608
592
 
609
- .meter { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
610
- .meter > i { display: block; height: 100%; border-radius: 3px 0 0 3px; }
611
- .meter-lg { height: 7px; border-radius: 4px; }
612
-
613
- .class-dist-bar { display: flex; height: 10px; border-radius: 4px; overflow: hidden; background: var(--surface-3); margin-bottom: 8px; }
614
- .class-dist-bar i { display: block; height: 100%; }
615
- .class-dist-bar i[data-class="preserved"] { background: var(--class-preserved); }
616
- .class-dist-bar i[data-class="renamed-encoded"] { background: var(--class-renamed); }
617
- .class-dist-bar i[data-class="flattened-fused"] { background: var(--class-flattened); }
618
- .class-dist-bar i[data-class="destroyed-fused"] { background: var(--class-destroyed); }
619
- .class-dist-rows { display: flex; flex-direction: column; gap: 4px; margin-bottom: 2px; }
620
- .class-dist-row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
621
- .class-dist-count { margin-left: auto; font-family: var(--font-mono); font-weight: 700; color: var(--text-secondary); }
622
- .class-reached-line { font-size: 11px; color: var(--text-secondary); margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
623
- .class-dist-footnote { font-size: 10px; color: var(--text-muted); margin-top: 6px; font-style: italic; }
624
-
625
- .class-legend-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 11px; }
626
- .class-legend-flag {
627
- flex: 0 0 auto;
628
- font-family: var(--font-mono);
629
- font-size: 9px;
630
- text-transform: uppercase;
631
- letter-spacing: 0.05em;
632
- color: var(--text-muted);
633
- }
593
+ .meter { position: relative; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
594
+ .meter > i { display: block; height: 100%; border-radius: 3px 0 0 3px; background: var(--cx-protected-solid); }
595
+ .meter > i[data-band="readable"], .meter > i[data-band="none"] { background: var(--cx-readable-solid); }
596
+ .meter > i[data-band="names"] { background: var(--cx-names-solid); }
597
+ .meter > i[data-band="low"] { background: var(--cx-low-solid); }
598
+ .meter > i[data-band="mid"] { background: var(--cx-mid-solid); }
599
+ .meter > i[data-band="high"] { background: var(--cx-high-solid); }
600
+ .meter > i[data-band="max"] { background: var(--cx-max-solid); }
601
+ .meter-lg { height: 7px; border-radius: 4px; overflow: visible; }
602
+ .meter-lg > i { border-radius: 4px; }
603
+ .meter-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text-primary); }
604
+
605
+ .class-rows { display: flex; flex-direction: column; gap: 4px; }
606
+ .class-row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
607
+ .class-row-count { margin-left: auto; font-family: var(--font-mono); font-weight: 700; color: var(--text-secondary); }
634
608
 
635
609
  .class-chip {
636
610
  display: inline-flex;
@@ -641,37 +615,24 @@ body.is-resizing .pane-resizer::before { transition: none; }
641
615
  font-weight: 700;
642
616
  padding: 3px 8px;
643
617
  border-radius: 999px;
644
- border: 1px solid transparent;
618
+ border: 1px solid var(--border-strong);
619
+ color: var(--text-secondary);
620
+ background: var(--surface-2);
645
621
  flex-shrink: 0;
646
622
  white-space: nowrap;
647
623
  }
648
- .class-chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
649
- .class-chip[data-class="preserved"] { color: var(--class-preserved); background: var(--class-preserved-soft); }
650
- .class-chip[data-class="preserved"] .dot { background: var(--class-preserved); }
651
- .class-chip[data-class="renamed-encoded"] { color: var(--class-renamed); background: var(--class-renamed-soft); }
652
- .class-chip[data-class="renamed-encoded"] .dot { background: var(--class-renamed); }
653
- .class-chip[data-class="flattened-fused"] { color: var(--class-flattened); background: var(--class-flattened-soft); }
654
- .class-chip[data-class="flattened-fused"] .dot { background: var(--class-flattened); }
655
- .class-chip[data-class="destroyed-fused"] { color: var(--class-destroyed); background: var(--class-destroyed-soft); border-color: var(--class-destroyed-edge); }
656
- .class-chip[data-class="destroyed-fused"] .dot { background: var(--class-destroyed); }
657
- .class-chip.is-ghost { opacity: 0.6; background: transparent; border-style: dashed; border-color: currentColor; }
658
-
659
- .tier-pill {
660
- font-family: var(--font-mono);
661
- font-size: 9.5px;
662
- font-weight: 700;
663
- text-transform: uppercase;
664
- letter-spacing: 0.04em;
665
- border-radius: 4px;
666
- padding: 2px 6px;
667
- border: 1px solid;
668
- flex-shrink: 0;
669
- }
670
- .tier-pill.tier-free { color: var(--text-secondary); border-color: var(--border-strong); background: var(--surface-2); }
671
- .tier-pill.tier-pro { color: var(--class-destroyed); border-color: var(--class-destroyed); background: var(--class-destroyed-soft); }
624
+ .class-chip.is-ghost { opacity: 0.75; background: transparent; border-style: dashed; }
625
+
626
+ .cx-legend { display: flex; flex-direction: column; gap: 3px; }
627
+ .cx-legend-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-secondary); }
628
+ .cx-swatch { flex: 0 0 auto; width: 34px; text-align: center; font-family: var(--font-mono); font-size: 10.5px; border-radius: 3px; color: var(--text-primary); padding: 0 2px; }
629
+ .cx-legend-note { font-size: 11px; line-height: 1.45; color: var(--text-secondary); margin-top: 8px; }
630
+ .cx-legend-note + .cx-legend-note { margin-top: 4px; }
672
631
 
673
- .legend-bar { height: 10px; border-radius: 3px; border: 1px solid var(--border); }
674
- .legend-labels { display: flex; justify-content: space-between; margin-top: 5px; font-size: 10.5px; font-family: var(--font-mono); color: var(--text-muted); }
632
+ .doc-link { font-family: var(--font-ui); font-size: 10.5px; font-weight: 600; text-decoration: none; white-space: nowrap; letter-spacing: 0; text-transform: none; }
633
+ .doc-link:hover { text-decoration: underline; }
634
+ .popover-section > .popover-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
635
+ .popover-section > .popover-head > .eyebrow { flex: 1 1 auto; }
675
636
 
676
637
  .engine-info {
677
638
  font-family: var(--font-mono);
@@ -682,6 +643,7 @@ body.is-resizing .pane-resizer::before { transition: none; }
682
643
  gap: 3px 8px;
683
644
  }
684
645
  .engine-info dt { text-align: left; }
646
+ .engine-info dt[data-tip] { cursor: help; text-decoration: underline dotted var(--border-strong); text-underline-offset: 3px; }
685
647
  .engine-info dd { margin: 0; text-align: right; color: var(--text-secondary); overflow-wrap: anywhere; }
686
648
 
687
649
  .pane-center { grid-area: center; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--ground); }
@@ -700,7 +662,7 @@ body.is-resizing .pane-resizer::before { transition: none; }
700
662
  backdrop-filter: blur(14px);
701
663
  -webkit-backdrop-filter: blur(14px);
702
664
  }
703
- .file-head-row { display: flex; align-items: center; gap: 8px; padding: 9px 14px 5px; min-width: 0; }
665
+ .file-head-row { display: flex; align-items: center; gap: 8px; padding: 9px 14px; min-width: 0; }
704
666
  .file-head-spacer { flex: 1 1 auto; min-width: 10px; }
705
667
  .file-summary-path { display: flex; align-items: baseline; gap: 1px; min-width: 0; font-family: var(--font-mono); font-size: 12.5px; }
706
668
  .file-summary-path .fs-dir {
@@ -713,7 +675,8 @@ body.is-resizing .pane-resizer::before { transition: none; }
713
675
  min-width: 0;
714
676
  }
715
677
  .file-summary-path .fs-name { color: var(--text-primary); font-weight: 700; flex-shrink: 0; }
716
- #source-origin-note { flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; cursor: help; }
678
+ #head-note { flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; cursor: help; }
679
+ #head-note[hidden], #syntax-label[hidden] { display: none; }
717
680
  .icon-btn {
718
681
  flex: 0 0 auto;
719
682
  display: inline-flex;
@@ -733,31 +696,8 @@ body.is-resizing .pane-resizer::before { transition: none; }
733
696
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
734
697
  }
735
698
  .icon-btn:hover { background: var(--surface-hover); color: var(--brand); border-color: var(--brand); }
736
- .code-toolbar {
737
- display: flex;
738
- align-items: center;
739
- gap: 12px;
740
- padding: 0 14px 8px;
741
- font-family: var(--font-mono);
742
- font-size: 11px;
743
- color: var(--text-muted);
744
- min-width: 0;
745
- }
746
- .code-toolbar .toolbar-spacer { flex: 1 1 auto; min-width: 8px; }
747
699
  .toggle-inline { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); cursor: pointer; white-space: nowrap; flex: 0 0 auto; }
748
700
  .toggle-inline input[type="checkbox"] { accent-color: var(--brand); width: 13px; height: 13px; margin: 0; }
749
- .toggle-inline:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
750
- #highlight-class-status {
751
- flex: 0 0 auto;
752
- display: inline-block;
753
- min-width: 12ch;
754
- color: var(--brand);
755
- white-space: nowrap;
756
- overflow: hidden;
757
- text-overflow: ellipsis;
758
- visibility: hidden;
759
- }
760
- #highlight-class-status.is-on { visibility: visible; }
761
701
 
762
702
  .code-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 0 40px; }
763
703
  .code-line { display: flex; min-width: max-content; white-space: pre; }
@@ -791,13 +731,23 @@ body.is-resizing .pane-resizer::before { transition: none; }
791
731
  filter: brightness(1.06);
792
732
  }
793
733
  .tok.is-selected { outline: 2px solid var(--brand); outline-offset: 1px; }
734
+ .tok.tok-named { text-decoration: underline dotted; text-decoration-color: var(--text-secondary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
794
735
  .tok.spot-leak { text-decoration: underline; text-decoration-color: var(--status-leak); text-decoration-thickness: 2px; text-underline-offset: 2px; }
795
736
  .tok.spot-propertyName { text-decoration: underline; text-decoration-color: var(--status-property); text-decoration-thickness: 2px; text-underline-offset: 2px; }
796
737
  .tok.spot-weak { text-decoration: underline dashed; text-decoration-color: var(--status-weak); text-decoration-thickness: 2px; text-underline-offset: 2px; }
797
738
  .tok.tok-preserved {
798
- background-color: var(--class-preserved-wash);
739
+ background-color: var(--cx-readable);
799
740
  color: var(--text-secondary);
800
741
  }
742
+ .tok.cx-none { background-color: var(--cx-readable); }
743
+ .tok.cx-names { background-color: var(--cx-names); }
744
+ .tok.cx-low { background-color: var(--cx-low); }
745
+ .tok.cx-mid { background-color: var(--cx-mid); }
746
+ .tok.cx-high { background-color: var(--cx-high); }
747
+ .tok.cx-max { background-color: var(--cx-max); }
748
+ .tok.cx-protected { background-color: var(--cx-protected); }
749
+ .lc .tok.cx-max i { color: inherit; }
750
+ .cx-swatch.tok-unlit { background: var(--wash); }
801
751
  .pin {
802
752
  display: inline-block;
803
753
  width: 11px;
@@ -814,7 +764,6 @@ body.is-resizing .pane-resizer::before { transition: none; }
814
764
  .lc i { font-style: normal; }
815
765
  .lc i.sy-c, .lc .tok.sy-c { color: var(--syn-comment); font-style: italic; }
816
766
  .lc .tok-hot i.sy-c { color: inherit; }
817
- .lc .tok-ink-yield i { color: inherit; }
818
767
  .lc i.sy-k, .lc .tok.sy-k { color: var(--syn-key); }
819
768
  .lc i.sy-s, .lc .tok.sy-s { color: var(--syn-str); }
820
769
  .lc i.sy-n, .lc .tok.sy-n { color: var(--syn-num); }
@@ -859,18 +808,6 @@ body.is-resizing .pane-resizer::before { transition: none; }
859
808
  .directive-legend-row .swatch { flex: 0 0 auto; font-family: var(--font-mono); font-size: 10px; }
860
809
  .directive-legend-row code { font-family: var(--font-mono); color: var(--text-secondary); }
861
810
 
862
- .code-body[data-highlight-class] .tok[data-class]:not([data-class="preserved"]):not([data-class="renamed-encoded"]):not([data-class="flattened-fused"]):not([data-class="destroyed-fused"]) { opacity: 1; }
863
- .code-body[data-highlight-class="preserved"] .tok[data-class]:not([data-class="preserved"]),
864
- .code-body[data-highlight-class="renamed-encoded"] .tok[data-class]:not([data-class="renamed-encoded"]),
865
- .code-body[data-highlight-class="flattened-fused"] .tok[data-class]:not([data-class="flattened-fused"]),
866
- .code-body[data-highlight-class="destroyed-fused"] .tok[data-class]:not([data-class="destroyed-fused"]) {
867
- opacity: 0.28;
868
- }
869
- .code-body[data-highlight-class="preserved"] .tok[data-class="preserved"] { box-shadow: 0 0 0 1px var(--class-preserved) inset; }
870
- .code-body[data-highlight-class="renamed-encoded"] .tok[data-class="renamed-encoded"] { box-shadow: 0 0 0 1px var(--class-renamed) inset; }
871
- .code-body[data-highlight-class="flattened-fused"] .tok[data-class="flattened-fused"] { box-shadow: 0 0 0 1px var(--class-flattened) inset; }
872
- .code-body[data-highlight-class="destroyed-fused"] .tok[data-class="destroyed-fused"] { box-shadow: 0 0 0 1px var(--class-destroyed) inset; }
873
-
874
811
  .tooltip {
875
812
  position: fixed;
876
813
  z-index: 60;
@@ -889,6 +826,9 @@ body.is-resizing .pane-resizer::before { transition: none; }
889
826
  transition: opacity 0.12s ease;
890
827
  }
891
828
  .tooltip[data-show] { opacity: 1; }
829
+ .tooltip.has-link[data-show] { pointer-events: auto; }
830
+ .tip-link { display: inline-block; margin-top: 5px; font-weight: 600; text-decoration: none; }
831
+ .tip-link:hover { text-decoration: underline; }
892
832
  .info-dot {
893
833
  display: inline-flex;
894
834
  align-items: center;
@@ -939,11 +879,8 @@ body.is-resizing .pane-resizer::before { transition: none; }
939
879
  .weakspot-summary:hover { background: var(--surface-hover); }
940
880
  .weakspot-sev { flex: 0 0 auto; padding: 1px 5px; font-size: 10px; }
941
881
  .weakspot-sample { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-primary); overflow-wrap: anywhere; white-space: pre-wrap; }
942
- .weakspot-tail { flex: 0 0 auto; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); white-space: nowrap; }
943
882
  .weakspot-body { padding: 8px 10px 10px; border-top: 1px dashed var(--border); }
944
883
  .weakspot-reason { font-size: 11px; color: var(--text-secondary); margin: 0 0 6px; }
945
- .weakspot-kv { font-size: 10.5px; color: var(--text-muted); font-family: var(--font-mono); margin: 0 0 8px; overflow-wrap: anywhere; }
946
- .empty-note { font-size: 11.5px; color: var(--text-muted); font-style: italic; }
947
884
  .empty-note-ok { font-size: 11.5px; color: var(--text-muted); font-style: normal; margin: 0; }
948
885
  .empty-note-ok .ok-check { color: var(--brand); font-weight: 700; margin-right: 4px; }
949
886
 
@@ -1022,24 +959,13 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1022
959
  .pill-propertyName { background: var(--status-property-soft); color: var(--status-property); }
1023
960
  .pill-weak { background: var(--status-weak-soft); color: var(--status-weak); }
1024
961
 
1025
- .inspector-section {
1026
- background: var(--surface-1);
1027
- border: 1px solid var(--border);
1028
- border-radius: var(--radius-card);
1029
- padding: 10px 12px;
1030
- margin-bottom: 12px;
1031
- transition: border-color 0.3s ease, box-shadow 0.3s ease;
1032
- }
1033
- .inspector-section:last-child { margin-bottom: 0; }
1034
- .inspector-section h3 { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
1035
962
  .inspector-empty { font-size: 12px; color: var(--text-muted); }
1036
963
 
1037
964
  .insp { display: flex; flex-direction: column; gap: 8px; }
1038
- .insp-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 9px 11px; }
1039
- .insp-ident { display: flex; align-items: center; gap: 6px; height: 22px; min-width: 0; }
1040
- .insp-ident .class-chip, .insp-ident .tier-pill { min-width: 0; overflow: hidden; }
1041
- .insp-ident .class-chip { flex: 0 1 auto; }
1042
- .insp-flags { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: 0 0 auto; }
965
+ .insp-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 10px 11px; }
966
+ .insp-ident { display: flex; align-items: center; gap: 6px; min-height: 24px; min-width: 0; }
967
+ .insp-ident .class-chip { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
968
+ .insp-flags { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
1043
969
  .insp-flag {
1044
970
  display: inline-flex;
1045
971
  align-items: center;
@@ -1055,43 +981,34 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1055
981
  line-height: 1;
1056
982
  cursor: help;
1057
983
  }
1058
- .insp-flag[data-kind="warn"] { color: var(--status-property); border-color: var(--status-property); background: var(--status-property-soft); }
1059
984
  .insp-flag[data-kind="leak"] { color: var(--status-leak); border-color: var(--status-leak); background: var(--status-leak-soft); }
1060
985
  .insp-flag[data-kind="dir"] { color: var(--brand); border-color: var(--brand); }
1061
- .insp-flag[data-kind="info"] { color: var(--text-muted); border-color: var(--border-strong); }
1062
- .insp-score { flex: 0 0 auto; font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--text-primary); }
1063
- .insp-score small { font-size: 10px; font-weight: 700; color: var(--text-muted); }
1064
- .insp-meter { margin: 7px 0 7px; }
1065
- .insp-meter.is-blank { visibility: hidden; }
1066
- .insp-where { height: 16px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
986
+ .insp-score { margin-left: auto; flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 5px; font-family: var(--font-mono); cursor: help; }
987
+ .insp-score b { font-size: 20px; line-height: 1; font-weight: 700; color: var(--text-primary); }
988
+ .insp-score small { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
989
+ .insp-meter { margin: 9px 0 4px; }
990
+ .insp-line { font-size: 11.5px; line-height: 1.45; color: var(--text-secondary); margin-top: 8px; }
1067
991
  .insp-facts { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
1068
- .insp-fact { display: flex; align-items: center; gap: 10px; height: 19px; }
992
+ .insp-fact { display: flex; align-items: center; gap: 10px; min-height: 19px; }
1069
993
  .insp-fact > .k { flex: 0 0 auto; font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; }
1070
994
  .insp-fact[data-tip] > .k { border-bottom: 1px dotted var(--border-strong); cursor: help; }
1071
995
  .insp-fact > .v { flex: 1 1 auto; min-width: 0; text-align: right; font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1072
996
  .insp-fact > .v.is-dim { color: var(--text-muted); font-weight: 400; }
1073
- .insp-fact > .v.is-warn { color: var(--status-leak); }
1074
997
  .insp-fact .class-chip { font-size: 9.5px; padding: 1px 6px; vertical-align: middle; }
1075
- .insp-fact.is-pad { visibility: hidden; }
1076
- .insp-actions { display: flex; align-items: center; gap: 6px; height: 27px; overflow: hidden; margin-top: 8px; }
998
+ .insp-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 11px; }
1077
999
  .insp-chain { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 7px 11px; }
1078
- .insp-chain > summary { height: 18px; }
1079
1000
  .insp-chain[open] > .details-summary { margin-bottom: 8px; }
1080
- .insp-chain .chain-step:last-of-type .chain-body { padding-bottom: 0; }
1081
- .insp-note { font-size: 11px; color: var(--text-secondary); }
1082
- .insp-title { font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
1083
- .insp-hint { font-size: 11px; color: var(--text-muted); font-style: italic; }
1084
- .insp-chain .inspector-section { background: transparent; border: 0; border-radius: 0; padding: 0; margin: 0; }
1085
- .insp-chain .inspector-section > h3 { display: none; }
1001
+ .insp-note { font-size: 11px; line-height: 1.45; color: var(--text-secondary); margin: 0; }
1086
1002
 
1087
1003
  .file-band { display: flex; flex-direction: column; gap: 2px; }
1088
1004
  .fb-row { display: flex; align-items: center; gap: 10px; height: 19px; }
1089
1005
  .fb-row > .k { flex: 0 0 auto; font-size: 11.5px; color: var(--text-secondary); border-bottom: 1px dotted var(--border-strong); cursor: help; }
1090
- .fb-row > .v { flex: 1 1 auto; min-width: 0; text-align: right; font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1006
+ .fb-row > .v { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 6px; text-align: right; font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1007
+ .fb-row > .v.is-dim { color: var(--text-muted); font-weight: 400; }
1091
1008
  .fb-row > .v.is-warn { color: var(--status-leak); }
1092
- .fb-row .class-chip { font-size: 9.5px; padding: 1px 6px; }
1093
1009
  .file-band-section { margin-bottom: 12px; }
1094
-
1010
+ .file-band-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
1011
+ .file-band-head > .eyebrow { flex: 1 1 auto; }
1095
1012
 
1096
1013
  .chain { display: flex; flex-direction: column; }
1097
1014
  .chain-step { display: flex; gap: 10px; }
@@ -1101,11 +1018,13 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1101
1018
  .chain-step:last-of-type .chain-line { display: none; }
1102
1019
  .chain-body { flex: 1 1 auto; min-width: 0; padding-bottom: 10px; }
1103
1020
  .chain-step:last-of-type .chain-body { padding-bottom: 0; }
1104
- .chain-head { display: flex; align-items: baseline; gap: 6px; }
1105
- .chain-transform { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--text-primary); overflow-wrap: anywhere; }
1106
- .chain-count { color: var(--brand); font-weight: 700; font-family: var(--font-mono); font-size: 11px; }
1107
- .chain-delta { margin-left: auto; color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
1108
- .chain-caption { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); letter-spacing: 0.02em; margin-top: 1px; }
1021
+ .chain-head { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
1022
+ .chain-transform { flex: 0 1 auto; min-width: 0; font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--text-primary); overflow-wrap: break-word; }
1023
+ .chain-count { flex: 0 0 auto; color: var(--brand); font-weight: 700; font-family: var(--font-mono); font-size: 11px; cursor: help; }
1024
+ .chain-delta { flex: 0 0 auto; margin-left: auto; padding-left: 6px; color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
1025
+ .chain-caption { font-size: 11px; line-height: 1.4; color: var(--text-muted); margin-top: 2px; }
1026
+ .chain-caption [data-tip] { cursor: help; }
1027
+ .chain-credit { color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
1109
1028
  .chain-more { margin-top: 6px; font-size: 10.5px; color: var(--text-muted); font-style: italic; padding-left: 22px; }
1110
1029
  .chip {
1111
1030
  font-family: var(--font-mono);
@@ -1121,10 +1040,6 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1121
1040
  }
1122
1041
 
1123
1042
 
1124
- .copy-btn-pro { border-color: var(--brand); color: var(--brand); }
1125
- .copy-btn-pro:hover { background: var(--surface-2); }
1126
-
1127
-
1128
1043
  @media (max-width: 980px) { .app-shell { overflow: visible; } }
1129
1044
 
1130
1045
  ::selection { background: rgba(234, 174, 61, 0.3); color: #0a0a0a; }
@@ -1157,7 +1072,8 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1157
1072
  </button>
1158
1073
  </div>
1159
1074
  <h1>Protection Map</h1>
1160
- <span class="tag-size" id="map-size" tabindex="0" role="note" data-tip="Measuring…">— </span>
1075
+ <span class="tag" id="build-cx" tabindex="0" role="note" hidden></span>
1076
+ <span class="tag" id="private-tag" tabindex="0" role="note" data-doc="mapLives"><svg width="10" height="11" viewBox="0 0 10 11" fill="none" aria-hidden="true" focusable="false"><rect x="1" y="4.6" width="8" height="5.6" rx="1.2" stroke="currentColor" stroke-width="1.2"/><path d="M3 4.6V3.2a2 2 0 0 1 4 0v1.4" stroke="currentColor" stroke-width="1.2"/></svg>Private</span>
1161
1077
  <div class="spacer"></div>
1162
1078
  <button type="button" class="top-btn" id="legend-toggle" aria-expanded="false" aria-controls="build-popover"><span class="top-btn-glyph" aria-hidden="true">ⓘ</span> Legend &amp; build</button>
1163
1079
  <button type="button" class="theme-toggle" id="theme-toggle" aria-label="Toggle color theme">🌙 Dark</button>
@@ -1225,11 +1141,11 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1225
1141
  </div>
1226
1142
  <input type="search" class="tree-search" id="tree-search" placeholder="Filter by path…" aria-label="Filter files by path" autocomplete="off" spellcheck="false" />
1227
1143
  <div class="segmented segmented-tight" id="file-filter" role="group" aria-label="Filter files by origin" style="margin:6px 0">
1228
- <button type="button" id="filter-all" data-filter="all" aria-pressed="true">All</button>
1229
- <button type="button" id="filter-app" data-filter="app" aria-pressed="false">App</button>
1230
- <button type="button" id="filter-vendor" data-filter="vendor" aria-pressed="false">Vendor</button>
1231
- <button type="button" id="filter-weak" data-filter="weak" aria-pressed="false" data-tip="Only the files that carry a WEAK SPOT — a readable literal that survived this build (severity “leak”) or a residual property name. Same count the dashboard’s “Weak spots” tile sums, per file. Deep-linkable as #filter=weak.">Weak</button>
1232
- <button type="button" id="filter-marked" data-filter="marked" aria-pressed="false" data-tip="Only the files where this build RECORDED an @afterpack marker over a span. The map records that a marker was found at those coordinates; whether it changed the outcome is not recorded. Empty on Free, where no marker is recorded. Deep-linkable as #filter=marked.">Marked</button>
1144
+ <button type="button" id="filter-all" data-filter="all" aria-pressed="true" data-tip="Every file in this build.">All</button>
1145
+ <button type="button" id="filter-app" data-filter="app" aria-pressed="false" data-tip="Your own code.">App</button>
1146
+ <button type="button" id="filter-vendor" data-filter="vendor" aria-pressed="false" data-tip="Third-party packages (node_modules)." data-doc="thirdParty">Vendor</button>
1147
+ <button type="button" id="filter-weak" data-filter="weak" aria-pressed="false" data-tip="Only files with a weak spot: text still readable in your output." data-doc="lightDefault">Weak</button>
1148
+ <button type="button" id="filter-marked" data-filter="marked" aria-pressed="false" data-tip="Only files with an @afterpack directive." data-doc="directives">Marked</button>
1233
1149
  </div>
1234
1150
  <p class="tree-note" id="deeplink-note" hidden></p>
1235
1151
  <div class="tree" id="file-tree" role="group" aria-label="File tree"></div>
@@ -1238,40 +1154,35 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1238
1154
  <div class="pane-resizer" id="resize-left" role="separator" aria-orientation="vertical" tabindex="0"
1239
1155
  aria-controls="rail-left" aria-valuemin="180" aria-valuenow="262"
1240
1156
  aria-label="File tree width — arrow keys resize"
1241
- title="Drag to resize the file tree (arrow keys also work; hold Shift for a bigger step)"></div>
1157
+ title="Drag to resize (arrow keys work too)"></div>
1242
1158
 
1243
- <main class="pane-center" aria-label="Original source, painted by protection intensity">
1159
+ <main class="pane-center" aria-label="Your source, colored by complexity">
1244
1160
  <div class="file-summary" id="file-summary">
1245
1161
  <div class="file-head-row">
1246
1162
  <div class="file-summary-path" id="file-summary-path"></div>
1247
- <button type="button" class="icon-btn" id="copy-path" data-copy="" data-copied-label="✓" aria-label="Copy the full file path" data-tip="Copy this file's full path">⧉</button>
1163
+ <button type="button" class="icon-btn" id="copy-path" data-copy="" data-copied-label="✓" aria-label="Copy path" data-tip="Copy path">⧉</button>
1248
1164
  <span class="file-head-spacer"></span>
1249
- <span id="source-origin-note" class="mono" tabindex="0">—</span>
1250
- </div>
1251
- <div class="code-toolbar" id="code-toolbar">
1252
- <label class="toggle-inline" id="syntax-label" data-tip="Colour the source by its own grammar (comments, keywords, strings, numbers). Foreground only — every background in this pane belongs to the protection overlay.">
1165
+ <span id="head-note" class="mono" tabindex="0" hidden></span>
1166
+ <label class="toggle-inline" id="syntax-label" data-tip="Color keywords, strings and comments. Backgrounds always show protection.">
1253
1167
  <input type="checkbox" id="syntax-toggle" checked />
1254
1168
  <span id="syntax-toggle-text">Syntax</span>
1255
1169
  </label>
1256
- <label class="toggle-inline" id="highlight-class-label" data-tip="Dim every painted token whose region is a DIFFERENT reversal class than the one you have selected, and ring the ones that match. Needs a region selected; engine scaffolding and un-attributed gaps are left alone either way.">
1257
- <input type="checkbox" id="highlight-class-toggle" disabled />
1258
- Highlight same class
1259
- </label>
1260
- <span id="highlight-class-status" aria-live="polite"></span>
1261
- <span class="toolbar-spacer"></span>
1262
1170
  </div>
1263
1171
  </div>
1264
- <div class="code-body" id="code-body" tabindex="0" role="group" aria-label="Painted source code"></div>
1172
+ <div class="code-body" id="code-body" tabindex="0" role="group" aria-label="Source code"></div>
1265
1173
  </main>
1266
1174
 
1267
1175
  <div class="pane-resizer" id="resize-right" role="separator" aria-orientation="vertical" tabindex="0"
1268
1176
  aria-controls="rail-right" aria-valuemin="180" aria-valuenow="340"
1269
1177
  aria-label="Inspector width — arrow keys resize"
1270
- title="Drag to resize the inspector (arrow keys also work; hold Shift for a bigger step)"></div>
1178
+ title="Drag to resize (arrow keys work too)"></div>
1271
1179
  <aside class="rail-right" id="rail-right" aria-label="Inspector and weak spots">
1272
1180
  <div class="rail-right-pin">
1273
1181
  <div class="rail-section file-band-section">
1274
- <span class="eyebrow">This file</span>
1182
+ <div class="file-band-head">
1183
+ <span class="eyebrow">This file</span>
1184
+ <a class="doc-link" data-doc-link="readMap" target="_blank" rel="noopener noreferrer">How to read this ↗</a>
1185
+ </div>
1275
1186
  <div class="file-band" id="file-summary-metrics"></div>
1276
1187
  </div>
1277
1188
  <div class="rail-section rail-collapsible is-collapsed" id="inspector-section">
@@ -1290,7 +1201,7 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1290
1201
  <button type="button" class="rail-section-head" id="weakspots-head" aria-expanded="false" aria-controls="weakspots-list">
1291
1202
  <span class="eyebrow" id="weakspots-title">Weak spots</span>
1292
1203
  </button>
1293
- <span class="info-dot" id="weakspots-info" tabindex="0" role="img" aria-label="About these figures" data-tip="Sizes are the engine's estimate of added output bytes, not a byte-exact count. Decode-ops / call-frames are a per-site static op count — not amortized over loops or repeated calls.">i</span>
1204
+ <span class="info-dot" id="weakspots-info" tabindex="0" role="img" aria-label="About weak spots" data-tip="Text from your source that is still readable in your output. Strings are worth fixing; property names usually have to stay." data-doc="lightDefault">i</span>
1294
1205
  </div>
1295
1206
  <div id="weakspots-list" style="margin-top:8px"></div>
1296
1207
  </div>
@@ -1301,27 +1212,32 @@ details[open] > .details-summary::before { transform: rotate(90deg); }
1301
1212
 
1302
1213
  <div class="popover" id="build-popover" role="dialog" aria-label="Legend and build info" hidden>
1303
1214
  <div class="popover-section">
1304
- <span class="eyebrow">Class distribution · selected file</span>
1305
- <div class="class-dist-bar" id="class-dist-bar"></div>
1306
- <ul class="class-dist-rows" id="class-dist-rows"></ul>
1307
- <div class="class-reached-line" id="class-reached"></div>
1308
- <div class="class-dist-footnote" id="class-dist-footnote" hidden></div>
1215
+ <div class="popover-head">
1216
+ <span class="eyebrow">Colors</span>
1217
+ <a class="doc-link" data-doc-link="complexity" target="_blank" rel="noopener noreferrer">Complexity ↗</a>
1218
+ </div>
1219
+ <div class="cx-legend" id="cx-legend"></div>
1220
+ <p class="cx-legend-note" id="cx-legend-note"></p>
1309
1221
  </div>
1310
1222
  <div class="popover-section">
1311
- <span class="eyebrow">Reversal classes</span>
1312
- <ul id="class-legend"></ul>
1223
+ <div class="popover-head">
1224
+ <span class="eyebrow">Protection types · this file</span>
1225
+ <a class="doc-link" data-doc-link="classes" target="_blank" rel="noopener noreferrer">Classes ↗</a>
1226
+ </div>
1227
+ <ul class="class-rows" id="class-rows"></ul>
1313
1228
  </div>
1314
1229
  <div class="popover-section" id="directive-legend-section" hidden>
1315
- <span class="eyebrow">Directive markers</span>
1230
+ <div class="popover-head">
1231
+ <span class="eyebrow">Directives</span>
1232
+ <a class="doc-link" data-doc-link="directives" target="_blank" rel="noopener noreferrer">Directives ↗</a>
1233
+ </div>
1316
1234
  <div id="directive-legend"></div>
1317
1235
  </div>
1318
1236
  <div class="popover-section">
1319
- <span class="eyebrow" id="legend-title">Scale · Protection (per file)</span>
1320
- <div class="legend-bar" id="legend-bar"></div>
1321
- <div class="legend-labels" id="legend-labels"><span>low in file</span><span>high in file</span></div>
1322
- </div>
1323
- <div class="popover-section">
1324
- <span class="eyebrow">Engine</span>
1237
+ <div class="popover-head">
1238
+ <span class="eyebrow">Build</span>
1239
+ <a class="doc-link" data-doc-link="ladder" target="_blank" rel="noopener noreferrer">Presets ↗</a>
1240
+ </div>
1325
1241
  <dl class="engine-info" id="engine-info"></dl>
1326
1242
  </div>
1327
1243
  </div>
@@ -1394,6 +1310,9 @@ function afterpackDecodeDocument(c) {
1394
1310
  aggregate: fc.aggregate,
1395
1311
  renamedSpans: fc.renamedSpans || [],
1396
1312
  extractedSpans: fc.extractedSpans || [],
1313
+ complexitySpans: fc.complexitySpans || [],
1314
+ declarationKinds: fc.declarationKinds || [],
1315
+ declarationSpans: fc.declarationSpans || [],
1397
1316
  };
1398
1317
  });
1399
1318
 
@@ -1402,6 +1321,7 @@ function afterpackDecodeDocument(c) {
1402
1321
  ...(c.spanUnits !== undefined ? { spanUnits: c.spanUnits } : {}),
1403
1322
  generatedAt: c.generatedAt !== undefined ? c.generatedAt : null,
1404
1323
  engine: c.engine !== undefined ? c.engine : null,
1324
+ ...(c.totals !== undefined ? { totals: c.totals } : {}),
1405
1325
  files,
1406
1326
  };
1407
1327
  }
@@ -1422,114 +1342,25 @@ async function afterpackInflateBase64Gzip(b64) {
1422
1342
  var dataEl = document.getElementById("afterpack-data");
1423
1343
  var DATA = null;
1424
1344
  var MAP_BYTES = null;
1425
- var MAP_ENCODING = "";
1426
1345
  var codeBodyEl = document.getElementById("code-body");
1427
1346
  try {
1428
1347
  var payload = dataEl.textContent.trim();
1429
- MAP_ENCODING = payload.charAt(0) === "{" ? "raw JSON" : "gzip";
1430
1348
  MAP_BYTES = payload.charAt(0) === "{"
1431
1349
  ? new TextEncoder().encode(payload).length
1432
1350
  : Math.floor(payload.replace(/=+$/, "").length * 3 / 4);
1433
1351
  if (payload.charAt(0) === "{") {
1434
1352
  DATA = JSON.parse(payload);
1435
1353
  } else {
1436
- codeBodyEl.textContent = "Decompressing Protection Map…";
1354
+ codeBodyEl.textContent = "Loading…";
1437
1355
  var json = await afterpackInflateBase64Gzip(payload);
1438
1356
  DATA = afterpackDecodeDocument(JSON.parse(json));
1439
1357
  }
1440
1358
  } catch (e) {
1441
- codeBodyEl.textContent = "Failed to load embedded Protection Map data: " + e.message;
1359
+ codeBodyEl.textContent = "Couldn't open this Protection Map: " + e.message;
1442
1360
  return;
1443
1361
  }
1444
1362
  if (!DATA || !Array.isArray(DATA.files)) DATA = { files: [] };
1445
1363
 
1446
- function s2lin(c) { return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4); }
1447
- function lin2s(c) { c = Math.max(0, Math.min(1, c)); return c <= 0.0031308 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055; }
1448
- function hex2rgb(hex) {
1449
- hex = hex.trim().replace(/^#/, "");
1450
- if (hex.length === 3) hex = hex.split("").map(function (c) { return c + c; }).join("");
1451
- return [0, 2, 4].map(function (i) { return parseInt(hex.slice(i, i + 2), 16) / 255; });
1452
- }
1453
- function rgb2hex(rgb) {
1454
- function to255(c) { return Math.round(Math.max(0, Math.min(1, c)) * 255).toString(16).padStart(2, "0"); }
1455
- return "#" + rgb.map(to255).join("");
1456
- }
1457
- function oklabFromLin(rgb) {
1458
- var r = rgb[0], g = rgb[1], b = rgb[2];
1459
- var l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
1460
- var m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
1461
- var s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
1462
- return [
1463
- 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s,
1464
- 1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s,
1465
- 0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s
1466
- ];
1467
- }
1468
- function linFromOklab(lab) {
1469
- var L = lab[0], a = lab[1], b = lab[2];
1470
- var l_ = L + 0.3963377774 * a + 0.2158037573 * b;
1471
- var m_ = L - 0.1055613458 * a - 0.0638541728 * b;
1472
- var s_ = L - 0.0894841775 * a - 1.2914855480 * b;
1473
- var l = l_ * l_ * l_, m = m_ * m_ * m_, s = s_ * s_ * s_;
1474
- return [
1475
- +4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
1476
- -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
1477
- -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s
1478
- ];
1479
- }
1480
- function hex2oklab(hex) { return oklabFromLin(hex2rgb(hex).map(s2lin)); }
1481
- function oklab2hex(lab) { return rgb2hex(linFromOklab(lab).map(lin2s)); }
1482
- function rampColor(stops, t) {
1483
- t = Math.max(0, Math.min(1, t));
1484
- var n = stops.length;
1485
- var pos = t * (n - 1);
1486
- var i = Math.min(n - 2, Math.floor(pos));
1487
- var f = pos - i;
1488
- var a = hex2oklab(stops[i]), b = hex2oklab(stops[i + 1]);
1489
- var lab = [a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f];
1490
- return oklab2hex(lab);
1491
- }
1492
- function hexToRgba(hex, a) {
1493
- var rgb = hex2rgb(hex).map(function (c) { return Math.round(c * 255); });
1494
- return "rgba(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "," + a.toFixed(3) + ")";
1495
- }
1496
- function readVar(name) { return getComputedStyle(document.documentElement).getPropertyValue(name).trim(); }
1497
- function currentRamp(prefix) {
1498
- var out = [];
1499
- for (var i = 0; i <= 6; i++) out.push(readVar("--" + prefix + "-" + i));
1500
- return out;
1501
- }
1502
- function tokenAlpha(m) { return m <= 0 ? 0 : Math.min(0.5, 0.10 + (m / 100) * 0.42); }
1503
- var RENAMED_WASH_ALPHA = 0.16;
1504
- var EXTRACTED_WASH_ALPHA = 0.22;
1505
- function lineAlpha(m) { return m < 60 ? 0 : Math.min(0.07, ((m - 60) / 40) * 0.07); }
1506
- function heatSolid(score) { return rampColor(currentRamp("heat"), Math.max(0, Math.min(100, score)) / 100); }
1507
-
1508
-
1509
- var INK_MIN_CONTRAST = 4.2;
1510
- var INK_COLORS = ["--syn-key", "--syn-str", "--syn-num"];
1511
- function relLuminance(rgb01) {
1512
- var c = rgb01.map(function (v) { return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); });
1513
- return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
1514
- }
1515
- function contrastRatio(a01, b01) {
1516
- var la = relLuminance(a01), lb = relLuminance(b01);
1517
- return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
1518
- }
1519
- function inkYieldScore(heatRamp) {
1520
- var ground = hex2rgb(readVar("--ground"));
1521
- var inks = INK_COLORS.map(function (n) { return hex2rgb(readVar(n)); });
1522
- for (var m = 1; m <= 100; m++) {
1523
- var c = hex2rgb(rampColor(heatRamp, m / 100));
1524
- var a = tokenAlpha(m);
1525
- var comp = [a * c[0] + (1 - a) * ground[0], a * c[1] + (1 - a) * ground[1], a * c[2] + (1 - a) * ground[2]];
1526
- for (var k = 0; k < inks.length; k++) {
1527
- if (contrastRatio(inks[k], comp) < INK_MIN_CONTRAST) return m;
1528
- }
1529
- }
1530
- return 101;
1531
- }
1532
-
1533
1364
  function escapeHtml(str) {
1534
1365
  return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1535
1366
  }
@@ -1543,83 +1374,156 @@ async function afterpackInflateBase64Gzip(b64) {
1543
1374
  return (n / (1024 * 1024)).toFixed(2) + " MB";
1544
1375
  }
1545
1376
  function fmtNum(n) { return n == null ? "—" : n.toLocaleString(); }
1377
+ function plural(n, one, many) { return n + " " + (n === 1 ? one : many); }
1378
+
1379
+ var DOCS_ORIGIN = ["https", "//www.afterpack.dev"].join(":");
1380
+ var DOC = {
1381
+ complexity: "/docs/complexity",
1382
+ complexityWhat: "/docs/complexity#what-rises-with-the-number",
1383
+ ladder: "/docs/presets#the-ladder",
1384
+ lightDefault: "/docs/presets#the-default-is-light",
1385
+ sizeBudget: "/docs/presets#size-budget",
1386
+ readMap: "/docs/protection-map#how-to-read-it",
1387
+ mapLives: "/docs/protection-map#where-your-map-lives",
1388
+ classes: "/docs/reversal-classes#the-classes",
1389
+ attackers: "/docs/threat-model#attacker-classes",
1390
+ secret: "/docs/threat-model#protecting-a-secret",
1391
+ antiTamper: "/docs/threat-model#anti-tamper",
1392
+ directives: "/docs/directives#writing-one",
1393
+ directivesCheck: "/docs/directives#checking-what-was-applied",
1394
+ preserve: "/docs/best-practices#preserve-what-must-stay-readable",
1395
+ thirdParty: "/docs/best-practices#dont-waste-protection-on-third-party-code",
1396
+ perf: "/docs/faq#does-obfuscation-slow-my-code-down",
1397
+ cfgComplexity: "/docs/config#complexity",
1398
+ cfgSeed: "/docs/config#seed",
1399
+ cfgDetailed: "/docs/config#protectionMap-detailed",
1400
+ cfgPreserveLiterals: "/docs/config#strings-preserveLiterals",
1401
+ cfgRename: "/docs/config#identifiers-rename",
1402
+ cfgTransforms: "/docs/config#transforms-kind-enabled"
1403
+ };
1404
+ function docUrl(key) { return Object.prototype.hasOwnProperty.call(DOC, key) ? DOCS_ORIGIN + DOC[key] : null; }
1405
+ function tipAttrs(tip, doc) {
1406
+ return ' data-tip="' + escapeAttr(tip) + '"' + (doc ? ' data-doc="' + escapeAttr(doc) + '"' : "");
1407
+ }
1408
+ function docLinkHtml(doc, label) {
1409
+ var href = docUrl(doc);
1410
+ return href ? '<a class="doc-link" href="' + escapeAttr(href) + '" target="_blank" rel="noopener noreferrer">' + escapeHtml(label) + " ↗</a>" : "";
1411
+ }
1412
+
1413
+ var CX_BANDS = [
1414
+ { band: "low", label: "under 4" },
1415
+ { band: "mid", label: "4 to 7" },
1416
+ { band: "high", label: "7 to 10" },
1417
+ { band: "max", label: "over 10" }
1418
+ ];
1419
+ function complexityBand(c) {
1420
+ if (c == null || typeof c !== "number" || isNaN(c)) return null;
1421
+ if (c <= 0) return "none";
1422
+ if (c < 4) return "low";
1423
+ if (c < 7) return "mid";
1424
+ if (c <= 10) return "high";
1425
+ return "max";
1426
+ }
1427
+ function fmtCx(c) {
1428
+ if (c == null || typeof c !== "number" || isNaN(c)) return "—";
1429
+ return String(Math.round(c * 10) / 10);
1430
+ }
1431
+ function cxDotHtml(band) { return '<span class="cx-dot" data-band="' + (band || "protected") + '" aria-hidden="true"></span>'; }
1546
1432
 
1547
1433
  var CLASS_ORDER = ["preserved", "renamed-encoded", "flattened-fused", "destroyed-fused"];
1548
1434
  var CLASS_META = {
1549
- "preserved": { label: "Preserved", note: "Left readable — either the engine had to keep it literal (import path, directive, property key) or no transform reached it. Not a claim about who wrote it." },
1550
- "renamed-encoded": { label: "Renamed & encoded", note: "Identifiers renamed, constants rebuilt at use sites. Recoverable with effort. (Free)" },
1551
- "flattened-fused": { label: "Flattened & fused", note: "Control flow flattened, logic fused into an equivalent-but-different program. (Free ceiling)" },
1552
- "destroyed-fused": { label: "Destroyed & fused", note: "Boundary-destroying fusion across the bundle — recovering authored structure is computationally infeasible for a static reader. (Pro)" }
1435
+ "preserved": { label: "Preserved", note: "Left readable on purpose: code that must keep its text to work, or code you excluded.", doc: "preserve" },
1436
+ "renamed-encoded": { label: "Renamed & encoded", note: "Names replaced and values encoded. A reader can recover the structure with effort.", doc: "classes" },
1437
+ "flattened-fused": { label: "Flattened & fused", note: "Logic reshaped and merged. A reader can recover code that behaves the same, not the code you wrote.", doc: "classes" },
1438
+ "destroyed-fused": { label: "Destroyed & fused", note: "Reshaped and merged across files. A reader can recover code that behaves the same, not the code you wrote.", doc: "classes" }
1439
+ };
1440
+ var CATEGORY_META = {
1441
+ Data: { label: "Hides values", tip: "Strings and numbers are replaced by code that rebuilds them at runtime.", doc: "lightDefault" },
1442
+ Structural: { label: "Reshapes code", tip: "Changes how the code is laid out, such as wrappers, flattened branches or rebuilt objects, without changing what it does.", doc: "complexityWhat" },
1443
+ Syntax: { label: "Rewrites syntax", tip: "Turns modern syntax into simpler equivalent code so other transforms can reach it. No protection on its own." },
1444
+ Entangle: { label: "Ties code together", tip: "Links this code to values elsewhere in the bundle, so it can't be read on its own.", doc: "complexityWhat" },
1445
+ AntiAnalysis: { label: "Misleads tools", tip: "Adds conditions and paths meant to throw off automated analysis.", doc: "complexityWhat" },
1446
+ AntiTamper: { label: "Detects edits", tip: "Makes a modified copy of the code stop working correctly.", doc: "antiTamper" },
1447
+ Optimize: { label: "Cleanup", tip: "Tidies the code between steps. No protection on its own." }
1553
1448
  };
1554
- var CATEGORY_LABEL = { Data: "data", Structural: "struct", Control: "control" };
1449
+ function categoryMeta(step) {
1450
+ if (step.category === "Structural" && step.phase === "Parse") return CATEGORY_META.Syntax;
1451
+ return CATEGORY_META[step.category] || (step.category ? { label: String(step.category), tip: "" } : null);
1452
+ }
1555
1453
  var WARN_ICON =
1556
1454
  '<span class="pin" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" ' +
1557
1455
  'stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">' +
1558
1456
  '<path d="M8 2.2 15 14H1z"/><path d="M8 6.4v3.4"/><path d="M8 11.8h.01"/></svg></span>';
1559
1457
  var SEVERITY_ICON = { leak: "🔓", propertyName: "🔑", weak: "〰" };
1560
- var SEVERITY_LABEL = { leak: "Leak", propertyName: "Property name", weak: "Weak" };
1561
- var MACHINERY_BLURB = "Whole-file pipeline bookkeeping — materialization plumbing, wrapper IIFEs, cached-string tables, and similar — that doesn't map to any specific span of your source. Excluded from the heat map and from token selection on purpose: every character in the file technically falls inside this bucket, so painting or selecting it would make the whole file look uniformly “protected” and hide the real, per-token signal underneath.";
1562
- var UNTRANSFORMED_BLURB = "This span is unlit because it is genuinely plain — required syntax the build keeps verbatim (a keyword, punctuation, a property key, or a module specifier), or code your bundler removed before AfterPack ran. Renamed identifiers are shown on their own baseline layer, so an unlit span is almost always one that is truly unchanged or was already gone — not a renamed identifier. Unlit here means plain-or-removed, not “untransformed but still exposed”.";
1458
+ var SEVERITY_LABEL = { leak: "Readable string", propertyName: "Readable property name", weak: "Readable text" };
1459
+ var SEVERITY_BODY = {
1460
+ leak: "This string is readable in your shipped code.",
1461
+ propertyName: "This property name is readable in your shipped code. Property names usually have to stay.",
1462
+ weak: "This text is readable in your shipped code."
1463
+ };
1464
+ var SEVERITY_HELP = {
1465
+ leak: { doc: "secret", label: "How to protect a string" },
1466
+ propertyName: { doc: "preserve", label: "Why property names stay" }
1467
+ };
1563
1468
 
1564
1469
  var INSP_COPY = {
1565
- score: "The engine's 0–100 protection score for this span — how hard the ledger says this region is to reverse.",
1566
- why: "The engine's own one-line account of what it did to this span.",
1567
- leakCap: "A readable literal survived un-encoded inside this span — the leaked literal itself is UNPROTECTED. The score and class on this card rate the surrounding transformed code, not the leak.",
1568
- spanMismatch: "This region is a string-materialization site — it encodes exactly one literal — but its recorded span covers no literal at all. Ledger spans are back-mapped from your bundled output through source maps, and a minifier's map resolves a position to the nearest mapping segment, not to the token: the encoded literal in `role === \"owner\"` back-maps onto `role`. The transform is real; the painted extent is wrong. Builds from August 2026 on re-anchor such a region onto the literal itself, and send it to Machinery when the literal is not inside the span at all — so this flag means the map predates that fix.",
1569
- transforms: "Transform passes the ledger recorded on this span.",
1570
- chainTop: "The oldest step of this span's transform chain. Open “Transform chain” below for the rest.",
1571
- chainNone: "This map carries the per-region totals but not the per-step column — the cloud artifact drops it so a several-hundred-file map stays small. It is a size trade-off, not a missing transform.",
1572
- sizeDelta: "The engine's estimate of the output bytes this span's transforms added. An estimate, not a byte-exact count.",
1573
- decodeOps: "A per-site STATIC op count for decoding this span at runtime — not amortized over loops or repeated calls.",
1574
- entropy: "The engine's RAW per-span entropy figure — an unbounded count (0 to the high tens on a real build), not a ratio. It is a different quantity from the file's “avg entropy”, which is a normalised 0–1 hint: do not compare the two.",
1575
- entropyAvg: "The file's average entropy hint, normalised to 0–1. A different quantity from a region's raw entropy figure — the two are not comparable.",
1576
- ceiling: "The strongest reversal class a Pro directive could pin this exact span to. An upgrade option, not a gap in this build.",
1577
- ceilingNone: "No stronger class is offered for this span in this build.",
1578
- preservedMust: "must stay literal",
1579
- preservedLowered: "Structure was lowered/desugared, but identifiers and values stay readable — no rename or encoding ran on this span.",
1580
- preservedNone: "No transform ran on this span — left readable.",
1581
- preservedState: "Why this span was left readable. “must stay literal” is a structural requirement the engine cannot break; “lowered only” means transforms ran but none of them renamed or encoded anything here.",
1582
- renamedLayer: "The rename baseline — the bottom tier of the map. A region always wins the fill over it, so this token carries no hardened transform.",
1583
- renamedStrength: "Renaming hides intent but is low-effort to undo. Real protection is the hardened regions (materialization / control-flow / MBA).",
1584
- renamedOutput: "This identifier's original name is not in your shipped output. Your bundler minified it and AfterPack re-renamed it under this build's seed.",
1585
- extractedLayer: "The extraction lane — one tier above the rename baseline, below any hardened region. Property names and free globals are hoisted into a whole-program constant pool and reached through a computed lookup, so the readable name is gone from every access site.",
1586
- extractedStrength: "Stronger than a rename (the name leaves the call site entirely) but still injective: the pool declaration holds each name literally, so a reader who finds the pool can undo it. Real protection is the hardened regions (materialization / control-flow / MBA).",
1587
- extractedOutput: "In your output this token is a computed lookup into the constant pool, not a readable name.",
1588
- extractedKind: "What was extracted: a PROPERTY name (a member access or an object-literal key) or a free/GLOBAL identifier.",
1589
- gapAbuts: "Ledger spans are back-mapped from your bundled output through source maps, and at that resolution a region edge can land a token short. This token may well be inside that region's transform even though the recorded span stops before it.",
1590
- gapClear: "No region edge is adjacent to this token, so this is not a clipped span.",
1591
- gapNone: "No ledger region was recorded anywhere near this token.",
1592
- coverage: "Share of this file's characters, measured over the same spans the code pane paints. Ledger region, Extracted only, Renamed only and Plain are the four disjoint buckets every character falls into, in that priority order, so they add up to the whole file. A ledger region is recorded only where a transform cleared the entropy funnel, so a large plain share is normal — most of a source file is syntax, and syntax cannot be obfuscated away.",
1593
- severity: "How the engine classed this weak spot.",
1594
- sample: "The exact text that survived readable in your output.",
1595
- mechanism: "The engine's mechanism code for this weak spot, glossed in plain English.",
1596
- disposition: "What the engine decided to do about this weak spot.",
1597
- bytes: "The engine's estimate of the added output bytes for this site, not a byte-exact count.",
1598
- avgScore: "Width-weighted average protection score across the spans of this file that carry a ledger region. It says nothing about how MUCH of the file has one — see “Attributed”.",
1599
- fileRegions: "Ledger regions recorded in this file, excluding the whole-file scaffolding bucket.",
1600
- selectHint: "Click (or focus + Enter/Space) any token in the code pane. Clicking whitespace, the gutter, or anywhere off the code returns here.",
1601
- weakSpots: "Weak spots recorded in THIS file — readable literals this build left in the output. Every one is listed below, with a jump to its exact position. The file-tree header counts them across the whole build.",
1602
- leaks: "The subset of this file's weak spots whose severity is “leak”: a literal that survived unprotected. The rest are residual property names, which the engine has to keep literal for your object to keep working.",
1603
- noRegion: "No ledger region covers this span."
1470
+ complexity: "How complex this code is after protection, on the same scale as --complexity. Higher means harder to reverse.",
1471
+ noComplexity: "This map doesn't record the complexity each part of your code reached, only the build's target.",
1472
+ target: "The complexity this build aimed for, set by --complexity or your preset.",
1473
+ resists: "Estimated chance that at least one transform here survives free automated deobfuscation tools, combined from each transform's measured rate.",
1474
+ addedSize: "Roughly how many bytes protection added here.",
1475
+ decoders: "Small decoders that run here to rebuild strings or values.",
1476
+ leakInside: "Readable text sits inside this code. The complexity shown is for the code around it, not the text.",
1477
+ transforms: "Each transform applied to this code, oldest first.",
1478
+ transformsRates: "A transform with no rate has no measured resistance on its own.",
1479
+ credit: "Measured on test builds: how much of this transform's work the best free deobfuscation tool could not undo.",
1480
+ detailsOff: "Step details were left out to keep this map small. Set protectionMap.detailed to true to include them.",
1481
+ noPosition: "The map can't point to where this sits in your source.",
1482
+ preservedLowered: "Syntax was rewritten, but names and values stay readable.",
1483
+ preservedNone: "Nothing was applied, so it stays readable.",
1484
+ renamedLine: "The original name isn't in your output. It gets a new name every build.",
1485
+ renamedStrength: "Renaming hides meaning but is easy to work around. Stronger protection shows as colored code.",
1486
+ renamedShare: "Share of this file that is renamed names only.",
1487
+ extractedLine: "In your output this name is looked up from a shared table, not written here.",
1488
+ extractedStrength: "The name is gone from here, but the shared table still holds it, so a determined reader can find it.",
1489
+ extractedShare: "Share of this file that is hidden names only.",
1490
+ unlitKind: "What the viewer reads this part of your code as.",
1491
+ gapAbuts: "A protected region ends right before this. Source maps can clip a region by a character or two, so this may be protected too.",
1492
+ sample: "As it appears in your output.",
1493
+ around: "The protection type of the code around this text. The text itself is readable."
1604
1494
  };
1605
1495
 
1606
- var HUMANIZE = {
1607
- "module-specifier": "import path — must stay literal to resolve the module",
1608
- "non-computed-key": "property key — must stay literal to keep your object working",
1609
- "directive": "directive (e.g. \"use client\") — must stay literal",
1610
- "reflection": "read by name at runtime — renaming it would break reflection",
1611
- "external": "external reference — resolved outside this bundle",
1612
- "ReachableConst": "a reachable constant the reader can still follow to its value"
1496
+ var PRESERVED_REASON = {
1497
+ "module-specifier": "An import path. The module can't load if it changes.",
1498
+ "non-computed-key": "A property key. Your objects stop working if it changes.",
1499
+ "directive": "A directive such as \"use client\". Tools read it as written.",
1500
+ "reflection": "Read by name at runtime. Renaming it would break your code.",
1501
+ "external": "Defined outside this bundle.",
1502
+ "position-blocked": "A spot where the language needs the literal text."
1503
+ };
1504
+ var MECHANISM = {
1505
+ reachableConst: "An ordinary string that wasn't encoded.",
1506
+ preservedLeaf: "Inside code AfterPack keeps as written.",
1507
+ opaqueField: "Inside syntax AfterPack keeps as written, such as a parameter default.",
1508
+ positionBlocked: "In a spot where the language needs the literal text.",
1509
+ pinnedLiteral: "Kept as written by strings.preserveLiterals.",
1510
+ outputOnly: "Found in the output only, not traced to a line of your source."
1613
1511
  };
1614
- function humanize(code) {
1512
+ function preservedReasonText(code) {
1513
+ return code == null || code === "" ? "" : PRESERVED_REASON[code] || "";
1514
+ }
1515
+ function mechanismKey(code) {
1615
1516
  if (code == null || code === "") return "";
1616
- return HUMANIZE[code] || String(code);
1517
+ var key = String(code).split(":")[0];
1518
+ return key.charAt(0).toLowerCase() + key.slice(1);
1617
1519
  }
1520
+ function mechanismText(code) { return MECHANISM[mechanismKey(code)] || ""; }
1618
1521
 
1619
- function classChipHtml(cls, ghost, labelOverride) {
1620
- var meta = CLASS_META[cls] || { label: cls };
1522
+ function classChipHtml(cls, ghost, labelOverride, noTip) {
1523
+ var meta = CLASS_META[cls] || { label: cls || "Protected" };
1621
1524
  var label = labelOverride != null ? labelOverride : meta.label;
1622
- return '<span class="class-chip' + (ghost ? " is-ghost" : "") + '" data-class="' + cls + '"><span class="dot" aria-hidden="true"></span>' + escapeHtml(label) + "</span>";
1525
+ var tip = !noTip && labelOverride == null && meta.note ? tipAttrs(meta.note, meta.doc) + ' tabindex="0"' : "";
1526
+ return '<span class="class-chip' + (ghost ? " is-ghost" : "") + '" data-class="' + escapeAttr(cls || "") + '"' + tip + ">" + escapeHtml(label) + "</span>";
1623
1527
  }
1624
1528
 
1625
1529
  var GRAMMARS = [
@@ -1664,9 +1568,9 @@ async function afterpackInflateBase64Gzip(b64) {
1664
1568
 
1665
1569
  var SYN_CLASS = { c: "sy-c", k: "sy-k", v: "sy-k", s: "sy-s", n: "sy-n" };
1666
1570
  var TOKEN_KIND = {
1667
- w: "whitespace", p: "punctuation / operator", i: "identifier", y: "property name",
1668
- k: "keyword", s: "string literal", n: "number literal", c: "comment", "?": "source text",
1669
- v: "value literal"
1571
+ w: "whitespace", p: "punctuation", i: "name", y: "property name",
1572
+ k: "keyword", s: "string", n: "number", c: "comment", "?": "text",
1573
+ v: "value"
1670
1574
  };
1671
1575
  var VALUE_LITERAL_TEXT = { "null": 1, "true": 1, "false": 1, "undefined": 1 };
1672
1576
  var NO_REGEX_AFTER = { "this": 1, "true": 1, "false": 1, "null": 1, "undefined": 1, "super": 1 };
@@ -2180,20 +2084,6 @@ async function afterpackInflateBase64Gzip(b64) {
2180
2084
  var machinery = regions.filter(function (r) { return r.isMachinery; })[0] || null;
2181
2085
  var realRegions = regions.filter(function (r) { return !r.isMachinery; });
2182
2086
 
2183
- var heatPositive = [], heatMax = 0;
2184
- realRegions.forEach(function (r) {
2185
- var s = r.raw.score || 0;
2186
- if (s > heatMax) heatMax = s;
2187
- if (s > 0) heatPositive.push(s);
2188
- });
2189
- var heatMinPos = heatPositive.length ? Math.min.apply(null, heatPositive) : 0;
2190
- regions.forEach(function (r) {
2191
- var s = r.raw.score || 0;
2192
- if (s <= 0) { r.heatNorm = 0; return; }
2193
- var norm = heatMax === heatMinPos ? 100 : ((s - heatMinPos) / (heatMax - heatMinPos)) * 100;
2194
- r.heatNorm = Math.max(1, norm);
2195
- });
2196
-
2197
2087
  var spotlights = (fdoc.spotlights || []).map(function (s, idx) {
2198
2088
  var span = s.span || [0, 0];
2199
2089
  var startChar = byteToChar(span[0]);
@@ -2212,7 +2102,7 @@ async function afterpackInflateBase64Gzip(b64) {
2212
2102
  endChar = startChar + s.sample.length;
2213
2103
  }
2214
2104
  }
2215
- return { idx: idx, raw: s, startChar: startChar, endChar: endChar };
2105
+ return { idx: idx, raw: s, startChar: startChar, endChar: endChar, positioned: endChar > startChar };
2216
2106
  });
2217
2107
 
2218
2108
  var renamedRanges = (fdoc.renamedSpans || []).map(function (pair) {
@@ -2234,6 +2124,36 @@ async function afterpackInflateBase64Gzip(b64) {
2234
2124
  }
2235
2125
  }
2236
2126
 
2127
+ var cxFlat = Array.isArray(fdoc.complexitySpans) ? fdoc.complexitySpans : [];
2128
+ var cxRanges = [];
2129
+ for (var ci = 0; ci + 2 < cxFlat.length; ci += 3) {
2130
+ var csc = byteToChar(cxFlat[ci]);
2131
+ var cec = Math.max(byteToChar(cxFlat[ci + 1]), csc);
2132
+ var cval = cxFlat[ci + 2];
2133
+ if (cec > csc && typeof cval === "number" && isFinite(cval) && cval >= 0) {
2134
+ cxRanges.push({ startChar: csc, endChar: cec, c: cval });
2135
+ }
2136
+ }
2137
+ cxRanges.sort(function (a, b) { return a.startChar - b.startChar || b.endChar - a.endChar || b.c - a.c; });
2138
+
2139
+ var declKinds = Array.isArray(fdoc.declarationKinds) ? fdoc.declarationKinds : [];
2140
+ var declFlat = Array.isArray(fdoc.declarationSpans) ? fdoc.declarationSpans : [];
2141
+ var declRanges = [], declByKey = {};
2142
+ for (var dk = 0; dk + 2 < declFlat.length; dk += 3) {
2143
+ var dsc = byteToChar(declFlat[dk]);
2144
+ var dec = Math.max(byteToChar(declFlat[dk + 1]), dsc);
2145
+ var dname = declKinds[declFlat[dk + 2]];
2146
+ if (dec <= dsc || typeof dname !== "string") continue;
2147
+ var dr = declByKey[dsc + ":" + dec];
2148
+ if (!dr) {
2149
+ dr = declByKey[dsc + ":" + dec] = { startChar: dsc, endChar: dec, names: [] };
2150
+ declRanges.push(dr);
2151
+ }
2152
+ if (dr.names.indexOf(dname) < 0) dr.names.push(dname);
2153
+ }
2154
+ var cxSum = 0;
2155
+ cxRanges.forEach(function (r) { cxSum += r.c; });
2156
+
2237
2157
  var directives = ((fdoc.aggregate && fdoc.aggregate.directives) || []).map(function (d, idx) {
2238
2158
  var span = d.span || [0, 0];
2239
2159
  var sc = byteToChar(span[0]);
@@ -2253,6 +2173,8 @@ async function afterpackInflateBase64Gzip(b64) {
2253
2173
  renamedRanges.forEach(function (r) { addB(r.startChar); addB(r.endChar); });
2254
2174
  extractedRanges.forEach(function (r) { addB(r.startChar); addB(r.endChar); });
2255
2175
  directives.forEach(function (d) { addB(d.startChar); addB(d.endChar); });
2176
+ cxRanges.forEach(function (r) { addB(r.startChar); addB(r.endChar); });
2177
+ declRanges.forEach(function (r) { addB(r.startChar); addB(r.endChar); });
2256
2178
  var boundaries = Object.keys(boundarySet).map(Number).sort(function (a, b) { return a - b; });
2257
2179
 
2258
2180
  function winnerFor(start, end) {
@@ -2272,20 +2194,24 @@ async function afterpackInflateBase64Gzip(b64) {
2272
2194
  }
2273
2195
  return null;
2274
2196
  }
2275
- function renamedForRange(start, end) {
2276
- for (var i = 0; i < renamedRanges.length; i++) {
2277
- var r = renamedRanges[i];
2278
- if (r.startChar <= start && r.endChar >= end) return i;
2279
- }
2280
- return -1;
2281
- }
2282
- function extractedForRange(start, end) {
2283
- for (var i = 0; i < extractedRanges.length; i++) {
2284
- var r = extractedRanges[i];
2285
- if (r.startChar <= start && r.endChar >= end) return i;
2286
- }
2287
- return -1;
2197
+ function coverSweep(ranges) {
2198
+ var order = ranges.map(function (r, i) { return i; }).sort(function (a, b) {
2199
+ return ranges[a].startChar - ranges[b].startChar || a - b;
2200
+ });
2201
+ var next = 0, open = [];
2202
+ return function (start, end) {
2203
+ while (next < order.length && ranges[order[next]].startChar <= start) open.push(order[next++]);
2204
+ open = open.filter(function (i) { return ranges[i].endChar > start; });
2205
+ var hit = -1;
2206
+ for (var k = 0; k < open.length; k++) {
2207
+ if (ranges[open[k]].endChar >= end && (hit < 0 || open[k] < hit)) hit = open[k];
2208
+ }
2209
+ return hit;
2210
+ };
2288
2211
  }
2212
+ var renamedAt = coverSweep(renamedRanges);
2213
+ var extractedAt = coverSweep(extractedRanges);
2214
+ var declarationAt = coverSweep(declRanges);
2289
2215
  function directiveForRange(start, end) {
2290
2216
  var best = -1, bestW = Infinity;
2291
2217
  for (var i = 0; i < directives.length; i++) {
@@ -2302,76 +2228,93 @@ async function afterpackInflateBase64Gzip(b64) {
2302
2228
  r.directive = di >= 0 ? directives[di] : null;
2303
2229
  });
2304
2230
 
2231
+ var cxNext = 0, cxOpen = [];
2232
+ function complexityForRange(start, end) {
2233
+ while (cxNext < cxRanges.length && cxRanges[cxNext].startChar <= start) cxOpen.push(cxRanges[cxNext++]);
2234
+ var best = null;
2235
+ cxOpen = cxOpen.filter(function (r) { return r.endChar > start; });
2236
+ for (var i = 0; i < cxOpen.length; i++) {
2237
+ var r = cxOpen[i];
2238
+ if (r.endChar < end) continue;
2239
+ var w = r.endChar - r.startChar, bw = best ? best.endChar - best.startChar : Infinity;
2240
+ if (w < bw || (w === bw && r.c > best.c)) best = r;
2241
+ }
2242
+ return best ? best.c : null;
2243
+ }
2244
+
2305
2245
  var runs = [];
2306
2246
  for (var bi = 0; bi < boundaries.length - 1; bi++) {
2307
2247
  var segStart = boundaries[bi], segEnd = boundaries[bi + 1];
2308
2248
  if (segEnd <= segStart) continue;
2309
2249
  var winner = winnerFor(segStart, segEnd);
2250
+ var cx = complexityForRange(segStart, segEnd);
2310
2251
  var spot = spotlightForRange(segStart, segEnd);
2311
- var extIdx = winner ? -1 : extractedForRange(segStart, segEnd);
2312
- var renIdx = winner || extIdx >= 0 ? -1 : renamedForRange(segStart, segEnd);
2252
+ var extAt = extractedAt(segStart, segEnd);
2253
+ var renAt = renamedAt(segStart, segEnd);
2254
+ var extIdx = winner ? -1 : extAt;
2255
+ var renIdx = winner || extIdx >= 0 ? -1 : renAt;
2313
2256
  var dirIdx = directiveForRange(segStart, segEnd);
2257
+ var declIdx = declarationAt(segStart, segEnd);
2314
2258
  runs.push({
2315
2259
  start: segStart, end: segEnd,
2316
2260
  regionIdx: winner ? winner.idx : null,
2317
2261
  spotlightIdx: spot ? spot.idx : null,
2318
2262
  renamedIdx: renIdx >= 0 ? renIdx : null,
2319
2263
  extractedIdx: extIdx >= 0 ? extIdx : null,
2264
+ named: extAt >= 0 ? "hidden" : renAt >= 0 ? "renamed" : null,
2320
2265
  directiveIdx: dirIdx >= 0 ? dirIdx : null,
2266
+ declIdx: declIdx >= 0 ? declIdx : null,
2267
+ cx: cx,
2321
2268
  isSpotlightStart: !!(spot && spot.startChar === segStart)
2322
2269
  });
2323
2270
  }
2324
2271
  var mergedRuns = [];
2325
2272
  runs.forEach(function (run) {
2326
2273
  var last = mergedRuns[mergedRuns.length - 1];
2327
- if (last && last.regionIdx === run.regionIdx && last.spotlightIdx === run.spotlightIdx && last.renamedIdx === run.renamedIdx && last.extractedIdx === run.extractedIdx && last.directiveIdx === run.directiveIdx && last.end === run.start) {
2274
+ if (last && last.regionIdx === run.regionIdx && last.spotlightIdx === run.spotlightIdx && last.renamedIdx === run.renamedIdx && last.extractedIdx === run.extractedIdx && (!CX_LANE || last.named === run.named) && last.directiveIdx === run.directiveIdx && last.declIdx === run.declIdx && last.cx === run.cx && last.end === run.start) {
2328
2275
  last.end = run.end;
2329
2276
  } else {
2330
2277
  mergedRuns.push(run);
2331
2278
  }
2332
2279
  });
2333
2280
 
2334
- var sumW = 0, totalW = 0;
2335
- mergedRuns.forEach(function (run) {
2336
- if (run.regionIdx == null) return;
2337
- var len = run.end - run.start;
2338
- sumW += len * (regions[run.regionIdx].raw.score || 0);
2339
- totalW += len;
2340
- });
2341
- var avgScore = totalW > 0 ? sumW / totalW : 0;
2342
-
2343
- var displayPath = (fdoc.file && fdoc.file.path) || null;
2344
- var displayName = displayPath ? displayPath.split(/[\\/]+/).pop() : "(unnamed input " + (fileIdx + 1) + ")";
2281
+ var isMachineryFile = !!(fdoc.file && fdoc.file.sourceOrigin === "machinery");
2282
+ var displayPath = isMachineryFile ? "(AfterPack runtime)" : (fdoc.file && fdoc.file.path) || null;
2283
+ var displayName = displayPath ? displayPath.split(/[\\/]+/).pop() : "(unnamed file " + (fileIdx + 1) + ")";
2345
2284
  var leakCount = (fdoc.aggregate && fdoc.aggregate.leakCount) || 0;
2346
2285
  var weakSpotCount = spotlights.length ||
2347
2286
  ((fdoc.aggregate && fdoc.aggregate.weakRegions) || 0);
2348
2287
 
2349
- var covRegion = 0, covRenamed = 0, covExtracted = 0;
2288
+ var coverage = { protected: 0, hidden: 0, renamed: 0, readable: 0, plain: 0, total: sourceLen };
2350
2289
  mergedRuns.forEach(function (run) {
2351
2290
  var len = run.end - run.start;
2352
- if (run.regionIdx != null) covRegion += len;
2353
- else if (run.extractedIdx != null) covExtracted += len;
2354
- else if (run.renamedIdx != null) covRenamed += len;
2291
+ var winnerRegion = run.regionIdx != null ? regions[run.regionIdx] : null;
2292
+ var bucket = runPaint(run, winnerRegion).bucket;
2293
+ coverage[bucket] += len;
2355
2294
  });
2295
+ coverage.plain = Math.max(0, sourceLen - coverage.protected - coverage.hidden - coverage.renamed - coverage.readable);
2356
2296
 
2357
2297
  return {
2358
2298
  grammar: grammarFor(displayPath || displayName),
2359
2299
  isTyped: isTypedPath(displayPath || displayName),
2360
- coverage: {
2361
- region: covRegion, renamed: covRenamed, extracted: covExtracted,
2362
- plain: Math.max(0, sourceLen - covRegion - covRenamed - covExtracted), total: sourceLen
2363
- },
2300
+ coverage: coverage,
2301
+ isMachineryFile: isMachineryFile,
2302
+ cxRanges: cxRanges, cxCount: cxRanges.length, cxSum: cxSum,
2303
+ cxAvg: cxRanges.length ? cxSum / cxRanges.length : null,
2364
2304
  fileIdx: fileIdx, doc: fdoc, source: source, sourceLen: sourceLen,
2365
2305
  regions: regions, realRegions: realRegions, machinery: machinery,
2366
2306
  spotlights: spotlights, mergedRuns: mergedRuns,
2367
- renamedRanges: renamedRanges, extractedRanges: extractedRanges, directives: directives,
2307
+ renamedRanges: renamedRanges, extractedRanges: extractedRanges, directives: directives, declRanges: declRanges,
2368
2308
  renamedCount: (fdoc.aggregate && fdoc.aggregate.renamedCount != null) ? fdoc.aggregate.renamedCount : renamedRanges.length,
2369
2309
  extractedCount: (fdoc.aggregate && fdoc.aggregate.extractedCount != null) ? fdoc.aggregate.extractedCount : extractedRanges.length,
2370
- avgScore: avgScore, leakCount: leakCount, weakSpotCount: weakSpotCount,
2310
+ leakCount: leakCount, weakSpotCount: weakSpotCount,
2371
2311
  displayPath: displayPath, displayName: displayName
2372
2312
  };
2373
2313
  }
2374
2314
 
2315
+ var CX_LANE = DATA.files.some(function (f) {
2316
+ return !!f && Array.isArray(f.complexitySpans) && f.complexitySpans.length > 2;
2317
+ });
2375
2318
  var FILES = DATA.files.map(prepareFile);
2376
2319
 
2377
2320
  function treePartsFor(f) {
@@ -2521,11 +2464,11 @@ async function afterpackInflateBase64Gzip(b64) {
2521
2464
  var deeplinkNote = "";
2522
2465
  var linkedFileIdx = -1;
2523
2466
  if (HASH0.unknownFilter) {
2524
- deeplinkNote = "This link asked for an unknown filter (“" + HASH0.unknownFilter + "”) — showing all files.";
2467
+ deeplinkNote = "This link asked for an unknown filter (“" + HASH0.unknownFilter + "”). Showing all files.";
2525
2468
  } else if (HASH0.filter && HASH0.filter !== "all") {
2526
2469
  activeFileFilter = HASH0.filter;
2527
2470
  if (!filteredFiles().length) {
2528
- deeplinkNote = "No file in this build matches the “" + HASH0.filter + "” filter — showing all files.";
2471
+ deeplinkNote = "No file matches the “" + HASH0.filter + "” filter. Showing all files.";
2529
2472
  activeFileFilter = "all";
2530
2473
  }
2531
2474
  }
@@ -2533,7 +2476,7 @@ async function afterpackInflateBase64Gzip(b64) {
2533
2476
  linkedFileIdx = findFileIdxByPath(HASH0.file);
2534
2477
  if (linkedFileIdx < 0) {
2535
2478
  deeplinkNote = (deeplinkNote ? deeplinkNote + " " : "") +
2536
- "“" + HASH0.file + "” is not in this Protection Map — showing the first file instead.";
2479
+ "“" + HASH0.file + "” is not in this Protection Map. Showing the first file.";
2537
2480
  } else if (!filteredFiles().some(function (f) { return f.fileIdx === linkedFileIdx; })) {
2538
2481
  activeFileFilter = "all";
2539
2482
  }
@@ -2563,7 +2506,6 @@ async function afterpackInflateBase64Gzip(b64) {
2563
2506
  var state = {
2564
2507
  activeFileIdx: initialFileIdx,
2565
2508
  selection: null,
2566
- highlightClassOn: false,
2567
2509
  syntaxOn: true,
2568
2510
  railCollapsed: false,
2569
2511
  railManual: false,
@@ -2589,17 +2531,28 @@ async function afterpackInflateBase64Gzip(b64) {
2589
2531
 
2590
2532
  var codeBody = document.getElementById("code-body");
2591
2533
 
2592
- function metricForRegion(region) {
2593
- return region ? (region.heatNorm || 0) : 0;
2594
- }
2595
2534
  function isPreservedRegion(region) {
2596
2535
  return !!(region && (region.raw.preservedReason || region.raw.reversalClass === "preserved"));
2597
2536
  }
2537
+ function runPaint(run, region) {
2538
+ var preserved = isPreservedRegion(region);
2539
+ var names = run.extractedIdx != null ? "hidden" : run.renamedIdx != null ? "renamed" : null;
2540
+ if (CX_LANE) {
2541
+ if (run.cx != null && run.cx > 0) {
2542
+ var band = complexityBand(run.cx);
2543
+ return { cls: "cx-" + band, band: band, bucket: "protected" };
2544
+ }
2545
+ if (preserved) return { cls: "tok-preserved", band: "readable", bucket: "readable" };
2546
+ if (run.cx != null || region || names) return { cls: "cx-none", band: "none", bucket: names || "plain" };
2547
+ return { cls: "", band: null, bucket: "plain" };
2548
+ }
2549
+ if (preserved) return { cls: "tok-preserved", band: "readable", bucket: "readable" };
2550
+ if (region) return { cls: "cx-protected", band: "protected", bucket: "protected" };
2551
+ if (names) return { cls: "cx-names", band: "names", bucket: names };
2552
+ return { cls: "", band: null, bucket: "plain" };
2553
+ }
2598
2554
 
2599
2555
  function paintCode(file) {
2600
- var heatRamp = currentRamp("heat");
2601
- var renamedHex = readVar("--class-renamed");
2602
- var inkYield = inkYieldScore(heatRamp);
2603
2556
  var src = file.source;
2604
2557
 
2605
2558
  var syn = lexFile(file);
@@ -2685,7 +2638,7 @@ async function afterpackInflateBase64Gzip(b64) {
2685
2638
  function unlitInner(a, b, directive) {
2686
2639
  if (!syn) {
2687
2640
  return '<span class="unlit"><span class="tok tok-unlit" tabindex="-1" data-unlit="' + a + '" data-ue="' + b +
2688
- '" data-ut="?" title="Not attributed — click to see why">' + escapeHtml(src.slice(a, b)) + "</span></span>";
2641
+ '" data-ut="?" title="Nothing recorded. Click for details.">' + escapeHtml(src.slice(a, b)) + "</span></span>";
2689
2642
  }
2690
2643
  var out = "", ti = tokAt(a);
2691
2644
  while (a < b) {
@@ -2704,11 +2657,9 @@ async function afterpackInflateBase64Gzip(b64) {
2704
2657
  } else {
2705
2658
  var cls = colored ? SYN_CLASS[t] : null;
2706
2659
  var dirAttr = directive ? ' data-directive="' + directive.kind + '"' : "";
2707
- var dirTitle = directive
2708
- ? escapeAttr(" — Directive: /* @afterpack " + directive.keyword + " */")
2709
- : "";
2660
+ var tokTitle = "Nothing recorded. Click for details." + (directive ? " · Directive: @afterpack " + directive.keyword : "");
2710
2661
  out += '<span class="tok tok-unlit' + (cls ? " " + cls : "") + '" tabindex="-1" data-unlit="' + a +
2711
- '" data-ut="' + t + '"' + dirAttr + ' title="Not attributed — ' + TOKEN_KIND[t] + dirTitle + '">' + piece + "</span>";
2662
+ '" data-ut="' + t + '"' + dirAttr + ' title="' + escapeAttr(tokTitle) + '">' + piece + "</span>";
2712
2663
  }
2713
2664
  a = stop; ti++;
2714
2665
  }
@@ -2716,69 +2667,55 @@ async function afterpackInflateBase64Gzip(b64) {
2716
2667
  }
2717
2668
 
2718
2669
  var lineChunks = [[]];
2719
- var lineWSum = [0];
2720
- var lineWLen = [0];
2721
2670
  var lineDir = [false];
2722
2671
 
2723
2672
  file.mergedRuns.forEach(function (run) {
2724
2673
  var text = src.slice(run.start, run.end);
2725
2674
  var region = regionByIdx(file, run.regionIdx);
2726
- var preserved = isPreservedRegion(region);
2727
- var metric = region && !preserved ? metricForRegion(region) : 0;
2728
- var renamedOnly = !region && run.renamedIdx != null;
2729
- var extractedOnly = !region && run.extractedIdx != null;
2730
- var extracted = extractedOnly ? file.extractedRanges[run.extractedIdx] : null;
2731
- var bg = "transparent", dataClass = "", extraCls = "";
2732
- if (region) {
2733
- if (preserved) {
2734
- dataClass = "preserved";
2735
- extraCls = " tok-preserved";
2736
- } else {
2737
- bg = hexToRgba(rampColor(heatRamp, metric / 100), tokenAlpha(metric));
2738
- dataClass = region.raw.reversalClass || "";
2739
- if (metric >= inkYield) extraCls += " tok-ink-yield";
2740
- }
2741
- } else if (extractedOnly) {
2742
- bg = hexToRgba(renamedHex, EXTRACTED_WASH_ALPHA);
2743
- extraCls = " tok-extracted";
2744
- dataClass = "renamed-encoded";
2745
- } else if (renamedOnly) {
2746
- bg = hexToRgba(renamedHex, RENAMED_WASH_ALPHA);
2747
- extraCls = " tok-renamed";
2748
- }
2675
+ var paint = runPaint(run, region);
2676
+ var extracted = !region && run.extractedIdx != null ? file.extractedRanges[run.extractedIdx] : null;
2677
+ var renamedOnly = !region && !extracted && run.renamedIdx != null;
2749
2678
  var spotlight = run.spotlightIdx != null ? file.spotlights[run.spotlightIdx] : null;
2750
- var attributed = !!region || !!spotlight || extractedOnly || renamedOnly;
2679
+ var attributed = !!region || !!spotlight || !!extracted || renamedOnly || run.cx != null;
2751
2680
  var directive = run.directiveIdx != null ? file.directives[run.directiveIdx] : null;
2752
2681
  var perToken = !attributed;
2753
- var cls = "tok" + extraCls + (attributed ? " tok-hot" : " tok-unlit unlit") + (spotlight ? " spot-" + spotlight.raw.severity : "");
2682
+ var nameMark = CX_LANE && paint.band === "none" && run.named && !spotlight;
2683
+ var cls = "tok" + (paint.cls ? " " + paint.cls : "") + (nameMark ? " tok-named" : "") + (attributed ? " tok-hot" : " tok-unlit unlit") + (spotlight ? " spot-" + spotlight.raw.severity : "");
2754
2684
 
2685
+ var classLabel = region && CLASS_META[region.raw.reversalClass] ? CLASS_META[region.raw.reversalClass].label : null;
2755
2686
  var titleParts = [];
2756
- titleParts.push(region
2757
- ? (preserved
2758
- ? (region.raw.preservedReason ? "Preserved — must stay literal · " + humanize(region.raw.preservedReason) : "Preserved — readable, not obscured")
2759
- : (CLASS_META[region.raw.reversalClass] ? CLASS_META[region.raw.reversalClass].label : region.raw.reversalClass) + " · score " + region.raw.score)
2760
- : extractedOnly
2761
- ? (extracted && extracted.kind === "global"
2762
- ? "Global reference extracted into the constant pool — the name is gone from this access site"
2763
- : "Property name extracted into the constant pool — the name is gone from this access site")
2764
- : renamedOnly
2765
- ? "Renamed identifier — original name not in your output (baseline, low-value protection)"
2766
- : "Not attributed — click to see what this token is and what the map can (and cannot) say about it");
2767
- if (spotlight) titleParts.push((SEVERITY_LABEL[spotlight.raw.severity] || spotlight.raw.severity) + ": " + (spotlight.raw.reason || ""));
2768
- if (directive) titleParts.push("Directive: /* @afterpack " + directive.keyword + " */");
2769
-
2770
- var bgCss = bg === "transparent" ? "" : bg;
2687
+ var nameNote = CX_LANE && run.named ? (run.named === "hidden" ? "Hidden name" : "Renamed") : null;
2688
+ if (paint.bucket === "readable") {
2689
+ var why = preservedReasonText(region.raw.preservedReason);
2690
+ titleParts.push(why ? "Left readable: " + why : "Left readable");
2691
+ } else if (run.cx != null && paint.band !== "names") {
2692
+ titleParts.push("Complexity " + fmtCx(run.cx) + (classLabel ? " · " + classLabel : ""));
2693
+ } else if (region) {
2694
+ titleParts.push((CX_LANE ? "Complexity not recorded" : "Protected") + (classLabel ? " · " + classLabel : ""));
2695
+ } else if (extracted) {
2696
+ titleParts.push("Hidden name: looked up from a shared table");
2697
+ nameNote = null;
2698
+ } else if (renamedOnly) {
2699
+ titleParts.push("Renamed");
2700
+ nameNote = null;
2701
+ } else {
2702
+ titleParts.push("Nothing recorded. Click for details.");
2703
+ }
2704
+ if (nameNote) titleParts.push(nameNote);
2705
+ if (spotlight) titleParts.push("Weak spot: " + (SEVERITY_LABEL[spotlight.raw.severity] || "readable text").toLowerCase());
2706
+ if (directive) titleParts.push("Directive: @afterpack " + directive.keyword);
2771
2707
 
2772
2708
  var attrs = 'class="' + cls + '"' + (attributed ? ' tabindex="0" role="button"' : ' tabindex="-1"') +
2773
- (bgCss ? ' style="background:' + bgCss + '"' : "") +
2774
2709
  ' data-region-idx="' + (run.regionIdx == null ? "" : run.regionIdx) + '"' +
2775
2710
  ' data-spotlight-idx="' + (run.spotlightIdx == null ? "" : run.spotlightIdx) + '"' +
2776
2711
  (run.renamedIdx == null ? "" : ' data-renamed-idx="' + run.renamedIdx + '"') +
2777
2712
  (run.extractedIdx == null ? "" : ' data-extracted-idx="' + run.extractedIdx + '"') +
2713
+ (run.cx == null ? "" : ' data-cx="' + run.cx + '"') +
2714
+ (run.declIdx == null ? "" : ' data-decl-idx="' + run.declIdx + '"') +
2778
2715
  (attributed ? "" : ' data-unlit="' + run.start + '" data-ue="' + run.end + '" data-ut="?"') +
2779
2716
  (directive ? ' data-directive="' + directive.kind + '"' : "") +
2780
- (dataClass ? ' data-class="' + dataClass + '"' : "") +
2781
- ' title="' + escapeAttr(titleParts.join(" — ")) + '"';
2717
+ (paint.band ? ' data-band="' + paint.band + '"' : "") +
2718
+ ' title="' + escapeAttr(titleParts.join(" · ")) + '"';
2782
2719
 
2783
2720
  var pin = run.isSpotlightStart ? WARN_ICON : "";
2784
2721
  var segments = text.split("\n");
@@ -2793,10 +2730,8 @@ async function afterpackInflateBase64Gzip(b64) {
2793
2730
  );
2794
2731
  if (directive) lineDir[lineDir.length - 1] = true;
2795
2732
  pin = "";
2796
- lineWLen[lineWLen.length - 1] += seg.length;
2797
- lineWSum[lineWSum.length - 1] += seg.length * metric;
2798
2733
  }
2799
- if (si < segments.length - 1) { lineChunks.push([]); lineWSum.push(0); lineWLen.push(0); lineDir.push(false); }
2734
+ if (si < segments.length - 1) { lineChunks.push([]); lineDir.push(false); }
2800
2735
  off += seg.length + 1;
2801
2736
  });
2802
2737
  });
@@ -2806,11 +2741,9 @@ async function afterpackInflateBase64Gzip(b64) {
2806
2741
 
2807
2742
  var html = lineChunks.map(function (spans, i) {
2808
2743
  var lineNo = i + 1;
2809
- var avgMetric = lineWLen[i] > 0 ? lineWSum[i] / lineWLen[i] : 0;
2810
- var lineBg = avgMetric > 0 ? hexToRgba(rampColor(heatRamp, avgMetric / 100), lineAlpha(avgMetric)) : "transparent";
2811
2744
  return '<div class="code-line' + (lineDir[i] ? " has-directive" : "") + '" data-line="' + lineNo + '">' +
2812
2745
  '<span class="ln" style="width:' + gutterWidth + 'ch">' + lineNo + "</span>" +
2813
- '<span class="lc" style="background:' + lineBg + '">' + (spans.join("") || " ") + "</span>" +
2746
+ '<span class="lc">' + (spans.join("") || " ") + "</span>" +
2814
2747
  "</div>";
2815
2748
  }).join("");
2816
2749
  codeBody.innerHTML = html;
@@ -2850,15 +2783,17 @@ async function afterpackInflateBase64Gzip(b64) {
2850
2783
  });
2851
2784
  return acc;
2852
2785
  }
2786
+ function weakBreakdown(weak, leaks) {
2787
+ var parts = [];
2788
+ if (leaks > 0) parts.push(plural(leaks, "readable string", "readable strings"));
2789
+ if (weak - leaks > 0) parts.push(plural(weak - leaks, "readable property name", "readable property names"));
2790
+ return parts.join(", ");
2791
+ }
2853
2792
  function weakBadgeHtml(weak, leaks, scope) {
2854
2793
  if (!weak) return "";
2855
- var residual = weak - leaks;
2856
- var tip = weak + " weak spot" + (weak === 1 ? "" : "s") + " " + scope + ": " +
2857
- (leaks > 0 ? leaks + " leaked literal" + (leaks === 1 ? "" : "s") : "no leaked literal") +
2858
- (residual > 0 ? ", " + residual + " residual property name" + (residual === 1 ? "" : "s") : "") +
2859
- ". A weak spot is a readable literal this build left in the output; the right rail lists every one in the open file.";
2860
- return '<span class="badge-weak' + (leaks > 0 ? " has-leak" : "") + '" data-tip="' +
2861
- escapeAttr(tip) + '">' + (leaks > 0 ? "\u26a0 " : "") + weak + "</span>";
2794
+ var tip = plural(weak, "weak spot", "weak spots") + " " + scope + ": " + weakBreakdown(weak, leaks) + ".";
2795
+ return '<span class="badge-weak' + (leaks > 0 ? " has-leak" : "") + '"' + tipAttrs(tip) + ">" +
2796
+ (leaks > 0 ? "\u26a0 " : "") + weak + "</span>";
2862
2797
  }
2863
2798
 
2864
2799
  function renderTreeChildren(node, html) {
@@ -2877,8 +2812,8 @@ async function afterpackInflateBase64Gzip(b64) {
2877
2812
  '<span class="tree-twisty" aria-hidden="true">▸</span>' +
2878
2813
  '<span class="tree-icon" aria-hidden="true">' + (expanded ? "📂" : "📁") + "</span>" +
2879
2814
  '<span class="tree-name">' + escapeHtml(child.name) + "</span>" +
2880
- (marked > 0 ? '<span class="tree-mark" data-tip="' + escapeAttr(marked + " file" + (marked === 1 ? "" : "s") +
2881
- " under this folder carry an @afterpack marker recorded over a span in this build.") + '">@' + marked + "</span>" : "") +
2815
+ (marked > 0 ? '<span class="tree-mark"' + tipAttrs(plural(marked, "file", "files") +
2816
+ " in this folder " + (marked === 1 ? "has" : "have") + " an @afterpack directive.", "directives") + ">@" + marked + "</span>" : "") +
2882
2817
  weakBadgeHtml(weakUnder.weak, weakUnder.leaks, "under this folder") +
2883
2818
  '<span class="tree-count">' + countFilesUnder(child) + "</span>" +
2884
2819
  "</button>"
@@ -2900,17 +2835,11 @@ async function afterpackInflateBase64Gzip(b64) {
2900
2835
  '<span class="tree-twisty" aria-hidden="true"></span>' +
2901
2836
  '<span class="tree-icon" aria-hidden="true">📄</span>' +
2902
2837
  '<span class="tree-name" title="' + escapeAttr(file.displayPath || file.displayName) + '">' + escapeHtml(file.displayName) + "</span>" +
2903
- (kws.length ? '<span class="tree-mark" data-tip="' + escapeAttr(file.directives.length + " @afterpack marker" +
2904
- (file.directives.length === 1 ? "" : "s") + " recorded in this file (" + kws.join(", ") +
2905
- "). The build records where markers were found; whether they changed the outcome is not recorded.") + '">@</span>' : "") +
2838
+ (kws.length ? '<span class="tree-mark"' + tipAttrs(plural(file.directives.length, "directive", "directives") +
2839
+ " here (" + kws.join(", ") + "). The map shows where each one sits, not what it changed.", "directivesCheck") + ">@</span>" : "") +
2906
2840
  weakBadgeHtml(file.weakSpotCount, file.leakCount, "in this file") +
2907
2841
  "</button>" +
2908
- '<div class="tree-file-meter' + (fileIgnored ? " is-ignored" : "") + '" style="padding-left:' + (indent + 18) + 'px"' +
2909
- ' data-tip="' + escapeAttr("Average protection score " + file.avgScore.toFixed(0) + "/100 across the spans that carry a ledger region — which is " +
2910
- (file.coverage.total > 0 ? Math.round((file.coverage.region / file.coverage.total) * 100) : 0) +
2911
- "% of this file. It is not a share of the file that is protected.") + '">' +
2912
- '<div class="meter"><i style="width:' + file.avgScore.toFixed(0) + '%;background:' + heatSolid(file.avgScore) + '"></i></div>' +
2913
- "</div>"
2842
+ fileMeterHtml(file, indent, fileIgnored)
2914
2843
  );
2915
2844
  }
2916
2845
  });
@@ -2938,11 +2867,7 @@ async function afterpackInflateBase64Gzip(b64) {
2938
2867
  document.getElementById("inspector").innerHTML = "";
2939
2868
  var inspCount = document.getElementById("inspector-count");
2940
2869
  if (inspCount) inspCount.textContent = "no selection";
2941
- document.getElementById("class-dist-bar").innerHTML = "";
2942
- document.getElementById("class-dist-rows").innerHTML = "";
2943
- document.getElementById("class-reached").innerHTML = "";
2944
- var footnote = document.getElementById("class-dist-footnote");
2945
- if (footnote) footnote.hidden = true;
2870
+ document.getElementById("class-rows").innerHTML = "";
2946
2871
  }
2947
2872
 
2948
2873
  function syncFilterButtons() {
@@ -3009,22 +2934,62 @@ async function afterpackInflateBase64Gzip(b64) {
3009
2934
  weak += f.weakSpotCount; leaks += f.leakCount;
3010
2935
  if (f.weakSpotCount > 0) filesWith++;
3011
2936
  });
3012
- el.textContent = weak > 0 ? weak + " weak spot" + (weak === 1 ? "" : "s") : "";
2937
+ el.textContent = weak > 0 ? plural(weak, "weak spot", "weak spots") : "";
3013
2938
  if (weak > 0) {
3014
- el.setAttribute("data-tip", weak + " weak spot" + (weak === 1 ? "" : "s") + " across this whole build, in " +
3015
- filesWith + " file" + (filesWith === 1 ? "" : "s") + " \u2014 " + leaks + " leaked literal" + (leaks === 1 ? "" : "s") +
3016
- " and " + (weak - leaks) + " residual property name" + (weak - leaks === 1 ? "" : "s") +
3017
- ". This is the number the dashboard's \u201cWeak spots\u201d tile shows; the Weak filter lists exactly these files.");
2939
+ el.setAttribute("data-tip", plural(weak, "weak spot", "weak spots") + " in " + plural(filesWith, "file", "files") + ": " +
2940
+ weakBreakdown(weak, leaks) + ". The Weak filter lists these files.");
2941
+ el.setAttribute("data-doc", "lightDefault");
3018
2942
  } else {
3019
2943
  el.removeAttribute("data-tip");
2944
+ el.removeAttribute("data-doc");
3020
2945
  }
3021
2946
  }
3022
2947
 
2948
+ function engineOf(file) { return DATA.engine || (file && file.doc.engine) || {}; }
2949
+ function buildTarget() {
2950
+ var t = engineOf(activeFile()).complexity;
2951
+ return typeof t === "number" && isFinite(t) ? t : null;
2952
+ }
2953
+ function targetSentence() {
2954
+ var t = buildTarget();
2955
+ return t != null ? "This build targeted " + fmtCx(t) + "." : "";
2956
+ }
2957
+ var BUILD_CX = (function () {
2958
+ var sum = 0, n = 0;
2959
+ FILES.forEach(function (f) {
2960
+ if (f.isMachineryFile) return;
2961
+ sum += f.cxSum;
2962
+ n += f.cxCount;
2963
+ });
2964
+ return { hasLane: CX_LANE, avg: n ? sum / n : null, count: n };
2965
+ })();
2966
+ var SCORES_ARE_RATES = (function () {
2967
+ var v = /^(\d+)\.(\d+)\.(\d+)/.exec(String(engineOf(FILES[0] || null).version || ""));
2968
+ if (v && (Number(v[1]) > 0 || Number(v[2]) > 1 || (Number(v[2]) === 1 && Number(v[3]) >= 1))) return true;
2969
+ return FILES.some(function (f) {
2970
+ return f.regions.some(function (r) {
2971
+ return (r.raw.lineage || []).some(function (s) { return typeof s.credit === "number" && s.credit > 0; });
2972
+ });
2973
+ });
2974
+ })();
2975
+ function scorePct(score) { return score >= 100 ? "99%+" : Math.round(score) + "%"; }
2976
+
2977
+ function fileMeterHtml(file, indent, ignored) {
2978
+ var c = file.coverage;
2979
+ var share = c.total > 0 ? c.protected / c.total : 0;
2980
+ var shareText = Math.round(share * 100) + "% of this file is protected.";
2981
+ var hasAvg = BUILD_CX.hasLane && file.cxAvg != null;
2982
+ var tip = hasAvg
2983
+ ? "Average complexity " + fmtCx(file.cxAvg) + ". " + targetSentence() + " " + shareText
2984
+ : shareText + (BUILD_CX.hasLane ? "" : " This map doesn't record complexity per token.");
2985
+ return '<div class="tree-file-meter' + (ignored ? " is-ignored" : "") + '" style="padding-left:' + (indent + 18) + 'px"' +
2986
+ tipAttrs(tip.replace(/\s+/g, " ").trim(), "complexity") + ">" +
2987
+ '<div class="meter"><i data-band="' + (hasAvg ? complexityBand(file.cxAvg) : BUILD_CX.hasLane ? "none" : "protected") +
2988
+ '" style="width:' + (share * 100).toFixed(1) + '%"></i></div></div>';
2989
+ }
2990
+
3023
2991
  function renderFileSummary(file) {
3024
2992
  var f = file.doc.file || {};
3025
- var a = file.doc.aggregate || {};
3026
- var cs = a.classSummary || {};
3027
-
3028
2993
  var full = file.displayPath || file.displayName || "";
3029
2994
  var name = file.displayName || full;
3030
2995
  var dir = full.length > name.length ? full.slice(0, full.length - name.length) : "";
@@ -3032,123 +2997,101 @@ async function afterpackInflateBase64Gzip(b64) {
3032
2997
  (dir ? '<span class="fs-dir">' + escapeHtml(dir) + "</span>" : "") +
3033
2998
  '<span class="fs-name">' + escapeHtml(name) + "</span>";
3034
2999
  var copyBtn = document.getElementById("copy-path");
3035
- if (copyBtn) {
3036
- copyBtn.setAttribute("data-copy", encodeURIComponent(full));
3037
- copyBtn.setAttribute("data-tip", "Copy the full path: " + full);
3000
+ if (copyBtn) copyBtn.setAttribute("data-copy", encodeURIComponent(full));
3001
+
3002
+ var target = buildTarget();
3003
+ var rows = [];
3004
+ if (BUILD_CX.hasLane) {
3005
+ rows.push(file.cxAvg != null
3006
+ ? { k: "Complexity", html: cxDotHtml(complexityBand(file.cxAvg)) + escapeHtml(fmtCx(file.cxAvg)),
3007
+ tip: "Average complexity of this file's protected code. " + targetSentence(), doc: "complexity" }
3008
+ : { k: "Complexity", v: "—", dim: true, tip: "No complexity was recorded for this file.", doc: "complexity" });
3009
+ } else if (target != null) {
3010
+ rows.push({ k: "Complexity target", v: fmtCx(target), tip: INSP_COPY.target + " " + INSP_COPY.noComplexity, doc: "complexity" });
3038
3011
  }
3039
3012
 
3040
- var maxCls = cs.maxClassReached;
3041
- var maxClsHtml = maxCls ? classChipHtml(maxCls, false) : "—";
3042
-
3043
- var est = f.outputSizeEstimated ? " (est.)" : "";
3044
- var bundledIn = f.bundledInputSize != null ? f.bundledInputSize : f.inputSize;
3045
- var sizeTip = "Bundled " + fmtBytes(bundledIn) + " → output " + fmtBytes(f.outputSize) + est +
3046
- (f.outputSizeEstimated
3047
- ? ". Output is this file's share of the chunk's MEASURED size, apportioned by how many of " +
3048
- "the chunk's bundled bytes came from this source — so the ratio is output ÷ bundled input, " +
3049
- "comparable to the build's headline ratio. The estimate is the one assumption left: " +
3050
- "inflation is taken as uniform within a chunk. Machinery the build ships once for the " +
3051
- "whole bundle — string pool, helpers, bootstrap — is carried as its own separate entry, " +
3052
- "not folded into any source file."
3053
- : "");
3054
- var sizeVal = f.inflationRatio != null ? f.inflationRatio.toFixed(2) + "×" : "—";
3055
-
3056
- var leaks = file.leakCount;
3057
- var weak = file.weakSpotCount;
3058
- var weakTip = weak + " weak spot" + (weak === 1 ? "" : "s") + " in THIS file (" + leaks + " leaked literal" +
3059
- (leaks === 1 ? "" : "s") + ", " + (weak - leaks) + " residual property name" + (weak - leaks === 1 ? "" : "s") +
3060
- "), listed in full below. The file-tree header counts them across the whole build, which is why the two numbers differ.";
3061
- var renamed = file.renamedCount || 0;
3062
-
3063
3013
  var cov = file.coverage;
3064
- var covPct = cov.total > 0 ? Math.round((cov.region / cov.total) * 100) : 0;
3065
- var covShare = function (n) { return cov.total > 0 ? Math.round((n / cov.total) * 100) : 0; };
3066
- var covTip = "Share of this file's characters carrying a ledger region: " + covPct +
3067
- "%. Extracted-only: " + covShare(cov.extracted || 0) + "%. Renamed-only: " + covShare(cov.renamed) +
3068
- "%. The rest is syntax, preserved names, comments, or code your bundler removed — a region is recorded only where a transform cleared the entropy funnel, so a large plain share is normal.";
3014
+ var covPct = cov.total > 0 ? Math.round((cov.protected / cov.total) * 100) : 0;
3015
+ rows.push({ k: "Protected", v: covPct + "%", doc: "readMap",
3016
+ tip: "Share of this file inside protected code. Keywords and punctuation often stay as written, so 100% isn't expected." });
3017
+
3018
+ var renamed = file.renamedCount || 0, extracted = file.extractedCount || 0;
3019
+ rows.push({ k: "Names hidden", v: fmtNum(renamed + extracted), doc: "cfgRename",
3020
+ tip: "Names renamed (" + fmtNum(renamed) + ") or moved to a shared lookup table (" + fmtNum(extracted) + "). Light protection on its own." });
3021
+
3022
+ var leaks = file.leakCount, weak = file.weakSpotCount;
3023
+ rows.push({ k: "Weak spots", v: fmtNum(weak) + (leaks > 0 ? " ⚠" : ""), warn: leaks > 0, doc: "lightDefault",
3024
+ tip: weak > 0 ? "Text still readable in your output: " + weakBreakdown(weak, leaks) + ". Listed below."
3025
+ : "No readable text from this file was found in your output." });
3026
+
3027
+ if (f.inflationRatio != null) {
3028
+ rows.push({ k: "Size", v: (f.outputSizeEstimated ? "≈" : "") + f.inflationRatio.toFixed(2) + "×", doc: "sizeBudget",
3029
+ tip: "Output size ÷ input size for this file." + (f.outputSizeEstimated ? " Estimated, because several files share one output file." : "") });
3030
+ }
3069
3031
 
3070
- var rows = [
3071
- { k: "Max class", html: maxClsHtml, tip: "The strongest reversal class any region in this file reached." },
3072
- { k: "Attributed", v: covPct + "%", tip: covTip },
3073
- { k: "Extracted", v: fmtNum(file.extractedCount || 0), tip: "Property names and free globals hoisted into the constant pool and reached through a computed lookup — the name is gone from every access site. One tier above renaming, still injective (the pool holds each name literally)." },
3074
- { k: "Renamed", v: fmtNum(renamed), tip: "Identifiers renamed under this build's seed — the low-value baseline layer. Real protection is the hardened regions (materialization / control-flow / MBA)." },
3075
- { k: "Transforms", v: fmtNum(a.totalTransforms), tip: "Total transform passes applied across this file." },
3076
- { k: "Weak spots", v: fmtNum(weak) + (leaks > 0 ? " ⚠" : ""), warn: leaks > 0, tip: weakTip },
3077
- { k: "Size cost" + est, v: sizeVal, tip: sizeTip }
3078
- ];
3079
3032
  document.getElementById("file-summary-metrics").innerHTML = rows.map(function (r) {
3080
- return '<div class="fb-row" data-tip="' + escapeAttr(r.tip) + '">' +
3033
+ return '<div class="fb-row"' + tipAttrs(r.tip, r.doc) + ">" +
3081
3034
  '<span class="k">' + escapeHtml(r.k) + "</span>" +
3082
- '<span class="v' + (r.warn ? " is-warn" : "") + '">' +
3035
+ '<span class="v' + (r.warn ? " is-warn" : "") + (r.dim ? " is-dim" : "") + '">' +
3083
3036
  (r.html != null ? r.html : escapeHtml(String(r.v))) + "</span></div>";
3084
3037
  }).join("");
3085
3038
  }
3086
3039
 
3087
- function renderMapSize() {
3088
- var el = document.getElementById("map-size");
3040
+ function renderPrivacyTag() {
3041
+ var el = document.getElementById("private-tag");
3089
3042
  if (!el) return;
3090
- if (MAP_BYTES == null) { el.textContent = "—"; return; }
3091
- el.textContent = "Map " + fmtBytes(MAP_BYTES);
3092
- el.setAttribute("data-tip",
3093
- "The Protection Map data embedded in this page: " + fmtNum(MAP_BYTES) + " bytes of " + MAP_ENCODING +
3094
- ", covering " + fmtNum(FILES.length) + " file" + (FILES.length === 1 ? "" : "s") +
3095
- ". The viewer itself is not counted. This artifact is a DEV-ONLY build output — it carries your original source, so keep it out of anything you publish.");
3043
+ el.setAttribute("data-tip", "This report contains your original source code. Don't deploy, publish or commit it." +
3044
+ (MAP_BYTES != null ? " (" + plural(FILES.length, "file", "files") + ", " + fmtBytes(MAP_BYTES) + ")" : ""));
3096
3045
  }
3097
3046
 
3098
- function renderClassDist(file) {
3047
+ function renderBuildComplexity() {
3048
+ var el = document.getElementById("build-cx");
3049
+ if (!el) return;
3050
+ var t = buildTarget();
3051
+ var preset = engineOf(activeFile()).preset;
3052
+ var tip;
3053
+ if (BUILD_CX.hasLane && BUILD_CX.avg != null) {
3054
+ el.innerHTML = cxDotHtml(complexityBand(BUILD_CX.avg)) + 'Complexity <span class="tag-em">' + escapeHtml(fmtCx(BUILD_CX.avg)) + "</span>" +
3055
+ (t != null ? " · target " + escapeHtml(fmtCx(t)) : "");
3056
+ tip = "Average complexity of your code in this build" + (t != null ? ", next to the target set by --complexity or your preset" : "") +
3057
+ ". Higher means harder to reverse.";
3058
+ } else if (t != null) {
3059
+ el.innerHTML = 'Complexity target <span class="tag-em">' + escapeHtml(fmtCx(t)) + "</span>" +
3060
+ (preset ? " · " + escapeHtml(String(preset)) : "");
3061
+ tip = INSP_COPY.target + " " + INSP_COPY.noComplexity;
3062
+ } else {
3063
+ el.hidden = true;
3064
+ return;
3065
+ }
3066
+ el.hidden = false;
3067
+ el.setAttribute("data-tip", tip);
3068
+ el.setAttribute("data-doc", "complexity");
3069
+ }
3070
+
3071
+ function classCounts(file) {
3099
3072
  var raw = (file.doc.aggregate && file.doc.aggregate.classSummary) || {};
3100
- var adjustedPreserved = Math.max(0, (raw.preserved || 0) - (file.machinery ? 1 : 0));
3101
- var counts = {
3102
- "preserved": adjustedPreserved,
3073
+ return {
3074
+ "preserved": Math.max(0, (raw.preserved || 0) - (file.machinery ? 1 : 0)),
3103
3075
  "renamed-encoded": raw["renamed-encoded"] || 0,
3104
3076
  "flattened-fused": raw["flattened-fused"] || 0,
3105
3077
  "destroyed-fused": raw["destroyed-fused"] || 0
3106
3078
  };
3107
- var total = counts["preserved"] + counts["renamed-encoded"] + counts["flattened-fused"] + counts["destroyed-fused"];
3108
-
3109
- document.getElementById("class-dist-bar").innerHTML = CLASS_ORDER.map(function (cls) {
3110
- var n = counts[cls];
3111
- if (!n) return "";
3112
- var pct = total > 0 ? (n / total * 100) : 0;
3113
- return '<i data-class="' + cls + '" style="width:' + pct.toFixed(2) + '%" title="' + escapeAttr(CLASS_META[cls].label + ": " + n) + '"></i>';
3114
- }).join("");
3115
-
3116
- document.getElementById("class-dist-rows").innerHTML = CLASS_ORDER.map(function (cls) {
3117
- return '<li class="class-dist-row">' + classChipHtml(cls, counts[cls] === 0) + '<span class="class-dist-count">' + counts[cls] + "</span></li>";
3118
- }).join("");
3119
-
3120
- var maxCls = raw.maxClassReached;
3121
- document.getElementById("class-reached").innerHTML = maxCls ? "Reached this build: " + classChipHtml(maxCls, false) : "";
3122
-
3123
- var footnote = document.getElementById("class-dist-footnote");
3124
- if (file.machinery && (raw.preserved || 0) > 0 && adjustedPreserved === 0) {
3125
- footnote.hidden = false;
3126
- footnote.textContent = "No user code was left preserved in this build — the \"" + (raw.preserved) + " preserved\" the engine reports is entirely the whole-file scaffolding bucket, excluded from this count.";
3127
- } else {
3128
- footnote.hidden = true;
3129
- }
3130
3079
  }
3131
-
3132
- function renderClassLegendStatic() {
3133
- var totals = { "preserved": 0, "renamed-encoded": 0, "flattened-fused": 0, "destroyed-fused": 0 };
3134
- FILES.forEach(function (f) {
3135
- var cs = (f.doc.aggregate && f.doc.aggregate.classSummary) || {};
3136
- CLASS_ORDER.forEach(function (cls) { totals[cls] += cs[cls] || 0; });
3137
- });
3138
- document.getElementById("class-legend").innerHTML = CLASS_ORDER.map(function (cls) {
3139
- var reached = totals[cls] > 0;
3140
- return '<li class="class-legend-row" tabindex="0" data-tip="' + escapeAttr(CLASS_META[cls].note) + '">' +
3141
- classChipHtml(cls, !reached) +
3142
- '<span class="class-legend-flag">' + (reached ? "reached" : "ceiling") + "</span>" +
3143
- "</li>";
3080
+ function renderClassDist(file) {
3081
+ var counts = classCounts(file);
3082
+ document.getElementById("class-rows").innerHTML = CLASS_ORDER.filter(function (cls) {
3083
+ return cls !== "destroyed-fused" || counts[cls] > 0;
3084
+ }).map(function (cls) {
3085
+ return '<li class="class-row">' + classChipHtml(cls, counts[cls] === 0) +
3086
+ '<span class="class-row-count">' + escapeHtml(plural(counts[cls], "area", "areas")) + "</span></li>";
3144
3087
  }).join("");
3145
3088
  }
3146
3089
 
3147
3090
  var DIRECTIVE_LEGEND_META = {
3148
- skip: "skip — asks for the span to stay readable",
3149
- hardened: "hardened — asks for the flattened-fused class",
3150
- destroy: "destroy — asks for the strongest, destroyed-fused class",
3151
- custom: "custom target/floor/deny — an explicit per-region override written on the marker"
3091
+ skip: "skip: keep this readable",
3092
+ hardened: "hardened: stronger protection",
3093
+ destroy: "destroy: strongest protection",
3094
+ custom: "custom: its own settings, such as preset=hard"
3152
3095
  };
3153
3096
  var DIRECTIVE_LEGEND_ORDER = ["skip", "hardened", "destroy", "custom"];
3154
3097
  function renderDirectiveLegend() {
@@ -3167,28 +3110,48 @@ async function afterpackInflateBase64Gzip(b64) {
3167
3110
  }).join("");
3168
3111
  }
3169
3112
 
3113
+ function legendRowHtml(cls, label) {
3114
+ return '<div class="cx-legend-row"><span class="cx-swatch tok ' + cls + '">abc</span>' + escapeHtml(label) + "</div>";
3115
+ }
3170
3116
  function renderLegend() {
3171
- var bar = document.getElementById("legend-bar");
3172
- var labels = document.getElementById("legend-labels");
3173
- var ramp = currentRamp("heat");
3174
- var stops = ramp.map(function (c, i) { return c + " " + ((i / (ramp.length - 1)) * 100).toFixed(1) + "%"; });
3175
- bar.style.background = "linear-gradient(to right, " + stops.join(", ") + ")";
3176
- labels.innerHTML = "<span>low in file</span><span>high in file</span>";
3117
+ var rows = [];
3118
+ if (BUILD_CX.hasLane) {
3119
+ CX_BANDS.forEach(function (b) { rows.push(legendRowHtml("cx-" + b.band, "Complexity " + b.label)); });
3120
+ rows.push(legendRowHtml("cx-none", "No complexity added"));
3121
+ rows.push(legendRowHtml("cx-none tok-named", "Name hidden, nothing more"));
3122
+ rows.push(legendRowHtml("tok-preserved", "Left readable on purpose"));
3123
+ } else {
3124
+ rows.push(legendRowHtml("tok-preserved", "Left readable on purpose"));
3125
+ rows.push(legendRowHtml("cx-names", "Names hidden only"));
3126
+ rows.push(legendRowHtml("cx-protected", "Protected"));
3127
+ }
3128
+ rows.push(legendRowHtml("tok-unlit", "Nothing recorded"));
3129
+ document.getElementById("cx-legend").innerHTML = rows.join("");
3130
+ var t = buildTarget();
3131
+ var note = BUILD_CX.hasLane
3132
+ ? "Hotter means more complex, so harder to reverse. Red is strong, not a problem." +
3133
+ (BUILD_CX.avg != null ? " This build: average " + fmtCx(BUILD_CX.avg) + (t != null ? ", target " + fmtCx(t) : "") + "." : "")
3134
+ : "This map doesn't record complexity per token, so all protected code shares one color." +
3135
+ (t != null ? " This build targeted " + fmtCx(t) + "." : "");
3136
+ var noteEl = document.getElementById("cx-legend-note");
3137
+ noteEl.innerHTML = escapeHtml(note) + " " + docLinkHtml(BUILD_CX.hasLane ? "complexityWhat" : "complexity", "Learn more");
3177
3138
  }
3178
3139
 
3179
3140
  function renderEngineInfo(file) {
3180
- var e = DATA.engine || file.doc.engine || {};
3181
- var schema = DATA.schemaVersion != null ? DATA.schemaVersion : file.doc.schemaVersion;
3182
- var origin = sourceOriginOf(file);
3141
+ var e = engineOf(file);
3183
3142
  var rows = [
3184
- ["backend", e.backend], ["preset", e.preset], ["seed", e.seed],
3185
- ["materialize", e.materialize === true ? "on" : e.materialize === false ? "off" : "—"],
3186
- ["complexity", e.complexity], ["engine version", e.version],
3187
- ["source origin", origin],
3188
- ["schema", schema != null ? "v" + schema : "—"]
3143
+ { k: "Preset", v: e.preset, tip: "The protection level this build used.", doc: "ladder" },
3144
+ { k: "Complexity target", v: typeof e.complexity === "number" ? fmtCx(e.complexity) : null, tip: INSP_COPY.target, doc: "cfgComplexity" }
3189
3145
  ];
3146
+ if (BUILD_CX.hasLane) {
3147
+ rows.push({ k: "Average complexity", v: BUILD_CX.avg != null ? fmtCx(BUILD_CX.avg) : null,
3148
+ tip: "Average complexity of your code across this build.", doc: "complexity" });
3149
+ }
3150
+ rows.push({ k: "Seed", v: e.seed, tip: "A new seed each build makes the output different every time.", doc: "cfgSeed" });
3151
+ rows.push({ k: "Engine version", v: e.version });
3190
3152
  document.getElementById("engine-info").innerHTML = rows.map(function (r) {
3191
- return "<dt>" + escapeHtml(r[0]) + "</dt><dd>" + escapeHtml(r[1] == null ? "—" : String(r[1])) + "</dd>";
3153
+ return "<dt" + (r.tip ? tipAttrs(r.tip, r.doc) + ' tabindex="0"' : "") + ">" + escapeHtml(r.k) + "</dt><dd>" +
3154
+ escapeHtml(r.v == null || r.v === "" ? "—" : String(r.v)) + "</dd>";
3192
3155
  }).join("");
3193
3156
  }
3194
3157
 
@@ -3220,8 +3183,8 @@ async function afterpackInflateBase64Gzip(b64) {
3220
3183
  list.style.marginTop = "0";
3221
3184
  var elsewhere = 0;
3222
3185
  FILES.forEach(function (f) { if (f.fileIdx !== file.fileIdx) elsewhere += f.weakSpotCount; });
3223
- list.innerHTML = '<p class="empty-note-ok"><span class="ok-check">✓</span>None recorded in this file.' +
3224
- (elsewhere > 0 ? " " + elsewhere + " elsewhere in this build — use the <strong>Weak</strong> file filter." : "") +
3186
+ list.innerHTML = '<p class="empty-note-ok"><span class="ok-check">✓</span>None in this file.' +
3187
+ (elsewhere > 0 ? " " + escapeHtml(plural(elsewhere, "weak spot", "weak spots")) + " in other files: use the <strong>Weak</strong> filter." : "") +
3225
3188
  "</p>";
3226
3189
  setWeakSpotsEmpty(true);
3227
3190
  return;
@@ -3233,154 +3196,145 @@ async function afterpackInflateBase64Gzip(b64) {
3233
3196
  list.innerHTML = file.spotlights.map(function (s) {
3234
3197
  var sev = s.raw.severity;
3235
3198
  var icon = SEVERITY_ICON[sev] || "⚠";
3236
- var mech = s.raw.mechanism || "";
3237
- var mechHuman = mech ? humanize(mech) : "";
3238
- var tail = s.raw.bytes != null ? s.raw.bytes + " B" : "";
3199
+ var why = mechanismText(s.raw.mechanism);
3200
+ var help = SEVERITY_HELP[sev];
3201
+ var actions = (s.positioned ? '<button type="button" class="mini-btn" data-jump-spotlight="' + s.idx + '">Show in code</button>' : "") +
3202
+ (help ? docLinkHtml(help.doc, help.label) : "");
3239
3203
  return '<details class="weakspot" data-spot-idx="' + s.idx + '">' +
3240
3204
  '<summary class="weakspot-summary">' +
3241
- '<span class="weakspot-sev pill pill-' + sev + '" title="' + escapeAttr(SEVERITY_LABEL[sev] || sev) + '">' + icon + "</span>" +
3205
+ '<span class="weakspot-sev pill pill-' + escapeAttr(sev || "") + '" title="' + escapeAttr(SEVERITY_LABEL[sev] || "Readable text") + '">' + icon + "</span>" +
3242
3206
  '<span class="weakspot-sample">' + escapeHtml(s.raw.sample || "") + "</span>" +
3243
- (tail ? '<span class="weakspot-tail">' + escapeHtml(tail) + "</span>" : "") +
3244
3207
  "</summary>" +
3245
3208
  '<div class="weakspot-body">' +
3246
- '<p class="weakspot-reason">' + escapeHtml(s.raw.reason || "") + "</p>" +
3247
- (mech ? '<p class="weakspot-reason">' + escapeHtml(mechHuman) + "</p>" : "") +
3248
- '<p class="weakspot-kv">disposition: <strong>' + escapeHtml(s.raw.disposition || "—") + "</strong>" +
3249
- (mech ? ' · mechanism: <strong data-tip="' + escapeAttr(mech) + '">' + escapeHtml(mech) + "</strong>" : "") +
3250
- (s.raw.bytes != null ? " · " + s.raw.bytes + " bytes" : "") + "</p>" +
3251
- '<div class="cta"><button type="button" class="mini-btn" data-jump-spotlight="' + s.idx + '">Jump to code &amp; inspect</button></div>' +
3209
+ '<p class="weakspot-reason">' + escapeHtml(SEVERITY_BODY[sev] || SEVERITY_BODY.weak) + "</p>" +
3210
+ (why ? '<p class="weakspot-reason">' + escapeHtml(why) + "</p>" : "") +
3211
+ (s.positioned ? "" : '<p class="weakspot-reason">' + escapeHtml(INSP_COPY.noPosition) + "</p>") +
3212
+ (actions ? '<div class="insp-actions">' + actions + "</div>" : "") +
3252
3213
  "</div>" +
3253
3214
  "</details>";
3254
3215
  }).join("");
3255
3216
  }
3256
3217
 
3257
- function collapseLineage(lineage) {
3258
- var groups = [];
3218
+ function groupLineage(lineage) {
3219
+ var groups = [], byName = Object.create(null);
3259
3220
  lineage.forEach(function (step) {
3260
- var last = groups[groups.length - 1];
3261
- if (last && last.transform === step.transform) {
3262
- last.count++;
3263
- last.entropyGain += step.entropyGain || 0;
3264
- last.sizeDeltaEst += step.sizeDeltaEst || 0;
3221
+ var key = step.transform || "?";
3222
+ var g = byName[key];
3223
+ if (g) {
3224
+ g.count++;
3225
+ g.sizeDeltaEst += step.sizeDeltaEst || 0;
3226
+ if (g.credit == null && step.credit != null) g.credit = step.credit;
3265
3227
  } else {
3266
- groups.push({ transform: step.transform, category: step.category, phase: step.phase, count: 1, entropyGain: step.entropyGain || 0, sizeDeltaEst: step.sizeDeltaEst || 0 });
3228
+ g = byName[key] = { transform: key, category: step.category, phase: step.phase, count: 1, sizeDeltaEst: step.sizeDeltaEst || 0, credit: step.credit };
3229
+ groups.push(g);
3267
3230
  }
3268
3231
  });
3269
3232
  return groups;
3270
3233
  }
3271
3234
 
3272
- var CHAIN_VISIBLE_CAP = 5;
3235
+ function creditPct(permille) {
3236
+ if (typeof permille !== "number" || isNaN(permille) || permille <= 0) return null;
3237
+ var p = permille / 10;
3238
+ return (p >= 10 ? Math.round(p) : Math.round(p * 10) / 10) + "%";
3239
+ }
3240
+ function breakCamel(name) { return escapeHtml(name).replace(/([a-z0-9])([A-Z])/g, "$1<wbr>$2"); }
3241
+
3242
+ var CHAIN_VISIBLE_CAP = 6;
3273
3243
  function chainStepHtml(g) {
3274
- var cat = CATEGORY_LABEL[g.category] || (g.category || "").toLowerCase();
3275
- var caption = [cat, g.phase].filter(Boolean).join(" · ");
3276
- var delta = [];
3277
- if (g.sizeDeltaEst) delta.push((g.sizeDeltaEst >= 0 ? "+" : "") + g.sizeDeltaEst + "B");
3244
+ var cat = categoryMeta(g);
3245
+ var credit = creditPct(g.credit);
3246
+ var caption = [];
3247
+ if (cat) caption.push("<span" + (cat.tip ? tipAttrs(cat.tip, cat.doc) : "") + ">" + escapeHtml(cat.label) + "</span>");
3248
+ if (credit) caption.push('<span class="chain-credit"' + tipAttrs(INSP_COPY.credit, "attackers") + ">resists deobfuscators " + credit + "</span>");
3278
3249
  return '<div class="chain-step">' +
3279
3250
  '<div class="chain-rail"><span class="chain-dot"></span><span class="chain-line"></span></div>' +
3280
3251
  '<div class="chain-body">' +
3281
3252
  '<div class="chain-head">' +
3282
- '<span class="chain-transform">' + escapeHtml(g.transform || "?") + "</span>" +
3283
- (g.count > 1 ? '<span class="chain-count">×' + g.count + "</span>" : "") +
3284
- (delta.length ? '<span class="chain-delta">' + escapeHtml(delta.join(" ")) + "</span>" : "") +
3253
+ '<span class="chain-transform">' + breakCamel(g.transform) + "</span>" +
3254
+ (g.count > 1 ? '<span class="chain-count"' + tipAttrs("Applied " + g.count + " times.") + ">×" + g.count + "</span>" : "") +
3255
+ (g.sizeDeltaEst ? '<span class="chain-delta">' + escapeHtml((g.sizeDeltaEst > 0 ? "+" : "") + fmtNum(g.sizeDeltaEst) + " B") + "</span>" : "") +
3285
3256
  "</div>" +
3286
- (caption ? '<div class="chain-caption">' + escapeHtml(caption) + "</div>" : "") +
3257
+ (caption.length ? '<div class="chain-caption">' + caption.join(" · ") + "</div>" : "") +
3287
3258
  "</div>" +
3288
3259
  "</div>";
3289
3260
  }
3290
- function renderChainStepper(region) {
3261
+ function renderChainBody(region) {
3291
3262
  var lineage = region.raw.lineage || [];
3292
3263
  if (!lineage.length) {
3293
- var n = region.raw.transformCount || 0;
3294
- return '<div class="inspector-section"><h3>Transform chain</h3>' +
3295
- '<p class="inspector-empty">' + (n > 0
3296
- ? escapeHtml("This map stores per-region TOTALS only, not the individual steps — the ledger counts " +
3297
- n + " transform" + (n === 1 ? "" : "s") + " on this span, all of them real. Maps stored before " +
3298
- "August 2026 were captured without the step column to keep the artifact small; re-run your " +
3299
- "build to get the full chain.")
3300
- : "No transform ran on this span.") +
3301
- "</p></div>";
3264
+ return '<p class="insp-note">' + escapeHtml(INSP_COPY.detailsOff) + " " + docLinkHtml("cfgDetailed", "Learn more") + "</p>";
3302
3265
  }
3303
- var groups = collapseLineage(lineage);
3266
+ var groups = groupLineage(lineage);
3304
3267
  var visible = groups.slice(0, CHAIN_VISIBLE_CAP).map(chainStepHtml).join("");
3305
3268
  var extra = groups.slice(CHAIN_VISIBLE_CAP);
3306
3269
  var extraHtml = extra.length
3307
- ? '<details class="chain-extra"><summary>show ' + extra.length + " more step" + (extra.length === 1 ? "" : "s") + "</summary>" +
3308
- extra.map(chainStepHtml).join("") + "</details>"
3270
+ ? '<details class="chain-extra"><summary>' + extra.length + " more</summary>" + extra.map(chainStepHtml).join("") + "</details>"
3309
3271
  : "";
3310
3272
  var note = region.raw.lineageCapped
3311
- ? '<div class="chain-more">' + escapeHtml("ledger recorded " + region.raw.lineageCapped + " raw steps total; " + lineage.length + " embedded in this map") + "</div>"
3273
+ ? '<div class="chain-more">' + escapeHtml(region.raw.lineageCapped + " steps in total; this map keeps the first " + lineage.length + ".") + "</div>"
3312
3274
  : "";
3313
- return '<div class="inspector-section"><h3>Transform chain <span class="chip">' + groups.length + " step" + (groups.length === 1 ? "" : "s") +
3314
- (region.raw.lineageCapped ? "+" : "") + '</span></h3><div class="chain">' + visible + "</div>" + extraHtml + note + "</div>";
3275
+ return '<div class="chain">' + visible + "</div>" + extraHtml + note;
3276
+ }
3277
+ function transformsLabel(region) {
3278
+ var lineage = region.raw.lineage || [];
3279
+ if (lineage.length) return String(groupLineage(lineage).length) + (region.raw.lineageCapped ? "+" : "");
3280
+ return (region.raw.transformCount || 0) > 0 ? "details off" : null;
3281
+ }
3282
+ function inspChain(region) {
3283
+ if (!region) return "";
3284
+ var label = transformsLabel(region);
3285
+ if (label == null) return "";
3286
+ var tip = INSP_COPY.transforms + (SCORES_ARE_RATES ? " " + INSP_COPY.transformsRates : "");
3287
+ return '<details class="insp-chain"><summary class="details-summary"' + tipAttrs(tip, "cfgTransforms") +
3288
+ '>Transforms <span class="chip">' + escapeHtml(label) + "</span></summary>" + renderChainBody(region) + "</details>";
3315
3289
  }
3316
3290
 
3317
- var INSP_FACTS = 6;
3318
- function inspFlag(kind, glyph, tip) {
3319
- return '<span class="insp-flag" data-kind="' + kind + '" tabindex="0" role="note" data-tip="' +
3320
- escapeAttr(tip) + '">' + escapeHtml(glyph) + "</span>";
3291
+ function inspFlag(kind, glyph, tip, doc) {
3292
+ return '<span class="insp-flag" data-kind="' + kind + '" tabindex="0" role="note"' + tipAttrs(tip, doc) + ">" + escapeHtml(glyph) + "</span>";
3321
3293
  }
3322
3294
  function inspFact(f) {
3323
- if (!f) return '<div class="insp-fact is-pad" aria-hidden="true"><span class="k">-</span><span class="v">-</span></div>';
3324
3295
  var val = f.html != null ? f.html : escapeHtml(f.v == null || f.v === "" ? "—" : String(f.v));
3325
- return '<div class="insp-fact"' + (f.tip ? ' data-tip="' + escapeAttr(f.tip) + '"' : "") + ">" +
3296
+ return '<div class="insp-fact"' + (f.tip ? tipAttrs(f.tip, f.doc) : "") + ">" +
3326
3297
  '<span class="k">' + escapeHtml(f.k) + "</span>" +
3327
- '<span class="v' + (f.dim ? " is-dim" : "") + (f.warn ? " is-warn" : "") + '"' +
3328
- (f.full ? ' title="' + escapeAttr(f.full) + '"' : "") + ">" + val + "</span></div>";
3298
+ '<span class="v' + (f.dim ? " is-dim" : "") + '"' + (f.full ? ' title="' + escapeAttr(f.full) + '"' : "") + ">" + val + "</span></div>";
3299
+ }
3300
+ function complexityMeterHtml(cx, target) {
3301
+ var top = Math.max(12, (target || 0) * 2, cx * 1.1);
3302
+ var w = Math.max(2, Math.min(100, (cx / top) * 100));
3303
+ var tick = target != null && target > 0 ? '<span class="meter-tick" style="left:' + ((target / top) * 100).toFixed(1) + '%"></span>' : "";
3304
+ return '<div class="meter meter-lg insp-meter"><i data-band="' + complexityBand(cx) + '" style="width:' + w.toFixed(1) + '%"></i>' + tick + "</div>";
3329
3305
  }
3330
3306
  function inspCard(o) {
3331
- var facts = (o.facts || []).slice(0, INSP_FACTS);
3332
- while (facts.length < INSP_FACTS) facts.push(null);
3333
- var hasScore = o.score != null && !isNaN(o.score);
3334
- var s = hasScore ? Math.max(0, Math.min(100, Math.round(o.score))) : 0;
3307
+ var hasCx = typeof o.cx === "number" && !isNaN(o.cx);
3308
+ var facts = (o.facts || []).filter(Boolean);
3309
+ var lines = (o.lines || []).filter(Boolean);
3335
3310
  return '<div class="insp-card">' +
3336
- '<div class="insp-ident">' + (o.chip || "") + (o.tier || "") +
3311
+ '<div class="insp-ident">' + (o.chip || "") +
3337
3312
  '<span class="insp-flags">' + (o.flags || []).join("") + "</span>" +
3338
- '<span class="insp-score"' + (o.scoreTip ? ' data-tip="' + escapeAttr(o.scoreTip) + '"' : "") + ">" +
3339
- (hasScore ? s + "<small>/100</small>" : "<small>—</small>") + "</span>" +
3313
+ (hasCx ? '<span class="insp-score" tabindex="0"' + tipAttrs(o.cxTip || INSP_COPY.complexity, "complexity") + "><b>" +
3314
+ escapeHtml(fmtCx(o.cx)) + "</b><small>complexity</small></span>" : "") +
3340
3315
  "</div>" +
3341
- '<div class="meter meter-lg insp-meter' + (hasScore ? "" : " is-blank") + '">' +
3342
- '<i style="width:' + s + "%;background:" + heatSolid(s) + '"></i></div>' +
3343
- '<div class="insp-where">' + escapeHtml(o.where || "") + "</div>" +
3344
- '<div class="insp-facts">' + facts.map(inspFact).join("") + "</div>" +
3345
- '<div class="insp-actions">' + (o.actions || "") + "</div>" +
3316
+ (hasCx ? complexityMeterHtml(o.cx, buildTarget()) : "") +
3317
+ lines.map(function (l) { return '<p class="insp-line">' + l + "</p>"; }).join("") +
3318
+ (facts.length ? '<div class="insp-facts">' + facts.map(inspFact).join("") + "</div>" : "") +
3319
+ (o.actions ? '<div class="insp-actions">' + o.actions + "</div>" : "") +
3346
3320
  "</div>";
3347
3321
  }
3348
- function inspChain(region) {
3349
- if (!region) {
3350
- return '<details class="insp-chain"><summary class="details-summary" data-tip="' +
3351
- escapeAttr(INSP_COPY.noRegion) + '">Transform chain <span class="chip">no region</span></summary>' +
3352
- '<p class="insp-note">' + escapeHtml(INSP_COPY.noRegion) + "</p></details>";
3353
- }
3354
- var groups = collapseLineage(region.raw.lineage || []);
3355
- var n = region.raw.transformCount || 0;
3356
- var label = groups.length
3357
- ? groups.length + " step" + (groups.length === 1 ? "" : "s") + (region.raw.lineageCapped ? "+" : "")
3358
- : n > 0 ? "totals only" : "none";
3359
- return '<details class="insp-chain"><summary class="details-summary">Transform chain <span class="chip">' +
3360
- escapeHtml(label) + "</span></summary>" + renderChainStepper(region) + "</details>";
3361
- }
3362
- function chainTopStep(region) {
3363
- var g = collapseLineage((region && region.raw.lineage) || [])[0];
3364
- return g ? (g.transform || "?") + (g.count > 1 ? " ×" + g.count : "") : null;
3365
- }
3366
3322
  function directiveTip(d) {
3367
- var posture = [];
3368
- if (d.target != null) posture.push("target " + d.target);
3369
- if (d.floor != null) posture.push("floor " + (d.floor ? "on" : "off"));
3370
- return "An @afterpack " + d.keyword + " marker recorded over this span" +
3371
- (posture.length ? " — " + posture.join(" · ") : "") +
3372
- ". The build records the marker and its coordinates; whether it changed this span's target class is not recorded.";
3323
+ return "Marked with @afterpack " + d.keyword + (typeof d.target === "number" ? " (complexity " + fmtCx(d.target) + ")" : "") +
3324
+ ". The map shows where the directive sits, not what it changed.";
3373
3325
  }
3374
- function sizeDeltaText(n) { return n == null ? null : (n >= 0 ? "+" : "") + fmtNum(n) + " B"; }
3375
- function machineryTip(file) {
3376
- var m = file.machinery ? file.machinery.raw : null;
3377
- if (!m) return MACHINERY_BLURB;
3378
- var num = function (v) { return v == null ? "—" : String(v); };
3379
- return "Whole-file bucket (not per-token) — entropyRaw " + num(m.entropyRaw) +
3380
- ", transformCount " + num(m.transformCount) + ", sizeDeltaEst " + num(m.sizeDeltaEst) +
3381
- " (est.). " + MACHINERY_BLURB;
3326
+ function complexityTip(region) {
3327
+ var d = region && region.directive;
3328
+ return INSP_COPY.complexity + " " + targetSentence() +
3329
+ (d && typeof d.target === "number" ? " A directive here asks for " + fmtCx(d.target) + "." : "");
3330
+ }
3331
+ function missingComplexityFact() {
3332
+ if (BUILD_CX.hasLane) {
3333
+ return { k: "Complexity", v: "not recorded", dim: true, tip: "No complexity was recorded for this part of the code.", doc: "complexity" };
3334
+ }
3335
+ var t = buildTarget();
3336
+ return t != null ? { k: "Complexity target", v: fmtCx(t), tip: INSP_COPY.target + " " + INSP_COPY.noComplexity, doc: "complexity" } : null;
3382
3337
  }
3383
-
3384
3338
 
3385
3339
  function tokenAt(file, pos) {
3386
3340
  var syn = lexFile(file);
@@ -3397,145 +3351,96 @@ async function afterpackInflateBase64Gzip(b64) {
3397
3351
  });
3398
3352
  return { before: before, after: after };
3399
3353
  }
3400
- function regionCoversLiteral(file, region) {
3401
- var syn = lexFile(file);
3402
- if (!syn) return true;
3403
- var ti = tokenIndexAt(syn, region.startChar);
3404
- while (ti < syn.starts.length && syn.starts[ti] < region.endChar) {
3405
- var t = syn.types.charAt(ti);
3406
- if (t === "s" || t === "n") return true;
3407
- ti++;
3408
- }
3409
- return false;
3410
- }
3411
- function isMaterializationRegion(region) {
3412
- return !!region && (region.raw.annotations || []).indexOf("materializationSite") >= 0;
3413
- }
3414
3354
  function pct(part, total) { return total > 0 ? Math.round((part / total) * 100) + "%" : "—"; }
3415
3355
 
3416
3356
  var UNLIT_VERDICT = {
3417
- w: "Whitespace. Nothing here for any transform to act on.",
3418
- p: "An operator or punctuation — required syntax. It has to survive verbatim for the program to parse, so no transform can touch it.",
3419
- k: "A syntactic keyword — `if`, `return`, `function`, `const`. Required syntax: it has to survive verbatim for the program to parse, so no transform can touch it. (`null`, `true`, `false` and `undefined` are lexically keywords too, but they are VALUES, and this viewer reports them separately — they are not untouchable.)",
3420
- v: "A value literal, not syntax. `null` / `true` / `false` / `undefined` are ordinary expressions, so unlike `if` or `return` an obfuscator may legitimately replace them — and AfterPack does: `true`/`false` are lowered to `!0`/`!1` and then fused into opaque arithmetic, while `null` and `undefined` are replaced by a reference to a shared sink, so the keyword itself never reaches your output. Unlit here means THIS MAP carries no region for the span, not that the token shipped verbatim. Maps captured before value-literal lowering was ledgered show every one of them unlit.",
3421
- y: "A property key. AfterPack never RENAMES one — that would break every dynamic access, JSON round-trip and external contract that reaches it by name — but it does not leave it alone either: property extraction rewrites `state.items.map(…)` to `a[l](…)` and hoists `\"map\"` into the string pool, where string encoding treats it like any other literal. So a property key CAN carry a region, and usually does once encoding is on. Unlit means no region landed on THIS key: either the key was not extracted, or its span did not survive back-mapping. Keys that reach your output still readable are listed separately as `Property name` spotlights.",
3422
- i: "An identifier with no rename recorded on it. Either your bundler resolved or removed it before AfterPack ran (an import binding, a type, dead code), or it is a name AfterPack must not touch — a global, an export your consumers call, a reserved word.",
3423
- s: "A string literal with no ledger region on it.",
3424
- n: "A number literal with no ledger region on it.",
3425
- c: "A comment. Comments never reach your shipped output — your bundler strips them long before AfterPack sees the code — so there is nothing here to protect and nothing to leak.",
3426
- "?": "This viewer has no grammar for this file type, so it cannot say what this token is. It carries no ledger region and no rename."
3357
+ w: "Whitespace. Nothing to protect.",
3358
+ p: "Punctuation or an operator. The language needs it as written.",
3359
+ k: "A keyword such as if or return. The language needs it as written.",
3360
+ v: "A value like true or null. Your output may still rewrite it; this map just has no record of it.",
3361
+ y: "A property name. AfterPack doesn't rename these, because code can look them up by their text.",
3362
+ i: "A name with no rename recorded. Usually one that must keep its name, like a global or an export, or one your bundler removed.",
3363
+ s: "A string with nothing recorded. Your bundler may have removed it (for example a TypeScript type) before AfterPack ran.",
3364
+ n: "A number with nothing recorded. Your bundler may have folded it away.",
3365
+ c: "A comment. Comments don't ship, so there's nothing to protect.",
3366
+ "?": "The viewer can't read this file type, so it can't say what this is."
3427
3367
  };
3428
- var LITERAL_FUNNEL_NOTE = "The map records a region only where a transform cleared the entropy funnel. A literal can also be gone before the engine ever sees it — a TypeScript type-position string is erased at compile time, and a constant your bundler folded away leaves nothing to encode.";
3368
+ var UNLIT_DOC = { y: "preserve" };
3429
3369
 
3430
- function cardRegion(file, region, opts) {
3370
+ function cardRegion(file, region, sel) {
3431
3371
  var r = region.raw;
3432
3372
  var perf = r.perf || {};
3373
+ var cx = sel && typeof sel.cx === "number" ? sel.cx : null;
3433
3374
  var flags = [];
3434
- if (r.why) flags.push(inspFlag("info", "?", r.why));
3435
- if (opts && opts.leakInside) flags.push(inspFlag("leak", "!", INSP_COPY.leakCap));
3436
- if (isMaterializationRegion(region) && !regionCoversLiteral(file, region)) {
3437
- flags.push(inspFlag("warn", "▲", INSP_COPY.spanMismatch));
3438
- }
3439
- if (region.directive) flags.push(inspFlag("dir", "@", directiveTip(region.directive)));
3440
- var top = chainTopStep(region);
3375
+ var leakInside = file.spotlights.some(function (sp) {
3376
+ return sp.raw.severity === "leak" && sp.startChar >= region.startChar && sp.endChar <= region.endChar;
3377
+ });
3378
+ if (leakInside) flags.push(inspFlag("leak", "!", INSP_COPY.leakInside, "secret"));
3379
+ if (region.directive) flags.push(inspFlag("dir", "@", directiveTip(region.directive), "directivesCheck"));
3441
3380
  return inspCard({
3442
3381
  chip: classChipHtml(r.reversalClass, false),
3443
- tier: r.tier ? '<span class="tier-pill tier-' + escapeAttr(r.tier) + '">' + escapeHtml(r.tier) + "</span>" : "",
3444
3382
  flags: flags,
3445
- score: r.score,
3446
- scoreTip: INSP_COPY.score,
3447
- where: (r.nodeKind || "?") + " · chars " + region.startChar + "–" + region.endChar,
3383
+ cx: cx,
3384
+ cxTip: complexityTip(region),
3448
3385
  facts: [
3449
- { k: "Transforms", v: r.transformCount, tip: INSP_COPY.transforms },
3450
- { k: "Chain", v: top || (r.transformCount ? "totals only" : "none"), dim: !top, full: top || "",
3451
- tip: top ? INSP_COPY.chainTop : INSP_COPY.chainNone },
3452
- { k: "Size Δ", v: sizeDeltaText(r.sizeDeltaEst), tip: INSP_COPY.sizeDelta },
3453
- { k: "Decode ops", v: perf.decodeOps, tip: INSP_COPY.decodeOps },
3454
- { k: "Entropy (raw)", v: r.entropyRaw, tip: INSP_COPY.entropy },
3455
- r.ceiling
3456
- ? { k: "Ceiling", html: classChipHtml(r.ceiling.class, true), tip: INSP_COPY.ceiling }
3457
- : { k: "Ceiling", v: "—", dim: true, tip: INSP_COPY.ceilingNone }
3458
- ],
3459
- actions: r.ceiling
3460
- ? '<button type="button" class="mini-btn copy-btn-pro" data-copy="' + encodeURIComponent(r.ceiling.directive) +
3461
- '" data-tip="' + escapeAttr(r.ceiling.directive + " — " + INSP_COPY.ceiling) + '">Copy Pro directive</button>'
3462
- : ""
3386
+ cx == null ? missingComplexityFact() : null,
3387
+ SCORES_ARE_RATES && typeof r.score === "number" && r.score > 0
3388
+ ? { k: "Resists deobfuscators", v: scorePct(r.score), tip: INSP_COPY.resists, doc: "attackers" } : null,
3389
+ typeof r.sizeDeltaEst === "number" && r.sizeDeltaEst !== 0
3390
+ ? { k: "Added size", v: (r.sizeDeltaEst > 0 ? "+" : "") + fmtNum(r.sizeDeltaEst) + " B", tip: INSP_COPY.addedSize, doc: "sizeBudget" } : null,
3391
+ perf.decodeOps > 0 ? { k: "Runtime decoders", v: perf.decodeOps, tip: INSP_COPY.decoders, doc: "perf" } : null
3392
+ ]
3463
3393
  }) + inspChain(region);
3464
3394
  }
3465
3395
 
3466
3396
  function cardPreserved(file, region) {
3467
3397
  var r = region.raw;
3468
- var hasReason = !!r.preservedReason;
3469
- var steps = (r.lineage || []).length;
3470
- var count = r.transformCount || 0;
3471
- var lowered = !hasReason && (steps > 0 || count > 0);
3472
- var reason = hasReason ? humanize(r.preservedReason) : lowered ? INSP_COPY.preservedLowered : INSP_COPY.preservedNone;
3473
- var flags = [inspFlag("info", "?", reason)];
3474
- if (region.directive) flags.push(inspFlag("dir", "@", directiveTip(region.directive)));
3475
- var top = chainTopStep(region);
3398
+ var lowered = (r.lineage || []).length > 0 || (r.transformCount || 0) > 0;
3399
+ var why = r.preservedReason
3400
+ ? preservedReasonText(r.preservedReason) || "Your code needs its text to work."
3401
+ : lowered ? INSP_COPY.preservedLowered : INSP_COPY.preservedNone;
3402
+ var flags = region.directive ? [inspFlag("dir", "@", directiveTip(region.directive), "directivesCheck")] : [];
3476
3403
  return inspCard({
3477
3404
  chip: classChipHtml("preserved", false),
3478
3405
  flags: flags,
3479
- score: null,
3480
- where: (r.nodeKind || "?") + " · chars " + region.startChar + "–" + region.endChar,
3481
- facts: [
3482
- { k: "State", v: hasReason ? "must stay literal" : lowered ? "lowered only" : "no transform ran",
3483
- tip: INSP_COPY.preservedState },
3484
- { k: "Reason", v: hasReason ? humanize(r.preservedReason) : "—", dim: !hasReason,
3485
- full: hasReason ? humanize(r.preservedReason) : "", tip: hasReason ? reason : INSP_COPY.preservedState },
3486
- { k: "Reason code", v: r.preservedReason || "—", dim: !hasReason },
3487
- { k: "Transforms", v: count, tip: INSP_COPY.transforms },
3488
- { k: "Chain", v: top || (count ? "totals only" : "none"), dim: !top,
3489
- tip: top ? INSP_COPY.chainTop : INSP_COPY.chainNone },
3490
- region.directive
3491
- ? { k: "Directive", v: "@afterpack " + region.directive.keyword, tip: directiveTip(region.directive) }
3492
- : { k: "Directive", v: "—", dim: true }
3493
- ],
3494
- actions: ""
3406
+ lines: [escapeHtml(why) + (r.preservedReason ? " " + docLinkHtml("preserve", "Why") : "")]
3495
3407
  }) + inspChain(region);
3496
3408
  }
3497
3409
 
3498
- function cardRenamed(file, idx) {
3499
- var r = file.renamedRanges[idx];
3410
+ function cardRenamed(file, idx, sel) {
3411
+ var cx = sel && typeof sel.cx === "number" ? sel.cx : null;
3500
3412
  return inspCard({
3501
3413
  chip: classChipHtml("renamed-encoded", false, "Renamed"),
3502
- flags: [inspFlag("info", "?", INSP_COPY.renamedOutput)],
3503
- score: null,
3504
- where: "identifier" + (r ? " · chars " + r.startChar + "–" + r.endChar : ""),
3414
+ cx: cx,
3415
+ lines: [escapeHtml(INSP_COPY.renamedLine) + " " + docLinkHtml("cfgRename", "Renaming")],
3505
3416
  facts: [
3506
- { k: "Layer", v: "rename baseline", tip: INSP_COPY.renamedLayer },
3507
- { k: "In your output", v: "name replaced", tip: INSP_COPY.renamedOutput },
3508
- { k: "Strength", v: "low", dim: true, tip: INSP_COPY.renamedStrength },
3509
- { k: "Hardened region", v: "none on this span", dim: true, tip: INSP_COPY.renamedLayer },
3510
- { k: "Renamed span", v: (idx + 1) + " of " + fmtNum(file.renamedRanges.length),
3511
- tip: "This span's position in the file's list of renamed identifier occurrences — not the 5th use of this particular name." },
3512
- { k: "Renamed share", v: pct(file.coverage.renamed, file.coverage.total), tip: INSP_COPY.coverage }
3513
- ],
3514
- actions: ""
3515
- }) + inspChain(null);
3417
+ !(cx > 0) ? { k: "Strength", v: "light", tip: INSP_COPY.renamedStrength, doc: "cfgRename" } : null,
3418
+ { k: "Renamed in this file", v: pct(file.coverage.renamed, file.coverage.total), tip: INSP_COPY.renamedShare, doc: "cfgRename" }
3419
+ ]
3420
+ });
3516
3421
  }
3517
3422
 
3518
- function cardExtracted(file, idx) {
3423
+ function cardExtracted(file, idx, sel) {
3519
3424
  var r = file.extractedRanges[idx];
3520
- var isGlobal = !!r && r.kind === "global";
3425
+ var cx = sel && typeof sel.cx === "number" ? sel.cx : null;
3521
3426
  return inspCard({
3522
- chip: classChipHtml("renamed-encoded", false, "Extracted"),
3523
- flags: [inspFlag("info", "?", INSP_COPY.extractedOutput)],
3524
- score: null,
3525
- where: (isGlobal ? "global reference" : "property name") +
3526
- (r ? " · chars " + r.startChar + "–" + r.endChar : ""),
3427
+ chip: classChipHtml("renamed-encoded", false, "Hidden name"),
3428
+ cx: cx,
3429
+ lines: [escapeHtml(INSP_COPY.extractedLine)],
3527
3430
  facts: [
3528
- { k: "Layer", v: "constant-pool extraction", tip: INSP_COPY.extractedLayer },
3529
- { k: "Extracted", v: isGlobal ? "global identifier" : "property name", tip: INSP_COPY.extractedKind },
3530
- { k: "In your output", v: "computed pool lookup", tip: INSP_COPY.extractedOutput },
3531
- { k: "Strength", v: "low–moderate", dim: true, tip: INSP_COPY.extractedStrength },
3532
- { k: "Hardened region", v: "none on this span", dim: true, tip: INSP_COPY.extractedLayer },
3533
- { k: "Extracted span", v: (idx + 1) + " of " + fmtNum(file.extractedRanges.length),
3534
- tip: "This span's position in the file's list of extracted tokens — not the Nth use of this particular name." },
3535
- { k: "Extracted share", v: pct(file.coverage.extracted, file.coverage.total), tip: INSP_COPY.coverage }
3536
- ],
3537
- actions: ""
3538
- }) + inspChain(null);
3431
+ { k: "Kind", v: r && r.kind === "global" ? "global name" : "property name" },
3432
+ !(cx > 0) ? { k: "Strength", v: "light", tip: INSP_COPY.extractedStrength } : null,
3433
+ { k: "Hidden in this file", v: pct(file.coverage.hidden, file.coverage.total), tip: INSP_COPY.extractedShare }
3434
+ ]
3435
+ });
3436
+ }
3437
+
3438
+ function cardComplexityOnly(file, sel) {
3439
+ return inspCard({
3440
+ chip: classChipHtml("", false, sel.cx > 0 ? "Protected" : "No complexity added"),
3441
+ cx: sel.cx,
3442
+ cxTip: complexityTip(null)
3443
+ });
3539
3444
  }
3540
3445
 
3541
3446
  function cardUnlit(file, u) {
@@ -3543,115 +3448,53 @@ async function afterpackInflateBase64Gzip(b64) {
3543
3448
  if (tok.type === "?" && u.end != null) tok = { start: u.pos, end: u.end, type: "?", text: file.source.slice(u.pos, u.end) };
3544
3449
  var type = tok.type === "?" && u.type && u.type !== "?" ? u.type : tok.type;
3545
3450
  if (type === "k" && VALUE_LITERAL_TEXT[tok.text] === 1) type = "v";
3546
- var kind = TOKEN_KIND[type] || "source text";
3547
- var nb = neighbourRegions(file, tok.start);
3548
- var cov = file.coverage;
3549
- var before = nb.before;
3451
+ var verdict = UNLIT_VERDICT[type] || UNLIT_VERDICT["?"];
3452
+ var before = neighbourRegions(file, tok.start).before;
3550
3453
  var gapText = before ? file.source.slice(before.endChar, tok.start) : null;
3551
3454
  var abuts = !!before && gapText.length <= 2 && !/\S/.test(gapText);
3552
- var mislaid = abuts && isMaterializationRegion(before) && !regionCoversLiteral(file, before);
3553
- var verdict = UNLIT_VERDICT[type] || UNLIT_VERDICT["?"];
3554
3455
 
3555
- var flags = [inspFlag("info", "?", verdict)];
3556
- if (type === "s" || type === "n") flags.push(inspFlag("info", "ƒ", LITERAL_FUNNEL_NOTE));
3557
- if (abuts) {
3558
- flags.push(inspFlag("warn", "▲", "A recorded region ends " +
3559
- (gapText.length === 0 ? "immediately" : gapText.length + " character" + (gapText.length === 1 ? "" : "s")) +
3560
- " before this token, with nothing but whitespace in between. " + INSP_COPY.gapAbuts +
3561
- (mislaid ? " " + INSP_COPY.spanMismatch : "")));
3562
- }
3456
+ var flags = [];
3563
3457
  var di = -1;
3564
3458
  file.directives.forEach(function (d, i) {
3565
3459
  if (d.startChar <= tok.start && d.endChar >= tok.end &&
3566
3460
  (di < 0 || (d.endChar - d.startChar) < (file.directives[di].endChar - file.directives[di].startChar))) di = i;
3567
3461
  });
3568
- if (di >= 0) flags.push(inspFlag("dir", "@", directiveTip(file.directives[di])));
3569
- if (file.machinery) flags.push(inspFlag("info", "◫", machineryTip(file)));
3570
-
3571
- var nearest = abuts
3572
- ? (gapText.length === 0 ? "abuts a region" : gapText.length + " chars after a region")
3573
- : (before || nb.after)
3574
- ? [before ? (tok.start - before.endChar) + " chars after" : null,
3575
- nb.after ? (nb.after.startChar - tok.end) + " chars before" : null].filter(Boolean).join(" · ")
3576
- : "none in this file";
3462
+ if (di >= 0) flags.push(inspFlag("dir", "@", directiveTip(file.directives[di]), "directivesCheck"));
3463
+
3577
3464
  return inspCard({
3578
- chip: classChipHtml("preserved", true, "Not attributed"),
3465
+ chip: classChipHtml("", true, "Nothing recorded"),
3579
3466
  flags: flags,
3580
- score: null,
3581
- where: kind + " · chars " + tok.start + "–" + tok.end,
3582
- facts: [
3583
- { k: "Token", v: kind, tip: verdict },
3584
- { k: "Nearest region", v: nearest, warn: abuts,
3585
- tip: abuts ? INSP_COPY.gapAbuts : (before || nb.after) ? INSP_COPY.gapClear : INSP_COPY.gapNone },
3586
- { k: "Ledger region", v: pct(cov.region, cov.total), tip: INSP_COPY.coverage },
3587
- { k: "Extracted only", v: pct(cov.extracted || 0, cov.total), tip: INSP_COPY.coverage },
3588
- { k: "Renamed only", v: pct(cov.renamed, cov.total), tip: INSP_COPY.coverage },
3589
- { k: "Plain", v: pct(cov.plain, cov.total), tip: INSP_COPY.coverage }
3467
+ lines: [
3468
+ escapeHtml(verdict) + (UNLIT_DOC[type] ? " " + docLinkHtml(UNLIT_DOC[type], "Why") : ""),
3469
+ abuts ? escapeHtml(INSP_COPY.gapAbuts) : null
3590
3470
  ],
3591
- actions: abuts
3592
- ? '<button type="button" class="mini-btn" data-select-region="' + before.idx + '">Inspect that region</button>'
3593
- : ""
3594
- }) + inspChain(null);
3471
+ facts: [{ k: "What it is", v: TOKEN_KIND[type] || "text", tip: INSP_COPY.unlitKind }],
3472
+ actions: abuts ? '<button type="button" class="mini-btn" data-select-region="' + before.idx + '">Show that region</button>' : ""
3473
+ });
3595
3474
  }
3596
3475
 
3597
3476
  function cardSpotlight(file, spotlight, region) {
3598
3477
  var s = spotlight.raw;
3599
3478
  var sev = s.severity;
3600
- var leakLabel = sev === "leak" ? "Unprotected — leaked"
3601
- : sev === "propertyName" ? "Unprotected — key name" : null;
3602
3479
  var flags = [];
3603
- if (s.reason) flags.push(inspFlag("info", "?", s.reason));
3604
- flags.push(inspFlag("leak", "!", INSP_COPY.leakCap));
3605
- if (region && region.directive) flags.push(inspFlag("dir", "@", directiveTip(region.directive)));
3606
- var mech = s.mechanism || "";
3480
+ if (region && region.directive) flags.push(inspFlag("dir", "@", directiveTip(region.directive), "directivesCheck"));
3481
+ var why = mechanismText(s.mechanism);
3482
+ var whyDoc = mechanismKey(s.mechanism) === "pinnedLiteral" ? " " + docLinkHtml("cfgPreserveLiterals", "strings.preserveLiterals") : "";
3483
+ var help = SEVERITY_HELP[sev];
3607
3484
  return inspCard({
3608
- chip: classChipHtml(s.reversalClass || "preserved", false, leakLabel),
3609
- tier: '<span class="pill pill-' + escapeAttr(sev) + '">' + escapeHtml(SEVERITY_LABEL[sev] || sev) + "</span>",
3485
+ chip: classChipHtml("", false, (SEVERITY_ICON[sev] ? SEVERITY_ICON[sev] + " " : "") + (SEVERITY_LABEL[sev] || "Readable text")),
3610
3486
  flags: flags,
3611
- score: region ? region.raw.score : null,
3612
- scoreTip: INSP_COPY.leakCap,
3613
- where: (SEVERITY_ICON[sev] || "⚠") + " " + (SEVERITY_LABEL[sev] || sev) +
3614
- " · chars " + spotlight.startChar + "–" + spotlight.endChar,
3487
+ lines: [escapeHtml(SEVERITY_BODY[sev] || SEVERITY_BODY.weak), why ? escapeHtml(why) + whyDoc : null],
3615
3488
  facts: [
3616
- { k: "Sample", v: s.sample, full: s.sample, tip: INSP_COPY.sample },
3617
- { k: "Mechanism", v: mech ? humanize(mech) : "—", full: mech, dim: !mech, tip: INSP_COPY.mechanism },
3618
- { k: "Disposition", v: s.disposition, tip: INSP_COPY.disposition },
3619
- { k: "Added bytes", v: s.bytes == null ? "—" : s.bytes + " B", dim: s.bytes == null, tip: INSP_COPY.bytes },
3620
- { k: "Region class", html: region ? classChipHtml(region.raw.reversalClass, false) : null, v: "none",
3621
- dim: !region, tip: region ? INSP_COPY.leakCap : INSP_COPY.noRegion },
3622
- { k: "Region score", v: region ? region.raw.score + "/100" : "—", dim: !region, tip: INSP_COPY.leakCap }
3489
+ { k: "Text", v: s.sample, full: s.sample, tip: INSP_COPY.sample },
3490
+ typeof s.bytes === "number" ? { k: "Length", v: plural(s.bytes, "byte", "bytes") } : null,
3491
+ region && !isPreservedRegion(region)
3492
+ ? { k: "Code around it", html: classChipHtml(region.raw.reversalClass, false, null, true), tip: INSP_COPY.around, doc: "classes" } : null
3623
3493
  ],
3624
- actions: s.proHint
3625
- ? '<button type="button" class="mini-btn copy-btn-pro" data-copy="' + encodeURIComponent(s.proHint) +
3626
- '" data-tip="' + escapeAttr(s.proHint) + '">Force-protect in Pro</button>'
3627
- : ""
3494
+ actions: help ? docLinkHtml(help.doc, help.label) : ""
3628
3495
  }) + inspChain(region);
3629
3496
  }
3630
3497
 
3631
- function cardFile(file) {
3632
- var a = file.doc.aggregate || {};
3633
- var leaks = file.leakCount;
3634
- var maxCls = (a.classSummary || {}).maxClassReached;
3635
- var flags = [inspFlag("info", "?", INSP_COPY.selectHint)];
3636
- if (file.machinery) flags.push(inspFlag("info", "◫", machineryTip(file)));
3637
- return inspCard({
3638
- chip: maxCls ? classChipHtml(maxCls, false) : '<span class="insp-title">File aggregate</span>',
3639
- flags: flags,
3640
- score: Math.round(file.avgScore),
3641
- scoreTip: INSP_COPY.avgScore,
3642
- where: "no selection · whole file",
3643
- facts: [
3644
- { k: "Regions", v: fmtNum(file.realRegions.length), tip: INSP_COPY.fileRegions },
3645
- { k: "Transforms", v: fmtNum(a.totalTransforms), tip: INSP_COPY.transforms },
3646
- { k: "Weak spots", v: fmtNum(file.weakSpotCount), tip: INSP_COPY.weakSpots },
3647
- { k: "of which leaks", v: fmtNum(leaks), warn: leaks > 0, tip: INSP_COPY.leaks },
3648
- { k: "Size Δ total", v: sizeDeltaText(a.sizeDeltaEstTotal), tip: INSP_COPY.sizeDelta },
3649
- { k: "Avg entropy", v: a.avgEntropy, tip: INSP_COPY.entropyAvg }
3650
- ],
3651
- actions: '<span class="insp-hint">Select any token to inspect it.</span>'
3652
- }) + inspChain(null);
3653
- }
3654
-
3655
3498
  function inspectorSummary(file, sel) {
3656
3499
  if (!sel) return "no selection";
3657
3500
  if (sel.spotlightIdx != null) {
@@ -3660,16 +3503,17 @@ async function afterpackInflateBase64Gzip(b64) {
3660
3503
  if (sample.length > 24) sample = sample.slice(0, 23) + "…";
3661
3504
  return sample ? "weak spot · " + sample : "weak spot";
3662
3505
  }
3663
- if (sel.unlit) return "unattributed token";
3664
- if (sel.renamedIdx != null) return "renamed identifier";
3665
- if (sel.extractedIdx != null) return "extracted name";
3506
+ if (sel.unlit) return "nothing recorded";
3507
+ var cxText = typeof sel.cx === "number" ? "complexity " + fmtCx(sel.cx) : "";
3666
3508
  if (sel.regionIdx != null) {
3667
3509
  var region = regionByIdx(file, sel.regionIdx);
3668
- if (!region) return "region";
3669
- var cls = region.raw.reversalClass;
3670
- return (CLASS_META[cls] && CLASS_META[cls].label) || cls || "region";
3510
+ var cls = region ? region.raw.reversalClass : null;
3511
+ var label = (CLASS_META[cls] && CLASS_META[cls].label) || cls || "protected code";
3512
+ return cxText ? label + " · " + cxText : label;
3671
3513
  }
3672
- return "";
3514
+ if (sel.extractedIdx != null) return "hidden name";
3515
+ if (sel.renamedIdx != null) return "renamed";
3516
+ return cxText || "";
3673
3517
  }
3674
3518
 
3675
3519
  function renderInspector() {
@@ -3680,19 +3524,33 @@ async function afterpackInflateBase64Gzip(b64) {
3680
3524
  if (countEl) countEl.textContent = file ? inspectorSummary(file, sel) : "";
3681
3525
  if (!file) { el.innerHTML = ""; return; }
3682
3526
  if (!sel) {
3683
- el.innerHTML = '<p class="inspector-empty">Select any token in the code pane to inspect it.</p>';
3527
+ el.innerHTML = '<p class="inspector-empty">Click any part of the code to see how it was protected.</p>';
3684
3528
  return;
3685
3529
  }
3686
3530
  var region = sel.regionIdx != null ? regionByIdx(file, sel.regionIdx) : null;
3687
3531
  var spotlight = sel.spotlightIdx != null ? file.spotlights[sel.spotlightIdx] : null;
3688
3532
  var html = spotlight ? cardSpotlight(file, spotlight, region)
3689
- : region && isPreservedRegion(region) ? cardPreserved(file, region)
3690
- : region ? cardRegion(file, region, null)
3533
+ : region && isPreservedRegion(region) && !(typeof sel.cx === "number" && sel.cx > 0) ? cardPreserved(file, region)
3534
+ : region ? cardRegion(file, region, sel)
3691
3535
  : sel.unlit ? cardUnlit(file, sel.unlit)
3692
- : sel.extractedIdx != null ? cardExtracted(file, sel.extractedIdx)
3693
- : sel.renamedIdx != null ? cardRenamed(file, sel.renamedIdx)
3694
- : cardFile(file);
3695
- el.innerHTML = '<div class="insp">' + html + "</div>";
3536
+ : sel.extractedIdx != null ? cardExtracted(file, sel.extractedIdx, sel)
3537
+ : sel.renamedIdx != null ? cardRenamed(file, sel.renamedIdx, sel)
3538
+ : typeof sel.cx === "number" ? cardComplexityOnly(file, sel)
3539
+ : "";
3540
+ el.innerHTML = '<div class="insp">' + html + declarationNote(file, sel) + "</div>";
3541
+ }
3542
+
3543
+ function declarationNote(file, sel) {
3544
+ var idx = sel.declIdx;
3545
+ if (idx == null && sel.unlit) {
3546
+ var end = sel.unlit.end != null ? sel.unlit.end : sel.unlit.pos + 1;
3547
+ file.declRanges.forEach(function (r, i) {
3548
+ if (idx == null && r.startChar <= sel.unlit.pos && r.endChar >= end) idx = i;
3549
+ });
3550
+ }
3551
+ var decl = idx != null ? file.declRanges[idx] : null;
3552
+ if (!decl) return "";
3553
+ return '<p class="insp-note insp-also">Also rewritten: ' + decl.names.map(breakCamel).join(", ") + "</p>";
3696
3554
  }
3697
3555
 
3698
3556
  function highlightSelectionRing() {
@@ -3712,68 +3570,42 @@ async function afterpackInflateBase64Gzip(b64) {
3712
3570
  }
3713
3571
  }
3714
3572
 
3715
- var highlightToggle = document.getElementById("highlight-class-toggle");
3716
- var highlightStatus = document.getElementById("highlight-class-status");
3717
3573
  var syntaxToggle = document.getElementById("syntax-toggle");
3718
3574
  var syntaxToggleText = document.getElementById("syntax-toggle-text");
3719
3575
  function updateSyntaxToggle(file) {
3720
3576
  if (!syntaxToggle) return;
3721
3577
  var g = file && file.grammar;
3578
+ var label = document.getElementById("syntax-label");
3579
+ if (label) label.hidden = !g;
3722
3580
  syntaxToggle.disabled = !g;
3723
3581
  syntaxToggle.checked = !!g && state.syntaxOn;
3724
- if (syntaxToggleText) syntaxToggleText.textContent = g ? "Syntax · " + g.label : "Syntax · n/a";
3725
- }
3726
- function currentSelectedRegion() {
3727
- var file = activeFile();
3728
- if (!file || !state.selection || state.selection.regionIdx == null) return null;
3729
- return regionByIdx(file, state.selection.regionIdx);
3730
- }
3731
- function applyHighlightClass() {
3732
- var region = currentSelectedRegion();
3733
- var cls = region ? region.raw.reversalClass : null;
3734
- highlightToggle.disabled = !cls;
3735
- var active = state.highlightClassOn && !!cls;
3736
- if (active) {
3737
- codeBody.setAttribute("data-highlight-class", cls);
3738
- var file = activeFile();
3739
- var count = file ? file.realRegions.filter(function (r) { return r.raw.reversalClass === cls; }).length : 0;
3740
- var label = CLASS_META[cls] ? CLASS_META[cls].label : cls;
3741
- highlightStatus.textContent = "· " + count + " region" + (count === 1 ? "" : "s");
3742
- highlightStatus.setAttribute("data-tip", "Highlighting " + label + " — " + count + " region" +
3743
- (count === 1 ? "" : "s") + " in this file share the selected token's reversal class.");
3744
- highlightStatus.classList.add("is-on");
3745
- } else {
3746
- codeBody.removeAttribute("data-highlight-class");
3747
- highlightStatus.classList.remove("is-on");
3748
- highlightStatus.removeAttribute("data-tip");
3749
- }
3582
+ if (syntaxToggleText) syntaxToggleText.textContent = g ? "Syntax · " + g.label : "Syntax";
3750
3583
  }
3751
3584
 
3752
- function selectFromRun(regionIdx, spotlightIdx, renamedIdx, extractedIdx) {
3585
+ function selectFromRun(regionIdx, spotlightIdx, renamedIdx, extractedIdx, cx, declIdx) {
3753
3586
  state.selection = {
3754
3587
  regionIdx: regionIdx == null || isNaN(regionIdx) ? null : regionIdx,
3755
3588
  spotlightIdx: spotlightIdx == null || isNaN(spotlightIdx) ? null : spotlightIdx,
3756
3589
  renamedIdx: renamedIdx == null || isNaN(renamedIdx) ? null : renamedIdx,
3757
3590
  extractedIdx: extractedIdx == null || isNaN(extractedIdx) ? null : extractedIdx,
3591
+ cx: typeof cx === "number" && !isNaN(cx) ? cx : null,
3592
+ declIdx: declIdx == null || isNaN(declIdx) ? null : declIdx,
3758
3593
  unlit: null
3759
3594
  };
3760
3595
  revealInspectorSection();
3761
3596
  highlightSelectionRing();
3762
- applyHighlightClass();
3763
3597
  renderInspector();
3764
3598
  }
3765
3599
  function selectUnlit(pos, type, end) {
3766
- state.selection = { regionIdx: null, spotlightIdx: null, renamedIdx: null, extractedIdx: null, unlit: { pos: pos, type: type, end: end } };
3600
+ state.selection = { regionIdx: null, spotlightIdx: null, renamedIdx: null, extractedIdx: null, cx: null, unlit: { pos: pos, type: type, end: end } };
3767
3601
  revealInspectorSection();
3768
3602
  highlightSelectionRing();
3769
- applyHighlightClass();
3770
3603
  renderInspector();
3771
3604
  }
3772
3605
  function clearSelection() {
3773
3606
  if (!state.selection) return;
3774
3607
  state.selection = null;
3775
3608
  highlightSelectionRing();
3776
- applyHighlightClass();
3777
3609
  renderInspector();
3778
3610
  }
3779
3611
  function isAttributedTok(el) { return !!el && el.classList.contains("tok-hot"); }
@@ -3787,7 +3619,9 @@ async function afterpackInflateBase64Gzip(b64) {
3787
3619
  var s = tokEl.dataset.spotlightIdx === "" ? null : Number(tokEl.dataset.spotlightIdx);
3788
3620
  var rn = tokEl.dataset.renamedIdx == null || tokEl.dataset.renamedIdx === "" ? null : Number(tokEl.dataset.renamedIdx);
3789
3621
  var ex = tokEl.dataset.extractedIdx == null || tokEl.dataset.extractedIdx === "" ? null : Number(tokEl.dataset.extractedIdx);
3790
- selectFromRun(r, s, rn, ex);
3622
+ var cx = tokEl.dataset.cx == null || tokEl.dataset.cx === "" ? null : Number(tokEl.dataset.cx);
3623
+ var dl = tokEl.dataset.declIdx == null || tokEl.dataset.declIdx === "" ? null : Number(tokEl.dataset.declIdx);
3624
+ selectFromRun(r, s, rn, ex, cx, dl);
3791
3625
  }
3792
3626
  function jumpToSpotlight(idx) {
3793
3627
  var file = activeFile();
@@ -3797,7 +3631,7 @@ async function afterpackInflateBase64Gzip(b64) {
3797
3631
  target.scrollIntoView({ block: "center", inline: "center", behavior: "smooth" });
3798
3632
  target.focus({ preventScroll: true });
3799
3633
  }
3800
- selectFromRun(run ? run.regionIdx : null, idx);
3634
+ selectFromRun(run ? run.regionIdx : null, idx, null, null, run ? run.cx : null, run ? run.declIdx : null);
3801
3635
  }
3802
3636
 
3803
3637
  function copyText(text, btn) {
@@ -3825,16 +3659,16 @@ async function afterpackInflateBase64Gzip(b64) {
3825
3659
  }
3826
3660
 
3827
3661
  function updateSourceOriginNote(file) {
3828
- var noteEl = document.getElementById("source-origin-note");
3829
- var origin = sourceOriginOf(file);
3830
- noteEl.textContent = origin === "machinery" ? "engine note (not your source)"
3831
- : origin === "engineInput" ? "source: engine-input"
3832
- : "source: original (via source map)";
3833
- noteEl.setAttribute("data-tip", origin === "machinery"
3834
- ? "Not one of your files. This is the engine's accounting bucket for spans that map to no original source; the text in the pane is a fixed note the engine wrote, and the regions listed against it are measured in BUNDLE positions, so nothing here is painted over your code."
3835
- : origin === "engineInput"
3836
- ? "Colored over engine-input source — if this input was bundled, provide a source map to see pre-bundle original source."
3837
- : "Colored over original source (recovered via input source map).");
3662
+ var noteEl = document.getElementById("head-note");
3663
+ if (!noteEl) return;
3664
+ var machinery = sourceOriginOf(file) === "machinery";
3665
+ noteEl.hidden = !machinery;
3666
+ noteEl.textContent = machinery ? "AfterPack runtime (not your code)" : "";
3667
+ if (machinery) {
3668
+ noteEl.setAttribute("data-tip", "Not one of your files. It holds protection that can't be tied to one line of your source, such as shared decoders.");
3669
+ } else {
3670
+ noteEl.removeAttribute("data-tip");
3671
+ }
3838
3672
  }
3839
3673
 
3840
3674
  function onActiveFileChanged() {
@@ -3852,7 +3686,6 @@ async function afterpackInflateBase64Gzip(b64) {
3852
3686
  paintCode(file);
3853
3687
  renderWeakSpots(file);
3854
3688
  highlightSelectionRing();
3855
- applyHighlightClass();
3856
3689
  renderInspector();
3857
3690
  }
3858
3691
 
@@ -4012,6 +3845,7 @@ async function afterpackInflateBase64Gzip(b64) {
4012
3845
 
4013
3846
  var tooltipEl = document.getElementById("tooltip");
4014
3847
  var tipTarget = null;
3848
+ var tipHideTimer = null;
4015
3849
  function positionTip(el) {
4016
3850
  var r = el.getBoundingClientRect();
4017
3851
  var tr = tooltipEl.getBoundingClientRect();
@@ -4025,15 +3859,34 @@ async function afterpackInflateBase64Gzip(b64) {
4025
3859
  function showTip(el) {
4026
3860
  var tip = el.getAttribute("data-tip");
4027
3861
  if (!tip) return;
3862
+ clearTimeout(tipHideTimer);
4028
3863
  tipTarget = el;
4029
3864
  tooltipEl.textContent = tip;
3865
+ var href = docUrl(el.getAttribute("data-doc"));
3866
+ if (href) {
3867
+ var a = document.createElement("a");
3868
+ a.className = "tip-link";
3869
+ a.href = href;
3870
+ a.target = "_blank";
3871
+ a.rel = "noopener noreferrer";
3872
+ a.textContent = "Learn more ↗";
3873
+ tooltipEl.appendChild(document.createElement("br"));
3874
+ tooltipEl.appendChild(a);
3875
+ }
3876
+ tooltipEl.classList.toggle("has-link", !!href);
4030
3877
  tooltipEl.hidden = false;
4031
3878
  positionTip(el);
4032
3879
  tooltipEl.setAttribute("data-show", "");
4033
3880
  }
4034
3881
  function hideTip() {
3882
+ clearTimeout(tipHideTimer);
4035
3883
  tipTarget = null;
4036
3884
  tooltipEl.removeAttribute("data-show");
3885
+ tooltipEl.classList.remove("has-link");
3886
+ }
3887
+ function hideTipSoon() {
3888
+ clearTimeout(tipHideTimer);
3889
+ tipHideTimer = setTimeout(hideTip, tooltipEl.classList.contains("has-link") ? 260 : 0);
4037
3890
  }
4038
3891
 
4039
3892
  var THEME_LABEL = { light: "☀ Light", dark: "🌙 Dark" };
@@ -4041,11 +3894,6 @@ async function afterpackInflateBase64Gzip(b64) {
4041
3894
  function systemTheme() {
4042
3895
  return window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
4043
3896
  }
4044
- function repaintForTheme() {
4045
- var file = activeFile();
4046
- renderDirectiveLegend();
4047
- if (file) { paintCode(file); renderTree(); renderLegend(); highlightSelectionRing(); }
4048
- }
4049
3897
  function labelTheme(mode) {
4050
3898
  themeBtn.dataset.theme = mode;
4051
3899
  themeBtn.textContent = THEME_LABEL[mode] || THEME_LABEL.dark;
@@ -4055,10 +3903,9 @@ async function afterpackInflateBase64Gzip(b64) {
4055
3903
  if (mode !== "light" && mode !== "dark") mode = systemTheme();
4056
3904
  document.documentElement.setAttribute("data-theme", mode);
4057
3905
  labelTheme(mode);
4058
- if (forced) { if (!quiet) repaintForTheme(); return; }
3906
+ if (forced) return;
4059
3907
  setPref("theme", mode);
4060
3908
  try { localStorage.setItem(THEME_KEY, mode); } catch (e) {}
4061
- if (!quiet) repaintForTheme();
4062
3909
  }
4063
3910
 
4064
3911
  function wireEvents() {
@@ -4092,13 +3939,20 @@ async function afterpackInflateBase64Gzip(b64) {
4092
3939
  });
4093
3940
  document.addEventListener("mouseout", function (e) {
4094
3941
  var el = e.target.closest ? e.target.closest("[data-tip]") : null;
4095
- if (el && el === tipTarget && !el.contains(e.relatedTarget)) hideTip();
3942
+ if (el && el === tipTarget && !el.contains(e.relatedTarget)) hideTipSoon();
4096
3943
  });
3944
+ tooltipEl.addEventListener("mouseenter", function () { clearTimeout(tipHideTimer); });
3945
+ tooltipEl.addEventListener("mouseleave", hideTipSoon);
4097
3946
  document.addEventListener("focusin", function (e) {
4098
3947
  var el = e.target.closest ? e.target.closest("[data-tip]") : null;
4099
- if (el) showTip(el);
3948
+ var keyboard = true;
3949
+ try { keyboard = !e.target.matches || e.target.matches(":focus-visible"); } catch (err) { keyboard = true; }
3950
+ if (el && keyboard) showTip(el);
3951
+ });
3952
+ document.addEventListener("focusout", function (e) {
3953
+ if (e.relatedTarget && tooltipEl.contains(e.relatedTarget)) return;
3954
+ hideTipSoon();
4100
3955
  });
4101
- document.addEventListener("focusout", function () { hideTip(); });
4102
3956
 
4103
3957
  themeBtn.addEventListener("click", function () {
4104
3958
  applyTheme((themeBtn.dataset.theme || systemTheme()) === "dark" ? "light" : "dark");
@@ -4108,7 +3962,6 @@ async function afterpackInflateBase64Gzip(b64) {
4108
3962
  var onSystemThemeChange = function () {
4109
3963
  if (document.documentElement.hasAttribute("data-theme")) return;
4110
3964
  labelTheme(systemTheme());
4111
- repaintForTheme();
4112
3965
  };
4113
3966
  if (darkQuery.addEventListener) darkQuery.addEventListener("change", onSystemThemeChange);
4114
3967
  else if (darkQuery.addListener) darkQuery.addListener(onSystemThemeChange);
@@ -4143,7 +3996,7 @@ async function afterpackInflateBase64Gzip(b64) {
4143
3996
  if (!state.selection) return;
4144
3997
  var t = e.target;
4145
3998
  if (!t || !t.closest) return;
4146
- if (t.closest(".tok") || t.closest(".rail-left, .rail-right, .topbar, .popover, .tooltip, .pane-resizer, .file-summary, .code-toolbar")) return;
3999
+ if (t.closest(".tok") || t.closest(".rail-left, .rail-right, .topbar, .popover, .tooltip, .pane-resizer, .file-summary")) return;
4147
4000
  clearSelection();
4148
4001
  });
4149
4002
  var headEl = document.getElementById("file-summary");
@@ -4158,8 +4011,6 @@ async function afterpackInflateBase64Gzip(b64) {
4158
4011
  if (btn) jumpToSpotlight(Number(btn.dataset.jumpSpotlight));
4159
4012
  });
4160
4013
  document.getElementById("inspector").addEventListener("click", function (e) {
4161
- var btn = e.target.closest("[data-copy]");
4162
- if (btn) { copyText(decodeURIComponent(btn.dataset.copy), btn); return; }
4163
4014
  var jump = e.target.closest("[data-select-region]");
4164
4015
  if (jump) {
4165
4016
  var idx = Number(jump.dataset.selectRegion);
@@ -4191,10 +4042,6 @@ async function afterpackInflateBase64Gzip(b64) {
4191
4042
  onActiveFileChanged();
4192
4043
  }
4193
4044
  });
4194
- highlightToggle.addEventListener("change", function () {
4195
- state.highlightClassOn = highlightToggle.checked;
4196
- applyHighlightClass();
4197
- });
4198
4045
  var filterEl = document.getElementById("file-filter");
4199
4046
  if (filterEl) {
4200
4047
  filterEl.addEventListener("click", function (e) {
@@ -4245,10 +4092,14 @@ async function afterpackInflateBase64Gzip(b64) {
4245
4092
  var brandLink = document.getElementById("brand-logo");
4246
4093
  if (brandLink) brandLink.setAttribute("href", ["https", "//www.afterpack.dev"].join(":"));
4247
4094
 
4248
- renderClassLegendStatic();
4095
+ document.querySelectorAll("a[data-doc-link]").forEach(function (a) {
4096
+ var href = docUrl(a.getAttribute("data-doc-link"));
4097
+ if (href) a.setAttribute("href", href);
4098
+ });
4249
4099
  renderDirectiveLegend();
4250
4100
  renderWorkspaceSummary();
4251
- renderMapSize();
4101
+ renderPrivacyTag();
4102
+ renderBuildComplexity();
4252
4103
  var markedBtn = document.getElementById("filter-marked");
4253
4104
  if (markedBtn && !FILES.some(isMarkedFile)) markedBtn.remove();
4254
4105
  var weakBtn = document.getElementById("filter-weak");
@@ -4275,7 +4126,7 @@ async function afterpackInflateBase64Gzip(b64) {
4275
4126
 
4276
4127
  var file = activeFile();
4277
4128
  if (!file) {
4278
- document.getElementById("code-body").textContent = "No files in this Protection Map document.";
4129
+ document.getElementById("code-body").textContent = "This Protection Map has no files.";
4279
4130
  return;
4280
4131
  }
4281
4132
 
@@ -4289,7 +4140,6 @@ async function afterpackInflateBase64Gzip(b64) {
4289
4140
  renderEngineInfo(file);
4290
4141
  paintCode(file);
4291
4142
  renderWeakSpots(file);
4292
- applyHighlightClass();
4293
4143
  renderInspector();
4294
4144
  scrollTreeToActive();
4295
4145
  syncHash();