@t0.labs/daxta 0.4.23 → 0.5.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,3699 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>DAxTA</title>
7
+ <link rel="icon" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+CiAgPHN0eWxlPgogICAgLmJnIHsgZmlsbDogI2ZmZmZmZjsgfQogICAgLmZnIHsgZmlsbDogIzExMTExMTsgfQogICAgLnJpbmcgeyBmaWxsOiBub25lOyBzdHJva2U6ICMxMTExMTE7IHN0cm9rZS13aWR0aDogMS4yNTsgfQogICAgQG1lZGlhIChwcmVmZXJzLWNvbG9yLXNjaGVtZTogZGFyaykgewogICAgICAuYmcgeyBmaWxsOiAjMTExMTExOyB9CiAgICAgIC5mZyB7IGZpbGw6ICNmZmZmZmY7IH0KICAgICAgLnJpbmcgeyBzdHJva2U6ICNmZmZmZmY7IH0KICAgIH0KICA8L3N0eWxlPgogIDxyZWN0IGNsYXNzPSJiZyIgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNyIvPgogIDxyZWN0IGNsYXNzPSJyaW5nIiB4PSIwLjYiIHk9IjAuNiIgd2lkdGg9IjMwLjgiIGhlaWdodD0iMzAuOCIgcng9IjYuNCIvPgogIDxwYXRoIGNsYXNzPSJmZyIgZD0iTTQuMiA1LjIgMTQuMiA4Ljh2NC4yQTQuMiA0LjIgMCAwIDEgMTQuMiAyMS40djRMNC4yIDI2LjhaIi8+CiAgPHBhdGggY2xhc3M9ImZnIiBkPSJNMjcuOCA1LjIgMTcuOCA4Ljh2NC4yQTQuMiA0LjIgMCAwIDAgMTcuOCAyMS40djRMMjcuOCAyNi44WiIvPgo8L3N2Zz4K" />
8
+ <link rel="apple-touch-icon" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+CiAgPHN0eWxlPgogICAgLmJnIHsgZmlsbDogI2ZmZmZmZjsgfQogICAgLmZnIHsgZmlsbDogIzExMTExMTsgfQogICAgLnJpbmcgeyBmaWxsOiBub25lOyBzdHJva2U6ICMxMTExMTE7IHN0cm9rZS13aWR0aDogMS4yNTsgfQogICAgQG1lZGlhIChwcmVmZXJzLWNvbG9yLXNjaGVtZTogZGFyaykgewogICAgICAuYmcgeyBmaWxsOiAjMTExMTExOyB9CiAgICAgIC5mZyB7IGZpbGw6ICNmZmZmZmY7IH0KICAgICAgLnJpbmcgeyBzdHJva2U6ICNmZmZmZmY7IH0KICAgIH0KICA8L3N0eWxlPgogIDxyZWN0IGNsYXNzPSJiZyIgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNyIvPgogIDxyZWN0IGNsYXNzPSJyaW5nIiB4PSIwLjYiIHk9IjAuNiIgd2lkdGg9IjMwLjgiIGhlaWdodD0iMzAuOCIgcng9IjYuNCIvPgogIDxwYXRoIGNsYXNzPSJmZyIgZD0iTTQuMiA1LjIgMTQuMiA4Ljh2NC4yQTQuMiA0LjIgMCAwIDEgMTQuMiAyMS40djRMNC4yIDI2LjhaIi8+CiAgPHBhdGggY2xhc3M9ImZnIiBkPSJNMjcuOCA1LjIgMTcuOCA4Ljh2NC4yQTQuMiA0LjIgMCAwIDAgMTcuOCAyMS40djRMMjcuOCAyNi44WiIvPgo8L3N2Zz4K" />
9
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
10
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
11
+ <link href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&family=Geist:wght@400;500;600&display=swap" rel="stylesheet" />
12
+ <style>
13
+ :root {
14
+ --canvas: #fafafa;
15
+ --sidebar: #fafafa;
16
+ --nav: #ffffff;
17
+ --paper: #fafafa;
18
+ --white: #ffffff;
19
+ --inset: #f5f5f5;
20
+ --hairline: #e6e6e6;
21
+ --line: #e6e6e6;
22
+ --smoke: #888888;
23
+ --stone: #666666;
24
+ --charcoal: #333333;
25
+ --obsidian: #111111;
26
+ --accent: #6f7d3c;
27
+ --ok: #15803d;
28
+ --ok-bg: #e8f8ee;
29
+ --get: #16a34a;
30
+ --err: #b42318;
31
+ --err-bg: #fbeaea;
32
+ --sans: Geist, Inter, ui-sans-serif, system-ui, sans-serif;
33
+ --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
34
+ --radius: 5px;
35
+ --ring: 0 0 0 1px #e6e6e6;
36
+ --ghost: 0 0 0 1px #e6e6e6;
37
+ }
38
+ * { box-sizing: border-box; }
39
+ html, body { height: 100%; }
40
+ body {
41
+ margin: 0;
42
+ background: var(--canvas);
43
+ color: var(--obsidian);
44
+ font: 13px/1.45 var(--sans);
45
+ }
46
+ button, input { font: inherit; color: inherit; }
47
+
48
+ .topnav {
49
+ height: 44px;
50
+ display: grid;
51
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
52
+ align-items: center;
53
+ gap: 12px;
54
+ padding: 0 14px;
55
+ background: var(--nav);
56
+ border-bottom: 1px solid var(--hairline);
57
+ position: sticky;
58
+ top: 0;
59
+ z-index: 20;
60
+ }
61
+ body.searching .topnav { z-index: 30; }
62
+ .brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; }
63
+ .workspace { display: none; }
64
+ .brand { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--charcoal); }
65
+ .ep-nav {
66
+ justify-self: center;
67
+ display: flex;
68
+ align-items: center;
69
+ gap: 8px;
70
+ min-width: 0;
71
+ max-width: 100%;
72
+ }
73
+ .ep-name {
74
+ font-size: 14px;
75
+ font-weight: 600;
76
+ letter-spacing: -0.02em;
77
+ white-space: nowrap;
78
+ overflow: hidden;
79
+ text-overflow: ellipsis;
80
+ color: var(--obsidian);
81
+ }
82
+ .ver-select {
83
+ height: 24px;
84
+ border: 1px solid var(--hairline);
85
+ border-radius: 4px;
86
+ background: var(--white);
87
+ font: 500 11px/1 var(--mono);
88
+ color: var(--obsidian);
89
+ padding: 0 6px;
90
+ cursor: pointer;
91
+ }
92
+ .nav-tools { display: flex; align-items: center; gap: 8px; justify-self: end; }
93
+ .nav-tools .btn {
94
+ height: 28px;
95
+ padding: 0 10px;
96
+ font-size: 12px;
97
+ }
98
+ .nav-tools .btn.icon {
99
+ width: 28px;
100
+ height: 28px;
101
+ padding: 0;
102
+ }
103
+ .nav-tools .btn.icon svg { width: 16px; height: 16px; }
104
+ .btn[data-tip] { position: relative; }
105
+ .btn[data-tip]::after {
106
+ content: attr(data-tip);
107
+ position: absolute;
108
+ top: calc(100% + 8px);
109
+ left: 50%;
110
+ transform: translateX(-50%) translateY(4px);
111
+ background: var(--obsidian);
112
+ color: var(--white);
113
+ font-size: 11px;
114
+ font-weight: 500;
115
+ padding: 6px 8px;
116
+ border-radius: var(--radius);
117
+ white-space: nowrap;
118
+ opacity: 0;
119
+ pointer-events: none;
120
+ transition: opacity 0.12s ease, transform 0.12s ease;
121
+ z-index: 50;
122
+ }
123
+ .btn[data-tip]:hover::after {
124
+ opacity: 1;
125
+ transform: translateX(-50%) translateY(0);
126
+ }
127
+ .search-wrap {
128
+ position: relative;
129
+ width: 100%;
130
+ flex: none;
131
+ z-index: 30;
132
+ margin-bottom: 8px;
133
+ }
134
+ .search {
135
+ width: 100%;
136
+ height: 30px;
137
+ border: 1px solid var(--hairline);
138
+ border-radius: var(--radius);
139
+ box-shadow: none;
140
+ background: var(--white);
141
+ padding: 0 28px 0 10px;
142
+ font-size: 12px;
143
+ }
144
+ .search-kbd {
145
+ position: absolute;
146
+ right: 8px;
147
+ top: 50%;
148
+ transform: translateY(-50%);
149
+ font: 500 10px/1 var(--mono);
150
+ color: var(--smoke);
151
+ border: 1px solid var(--hairline);
152
+ border-radius: 4px;
153
+ padding: 3px 5px;
154
+ pointer-events: none;
155
+ background: var(--inset);
156
+ }
157
+ .search::placeholder { color: var(--smoke); }
158
+ .search-wrap.open .search {
159
+ border-color: var(--obsidian);
160
+ border-radius: var(--radius) var(--radius) 0 0;
161
+ }
162
+ .search-wrap.open .search-kbd { display: none; }
163
+ .search-backdrop {
164
+ display: none;
165
+ position: fixed;
166
+ inset: 0;
167
+ background: rgba(232, 232, 232, 0.72);
168
+ backdrop-filter: blur(2px);
169
+ z-index: 25;
170
+ }
171
+ body.searching .search-backdrop { display: block; }
172
+ .search-panel {
173
+ display: none;
174
+ position: absolute;
175
+ top: 100%;
176
+ left: 0;
177
+ right: 0;
178
+ max-height: min(420px, calc(100vh - 90px));
179
+ overflow: auto;
180
+ background: var(--white);
181
+ border-radius: 0 0 var(--radius) var(--radius);
182
+ box-shadow: none;
183
+ border: 1px solid var(--hairline);
184
+ border-top: 0;
185
+ z-index: 31;
186
+ padding: 6px;
187
+ }
188
+ .search-wrap.open .search-panel { display: block; }
189
+ .search-hit {
190
+ display: flex;
191
+ align-items: center;
192
+ gap: 10px;
193
+ width: 100%;
194
+ border: 0;
195
+ background: transparent;
196
+ text-align: left;
197
+ padding: 10px 10px;
198
+ border-radius: var(--radius);
199
+ cursor: pointer;
200
+ color: var(--charcoal);
201
+ }
202
+ .search-hit:hover,
203
+ .search-hit.active { background: var(--inset); }
204
+ .search-hit-path {
205
+ min-width: 0;
206
+ font: 12px/1.35 var(--mono);
207
+ color: var(--obsidian);
208
+ overflow: hidden;
209
+ text-overflow: ellipsis;
210
+ white-space: nowrap;
211
+ }
212
+ .search-hit mark {
213
+ background: transparent;
214
+ color: var(--obsidian);
215
+ font-weight: 600;
216
+ text-decoration: underline;
217
+ text-decoration-thickness: 1px;
218
+ text-underline-offset: 2px;
219
+ }
220
+ .search-empty {
221
+ padding: 18px 12px;
222
+ color: var(--stone);
223
+ font-size: 13px;
224
+ text-align: center;
225
+ }
226
+ .env-wrap { position: relative; flex: none; }
227
+ .env-wrap.open .env-pop { display: block; }
228
+ .env-trigger {
229
+ flex: none;
230
+ width: 180px;
231
+ height: 28px;
232
+ border: 0;
233
+ border-radius: var(--radius);
234
+ box-shadow: var(--ghost);
235
+ background: var(--white);
236
+ padding: 0 32px 0 12px;
237
+ font: 500 12px/1 var(--mono);
238
+ color: var(--obsidian);
239
+ cursor: pointer;
240
+ position: relative;
241
+ white-space: nowrap;
242
+ text-align: left;
243
+ overflow: hidden;
244
+ text-overflow: ellipsis;
245
+ }
246
+ .env-trigger::after {
247
+ content: "";
248
+ position: absolute;
249
+ right: 12px;
250
+ top: 50%;
251
+ width: 6px;
252
+ height: 6px;
253
+ border-right: 1px solid var(--obsidian);
254
+ border-bottom: 1px solid var(--obsidian);
255
+ transform: translateY(-70%) rotate(45deg);
256
+ }
257
+ .env-wrap.open .env-trigger::after { transform: translateY(-20%) rotate(225deg); }
258
+ .env-pop {
259
+ display: none;
260
+ position: absolute;
261
+ top: calc(100% + 6px);
262
+ right: 0;
263
+ width: min(420px, calc(100vw - 48px));
264
+ max-height: min(520px, calc(100vh - 120px));
265
+ overflow: auto;
266
+ background: var(--white);
267
+ border-radius: var(--radius);
268
+ box-shadow: none;
269
+ border: 1px solid var(--hairline);
270
+ padding: 16px;
271
+ z-index: 40;
272
+ }
273
+ .env-block { margin-bottom: 20px; }
274
+ .env-block:last-child { margin-bottom: 0; }
275
+ .env-label {
276
+ font-family: var(--mono);
277
+ font-size: 11px;
278
+ letter-spacing: 0.08em;
279
+ text-transform: uppercase;
280
+ color: var(--stone);
281
+ margin-bottom: 8px;
282
+ }
283
+ .env-cell {
284
+ width: 100%;
285
+ min-width: 0;
286
+ height: 32px;
287
+ border: 0;
288
+ border-radius: var(--radius);
289
+ background: var(--inset);
290
+ padding: 0 10px;
291
+ font: 12px/1 var(--mono);
292
+ color: var(--obsidian);
293
+ }
294
+ .env-kv {
295
+ display: grid;
296
+ grid-template-columns: 1fr 1fr 28px;
297
+ gap: 6px;
298
+ margin-bottom: 6px;
299
+ }
300
+ .ghost-btn {
301
+ border: 0;
302
+ background: transparent;
303
+ color: var(--stone);
304
+ cursor: pointer;
305
+ width: 32px;
306
+ height: 32px;
307
+ padding: 0;
308
+ display: inline-flex;
309
+ align-items: center;
310
+ justify-content: center;
311
+ font-size: 16px;
312
+ line-height: 1;
313
+ }
314
+ .ghost-btn:hover { color: var(--obsidian); }
315
+ .ghost-btn:disabled { opacity: 0.35; cursor: default; }
316
+ .ghost-btn:disabled:hover { color: var(--stone); }
317
+ .chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: center; }
318
+ .chip-btn {
319
+ border: 0;
320
+ background: var(--inset);
321
+ box-shadow: var(--ghost);
322
+ border-radius: 9999px;
323
+ padding: 5px 10px;
324
+ cursor: pointer;
325
+ font-size: 12px;
326
+ color: var(--charcoal);
327
+ }
328
+ .chip-btn.on {
329
+ background: var(--obsidian);
330
+ color: var(--white);
331
+ box-shadow: none;
332
+ }
333
+ .env-base-line {
334
+ margin-top: 8px;
335
+ padding: 8px 10px;
336
+ border-radius: 8px;
337
+ background: var(--inset);
338
+ font: 11px/1.4 var(--mono);
339
+ color: var(--charcoal);
340
+ word-break: break-all;
341
+ }
342
+ .env-base-line span { color: var(--stone); }
343
+ .env-quick {
344
+ display: flex;
345
+ flex-wrap: wrap;
346
+ gap: 6px;
347
+ margin-top: 8px;
348
+ }
349
+ .env-kv.base-url .env-cell[data-field="key"] {
350
+ opacity: 0.7;
351
+ pointer-events: none;
352
+ }
353
+ .env-add {
354
+ height: 32px;
355
+ padding: 0 10px;
356
+ font-size: 12px;
357
+ margin-top: 4px;
358
+ }
359
+ .btn.primary {
360
+ background: var(--obsidian);
361
+ color: var(--white);
362
+ box-shadow: none;
363
+ }
364
+ .btn.primary:hover { opacity: 0.92; color: var(--white); }
365
+ .btn.primary:disabled { opacity: 0.45; cursor: default; }
366
+ .live-err {
367
+ color: #8a2e2e;
368
+ font-size: 13px;
369
+ line-height: 1.5;
370
+ padding: 14px 16px;
371
+ white-space: pre-wrap;
372
+ }
373
+
374
+ .app {
375
+ display: grid;
376
+ grid-template-columns: var(--sidebar-w, 320px) 6px minmax(0, 1fr);
377
+ grid-template-rows: minmax(0, 1fr) auto;
378
+ height: calc(100vh - 44px);
379
+ }
380
+ .app.sidebar-collapsed {
381
+ grid-template-columns: 0 28px minmax(0, 1fr);
382
+ }
383
+ .sidebar {
384
+ grid-row: 1 / -1;
385
+ }
386
+ .sidebar-resizer {
387
+ grid-row: 1 / -1;
388
+ }
389
+ .workbench {
390
+ grid-column: 3;
391
+ grid-row: 1;
392
+ min-height: 0;
393
+ overflow: auto;
394
+ padding: 14px 18px 16px;
395
+ background: var(--paper);
396
+ }
397
+ .sidebar {
398
+ position: relative;
399
+ min-width: 0;
400
+ overflow: hidden;
401
+ padding: 10px 10px 12px;
402
+ display: flex;
403
+ flex-direction: column;
404
+ background: var(--sidebar);
405
+ border-right: 0;
406
+ font-size: 13px;
407
+ }
408
+ .app.sidebar-collapsed .sidebar {
409
+ overflow: hidden;
410
+ padding: 0;
411
+ pointer-events: none;
412
+ opacity: 0;
413
+ }
414
+ .nav-filter {
415
+ width: 100%;
416
+ height: 28px;
417
+ border: 1px solid var(--hairline);
418
+ border-radius: var(--radius);
419
+ background: var(--white);
420
+ padding: 0 8px;
421
+ font-size: 12px;
422
+ margin-bottom: 8px;
423
+ flex: none;
424
+ }
425
+ .nav-filter::placeholder { color: var(--smoke); }
426
+ .tree-scroll { flex: 1; min-height: 0; overflow: auto; }
427
+ .nav-foot {
428
+ flex: none;
429
+ margin-top: 8px;
430
+ padding: 8px 2px 0;
431
+ display: flex;
432
+ justify-content: space-between;
433
+ gap: 8px;
434
+ font-size: 11px;
435
+ color: var(--smoke);
436
+ }
437
+ .sidebar-resizer {
438
+ position: relative;
439
+ z-index: 5;
440
+ width: 6px;
441
+ margin: 0;
442
+ padding: 0;
443
+ border: 0;
444
+ background: var(--hairline);
445
+ cursor: col-resize;
446
+ touch-action: none;
447
+ }
448
+ .sidebar-resizer::after {
449
+ content: "";
450
+ position: absolute;
451
+ inset: 0 -4px;
452
+ }
453
+ .sidebar-resizer:hover,
454
+ body.sidebar-resizing .sidebar-resizer {
455
+ background: var(--obsidian);
456
+ }
457
+ .app.sidebar-collapsed .sidebar-resizer {
458
+ width: 28px;
459
+ cursor: pointer;
460
+ background: var(--sidebar);
461
+ border-right: 1px solid var(--line);
462
+ }
463
+ .app.sidebar-collapsed .sidebar-resizer::before {
464
+ content: "";
465
+ position: absolute;
466
+ top: 50%;
467
+ left: 50%;
468
+ width: 6px;
469
+ height: 6px;
470
+ border-right: 1.5px solid var(--charcoal);
471
+ border-bottom: 1.5px solid var(--charcoal);
472
+ transform: translate(-70%, -50%) rotate(-45deg);
473
+ }
474
+ body.sidebar-resizing {
475
+ cursor: col-resize;
476
+ user-select: none;
477
+ }
478
+ body.sidebar-resizing * {
479
+ cursor: col-resize !important;
480
+ user-select: none !important;
481
+ }
482
+ .tree-root { display: flex; flex-direction: column; gap: 2px; }
483
+ .tree-folder { display: flex; flex-direction: column; gap: 2px; }
484
+ .tree-folder-toggle {
485
+ display: flex;
486
+ align-items: center;
487
+ gap: 6px;
488
+ width: 100%;
489
+ border: 0;
490
+ background: transparent;
491
+ text-align: left;
492
+ padding: 6px 8px;
493
+ border-radius: var(--radius);
494
+ cursor: pointer;
495
+ color: var(--charcoal);
496
+ font: 500 12px/1.4 var(--mono);
497
+ }
498
+ .tree-folder-toggle:hover { background: var(--white); color: var(--obsidian); }
499
+ .tree-folder-toggle .chev {
500
+ width: 10px;
501
+ height: 10px;
502
+ flex: none;
503
+ position: relative;
504
+ opacity: 0.55;
505
+ }
506
+ .tree-folder-toggle .chev::before {
507
+ content: "";
508
+ position: absolute;
509
+ left: 2px;
510
+ top: 1px;
511
+ width: 5px;
512
+ height: 5px;
513
+ border-right: 1.5px solid currentColor;
514
+ border-bottom: 1.5px solid currentColor;
515
+ transform: rotate(-45deg);
516
+ transition: transform 0.15s ease;
517
+ }
518
+ .tree-folder.open > .tree-folder-toggle .chev::before { transform: rotate(45deg); top: 0; }
519
+ .tree-folder-name {
520
+ min-width: 0;
521
+ overflow: hidden;
522
+ text-overflow: ellipsis;
523
+ white-space: nowrap;
524
+ }
525
+ .tree-children {
526
+ display: none;
527
+ margin-left: 14px;
528
+ padding-left: 8px;
529
+ border-left: 1px solid var(--hairline);
530
+ }
531
+ .tree-folder.open > .tree-children { display: flex; flex-direction: column; gap: 2px; }
532
+ .tree-empty {
533
+ padding: 24px 12px;
534
+ color: var(--stone);
535
+ font-size: 13px;
536
+ text-align: center;
537
+ }
538
+ .nav-item {
539
+ display: flex;
540
+ align-items: center;
541
+ gap: 8px;
542
+ flex: 1;
543
+ min-width: 0;
544
+ border: 0;
545
+ background: transparent;
546
+ text-align: left;
547
+ padding: 5px 8px;
548
+ border-radius: var(--radius);
549
+ cursor: pointer;
550
+ }
551
+ .nav-item:hover { background: transparent; }
552
+ .nav-op {
553
+ display: flex;
554
+ flex-direction: column;
555
+ gap: 0;
556
+ border-radius: var(--radius);
557
+ }
558
+ .nav-op:hover { background: var(--white); }
559
+ .nav-op.active { background: var(--white); box-shadow: 0 0 0 1px var(--hairline); }
560
+ .nav-op-row {
561
+ display: flex;
562
+ align-items: center;
563
+ gap: 2px;
564
+ min-width: 0;
565
+ }
566
+ .nav-expand {
567
+ flex: none;
568
+ width: 24px;
569
+ height: 24px;
570
+ border: 0;
571
+ border-radius: 4px;
572
+ background: transparent;
573
+ color: var(--stone);
574
+ cursor: pointer;
575
+ display: inline-flex;
576
+ align-items: center;
577
+ justify-content: center;
578
+ padding: 0;
579
+ }
580
+ .nav-expand:hover { color: var(--obsidian); background: var(--inset); }
581
+ .nav-expand .chev {
582
+ width: 6px;
583
+ height: 6px;
584
+ border-right: 1.5px solid currentColor;
585
+ border-bottom: 1.5px solid currentColor;
586
+ transform: rotate(-45deg);
587
+ margin-top: -2px;
588
+ }
589
+ .nav-op.examples-open > .nav-op-row .nav-expand .chev {
590
+ transform: rotate(45deg);
591
+ margin-top: 0;
592
+ }
593
+ .nav-expand:disabled { opacity: 0.25; cursor: default; }
594
+ .nav-examples {
595
+ display: none;
596
+ flex-direction: column;
597
+ gap: 4px;
598
+ margin: 0 4px 6px 18px;
599
+ padding-left: 8px;
600
+ border-left: 1px solid var(--hairline);
601
+ }
602
+ .nav-op.examples-open > .nav-examples { display: flex; }
603
+ .nav-ex-group { display: flex; flex-direction: column; gap: 1px; }
604
+ .nav-ex-group-label {
605
+ display: flex;
606
+ align-items: center;
607
+ justify-content: space-between;
608
+ gap: 8px;
609
+ padding: 6px 8px 2px;
610
+ font: 600 10px/1.2 var(--sans);
611
+ letter-spacing: 0.02em;
612
+ color: var(--stone);
613
+ }
614
+ .nav-ex-count {
615
+ font: 600 10px/1.4 var(--mono);
616
+ color: var(--stone);
617
+ }
618
+ .nav-example {
619
+ display: block;
620
+ width: 100%;
621
+ border: 0;
622
+ background: transparent;
623
+ text-align: left;
624
+ padding: 4px 8px;
625
+ border-radius: 4px;
626
+ cursor: pointer;
627
+ font-size: 11px;
628
+ line-height: 1.35;
629
+ color: var(--stone);
630
+ overflow: hidden;
631
+ text-overflow: ellipsis;
632
+ white-space: nowrap;
633
+ }
634
+ .nav-example:hover { background: var(--inset); color: var(--charcoal); }
635
+ .nav-example.on { color: var(--obsidian); background: var(--inset); }
636
+ .nav-ex-total {
637
+ flex: none;
638
+ min-width: 16px;
639
+ margin-right: 2px;
640
+ padding: 1px 5px;
641
+ border-radius: 4px;
642
+ background: var(--obsidian);
643
+ color: var(--white);
644
+ font: 600 10px/1.4 var(--mono);
645
+ text-align: center;
646
+ cursor: pointer;
647
+ }
648
+ .nav-title {
649
+ font-size: 12px;
650
+ color: var(--charcoal);
651
+ min-width: 0;
652
+ overflow: hidden;
653
+ text-overflow: ellipsis;
654
+ white-space: nowrap;
655
+ }
656
+ .nav-op.active .nav-title { color: var(--obsidian); font-weight: 500; }
657
+
658
+ .export-backdrop {
659
+ display: none;
660
+ position: fixed;
661
+ inset: 0;
662
+ background: rgba(232, 232, 232, 0.72);
663
+ backdrop-filter: blur(2px);
664
+ z-index: 40;
665
+ align-items: center;
666
+ justify-content: center;
667
+ padding: 24px;
668
+ }
669
+ body.exporting .export-backdrop { display: flex; }
670
+ .export-modal {
671
+ width: min(560px, 100%);
672
+ max-height: min(720px, calc(100vh - 48px));
673
+ display: flex;
674
+ flex-direction: column;
675
+ background: var(--white);
676
+ border-radius: var(--radius);
677
+ box-shadow: none;
678
+ border: 1px solid var(--hairline);
679
+ overflow: hidden;
680
+ }
681
+ .export-head {
682
+ padding: 18px 20px 12px;
683
+ border-bottom: 1px solid var(--hairline);
684
+ }
685
+ .export-head h2 {
686
+ margin: 0;
687
+ font-size: 18px;
688
+ font-weight: 500;
689
+ letter-spacing: -0.02em;
690
+ }
691
+ .export-head p {
692
+ margin: 6px 0 0;
693
+ font-size: 13px;
694
+ color: var(--stone);
695
+ line-height: 1.4;
696
+ }
697
+ .export-options {
698
+ padding: 12px 20px;
699
+ border-bottom: 1px solid var(--hairline);
700
+ display: flex;
701
+ flex-direction: column;
702
+ gap: 10px;
703
+ background: var(--inset);
704
+ }
705
+ .export-check {
706
+ display: flex;
707
+ align-items: flex-start;
708
+ gap: 8px;
709
+ font-size: 13px;
710
+ color: var(--obsidian);
711
+ cursor: pointer;
712
+ line-height: 1.35;
713
+ }
714
+ .export-check input { margin-top: 2px; }
715
+ .export-tryit-meta {
716
+ margin: -4px 0 0 22px;
717
+ font-size: 12px;
718
+ color: var(--stone);
719
+ font-family: var(--mono);
720
+ }
721
+ .export-toolbar {
722
+ display: flex;
723
+ flex-wrap: wrap;
724
+ gap: 8px;
725
+ padding: 10px 20px;
726
+ border-bottom: 1px solid var(--hairline);
727
+ }
728
+ .export-body {
729
+ flex: 1;
730
+ overflow: auto;
731
+ padding: 8px 12px 16px;
732
+ }
733
+ .export-op {
734
+ padding: 10px 8px;
735
+ border-bottom: 1px solid var(--hairline);
736
+ }
737
+ .export-op:last-child { border-bottom: 0; }
738
+ .export-op-title {
739
+ display: flex;
740
+ align-items: center;
741
+ gap: 8px;
742
+ margin-bottom: 8px;
743
+ font-size: 12px;
744
+ color: var(--obsidian);
745
+ }
746
+ .export-op-title .path {
747
+ font-family: var(--mono);
748
+ font-size: 11px;
749
+ color: var(--stone);
750
+ overflow: hidden;
751
+ text-overflow: ellipsis;
752
+ white-space: nowrap;
753
+ }
754
+ .export-ex {
755
+ display: flex;
756
+ align-items: flex-start;
757
+ gap: 8px;
758
+ padding: 4px 4px 4px 2px;
759
+ font-size: 12px;
760
+ color: var(--charcoal);
761
+ line-height: 1.35;
762
+ }
763
+ .export-ex input { margin-top: 2px; }
764
+ .export-ex label { cursor: pointer; min-width: 0; }
765
+ .export-empty {
766
+ padding: 28px 16px;
767
+ text-align: center;
768
+ color: var(--stone);
769
+ font-size: 13px;
770
+ }
771
+ .export-foot {
772
+ display: flex;
773
+ justify-content: flex-end;
774
+ gap: 8px;
775
+ padding: 12px 16px 16px;
776
+ border-top: 1px solid var(--hairline);
777
+ }
778
+
779
+ .method {
780
+ display: inline-flex;
781
+ align-items: center;
782
+ justify-content: center;
783
+ min-width: 40px;
784
+ height: 18px;
785
+ padding: 0 5px;
786
+ border-radius: 4px;
787
+ font: 600 10px/1 var(--mono);
788
+ letter-spacing: 0.04em;
789
+ text-transform: uppercase;
790
+ box-shadow: none;
791
+ border: 0;
792
+ background: #e4e4e7;
793
+ color: #27272a;
794
+ }
795
+ .method.get { background: #f4f4f5; color: #52525b; }
796
+ .method.patch { background: #d4d4d8; color: #18181b; }
797
+ .method.put { background: #a1a1aa; color: #fafafa; }
798
+ .method.post { background: #3f3f46; color: #fafafa; }
799
+ .method.delete { background: #111111; color: #ffffff; }
800
+ .schema-block {
801
+ padding: 10px 12px 12px;
802
+ border-top: 1px solid var(--hairline);
803
+ }
804
+ .schema-block .meta-label { margin-bottom: 8px; display: block; }
805
+
806
+ .ex-block { margin: 0; position: relative; }
807
+ .ex-dock {
808
+ grid-column: 3;
809
+ grid-row: 2;
810
+ position: relative;
811
+ z-index: 100;
812
+ padding: 8px 16px 10px;
813
+ background: var(--white);
814
+ border-top: 1px solid var(--hairline);
815
+ }
816
+ .ex-dock:empty { display: none; }
817
+ .ex-dock .dd-menu {
818
+ top: auto;
819
+ bottom: calc(100% + 4px);
820
+ max-height: min(380px, 45vh);
821
+ }
822
+ .dd { position: relative; width: 100%; }
823
+ .dd-toggle {
824
+ width: 100%;
825
+ height: 28px;
826
+ min-height: 28px;
827
+ border: 1px solid var(--hairline);
828
+ border-radius: var(--radius);
829
+ box-shadow: none;
830
+ background: var(--white);
831
+ padding: 0 28px 0 8px;
832
+ text-align: left;
833
+ cursor: pointer;
834
+ font-size: 12px;
835
+ line-height: 1;
836
+ position: relative;
837
+ display: flex;
838
+ align-items: center;
839
+ gap: 8px;
840
+ }
841
+ .dd-kicker {
842
+ font: 600 10px/1 var(--mono);
843
+ letter-spacing: 0.06em;
844
+ text-transform: uppercase;
845
+ color: var(--stone);
846
+ flex: none;
847
+ }
848
+ .dd-status {
849
+ font: 600 11px/1 var(--mono);
850
+ min-width: 28px;
851
+ }
852
+ .dd-status.ok { color: var(--ok); }
853
+ .dd-status.err { color: var(--err); }
854
+ .dd-kind {
855
+ color: var(--stone);
856
+ font-size: 12px;
857
+ }
858
+ .dd-toggle .dd-toggle-label {
859
+ min-width: 0;
860
+ overflow: hidden;
861
+ text-overflow: ellipsis;
862
+ white-space: nowrap;
863
+ flex: 1;
864
+ }
865
+ .dd-toggle::after {
866
+ content: "";
867
+ position: absolute;
868
+ right: 10px;
869
+ top: 50%;
870
+ width: 5px;
871
+ height: 5px;
872
+ border-right: 1px solid var(--obsidian);
873
+ border-bottom: 1px solid var(--obsidian);
874
+ transform: translateY(-70%) rotate(45deg);
875
+ }
876
+ .dd.open .dd-toggle::after { transform: translateY(-20%) rotate(225deg); }
877
+ .dd-menu {
878
+ display: none;
879
+ position: absolute;
880
+ z-index: 30;
881
+ top: calc(100% + 4px);
882
+ left: 0;
883
+ right: 0;
884
+ max-height: 420px;
885
+ overflow: hidden;
886
+ background: var(--white);
887
+ border-radius: var(--radius);
888
+ border: 1px solid var(--hairline);
889
+ box-shadow: none;
890
+ padding: 0;
891
+ }
892
+ .dd.open .dd-menu { display: flex; flex-direction: column; }
893
+ .dd-search {
894
+ height: 32px;
895
+ margin: 8px 8px 4px;
896
+ border: 1px solid var(--hairline);
897
+ border-radius: 4px;
898
+ padding: 0 8px;
899
+ font-size: 12px;
900
+ background: var(--white);
901
+ }
902
+ .dd-list { overflow: auto; padding: 4px 0 8px; }
903
+ .dd-group {
904
+ display: flex;
905
+ align-items: center;
906
+ justify-content: space-between;
907
+ gap: 8px;
908
+ font-family: var(--mono);
909
+ font-size: 10px;
910
+ letter-spacing: 0.08em;
911
+ text-transform: uppercase;
912
+ color: var(--stone);
913
+ padding: 10px 12px 4px;
914
+ }
915
+ .dd-group.ok { color: var(--ok); }
916
+ .dd-group.err { color: var(--err); }
917
+ .dd-count {
918
+ font: 600 10px/1.4 var(--mono);
919
+ color: var(--stone);
920
+ letter-spacing: 0;
921
+ text-transform: none;
922
+ }
923
+ .dd-item {
924
+ display: flex;
925
+ align-items: center;
926
+ gap: 10px;
927
+ width: 100%;
928
+ border: 0;
929
+ background: transparent;
930
+ text-align: left;
931
+ padding: 6px 12px;
932
+ font-size: 13px;
933
+ cursor: pointer;
934
+ }
935
+ .dd-item:hover, .dd-item.on { background: var(--inset); }
936
+ .dd-item .st {
937
+ font: 600 11px/1 var(--mono);
938
+ width: 28px;
939
+ flex: none;
940
+ }
941
+ .dd-item .st.ok { color: var(--ok); }
942
+ .dd-item .st.err { color: var(--err); }
943
+
944
+ .urlbar {
945
+ display: flex;
946
+ gap: 8px;
947
+ align-items: stretch;
948
+ margin-bottom: 12px;
949
+ }
950
+ .url {
951
+ flex: 1;
952
+ min-width: 0;
953
+ display: flex;
954
+ align-items: center;
955
+ gap: 10px;
956
+ background: var(--white);
957
+ border-radius: var(--radius);
958
+ border: 1px solid var(--hairline);
959
+ box-shadow: none;
960
+ padding: 0 10px;
961
+ height: 36px;
962
+ font-family: var(--mono);
963
+ font-size: 12px;
964
+ overflow: hidden;
965
+ }
966
+ .url span:last-child {
967
+ overflow: hidden;
968
+ text-overflow: ellipsis;
969
+ white-space: nowrap;
970
+ }
971
+ .url .method { flex: none; }
972
+ .btn {
973
+ border: 1px solid var(--hairline);
974
+ background: var(--white);
975
+ box-shadow: none;
976
+ border-radius: var(--radius);
977
+ padding: 0 12px;
978
+ height: 36px;
979
+ cursor: pointer;
980
+ color: var(--charcoal);
981
+ white-space: nowrap;
982
+ font-size: 12px;
983
+ text-decoration: none;
984
+ }
985
+ .btn:hover { color: var(--obsidian); }
986
+ .btn.sm { height: 32px; padding: 0 10px; font-size: 12px; }
987
+ .btn.icon {
988
+ width: 32px;
989
+ height: 32px;
990
+ padding: 0;
991
+ display: inline-flex;
992
+ align-items: center;
993
+ justify-content: center;
994
+ color: var(--stone);
995
+ }
996
+ .btn.icon:hover:not(:disabled) { color: var(--obsidian); }
997
+ .btn.icon svg { width: 15px; height: 15px; display: block; }
998
+ .btn:disabled { opacity: 0.4; cursor: default; }
999
+
1000
+ .toast {
1001
+ position: fixed;
1002
+ bottom: 24px;
1003
+ left: 50%;
1004
+ transform: translateX(-50%) translateY(12px);
1005
+ background: var(--obsidian);
1006
+ color: var(--white);
1007
+ font-size: 13px;
1008
+ padding: 10px 16px;
1009
+ border-radius: var(--radius);
1010
+ box-shadow: var(--ring);
1011
+ opacity: 0;
1012
+ pointer-events: none;
1013
+ transition: opacity 0.18s ease, transform 0.18s ease;
1014
+ z-index: 100;
1015
+ }
1016
+ .toast.show {
1017
+ opacity: 1;
1018
+ transform: translateX(-50%) translateY(0);
1019
+ }
1020
+
1021
+ .pair {
1022
+ display: grid;
1023
+ grid-template-columns: 1fr 1fr;
1024
+ gap: 12px;
1025
+ margin-bottom: 20px;
1026
+ align-items: start;
1027
+ }
1028
+ .card {
1029
+ background: var(--white);
1030
+ border-radius: var(--radius);
1031
+ border: 1px solid var(--hairline);
1032
+ box-shadow: none;
1033
+ min-width: 0;
1034
+ display: flex;
1035
+ flex-direction: column;
1036
+ max-width: 100%;
1037
+ }
1038
+ .card.response-card {
1039
+ overflow: hidden;
1040
+ }
1041
+ .card-head {
1042
+ display: flex;
1043
+ align-items: center;
1044
+ justify-content: space-between;
1045
+ gap: 12px;
1046
+ padding: 10px 12px;
1047
+ border-bottom: 1px solid var(--hairline);
1048
+ flex: none;
1049
+ }
1050
+ .card-head h2 {
1051
+ margin: 0;
1052
+ font-size: 11px;
1053
+ font-weight: 600;
1054
+ letter-spacing: 0.08em;
1055
+ text-transform: uppercase;
1056
+ }
1057
+ .card-head-actions { display: flex; align-items: center; gap: 8px; }
1058
+ .mode-toggle {
1059
+ display: flex;
1060
+ border: 1px solid var(--hairline);
1061
+ border-radius: 4px;
1062
+ overflow: hidden;
1063
+ }
1064
+ .mode-toggle button {
1065
+ height: 24px;
1066
+ padding: 0 8px;
1067
+ border: 0;
1068
+ background: var(--white);
1069
+ font-size: 11px;
1070
+ cursor: pointer;
1071
+ color: var(--stone);
1072
+ }
1073
+ .mode-toggle button.on { background: var(--obsidian); color: var(--white); }
1074
+ .card-body {
1075
+ padding: 0;
1076
+ display: flex;
1077
+ flex-direction: column;
1078
+ min-height: 0;
1079
+ }
1080
+ #response-body {
1081
+ overflow: auto;
1082
+ }
1083
+ #response-body pre {
1084
+ max-height: none;
1085
+ }
1086
+ .meta-block {
1087
+ padding: 10px 12px;
1088
+ border-top: 1px solid var(--hairline);
1089
+ }
1090
+ .meta-block:first-child { border-top: 0; }
1091
+ .meta-toolbar {
1092
+ display: flex;
1093
+ align-items: center;
1094
+ justify-content: space-between;
1095
+ gap: 8px;
1096
+ margin-bottom: 8px;
1097
+ }
1098
+ .meta-label {
1099
+ font: 600 10px/1 var(--mono);
1100
+ letter-spacing: 0.08em;
1101
+ text-transform: uppercase;
1102
+ color: var(--obsidian);
1103
+ }
1104
+ .meta-source { color: var(--smoke); font: 11px/1 var(--mono); }
1105
+ .meta-empty { color: var(--smoke); font-size: 12px; padding: 2px 0; }
1106
+ .kv {
1107
+ display: flex;
1108
+ align-items: center;
1109
+ gap: 12px;
1110
+ margin-bottom: 6px;
1111
+ font-size: 12px;
1112
+ min-width: 0;
1113
+ }
1114
+ .kv:last-child { margin-bottom: 0; }
1115
+ .kname {
1116
+ flex: none;
1117
+ width: 110px;
1118
+ color: var(--stone);
1119
+ font-family: var(--mono);
1120
+ font-size: 11px;
1121
+ letter-spacing: 0.02em;
1122
+ white-space: nowrap;
1123
+ overflow: hidden;
1124
+ text-overflow: ellipsis;
1125
+ }
1126
+ .kval {
1127
+ flex: 1;
1128
+ min-width: 0;
1129
+ font-family: var(--mono);
1130
+ font-size: 12px;
1131
+ color: var(--obsidian);
1132
+ padding: 4px 0;
1133
+ background: transparent;
1134
+ border-radius: 0;
1135
+ white-space: nowrap;
1136
+ overflow: hidden;
1137
+ text-overflow: ellipsis;
1138
+ }
1139
+ pre {
1140
+ margin: 0;
1141
+ padding: 10px 12px;
1142
+ background: #fcfcfc;
1143
+ border-radius: 0;
1144
+ overflow: auto;
1145
+ font: 12px/1.5 var(--mono);
1146
+ }
1147
+ .k { color: #111111; }
1148
+ .s { color: var(--accent); }
1149
+ .n { color: #111111; }
1150
+ .p { color: #666666; }
1151
+ .empty { color: var(--stone); font-size: 13px; padding: 14px 16px; }
1152
+ .code {
1153
+ font: 600 11px/1 var(--mono);
1154
+ padding: 3px 6px;
1155
+ border-radius: 4px;
1156
+ background: var(--inset);
1157
+ }
1158
+ .code.ok { background: var(--ok-bg); color: var(--ok); }
1159
+ .code.err { background: var(--err-bg); color: var(--err); }
1160
+ .code-text { color: var(--stone); font-size: 12px; }
1161
+ .res-meta { display: flex; align-items: center; gap: 10px; color: var(--stone); font: 11px/1 var(--mono); }
1162
+
1163
+ .schemas {
1164
+ display: grid;
1165
+ grid-template-columns: 1fr 1fr;
1166
+ gap: 24px;
1167
+ padding-top: 8px;
1168
+ border-top: 1px solid var(--hairline);
1169
+ }
1170
+ .schemas h2 {
1171
+ font-size: 11px;
1172
+ font-weight: 600;
1173
+ letter-spacing: 0.08em;
1174
+ text-transform: uppercase;
1175
+ margin: 0 0 8px;
1176
+ color: var(--stone);
1177
+ }
1178
+ .row {
1179
+ display: grid;
1180
+ grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr) auto;
1181
+ gap: 8px;
1182
+ align-items: baseline;
1183
+ padding: 5px 0;
1184
+ font-size: 12px;
1185
+ }
1186
+ .row .name {
1187
+ font-family: var(--mono);
1188
+ font-size: 12px;
1189
+ color: var(--obsidian);
1190
+ min-width: 0;
1191
+ overflow-wrap: anywhere;
1192
+ word-break: break-word;
1193
+ }
1194
+ .row .name.nested {
1195
+ color: var(--charcoal);
1196
+ border-left: 1px solid var(--hairline);
1197
+ padding-left: 8px;
1198
+ margin-left: 2px;
1199
+ }
1200
+ .row .name.nested[data-depth="2"] { margin-left: 14px; }
1201
+ .row .name.nested[data-depth="3"] { margin-left: 26px; }
1202
+ .row .name.nested[data-depth="4"] { margin-left: 38px; }
1203
+ .row .loc,
1204
+ .row .type {
1205
+ color: var(--stone);
1206
+ font-family: var(--mono);
1207
+ font-size: 11px;
1208
+ min-width: 0;
1209
+ }
1210
+ .flag { font-size: 11px; color: var(--smoke); }
1211
+ .flag.req { color: var(--err); }
1212
+
1213
+ .work-foot {
1214
+ margin-top: 24px;
1215
+ font-size: 11px;
1216
+ color: var(--smoke);
1217
+ }
1218
+
1219
+ @media (max-width: 960px) {
1220
+ .app {
1221
+ grid-template-columns: 1fr;
1222
+ grid-template-rows: auto 1fr auto;
1223
+ height: auto;
1224
+ min-height: calc(100vh - 44px);
1225
+ }
1226
+ .app.sidebar-collapsed {
1227
+ grid-template-columns: 1fr;
1228
+ }
1229
+ .sidebar, .workbench, .ex-dock { grid-column: 1; grid-row: auto; }
1230
+ .sidebar { max-height: 40vh; opacity: 1 !important; pointer-events: auto !important; padding: 16px 12px 24px !important; }
1231
+ .ex-dock { position: sticky; bottom: 0; }
1232
+ .sidebar-resizer { display: none; }
1233
+ .pair, .schemas { grid-template-columns: 1fr; }
1234
+ .search-wrap { width: min(280px, 70vw); }
1235
+ }
1236
+ </style>
1237
+ </head>
1238
+ <body>
1239
+ <header class="topnav">
1240
+ <div class="brand-wrap">
1241
+ <div class="brand" id="brand">API</div>
1242
+ <select class="ver-select" id="ver-select" aria-label="API version"></select>
1243
+ </div>
1244
+ <div class="ep-nav" id="ep-nav">
1245
+ <span class="ep-name" id="ep-name"></span>
1246
+ </div>
1247
+ <div class="nav-tools">
1248
+ <button class="btn icon" id="export-openapi" type="button" data-tip="Export" aria-label="Export">
1249
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
1250
+ </button>
1251
+ <div class="env-wrap" id="env-wrap">
1252
+ <button class="env-trigger" id="env-trigger" type="button">local · —</button>
1253
+ <div class="env-pop" id="env-pop"></div>
1254
+ </div>
1255
+ </div>
1256
+ </header>
1257
+ <div class="search-backdrop" id="search-backdrop"></div>
1258
+ <div class="export-backdrop" id="export-backdrop" role="dialog" aria-modal="true" aria-labelledby="export-title">
1259
+ <div class="export-modal" id="export-modal">
1260
+ <div class="export-head">
1261
+ <h2 id="export-title">Export Postman</h2>
1262
+ <p>Pick examples, then download a Collection with the docs folder tree. Env + headers come from the active Try-it preset.</p>
1263
+ </div>
1264
+ <div class="export-options">
1265
+ <label class="export-check">
1266
+ <input type="checkbox" id="export-include-tryit" checked />
1267
+ <span>Include env + headers <span style="color:var(--stone)">(Collection uses <code>{{baseUrl}}</code> / <code>{{vars}}</code> + environment file)</span></span>
1268
+ </label>
1269
+ <div class="export-tryit-meta" id="export-tryit-meta">—</div>
1270
+ </div>
1271
+ <div class="export-toolbar">
1272
+ <button type="button" class="btn sm" id="export-all">All</button>
1273
+ <button type="button" class="btn sm" id="export-none">None</button>
1274
+ <button type="button" class="btn sm" id="export-success">Success only</button>
1275
+ </div>
1276
+ <div class="export-body" id="export-body"></div>
1277
+ <div class="export-foot">
1278
+ <button type="button" class="btn sm" id="export-cancel">Cancel</button>
1279
+ <button type="button" class="btn primary sm" id="export-confirm">Download</button>
1280
+ </div>
1281
+ </div>
1282
+ </div>
1283
+ <div class="app" id="app">
1284
+ <aside class="sidebar">
1285
+ <div class="search-wrap" id="search-wrap">
1286
+ <input class="search" id="search" placeholder="Search endpoints..." autocomplete="off" spellcheck="false" />
1287
+ <span class="search-kbd">/</span>
1288
+ <div class="search-panel" id="search-panel" role="listbox"></div>
1289
+ </div>
1290
+ <div class="tree-scroll" id="nav"></div>
1291
+ <div class="nav-foot"><span>Generated by DAxTA</span><span id="nav-version"></span></div>
1292
+ </aside>
1293
+ <button type="button" class="sidebar-resizer" id="sidebar-resizer" aria-label="Resize sidebar" title="Drag to resize · double-click to collapse"></button>
1294
+ <main class="workbench" id="main"></main>
1295
+ <div class="ex-dock" id="ex-dock"></div>
1296
+ </div>
1297
+ <script>
1298
+ window.__SPEC__ = {
1299
+ "openapi": "3.0.3",
1300
+ "info": {
1301
+ "title": "Token X Onboarding Service",
1302
+ "version": "v1",
1303
+ "x-workspace": "token-x"
1304
+ },
1305
+ "x-viewer": {
1306
+ "workspace": "token-x",
1307
+ "baseUrl": "http://localhost:3000",
1308
+ "docsPath": "/docs",
1309
+ "envPresets": {
1310
+ "local": { "baseUrl": "http://localhost:3000" }
1311
+ }
1312
+ },
1313
+ "servers": [{ "url": "http://localhost:3000" }],
1314
+ "components": {
1315
+ "securitySchemes": {
1316
+ "adminId": { "type": "apiKey", "in": "header", "name": "x-admin-id" }
1317
+ }
1318
+ },
1319
+ "paths": {
1320
+ "/v1/admin/mock-tbs": {
1321
+ "post": {
1322
+ "summary": "Create Mock Tbs",
1323
+ "security": [{ "adminId": [] }],
1324
+ "x-tree-segments": ["v1", "mock-tbs", "admin"],
1325
+ "x-docs": {
1326
+ "title": "Create Mock Tbs",
1327
+ "fields": [
1328
+ { "name": "taxId", "in": "body", "type": "string", "required": true },
1329
+ { "name": "terminals", "in": "body", "type": "array<object>", "required": false },
1330
+ { "name": "terminals[].count", "in": "body", "type": "integer", "required": false }
1331
+ ]
1332
+ },
1333
+ "x-scenarios": [
1334
+ {
1335
+ "name": "Creates mock TBS record with counted random model",
1336
+ "group": "POSITIVE CASES",
1337
+ "status": 201,
1338
+ "headers": {
1339
+ "x-admin-id": "28c82ecd-645e-4df3-96fe-f45b8adbc5ba",
1340
+ "content-type": "application/json"
1341
+ },
1342
+ "reqBody": { "taxId": "7128961871", "terminals": [{ "count": 2 }] },
1343
+ "resBody": {
1344
+ "statusCode": 201,
1345
+ "success": true,
1346
+ "timestamp": "2026-08-22T23:24:16.571Z",
1347
+ "path": "/v1/admin/mock-tbs",
1348
+ "error": null
1349
+ }
1350
+ },
1351
+ {
1352
+ "name": "Creates mock TBS record with terminal model specs",
1353
+ "group": "POSITIVE CASES",
1354
+ "status": 201,
1355
+ "headers": {
1356
+ "x-admin-id": "28c82ecd-645e-4df3-96fe-f45b8adbc5ba",
1357
+ "content-type": "application/json"
1358
+ },
1359
+ "reqBody": { "taxId": "7128961872", "terminals": [{ "count": 1, "model": "PAX-A920" }] },
1360
+ "resBody": {
1361
+ "statusCode": 201,
1362
+ "success": true,
1363
+ "timestamp": "2026-08-22T23:24:18.120Z",
1364
+ "path": "/v1/admin/mock-tbs",
1365
+ "error": null
1366
+ }
1367
+ },
1368
+ {
1369
+ "name": "Tax id already exists",
1370
+ "group": "SEMANTIC ERROR CASES",
1371
+ "status": 409,
1372
+ "headers": {
1373
+ "x-admin-id": "28c82ecd-645e-4df3-96fe-f45b8adbc5ba",
1374
+ "content-type": "application/json"
1375
+ },
1376
+ "reqBody": { "taxId": "7128961871" },
1377
+ "resBody": {
1378
+ "statusCode": 409,
1379
+ "success": false,
1380
+ "path": "/v1/admin/mock-tbs",
1381
+ "error": "Tax id already exists"
1382
+ }
1383
+ },
1384
+ {
1385
+ "name": "Fiscal id does not exist",
1386
+ "group": "SEMANTIC ERROR CASES",
1387
+ "status": 404,
1388
+ "headers": {
1389
+ "x-admin-id": "28c82ecd-645e-4df3-96fe-f45b8adbc5ba",
1390
+ "content-type": "application/json"
1391
+ },
1392
+ "reqBody": { "taxId": "0000000000" },
1393
+ "resBody": {
1394
+ "statusCode": 404,
1395
+ "success": false,
1396
+ "path": "/v1/admin/mock-tbs",
1397
+ "error": "Fiscal id does not exist"
1398
+ }
1399
+ },
1400
+ {
1401
+ "name": "taxId should not be array",
1402
+ "group": "INVALID CASES",
1403
+ "status": 400,
1404
+ "headers": {
1405
+ "x-admin-id": "28c82ecd-645e-4df3-96fe-f45b8adbc5ba",
1406
+ "content-type": "application/json"
1407
+ },
1408
+ "reqBody": { "taxId": ["7128961871"] },
1409
+ "resBody": {
1410
+ "statusCode": 400,
1411
+ "success": false,
1412
+ "path": "/v1/admin/mock-tbs",
1413
+ "error": "taxId should not be array"
1414
+ }
1415
+ },
1416
+ {
1417
+ "name": "taxId has invalid format",
1418
+ "group": "INVALID CASES",
1419
+ "status": 400,
1420
+ "headers": {
1421
+ "x-admin-id": "28c82ecd-645e-4df3-96fe-f45b8adbc5ba",
1422
+ "content-type": "application/json"
1423
+ },
1424
+ "reqBody": { "taxId": "abc" },
1425
+ "resBody": {
1426
+ "statusCode": 400,
1427
+ "success": false,
1428
+ "path": "/v1/admin/mock-tbs",
1429
+ "error": "taxId has invalid format"
1430
+ }
1431
+ },
1432
+ {
1433
+ "name": "terminals is omitted",
1434
+ "group": "OMITTED CASES",
1435
+ "status": 201,
1436
+ "headers": {
1437
+ "x-admin-id": "28c82ecd-645e-4df3-96fe-f45b8adbc5ba",
1438
+ "content-type": "application/json"
1439
+ },
1440
+ "reqBody": { "taxId": "7128961873" },
1441
+ "resBody": {
1442
+ "statusCode": 201,
1443
+ "success": true,
1444
+ "timestamp": "2026-08-22T23:25:01.000Z",
1445
+ "path": "/v1/admin/mock-tbs",
1446
+ "error": null
1447
+ }
1448
+ },
1449
+ {
1450
+ "name": "Headers are missing",
1451
+ "group": "SEMANTIC ERROR CASES - AUTH",
1452
+ "status": 401,
1453
+ "headers": { "content-type": "application/json" },
1454
+ "reqBody": { "taxId": "7128961871" },
1455
+ "resBody": {
1456
+ "statusCode": 401,
1457
+ "success": false,
1458
+ "path": "/v1/admin/mock-tbs",
1459
+ "error": "Unauthorized"
1460
+ }
1461
+ }
1462
+ ]
1463
+ }
1464
+ },
1465
+ "/v1/admin/terminals": {
1466
+ "get": {
1467
+ "summary": "List Terminals",
1468
+ "security": [{ "adminId": [] }],
1469
+ "x-tree-segments": ["v1", "terminal", "admin"],
1470
+ "x-docs": { "title": "List Terminals", "fields": [] },
1471
+ "x-scenarios": [
1472
+ {
1473
+ "name": "Returns terminals for admin",
1474
+ "group": "POSITIVE CASES",
1475
+ "status": 200,
1476
+ "headers": { "x-admin-id": "28c82ecd-645e-4df3-96fe-f45b8adbc5ba" },
1477
+ "resBody": { "statusCode": 200, "success": true, "data": [] }
1478
+ }
1479
+ ]
1480
+ }
1481
+ },
1482
+ "/v1/payments": {
1483
+ "post": {
1484
+ "summary": "Create Payment",
1485
+ "x-tree-segments": ["v1", "payments"],
1486
+ "x-docs": { "title": "Create Payment", "fields": [{ "name": "amount", "in": "body", "type": "number", "required": true }] },
1487
+ "x-scenarios": [
1488
+ {
1489
+ "name": "Creates a payment",
1490
+ "group": "POSITIVE CASES",
1491
+ "status": 201,
1492
+ "headers": { "content-type": "application/json" },
1493
+ "reqBody": { "amount": 1200 },
1494
+ "resBody": { "statusCode": 201, "success": true }
1495
+ }
1496
+ ]
1497
+ }
1498
+ }
1499
+ }
1500
+ };
1501
+ </script>
1502
+ <script>
1503
+ const spec = window.__SPEC__ || {};
1504
+ const viewer = spec["x-viewer"] || {};
1505
+ const workspace = (spec.info && spec.info["x-workspace"]) || viewer.workspace || "";
1506
+ const defaultBaseUrlFromSpec = String((viewer.baseUrl || (spec.servers && spec.servers[0] && spec.servers[0].url) || "http://localhost:3000")).replace(/\/$/, "");
1507
+ const docsPathSuffix = String(viewer.docsPath || "/docs").replace(/\/$/, "") || "/docs";
1508
+
1509
+ const inferBaseUrlFromLocation = () => {
1510
+ if (typeof location === "undefined") return null;
1511
+ if (location.protocol !== "http:" && location.protocol !== "https:") return null;
1512
+ let pathname = (location.pathname || "/").replace(/\/$/, "") || "";
1513
+ if (pathname === docsPathSuffix) return location.origin.replace(/\/$/, "");
1514
+ if (pathname.endsWith(docsPathSuffix)) {
1515
+ const prefix = pathname.slice(0, -docsPathSuffix.length).replace(/\/$/, "");
1516
+ return (location.origin + prefix).replace(/\/$/, "");
1517
+ }
1518
+ const idx = pathname.indexOf(docsPathSuffix + "/");
1519
+ if (idx >= 0) {
1520
+ const prefix = pathname.slice(0, idx).replace(/\/$/, "");
1521
+ return (location.origin + prefix).replace(/\/$/, "");
1522
+ }
1523
+ return null;
1524
+ };
1525
+
1526
+ const locationBaseUrl = inferBaseUrlFromLocation();
1527
+ // Prefer the URL that is serving the viewer (strip /docs), else fall back to spec.
1528
+ const defaultBaseUrl = locationBaseUrl || defaultBaseUrlFromSpec;
1529
+ const title = (spec.info && spec.info.title) || "API Docs";
1530
+ const STORE_KEY = "openapi-docs-env:" + (workspace || "default");
1531
+ const SIDEBAR_STORE_KEY = "openapi-docs-sidebar:" + (workspace || "default");
1532
+ const SIDEBAR_MIN = 200;
1533
+ const SIDEBAR_MAX = 560;
1534
+ const SIDEBAR_DEFAULT = 320;
1535
+
1536
+ const docsBaseForApi = (() => {
1537
+ if (typeof location === "undefined") return docsPathSuffix;
1538
+ let pathname = (location.pathname || "/").replace(/\/$/, "") || "";
1539
+ if (pathname === docsPathSuffix || pathname.endsWith(docsPathSuffix)) return pathname || docsPathSuffix;
1540
+ const idx = pathname.indexOf(docsPathSuffix);
1541
+ if (idx >= 0) return pathname.slice(0, idx + docsPathSuffix.length) || docsPathSuffix;
1542
+ return docsPathSuffix;
1543
+ })();
1544
+ const ENV_STORE_URL = docsBaseForApi + "/env.json";
1545
+
1546
+ const loadSidebarLayout = () => {
1547
+ try {
1548
+ const raw = localStorage.getItem(SIDEBAR_STORE_KEY);
1549
+ if (!raw) return { width: SIDEBAR_DEFAULT, collapsed: false };
1550
+ const parsed = JSON.parse(raw);
1551
+ const width = Number(parsed.width);
1552
+ return {
1553
+ width: Number.isFinite(width) ? Math.min(SIDEBAR_MAX, Math.max(SIDEBAR_MIN, width)) : SIDEBAR_DEFAULT,
1554
+ collapsed: Boolean(parsed.collapsed),
1555
+ };
1556
+ } catch {
1557
+ return { width: SIDEBAR_DEFAULT, collapsed: false };
1558
+ }
1559
+ };
1560
+
1561
+ let sidebarLayout = loadSidebarLayout();
1562
+
1563
+ const applySidebarLayout = () => {
1564
+ const app = document.getElementById("app");
1565
+ const resizer = document.getElementById("sidebar-resizer");
1566
+ if (!app) return;
1567
+ app.style.setProperty("--sidebar-w", sidebarLayout.width + "px");
1568
+ app.classList.toggle("sidebar-collapsed", sidebarLayout.collapsed);
1569
+ if (resizer) {
1570
+ resizer.title = sidebarLayout.collapsed
1571
+ ? "Click to expand sidebar"
1572
+ : "Drag to resize · double-click to collapse";
1573
+ resizer.setAttribute("aria-label", sidebarLayout.collapsed ? "Expand sidebar" : "Resize sidebar");
1574
+ }
1575
+ };
1576
+
1577
+ const persistSidebarLayout = () => {
1578
+ try {
1579
+ localStorage.setItem(SIDEBAR_STORE_KEY, JSON.stringify(sidebarLayout));
1580
+ } catch {}
1581
+ };
1582
+
1583
+ const initSidebarResize = () => {
1584
+ const resizer = document.getElementById("sidebar-resizer");
1585
+ if (!resizer) return;
1586
+ applySidebarLayout();
1587
+
1588
+ let dragging = false;
1589
+ let startX = 0;
1590
+ let startWidth = 0;
1591
+ let moved = false;
1592
+
1593
+ const onMove = (event) => {
1594
+ if (!dragging) return;
1595
+ if (event.cancelable) event.preventDefault();
1596
+ const clientX = event.touches ? event.touches[0].clientX : event.clientX;
1597
+ const delta = clientX - startX;
1598
+ if (Math.abs(delta) > 2) moved = true;
1599
+ const next = Math.min(SIDEBAR_MAX, Math.max(SIDEBAR_MIN, startWidth + delta));
1600
+ sidebarLayout.width = next;
1601
+ sidebarLayout.collapsed = false;
1602
+ applySidebarLayout();
1603
+ };
1604
+
1605
+ const onUp = () => {
1606
+ if (!dragging) return;
1607
+ dragging = false;
1608
+ document.body.classList.remove("sidebar-resizing");
1609
+ window.removeEventListener("mousemove", onMove);
1610
+ window.removeEventListener("mouseup", onUp);
1611
+ window.removeEventListener("touchmove", onMove);
1612
+ window.removeEventListener("touchend", onUp);
1613
+ persistSidebarLayout();
1614
+ };
1615
+
1616
+ const onDown = (event) => {
1617
+ if (sidebarLayout.collapsed) return;
1618
+ if (event.button != null && event.button !== 0) return;
1619
+ event.preventDefault();
1620
+ dragging = true;
1621
+ moved = false;
1622
+ startX = event.touches ? event.touches[0].clientX : event.clientX;
1623
+ startWidth = sidebarLayout.width;
1624
+ document.body.classList.add("sidebar-resizing");
1625
+ window.addEventListener("mousemove", onMove);
1626
+ window.addEventListener("mouseup", onUp);
1627
+ window.addEventListener("touchmove", onMove, { passive: false });
1628
+ window.addEventListener("touchend", onUp);
1629
+ };
1630
+
1631
+ resizer.addEventListener("mousedown", onDown);
1632
+ resizer.addEventListener("touchstart", onDown, { passive: false });
1633
+ resizer.addEventListener("dblclick", (event) => {
1634
+ event.preventDefault();
1635
+ sidebarLayout.collapsed = !sidebarLayout.collapsed;
1636
+ if (!sidebarLayout.collapsed && sidebarLayout.width < SIDEBAR_MIN) sidebarLayout.width = SIDEBAR_DEFAULT;
1637
+ applySidebarLayout();
1638
+ persistSidebarLayout();
1639
+ });
1640
+ resizer.addEventListener("click", (event) => {
1641
+ if (!sidebarLayout.collapsed || moved) return;
1642
+ event.preventDefault();
1643
+ sidebarLayout.collapsed = false;
1644
+ applySidebarLayout();
1645
+ persistSidebarLayout();
1646
+ });
1647
+ };
1648
+
1649
+ initSidebarResize();
1650
+
1651
+ let liveResult = null;
1652
+
1653
+ const escapeAttr = (value) =>
1654
+ String(value ?? "")
1655
+ .replace(/&/g, "&amp;")
1656
+ .replace(/"/g, "&quot;")
1657
+ .replace(/</g, "&lt;");
1658
+
1659
+ const varNameFromHeader = (header) => {
1660
+ const parts = String(header).replace(/^x-/, "").split("-").filter(Boolean);
1661
+ if (!parts.length) return String(header).replace(/[^a-zA-Z0-9]/g, "");
1662
+ return parts[0] + parts.slice(1).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
1663
+ };
1664
+
1665
+ /** Pull try-it defaults from recorded success traffic + parameter examples. */
1666
+ const collectDefaultHeaderValues = () => {
1667
+ const byHeader = {};
1668
+ const take = (header, value, prefer) => {
1669
+ if (value == null || value === "") return;
1670
+ const key = String(header).toLowerCase();
1671
+ if (!byHeader[key] || prefer) byHeader[key] = String(value);
1672
+ };
1673
+ for (const pathItem of Object.values(spec.paths || {})) {
1674
+ for (const op of Object.values(pathItem || {})) {
1675
+ if (!op || typeof op !== "object") continue;
1676
+ for (const param of op.parameters || []) {
1677
+ if (param && param.in === "header" && param.name && param.example != null) {
1678
+ take(param.name, param.example, false);
1679
+ }
1680
+ }
1681
+ for (const scenario of op["x-scenarios"] || []) {
1682
+ const success = scenario.status >= 200 && scenario.status < 300;
1683
+ for (const [header, value] of Object.entries(scenario.headers || {})) {
1684
+ if (!String(header).toLowerCase().startsWith("x-")) continue;
1685
+ take(header, value, success);
1686
+ }
1687
+ }
1688
+ }
1689
+ }
1690
+ return byHeader;
1691
+ };
1692
+
1693
+ const defaultHeaderValues = collectDefaultHeaderValues();
1694
+
1695
+ const configuredPresets = (() => {
1696
+ const raw = viewer.envPresets;
1697
+ if (raw && typeof raw === "object" && Object.keys(raw).length) return raw;
1698
+ return { local: { baseUrl: defaultBaseUrl } };
1699
+ })();
1700
+
1701
+ const setEnvBaseUrl = (env, baseUrl) => {
1702
+ const variables = env.variables || (env.variables = []);
1703
+ const row = variables.find((entry) => entry.key === "baseUrl");
1704
+ if (row) row.value = baseUrl;
1705
+ else variables.unshift({ key: "baseUrl", value: baseUrl });
1706
+ };
1707
+
1708
+ const buildHeaderTemplate = () => {
1709
+ const schemes = (spec.components && spec.components.securitySchemes) || {};
1710
+ const variables = [];
1711
+ const varKeys = new Set();
1712
+ const headerGroups = {};
1713
+ for (const [schemeId, scheme] of Object.entries(schemes)) {
1714
+ if (!scheme || scheme.in !== "header" || !scheme.name) continue;
1715
+ const header = scheme.name;
1716
+ const varName = varNameFromHeader(header);
1717
+ if (!varKeys.has(varName)) {
1718
+ const seeded = defaultHeaderValues[String(header).toLowerCase()] || "";
1719
+ variables.push({ key: varName, value: seeded });
1720
+ varKeys.add(varName);
1721
+ }
1722
+ headerGroups[schemeId] = [
1723
+ { key: header, value: "{{" + varName + "}}" },
1724
+ { key: "content-type", value: "application/json" },
1725
+ ];
1726
+ }
1727
+ const seenCombos = new Set();
1728
+ for (const pathItem of Object.values(spec.paths || {})) {
1729
+ for (const op of Object.values(pathItem || {})) {
1730
+ if (!op || typeof op !== "object") continue;
1731
+ const ids = [];
1732
+ for (const requirement of op.security || []) {
1733
+ if (!requirement || typeof requirement !== "object") continue;
1734
+ for (const id of Object.keys(requirement)) {
1735
+ if (headerGroups[id]) ids.push(id);
1736
+ }
1737
+ }
1738
+ const unique = [...new Set(ids)];
1739
+ if (unique.length < 2) continue;
1740
+ const comboKey = unique.slice().sort().join("+");
1741
+ if (seenCombos.has(comboKey)) continue;
1742
+ seenCombos.add(comboKey);
1743
+ const byKey = {};
1744
+ for (const id of unique) {
1745
+ for (const row of headerGroups[id] || []) {
1746
+ if (!row.key) continue;
1747
+ byKey[row.key] = { key: row.key, value: row.value };
1748
+ }
1749
+ }
1750
+ if (!byKey["content-type"]) byKey["content-type"] = { key: "content-type", value: "application/json" };
1751
+ headerGroups[comboKey] = Object.values(byKey);
1752
+ }
1753
+ }
1754
+ const groupNames = Object.keys(headerGroups);
1755
+ if (!groupNames.length) headerGroups.default = [{ key: "content-type", value: "application/json" }];
1756
+ return { variables, headerGroups };
1757
+ };
1758
+
1759
+ const envFromPreset = (preset) => {
1760
+ const template = buildHeaderTemplate();
1761
+ const baseUrl = String((preset && preset.baseUrl) || defaultBaseUrl).replace(/\/$/, "") || defaultBaseUrl;
1762
+ const variables = [{ key: "baseUrl", value: baseUrl }, ...template.variables.map((row) => ({ ...row }))];
1763
+ const known = new Set(variables.map((row) => row.key));
1764
+ if (preset && preset.variables && typeof preset.variables === "object") {
1765
+ for (const [key, value] of Object.entries(preset.variables)) {
1766
+ if (!key || key === "baseUrl") continue;
1767
+ if (known.has(key)) {
1768
+ const row = variables.find((entry) => entry.key === key);
1769
+ if (row) row.value = String(value ?? "");
1770
+ } else {
1771
+ variables.push({ key, value: String(value ?? "") });
1772
+ known.add(key);
1773
+ }
1774
+ }
1775
+ }
1776
+ const headerGroups = {};
1777
+ for (const [group, rows] of Object.entries(template.headerGroups)) {
1778
+ headerGroups[group] = rows.map((row) => ({ ...row }));
1779
+ }
1780
+ return { variables, headerGroups };
1781
+ };
1782
+
1783
+ const buildDefaultStore = () => {
1784
+ const envs = {};
1785
+ for (const [name, preset] of Object.entries(configuredPresets)) {
1786
+ envs[name] = envFromPreset(preset);
1787
+ }
1788
+ if (!Object.keys(envs).length) envs.local = envFromPreset({ baseUrl: defaultBaseUrl });
1789
+ const names = Object.keys(envs);
1790
+ const activeEnv = names.includes("local") ? "local" : names[0];
1791
+ const groupNames = Object.keys(envs[activeEnv].headerGroups || {});
1792
+ return {
1793
+ activeEnv,
1794
+ activeGroup: groupNames[0] || "default",
1795
+ envs,
1796
+ };
1797
+ };
1798
+
1799
+ const cloneDefaultEnv = () => {
1800
+ const defaults = buildDefaultStore();
1801
+ const name = defaults.envs.local ? "local" : Object.keys(defaults.envs)[0];
1802
+ return JSON.parse(JSON.stringify(defaults.envs[name]));
1803
+ };
1804
+
1805
+ const mergeStore = (saved) => {
1806
+ const defaults = buildDefaultStore();
1807
+ if (!saved || !saved.envs || typeof saved.envs !== "object") return defaults;
1808
+ const envs = {};
1809
+ for (const [name, env] of Object.entries(saved.envs)) {
1810
+ const base = cloneDefaultEnv();
1811
+ const variables = Array.isArray(env.variables)
1812
+ ? env.variables.map((row) => ({ key: String(row.key || ""), value: String(row.value ?? "") }))
1813
+ : base.variables.map((row) => ({ ...row }));
1814
+ const known = new Set(variables.map((row) => row.key).filter(Boolean));
1815
+ for (const row of base.variables) {
1816
+ if (row.key && !known.has(row.key)) variables.push({ ...row });
1817
+ }
1818
+ const defaultsByKey = Object.fromEntries((base.variables || []).filter((row) => row.key).map((row) => [row.key, row.value ?? ""]));
1819
+ for (const row of variables) {
1820
+ if (!row.key) continue;
1821
+ if (String(row.value ?? "").trim()) continue;
1822
+ if (defaultsByKey[row.key]) row.value = defaultsByKey[row.key];
1823
+ }
1824
+ const headerGroups = { ...(env.headerGroups || {}) };
1825
+ for (const [group, rows] of Object.entries(base.headerGroups)) {
1826
+ if (!headerGroups[group]) headerGroups[group] = rows.map((row) => ({ ...row }));
1827
+ }
1828
+ if (!Object.keys(headerGroups).length) headerGroups.default = [{ key: "content-type", value: "application/json" }];
1829
+ envs[name] = { variables, headerGroups };
1830
+ }
1831
+ // Seed any config presets that are missing from the saved store (don't wipe existing).
1832
+ for (const [name, preset] of Object.entries(configuredPresets)) {
1833
+ if (envs[name]) continue;
1834
+ envs[name] = envFromPreset(preset);
1835
+ }
1836
+ if (!Object.keys(envs).length) return defaults;
1837
+ const activeEnv = envs[saved.activeEnv] ? saved.activeEnv : Object.keys(envs)[0];
1838
+ const groups = Object.keys(envs[activeEnv].headerGroups || {});
1839
+ const activeGroup = groups.includes(saved.activeGroup) ? saved.activeGroup : groups[0] || "default";
1840
+ return { activeEnv, activeGroup, envs };
1841
+ };
1842
+
1843
+ const loadLocalStore = () => {
1844
+ try {
1845
+ const raw = localStorage.getItem(STORE_KEY);
1846
+ if (raw) return mergeStore(JSON.parse(raw));
1847
+ } catch {}
1848
+ return null;
1849
+ };
1850
+
1851
+ /**
1852
+ * Only rewrite baseUrl for local-ish presets so staging/production stay intact.
1853
+ */
1854
+ const applyServingBaseUrl = (state) => {
1855
+ if (!locationBaseUrl || !state || !state.envs) return state;
1856
+ const preferred = ["local", "development", "dev"].find((name) => state.envs[name]);
1857
+ if (preferred) {
1858
+ setEnvBaseUrl(state.envs[preferred], locationBaseUrl);
1859
+ return state;
1860
+ }
1861
+ const names = Object.keys(state.envs);
1862
+ if (names.length === 1) setEnvBaseUrl(state.envs[names[0]], locationBaseUrl);
1863
+ return state;
1864
+ };
1865
+
1866
+ // Prefer disk (shared across browsers / deploy), then localStorage, then defaults.
1867
+ let store = applyServingBaseUrl(loadLocalStore() || buildDefaultStore());
1868
+ let persistTimer = null;
1869
+
1870
+ const writeLocalStore = () => {
1871
+ try {
1872
+ localStorage.setItem(STORE_KEY, JSON.stringify(store));
1873
+ } catch {}
1874
+ };
1875
+
1876
+ const writeServerStore = async () => {
1877
+ try {
1878
+ const res = await fetch(ENV_STORE_URL, {
1879
+ method: "PUT",
1880
+ headers: { "content-type": "application/json" },
1881
+ body: JSON.stringify(store),
1882
+ });
1883
+ if (!res.ok) return;
1884
+ } catch {
1885
+ /* offline / file:// — localStorage still works */
1886
+ }
1887
+ };
1888
+
1889
+ const persistStore = () => {
1890
+ writeLocalStore();
1891
+ if (persistTimer) clearTimeout(persistTimer);
1892
+ persistTimer = setTimeout(() => {
1893
+ persistTimer = null;
1894
+ writeServerStore();
1895
+ }, 250);
1896
+ };
1897
+
1898
+ const hydrateStoreFromServer = async () => {
1899
+ try {
1900
+ const res = await fetch(ENV_STORE_URL, { cache: "no-store" });
1901
+ if (!res.ok) return false;
1902
+ const remote = await res.json();
1903
+ if (!remote || typeof remote !== "object" || !remote.envs) return false;
1904
+ store = applyServingBaseUrl(mergeStore(remote));
1905
+ writeLocalStore();
1906
+ return true;
1907
+ } catch {
1908
+ return false;
1909
+ }
1910
+ };
1911
+
1912
+ const activeEnvConfig = () => store.envs[store.activeEnv] || store.envs[Object.keys(store.envs)[0]];
1913
+
1914
+ const varMap = () => {
1915
+ const env = activeEnvConfig();
1916
+ return Object.fromEntries((env.variables || []).filter((row) => row.key).map((row) => [row.key, row.value ?? ""]));
1917
+ };
1918
+
1919
+ const interpolate = (value, vars, depth = 0) => {
1920
+ if (value == null || depth > 8) return value;
1921
+ if (typeof value === "object") {
1922
+ if (Array.isArray(value)) return value.map((item) => interpolate(item, vars, depth));
1923
+ return Object.fromEntries(Object.entries(value).map(([key, nested]) => [key, interpolate(nested, vars, depth)]));
1924
+ }
1925
+ if (typeof value !== "string") return value;
1926
+ return value.replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g, (_, key) => (key in vars ? String(interpolate(vars[key], vars, depth + 1)) : "{{" + key + "}}"));
1927
+ };
1928
+
1929
+ const resolvedHeadersFromGroup = (groupName) => {
1930
+ const env = activeEnvConfig();
1931
+ const groups = env.headerGroups || {};
1932
+ const group = groups[groupName] || groups[Object.keys(groups)[0]] || [];
1933
+ const vars = varMap();
1934
+ return Object.fromEntries(group.filter((row) => row.key).map((row) => [row.key, String(interpolate(row.value || "", vars))]));
1935
+ };
1936
+
1937
+ const resolvedHeaders = () => resolvedHeadersFromGroup(store.activeGroup);
1938
+
1939
+ /** OpenAPI security scheme ids for an operation (union across requirements). */
1940
+ const securitySchemeIds = (op) => {
1941
+ const requirements = (op && op.security) || spec.security || [];
1942
+ if (!Array.isArray(requirements) || !requirements.length) return [];
1943
+ const ids = [];
1944
+ for (const requirement of requirements) {
1945
+ if (!requirement || typeof requirement !== "object") continue;
1946
+ for (const id of Object.keys(requirement)) ids.push(id);
1947
+ }
1948
+ return [...new Set(ids)];
1949
+ };
1950
+
1951
+ /** Stable group name for this op: single scheme, or merged combo (userId+merchantId). */
1952
+ const requiredGroupName = (op) => {
1953
+ const ids = securitySchemeIds(op);
1954
+ if (!ids.length) return null;
1955
+ if (ids.length === 1) return ids[0];
1956
+ return ids.slice().sort().join("+");
1957
+ };
1958
+
1959
+ /** Fixed hint next to Headers — what this API needs to work. */
1960
+ const requiredAuthHint = (op) => {
1961
+ const ids = securitySchemeIds(op);
1962
+ if (!ids.length) return "";
1963
+ return "Required: " + ids.join(" + ");
1964
+ };
1965
+
1966
+ /** Ensure merged combo group exists in the active env (lazy for older localStorage). */
1967
+ const ensureRequiredHeaderGroup = (op) => {
1968
+ const name = requiredGroupName(op);
1969
+ if (!name) return null;
1970
+ const env = activeEnvConfig();
1971
+ const groups = env.headerGroups || (env.headerGroups = {});
1972
+ if (groups[name]) return name;
1973
+ const ids = securitySchemeIds(op);
1974
+ const byKey = {};
1975
+ for (const id of ids) {
1976
+ for (const row of groups[id] || []) {
1977
+ if (!row.key) continue;
1978
+ byKey[row.key] = { key: row.key, value: row.value };
1979
+ }
1980
+ }
1981
+ if (!Object.keys(byKey).length) return null;
1982
+ if (!byKey["content-type"]) byKey["content-type"] = { key: "content-type", value: "application/json" };
1983
+ groups[name] = Object.values(byKey);
1984
+ return name;
1985
+ };
1986
+
1987
+ /**
1988
+ * On operation select: switch to the required (possibly merged) group once.
1989
+ * User can still change the group from the top env panel afterward; Send follows that.
1990
+ */
1991
+ const syncHeaderGroupForOp = (op) => {
1992
+ const name = ensureRequiredHeaderGroup(op);
1993
+ if (!name) return;
1994
+ if (store.activeGroup === name) return;
1995
+ store.activeGroup = name;
1996
+ persistStore();
1997
+ syncEnvTrigger();
1998
+ if (document.getElementById("env-wrap")?.classList.contains("open")) renderEnvPop();
1999
+ };
2000
+
2001
+ const currentBaseUrl = () => String(interpolate(varMap().baseUrl || defaultBaseUrl, varMap()) || defaultBaseUrl).replace(/\/$/, "");
2002
+
2003
+ const envLabel = () => store.activeEnv + " · " + store.activeGroup;
2004
+
2005
+ const syncEnvTrigger = () => {
2006
+ const trigger = document.getElementById("env-trigger");
2007
+ if (!trigger) return;
2008
+ trigger.textContent = envLabel();
2009
+ const base = varMap().baseUrl || "";
2010
+ trigger.title = base ? store.activeEnv + " · " + base + " · " + store.activeGroup : envLabel();
2011
+ };
2012
+
2013
+ const presetBaseUrl = (name) => {
2014
+ const env = store.envs[name];
2015
+ if (!env) return "";
2016
+ const row = (env.variables || []).find((entry) => entry.key === "baseUrl");
2017
+ return row ? String(row.value || "") : "";
2018
+ };
2019
+
2020
+ const addNamedPreset = (name, baseUrl) => {
2021
+ if (!name || store.envs[name]) return false;
2022
+ const env = cloneDefaultEnv();
2023
+ setEnvBaseUrl(env, baseUrl || defaultBaseUrl);
2024
+ store.envs[name] = env;
2025
+ store.activeEnv = name;
2026
+ store.activeGroup = Object.keys(env.headerGroups || {})[0] || "default";
2027
+ return true;
2028
+ };
2029
+
2030
+ const renderEnvPop = () => {
2031
+ const env = activeEnvConfig();
2032
+ const envNames = Object.keys(store.envs);
2033
+ const groups = Object.keys(env.headerGroups || {});
2034
+ if (!groups.includes(store.activeGroup)) store.activeGroup = groups[0] || "default";
2035
+ const groupRows = env.headerGroups[store.activeGroup] || [];
2036
+ const canRemoveEnv = envNames.length > 1;
2037
+ const canRemoveGroup = groups.length > 1;
2038
+ const activeBase = presetBaseUrl(store.activeEnv) || defaultBaseUrl;
2039
+ const quickPresets = [
2040
+ { id: "staging", baseUrl: (configuredPresets.staging && configuredPresets.staging.baseUrl) || "https://api.staging.example.com" },
2041
+ { id: "production", baseUrl: (configuredPresets.production && configuredPresets.production.baseUrl) || "https://api.example.com" },
2042
+ ].filter((preset) => !store.envs[preset.id]);
2043
+
2044
+ document.getElementById("env-pop").innerHTML = `
2045
+ <div class="env-block">
2046
+ <div class="env-label">Presets</div>
2047
+ <div class="chip-row">
2048
+ ${envNames
2049
+ .map((id) => `<button type="button" class="chip-btn ${id === store.activeEnv ? "on" : ""}" data-env="${escapeAttr(id)}" title="${escapeAttr(presetBaseUrl(id))}">${escapeAttr(id)}</button>`)
2050
+ .join("")}
2051
+ <button type="button" class="ghost-btn" id="add-env" title="Add preset">+</button>
2052
+ <button type="button" class="ghost-btn" id="dup-env" title="Duplicate preset">⧉</button>
2053
+ <button type="button" class="ghost-btn" id="remove-env" title="Remove preset" ${canRemoveEnv ? "" : "disabled"}>×</button>
2054
+ </div>
2055
+ <div class="env-base-line"><span>baseUrl</span> · ${escapeAttr(activeBase)}</div>
2056
+ ${
2057
+ quickPresets.length
2058
+ ? `<div class="env-quick">${quickPresets
2059
+ .map(
2060
+ (preset) =>
2061
+ `<button type="button" class="btn sm" data-quick-preset="${escapeAttr(preset.id)}" data-base="${escapeAttr(preset.baseUrl)}">+ ${escapeAttr(preset.id)}</button>`,
2062
+ )
2063
+ .join("")}</div>`
2064
+ : ""
2065
+ }
2066
+ </div>
2067
+ <div class="env-block">
2068
+ <div class="env-label">Variables</div>
2069
+ ${(env.variables || [])
2070
+ .map(
2071
+ (row, index) => `<div class="env-kv ${row.key === "baseUrl" ? "base-url" : ""}" data-var="${index}">
2072
+ <input class="env-cell" data-field="key" spellcheck="false" value="${escapeAttr(row.key)}" ${row.key === "baseUrl" ? "readonly" : ""} />
2073
+ <input class="env-cell" data-field="value" spellcheck="false" value="${escapeAttr(row.value)}" />
2074
+ <button type="button" class="ghost-btn" data-remove-var="${index}" ${row.key === "baseUrl" ? "disabled" : ""}>×</button>
2075
+ </div>`,
2076
+ )
2077
+ .join("")}
2078
+ <button type="button" class="btn env-add" id="add-var">Add variable</button>
2079
+ </div>
2080
+ <div class="env-block">
2081
+ <div class="env-label">Header group</div>
2082
+ <div class="chip-row">
2083
+ ${groups
2084
+ .map((group) => `<button type="button" class="chip-btn ${group === store.activeGroup ? "on" : ""}" data-group="${escapeAttr(group)}">${escapeAttr(group)}</button>`)
2085
+ .join("")}
2086
+ <button type="button" class="ghost-btn" id="add-group" title="Add header group">+</button>
2087
+ <button type="button" class="ghost-btn" id="remove-group" title="Remove header group" ${canRemoveGroup ? "" : "disabled"}>×</button>
2088
+ </div>
2089
+ ${groupRows
2090
+ .map(
2091
+ (row, index) => `<div class="env-kv" data-hdr="${index}">
2092
+ <input class="env-cell" data-field="key" spellcheck="false" value="${escapeAttr(row.key)}" />
2093
+ <input class="env-cell" data-field="value" spellcheck="false" value="${escapeAttr(row.value)}" />
2094
+ <button type="button" class="ghost-btn" data-remove-hdr="${index}">×</button>
2095
+ </div>`,
2096
+ )
2097
+ .join("")}
2098
+ <button type="button" class="btn env-add" id="add-hdr">Add header</button>
2099
+ </div>
2100
+ `;
2101
+
2102
+ syncEnvTrigger();
2103
+
2104
+ document.getElementById("env-pop").querySelectorAll("[data-env]").forEach((button) => {
2105
+ button.onclick = (event) => {
2106
+ event.stopPropagation();
2107
+ store.activeEnv = button.dataset.env;
2108
+ const nextGroups = Object.keys(activeEnvConfig().headerGroups || {});
2109
+ if (!nextGroups.includes(store.activeGroup)) store.activeGroup = nextGroups[0] || "default";
2110
+ persistStore();
2111
+ renderEnvPop();
2112
+ renderMain();
2113
+ };
2114
+ });
2115
+ document.getElementById("env-pop").querySelectorAll("[data-quick-preset]").forEach((button) => {
2116
+ button.onclick = (event) => {
2117
+ event.stopPropagation();
2118
+ if (!addNamedPreset(button.dataset.quickPreset, button.dataset.base)) return;
2119
+ persistStore();
2120
+ renderEnvPop();
2121
+ renderMain();
2122
+ };
2123
+ });
2124
+ document.getElementById("add-env").onclick = (event) => {
2125
+ event.stopPropagation();
2126
+ const typed = window.prompt("Preset name (e.g. staging)", "staging");
2127
+ if (!typed) return;
2128
+ const name = typed.trim().replace(/\s+/g, "-");
2129
+ if (!name) return;
2130
+ if (store.envs[name]) {
2131
+ store.activeEnv = name;
2132
+ } else {
2133
+ const base = window.prompt("baseUrl", configuredPresets[name]?.baseUrl || defaultBaseUrl) || defaultBaseUrl;
2134
+ addNamedPreset(name, base.replace(/\/$/, ""));
2135
+ }
2136
+ persistStore();
2137
+ renderEnvPop();
2138
+ renderMain();
2139
+ };
2140
+ document.getElementById("dup-env").onclick = (event) => {
2141
+ event.stopPropagation();
2142
+ const source = store.activeEnv;
2143
+ let name = source + "-copy";
2144
+ let n = 2;
2145
+ while (store.envs[name]) {
2146
+ name = source + "-copy" + n;
2147
+ n += 1;
2148
+ }
2149
+ store.envs[name] = JSON.parse(JSON.stringify(activeEnvConfig()));
2150
+ store.activeEnv = name;
2151
+ persistStore();
2152
+ renderEnvPop();
2153
+ renderMain();
2154
+ };
2155
+ document.getElementById("remove-env").onclick = (event) => {
2156
+ event.stopPropagation();
2157
+ const names = Object.keys(store.envs);
2158
+ if (names.length <= 1 || !store.envs[store.activeEnv]) return;
2159
+ delete store.envs[store.activeEnv];
2160
+ store.activeEnv = Object.keys(store.envs)[0];
2161
+ const nextGroups = Object.keys(activeEnvConfig().headerGroups || {});
2162
+ store.activeGroup = nextGroups.includes(store.activeGroup) ? store.activeGroup : nextGroups[0] || "default";
2163
+ persistStore();
2164
+ renderEnvPop();
2165
+ renderMain();
2166
+ };
2167
+ document.getElementById("env-pop").querySelectorAll("[data-group]").forEach((button) => {
2168
+ button.onclick = (event) => {
2169
+ event.stopPropagation();
2170
+ store.activeGroup = button.dataset.group;
2171
+ persistStore();
2172
+ renderEnvPop();
2173
+ renderMain();
2174
+ };
2175
+ });
2176
+ document.getElementById("add-group").onclick = (event) => {
2177
+ event.stopPropagation();
2178
+ let name = "group";
2179
+ let n = 1;
2180
+ const groupsMap = activeEnvConfig().headerGroups;
2181
+ while (groupsMap[name + n]) n += 1;
2182
+ name = name + n;
2183
+ groupsMap[name] = [{ key: "content-type", value: "application/json" }];
2184
+ store.activeGroup = name;
2185
+ persistStore();
2186
+ renderEnvPop();
2187
+ renderMain();
2188
+ };
2189
+ document.getElementById("remove-group").onclick = (event) => {
2190
+ event.stopPropagation();
2191
+ const groupsMap = activeEnvConfig().headerGroups;
2192
+ const names = Object.keys(groupsMap || {});
2193
+ if (names.length <= 1 || !groupsMap[store.activeGroup]) return;
2194
+ delete groupsMap[store.activeGroup];
2195
+ store.activeGroup = Object.keys(groupsMap)[0] || "default";
2196
+ persistStore();
2197
+ renderEnvPop();
2198
+ renderMain();
2199
+ };
2200
+ document.getElementById("env-pop").querySelectorAll("[data-var]").forEach((row) => {
2201
+ row.querySelectorAll("input").forEach((input) => {
2202
+ input.oninput = () => {
2203
+ const index = Number(row.dataset.var);
2204
+ const field = input.dataset.field;
2205
+ if (!activeEnvConfig().variables[index] || (field !== "key" && field !== "value")) return;
2206
+ activeEnvConfig().variables[index][field] = input.value;
2207
+ persistStore();
2208
+ syncEnvTrigger();
2209
+ if (field === "value" && activeEnvConfig().variables[index].key === "baseUrl") renderMain();
2210
+ };
2211
+ input.onchange = () => renderMain();
2212
+ });
2213
+ });
2214
+ document.getElementById("env-pop").querySelectorAll("[data-remove-var]").forEach((button) => {
2215
+ button.onclick = (event) => {
2216
+ event.stopPropagation();
2217
+ activeEnvConfig().variables.splice(Number(button.dataset.removeVar), 1);
2218
+ persistStore();
2219
+ renderEnvPop();
2220
+ renderMain();
2221
+ };
2222
+ });
2223
+ document.getElementById("add-var").onclick = (event) => {
2224
+ event.stopPropagation();
2225
+ activeEnvConfig().variables.push({ key: "", value: "" });
2226
+ persistStore();
2227
+ renderEnvPop();
2228
+ };
2229
+ document.getElementById("env-pop").querySelectorAll("[data-hdr]").forEach((row) => {
2230
+ row.querySelectorAll("input").forEach((input) => {
2231
+ input.oninput = () => {
2232
+ const index = Number(row.dataset.hdr);
2233
+ const field = input.dataset.field;
2234
+ const rows = activeEnvConfig().headerGroups[store.activeGroup] || [];
2235
+ if (!rows[index] || (field !== "key" && field !== "value")) return;
2236
+ rows[index][field] = input.value;
2237
+ persistStore();
2238
+ };
2239
+ input.onchange = () => renderMain();
2240
+ });
2241
+ });
2242
+ document.getElementById("env-pop").querySelectorAll("[data-remove-hdr]").forEach((button) => {
2243
+ button.onclick = (event) => {
2244
+ event.stopPropagation();
2245
+ (activeEnvConfig().headerGroups[store.activeGroup] || []).splice(Number(button.dataset.removeHdr), 1);
2246
+ persistStore();
2247
+ renderEnvPop();
2248
+ renderMain();
2249
+ };
2250
+ });
2251
+ document.getElementById("add-hdr").onclick = (event) => {
2252
+ event.stopPropagation();
2253
+ const groupsMap = activeEnvConfig().headerGroups;
2254
+ groupsMap[store.activeGroup] = groupsMap[store.activeGroup] || [];
2255
+ groupsMap[store.activeGroup].push({ key: "", value: "" });
2256
+ persistStore();
2257
+ renderEnvPop();
2258
+ };
2259
+ };
2260
+
2261
+ document.title = title ? "DAxTA · " + title : "DAxTA";
2262
+ const brandEl = document.getElementById("brand");
2263
+ if (brandEl) brandEl.textContent = title;
2264
+ const specVersion = (spec.info && spec.info.version) || "";
2265
+ const navVersion = document.getElementById("nav-version");
2266
+ if (navVersion) navVersion.textContent = specVersion ? (specVersion.startsWith("v") ? specVersion : "v" + specVersion) : "";
2267
+
2268
+ const envWrap = document.getElementById("env-wrap");
2269
+ document.getElementById("env-trigger").addEventListener("click", (event) => {
2270
+ event.stopPropagation();
2271
+ envWrap.classList.toggle("open");
2272
+ if (envWrap.classList.contains("open")) renderEnvPop();
2273
+ });
2274
+ document.getElementById("env-pop").addEventListener("click", (event) => event.stopPropagation());
2275
+ renderEnvPop();
2276
+
2277
+ const VIEWER_EXTENSIONS = new Set(["x-viewer", "x-docs", "x-scenarios", "x-tree-segments", "x-workspace"]);
2278
+ const HTTP_EXPORT = ["get", "post", "put", "patch", "delete", "options", "head", "trace"];
2279
+
2280
+ const stripExt = (value) => {
2281
+ if (Array.isArray(value)) return value.map(stripExt);
2282
+ if (!value || typeof value !== "object") return value;
2283
+ const out = {};
2284
+ for (const [key, child] of Object.entries(value)) {
2285
+ if (VIEWER_EXTENSIONS.has(key)) continue;
2286
+ out[key] = stripExt(child);
2287
+ }
2288
+ return out;
2289
+ };
2290
+
2291
+ /** Path keys follow sidebar tree; real URL kept on x-daxta-url-path when remapped. */
2292
+ const exportPathFromTree = (urlPath, treeSegments) => {
2293
+ const originalParts = urlPath.split("/").filter(Boolean);
2294
+ const paramIdx = originalParts.findIndex((part) => String(part).startsWith("{"));
2295
+ const tail = paramIdx >= 0 ? originalParts.slice(paramIdx) : [];
2296
+ const treeHasParam = treeSegments.some((part) => String(part).startsWith("{"));
2297
+ const parts =
2298
+ treeSegments.length === 0
2299
+ ? originalParts
2300
+ : treeHasParam || paramIdx < 0
2301
+ ? treeSegments
2302
+ : [...treeSegments, ...tail];
2303
+ return "/" + parts.join("/");
2304
+ };
2305
+
2306
+ const listOperationExamples = (operation) => {
2307
+ const byKey = new Map();
2308
+ const add = (key, summary) => {
2309
+ if (!key || byKey.has(key)) return;
2310
+ byKey.set(key, { key, summary: summary || key });
2311
+ };
2312
+ const reqExamples = operation?.requestBody?.content?.["application/json"]?.examples;
2313
+ for (const [key, example] of Object.entries(reqExamples || {})) {
2314
+ add(key, example && example.summary);
2315
+ }
2316
+ for (const response of Object.values(operation?.responses || {})) {
2317
+ const examples = response?.content?.["application/json"]?.examples;
2318
+ for (const [key, example] of Object.entries(examples || {})) {
2319
+ add(key, example && example.summary);
2320
+ }
2321
+ }
2322
+ return [...byKey.values()];
2323
+ };
2324
+
2325
+ const filterExamplesMap = (examples, allowedKeys) => {
2326
+ if (!examples || typeof examples !== "object") return examples;
2327
+ if (!allowedKeys) return examples;
2328
+ const out = {};
2329
+ for (const [key, value] of Object.entries(examples)) {
2330
+ if (allowedKeys.has(key)) out[key] = value;
2331
+ }
2332
+ return out;
2333
+ };
2334
+
2335
+ const filterOperationExamples = (operation, allowedKeys) => {
2336
+ if (!allowedKeys) return operation;
2337
+ const next = { ...operation };
2338
+ if (next.requestBody?.content?.["application/json"]?.examples) {
2339
+ const media = { ...next.requestBody.content["application/json"] };
2340
+ media.examples = filterExamplesMap(media.examples, allowedKeys);
2341
+ next.requestBody = {
2342
+ ...next.requestBody,
2343
+ content: { ...next.requestBody.content, "application/json": media },
2344
+ };
2345
+ }
2346
+ if (next.responses) {
2347
+ const responses = {};
2348
+ for (const [status, response] of Object.entries(next.responses)) {
2349
+ if (!response?.content?.["application/json"]?.examples) {
2350
+ responses[status] = response;
2351
+ continue;
2352
+ }
2353
+ const media = { ...response.content["application/json"] };
2354
+ media.examples = filterExamplesMap(media.examples, allowedKeys);
2355
+ responses[status] = {
2356
+ ...response,
2357
+ content: { ...response.content, "application/json": media },
2358
+ };
2359
+ }
2360
+ next.responses = responses;
2361
+ }
2362
+ return next;
2363
+ };
2364
+
2365
+ /** Rename example map keys to scenario titles; set summary+description (Postman-friendly). */
2366
+ const promoteExampleLabels = (examples) => {
2367
+ if (!examples || typeof examples !== "object") return examples;
2368
+ const out = {};
2369
+ for (const [key, example] of Object.entries(examples)) {
2370
+ if (!example || typeof example !== "object") continue;
2371
+ const summary = String(example.summary || example.description || key).trim() || key;
2372
+ let name = summary;
2373
+ let n = 2;
2374
+ while (Object.prototype.hasOwnProperty.call(out, name)) {
2375
+ name = summary + " (" + n + ")";
2376
+ n += 1;
2377
+ }
2378
+ out[name] = {
2379
+ summary,
2380
+ description: summary,
2381
+ value: example.value,
2382
+ };
2383
+ }
2384
+ return out;
2385
+ };
2386
+
2387
+ const promoteOperationExampleLabels = (operation) => {
2388
+ const next = { ...operation };
2389
+ if (next.requestBody?.content?.["application/json"]?.examples) {
2390
+ const media = { ...next.requestBody.content["application/json"] };
2391
+ media.examples = promoteExampleLabels(media.examples);
2392
+ next.requestBody = {
2393
+ ...next.requestBody,
2394
+ content: { ...next.requestBody.content, "application/json": media },
2395
+ };
2396
+ }
2397
+ if (next.responses) {
2398
+ const responses = {};
2399
+ for (const [status, response] of Object.entries(next.responses)) {
2400
+ const examples = response?.content?.["application/json"]?.examples;
2401
+ if (!examples) {
2402
+ responses[status] = response;
2403
+ continue;
2404
+ }
2405
+ const media = { ...response.content["application/json"] };
2406
+ media.examples = promoteExampleLabels(examples);
2407
+ const labels = Object.keys(media.examples);
2408
+ responses[status] = {
2409
+ ...response,
2410
+ // Single example: description becomes the scenario title (Postman uses this as the example name).
2411
+ description: labels.length === 1 ? labels[0] : response.description || status,
2412
+ content: { ...response.content, "application/json": media },
2413
+ };
2414
+ }
2415
+ next.responses = responses;
2416
+ }
2417
+ return next;
2418
+ };
2419
+
2420
+ const toExportSpec = (source, selectedByOpId) => {
2421
+ const pathsIn = source.paths || {};
2422
+ const pathsOut = {};
2423
+ const tagNames = new Set();
2424
+
2425
+ for (const [urlPath, pathItem] of Object.entries(pathsIn)) {
2426
+ if (!pathItem || typeof pathItem !== "object") continue;
2427
+
2428
+ let treeSegments = null;
2429
+ for (const [method, operation] of Object.entries(pathItem)) {
2430
+ if (!HTTP_EXPORT.includes(method) || !operation || typeof operation !== "object") continue;
2431
+ treeSegments = operation["x-tree-segments"] || urlPath.split("/").filter(Boolean);
2432
+ break;
2433
+ }
2434
+ if (!treeSegments) treeSegments = urlPath.split("/").filter(Boolean);
2435
+
2436
+ const exportPath = exportPathFromTree(urlPath, treeSegments);
2437
+ const itemOut = { ...(pathsOut[exportPath] || {}) };
2438
+
2439
+ for (const [method, operation] of Object.entries(pathItem)) {
2440
+ if (!HTTP_EXPORT.includes(method) || !operation || typeof operation !== "object") {
2441
+ if (!HTTP_EXPORT.includes(method) && itemOut[method] === undefined) {
2442
+ itemOut[method] = stripExt(operation);
2443
+ }
2444
+ continue;
2445
+ }
2446
+ const segments = operation["x-tree-segments"] || urlPath.split("/").filter(Boolean);
2447
+ let cleaned = stripExt(operation);
2448
+ const opId = method + ":" + urlPath;
2449
+ if (selectedByOpId && selectedByOpId.has(opId)) {
2450
+ cleaned = filterOperationExamples(cleaned, selectedByOpId.get(opId));
2451
+ }
2452
+ cleaned = promoteOperationExampleLabels(cleaned);
2453
+ const tagParts = segments.filter((part) => !String(part).startsWith("{"));
2454
+ const tag = tagParts.length ? tagParts.join(" / ") : "API";
2455
+ cleaned.tags = [tag];
2456
+ cleaned["x-tree-segments"] = segments;
2457
+ tagNames.add(tag);
2458
+ if (exportPath !== urlPath) cleaned["x-daxta-url-path"] = urlPath;
2459
+ itemOut[method] = cleaned;
2460
+ }
2461
+ pathsOut[exportPath] = itemOut;
2462
+ }
2463
+
2464
+ const ordered = {};
2465
+ for (const key of Object.keys(pathsOut).sort((a, b) => a.localeCompare(b))) ordered[key] = pathsOut[key];
2466
+
2467
+ return {
2468
+ openapi: source.openapi || "3.0.3",
2469
+ info: stripExt(source.info) || { title: title, version: "0.0.0" },
2470
+ ...(source.servers ? { servers: stripExt(source.servers) } : {}),
2471
+ tags: [...tagNames].sort((a, b) => a.localeCompare(b)).map((name) => ({ name })),
2472
+ paths: ordered,
2473
+ ...(source.components ? { components: stripExt(source.components) } : {}),
2474
+ };
2475
+ };
2476
+
2477
+ const headerRowsForExport = () => {
2478
+ const env = activeEnvConfig();
2479
+ const groups = env.headerGroups || {};
2480
+ return groups[store.activeGroup] || groups[Object.keys(groups)[0]] || [];
2481
+ };
2482
+
2483
+ const buildPostmanEnvironment = () => {
2484
+ const env = activeEnvConfig();
2485
+ const values = (env.variables || [])
2486
+ .filter((row) => row.key)
2487
+ .map((row) => ({
2488
+ key: row.key,
2489
+ value: String(row.value ?? ""),
2490
+ type: "default",
2491
+ enabled: true,
2492
+ }));
2493
+ // Ensure header template vars referenced as {{x}} appear even if missing from variables list.
2494
+ const known = new Set(values.map((row) => row.key));
2495
+ if (!known.has("baseUrl")) {
2496
+ known.add("baseUrl");
2497
+ values.unshift({
2498
+ key: "baseUrl",
2499
+ value: String(presetBaseUrl(store.activeEnv) || defaultBaseUrl || ""),
2500
+ type: "default",
2501
+ enabled: true,
2502
+ });
2503
+ }
2504
+ for (const row of headerRowsForExport()) {
2505
+ const text = String(row.value || "");
2506
+ const matches = text.matchAll(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g);
2507
+ for (const match of matches) {
2508
+ if (known.has(match[1])) continue;
2509
+ known.add(match[1]);
2510
+ values.push({ key: match[1], value: "", type: "default", enabled: true });
2511
+ }
2512
+ }
2513
+ return {
2514
+ id: typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : String(Date.now()),
2515
+ name: (workspace || title || "DAxTA") + " · " + store.activeEnv,
2516
+ values,
2517
+ _postman_variable_scope: "environment",
2518
+ _postman_exported_at: new Date().toISOString(),
2519
+ _postman_exported_using: "DAxTA",
2520
+ };
2521
+ };
2522
+
2523
+ const STATUS_EXPORT = {
2524
+ 200: "OK",
2525
+ 201: "Created",
2526
+ 204: "No Content",
2527
+ 400: "Bad Request",
2528
+ 401: "Unauthorized",
2529
+ 403: "Forbidden",
2530
+ 404: "Not Found",
2531
+ 409: "Conflict",
2532
+ 422: "Unprocessable Entity",
2533
+ 500: "Internal Server Error",
2534
+ };
2535
+
2536
+ const postmanUrlFromPath = (serverUrl, pathTemplate) => {
2537
+ const base = String(serverUrl || "{{baseUrl}}").replace(/\/$/, "");
2538
+ const path = String(pathTemplate || "/");
2539
+ const segments = path.split("/").filter(Boolean);
2540
+ const pathParams = [...path.matchAll(/\{([^}]+)\}/g)].map((m) => m[1]);
2541
+ return {
2542
+ raw: base + (path.startsWith("/") ? path : "/" + path),
2543
+ host: base.startsWith("{{") ? [base] : [base.replace(/^https?:\/\//, "").split("/")[0]],
2544
+ path: segments.map((seg) => (seg.startsWith("{") && seg.endsWith("}") ? ":" + seg.slice(1, -1) : seg)),
2545
+ variable: pathParams.map((key) => ({ key, value: "" })),
2546
+ };
2547
+ };
2548
+
2549
+ const collectionFolderSegments = (urlPath, operation) => {
2550
+ const fromTree = operation && operation["x-tree-segments"];
2551
+ const parts = Array.isArray(fromTree) && fromTree.length
2552
+ ? fromTree.map(String)
2553
+ : String(urlPath || "").split("/").filter(Boolean);
2554
+ const named = parts.filter((part) => part && !part.startsWith("{"));
2555
+ return named.length ? named : ["API"];
2556
+ };
2557
+
2558
+ const pushIntoFolderTree = (root, segments, requestItem) => {
2559
+ let level = root;
2560
+ for (let index = 0; index < segments.length; index += 1) {
2561
+ const name = segments[index];
2562
+ let folder = level.find((entry) => entry && entry.name === name && Array.isArray(entry.item) && !entry.request);
2563
+ if (!folder) {
2564
+ folder = { name, item: [] };
2565
+ level.push(folder);
2566
+ }
2567
+ if (index === segments.length - 1) folder.item.push(requestItem);
2568
+ else level = folder.item;
2569
+ }
2570
+ };
2571
+
2572
+ const sortCollectionTree = (items) => {
2573
+ const folders = items.filter((entry) => entry && Array.isArray(entry.item) && !entry.request);
2574
+ const requests = items.filter((entry) => entry && entry.request);
2575
+ folders.sort((left, right) => String(left.name).localeCompare(String(right.name)));
2576
+ for (const folder of folders) folder.item = sortCollectionTree(folder.item);
2577
+ requests.sort((left, right) => String(left.name).localeCompare(String(right.name)));
2578
+ return [...folders, ...requests];
2579
+ };
2580
+
2581
+ const collectionRequestHeaders = (operation, includeTryIt) => {
2582
+ const byLower = new Map();
2583
+ const add = (key, value) => {
2584
+ if (!key) return;
2585
+ const lower = String(key).toLowerCase();
2586
+ if (lower === "host" || lower === "content-length") return;
2587
+ byLower.set(lower, { key, value: value != null ? String(value) : "", type: "text" });
2588
+ };
2589
+ for (const param of operation.parameters || []) {
2590
+ if (param && param.in === "header" && param.name) add(param.name, param.example != null ? param.example : "");
2591
+ }
2592
+ if (includeTryIt) {
2593
+ for (const row of headerRowsForExport()) add(row.key, row.value ?? "");
2594
+ }
2595
+ return [...byLower.values()];
2596
+ };
2597
+
2598
+ /**
2599
+ * Postman Collection v2.1 — nested folders + named examples.
2600
+ * When includeTryIt, requests use {{baseUrl}} and the active header group; env file is downloaded separately.
2601
+ */
2602
+ const buildPostmanCollection = (openapi, includeTryIt) => {
2603
+ const specServer = (openapi.servers && openapi.servers[0] && openapi.servers[0].url) || "{{baseUrl}}";
2604
+ const serverUrl = includeTryIt ? "{{baseUrl}}" : specServer;
2605
+ const root = [];
2606
+
2607
+ for (const [urlPath, pathItem] of Object.entries(openapi.paths || {})) {
2608
+ if (!pathItem || typeof pathItem !== "object") continue;
2609
+ for (const method of HTTP_EXPORT) {
2610
+ const operation = pathItem[method];
2611
+ if (!operation || typeof operation !== "object") continue;
2612
+ const requestPath = operation["x-daxta-url-path"] || urlPath;
2613
+ const requestHeaders = collectionRequestHeaders(operation, includeTryIt);
2614
+
2615
+ const reqExamples = operation.requestBody?.content?.["application/json"]?.examples || {};
2616
+ const firstReq = Object.values(reqExamples)[0];
2617
+ const defaultBody =
2618
+ firstReq && firstReq.value !== undefined
2619
+ ? typeof firstReq.value === "string"
2620
+ ? firstReq.value
2621
+ : JSON.stringify(firstReq.value, null, 2)
2622
+ : undefined;
2623
+
2624
+ const baseRequest = {
2625
+ method: method.toUpperCase(),
2626
+ header: requestHeaders,
2627
+ url: postmanUrlFromPath(serverUrl, requestPath),
2628
+ description: operation.summary || "",
2629
+ };
2630
+ if (defaultBody !== undefined) {
2631
+ baseRequest.body = { mode: "raw", raw: defaultBody, options: { raw: { language: "json" } } };
2632
+ if (!requestHeaders.some((h) => String(h.key).toLowerCase() === "content-type")) {
2633
+ baseRequest.header = [...requestHeaders, { key: "Content-Type", value: "application/json", type: "text" }];
2634
+ }
2635
+ }
2636
+
2637
+ const responses = [];
2638
+ for (const [status, response] of Object.entries(operation.responses || {})) {
2639
+ const examples = response?.content?.["application/json"]?.examples || {};
2640
+ const entries = Object.entries(examples);
2641
+ if (!entries.length) {
2642
+ responses.push({
2643
+ name: response.description || STATUS_EXPORT[status] || status,
2644
+ originalRequest: baseRequest,
2645
+ status: STATUS_EXPORT[status] || response.description || status,
2646
+ code: Number(status) || 0,
2647
+ _postman_previewlanguage: "json",
2648
+ header: [{ key: "Content-Type", value: "application/json" }],
2649
+ body: "",
2650
+ });
2651
+ continue;
2652
+ }
2653
+ for (const [exKey, example] of entries) {
2654
+ const name = (example && (example.summary || example.description)) || exKey;
2655
+ const reqMatch = reqExamples[exKey] || reqExamples[name] || firstReq;
2656
+ const requestForExample = { ...baseRequest, header: [...(baseRequest.header || [])] };
2657
+ if (reqMatch && reqMatch.value !== undefined) {
2658
+ const raw =
2659
+ typeof reqMatch.value === "string" ? reqMatch.value : JSON.stringify(reqMatch.value, null, 2);
2660
+ requestForExample.body = { mode: "raw", raw, options: { raw: { language: "json" } } };
2661
+ }
2662
+ const bodyValue = example && example.value !== undefined ? example.value : "";
2663
+ responses.push({
2664
+ name,
2665
+ originalRequest: requestForExample,
2666
+ status: STATUS_EXPORT[status] || String(status),
2667
+ code: Number(status) || 0,
2668
+ _postman_previewlanguage: "json",
2669
+ header: [{ key: "Content-Type", value: "application/json" }],
2670
+ body: typeof bodyValue === "string" ? bodyValue : JSON.stringify(bodyValue, null, 2),
2671
+ });
2672
+ }
2673
+ }
2674
+
2675
+ pushIntoFolderTree(root, collectionFolderSegments(urlPath, operation), {
2676
+ name: operation.summary || method.toUpperCase() + " " + requestPath,
2677
+ request: baseRequest,
2678
+ response: responses,
2679
+ });
2680
+ }
2681
+ }
2682
+
2683
+ const item = sortCollectionTree(root);
2684
+
2685
+ return {
2686
+ info: {
2687
+ _postman_id: typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : String(Date.now()),
2688
+ name: (openapi.info && openapi.info.title) || workspace || title || "DAxTA",
2689
+ description: (openapi.info && openapi.info.description) || "Exported from DAxTA with named examples",
2690
+ schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
2691
+ },
2692
+ item,
2693
+ };
2694
+ };
2695
+
2696
+ const closeExportModal = () => {
2697
+ document.body.classList.remove("exporting");
2698
+ };
2699
+
2700
+ const syncExportTryItUi = () => {
2701
+ const meta = document.getElementById("export-tryit-meta");
2702
+ if (meta) meta.textContent = store.activeEnv + " · " + store.activeGroup;
2703
+ };
2704
+
2705
+ const openExportModal = () => {
2706
+ const body = document.getElementById("export-body");
2707
+ const blocks = ops
2708
+ .map((item) => {
2709
+ const examples = listOperationExamples(item.op);
2710
+ if (!examples.length) return "";
2711
+ return `<div class="export-op" data-op="${escapeAttr(item.id)}">
2712
+ <div class="export-op-title">
2713
+ <span class="method ${item.method}">${item.method}</span>
2714
+ <span class="path" title="${escapeAttr(item.path)}">${escapeAttr(item.path)}</span>
2715
+ </div>
2716
+ ${examples
2717
+ .map(
2718
+ (example) => `<div class="export-ex">
2719
+ <input type="checkbox" id="ex-${escapeAttr(item.id)}-${escapeAttr(example.key)}" data-op="${escapeAttr(item.id)}" data-key="${escapeAttr(example.key)}" checked />
2720
+ <label for="ex-${escapeAttr(item.id)}-${escapeAttr(example.key)}">${escapeAttr(example.summary)}</label>
2721
+ </div>`,
2722
+ )
2723
+ .join("")}
2724
+ </div>`;
2725
+ })
2726
+ .filter(Boolean)
2727
+ .join("");
2728
+ body.innerHTML = blocks || `<div class="export-empty">No recorded examples yet — export will include schemas only.</div>`;
2729
+ syncExportTryItUi();
2730
+ document.body.classList.add("exporting");
2731
+ };
2732
+
2733
+ const collectSelectedExamples = () => {
2734
+ const selectedByOpId = new Map();
2735
+ document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
2736
+ const opId = input.dataset.op;
2737
+ const key = input.dataset.key;
2738
+ if (!opId || !key) return;
2739
+ if (!selectedByOpId.has(opId)) selectedByOpId.set(opId, new Set());
2740
+ if (input.checked) selectedByOpId.get(opId).add(key);
2741
+ });
2742
+ return selectedByOpId;
2743
+ };
2744
+
2745
+ const downloadJsonFile = (filename, value) => {
2746
+ const blob = new Blob([JSON.stringify(value, null, 2) + "\n"], { type: "application/json" });
2747
+ const url = URL.createObjectURL(blob);
2748
+ const link = document.createElement("a");
2749
+ link.href = url;
2750
+ link.download = filename;
2751
+ document.body.appendChild(link);
2752
+ link.click();
2753
+ link.remove();
2754
+ URL.revokeObjectURL(url);
2755
+ };
2756
+
2757
+ const exportSafeName = () =>
2758
+ String(workspace || title || "openapi")
2759
+ .toLowerCase()
2760
+ .replace(/[^a-z0-9]+/g, "-")
2761
+ .replace(/^-|-$/g, "") || "daxta";
2762
+
2763
+ const runExportDownload = () => {
2764
+ const selectedByOpId = collectSelectedExamples();
2765
+ const exported = toExportSpec(spec, selectedByOpId);
2766
+ const includeTryIt = Boolean(document.getElementById("export-include-tryit")?.checked);
2767
+ const base = exportSafeName();
2768
+
2769
+ downloadJsonFile(base + ".postman_collection.json", buildPostmanCollection(exported, includeTryIt));
2770
+ if (includeTryIt) {
2771
+ setTimeout(() => {
2772
+ downloadJsonFile(base + ".postman_environment.json", buildPostmanEnvironment());
2773
+ }, 120);
2774
+ }
2775
+ };
2776
+
2777
+ document.getElementById("export-openapi").addEventListener("click", (event) => {
2778
+ event.stopPropagation();
2779
+ openExportModal();
2780
+ });
2781
+ document.getElementById("export-cancel").addEventListener("click", closeExportModal);
2782
+ document.getElementById("export-backdrop").addEventListener("click", (event) => {
2783
+ if (event.target.id === "export-backdrop") closeExportModal();
2784
+ });
2785
+ document.getElementById("export-modal").addEventListener("click", (event) => event.stopPropagation());
2786
+ document.getElementById("export-all").addEventListener("click", () => {
2787
+ document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
2788
+ input.checked = true;
2789
+ });
2790
+ });
2791
+ document.getElementById("export-none").addEventListener("click", () => {
2792
+ document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
2793
+ input.checked = false;
2794
+ });
2795
+ });
2796
+ document.getElementById("export-success").addEventListener("click", () => {
2797
+ document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
2798
+ const label = document.querySelector(`label[for="${CSS.escape(input.id)}"]`);
2799
+ const text = label ? label.textContent || "" : "";
2800
+ input.checked = /^2\d\d\b/.test(text.trim());
2801
+ });
2802
+ });
2803
+ document.getElementById("export-confirm").addEventListener("click", () => {
2804
+ runExportDownload();
2805
+ closeExportModal();
2806
+ });
2807
+
2808
+ const HTTP = ["get", "post", "put", "patch", "delete"];
2809
+ const STATUS = { 200: "OK", 201: "Created", 204: "No Content", 400: "Bad Request", 401: "Unauthorized", 404: "Not Found", 409: "Conflict", 422: "Unprocessable Entity" };
2810
+ const GROUP_ORDER = [
2811
+ "POSITIVE CASES",
2812
+ "SEMANTIC ERROR CASES",
2813
+ "INVALID CASES",
2814
+ "OMITTED CASES",
2815
+ "SEMANTIC ERROR CASES - AUTH",
2816
+ "Other",
2817
+ ];
2818
+ const METHOD_ORDER = { get: 0, post: 1, put: 2, patch: 3, delete: 4 };
2819
+
2820
+ const ops = [];
2821
+ for (const [path, item] of Object.entries(spec.paths || {})) {
2822
+ for (const method of HTTP) {
2823
+ if (!item[method]) continue;
2824
+ ops.push({
2825
+ id: method + ":" + path,
2826
+ method,
2827
+ path,
2828
+ op: item[method],
2829
+ title: item[method].summary || path,
2830
+ docs: item[method]["x-docs"] || { fields: [] },
2831
+ scenarios: item[method]["x-scenarios"] || [],
2832
+ treeSegments: item[method]["x-tree-segments"] || path.split("/").filter(Boolean),
2833
+ });
2834
+ }
2835
+ }
2836
+
2837
+ const highlight = (value) => {
2838
+ if (value === undefined || value === null || value === "") return "";
2839
+ return JSON.stringify(value, null, 2)
2840
+ .replace(/&/g, "&amp;")
2841
+ .replace(/</g, "&lt;")
2842
+ .replace(/"([^"]+)":/g, '<span class="k">"$1"</span>:')
2843
+ .replace(/: "([^"]*)"/g, ': <span class="s">"$1"</span>')
2844
+ .replace(/: (-?\d+(?:\.\d+)?)/g, ': <span class="n">$1</span>')
2845
+ .replace(/: (true|false|null)/g, ': <span class="p">$1</span>');
2846
+ };
2847
+
2848
+ const copyBodyText = (value) => {
2849
+ if (value === undefined || value === "") return null;
2850
+ if (typeof value === "string") return value;
2851
+ return JSON.stringify(value, null, 2);
2852
+ };
2853
+
2854
+ const copyIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>`;
2855
+
2856
+ const showToast = (message) => {
2857
+ let toast = document.getElementById("toast");
2858
+ if (!toast) {
2859
+ toast = document.createElement("div");
2860
+ toast.id = "toast";
2861
+ toast.className = "toast";
2862
+ document.body.appendChild(toast);
2863
+ }
2864
+ toast.textContent = message;
2865
+ toast.classList.add("show");
2866
+ clearTimeout(showToast._timer);
2867
+ showToast._timer = setTimeout(() => toast.classList.remove("show"), 1400);
2868
+ };
2869
+
2870
+ const copy = async (text, button, label) => {
2871
+ try {
2872
+ await navigator.clipboard.writeText(text);
2873
+ if (button && button.classList.contains("icon")) {
2874
+ showToast("Kopyalandı");
2875
+ return;
2876
+ }
2877
+ const previous = button.textContent;
2878
+ button.textContent = "Copied";
2879
+ setTimeout(() => (button.textContent = label || previous), 1200);
2880
+ } catch {}
2881
+ };
2882
+
2883
+ const resolvedUrl = (item, scenario) => {
2884
+ const vars = varMap();
2885
+ let path = item.path;
2886
+ for (const [name, value] of Object.entries(scenario.pathParams || {})) {
2887
+ const fromVar = vars[name] ? String(interpolate(vars[name], vars)) : value;
2888
+ path = path.replace("{" + name + "}", encodeURIComponent(fromVar ?? ""));
2889
+ }
2890
+ const query = { ...(scenario.query || {}) };
2891
+ for (const key of Object.keys(query)) {
2892
+ if (vars[key]) query[key] = String(interpolate(vars[key], vars));
2893
+ }
2894
+ const qs = new URLSearchParams(query).toString();
2895
+ return currentBaseUrl() + path + (qs ? "?" + qs : "");
2896
+ };
2897
+
2898
+ /**
2899
+ * Active Try-it header group wins: switching the group at the top overwrites
2900
+ * the example request headers (Send + cURL + Headers panel).
2901
+ * If the group is empty, fall back to what was recorded.
2902
+ */
2903
+ const requestHeadersForScenario = (scenario) => {
2904
+ const vars = varMap();
2905
+ const envHeaders = resolvedHeaders();
2906
+ if (Object.keys(envHeaders).length) {
2907
+ const out = {};
2908
+ for (const [name, value] of Object.entries(envHeaders)) {
2909
+ out[name] = String(interpolate(value, vars));
2910
+ }
2911
+ return out;
2912
+ }
2913
+ const recorded = { ...(scenario.headers || {}) };
2914
+ const out = {};
2915
+ for (const [name, value] of Object.entries(recorded)) {
2916
+ out[name] = String(interpolate(value, vars));
2917
+ }
2918
+ return out;
2919
+ };
2920
+
2921
+ const toCurl = (item, scenario) => {
2922
+ const headers = requestHeadersForScenario(scenario);
2923
+ const body = scenario.reqBody !== undefined ? interpolate(scenario.reqBody, varMap()) : undefined;
2924
+ const lines = ["curl -X " + item.method.toUpperCase() + " '" + resolvedUrl(item, scenario).replace(/'/g, "'\\''") + "'"];
2925
+ for (const [name, value] of Object.entries(headers)) {
2926
+ lines.push(" -H '" + name + ": " + String(value).replace(/'/g, "'\\''") + "'");
2927
+ }
2928
+ if (body !== undefined && item.method !== "get") {
2929
+ lines.push(" -d '" + JSON.stringify(body, null, 2).replace(/'/g, "'\\''") + "'");
2930
+ }
2931
+ return lines.join(" \\\n");
2932
+ };
2933
+
2934
+ const proxyUrl = (target) => {
2935
+ try {
2936
+ const absolute = new URL(target, location.href);
2937
+ if (absolute.origin === location.origin) return absolute.href;
2938
+ } catch {}
2939
+ if (location.protocol === "http:" || location.protocol === "https:") {
2940
+ return "/__proxy?target=" + encodeURIComponent(target);
2941
+ }
2942
+ return target;
2943
+ };
2944
+
2945
+ const sendRequest = async (item, scenario) => {
2946
+ const target = resolvedUrl(item, scenario);
2947
+ const headers = { ...requestHeadersForScenario(scenario) };
2948
+ const body = scenario.reqBody !== undefined ? interpolate(scenario.reqBody, varMap()) : undefined;
2949
+ if (body !== undefined && !headers["content-type"] && !headers["Content-Type"]) {
2950
+ headers["content-type"] = "application/json";
2951
+ }
2952
+ const init = {
2953
+ method: item.method.toUpperCase(),
2954
+ headers,
2955
+ };
2956
+ if (body !== undefined && item.method !== "get" && item.method !== "head") {
2957
+ init.body = typeof body === "string" ? body : JSON.stringify(body);
2958
+ }
2959
+ const started = performance.now();
2960
+ const response = await fetch(proxyUrl(target), init);
2961
+ const text = await response.text();
2962
+ const ms = Math.max(1, Math.round(performance.now() - started));
2963
+ let parsed = text;
2964
+ try {
2965
+ parsed = text ? JSON.parse(text) : undefined;
2966
+ } catch {
2967
+ parsed = text;
2968
+ }
2969
+ return { status: response.status, body: parsed, ok: response.ok, ms, bytes: text.length };
2970
+ };
2971
+
2972
+ const groupScenarios = (scenarios) => {
2973
+ const groups = {};
2974
+ (scenarios || []).forEach((scenario, index) => {
2975
+ const group = scenario.group || "Other";
2976
+ (groups[group] ||= []).push({ scenario, index });
2977
+ });
2978
+ const order = GROUP_ORDER.filter((name) => groups[name]).concat(
2979
+ Object.keys(groups).filter((name) => !GROUP_ORDER.includes(name)),
2980
+ );
2981
+ return { groups, order };
2982
+ };
2983
+
2984
+ const GROUP_LABEL = {
2985
+ "POSITIVE CASES": "Positive cases",
2986
+ "SEMANTIC ERROR CASES": "False positive cases",
2987
+ "INVALID CASES": "Invalid cases",
2988
+ "OMITTED CASES": "Omitted cases",
2989
+ "SEMANTIC ERROR CASES - AUTH": "False positive cases — Auth",
2990
+ Other: "Other",
2991
+ };
2992
+
2993
+ const displayGroup = (group) => GROUP_LABEL[group] || group || "Other";
2994
+ const groupTone = (label) => (String(label).toLowerCase() === "positive cases" ? "ok" : "err");
2995
+ const statusOk = (status) => Number(status) >= 200 && Number(status) < 300;
2996
+
2997
+ const groupedDropdown = (scenarios, selected) => {
2998
+ const { groups, order } = groupScenarios(scenarios);
2999
+ const current = scenarios[selected];
3000
+ const q = exampleQuery.trim().toLowerCase();
3001
+ const kind = current ? displayGroup(current.group) : "";
3002
+ const ok = current ? statusOk(current.status) : false;
3003
+ return `<div class="dd ${exampleOpen ? "open" : ""}" id="scenario-dd">
3004
+ <button type="button" class="dd-toggle" id="scenario-toggle">
3005
+ <span class="dd-kicker">Example</span>
3006
+ <span class="dd-status ${ok ? "ok" : "err"}">${escapeHtml(String(current?.status ?? ""))}</span>
3007
+ <span class="dd-kind">${escapeHtml(kind)}</span>
3008
+ <span class="dd-toggle-label">${escapeHtml(current?.name || "Example")}</span>
3009
+ </button>
3010
+ <div class="dd-menu">
3011
+ <input class="dd-search" id="example-search" placeholder="Search examples..." value="${escapeAttr(exampleQuery)}" autocomplete="off" spellcheck="false" />
3012
+ <div class="dd-list">${order
3013
+ .map((group) => {
3014
+ const rows = groups[group].filter(({ scenario }) => {
3015
+ if (!q) return true;
3016
+ return (String(scenario.status) + " " + (scenario.name || "") + " " + (scenario.group || "")).toLowerCase().includes(q);
3017
+ });
3018
+ if (!rows.length) return "";
3019
+ const label = displayGroup(group);
3020
+ return `<div class="dd-group ${groupTone(label)}"><span>${escapeHtml(label)} (${rows.length})</span></div>` +
3021
+ rows
3022
+ .map(
3023
+ ({ scenario, index }) =>
3024
+ `<button type="button" class="dd-item ${index === selected ? "on" : ""}" data-index="${index}"><span class="st ${statusOk(scenario.status) ? "ok" : "err"}">${escapeHtml(String(scenario.status))}</span><span>${escapeHtml(scenario.name)}</span></button>`,
3025
+ )
3026
+ .join("");
3027
+ })
3028
+ .join("")}</div>
3029
+ </div>
3030
+ </div>`;
3031
+ };
3032
+
3033
+ let currentId = ops[0]?.id;
3034
+ let scenarioIndex = 0;
3035
+ let navQuery = "";
3036
+ let exampleQuery = "";
3037
+ let exampleOpen = false;
3038
+ let jsonMode = { req: "pretty", res: "pretty" };
3039
+ const treePathSegments = (item) => item.treeSegments || item.path.split("/").filter(Boolean);
3040
+ const apiVersions = [...new Set(ops.map((item) => treePathSegments(item)[0]).filter(Boolean))];
3041
+ let activeVersion = apiVersions[0] || "";
3042
+ const expandedFolders = new Set(apiVersions.map((version) => "/" + version));
3043
+ const expandedExampleOps = new Set();
3044
+
3045
+ const scenarioNavLabel = (scenario) => {
3046
+ const status = scenario.status != null ? String(scenario.status) : "";
3047
+ const name = scenario.name || "example";
3048
+ return status ? status + " " + name : name;
3049
+ };
3050
+
3051
+ const renderNavExamples = (item) => {
3052
+ const { groups, order } = groupScenarios(item.scenarios);
3053
+ return `<div class="nav-examples">${order
3054
+ .map(
3055
+ (group) => `<div class="nav-ex-group">
3056
+ <div class="nav-ex-group-label"><span>${escapeHtml(displayGroup(group))}</span><span class="nav-ex-count">${groups[group].length}</span></div>
3057
+ ${groups[group]
3058
+ .map(
3059
+ ({ scenario, index }) =>
3060
+ `<button type="button" class="nav-example ${item.id === currentId && index === scenarioIndex ? "on" : ""}" data-id="${escapeAttr(item.id)}" data-scenario="${index}" title="${escapeAttr(scenarioNavLabel(scenario))}">${escapeHtml(scenarioNavLabel(scenario))}</button>`,
3061
+ )
3062
+ .join("")}
3063
+ </div>`,
3064
+ )
3065
+ .join("")}</div>`;
3066
+ };
3067
+
3068
+ const kv = (label, value) => {
3069
+ if (value === undefined || value === "") return "";
3070
+ const shown = typeof value === "object" ? JSON.stringify(value) : String(value);
3071
+ return `<div class="kv" title="${escapeAttr(label)}: ${escapeAttr(shown)}"><div class="kname">${label}</div><div class="kval">${shown}</div></div>`;
3072
+ };
3073
+
3074
+ const metaBlock = (title, bodyHtml, source = "", { always = false } = {}) => {
3075
+ if (!always && !bodyHtml) return "";
3076
+ return `<div class="meta-block">
3077
+ <div class="meta-toolbar">
3078
+ <span class="meta-label">${title}</span>
3079
+ ${source ? `<span class="meta-source">${source}</span>` : ""}
3080
+ </div>
3081
+ ${bodyHtml || `<div class="meta-empty">—</div>`}
3082
+ </div>`;
3083
+ };
3084
+
3085
+ const buildPathTree = (items) => {
3086
+ const root = { children: {}, ops: [] };
3087
+ for (const item of items) {
3088
+ const parts = treePathSegments(item);
3089
+ let node = root;
3090
+ for (let index = 0; index < parts.length; index += 1) {
3091
+ const part = parts[index];
3092
+ node.children[part] ??= { children: {}, ops: [] };
3093
+ node = node.children[part];
3094
+ if (index === parts.length - 1) node.ops.push(item);
3095
+ }
3096
+ }
3097
+ return root;
3098
+ };
3099
+
3100
+ const expandPathToItem = (item) => {
3101
+ const parts = treePathSegments(item);
3102
+ let prefix = "";
3103
+ for (const part of parts) {
3104
+ prefix += "/" + part;
3105
+ expandedFolders.add(prefix);
3106
+ }
3107
+ };
3108
+
3109
+ const collectVisibleItems = (node) => {
3110
+ const items = [...node.ops];
3111
+ for (const child of Object.values(node.children)) items.push(...collectVisibleItems(child));
3112
+ return items;
3113
+ };
3114
+
3115
+ const renderTreeNode = (node, prefix = "", q = "") => {
3116
+ const opsHtml = [...node.ops]
3117
+ .sort((left, right) => (METHOD_ORDER[left.method] ?? 99) - (METHOD_ORDER[right.method] ?? 99))
3118
+ .map((item) => {
3119
+ const hasExamples = Array.isArray(item.scenarios) && item.scenarios.length > 0;
3120
+ const examplesOpen = expandedExampleOps.has(item.id);
3121
+ const exampleCount = hasExamples ? item.scenarios.length : 0;
3122
+ return `<div class="nav-op ${item.id === currentId ? "active" : ""} ${examplesOpen ? "examples-open" : ""}" data-op-id="${escapeAttr(item.id)}">
3123
+ <div class="nav-op-row">
3124
+ <button type="button" class="nav-item" data-id="${escapeAttr(item.id)}" title="${escapeAttr(item.path)}">
3125
+ <span class="method ${item.method}">${item.method}</span>
3126
+ <span class="nav-title">${escapeAttr(item.title)}</span>
3127
+ </button>
3128
+ ${hasExamples ? `<span class="nav-ex-total" title="${exampleCount} examples">${exampleCount}</span>` : ""}
3129
+ <button type="button" class="nav-expand" data-expand-id="${escapeAttr(item.id)}" title="Examples" aria-label="Toggle examples" aria-expanded="${examplesOpen ? "true" : "false"}" ${hasExamples ? "" : "disabled"}>
3130
+ <span class="chev"></span>
3131
+ </button>
3132
+ </div>
3133
+ ${hasExamples ? renderNavExamples(item) : ""}
3134
+ </div>`;
3135
+ })
3136
+ .join("");
3137
+
3138
+ const foldersHtml = Object.entries(node.children)
3139
+ .sort(([left], [right]) => left.localeCompare(right))
3140
+ .map(([name, child]) => {
3141
+ const folderPath = (prefix ? prefix + "/" : "/") + name;
3142
+ const subtreeItems = collectVisibleItems(child);
3143
+ if (q && !subtreeItems.some((item) => (item.method + " " + item.path + " " + item.title).toLowerCase().includes(q))) return "";
3144
+ const open = q ? true : expandedFolders.has(folderPath);
3145
+ return `<div class="tree-folder ${open ? "open" : ""}" data-folder="${folderPath}">
3146
+ <button type="button" class="tree-folder-toggle" data-folder="${folderPath}">
3147
+ <span class="chev"></span>
3148
+ <span class="tree-folder-name">${name}</span>
3149
+ </button>
3150
+ <div class="tree-children">${renderTreeNode(child, folderPath, q)}</div>
3151
+ </div>`;
3152
+ })
3153
+ .join("");
3154
+
3155
+ return opsHtml + foldersHtml;
3156
+ };
3157
+
3158
+ const visibleOps = () => {
3159
+ if (!activeVersion) return ops;
3160
+ return ops.filter((item) => treePathSegments(item)[0] === activeVersion);
3161
+ };
3162
+
3163
+ const renderNav = () => {
3164
+ const nav = document.getElementById("nav");
3165
+ const q = navQuery.trim().toLowerCase();
3166
+ if (!ops.length) {
3167
+ nav.innerHTML = `<div class="tree-empty">No endpoints recorded</div>`;
3168
+ return;
3169
+ }
3170
+ if (currentId) {
3171
+ const active = ops.find((item) => item.id === currentId);
3172
+ if (active) expandPathToItem(active);
3173
+ }
3174
+ nav.innerHTML = `<div class="tree-root">${renderTreeNode(buildPathTree(visibleOps()), "", q)}</div>`;
3175
+ nav.querySelectorAll(".nav-item").forEach((button) => {
3176
+ button.onclick = () => select(button.dataset.id);
3177
+ });
3178
+ nav.querySelectorAll(".nav-expand").forEach((button) => {
3179
+ button.onclick = (event) => {
3180
+ event.stopPropagation();
3181
+ if (button.disabled) return;
3182
+ const opId = button.dataset.expandId;
3183
+ if (expandedExampleOps.has(opId)) expandedExampleOps.delete(opId);
3184
+ else expandedExampleOps.add(opId);
3185
+ const wrap = button.closest(".nav-op");
3186
+ if (wrap) {
3187
+ wrap.classList.toggle("examples-open", expandedExampleOps.has(opId));
3188
+ button.setAttribute("aria-expanded", expandedExampleOps.has(opId) ? "true" : "false");
3189
+ }
3190
+ };
3191
+ });
3192
+ nav.querySelectorAll(".nav-ex-total").forEach((badge) => {
3193
+ badge.onclick = (event) => {
3194
+ event.stopPropagation();
3195
+ const wrap = badge.closest(".nav-op");
3196
+ const opId = wrap && wrap.dataset.opId;
3197
+ if (!opId) return;
3198
+ if (expandedExampleOps.has(opId)) expandedExampleOps.delete(opId);
3199
+ else expandedExampleOps.add(opId);
3200
+ renderNav();
3201
+ };
3202
+ });
3203
+ nav.querySelectorAll(".nav-example").forEach((button) => {
3204
+ button.onclick = (event) => {
3205
+ event.stopPropagation();
3206
+ const opId = button.dataset.id;
3207
+ const index = Number(button.dataset.scenario);
3208
+ expandedExampleOps.add(opId);
3209
+ select(opId, Number.isFinite(index) ? index : 0);
3210
+ };
3211
+ });
3212
+ nav.querySelectorAll(".tree-folder-toggle").forEach((button) => {
3213
+ button.onclick = (event) => {
3214
+ event.stopPropagation();
3215
+ const folderPath = button.dataset.folder;
3216
+ const folder = button.closest(".tree-folder");
3217
+ if (expandedFolders.has(folderPath)) {
3218
+ expandedFolders.delete(folderPath);
3219
+ folder.classList.remove("open");
3220
+ } else {
3221
+ expandedFolders.add(folderPath);
3222
+ folder.classList.add("open");
3223
+ }
3224
+ };
3225
+ });
3226
+ };
3227
+
3228
+ const escapeHtml = (value) =>
3229
+ String(value ?? "")
3230
+ .replace(/&/g, "&amp;")
3231
+ .replace(/</g, "&lt;")
3232
+ .replace(/>/g, "&gt;")
3233
+ .replace(/"/g, "&quot;");
3234
+
3235
+ const highlightMatch = (text, query) => {
3236
+ const raw = String(text ?? "");
3237
+ const q = query.trim();
3238
+ if (!q) return escapeHtml(raw);
3239
+ const lower = raw.toLowerCase();
3240
+ const index = lower.indexOf(q.toLowerCase());
3241
+ if (index < 0) return escapeHtml(raw);
3242
+ return (
3243
+ escapeHtml(raw.slice(0, index)) +
3244
+ "<mark>" +
3245
+ escapeHtml(raw.slice(index, index + q.length)) +
3246
+ "</mark>" +
3247
+ escapeHtml(raw.slice(index + q.length))
3248
+ );
3249
+ };
3250
+
3251
+ let searchActiveIndex = 0;
3252
+
3253
+ const closeSearch = ({ clear = false } = {}) => {
3254
+ const wrap = document.getElementById("search-wrap");
3255
+ const input = document.getElementById("search");
3256
+ wrap.classList.remove("open");
3257
+ document.body.classList.remove("searching");
3258
+ searchActiveIndex = 0;
3259
+ if (clear) {
3260
+ input.value = "";
3261
+ navQuery = "";
3262
+ renderNav();
3263
+ }
3264
+ };
3265
+
3266
+ const openSearch = () => {
3267
+ document.getElementById("search-wrap").classList.add("open");
3268
+ document.body.classList.add("searching");
3269
+ };
3270
+
3271
+ const renderSearchPanel = (query = "") => {
3272
+ const q = query.trim().toLowerCase();
3273
+ navQuery = query;
3274
+ renderNav();
3275
+ const panel = document.getElementById("search-panel");
3276
+ if (!q) {
3277
+ closeSearch();
3278
+ panel.innerHTML = "";
3279
+ return;
3280
+ }
3281
+ openSearch();
3282
+ const matches = ops.filter((item) => (item.method + " " + item.path + " " + item.title).toLowerCase().includes(q));
3283
+ if (!matches.length) {
3284
+ panel.innerHTML = `<div class="search-empty">No matching endpoints</div>`;
3285
+ return;
3286
+ }
3287
+ if (searchActiveIndex >= matches.length) searchActiveIndex = 0;
3288
+ panel.innerHTML = matches
3289
+ .map(
3290
+ (item, index) => `<button type="button" class="search-hit ${index === searchActiveIndex ? "active" : ""}" data-id="${item.id}" role="option">
3291
+ <span class="method ${item.method}">${item.method}</span>
3292
+ <span class="search-hit-path">${highlightMatch(item.path, q)}</span>
3293
+ </button>`,
3294
+ )
3295
+ .join("");
3296
+ panel.querySelectorAll(".search-hit").forEach((button) => {
3297
+ button.onclick = (event) => {
3298
+ event.stopPropagation();
3299
+ select(button.dataset.id);
3300
+ closeSearch({ clear: true });
3301
+ };
3302
+ });
3303
+ };
3304
+
3305
+ const jsonBlock = (value, pretty) => {
3306
+ if (value === undefined) return `<div class="meta-empty">No JSON body</div>`;
3307
+ if (!pretty) {
3308
+ const raw = typeof value === "string" ? value : JSON.stringify(value);
3309
+ return `<pre>${escapeHtml(raw)}</pre>`;
3310
+ }
3311
+ return `<pre>${highlight(value)}</pre>`;
3312
+ };
3313
+
3314
+ const fieldDepth = (name) => {
3315
+ const parts = String(name || "")
3316
+ .replace(/\[\]/g, ".")
3317
+ .split(".")
3318
+ .filter(Boolean);
3319
+ return Math.max(0, parts.length - 1);
3320
+ };
3321
+
3322
+ const byteLabel = (bytes) => {
3323
+ if (!bytes) return "";
3324
+ if (bytes < 1024) return bytes + " B";
3325
+ return (bytes / 1024).toFixed(1).replace(/\.0$/, "") + " KB";
3326
+ };
3327
+
3328
+ const schemaFromValue = (value, prefix = "") => {
3329
+ const out = [];
3330
+ const walk = (node, path) => {
3331
+ if (node === null || node === undefined) {
3332
+ if (path) out.push({ name: path, type: "null" });
3333
+ return;
3334
+ }
3335
+ if (Array.isArray(node)) {
3336
+ const inner = node[0];
3337
+ const innerType = inner == null ? "unknown" : Array.isArray(inner) ? "array" : typeof inner === "object" ? "object" : typeof inner;
3338
+ out.push({ name: path, type: "array<" + innerType + ">" });
3339
+ if (inner && typeof inner === "object" && !Array.isArray(inner)) {
3340
+ for (const [key, nested] of Object.entries(inner)) walk(nested, path + "[]." + key);
3341
+ }
3342
+ return;
3343
+ }
3344
+ if (typeof node === "object") {
3345
+ if (path) out.push({ name: path, type: "object" });
3346
+ for (const [key, nested] of Object.entries(node)) walk(nested, path ? path + "." + key : key);
3347
+ return;
3348
+ }
3349
+ out.push({ name: path, type: typeof node === "number" && Number.isInteger(node) ? "integer" : typeof node });
3350
+ };
3351
+ walk(value, prefix);
3352
+ return out;
3353
+ };
3354
+
3355
+ const schemaRows = (fields, { showLoc = false } = {}) => {
3356
+ if (!fields.length) return `<div class="meta-empty">—</div>`;
3357
+ return fields
3358
+ .map((field) => {
3359
+ const depth = fieldDepth(field.name);
3360
+ const nestClass = depth ? " nested" : "";
3361
+ const depthAttr = depth ? ` data-depth="${Math.min(depth, 4)}"` : "";
3362
+ return `<div class="row">
3363
+ <div class="name${nestClass}"${depthAttr}>${escapeHtml(field.name)}</div>
3364
+ <div class="type">${escapeHtml(field.type)}${showLoc && field.in && field.in !== "body" ? " · " + escapeHtml(field.in) : ""}</div>
3365
+ ${field.required === true ? `<div class="flag req">required</div>` : field.required === false ? `<div class="flag">optional</div>` : `<div></div>`}
3366
+ </div>`;
3367
+ })
3368
+ .join("");
3369
+ };
3370
+
3371
+ const schemasInline = (fields, resBody) => {
3372
+ const requestFields = fields.filter((field) => field.in === "body" || field.in === "path" || field.in === "query" || field.in === "header");
3373
+ const responseFields = schemaFromValue(resBody);
3374
+ return {
3375
+ request: `<div class="schema-block"><span class="meta-label">Request schema</span>${schemaRows(requestFields, { showLoc: true })}</div>`,
3376
+ response: `<div class="schema-block"><span class="meta-label">Response schema</span>${schemaRows(responseFields)}</div>`,
3377
+ };
3378
+ };
3379
+
3380
+ const renderMain = () => {
3381
+ const item = ops.find((entry) => entry.id === currentId);
3382
+ if (!item) {
3383
+ document.getElementById("main").innerHTML = `<div class="empty">No operations in this workspace yet.</div>`;
3384
+ const dock = document.getElementById("ex-dock");
3385
+ if (dock) dock.innerHTML = "";
3386
+ const epName = document.getElementById("ep-name");
3387
+ if (epName) epName.textContent = "";
3388
+ return;
3389
+ }
3390
+ if (scenarioIndex >= item.scenarios.length) scenarioIndex = 0;
3391
+ const scenario = item.scenarios[scenarioIndex] || { status: 0, pathParams: {}, query: {}, headers: {}, name: "" };
3392
+ const fields = item.docs.fields || [];
3393
+ ensureRequiredHeaderGroup(item.op);
3394
+ const displayHeaders = requestHeadersForScenario(scenario);
3395
+ const recordedOk = scenario.status >= 200 && scenario.status < 300;
3396
+ const statusText = STATUS[scenario.status] || item.op.responses?.[String(scenario.status)]?.description || "";
3397
+ const emptyResponse = scenario.resBody === undefined || scenario.status === 204;
3398
+ const reqCopyText = scenario.reqBody !== undefined ? copyBodyText(scenario.reqBody) : null;
3399
+ const showingLive = liveResult && liveResult.id === item.id && liveResult.scenarioIndex === scenarioIndex;
3400
+ const displayStatus = showingLive ? liveResult.status : scenario.status;
3401
+ const displayBody = showingLive ? liveResult.body : scenario.resBody;
3402
+ const displayOk = showingLive ? liveResult.status >= 200 && liveResult.status < 300 : recordedOk;
3403
+ const displayStatusText = STATUS[displayStatus] || (showingLive ? "" : statusText);
3404
+ const displayEmpty = showingLive ? displayBody === undefined || displayBody === "" : emptyResponse;
3405
+ const resCopyText = displayEmpty ? null : copyBodyText(displayBody);
3406
+ const reqPretty = jsonMode.req !== "raw";
3407
+ const resPretty = jsonMode.res !== "raw";
3408
+ const recordedBytes = displayEmpty ? 0 : new Blob([typeof displayBody === "string" ? displayBody : JSON.stringify(displayBody)]).size;
3409
+ const bytes = showingLive && liveResult.bytes != null ? liveResult.bytes : recordedBytes;
3410
+ const ms = showingLive && liveResult.ms != null ? liveResult.ms : null;
3411
+ const headersHtml = Object.keys(displayHeaders).length
3412
+ ? Object.entries(displayHeaders).map(([name, value]) => kv(name, value)).join("")
3413
+ : `<div class="meta-empty">No headers in this header group</div>`;
3414
+ const pathParamsHtml = Object.entries(scenario.pathParams || {})
3415
+ .map(([name, value]) => kv(name, value))
3416
+ .join("");
3417
+ const queryHtml = Object.entries(scenario.query || {})
3418
+ .map(([name, value]) => kv(name, value))
3419
+ .join("");
3420
+ const bodyHtml =
3421
+ scenario.reqBody !== undefined
3422
+ ? jsonBlock(scenario.reqBody, reqPretty)
3423
+ : `<div class="meta-empty">No JSON body</div>`;
3424
+ const resHtml =
3425
+ showingLive && liveResult.error
3426
+ ? `<div class="live-err">${String(liveResult.error).replace(/&/g, "&amp;").replace(/</g, "&lt;")}</div>`
3427
+ : displayEmpty
3428
+ ? `<div class="empty">Empty body</div>`
3429
+ : jsonBlock(displayBody, resPretty);
3430
+
3431
+ const schemas = schemasInline(fields, displayEmpty ? undefined : displayBody);
3432
+ const epName = document.getElementById("ep-name");
3433
+ if (epName) epName.textContent = item.title;
3434
+ document.title = item.title + (title ? " · " + title : "");
3435
+
3436
+ document.getElementById("main").innerHTML = `
3437
+ <div class="urlbar">
3438
+ <div class="url"><span class="method ${item.method}">${item.method}</span><span>${resolvedUrl(item, scenario)}</span></div>
3439
+ <button class="btn" id="copy-curl" type="button">Copy cURL</button>
3440
+ <button class="btn primary" id="send" type="button">Send</button>
3441
+ </div>
3442
+ <div class="pair">
3443
+ <section class="card" id="request-card">
3444
+ <div class="card-head">
3445
+ <h2>Request</h2>
3446
+ <div class="card-head-actions">
3447
+ <div class="mode-toggle">
3448
+ <button type="button" data-json="req" data-mode="pretty" class="${reqPretty ? "on" : ""}">Pretty</button>
3449
+ <button type="button" data-json="req" data-mode="raw" class="${reqPretty ? "" : "on"}">Raw</button>
3450
+ </div>
3451
+ <button class="btn sm icon" id="copy-req" type="button" title="Copy body" aria-label="Copy body" ${reqCopyText ? "" : "disabled"}>${copyIcon}</button>
3452
+ </div>
3453
+ </div>
3454
+ <div class="card-body">
3455
+ ${metaBlock("Headers", headersHtml, requiredAuthHint(item.op), { always: true })}
3456
+ ${metaBlock("Path", pathParamsHtml)}
3457
+ ${metaBlock("Query", queryHtml)}
3458
+ ${metaBlock("Body", bodyHtml, "", { always: true })}
3459
+ ${schemas.request}
3460
+ </div>
3461
+ </section>
3462
+ <section class="card response-card" id="response-card">
3463
+ <div class="card-head">
3464
+ <h2>Response</h2>
3465
+ <div class="card-head-actions">
3466
+ <div class="res-meta">
3467
+ <span class="code ${displayOk ? "ok" : "err"}">${displayStatus || ""} ${escapeHtml(displayStatusText)}</span>
3468
+ ${ms != null ? `<span>${ms} ms</span>` : ""}
3469
+ ${bytes ? `<span>${byteLabel(bytes)}</span>` : ""}
3470
+ </div>
3471
+ <div class="mode-toggle">
3472
+ <button type="button" data-json="res" data-mode="pretty" class="${resPretty ? "on" : ""}">Pretty</button>
3473
+ <button type="button" data-json="res" data-mode="raw" class="${resPretty ? "" : "on"}">Raw</button>
3474
+ </div>
3475
+ <button class="btn sm icon" id="copy-res" type="button" title="Copy body" aria-label="Copy body" ${resCopyText ? "" : "disabled"}>${copyIcon}</button>
3476
+ </div>
3477
+ </div>
3478
+ <div class="card-body">
3479
+ <div id="response-body">${resHtml}</div>
3480
+ ${schemas.response}
3481
+ </div>
3482
+ </section>
3483
+ </div>
3484
+ `;
3485
+
3486
+ const dock = document.getElementById("ex-dock");
3487
+ if (dock) dock.innerHTML = item.scenarios.length ? groupedDropdown(item.scenarios, scenarioIndex) : "";
3488
+
3489
+ const scenarioToggle = document.getElementById("scenario-toggle");
3490
+ if (scenarioToggle) {
3491
+ const root = document.getElementById("scenario-dd");
3492
+ scenarioToggle.onclick = (event) => {
3493
+ event.stopPropagation();
3494
+ exampleOpen = !root.classList.contains("open");
3495
+ document.querySelectorAll(".dd.open").forEach((el) => {
3496
+ if (el !== root) el.classList.remove("open");
3497
+ });
3498
+ root.classList.toggle("open", exampleOpen);
3499
+ if (exampleOpen) document.getElementById("example-search")?.focus();
3500
+ };
3501
+ const exSearch = document.getElementById("example-search");
3502
+ if (exSearch) {
3503
+ exSearch.onclick = (event) => event.stopPropagation();
3504
+ exSearch.oninput = (event) => {
3505
+ exampleQuery = event.target.value;
3506
+ exampleOpen = true;
3507
+ const pos = event.target.selectionStart;
3508
+ renderMain();
3509
+ const next = document.getElementById("example-search");
3510
+ if (next) {
3511
+ next.focus();
3512
+ next.selectionStart = next.selectionEnd = pos;
3513
+ }
3514
+ };
3515
+ }
3516
+ root.querySelectorAll(".dd-item").forEach((button) => {
3517
+ button.onclick = (event) => {
3518
+ event.stopPropagation();
3519
+ scenarioIndex = Number(button.dataset.index);
3520
+ liveResult = null;
3521
+ exampleOpen = false;
3522
+ exampleQuery = "";
3523
+ renderNav();
3524
+ renderMain();
3525
+ };
3526
+ });
3527
+ root.onclick = (event) => event.stopPropagation();
3528
+ }
3529
+
3530
+ document.querySelectorAll("[data-json]").forEach((button) => {
3531
+ button.onclick = (event) => {
3532
+ event.stopPropagation();
3533
+ jsonMode[button.dataset.json] = button.dataset.mode;
3534
+ renderMain();
3535
+ };
3536
+ });
3537
+
3538
+ const syncResponseHeight = () => {
3539
+ const requestCard = document.getElementById("request-card");
3540
+ const responseCard = document.getElementById("response-card");
3541
+ const responseBody = document.getElementById("response-body");
3542
+ if (!requestCard || !responseCard || !responseBody) return;
3543
+ responseCard.style.maxHeight = "";
3544
+ responseBody.style.maxHeight = "";
3545
+ const requestHeight = requestCard.offsetHeight;
3546
+ const head = responseCard.querySelector(".card-head");
3547
+ const headHeight = head ? head.offsetHeight : 0;
3548
+ const maxBody = Math.max(0, requestHeight - headHeight);
3549
+ responseCard.style.maxHeight = requestHeight + "px";
3550
+ responseBody.style.maxHeight = maxBody + "px";
3551
+ };
3552
+ syncResponseHeight();
3553
+ requestAnimationFrame(syncResponseHeight);
3554
+
3555
+ document.getElementById("copy-curl").onclick = (event) => copy(toCurl(item, scenario), event.currentTarget, "Copy cURL");
3556
+ const copyReq = document.getElementById("copy-req");
3557
+ if (copyReq && reqCopyText) copyReq.onclick = (event) => copy(reqCopyText, event.currentTarget, "Copy body");
3558
+ const copyRes = document.getElementById("copy-res");
3559
+ if (copyRes && resCopyText) copyRes.onclick = (event) => copy(resCopyText, event.currentTarget, "Copy body");
3560
+
3561
+ const sendBtn = document.getElementById("send");
3562
+ if (sendBtn) {
3563
+ sendBtn.onclick = async () => {
3564
+ sendBtn.disabled = true;
3565
+ sendBtn.textContent = "Sending…";
3566
+ try {
3567
+ const result = await sendRequest(item, scenario);
3568
+ liveResult = {
3569
+ id: item.id,
3570
+ scenarioIndex,
3571
+ status: result.status,
3572
+ body: result.body,
3573
+ ms: result.ms,
3574
+ bytes: result.bytes,
3575
+ };
3576
+ } catch (error) {
3577
+ const message = error instanceof Error ? error.message : String(error);
3578
+ liveResult = {
3579
+ id: item.id,
3580
+ scenarioIndex,
3581
+ status: 0,
3582
+ body: undefined,
3583
+ error:
3584
+ message +
3585
+ "\n\nTip: open docs at the same app port: http://localhost:3000/docs",
3586
+ };
3587
+ }
3588
+ renderMain();
3589
+ };
3590
+ }
3591
+ };
3592
+
3593
+ const select = (id, nextScenarioIndex) => {
3594
+ currentId = id;
3595
+ scenarioIndex = typeof nextScenarioIndex === "number" ? nextScenarioIndex : 0;
3596
+ liveResult = null;
3597
+ exampleOpen = false;
3598
+ exampleQuery = "";
3599
+ const selected = ops.find((entry) => entry.id === id);
3600
+ if (selected) {
3601
+ syncHeaderGroupForOp(selected.op);
3602
+ const version = treePathSegments(selected)[0];
3603
+ if (version) activeVersion = version;
3604
+ expandedExampleOps.add(id);
3605
+ }
3606
+ renderNav();
3607
+ renderMain();
3608
+ history.replaceState(null, "", "#" + encodeURIComponent(id));
3609
+ };
3610
+
3611
+ const searchInput = document.getElementById("search");
3612
+ searchInput.addEventListener("input", (event) => {
3613
+ searchActiveIndex = 0;
3614
+ renderSearchPanel(event.target.value);
3615
+ });
3616
+ searchInput.addEventListener("keydown", (event) => {
3617
+ const panel = document.getElementById("search-panel");
3618
+ const hits = [...panel.querySelectorAll(".search-hit")];
3619
+ if (event.key === "Escape") {
3620
+ closeSearch({ clear: true });
3621
+ searchInput.blur();
3622
+ return;
3623
+ }
3624
+ if (!hits.length) return;
3625
+ if (event.key === "ArrowDown") {
3626
+ event.preventDefault();
3627
+ searchActiveIndex = (searchActiveIndex + 1) % hits.length;
3628
+ renderSearchPanel(searchInput.value);
3629
+ document.querySelectorAll(".search-hit")[searchActiveIndex]?.scrollIntoView({ block: "nearest" });
3630
+ } else if (event.key === "ArrowUp") {
3631
+ event.preventDefault();
3632
+ searchActiveIndex = (searchActiveIndex - 1 + hits.length) % hits.length;
3633
+ renderSearchPanel(searchInput.value);
3634
+ document.querySelectorAll(".search-hit")[searchActiveIndex]?.scrollIntoView({ block: "nearest" });
3635
+ } else if (event.key === "Enter") {
3636
+ event.preventDefault();
3637
+ const target = hits[searchActiveIndex] || hits[0];
3638
+ if (target) {
3639
+ select(target.dataset.id);
3640
+ closeSearch({ clear: true });
3641
+ }
3642
+ }
3643
+ });
3644
+ document.getElementById("search-backdrop").addEventListener("click", () => closeSearch({ clear: true }));
3645
+ document.getElementById("search-wrap").addEventListener("click", (event) => event.stopPropagation());
3646
+
3647
+ document.addEventListener("click", () => {
3648
+ exampleOpen = false;
3649
+ document.querySelectorAll(".dd.open").forEach((el) => el.classList.remove("open"));
3650
+ document.getElementById("env-wrap").classList.remove("open");
3651
+ if (document.body.classList.contains("searching")) closeSearch({ clear: true });
3652
+ });
3653
+
3654
+ document.addEventListener("keydown", (event) => {
3655
+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
3656
+ event.preventDefault();
3657
+ document.getElementById("search")?.focus();
3658
+ return;
3659
+ }
3660
+ if (event.key === "/" && !event.metaKey && !event.ctrlKey && !event.altKey) {
3661
+ const tag = (event.target && event.target.tagName) || "";
3662
+ if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT" || event.target?.isContentEditable) return;
3663
+ event.preventDefault();
3664
+ document.getElementById("search")?.focus();
3665
+ }
3666
+ });
3667
+
3668
+ const verSelect = document.getElementById("ver-select");
3669
+ if (verSelect) {
3670
+ if (!apiVersions.length) verSelect.hidden = true;
3671
+ else {
3672
+ verSelect.innerHTML = apiVersions.map((name) => `<option value="${escapeAttr(name)}">${escapeHtml(name)}</option>`).join("");
3673
+ verSelect.value = activeVersion;
3674
+ verSelect.onchange = () => {
3675
+ activeVersion = verSelect.value;
3676
+ const first = visibleOps()[0];
3677
+ if (first) select(first.id);
3678
+ else {
3679
+ renderNav();
3680
+ renderMain();
3681
+ }
3682
+ };
3683
+ }
3684
+ }
3685
+
3686
+ const initial = decodeURIComponent(location.hash.replace(/^#/, "")) || ops[0]?.id;
3687
+ select(ops.some((item) => item.id === initial) ? initial : ops[0]?.id);
3688
+
3689
+ hydrateStoreFromServer().then((loaded) => {
3690
+ if (!loaded) return;
3691
+ const selected = ops.find((entry) => entry.id === currentId);
3692
+ if (selected) syncHeaderGroupForOp(selected.op);
3693
+ syncEnvTrigger();
3694
+ if (document.getElementById("env-wrap")?.classList.contains("open")) renderEnvPop();
3695
+ renderMain();
3696
+ });
3697
+ </script>
3698
+ </body>
3699
+ </html>