@mayder/devibe 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,731 @@
1
+ <section id="atlas-review" aria-label="DeVibe, explorador de código local">
2
+ <header class="ar-bar">
3
+ <div class="ar-brand"><span class="ar-mark" aria-hidden="true"><i data-lucide="route"></i></span><strong>DeVibe</strong></div>
4
+ <div class="ar-project"><span data-case-project>Proyecto</span><span aria-hidden="true">/</span><span data-case-area>Recorrido</span></div>
5
+ <span class="ar-local"><i data-lucide="hard-drive" aria-hidden="true"></i> <span data-case-environment></span></span>
6
+ <label class="ar-preference">Tema <select data-ui-theme aria-label="Tema de la interfaz"><option value="auto">Sistema</option><option value="light">Claro</option><option value="dark">Oscuro</option></select></label>
7
+ </header>
8
+ <main class="ar-main">
9
+ <div class="ar-heading">
10
+ <div><h2 data-case-title>Explorar código</h2><p data-case-summary></p></div>
11
+ <span class="ar-revision"><i data-lucide="git-commit-horizontal" aria-hidden="true"></i><code></code></span>
12
+ </div>
13
+ <div class="ar-entry" hidden>
14
+ <label for="atlas-entry">Punto de entrada</label>
15
+ <select id="atlas-entry" aria-describedby="atlas-entry-status"></select>
16
+ <span id="atlas-entry-status" aria-live="polite"></span>
17
+ </div>
18
+ <nav class="ar-nav" aria-label="Modos de exploración">
19
+ <button type="button" data-mode="learn" aria-pressed="true">Entender</button>
20
+ <button type="button" data-mode="diff" aria-pressed="false">Ver cambios</button>
21
+ <button type="button" data-mode="review" aria-pressed="false">Revisar</button>
22
+ </nav>
23
+ <div class="ar-context" hidden></div>
24
+ <div class="ar-workbench">
25
+ <section class="ar-flow" aria-labelledby="ar-flow-title">
26
+ <div class="ar-section-title">
27
+ <h3 id="ar-flow-title">Recorrido</h3>
28
+ <div class="ar-layout" role="group" aria-label="Vista del recorrido">
29
+ <button type="button" data-layout="iso" aria-pressed="true">Isométrico</button>
30
+ <button type="button" data-layout="steps" aria-pressed="false">Pasos</button>
31
+ </div>
32
+ </div>
33
+ <div class="ar-map" role="group" aria-label="Mapa espacial del recorrido">
34
+ <div class="ar-map-tools">
35
+ <label>Detalle
36
+ <select data-detail><option value="module">Módulos</option><option value="symbol">Clases y funciones</option><option value="call">Llamadas</option></select>
37
+ </label>
38
+ <label>Cámara
39
+ <select data-camera><option value="diagonal">Diagonal</option><option value="opposite">Lado opuesto</option><option value="high">Elevada</option></select>
40
+ </label>
41
+ <details class="ar-filters">
42
+ <summary>Mostrar</summary>
43
+ <fieldset aria-label="Elementos del mapa">
44
+ <label><input type="checkbox" data-layer="web" checked> Interfaz</label>
45
+ <label><input type="checkbox" data-layer="api" checked> API</label>
46
+ <label><input type="checkbox" data-layer="data" checked> Datos</label>
47
+ <label><input type="checkbox" data-layer="error"> Rama de error</label>
48
+ </fieldset>
49
+ </details>
50
+ </div>
51
+ <div class="ar-scene">
52
+ <svg class="ar-world" viewBox="0 0 420 292" aria-hidden="true" focusable="false"></svg>
53
+ <div class="ar-pins"></div>
54
+ </div>
55
+ <div class="ar-map-foot">
56
+ <button type="button" class="ar-map-return" data-step="3" aria-pressed="false">Ver respuesta</button>
57
+ <span class="ar-hidden" aria-live="polite"></span>
58
+ </div>
59
+ <div class="ar-detail-list" hidden></div>
60
+ </div>
61
+ <ol class="ar-steps" hidden></ol>
62
+ </section>
63
+ <aside class="ar-inspector" aria-labelledby="ar-inspector-title">
64
+ <div class="ar-section-title"><h3 id="ar-inspector-title">Evidencia</h3><label class="ar-preference">Código <select data-code-theme aria-label="Tema del código"><option value="devibe">DeVibe</option><option value="light">Claro</option><option value="dark">Oscuro</option></select></label></div>
65
+ <div class="ar-evidence" aria-live="polite"></div>
66
+ </aside>
67
+ </div>
68
+ </main>
69
+ </section>
70
+ <style>
71
+ #atlas-review {
72
+ color-scheme: light dark;
73
+ --ar-bg: light-dark(#f8faed,#191d1b);
74
+ --ar-paper: light-dark(#fffff8,#232825);
75
+ --ar-ink: light-dark(#243319,#e9efea);
76
+ --ar-sub: light-dark(#50603f,#adbdb1);
77
+ --ar-line: light-dark(#d8e1bd,#3b483e);
78
+ --ar-green: light-dark(#355413,#a9d7bd);
79
+ --ar-selection: light-dark(#e9f5ba,#2a4335);
80
+ --ar-review: light-dark(#f9f0df,#3e3426);
81
+ --ar-amber: light-dark(#73501e,#eec686);
82
+ --ar-code: light-dark(#f0f5e3,#1a211d);
83
+ --ar-map-line: light-dark(#748652,#91b09f);
84
+ --ar-map-ground: light-dark(#f0f6db,#1e2721);
85
+ --syntax-bg: var(--ar-code);
86
+ --syntax-ink: var(--ar-ink);
87
+ --syntax-line: var(--ar-line);
88
+ --syntax-keyword: light-dark(#68327f,#d4b6ff);
89
+ --syntax-string: light-dark(#356316,#bedc8e);
90
+ --syntax-number: light-dark(#92430b,#f3b288);
91
+ --syntax-name: light-dark(#175b76,#a0d6f3);
92
+ --syntax-comment: light-dark(#57664b,#a2b3a6);
93
+ --syntax-selection: var(--ar-selection);
94
+ --syntax-removal: var(--ar-review);
95
+ --ar-mono: 'Cascadia Code', Consolas, monospace;
96
+ border: 1px solid var(--ar-line);
97
+ border-radius: 15px;
98
+ overflow: clip;
99
+ container-type: inline-size;
100
+ background: var(--ar-bg);
101
+ color: var(--ar-ink);
102
+ font: 14px/1.45 'Aptos','Segoe UI',system-ui,sans-serif;
103
+ text-align: start;
104
+ }
105
+ #atlas-review[data-ui-theme="light"] { color-scheme: light; }
106
+ #atlas-review[data-ui-theme="dark"] { color-scheme: dark; }
107
+ #atlas-review[data-code-theme="light"] {
108
+ --syntax-bg: #f7f8fa; --syntax-ink: #24292f; --syntax-line: #d0d7de;
109
+ --syntax-keyword: #a32945; --syntax-string: #124b78; --syntax-number: #0550ae;
110
+ --syntax-name: #633598; --syntax-comment: #59636d; --syntax-selection: #def6e5; --syntax-removal: #ffebe9;
111
+ }
112
+ #atlas-review[data-code-theme="dark"] {
113
+ --syntax-bg: #101722; --syntax-ink: #f0f3f6; --syntax-line: #394659;
114
+ --syntax-keyword: #ff9bab; --syntax-string: #a5d6ff; --syntax-number: #ffbe98;
115
+ --syntax-name: #d2a8ff; --syntax-comment: #a6b2c2; --syntax-selection: #1b3b32; --syntax-removal: #49262a;
116
+ }
117
+ #atlas-review *, #atlas-review *::before, #atlas-review *::after { box-sizing: border-box; }
118
+ #atlas-review :is(h2,h3,h4,p,ol,ul) { margin: 0; }
119
+ #atlas-review [hidden] { display: none !important; }
120
+ #atlas-review button { color: inherit; font: inherit; cursor: pointer; }
121
+ #atlas-review button:focus-visible { outline: 2px solid var(--ar-green); outline-offset: 2px; }
122
+ #atlas-review :is(svg.lucide,i[data-lucide]) { width: 16px; height: 16px; flex: none; }
123
+ #atlas-review code { font: 12px/1.55 var(--ar-mono); overflow-wrap: anywhere; }
124
+ #atlas-review .ar-bar { min-height: 58px; padding: 9px 23px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; background: var(--ar-paper); border-bottom: 1px solid var(--ar-line); }
125
+ #atlas-review :is(.ar-brand,.ar-project,.ar-local,.ar-revision) { display: inline-flex; align-items: center; gap: 8px; }
126
+ #atlas-review .ar-brand strong { font-size: 19px; letter-spacing: -.04em; }
127
+ #atlas-review .ar-mark { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 7px; background: var(--ar-selection); color: var(--ar-green); }
128
+ #atlas-review .ar-project { color: var(--ar-sub); font-size: 13px; flex-wrap: wrap; }
129
+ #atlas-review .ar-local { margin-inline-start: auto; color: var(--ar-sub); font-size: 12px; }
130
+ #atlas-review .ar-preference { display: flex; align-items: center; gap: 6px; color: var(--ar-sub); font-size: 12px; }
131
+ #atlas-review .ar-preference select { min-height: 32px; max-width: 100%; border: 1px solid var(--ar-line); border-radius: 6px; background: var(--ar-paper); color: var(--ar-ink); padding: 3px 6px; font: inherit; }
132
+ #atlas-review .ar-main { padding: 22px 23px; }
133
+ #atlas-review .ar-heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
134
+ #atlas-review .ar-heading h2 { font: 500 clamp(25px,4.4cqi,41px)/1.08 Georgia,serif; letter-spacing: -.045em; }
135
+ #atlas-review .ar-heading p { margin-top: 7px; color: var(--ar-sub); }
136
+ #atlas-review .ar-revision { color: var(--ar-sub); }
137
+ #atlas-review .ar-entry { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 12px; }
138
+ #atlas-review :is(.ar-entry,.ar-changed-files) select { border: 1px solid var(--ar-line); border-radius: 6px; background: var(--ar-paper); color: var(--ar-ink); padding: 6px; max-width: 100%; font: inherit; }
139
+ #atlas-review .ar-entry span { color: var(--ar-sub); font-size: 12px; }
140
+ #atlas-review .ar-nav { display: flex; flex-wrap: wrap; align-items: end; gap: 15px; margin: 15px 0 14px; border-bottom: 1px solid var(--ar-line); }
141
+ #atlas-review .ar-nav button { padding: 0 2px; min-height: 44px; border: 0; border-bottom: 2px solid transparent; font-weight: 550; color: var(--ar-sub); background: transparent; }
142
+ #atlas-review .ar-nav button[aria-pressed="true"] { border-bottom-color: var(--ar-green); color: var(--ar-green); font-weight: 700; }
143
+ #atlas-review .ar-context { margin-bottom: 13px; padding: 11px 13px; border: 1px solid var(--ar-line); border-left: 3px solid var(--ar-green); border-radius: 8px; background: var(--ar-paper); }
144
+ #atlas-review .ar-context p { margin-top: 3px; color: var(--ar-sub); }
145
+ #atlas-review .ar-changed-files { margin-top: 6px; color: var(--ar-sub); }
146
+ #atlas-review .ar-changed-files summary { cursor: pointer; }
147
+ #atlas-review .ar-changed-files ul { padding-inline-start: 21px; }
148
+ #atlas-review .ar-changed-files label { display: grid; justify-items: start; gap: 3px; margin-top: 8px; }
149
+ #atlas-review .ar-patch { display: grid; gap: 7px; margin-top: 7px; min-width: 0; }
150
+ #atlas-review .ar-patch pre { min-width: 0; margin: 0; padding: 3px 0; background: var(--syntax-bg); color: var(--syntax-ink); border: 1px solid var(--syntax-line); border-radius: 6px; font: 12px/1.45 var(--ar-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
151
+ #atlas-review .ar-patch-line { display: grid; grid-template-columns: minmax(2ch,5ch) minmax(2ch,5ch) 1.5ch minmax(0,1fr); gap: 5px; padding: 2px 6px; }
152
+ #atlas-review .ar-patch-gutter { text-align: end; color: var(--syntax-comment); }
153
+ #atlas-review .ar-patch-line[data-kind="add"] { background: var(--syntax-selection); }
154
+ #atlas-review .ar-patch-line[data-kind="remove"] { background: var(--syntax-removal); }
155
+ #atlas-review .ar-patch-header { font: 12px var(--ar-mono); color: var(--ar-sub); }
156
+ #atlas-review .ar-patch-jump { justify-self: start; border: 1px solid var(--ar-line); border-radius: 6px; background: var(--ar-paper); padding: 4px 8px; color: var(--ar-green); }
157
+ #atlas-review .ar-review-options { list-style: none; display: flex; gap: 5px 12px; flex-wrap: wrap; padding: 0; margin-top: 6px; }
158
+ #atlas-review .ar-review-options button { background: transparent; border: 1px solid var(--ar-line); border-radius: 6px; min-height: 39px; padding: 4px 8px; text-align: start; }
159
+ #atlas-review .ar-review-options button[aria-pressed="true"] { background: var(--ar-selection); border-color: var(--ar-green); }
160
+ #atlas-review .ar-review-options small { color: var(--ar-amber); }
161
+ #atlas-review .ar-workbench { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 13px; align-items: stretch; }
162
+ #atlas-review :is(.ar-flow,.ar-inspector) { min-width: 0; background: var(--ar-paper); border: 1px solid var(--ar-line); border-radius: 10px; }
163
+ #atlas-review .ar-section-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 13px; border-bottom: 1px solid var(--ar-line); }
164
+ #atlas-review .ar-section-title h3 { font-size: 13px; font-weight: 690; }
165
+ #atlas-review .ar-section-title span { color: var(--ar-sub); font-size: 12px; }
166
+ #atlas-review .ar-layout { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--ar-line); border-radius: 7px; }
167
+ #atlas-review .ar-layout button { min-height: 27px; padding: 3px 7px; border: 0; border-radius: 4px; background: transparent; color: var(--ar-sub); font-size: 12px; }
168
+ #atlas-review .ar-layout button[aria-pressed="true"] { color: var(--ar-green); background: var(--ar-selection); font-weight: 690; }
169
+ #atlas-review .ar-steps { list-style: none; padding: 12px; display: grid; gap: 8px; }
170
+ #atlas-review .ar-steps li { position: relative; }
171
+ #atlas-review .ar-steps li + li::before { content: ''; position: absolute; top: -9px; left: 26px; height: 9px; border-inline-start: 1px solid var(--ar-green); }
172
+ #atlas-review .ar-steps[data-static] li + li::before { content: none; }
173
+ #atlas-review .ar-step { width: 100%; display: grid; grid-template-columns: 30px minmax(0,1fr) auto; gap: 9px; align-items: center; text-align: start; min-height: 57px; padding: 6px 9px; border: 1px solid var(--ar-line); border-radius: 8px; background: var(--ar-paper); }
174
+ #atlas-review .ar-step:is(:hover,[aria-pressed="true"]) { background: var(--ar-selection); }
175
+ #atlas-review .ar-step[aria-pressed="true"] { border-color: var(--ar-green); }
176
+ #atlas-review .ar-step strong { display: block; }
177
+ #atlas-review .ar-step code { display: block; color: var(--ar-sub); line-height: 1.3; }
178
+ #atlas-review .ar-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 6px; background: var(--ar-code); color: var(--ar-green); }
179
+ #atlas-review .ar-change { font-size: 11px; font-weight: 630; color: var(--ar-green); }
180
+ #atlas-review .ar-map-tools { position: relative; display: flex; flex-wrap: wrap; align-items: end; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--ar-line); }
181
+ #atlas-review .ar-map-tools > label { display: grid; gap: 2px; min-width: 0; color: var(--ar-sub); font-size: 11px; }
182
+ #atlas-review .ar-map-tools :is(select,summary) { min-height: 33px; max-width: 100%; padding: 4px 6px; border: 1px solid var(--ar-line); border-radius: 6px; background: var(--ar-paper); color: var(--ar-ink); font: 12px/1.4 'Aptos','Segoe UI',sans-serif; }
183
+ #atlas-review .ar-filters { font-size: 12px; }
184
+ #atlas-review .ar-filters summary { align-content: center; cursor: pointer; }
185
+ #atlas-review .ar-filters fieldset { position: absolute; z-index: 2; inset-inline-end: 12px; inset-block-start: calc(100% - 4px); display: grid; min-width: 139px; margin: 0; padding: 5px 9px; border: 1px solid var(--ar-line); border-radius: 7px; background: var(--ar-paper); box-shadow: 0 9px 20px color-mix(in srgb,var(--ar-ink) 13%,transparent); }
186
+ #atlas-review .ar-filters label { min-height: 29px; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
187
+ #atlas-review .ar-filters input { accent-color: var(--ar-green); }
188
+ #atlas-review .ar-scene { position: relative; aspect-ratio: 420 / 292; background: var(--ar-map-ground); }
189
+ #atlas-review .ar-world, #atlas-review .ar-pins { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
190
+ #atlas-review .ar-pins { pointer-events: none; }
191
+ #atlas-review .ar-pin { position: absolute; display: grid; justify-items: center; width: max-content; min-width: 60px; max-width: 32%; transform: translate(-50%,-50%); padding: 4px 6px; text-align: center; border: 1px solid var(--ar-line); border-radius: 6px; background: var(--ar-paper); pointer-events: auto; }
192
+ #atlas-review .ar-pin strong { font-size: 12px; line-height: 1.15; }
193
+ #atlas-review .ar-pin span { color: var(--ar-sub); font-size: 11px; line-height: 1.15; }
194
+ #atlas-review .ar-pin:is(:hover,[aria-pressed="true"]) { background: var(--ar-selection); border-color: var(--ar-green); }
195
+ #atlas-review .ar-floor { fill: var(--ar-paper); stroke: var(--ar-line); }
196
+ #atlas-review .ar-gridline { fill: none; stroke: var(--ar-line); stroke-width: .85; }
197
+ #atlas-review .ar-dropline { fill: none; stroke: var(--ar-map-line); stroke-width: .9; }
198
+ #atlas-review .ar-plinth { --ar-top: light-dark(#e6ebe1,#32433a); --ar-face: light-dark(#c7d3c6,#29382f); --ar-side: light-dark(#b4c3b4,#26362e); }
199
+ #atlas-review .ar-web { --ar-top: light-dark(#d5e7db,#416450); --ar-face: light-dark(#eef8ef,#314b3d); --ar-side: light-dark(#91b49f,#263e33); }
200
+ #atlas-review .ar-api { --ar-top: light-dark(#dae6ec,#46636d); --ar-face: light-dark(#adc7d1,#344f5b); --ar-side: light-dark(#7f9eab,#2e434e); }
201
+ #atlas-review .ar-data { --ar-top: light-dark(#e9dfc9,#66573a); --ar-face: light-dark(#dbcbaa,#514630); --ar-side: light-dark(#bda782,#413820); }
202
+ #atlas-review .ar-error { --ar-top: var(--ar-review); --ar-face: var(--ar-review); --ar-side: var(--ar-amber); }
203
+ #atlas-review :is(.ar-form-top,.ar-form-face,.ar-form-side) { stroke: var(--ar-map-line); stroke-width: .85; stroke-linejoin: round; }
204
+ #atlas-review .ar-form-top { fill: var(--ar-top); }
205
+ #atlas-review .ar-form-face { fill: var(--ar-face); }
206
+ #atlas-review .ar-form-side { fill: var(--ar-side); }
207
+ #atlas-review .ar-form-shadow { fill: var(--ar-ink); opacity: .1; }
208
+ #atlas-review .ar-form-detail { fill: none; stroke: var(--ar-map-line); stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
209
+ #atlas-review .ar-connection { fill: none; stroke: var(--ar-green); stroke-width: 1.7; stroke-linejoin: round; }
210
+ #atlas-review .ar-connection.ar-secondary { stroke: var(--ar-map-line); stroke-dasharray: 4 3; }
211
+ #atlas-review .ar-arrowhead { fill: var(--ar-green); }
212
+ #atlas-review .ar-edge-label { font: 650 17px/1 'Aptos','Segoe UI',sans-serif; fill: var(--ar-ink); paint-order: stroke; stroke: var(--ar-paper); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
213
+ #atlas-review .ar-map-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 10px 9px; background: var(--ar-map-ground); }
214
+ #atlas-review .ar-map-return { min-height: 33px; padding: 4px 7px; border: 1px solid var(--ar-line); border-radius: 6px; background: var(--ar-paper); color: var(--ar-green); font-size: 12px; }
215
+ #atlas-review .ar-map-return:is(:hover,[aria-pressed="true"]) { background: var(--ar-selection); border-color: var(--ar-green); }
216
+ #atlas-review .ar-hidden { font-size: 11px; color: var(--ar-sub); }
217
+ #atlas-review .ar-detail-list { display: grid; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--ar-line); }
218
+ #atlas-review .ar-detail-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
219
+ #atlas-review .ar-detail-group h4 { font-size: 11px; color: var(--ar-sub); padding: 0 3px; }
220
+ #atlas-review .ar-detail-group button { display: grid; justify-items: start; max-width: 100%; min-height: 35px; padding: 4px 6px; text-align: start; background: var(--ar-paper); border: 1px solid var(--ar-line); border-radius: 5px; }
221
+ #atlas-review .ar-detail-group button[aria-pressed="true"] { border-color: var(--ar-green); background: var(--ar-selection); }
222
+ #atlas-review .ar-detail-group code { font-size: 11px; line-height: 1.2; }
223
+ #atlas-review .ar-detail-group small { color: var(--ar-sub); font-size: 11px; }
224
+ #atlas-review .ar-evidence { display: grid; gap: 8px; padding: 12px 13px 14px; align-content: start; }
225
+ #atlas-review .ar-evidence h4 { font-size: 17px; letter-spacing: -.02em; }
226
+ #atlas-review .ar-evidence p { color: var(--ar-sub); }
227
+ #atlas-review .ar-status { justify-self: start; color: var(--ar-green); background: var(--ar-selection); padding: 3px 6px; border-radius: 5px; font-size: 11px; font-weight: 670; }
228
+ #atlas-review .ar-status.ar-pending { color: var(--ar-amber); background: var(--ar-review); }
229
+ #atlas-review .ar-code { min-width: 0; border: 1px solid var(--syntax-line); border-radius: 7px; background: var(--syntax-bg); color: var(--syntax-ink); }
230
+ #atlas-review .ar-code-head { min-width: 0; padding: 6px 8px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 7px; border-bottom: 1px solid var(--syntax-line); }
231
+ #atlas-review .ar-code-head strong { font-size: 12px; }
232
+ #atlas-review .ar-code-head code { color: var(--syntax-comment); }
233
+ #atlas-review .ar-code-line { padding: 1px 7px; display: grid; gap: 5px; grid-template-columns: 22px minmax(0,1fr); }
234
+ #atlas-review .ar-code-line:first-of-type { padding-top: 4px; }
235
+ #atlas-review .ar-code-line:last-child { padding-bottom: 5px; }
236
+ #atlas-review .ar-code-line[data-hit] { background: var(--syntax-selection); }
237
+ #atlas-review .ar-code-line > span { text-align: end; color: var(--syntax-comment); font: 12px/1.55 var(--ar-mono); }
238
+ #atlas-review .ar-code-line code { white-space: pre-wrap; font-size: 12px; }
239
+ #atlas-review :is(.ar-code,.ar-patch) :is(.hljs-keyword,.hljs-built_in,.hljs-type,.hljs-selector-tag) { color: var(--syntax-keyword); }
240
+ #atlas-review :is(.ar-code,.ar-patch) :is(.hljs-string,.hljs-regexp) { color: var(--syntax-string); }
241
+ #atlas-review :is(.ar-code,.ar-patch) :is(.hljs-number,.hljs-literal,.hljs-symbol) { color: var(--syntax-number); }
242
+ #atlas-review :is(.ar-code,.ar-patch) :is(.hljs-title,.hljs-attr,.hljs-attribute,.hljs-name,.hljs-variable) { color: var(--syntax-name); }
243
+ #atlas-review :is(.ar-code,.ar-patch) :is(.hljs-comment,.hljs-quote,.hljs-doctag) { color: var(--syntax-comment); }
244
+ @container (max-width: 630px) {
245
+ #atlas-review .ar-workbench { grid-template-columns: minmax(0,1fr); }
246
+ }
247
+ @container (max-width: 420px) {
248
+ #atlas-review .ar-main, #atlas-review .ar-bar { padding-inline: 11px; }
249
+ #atlas-review .ar-local { margin-inline-start: 0; }
250
+ #atlas-review .ar-step { column-gap: 6px; }
251
+ }
252
+ @media (pointer: coarse) {
253
+ #atlas-review :is(.ar-review-options,.ar-layout,.ar-detail-list) button, #atlas-review .ar-map-tools :is(select,summary), #atlas-review :is(.ar-pin,.ar-map-return,.ar-filters label) { min-height: 44px; }
254
+ }
255
+ </style>
256
+ <script>
257
+ (() => {
258
+ const root = document.getElementById('atlas-review');
259
+ const steps = root.querySelector('.ar-steps');
260
+ const evidence = root.querySelector('.ar-evidence');
261
+ const context = root.querySelector('.ar-context');
262
+ const revision = root.querySelector('.ar-revision code');
263
+ const map = root.querySelector('.ar-map');
264
+ const world = map.querySelector('.ar-world');
265
+ const pins = map.querySelector('.ar-pins');
266
+ const detailList = map.querySelector('.ar-detail-list');
267
+ const filterStatus = map.querySelector('.ar-hidden');
268
+ const dataElement = document.getElementById('atlas-case-data');
269
+ function bindPreference(selector, key, apply) {
270
+ const control = root.querySelector(selector);
271
+ try {
272
+ const saved = localStorage.getItem(key);
273
+ if ([...control.options].some(option => option.value === saved)) control.value = saved;
274
+ } catch {}
275
+ apply(control.value);
276
+ control.addEventListener('change', () => {
277
+ apply(control.value);
278
+ try { localStorage.setItem(key, control.value); } catch {}
279
+ });
280
+ }
281
+ bindPreference('[data-ui-theme]', 'devibe-theme', value => {
282
+ root.dataset.uiTheme = value;
283
+ if (dataElement) document.documentElement.dataset.devibeTheme = value;
284
+ });
285
+ bindPreference('[data-code-theme]', 'devibe-code-theme', value => { root.dataset.codeTheme = value; });
286
+ let atlasCase = dataElement ? JSON.parse(dataElement.textContent) : null;
287
+ if (!atlasCase) throw Error('DeVibe necesita datos de un proyecto.');
288
+ const graphProject = atlasCase?.graph;
289
+ const entrySelect = root.querySelector('#atlas-entry');
290
+ const entryStatus = root.querySelector('#atlas-entry-status');
291
+ const revisionLabel = value => /^[a-f0-9]{40,64}$/.test(value) ? value.slice(0, 7) : value;
292
+ const baseRevision = revisionLabel(atlasCase.base);
293
+ const headRevision = revisionLabel(atlasCase.head);
294
+ const escapeMarkup = value => value.replace(/[&<>"']/g, char => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char]);
295
+ const { diff: atlasDiff, review } = atlasCase;
296
+ if (atlasCase) {
297
+ root.querySelector('[data-case-project]').textContent = atlasCase.project;
298
+ root.querySelector('[data-case-area]').textContent = atlasCase.area;
299
+ root.querySelector('[data-case-title]').textContent = atlasCase.title;
300
+ root.querySelector('[data-case-summary]').textContent = atlasCase.summary;
301
+ root.querySelector('[data-case-environment]').textContent = atlasCase.environment === 'demo' ? 'Demo local' : 'Código local';
302
+ map.setAttribute('aria-label', `Mapa espacial: ${atlasCase.title}`);
303
+ map.querySelector('.ar-map-return').textContent = atlasCase.labels.response;
304
+ }
305
+ if (graphProject) {
306
+ root.querySelector('.ar-layout').hidden = true;
307
+ root.querySelector('#ar-flow-title').textContent = 'Llamadas detectadas';
308
+ steps.setAttribute('data-static', '');
309
+ root.querySelector('.ar-entry').hidden = graphProject.entries.length === 0;
310
+ for (const entry of graphProject.entries) {
311
+ const option = document.createElement('option');
312
+ option.value = entry.id;
313
+ option.textContent = entry.file ? `${entry.label} · ${entry.file}` : entry.label;
314
+ entrySelect.add(option);
315
+ }
316
+ entrySelect.value = graphProject.selected;
317
+ }
318
+ let flow = atlasCase.flow;
319
+ const places = {
320
+ web: { ...atlasCase.places.web, x: -115, y: 4, labelOffset: 58, step: 0 },
321
+ api: { ...atlasCase.places.api, x: 0, y: -24, labelOffset: 45, step: 1 },
322
+ data: { ...atlasCase.places.data, x: 115, y: 8, labelOffset: 45, step: 2 },
323
+ error: { ...atlasCase.places.error, x: 62, y: 75, labelOffset: 63, step: 4 },
324
+ };
325
+ const cameras = { diagonal: [-34, 34], opposite: [29, 31], high: [-21, 59] };
326
+ const { error: errorBranch, details } = atlasCase;
327
+ const catalogue = new Map(Object.values(details).flat().map(entry => [entry.id, entry]));
328
+ let mode = 'learn';
329
+ let layout = graphProject ? 'steps' : 'iso';
330
+ let selected = graphProject ? 0 : 1;
331
+ let selectedDetail = null;
332
+ let detail = 'module';
333
+ let camera = 'diagonal';
334
+ let layers = { web: true, api: true, data: true, error: false };
335
+ let criterion = null;
336
+
337
+ function renderScene() {
338
+ const [yaw, tilt] = cameras[camera].map(angle => angle * Math.PI / 180);
339
+ const cosYaw = Math.cos(yaw);
340
+ const sinYaw = Math.sin(yaw);
341
+ const cosTilt = Math.cos(tilt);
342
+ const sinTilt = Math.sin(tilt);
343
+ const depth = (x, y) => x * sinYaw + y * cosYaw;
344
+ const project = ([x, y, z = 0]) => [210 + x * cosYaw - y * sinYaw, 139 + depth(x, y) * sinTilt - z * cosTilt];
345
+ const points = vertices => vertices.map(vertex => project(vertex).map(value => value.toFixed(1)).join(',')).join(' ');
346
+ const polygon = (type, vertices) => `<polygon class="${type}" points="${points(vertices)}"/>`;
347
+ const path = (type, vertices, arrow = false) => `<polyline class="${type}" points="${points(vertices)}" ${arrow ? 'marker-end="url(#atlas-world-arrow)"' : ''}/>`;
348
+
349
+ function box(x, y, z, width, length, height, palette) {
350
+ const left = x - width / 2;
351
+ const right = x + width / 2;
352
+ const front = y + length / 2;
353
+ const back = y - length / 2;
354
+ const nearX = sinYaw < 0 ? left : right;
355
+ const top = z + height;
356
+ return `<g class="ar-${palette}">
357
+ ${polygon('ar-form-side', [[nearX, back, z], [nearX, front, z], [nearX, front, top], [nearX, back, top]])}
358
+ ${polygon('ar-form-face', [[left, front, z], [right, front, z], [right, front, top], [left, front, top]])}
359
+ ${polygon('ar-form-top', [[left, back, top], [right, back, top], [right, front, top], [left, front, top]])}
360
+ </g>`;
361
+ }
362
+
363
+ function cylinder(x, y, radius, height) {
364
+ const nearAngle = Math.atan2(cosYaw, sinYaw) - Math.PI / 2;
365
+ const arc = (z, sweep) => Array.from({ length: 25 }, (_, i) => {
366
+ const rotation = nearAngle + i * sweep / 24;
367
+ return [x + radius * Math.cos(rotation), y + radius * Math.sin(rotation), z];
368
+ });
369
+ return `<g class="ar-data">
370
+ ${polygon('ar-form-face', [...arc(height, Math.PI), ...arc(6, Math.PI).reverse()])}
371
+ ${polygon('ar-form-top', arc(height, 2 * Math.PI))}
372
+ ${[height / 2 + 4, height * .75 + 2].map(z => path('ar-form-detail', arc(z, Math.PI))).join('')}
373
+ </g>`;
374
+ }
375
+
376
+ function object(layer, x, y) {
377
+ const compact = detail !== 'module';
378
+ const shadow = polygon('ar-form-shadow', [[x - 31,y - 19],[x + 46,y - 19],[x + 46,y + 29],[x - 31,y + 29]]);
379
+ const base = box(x, y, 0, layer === 'error' ? 37 : 68, layer === 'error' ? 32 : 52, 6, 'plinth');
380
+ if (layer === 'web') {
381
+ return shadow + base + box(x, y + 4, 6, 21, 23, 4, 'web') + box(x, y, 10, 6, 7, 12, 'web') + box(x, y - 3, 22, 46, 6, compact ? 22 : 30, 'web')
382
+ + path('ar-form-detail', [[x - 18,y + .6,compact ? 38 : 45],[x + 18,y + .6,compact ? 38 : 45]])
383
+ + path('ar-form-detail', [[x - 13,y + .6,29],[x - 13,y + .6,34],[x + 9,y + .6,34]]);
384
+ }
385
+ if (layer === 'api') {
386
+ return shadow + base + [6, 20, 34].slice(0, compact ? 2 : 3).map(z => box(x, y, z, 45, 35, 11, 'api')
387
+ + path('ar-form-detail', [[x - 14,y + 18,z + 5],[x + 7,y + 18,z + 5]])).join('');
388
+ }
389
+ if (layer === 'data') {
390
+ return shadow + base + (compact ? cylinder(x - 12, y + 4, 10, 32) + cylinder(x + 12, y - 5, 10, 42) : cylinder(x, y, 21, 49));
391
+ }
392
+ return base + box(x, y, 6, 24, 20, 19, 'error');
393
+ }
394
+
395
+ const edgeLabels = [];
396
+ function connection(a, b, vertices, label, textPoint, secondary = false) {
397
+ if (!layers[a] || !layers[b]) return '';
398
+ if (label) {
399
+ const [x, y] = project(textPoint);
400
+ edgeLabels.push(`<text class="ar-edge-label" x="${x}" y="${y - 10}" text-anchor="middle">${escapeMarkup(label)}</text>`);
401
+ }
402
+ return path(`ar-connection${secondary ? ' ar-secondary' : ''}`, vertices, true);
403
+ }
404
+
405
+ const visible = Object.entries(places).filter(([layer]) => layers[layer]);
406
+ const position = (x, y) => `left:${x / 4.2}%; top:${y / 2.92}%`;
407
+ const ground = polygon('ar-floor', [[-176,-67],[176,-67],[176,104],[-176,104]]);
408
+ let grid = '';
409
+ for (let x = -160; x <= 160; x += 32) grid += path('ar-gridline', [[x,-67],[x,104]]);
410
+ for (let y = -64; y <= 96; y += 32) grid += path('ar-gridline', [[-176,y],[176,y]]);
411
+ const connections = connection('web', 'api', [[-79,4],[-54,4],[-54,-24],[-35,-24]], atlasCase?.labels.request ?? 'GET', [-54,-10,6])
412
+ + connection('api', 'data', [[36,-24],[57,-24],[57,8],[79,8]], atlasCase?.labels.database ?? 'Lee', [58,-13,6])
413
+ + connection('api', 'web', [[0,4],[0,64],[-115,64],[-115,35]], '', [0,0], true)
414
+ + connection('api', 'error', [[21,4],[40,4],[40,75],[41,75]], '', [0,0], true);
415
+ const solids = [...visible].sort(([, a], [, b]) => depth(a.x, a.y) - depth(b.x, b.y))
416
+ .map(([layer, item]) => object(layer, item.x, item.y)).join('');
417
+ const leaders = visible.map(([, item]) => path('ar-dropline', [[item.x,item.y + 25],[item.x,item.y + item.labelOffset]])).join('');
418
+ world.innerHTML = `<defs><marker id="atlas-world-arrow" markerWidth="5" markerHeight="5" refX="4" refY="2.5" orient="auto"><path class="ar-arrowhead" d="M0 0l5 2.5L0 5Z"/></marker></defs>${ground}${grid}${connections}${solids}${leaders}<g class="ar-edge-labels">${edgeLabels.join('')}</g>`;
419
+ pins.innerHTML = visible.map(([, item]) => {
420
+ const [x, y] = project([item.x,item.y + item.labelOffset]);
421
+ const role = mode === 'learn' ? item.role : item.change;
422
+ const horizontalOffset = camera === 'opposite' && item === places.data ? 22 : 0;
423
+ return `<button type="button" class="ar-pin" data-step="${item.step}" style="${position(x + horizontalOffset, y + 14)}"><strong>${escapeMarkup(item.title)}</strong><span>${escapeMarkup(role)}</span></button>`;
424
+ }).join('');
425
+ const hidden = ['web', 'api', 'data'].filter(layer => !layers[layer]).length;
426
+ filterStatus.textContent = hidden ? `${hidden} ${hidden === 1 ? 'grupo oculto' : 'grupos ocultos'}` : '';
427
+ map.querySelector('.ar-map-return').hidden = !layers.api || !layers.web;
428
+ detailList.hidden = detail === 'module';
429
+ detailList.innerHTML = ['web', 'api', 'data'].filter(layer => layers[layer] && detail !== 'module').map(layer => {
430
+ const entries = details[detail].filter(entry => entry.layer === layer);
431
+ return `<section class="ar-detail-group"><h4>${escapeMarkup(places[layer].title)}</h4>${entries.map(entry => `<button type="button" data-entry="${escapeMarkup(entry.id)}"><code>${escapeMarkup(entry.label)}</code><small>${escapeMarkup(entry.kind)}</small></button>`).join('')}</section>`;
432
+ }).join('');
433
+ }
434
+
435
+ const languagesByExtension = {
436
+ ts: 'typescript', tsx: 'typescript', mts: 'typescript', cts: 'typescript',
437
+ js: 'javascript', jsx: 'javascript', mjs: 'javascript', cjs: 'javascript',
438
+ py: 'python', rb: 'ruby', go: 'go', rs: 'rust', java: 'java', kt: 'kotlin', cs: 'csharp',
439
+ c: 'c', h: 'c', cpp: 'cpp', hpp: 'cpp', php: 'php', sh: 'bash', bash: 'bash',
440
+ json: 'json', yaml: 'yaml', yml: 'yaml', sql: 'sql', css: 'css', html: 'xml', xml: 'xml',
441
+ };
442
+
443
+ function highlightedLines(lines, file) {
444
+ const extension = file.split('.').at(-1)?.toLowerCase();
445
+ const language = languagesByExtension[extension];
446
+ const highlighter = globalThis.hljs;
447
+ if (!language || !highlighter?.getLanguage(language)) return lines.map(line => document.createTextNode(line));
448
+
449
+ const formatted = document.createElement('template');
450
+ formatted.innerHTML = highlighter.highlight(lines.join('\n'), { language, ignoreIllegals: true }).value;
451
+ const pieces = lines.map(() => document.createDocumentFragment());
452
+ let row = 0;
453
+ function distribute(node, classes = '') {
454
+ if (node.nodeType === Node.TEXT_NODE) {
455
+ for (const [offset, text] of node.textContent.split('\n').entries()) {
456
+ if (offset) row++;
457
+ if (!text || !pieces[row]) continue;
458
+ if (classes) {
459
+ const token = document.createElement('span');
460
+ token.className = classes;
461
+ token.textContent = text;
462
+ pieces[row].append(token);
463
+ } else pieces[row].append(text);
464
+ }
465
+ } else {
466
+ const tokenClass = node.nodeName === 'SPAN' ? node.className : '';
467
+ const inherited = [classes, tokenClass].filter(Boolean).join(' ');
468
+ for (const child of node.childNodes) distribute(child, inherited);
469
+ }
470
+ }
471
+ distribute(formatted.content);
472
+ return pieces;
473
+ }
474
+
475
+ function addCode(label, source, commit) {
476
+ const block = document.createElement('section');
477
+ block.className = 'ar-code';
478
+ const heading = document.createElement('div');
479
+ heading.className = 'ar-code-head';
480
+ const title = document.createElement('strong');
481
+ title.textContent = label;
482
+ const reference = document.createElement('code');
483
+ reference.textContent = `${source.file}:${source.focus} · ${commit}`;
484
+ heading.append(title, reference);
485
+ block.append(heading);
486
+ for (const [offset, text] of highlightedLines(source.lines, source.file).entries()) {
487
+ const number = source.start + offset;
488
+ const line = document.createElement('div');
489
+ line.className = 'ar-code-line';
490
+ line.toggleAttribute('data-hit', source.focus === number);
491
+ const gutter = document.createElement('span');
492
+ gutter.textContent = number;
493
+ const code = document.createElement('code');
494
+ code.append(text);
495
+ line.append(gutter, code);
496
+ block.append(line);
497
+ }
498
+ evidence.append(block);
499
+ }
500
+
501
+ function renderEvidence() {
502
+ const item = catalogue.get(selectedDetail)?.item ?? (!graphProject && selected === 4 ? errorBranch : flow[selected]);
503
+ if (!item) {
504
+ evidence.textContent = 'Graphify no encontró llamadas salientes indexadas en este proyecto. El diff de Git sigue disponible.';
505
+ return;
506
+ }
507
+ const pending = mode === 'review' ? review.criteria.find(entry => entry.id === criterion)?.pending : undefined;
508
+ const badge = document.createElement('span');
509
+ badge.className = pending ? 'ar-status ar-pending' : 'ar-status';
510
+ badge.textContent = pending ? 'Prueba pendiente' : ({ extracted: 'Extraído por Graphify', inferred: 'Inferido por Graphify', unknown: 'Relación sin clasificar' }[item.provenance] ?? 'Confirmado en el código');
511
+ const heading = document.createElement('h4');
512
+ heading.textContent = pending?.title ?? item.title;
513
+ const description = document.createElement('p');
514
+ description.textContent = pending?.explanation ?? (mode === 'learn' ? item.explanation : item.effect);
515
+ evidence.replaceChildren(badge, heading, description);
516
+ const sharedDefinition = mode !== 'learn' && item.before && item.after && item.before.file === item.after.file && item.before.start === item.after.start && item.before.lines.join('\n') === item.after.lines.join('\n');
517
+ if (mode !== 'learn' && !pending && item.before && !sharedDefinition) addCode('Antes', item.before, baseRevision);
518
+ const label = sharedDefinition ? 'Definición en ambas versiones' : mode === 'learn' || pending ? 'Código' : 'Después';
519
+ if (item.after) addCode(label, item.after, sharedDefinition ? `${baseRevision} · ${headRevision}` : headRevision);
520
+ else {
521
+ const missing = document.createElement('p');
522
+ missing.textContent = 'Ubicación de código no disponible para esta llamada.';
523
+ evidence.append(missing);
524
+ }
525
+ if (mode !== 'learn' && atlasCase?.hasPatches && item.after && atlasDiff.files.includes(item.after.file)) {
526
+ const jump = document.createElement('button');
527
+ jump.className = 'ar-patch-jump';
528
+ jump.type = 'button';
529
+ jump.dataset.openPatch = item.after.file;
530
+ jump.textContent = 'Abrir diff del archivo';
531
+ evidence.append(jump);
532
+ }
533
+ for (const button of root.querySelectorAll('[data-step]')) button.setAttribute('aria-pressed', Number(button.dataset.step) === selected);
534
+ for (const button of detailList.querySelectorAll('[data-entry]')) button.setAttribute('aria-pressed', button.dataset.entry === selectedDetail);
535
+ for (const button of context.querySelectorAll('[data-criterion]')) button.setAttribute('aria-pressed', button.dataset.criterion === criterion);
536
+ }
537
+
538
+ function renderLayout() {
539
+ map.hidden = layout !== 'iso';
540
+ steps.hidden = layout !== 'steps';
541
+ for (const button of root.querySelectorAll('[data-layout]')) button.setAttribute('aria-pressed', button.dataset.layout === layout);
542
+ if (layout === 'iso') renderScene();
543
+ renderEvidence();
544
+ }
545
+
546
+ function renderMode() {
547
+ const comparing = mode !== 'learn';
548
+ revision.textContent = comparing ? `${baseRevision} → ${headRevision}` : headRevision;
549
+ context.hidden = !comparing;
550
+ const fileList = atlasCase?.hasPatches
551
+ ? `<label>Archivo modificado<select data-patch-menu><option value="">Elige un archivo</option>${atlasDiff.files.map(file => `<option>${escapeMarkup(file)}</option>`).join('')}</select></label><div class="ar-patch" aria-live="polite"></div>`
552
+ : `<ul>${atlasDiff.files.map(file => `<li><code>${escapeMarkup(file)}</code></li>`).join('')}</ul>`;
553
+ const changes = atlasDiff.files.length
554
+ ? `<details class="ar-changed-files"><summary>${atlasDiff.files.length === 1 ? '1 archivo cambiado' : `${atlasDiff.files.length} archivos cambiados`}</summary>${fileList}</details>`
555
+ : atlasCase?.hasPatches ? '<p>No hay archivos cambiados en esta comparación.</p>' : '';
556
+ context.innerHTML = mode === 'diff'
557
+ ? `<strong>${escapeMarkup(atlasDiff.title)}</strong><p>${escapeMarkup(atlasDiff.explanation)}</p>${changes}`
558
+ : mode === 'review' ? `<strong>${escapeMarkup(review.title)}</strong><p>${escapeMarkup(review.description)}</p>
559
+ <ul class="ar-review-options">${review.criteria.map(entry => `<li><button type="button" data-criterion="${escapeMarkup(entry.id)}" aria-pressed="false">${escapeMarkup(entry.label)}${entry.pending ? ' <small>· Prueba pendiente</small>' : ''}</button></li>`).join('')}</ul>${changes}` : '';
560
+ steps.innerHTML = flow.map((item, index) => `<li><button class="ar-step" type="button" data-step="${index}">
561
+ <span class="ar-icon"><i data-lucide="${escapeMarkup(item.icon)}" aria-hidden="true"></i></span>
562
+ <span><strong>${escapeMarkup(item.title)}</strong><code>${escapeMarkup(item.symbol)}</code></span>
563
+ ${comparing ? `<span class="ar-change">${escapeMarkup(item.change)}</span>` : '<i data-lucide="chevron-right" aria-hidden="true"></i>'}
564
+ </button></li>`).join('') || '<li>Sin llamadas en el grafo.</li>';
565
+ for (const button of root.querySelectorAll('[data-mode]')) button.setAttribute('aria-pressed', button.dataset.mode === mode);
566
+ renderLayout();
567
+ globalThis.lucide?.createIcons({ attrs: { width: 16, height: 16 } });
568
+ }
569
+
570
+ async function showPatch(file) {
571
+ const panel = context.querySelector('.ar-patch');
572
+ if (!panel) return;
573
+ panel.dataset.file = file;
574
+ panel.textContent = file ? 'Leyendo diff…' : '';
575
+ if (!file) return;
576
+ try {
577
+ const response = await fetch(`/api/patch?${new URLSearchParams({ file })}`);
578
+ const patch = await response.json();
579
+ if (!response.ok) throw Error(patch.error);
580
+ if (!panel.isConnected || panel.dataset.file !== file) return;
581
+ panel.replaceChildren();
582
+ const metadata = document.createElement('p');
583
+ metadata.textContent = patch.file.previous ? `${patch.file.previous} → ${patch.file.path}` : patch.file.path;
584
+ panel.append(metadata);
585
+ for (const text of patch.summary) {
586
+ const note = document.createElement('p');
587
+ note.textContent = text;
588
+ panel.append(note);
589
+ }
590
+ if (patch.hunks.length === 0 && patch.summary.length === 0) panel.append('Git no devolvió bloques de texto para este archivo.');
591
+ let remaining = 400;
592
+ for (const hunk of patch.hunks) {
593
+ if (remaining === 0) break;
594
+ const heading = document.createElement('div');
595
+ heading.className = 'ar-patch-header';
596
+ heading.textContent = hunk.header;
597
+ const code = document.createElement('pre');
598
+ code.setAttribute('aria-label', 'Línea anterior, línea actual y texto del diff');
599
+ const visible = hunk.lines.slice(0, remaining);
600
+ const before = highlightedLines(visible.filter(line => line.before !== undefined).map(line => line.text), patch.file.previous ?? patch.file.path);
601
+ const after = highlightedLines(visible.filter(line => line.after !== undefined).map(line => line.text), patch.file.path);
602
+ let previousLine = 0;
603
+ let currentLine = 0;
604
+ for (const line of visible) {
605
+ const row = document.createElement('span');
606
+ row.className = 'ar-patch-line';
607
+ row.dataset.kind = line.kind;
608
+ for (const number of [line.before, line.after]) {
609
+ const gutter = document.createElement('span');
610
+ gutter.className = 'ar-patch-gutter';
611
+ gutter.textContent = number ?? '';
612
+ row.append(gutter);
613
+ }
614
+ const marker = document.createElement('span');
615
+ marker.textContent = line.kind === 'add' ? '+' : line.kind === 'remove' ? '−' : '';
616
+ const text = document.createElement('span');
617
+ const oldCode = line.before === undefined ? null : before[previousLine++];
618
+ const newCode = line.after === undefined ? null : after[currentLine++];
619
+ text.append(newCode ?? oldCode ?? line.text);
620
+ row.append(marker, text);
621
+ code.append(row);
622
+ }
623
+ remaining -= visible.length;
624
+ panel.append(heading, code);
625
+ }
626
+ if (patch.hunks.reduce((sum, hunk) => sum + hunk.lines.length, 0) > 400) panel.append('Vista limitada a las primeras 400 líneas del diff.');
627
+ } catch (error) {
628
+ if (panel.dataset.file === file) panel.textContent = error.message;
629
+ }
630
+ }
631
+
632
+ function restore(saved) {
633
+ if (!saved || !['learn', 'diff', 'review'].includes(saved.mode)) return;
634
+ mode = saved.mode;
635
+ if (!graphProject && ['iso', 'steps'].includes(saved.layout)) layout = saved.layout;
636
+ if (Object.hasOwn(cameras, saved.camera ?? '')) camera = saved.camera;
637
+ if (saved.detail === 'module' || Object.hasOwn(details, saved.detail ?? '')) detail = saved.detail;
638
+ for (const layer of Object.keys(layers)) if (typeof saved.layers?.[layer] === 'boolean') layers[layer] = saved.layers[layer];
639
+ if (Number.isInteger(saved.selected) && saved.selected >= 0 && saved.selected <= flow.length) selected = saved.selected;
640
+ selectedDetail = catalogue.has(saved.selectedDetail) ? saved.selectedDetail : null;
641
+ if (mode === 'review' && review.criteria.some(entry => entry.id === saved.criterion)) criterion = saved.criterion;
642
+ map.querySelector('[data-camera]').value = camera;
643
+ map.querySelector('[data-detail]').value = detail;
644
+ for (const input of map.querySelectorAll('[data-layer]')) input.checked = layers[input.dataset.layer];
645
+ }
646
+
647
+ function save() {
648
+ window.openai?.setWidgetState?.({ privateContent: { mode, layout, detail, camera, layers, selected, selectedDetail, criterion } })?.catch(() => {});
649
+ }
650
+
651
+ root.addEventListener('click', (event) => {
652
+ const button = event.target.closest('button');
653
+ if (!button) return;
654
+ if (button.dataset.openPatch) {
655
+ const menu = context.querySelector('[data-patch-menu]');
656
+ menu.closest('details').open = true;
657
+ menu.value = button.dataset.openPatch;
658
+ menu.focus();
659
+ showPatch(menu.value);
660
+ } else if (button.dataset.mode) {
661
+ mode = button.dataset.mode;
662
+ criterion = null;
663
+ renderMode();
664
+ } else if (button.dataset.layout) {
665
+ layout = button.dataset.layout;
666
+ renderLayout();
667
+ } else if (button.dataset.criterion) {
668
+ selected = review.criteria.find(entry => entry.id === button.dataset.criterion).step;
669
+ selectedDetail = null;
670
+ criterion = button.dataset.criterion;
671
+ renderEvidence();
672
+ } else if (button.dataset.entry) {
673
+ selectedDetail = button.dataset.entry;
674
+ selected = catalogue.get(selectedDetail).step;
675
+ criterion = null;
676
+ renderEvidence();
677
+ } else if (button.dataset.step !== undefined) {
678
+ selected = Number(button.dataset.step);
679
+ selectedDetail = null;
680
+ criterion = null;
681
+ renderEvidence();
682
+ }
683
+ save();
684
+ });
685
+ map.addEventListener('change', (event) => {
686
+ const control = event.target;
687
+ if (control.matches('[data-camera]')) camera = control.value;
688
+ else if (control.matches('[data-detail]')) detail = control.value;
689
+ else if (control.matches('[data-layer]')) layers[control.dataset.layer] = control.checked;
690
+ else return;
691
+ renderScene();
692
+ renderEvidence();
693
+ save();
694
+ });
695
+ context.addEventListener('change', event => {
696
+ if (event.target.matches('[data-patch-menu]')) showPatch(event.target.value);
697
+ });
698
+ entrySelect.addEventListener('change', async () => {
699
+ const oldValue = graphProject.selected;
700
+ entryStatus.textContent = 'Cargando llamadas…';
701
+ entrySelect.disabled = true;
702
+ try {
703
+ const response = await fetch(`/api/flow?${new URLSearchParams({ entry: entrySelect.value })}`);
704
+ const result = await response.json();
705
+ if (!response.ok) throw Error(result.error);
706
+ flow = result;
707
+ graphProject.selected = entrySelect.value;
708
+ selected = 0;
709
+ selectedDetail = null;
710
+ criterion = null;
711
+ renderMode();
712
+ entryStatus.textContent = `${flow.length} llamadas visibles`;
713
+ } catch (error) {
714
+ entrySelect.value = oldValue;
715
+ entryStatus.textContent = error.message;
716
+ } finally {
717
+ entrySelect.disabled = false;
718
+ }
719
+ });
720
+ window.addEventListener('openai:set_globals', (event) => {
721
+ const saved = event.detail?.globals?.widgetState?.privateContent;
722
+ if (saved) {
723
+ restore(saved);
724
+ renderMode();
725
+ }
726
+ });
727
+
728
+ restore(window.openai?.widgetState?.privateContent);
729
+ renderMode();
730
+ })();
731
+ </script>